From dd0ce02dfbf700764d4bd5f7109079a3acb5037c Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 7 Apr 2016 12:07:48 -0700 Subject: [PATCH 001/357] Initial Commit --- .dockerignore | 4 + .drone.yml | 4 + .gitignore | 4 + Dockerfile.dapper | 15 + LICENSE | 177 +++++++++ Makefile | 23 ++ README.md | 28 ++ main.go | 9 + package/Dockerfile | 3 + scripts/build | 9 + scripts/ci | 9 + scripts/entry | 11 + scripts/package | 14 + scripts/release | 3 + scripts/test | 10 + scripts/validate | 20 + scripts/version | 14 + trash.yml | 3 + vendor/github.com/Sirupsen/logrus/.gitignore | 1 + vendor/github.com/Sirupsen/logrus/.travis.yml | 7 + .../github.com/Sirupsen/logrus/CHANGELOG.md | 55 +++ vendor/github.com/Sirupsen/logrus/LICENSE | 21 + vendor/github.com/Sirupsen/logrus/README.md | 365 ++++++++++++++++++ vendor/github.com/Sirupsen/logrus/doc.go | 26 ++ vendor/github.com/Sirupsen/logrus/entry.go | 264 +++++++++++++ .../github.com/Sirupsen/logrus/entry_test.go | 77 ++++ vendor/github.com/Sirupsen/logrus/exported.go | 193 +++++++++ .../github.com/Sirupsen/logrus/formatter.go | 48 +++ .../Sirupsen/logrus/formatter_bench_test.go | 98 +++++ .../github.com/Sirupsen/logrus/hook_test.go | 122 ++++++ vendor/github.com/Sirupsen/logrus/hooks.go | 34 ++ .../Sirupsen/logrus/json_formatter.go | 41 ++ .../Sirupsen/logrus/json_formatter_test.go | 120 ++++++ vendor/github.com/Sirupsen/logrus/logger.go | 212 ++++++++++ vendor/github.com/Sirupsen/logrus/logrus.go | 98 +++++ .../github.com/Sirupsen/logrus/logrus_test.go | 301 +++++++++++++++ .../Sirupsen/logrus/terminal_bsd.go | 9 + .../Sirupsen/logrus/terminal_linux.go | 12 + .../Sirupsen/logrus/terminal_notwindows.go | 21 + .../Sirupsen/logrus/terminal_solaris.go | 15 + .../Sirupsen/logrus/terminal_windows.go | 27 ++ .../Sirupsen/logrus/text_formatter.go | 161 ++++++++ .../Sirupsen/logrus/text_formatter_test.go | 61 +++ vendor/github.com/Sirupsen/logrus/writer.go | 31 ++ 44 files changed, 2780 insertions(+) create mode 100644 .dockerignore create mode 100644 .drone.yml create mode 100644 .gitignore create mode 100644 Dockerfile.dapper create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.go create mode 100644 package/Dockerfile create mode 100755 scripts/build create mode 100755 scripts/ci create mode 100755 scripts/entry create mode 100755 scripts/package create mode 100755 scripts/release create mode 100755 scripts/test create mode 100755 scripts/validate create mode 100755 scripts/version create mode 100644 trash.yml create mode 100644 vendor/github.com/Sirupsen/logrus/.gitignore create mode 100644 vendor/github.com/Sirupsen/logrus/.travis.yml create mode 100644 vendor/github.com/Sirupsen/logrus/CHANGELOG.md create mode 100644 vendor/github.com/Sirupsen/logrus/LICENSE create mode 100644 vendor/github.com/Sirupsen/logrus/README.md create mode 100644 vendor/github.com/Sirupsen/logrus/doc.go create mode 100644 vendor/github.com/Sirupsen/logrus/entry.go create mode 100644 vendor/github.com/Sirupsen/logrus/entry_test.go create mode 100644 vendor/github.com/Sirupsen/logrus/exported.go create mode 100644 vendor/github.com/Sirupsen/logrus/formatter.go create mode 100644 vendor/github.com/Sirupsen/logrus/formatter_bench_test.go create mode 100644 vendor/github.com/Sirupsen/logrus/hook_test.go create mode 100644 vendor/github.com/Sirupsen/logrus/hooks.go create mode 100644 vendor/github.com/Sirupsen/logrus/json_formatter.go create mode 100644 vendor/github.com/Sirupsen/logrus/json_formatter_test.go create mode 100644 vendor/github.com/Sirupsen/logrus/logger.go create mode 100644 vendor/github.com/Sirupsen/logrus/logrus.go create mode 100644 vendor/github.com/Sirupsen/logrus/logrus_test.go create mode 100644 vendor/github.com/Sirupsen/logrus/terminal_bsd.go create mode 100644 vendor/github.com/Sirupsen/logrus/terminal_linux.go create mode 100644 vendor/github.com/Sirupsen/logrus/terminal_notwindows.go create mode 100644 vendor/github.com/Sirupsen/logrus/terminal_solaris.go create mode 100644 vendor/github.com/Sirupsen/logrus/terminal_windows.go create mode 100644 vendor/github.com/Sirupsen/logrus/text_formatter.go create mode 100644 vendor/github.com/Sirupsen/logrus/text_formatter_test.go create mode 100644 vendor/github.com/Sirupsen/logrus/writer.go diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6e43c2a9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +./bin +./.dapper +./dist +./.trash-cache diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..b0f0e2eb --- /dev/null +++ b/.drone.yml @@ -0,0 +1,4 @@ +image: rancher/dind:v1.10.0-rancher1 +script: + - wrapdocker + - make ci diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d43bb90f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.dapper +/bin +*.swp +/.trash-cache diff --git a/Dockerfile.dapper b/Dockerfile.dapper new file mode 100644 index 00000000..4a60711a --- /dev/null +++ b/Dockerfile.dapper @@ -0,0 +1,15 @@ +FROM golang:1.6 +RUN go get github.com/rancher/trash +RUN go get github.com/golang/lint/golint +RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ + chmod +x /usr/bin/docker +ENV PATH /go/bin:$PATH +ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn +ENV DAPPER_OUTPUT bin +ENV DAPPER_DOCKER_SOCKET true +ENV DAPPER_ENV TAG REPO +ENV GO15VENDOREXPERIMENT 1 +ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache +WORKDIR ${DAPPER_SOURCE} +ENTRYPOINT ["./scripts/entry"] +CMD ["ci"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,177 @@ + + 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/Makefile b/Makefile new file mode 100644 index 00000000..d7d72a16 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +TARGETS := $(shell ls scripts) + +.dapper: + @echo Downloading dapper + @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp + @@chmod +x .dapper.tmp + @./.dapper.tmp -v + @mv .dapper.tmp .dapper + +$(TARGETS): .dapper + ./.dapper $@ + +trash: .dapper + ./.dapper -m bind trash + +trash-keep: .dapper + ./.dapper -m bind trash -k + +deps: trash + +.DEFAULT_GOAL := ci + +.PHONY: $(TARGETS) diff --git a/README.md b/README.md new file mode 100644 index 00000000..49dd4da6 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +longhorn +======== + +A microservice that does micro things. + +## Building + +`make` + + +## Running + +`./bin/longhorn` + +## License +Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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/main.go b/main.go new file mode 100644 index 00000000..cca1dc75 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "github.com/Sirupsen/logrus" +) + +func main() { + logrus.Info("I'm a turkey") +} diff --git a/package/Dockerfile b/package/Dockerfile new file mode 100644 index 00000000..3922aaab --- /dev/null +++ b/package/Dockerfile @@ -0,0 +1,3 @@ +FROM ubuntu:15.10 +COPY longhorn /usr/bin/ +CMD ["longhorn"] diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..e6c78f0d --- /dev/null +++ b/scripts/build @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source $(dirname $0)/version + +cd $(dirname $0)/.. + +mkdir -p bin +go build -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn diff --git a/scripts/ci b/scripts/ci new file mode 100755 index 00000000..e6fae796 --- /dev/null +++ b/scripts/ci @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +cd $(dirname $0) + +./build +./test +./validate +./package diff --git a/scripts/entry b/scripts/entry new file mode 100755 index 00000000..486dc0fa --- /dev/null +++ b/scripts/entry @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +trap "chown -R $DAPPER_UID:$DAPPER_GID ." exit + +mkdir -p bin +if [ -e ./scripts/$1 ]; then + ./scripts/"$@" +else + "$@" +fi diff --git a/scripts/package b/scripts/package new file mode 100755 index 00000000..b08d16d4 --- /dev/null +++ b/scripts/package @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +source $(dirname $0)/version + +cd $(dirname $0)/../package + +TAG=${TAG:-${VERSION}} +REPO=${REPO:-rancher} + +cp ../bin/longhorn . +docker build -t ${REPO}/longhorn:${TAG} . + +echo Built ${REPO}/longhorn:${TAG} diff --git a/scripts/release b/scripts/release new file mode 100755 index 00000000..7af0df35 --- /dev/null +++ b/scripts/release @@ -0,0 +1,3 @@ +#!/bin/bash + +exec $(dirname $0)/ci diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..4a6795b8 --- /dev/null +++ b/scripts/test @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +cd $(dirname $0)/.. + +echo Running tests + +PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" + +go test -race -cover -tags=test ${PACKAGES} diff --git a/scripts/validate b/scripts/validate new file mode 100755 index 00000000..888c4554 --- /dev/null +++ b/scripts/validate @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +cd $(dirname $0)/.. + +echo Running validation + +PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" + +echo Running: go vet +go vet ${PACKAGES} +echo Running: golint +for i in ${PACKAGES}; do + if [ -z "$(golint $i | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then + failed=true + fi +done +test -n "$failed" +echo Running: go fmt +test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)" diff --git a/scripts/version b/scripts/version new file mode 100755 index 00000000..983b02b3 --- /dev/null +++ b/scripts/version @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ -n "$(git status --porcelain --untracked-files=no)" ]; then + DIRTY="-dirty" +fi + +COMMIT=$(git rev-parse --short HEAD) +GIT_TAG=$(git tag -l --contains HEAD | head -n 1) + +if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then + VERSION=$GIT_TAG +else + VERSION="${COMMIT}${DIRTY}" +fi diff --git a/trash.yml b/trash.yml new file mode 100644 index 00000000..04e6e49b --- /dev/null +++ b/trash.yml @@ -0,0 +1,3 @@ +import: +- package: github.com/Sirupsen/logrus + version: 446d1c146faa8ed3f4218f056fcd165f6bcfda81 diff --git a/vendor/github.com/Sirupsen/logrus/.gitignore b/vendor/github.com/Sirupsen/logrus/.gitignore new file mode 100644 index 00000000..66be63a0 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/.gitignore @@ -0,0 +1 @@ +logrus diff --git a/vendor/github.com/Sirupsen/logrus/.travis.yml b/vendor/github.com/Sirupsen/logrus/.travis.yml new file mode 100644 index 00000000..ec641142 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/.travis.yml @@ -0,0 +1,7 @@ +language: go +go: + - 1.3 + - 1.4 + - tip +install: + - go get -t ./... diff --git a/vendor/github.com/Sirupsen/logrus/CHANGELOG.md b/vendor/github.com/Sirupsen/logrus/CHANGELOG.md new file mode 100644 index 00000000..ecc84327 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/CHANGELOG.md @@ -0,0 +1,55 @@ +# 0.9.0 (Unreleased) + +* logrus/text_formatter: don't emit empty msg +* logrus/hooks/airbrake: move out of main repository +* logrus/hooks/sentry: move out of main repository +* logrus/hooks/papertrail: move out of main repository +* logrus/hooks/bugsnag: move out of main repository + +# 0.8.7 + +* logrus/core: fix possible race (#216) +* logrus/doc: small typo fixes and doc improvements + + +# 0.8.6 + +* hooks/raven: allow passing an initialized client + +# 0.8.5 + +* logrus/core: revert #208 + +# 0.8.4 + +* formatter/text: fix data race (#218) + +# 0.8.3 + +* logrus/core: fix entry log level (#208) +* logrus/core: improve performance of text formatter by 40% +* logrus/core: expose `LevelHooks` type +* logrus/core: add support for DragonflyBSD and NetBSD +* formatter/text: print structs more verbosely + +# 0.8.2 + +* logrus: fix more Fatal family functions + +# 0.8.1 + +* logrus: fix not exiting on `Fatalf` and `Fatalln` + +# 0.8.0 + +* logrus: defaults to stderr instead of stdout +* hooks/sentry: add special field for `*http.Request` +* formatter/text: ignore Windows for colors + +# 0.7.3 + +* formatter/\*: allow configuration of timestamp layout + +# 0.7.2 + +* formatter/text: Add configuration option for time format (#158) diff --git a/vendor/github.com/Sirupsen/logrus/LICENSE b/vendor/github.com/Sirupsen/logrus/LICENSE new file mode 100644 index 00000000..f090cb42 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Simon Eskildsen + +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/Sirupsen/logrus/README.md b/vendor/github.com/Sirupsen/logrus/README.md new file mode 100644 index 00000000..55d3a8d5 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/README.md @@ -0,0 +1,365 @@ +# Logrus :walrus: [![Build Status](https://travis-ci.org/Sirupsen/logrus.svg?branch=master)](https://travis-ci.org/Sirupsen/logrus) [![godoc reference](https://godoc.org/github.com/Sirupsen/logrus?status.png)][godoc] + +Logrus is a structured logger for Go (golang), completely API compatible with +the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not +yet stable (pre 1.0). Logrus itself is completely stable and has been used in +many large deployments. The core API is unlikely to change much but please +version control your Logrus to make sure you aren't fetching latest `master` on +every build.** + +Nicely color-coded in development (when a TTY is attached, otherwise just +plain text): + +![Colored](http://i.imgur.com/PY7qMwd.png) + +With `log.Formatter = new(logrus.JSONFormatter)`, for easy parsing by logstash +or Splunk: + +```json +{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the +ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"} + +{"level":"warning","msg":"The group's number increased tremendously!", +"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"} + +{"animal":"walrus","level":"info","msg":"A giant walrus appears!", +"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"} + +{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.", +"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"} + +{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true, +"time":"2014-03-10 19:57:38.562543128 -0400 EDT"} +``` + +With the default `log.Formatter = new(&log.TextFormatter{})` when a TTY is not +attached, the output is compatible with the +[logfmt](http://godoc.org/github.com/kr/logfmt) format: + +```text +time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8 +time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10 +time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true +time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4 +time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 +time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true +exit status 1 +``` + +#### Example + +The simplest way to use Logrus is simply the package-level exported logger: + +```go +package main + +import ( + log "github.com/Sirupsen/logrus" +) + +func main() { + log.WithFields(log.Fields{ + "animal": "walrus", + }).Info("A walrus appears") +} +``` + +Note that it's completely api-compatible with the stdlib logger, so you can +replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"` +and you'll now have the flexibility of Logrus. You can customize it all you +want: + +```go +package main + +import ( + "os" + log "github.com/Sirupsen/logrus" +) + +func init() { + // Log as JSON instead of the default ASCII formatter. + log.SetFormatter(&log.JSONFormatter{}) + + // Output to stderr instead of stdout, could also be a file. + log.SetOutput(os.Stderr) + + // Only log the warning severity or above. + log.SetLevel(log.WarnLevel) +} + +func main() { + log.WithFields(log.Fields{ + "animal": "walrus", + "size": 10, + }).Info("A group of walrus emerges from the ocean") + + log.WithFields(log.Fields{ + "omg": true, + "number": 122, + }).Warn("The group's number increased tremendously!") + + log.WithFields(log.Fields{ + "omg": true, + "number": 100, + }).Fatal("The ice breaks!") + + // A common pattern is to re-use fields between logging statements by re-using + // the logrus.Entry returned from WithFields() + contextLogger := log.WithFields(log.Fields{ + "common": "this is a common field", + "other": "I also should be logged always", + }) + + contextLogger.Info("I'll be logged with common and other field") + contextLogger.Info("Me too") +} +``` + +For more advanced usage such as logging to multiple locations from the same +application, you can also create an instance of the `logrus` Logger: + +```go +package main + +import ( + "github.com/Sirupsen/logrus" +) + +// Create a new instance of the logger. You can have any number of instances. +var log = logrus.New() + +func main() { + // The API for setting attributes is a little different than the package level + // exported logger. See Godoc. + log.Out = os.Stderr + + log.WithFields(logrus.Fields{ + "animal": "walrus", + "size": 10, + }).Info("A group of walrus emerges from the ocean") +} +``` + +#### Fields + +Logrus encourages careful, structured logging though logging fields instead of +long, unparseable error messages. For example, instead of: `log.Fatalf("Failed +to send event %s to topic %s with key %d")`, you should log the much more +discoverable: + +```go +log.WithFields(log.Fields{ + "event": event, + "topic": topic, + "key": key, +}).Fatal("Failed to send event") +``` + +We've found this API forces you to think about logging in a way that produces +much more useful logging messages. We've been in countless situations where just +a single added field to a log statement that was already there would've saved us +hours. The `WithFields` call is optional. + +In general, with Logrus using any of the `printf`-family functions should be +seen as a hint you should add a field, however, you can still use the +`printf`-family functions with Logrus. + +#### Hooks + +You can add hooks for logging levels. For example to send errors to an exception +tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to +multiple places simultaneously, e.g. syslog. + +Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in +`init`: + +```go +import ( + log "github.com/Sirupsen/logrus" + "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake" + logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" + "log/syslog" +) + +func init() { + + // Use the Airbrake hook to report errors that have Error severity or above to + // an exception tracker. You can create custom hooks, see the Hooks section. + log.AddHook(airbrake.NewHook(123, "xyz", "production")) + + hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") + if err != nil { + log.Error("Unable to connect to local syslog daemon") + } else { + log.AddHook(hook) + } +} +``` +Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md). + +| Hook | Description | +| ----- | ----------- | +| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. | +| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. | +| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. | +| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | +| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | +| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. | +| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | +| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | +| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | +| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | +| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | +| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) | +| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | +| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | +| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | +| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar | +| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | +| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | +| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | +| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | +| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | + +#### Level logging + +Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic. + +```go +log.Debug("Useful debugging information.") +log.Info("Something noteworthy happened!") +log.Warn("You should probably take a look at this.") +log.Error("Something failed but I'm not quitting.") +// Calls os.Exit(1) after logging +log.Fatal("Bye.") +// Calls panic() after logging +log.Panic("I'm bailing.") +``` + +You can set the logging level on a `Logger`, then it will only log entries with +that severity or anything above it: + +```go +// Will log anything that is info or above (warn, error, fatal, panic). Default. +log.SetLevel(log.InfoLevel) +``` + +It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose +environment if your application has that. + +#### Entries + +Besides the fields added with `WithField` or `WithFields` some fields are +automatically added to all logging events: + +1. `time`. The timestamp when the entry was created. +2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after + the `AddFields` call. E.g. `Failed to send event.` +3. `level`. The logging level. E.g. `info`. + +#### Environments + +Logrus has no notion of environment. + +If you wish for hooks and formatters to only be used in specific environments, +you should handle that yourself. For example, if your application has a global +variable `Environment`, which is a string representation of the environment you +could do: + +```go +import ( + log "github.com/Sirupsen/logrus" +) + +init() { + // do something here to set environment depending on an environment variable + // or command-line flag + if Environment == "production" { + log.SetFormatter(&log.JSONFormatter{}) + } else { + // The TextFormatter is default, you don't actually have to do this. + log.SetFormatter(&log.TextFormatter{}) + } +} +``` + +This configuration is how `logrus` was intended to be used, but JSON in +production is mostly only useful if you do log aggregation with tools like +Splunk or Logstash. + +#### Formatters + +The built-in logging formatters are: + +* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise + without colors. + * *Note:* to force colored output when there is no TTY, set the `ForceColors` + field to `true`. To force no colored output even if there is a TTY set the + `DisableColors` field to `true` +* `logrus.JSONFormatter`. Logs fields as JSON. +* `logrus/formatters/logstash.LogstashFormatter`. Logs fields as [Logstash](http://logstash.net) Events. + + ```go + logrus.SetFormatter(&logstash.LogstashFormatter{Type: "application_name"}) + ``` + +Third party logging formatters: + +* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. +* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. + +You can define your formatter by implementing the `Formatter` interface, +requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a +`Fields` type (`map[string]interface{}`) with all your fields as well as the +default ones (see Entries section above): + +```go +type MyJSONFormatter struct { +} + +log.SetFormatter(new(MyJSONFormatter)) + +func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) { + // Note this doesn't include Time, Level and Message which are available on + // the Entry. Consult `godoc` on information about those fields or read the + // source of the official loggers. + serialized, err := json.Marshal(entry.Data) + if err != nil { + return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) + } + return append(serialized, '\n'), nil +} +``` + +#### Logger as an `io.Writer` + +Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it. + +```go +w := logger.Writer() +defer w.Close() + +srv := http.Server{ + // create a stdlib log.Logger that writes to + // logrus.Logger. + ErrorLog: log.New(w, "", 0), +} +``` + +Each line written to that writer will be printed the usual way, using formatters +and hooks. The level for those entries is `info`. + +#### Rotation + +Log rotation is not provided with Logrus. Log rotation should be done by an +external program (like `logrotate(8)`) that can compress and delete old log +entries. It should not be a feature of the application-level logger. + +#### Tools + +| Tool | Description | +| ---- | ----------- | +|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.| + +[godoc]: https://godoc.org/github.com/Sirupsen/logrus diff --git a/vendor/github.com/Sirupsen/logrus/doc.go b/vendor/github.com/Sirupsen/logrus/doc.go new file mode 100644 index 00000000..dddd5f87 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/doc.go @@ -0,0 +1,26 @@ +/* +Package logrus is a structured logger for Go, completely API compatible with the standard library logger. + + +The simplest way to use Logrus is simply the package-level exported logger: + + package main + + import ( + log "github.com/Sirupsen/logrus" + ) + + func main() { + log.WithFields(log.Fields{ + "animal": "walrus", + "number": 1, + "size": 10, + }).Info("A walrus appears") + } + +Output: + time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 + +For a full guide visit https://github.com/Sirupsen/logrus +*/ +package logrus diff --git a/vendor/github.com/Sirupsen/logrus/entry.go b/vendor/github.com/Sirupsen/logrus/entry.go new file mode 100644 index 00000000..9ae900bc --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/entry.go @@ -0,0 +1,264 @@ +package logrus + +import ( + "bytes" + "fmt" + "io" + "os" + "time" +) + +// Defines the key when adding errors using WithError. +var ErrorKey = "error" + +// An entry is the final or intermediate Logrus logging entry. It contains all +// the fields passed with WithField{,s}. It's finally logged when Debug, Info, +// Warn, Error, Fatal or Panic is called on it. These objects can be reused and +// passed around as much as you wish to avoid field duplication. +type Entry struct { + Logger *Logger + + // Contains all the fields set by the user. + Data Fields + + // Time at which the log entry was created + Time time.Time + + // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic + Level Level + + // Message passed to Debug, Info, Warn, Error, Fatal or Panic + Message string +} + +func NewEntry(logger *Logger) *Entry { + return &Entry{ + Logger: logger, + // Default is three fields, give a little extra room + Data: make(Fields, 5), + } +} + +// Returns a reader for the entry, which is a proxy to the formatter. +func (entry *Entry) Reader() (*bytes.Buffer, error) { + serialized, err := entry.Logger.Formatter.Format(entry) + return bytes.NewBuffer(serialized), err +} + +// Returns the string representation from the reader and ultimately the +// formatter. +func (entry *Entry) String() (string, error) { + reader, err := entry.Reader() + if err != nil { + return "", err + } + + return reader.String(), err +} + +// Add an error as single field (using the key defined in ErrorKey) to the Entry. +func (entry *Entry) WithError(err error) *Entry { + return entry.WithField(ErrorKey, err) +} + +// Add a single field to the Entry. +func (entry *Entry) WithField(key string, value interface{}) *Entry { + return entry.WithFields(Fields{key: value}) +} + +// Add a map of fields to the Entry. +func (entry *Entry) WithFields(fields Fields) *Entry { + data := Fields{} + for k, v := range entry.Data { + data[k] = v + } + for k, v := range fields { + data[k] = v + } + return &Entry{Logger: entry.Logger, Data: data} +} + +// This function is not declared with a pointer value because otherwise +// race conditions will occur when using multiple goroutines +func (entry Entry) log(level Level, msg string) { + entry.Time = time.Now() + entry.Level = level + entry.Message = msg + + if err := entry.Logger.Hooks.Fire(level, &entry); err != nil { + entry.Logger.mu.Lock() + fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) + entry.Logger.mu.Unlock() + } + + reader, err := entry.Reader() + if err != nil { + entry.Logger.mu.Lock() + fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err) + entry.Logger.mu.Unlock() + } + + entry.Logger.mu.Lock() + defer entry.Logger.mu.Unlock() + + _, err = io.Copy(entry.Logger.Out, reader) + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) + } + + // To avoid Entry#log() returning a value that only would make sense for + // panic() to use in Entry#Panic(), we avoid the allocation by checking + // directly here. + if level <= PanicLevel { + panic(&entry) + } +} + +func (entry *Entry) Debug(args ...interface{}) { + if entry.Logger.Level >= DebugLevel { + entry.log(DebugLevel, fmt.Sprint(args...)) + } +} + +func (entry *Entry) Print(args ...interface{}) { + entry.Info(args...) +} + +func (entry *Entry) Info(args ...interface{}) { + if entry.Logger.Level >= InfoLevel { + entry.log(InfoLevel, fmt.Sprint(args...)) + } +} + +func (entry *Entry) Warn(args ...interface{}) { + if entry.Logger.Level >= WarnLevel { + entry.log(WarnLevel, fmt.Sprint(args...)) + } +} + +func (entry *Entry) Warning(args ...interface{}) { + entry.Warn(args...) +} + +func (entry *Entry) Error(args ...interface{}) { + if entry.Logger.Level >= ErrorLevel { + entry.log(ErrorLevel, fmt.Sprint(args...)) + } +} + +func (entry *Entry) Fatal(args ...interface{}) { + if entry.Logger.Level >= FatalLevel { + entry.log(FatalLevel, fmt.Sprint(args...)) + } + os.Exit(1) +} + +func (entry *Entry) Panic(args ...interface{}) { + if entry.Logger.Level >= PanicLevel { + entry.log(PanicLevel, fmt.Sprint(args...)) + } + panic(fmt.Sprint(args...)) +} + +// Entry Printf family functions + +func (entry *Entry) Debugf(format string, args ...interface{}) { + if entry.Logger.Level >= DebugLevel { + entry.Debug(fmt.Sprintf(format, args...)) + } +} + +func (entry *Entry) Infof(format string, args ...interface{}) { + if entry.Logger.Level >= InfoLevel { + entry.Info(fmt.Sprintf(format, args...)) + } +} + +func (entry *Entry) Printf(format string, args ...interface{}) { + entry.Infof(format, args...) +} + +func (entry *Entry) Warnf(format string, args ...interface{}) { + if entry.Logger.Level >= WarnLevel { + entry.Warn(fmt.Sprintf(format, args...)) + } +} + +func (entry *Entry) Warningf(format string, args ...interface{}) { + entry.Warnf(format, args...) +} + +func (entry *Entry) Errorf(format string, args ...interface{}) { + if entry.Logger.Level >= ErrorLevel { + entry.Error(fmt.Sprintf(format, args...)) + } +} + +func (entry *Entry) Fatalf(format string, args ...interface{}) { + if entry.Logger.Level >= FatalLevel { + entry.Fatal(fmt.Sprintf(format, args...)) + } + os.Exit(1) +} + +func (entry *Entry) Panicf(format string, args ...interface{}) { + if entry.Logger.Level >= PanicLevel { + entry.Panic(fmt.Sprintf(format, args...)) + } +} + +// Entry Println family functions + +func (entry *Entry) Debugln(args ...interface{}) { + if entry.Logger.Level >= DebugLevel { + entry.Debug(entry.sprintlnn(args...)) + } +} + +func (entry *Entry) Infoln(args ...interface{}) { + if entry.Logger.Level >= InfoLevel { + entry.Info(entry.sprintlnn(args...)) + } +} + +func (entry *Entry) Println(args ...interface{}) { + entry.Infoln(args...) +} + +func (entry *Entry) Warnln(args ...interface{}) { + if entry.Logger.Level >= WarnLevel { + entry.Warn(entry.sprintlnn(args...)) + } +} + +func (entry *Entry) Warningln(args ...interface{}) { + entry.Warnln(args...) +} + +func (entry *Entry) Errorln(args ...interface{}) { + if entry.Logger.Level >= ErrorLevel { + entry.Error(entry.sprintlnn(args...)) + } +} + +func (entry *Entry) Fatalln(args ...interface{}) { + if entry.Logger.Level >= FatalLevel { + entry.Fatal(entry.sprintlnn(args...)) + } + os.Exit(1) +} + +func (entry *Entry) Panicln(args ...interface{}) { + if entry.Logger.Level >= PanicLevel { + entry.Panic(entry.sprintlnn(args...)) + } +} + +// Sprintlnn => Sprint no newline. This is to get the behavior of how +// fmt.Sprintln where spaces are always added between operands, regardless of +// their type. Instead of vendoring the Sprintln implementation to spare a +// string allocation, we do the simplest thing. +func (entry *Entry) sprintlnn(args ...interface{}) string { + msg := fmt.Sprintln(args...) + return msg[:len(msg)-1] +} diff --git a/vendor/github.com/Sirupsen/logrus/entry_test.go b/vendor/github.com/Sirupsen/logrus/entry_test.go new file mode 100644 index 00000000..99c3b41d --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/entry_test.go @@ -0,0 +1,77 @@ +package logrus + +import ( + "bytes" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestEntryWithError(t *testing.T) { + + assert := assert.New(t) + + defer func() { + ErrorKey = "error" + }() + + err := fmt.Errorf("kaboom at layer %d", 4711) + + assert.Equal(err, WithError(err).Data["error"]) + + logger := New() + logger.Out = &bytes.Buffer{} + entry := NewEntry(logger) + + assert.Equal(err, entry.WithError(err).Data["error"]) + + ErrorKey = "err" + + assert.Equal(err, entry.WithError(err).Data["err"]) + +} + +func TestEntryPanicln(t *testing.T) { + errBoom := fmt.Errorf("boom time") + + defer func() { + p := recover() + assert.NotNil(t, p) + + switch pVal := p.(type) { + case *Entry: + assert.Equal(t, "kaboom", pVal.Message) + assert.Equal(t, errBoom, pVal.Data["err"]) + default: + t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) + } + }() + + logger := New() + logger.Out = &bytes.Buffer{} + entry := NewEntry(logger) + entry.WithField("err", errBoom).Panicln("kaboom") +} + +func TestEntryPanicf(t *testing.T) { + errBoom := fmt.Errorf("boom again") + + defer func() { + p := recover() + assert.NotNil(t, p) + + switch pVal := p.(type) { + case *Entry: + assert.Equal(t, "kaboom true", pVal.Message) + assert.Equal(t, errBoom, pVal.Data["err"]) + default: + t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) + } + }() + + logger := New() + logger.Out = &bytes.Buffer{} + entry := NewEntry(logger) + entry.WithField("err", errBoom).Panicf("kaboom %v", true) +} diff --git a/vendor/github.com/Sirupsen/logrus/exported.go b/vendor/github.com/Sirupsen/logrus/exported.go new file mode 100644 index 00000000..9a0120ac --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/exported.go @@ -0,0 +1,193 @@ +package logrus + +import ( + "io" +) + +var ( + // std is the name of the standard logger in stdlib `log` + std = New() +) + +func StandardLogger() *Logger { + return std +} + +// SetOutput sets the standard logger output. +func SetOutput(out io.Writer) { + std.mu.Lock() + defer std.mu.Unlock() + std.Out = out +} + +// SetFormatter sets the standard logger formatter. +func SetFormatter(formatter Formatter) { + std.mu.Lock() + defer std.mu.Unlock() + std.Formatter = formatter +} + +// SetLevel sets the standard logger level. +func SetLevel(level Level) { + std.mu.Lock() + defer std.mu.Unlock() + std.Level = level +} + +// GetLevel returns the standard logger level. +func GetLevel() Level { + std.mu.Lock() + defer std.mu.Unlock() + return std.Level +} + +// AddHook adds a hook to the standard logger hooks. +func AddHook(hook Hook) { + std.mu.Lock() + defer std.mu.Unlock() + std.Hooks.Add(hook) +} + +// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. +func WithError(err error) *Entry { + return std.WithField(ErrorKey, err) +} + +// WithField creates an entry from the standard logger and adds a field to +// it. If you want multiple fields, use `WithFields`. +// +// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal +// or Panic on the Entry it returns. +func WithField(key string, value interface{}) *Entry { + return std.WithField(key, value) +} + +// WithFields creates an entry from the standard logger and adds multiple +// fields to it. This is simply a helper for `WithField`, invoking it +// once for each field. +// +// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal +// or Panic on the Entry it returns. +func WithFields(fields Fields) *Entry { + return std.WithFields(fields) +} + +// Debug logs a message at level Debug on the standard logger. +func Debug(args ...interface{}) { + std.Debug(args...) +} + +// Print logs a message at level Info on the standard logger. +func Print(args ...interface{}) { + std.Print(args...) +} + +// Info logs a message at level Info on the standard logger. +func Info(args ...interface{}) { + std.Info(args...) +} + +// Warn logs a message at level Warn on the standard logger. +func Warn(args ...interface{}) { + std.Warn(args...) +} + +// Warning logs a message at level Warn on the standard logger. +func Warning(args ...interface{}) { + std.Warning(args...) +} + +// Error logs a message at level Error on the standard logger. +func Error(args ...interface{}) { + std.Error(args...) +} + +// Panic logs a message at level Panic on the standard logger. +func Panic(args ...interface{}) { + std.Panic(args...) +} + +// Fatal logs a message at level Fatal on the standard logger. +func Fatal(args ...interface{}) { + std.Fatal(args...) +} + +// Debugf logs a message at level Debug on the standard logger. +func Debugf(format string, args ...interface{}) { + std.Debugf(format, args...) +} + +// Printf logs a message at level Info on the standard logger. +func Printf(format string, args ...interface{}) { + std.Printf(format, args...) +} + +// Infof logs a message at level Info on the standard logger. +func Infof(format string, args ...interface{}) { + std.Infof(format, args...) +} + +// Warnf logs a message at level Warn on the standard logger. +func Warnf(format string, args ...interface{}) { + std.Warnf(format, args...) +} + +// Warningf logs a message at level Warn on the standard logger. +func Warningf(format string, args ...interface{}) { + std.Warningf(format, args...) +} + +// Errorf logs a message at level Error on the standard logger. +func Errorf(format string, args ...interface{}) { + std.Errorf(format, args...) +} + +// Panicf logs a message at level Panic on the standard logger. +func Panicf(format string, args ...interface{}) { + std.Panicf(format, args...) +} + +// Fatalf logs a message at level Fatal on the standard logger. +func Fatalf(format string, args ...interface{}) { + std.Fatalf(format, args...) +} + +// Debugln logs a message at level Debug on the standard logger. +func Debugln(args ...interface{}) { + std.Debugln(args...) +} + +// Println logs a message at level Info on the standard logger. +func Println(args ...interface{}) { + std.Println(args...) +} + +// Infoln logs a message at level Info on the standard logger. +func Infoln(args ...interface{}) { + std.Infoln(args...) +} + +// Warnln logs a message at level Warn on the standard logger. +func Warnln(args ...interface{}) { + std.Warnln(args...) +} + +// Warningln logs a message at level Warn on the standard logger. +func Warningln(args ...interface{}) { + std.Warningln(args...) +} + +// Errorln logs a message at level Error on the standard logger. +func Errorln(args ...interface{}) { + std.Errorln(args...) +} + +// Panicln logs a message at level Panic on the standard logger. +func Panicln(args ...interface{}) { + std.Panicln(args...) +} + +// Fatalln logs a message at level Fatal on the standard logger. +func Fatalln(args ...interface{}) { + std.Fatalln(args...) +} diff --git a/vendor/github.com/Sirupsen/logrus/formatter.go b/vendor/github.com/Sirupsen/logrus/formatter.go new file mode 100644 index 00000000..104d689f --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/formatter.go @@ -0,0 +1,48 @@ +package logrus + +import "time" + +const DefaultTimestampFormat = time.RFC3339 + +// The Formatter interface is used to implement a custom Formatter. It takes an +// `Entry`. It exposes all the fields, including the default ones: +// +// * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. +// * `entry.Data["time"]`. The timestamp. +// * `entry.Data["level"]. The level the entry was logged at. +// +// Any additional fields added with `WithField` or `WithFields` are also in +// `entry.Data`. Format is expected to return an array of bytes which are then +// logged to `logger.Out`. +type Formatter interface { + Format(*Entry) ([]byte, error) +} + +// This is to not silently overwrite `time`, `msg` and `level` fields when +// dumping it. If this code wasn't there doing: +// +// logrus.WithField("level", 1).Info("hello") +// +// Would just silently drop the user provided level. Instead with this code +// it'll logged as: +// +// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} +// +// It's not exported because it's still using Data in an opinionated way. It's to +// avoid code duplication between the two default formatters. +func prefixFieldClashes(data Fields) { + _, ok := data["time"] + if ok { + data["fields.time"] = data["time"] + } + + _, ok = data["msg"] + if ok { + data["fields.msg"] = data["msg"] + } + + _, ok = data["level"] + if ok { + data["fields.level"] = data["level"] + } +} diff --git a/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go b/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go new file mode 100644 index 00000000..c6d290c7 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go @@ -0,0 +1,98 @@ +package logrus + +import ( + "fmt" + "testing" + "time" +) + +// smallFields is a small size data set for benchmarking +var smallFields = Fields{ + "foo": "bar", + "baz": "qux", + "one": "two", + "three": "four", +} + +// largeFields is a large size data set for benchmarking +var largeFields = Fields{ + "foo": "bar", + "baz": "qux", + "one": "two", + "three": "four", + "five": "six", + "seven": "eight", + "nine": "ten", + "eleven": "twelve", + "thirteen": "fourteen", + "fifteen": "sixteen", + "seventeen": "eighteen", + "nineteen": "twenty", + "a": "b", + "c": "d", + "e": "f", + "g": "h", + "i": "j", + "k": "l", + "m": "n", + "o": "p", + "q": "r", + "s": "t", + "u": "v", + "w": "x", + "y": "z", + "this": "will", + "make": "thirty", + "entries": "yeah", +} + +var errorFields = Fields{ + "foo": fmt.Errorf("bar"), + "baz": fmt.Errorf("qux"), +} + +func BenchmarkErrorTextFormatter(b *testing.B) { + doBenchmark(b, &TextFormatter{DisableColors: true}, errorFields) +} + +func BenchmarkSmallTextFormatter(b *testing.B) { + doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields) +} + +func BenchmarkLargeTextFormatter(b *testing.B) { + doBenchmark(b, &TextFormatter{DisableColors: true}, largeFields) +} + +func BenchmarkSmallColoredTextFormatter(b *testing.B) { + doBenchmark(b, &TextFormatter{ForceColors: true}, smallFields) +} + +func BenchmarkLargeColoredTextFormatter(b *testing.B) { + doBenchmark(b, &TextFormatter{ForceColors: true}, largeFields) +} + +func BenchmarkSmallJSONFormatter(b *testing.B) { + doBenchmark(b, &JSONFormatter{}, smallFields) +} + +func BenchmarkLargeJSONFormatter(b *testing.B) { + doBenchmark(b, &JSONFormatter{}, largeFields) +} + +func doBenchmark(b *testing.B, formatter Formatter, fields Fields) { + entry := &Entry{ + Time: time.Time{}, + Level: InfoLevel, + Message: "message", + Data: fields, + } + var d []byte + var err error + for i := 0; i < b.N; i++ { + d, err = formatter.Format(entry) + if err != nil { + b.Fatal(err) + } + b.SetBytes(int64(len(d))) + } +} diff --git a/vendor/github.com/Sirupsen/logrus/hook_test.go b/vendor/github.com/Sirupsen/logrus/hook_test.go new file mode 100644 index 00000000..13f34cb6 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/hook_test.go @@ -0,0 +1,122 @@ +package logrus + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +type TestHook struct { + Fired bool +} + +func (hook *TestHook) Fire(entry *Entry) error { + hook.Fired = true + return nil +} + +func (hook *TestHook) Levels() []Level { + return []Level{ + DebugLevel, + InfoLevel, + WarnLevel, + ErrorLevel, + FatalLevel, + PanicLevel, + } +} + +func TestHookFires(t *testing.T) { + hook := new(TestHook) + + LogAndAssertJSON(t, func(log *Logger) { + log.Hooks.Add(hook) + assert.Equal(t, hook.Fired, false) + + log.Print("test") + }, func(fields Fields) { + assert.Equal(t, hook.Fired, true) + }) +} + +type ModifyHook struct { +} + +func (hook *ModifyHook) Fire(entry *Entry) error { + entry.Data["wow"] = "whale" + return nil +} + +func (hook *ModifyHook) Levels() []Level { + return []Level{ + DebugLevel, + InfoLevel, + WarnLevel, + ErrorLevel, + FatalLevel, + PanicLevel, + } +} + +func TestHookCanModifyEntry(t *testing.T) { + hook := new(ModifyHook) + + LogAndAssertJSON(t, func(log *Logger) { + log.Hooks.Add(hook) + log.WithField("wow", "elephant").Print("test") + }, func(fields Fields) { + assert.Equal(t, fields["wow"], "whale") + }) +} + +func TestCanFireMultipleHooks(t *testing.T) { + hook1 := new(ModifyHook) + hook2 := new(TestHook) + + LogAndAssertJSON(t, func(log *Logger) { + log.Hooks.Add(hook1) + log.Hooks.Add(hook2) + + log.WithField("wow", "elephant").Print("test") + }, func(fields Fields) { + assert.Equal(t, fields["wow"], "whale") + assert.Equal(t, hook2.Fired, true) + }) +} + +type ErrorHook struct { + Fired bool +} + +func (hook *ErrorHook) Fire(entry *Entry) error { + hook.Fired = true + return nil +} + +func (hook *ErrorHook) Levels() []Level { + return []Level{ + ErrorLevel, + } +} + +func TestErrorHookShouldntFireOnInfo(t *testing.T) { + hook := new(ErrorHook) + + LogAndAssertJSON(t, func(log *Logger) { + log.Hooks.Add(hook) + log.Info("test") + }, func(fields Fields) { + assert.Equal(t, hook.Fired, false) + }) +} + +func TestErrorHookShouldFireOnError(t *testing.T) { + hook := new(ErrorHook) + + LogAndAssertJSON(t, func(log *Logger) { + log.Hooks.Add(hook) + log.Error("test") + }, func(fields Fields) { + assert.Equal(t, hook.Fired, true) + }) +} diff --git a/vendor/github.com/Sirupsen/logrus/hooks.go b/vendor/github.com/Sirupsen/logrus/hooks.go new file mode 100644 index 00000000..3f151cdc --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/hooks.go @@ -0,0 +1,34 @@ +package logrus + +// A hook to be fired when logging on the logging levels returned from +// `Levels()` on your implementation of the interface. Note that this is not +// fired in a goroutine or a channel with workers, you should handle such +// functionality yourself if your call is non-blocking and you don't wish for +// the logging calls for levels returned from `Levels()` to block. +type Hook interface { + Levels() []Level + Fire(*Entry) error +} + +// Internal type for storing the hooks on a logger instance. +type LevelHooks map[Level][]Hook + +// Add a hook to an instance of logger. This is called with +// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. +func (hooks LevelHooks) Add(hook Hook) { + for _, level := range hook.Levels() { + hooks[level] = append(hooks[level], hook) + } +} + +// Fire all the hooks for the passed level. Used by `entry.log` to fire +// appropriate hooks for a log entry. +func (hooks LevelHooks) Fire(level Level, entry *Entry) error { + for _, hook := range hooks[level] { + if err := hook.Fire(entry); err != nil { + return err + } + } + + return nil +} diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/Sirupsen/logrus/json_formatter.go new file mode 100644 index 00000000..2ad6dc5c --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/json_formatter.go @@ -0,0 +1,41 @@ +package logrus + +import ( + "encoding/json" + "fmt" +) + +type JSONFormatter struct { + // TimestampFormat sets the format used for marshaling timestamps. + TimestampFormat string +} + +func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { + data := make(Fields, len(entry.Data)+3) + for k, v := range entry.Data { + switch v := v.(type) { + case error: + // Otherwise errors are ignored by `encoding/json` + // https://github.com/Sirupsen/logrus/issues/137 + data[k] = v.Error() + default: + data[k] = v + } + } + prefixFieldClashes(data) + + timestampFormat := f.TimestampFormat + if timestampFormat == "" { + timestampFormat = DefaultTimestampFormat + } + + data["time"] = entry.Time.Format(timestampFormat) + data["msg"] = entry.Message + data["level"] = entry.Level.String() + + serialized, err := json.Marshal(data) + if err != nil { + return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) + } + return append(serialized, '\n'), nil +} diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter_test.go b/vendor/github.com/Sirupsen/logrus/json_formatter_test.go new file mode 100644 index 00000000..1d708732 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/json_formatter_test.go @@ -0,0 +1,120 @@ +package logrus + +import ( + "encoding/json" + "errors" + + "testing" +) + +func TestErrorNotLost(t *testing.T) { + formatter := &JSONFormatter{} + + b, err := formatter.Format(WithField("error", errors.New("wild walrus"))) + if err != nil { + t.Fatal("Unable to format entry: ", err) + } + + entry := make(map[string]interface{}) + err = json.Unmarshal(b, &entry) + if err != nil { + t.Fatal("Unable to unmarshal formatted entry: ", err) + } + + if entry["error"] != "wild walrus" { + t.Fatal("Error field not set") + } +} + +func TestErrorNotLostOnFieldNotNamedError(t *testing.T) { + formatter := &JSONFormatter{} + + b, err := formatter.Format(WithField("omg", errors.New("wild walrus"))) + if err != nil { + t.Fatal("Unable to format entry: ", err) + } + + entry := make(map[string]interface{}) + err = json.Unmarshal(b, &entry) + if err != nil { + t.Fatal("Unable to unmarshal formatted entry: ", err) + } + + if entry["omg"] != "wild walrus" { + t.Fatal("Error field not set") + } +} + +func TestFieldClashWithTime(t *testing.T) { + formatter := &JSONFormatter{} + + b, err := formatter.Format(WithField("time", "right now!")) + if err != nil { + t.Fatal("Unable to format entry: ", err) + } + + entry := make(map[string]interface{}) + err = json.Unmarshal(b, &entry) + if err != nil { + t.Fatal("Unable to unmarshal formatted entry: ", err) + } + + if entry["fields.time"] != "right now!" { + t.Fatal("fields.time not set to original time field") + } + + if entry["time"] != "0001-01-01T00:00:00Z" { + t.Fatal("time field not set to current time, was: ", entry["time"]) + } +} + +func TestFieldClashWithMsg(t *testing.T) { + formatter := &JSONFormatter{} + + b, err := formatter.Format(WithField("msg", "something")) + if err != nil { + t.Fatal("Unable to format entry: ", err) + } + + entry := make(map[string]interface{}) + err = json.Unmarshal(b, &entry) + if err != nil { + t.Fatal("Unable to unmarshal formatted entry: ", err) + } + + if entry["fields.msg"] != "something" { + t.Fatal("fields.msg not set to original msg field") + } +} + +func TestFieldClashWithLevel(t *testing.T) { + formatter := &JSONFormatter{} + + b, err := formatter.Format(WithField("level", "something")) + if err != nil { + t.Fatal("Unable to format entry: ", err) + } + + entry := make(map[string]interface{}) + err = json.Unmarshal(b, &entry) + if err != nil { + t.Fatal("Unable to unmarshal formatted entry: ", err) + } + + if entry["fields.level"] != "something" { + t.Fatal("fields.level not set to original level field") + } +} + +func TestJSONEntryEndsWithNewline(t *testing.T) { + formatter := &JSONFormatter{} + + b, err := formatter.Format(WithField("level", "something")) + if err != nil { + t.Fatal("Unable to format entry: ", err) + } + + if b[len(b)-1] != '\n' { + t.Fatal("Expected JSON log entry to end with a newline") + } +} diff --git a/vendor/github.com/Sirupsen/logrus/logger.go b/vendor/github.com/Sirupsen/logrus/logger.go new file mode 100644 index 00000000..2fdb2317 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/logger.go @@ -0,0 +1,212 @@ +package logrus + +import ( + "io" + "os" + "sync" +) + +type Logger struct { + // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a + // file, or leave it default which is `os.Stderr`. You can also set this to + // something more adventorous, such as logging to Kafka. + Out io.Writer + // Hooks for the logger instance. These allow firing events based on logging + // levels and log entries. For example, to send errors to an error tracking + // service, log to StatsD or dump the core on fatal errors. + Hooks LevelHooks + // All log entries pass through the formatter before logged to Out. The + // included formatters are `TextFormatter` and `JSONFormatter` for which + // TextFormatter is the default. In development (when a TTY is attached) it + // logs with colors, but to a file it wouldn't. You can easily implement your + // own that implements the `Formatter` interface, see the `README` or included + // formatters for examples. + Formatter Formatter + // The logging level the logger should log at. This is typically (and defaults + // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be + // logged. `logrus.Debug` is useful in + Level Level + // Used to sync writing to the log. + mu sync.Mutex +} + +// Creates a new logger. Configuration should be set by changing `Formatter`, +// `Out` and `Hooks` directly on the default logger instance. You can also just +// instantiate your own: +// +// var log = &Logger{ +// Out: os.Stderr, +// Formatter: new(JSONFormatter), +// Hooks: make(LevelHooks), +// Level: logrus.DebugLevel, +// } +// +// It's recommended to make this a global instance called `log`. +func New() *Logger { + return &Logger{ + Out: os.Stderr, + Formatter: new(TextFormatter), + Hooks: make(LevelHooks), + Level: InfoLevel, + } +} + +// Adds a field to the log entry, note that you it doesn't log until you call +// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. +// If you want multiple fields, use `WithFields`. +func (logger *Logger) WithField(key string, value interface{}) *Entry { + return NewEntry(logger).WithField(key, value) +} + +// Adds a struct of fields to the log entry. All it does is call `WithField` for +// each `Field`. +func (logger *Logger) WithFields(fields Fields) *Entry { + return NewEntry(logger).WithFields(fields) +} + +// Add an error as single field to the log entry. All it does is call +// `WithError` for the given `error`. +func (logger *Logger) WithError(err error) *Entry { + return NewEntry(logger).WithError(err) +} + +func (logger *Logger) Debugf(format string, args ...interface{}) { + if logger.Level >= DebugLevel { + NewEntry(logger).Debugf(format, args...) + } +} + +func (logger *Logger) Infof(format string, args ...interface{}) { + if logger.Level >= InfoLevel { + NewEntry(logger).Infof(format, args...) + } +} + +func (logger *Logger) Printf(format string, args ...interface{}) { + NewEntry(logger).Printf(format, args...) +} + +func (logger *Logger) Warnf(format string, args ...interface{}) { + if logger.Level >= WarnLevel { + NewEntry(logger).Warnf(format, args...) + } +} + +func (logger *Logger) Warningf(format string, args ...interface{}) { + if logger.Level >= WarnLevel { + NewEntry(logger).Warnf(format, args...) + } +} + +func (logger *Logger) Errorf(format string, args ...interface{}) { + if logger.Level >= ErrorLevel { + NewEntry(logger).Errorf(format, args...) + } +} + +func (logger *Logger) Fatalf(format string, args ...interface{}) { + if logger.Level >= FatalLevel { + NewEntry(logger).Fatalf(format, args...) + } + os.Exit(1) +} + +func (logger *Logger) Panicf(format string, args ...interface{}) { + if logger.Level >= PanicLevel { + NewEntry(logger).Panicf(format, args...) + } +} + +func (logger *Logger) Debug(args ...interface{}) { + if logger.Level >= DebugLevel { + NewEntry(logger).Debug(args...) + } +} + +func (logger *Logger) Info(args ...interface{}) { + if logger.Level >= InfoLevel { + NewEntry(logger).Info(args...) + } +} + +func (logger *Logger) Print(args ...interface{}) { + NewEntry(logger).Info(args...) +} + +func (logger *Logger) Warn(args ...interface{}) { + if logger.Level >= WarnLevel { + NewEntry(logger).Warn(args...) + } +} + +func (logger *Logger) Warning(args ...interface{}) { + if logger.Level >= WarnLevel { + NewEntry(logger).Warn(args...) + } +} + +func (logger *Logger) Error(args ...interface{}) { + if logger.Level >= ErrorLevel { + NewEntry(logger).Error(args...) + } +} + +func (logger *Logger) Fatal(args ...interface{}) { + if logger.Level >= FatalLevel { + NewEntry(logger).Fatal(args...) + } + os.Exit(1) +} + +func (logger *Logger) Panic(args ...interface{}) { + if logger.Level >= PanicLevel { + NewEntry(logger).Panic(args...) + } +} + +func (logger *Logger) Debugln(args ...interface{}) { + if logger.Level >= DebugLevel { + NewEntry(logger).Debugln(args...) + } +} + +func (logger *Logger) Infoln(args ...interface{}) { + if logger.Level >= InfoLevel { + NewEntry(logger).Infoln(args...) + } +} + +func (logger *Logger) Println(args ...interface{}) { + NewEntry(logger).Println(args...) +} + +func (logger *Logger) Warnln(args ...interface{}) { + if logger.Level >= WarnLevel { + NewEntry(logger).Warnln(args...) + } +} + +func (logger *Logger) Warningln(args ...interface{}) { + if logger.Level >= WarnLevel { + NewEntry(logger).Warnln(args...) + } +} + +func (logger *Logger) Errorln(args ...interface{}) { + if logger.Level >= ErrorLevel { + NewEntry(logger).Errorln(args...) + } +} + +func (logger *Logger) Fatalln(args ...interface{}) { + if logger.Level >= FatalLevel { + NewEntry(logger).Fatalln(args...) + } + os.Exit(1) +} + +func (logger *Logger) Panicln(args ...interface{}) { + if logger.Level >= PanicLevel { + NewEntry(logger).Panicln(args...) + } +} diff --git a/vendor/github.com/Sirupsen/logrus/logrus.go b/vendor/github.com/Sirupsen/logrus/logrus.go new file mode 100644 index 00000000..0c09fbc2 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/logrus.go @@ -0,0 +1,98 @@ +package logrus + +import ( + "fmt" + "log" +) + +// Fields type, used to pass to `WithFields`. +type Fields map[string]interface{} + +// Level type +type Level uint8 + +// Convert the Level to a string. E.g. PanicLevel becomes "panic". +func (level Level) String() string { + switch level { + case DebugLevel: + return "debug" + case InfoLevel: + return "info" + case WarnLevel: + return "warning" + case ErrorLevel: + return "error" + case FatalLevel: + return "fatal" + case PanicLevel: + return "panic" + } + + return "unknown" +} + +// ParseLevel takes a string level and returns the Logrus log level constant. +func ParseLevel(lvl string) (Level, error) { + switch lvl { + case "panic": + return PanicLevel, nil + case "fatal": + return FatalLevel, nil + case "error": + return ErrorLevel, nil + case "warn", "warning": + return WarnLevel, nil + case "info": + return InfoLevel, nil + case "debug": + return DebugLevel, nil + } + + var l Level + return l, fmt.Errorf("not a valid logrus Level: %q", lvl) +} + +// These are the different logging levels. You can set the logging level to log +// on your instance of logger, obtained with `logrus.New()`. +const ( + // PanicLevel level, highest level of severity. Logs and then calls panic with the + // message passed to Debug, Info, ... + PanicLevel Level = iota + // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the + // logging level is set to Panic. + FatalLevel + // ErrorLevel level. Logs. Used for errors that should definitely be noted. + // Commonly used for hooks to send errors to an error tracking service. + ErrorLevel + // WarnLevel level. Non-critical entries that deserve eyes. + WarnLevel + // InfoLevel level. General operational entries about what's going on inside the + // application. + InfoLevel + // DebugLevel level. Usually only enabled when debugging. Very verbose logging. + DebugLevel +) + +// Won't compile if StdLogger can't be realized by a log.Logger +var ( + _ StdLogger = &log.Logger{} + _ StdLogger = &Entry{} + _ StdLogger = &Logger{} +) + +// StdLogger is what your logrus-enabled library should take, that way +// it'll accept a stdlib logger and a logrus logger. There's no standard +// interface, this is the closest we get, unfortunately. +type StdLogger interface { + Print(...interface{}) + Printf(string, ...interface{}) + Println(...interface{}) + + Fatal(...interface{}) + Fatalf(string, ...interface{}) + Fatalln(...interface{}) + + Panic(...interface{}) + Panicf(string, ...interface{}) + Panicln(...interface{}) +} diff --git a/vendor/github.com/Sirupsen/logrus/logrus_test.go b/vendor/github.com/Sirupsen/logrus/logrus_test.go new file mode 100644 index 00000000..efaacea2 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/logrus_test.go @@ -0,0 +1,301 @@ +package logrus + +import ( + "bytes" + "encoding/json" + "strconv" + "strings" + "sync" + "testing" + + "github.com/stretchr/testify/assert" +) + +func LogAndAssertJSON(t *testing.T, log func(*Logger), assertions func(fields Fields)) { + var buffer bytes.Buffer + var fields Fields + + logger := New() + logger.Out = &buffer + logger.Formatter = new(JSONFormatter) + + log(logger) + + err := json.Unmarshal(buffer.Bytes(), &fields) + assert.Nil(t, err) + + assertions(fields) +} + +func LogAndAssertText(t *testing.T, log func(*Logger), assertions func(fields map[string]string)) { + var buffer bytes.Buffer + + logger := New() + logger.Out = &buffer + logger.Formatter = &TextFormatter{ + DisableColors: true, + } + + log(logger) + + fields := make(map[string]string) + for _, kv := range strings.Split(buffer.String(), " ") { + if !strings.Contains(kv, "=") { + continue + } + kvArr := strings.Split(kv, "=") + key := strings.TrimSpace(kvArr[0]) + val := kvArr[1] + if kvArr[1][0] == '"' { + var err error + val, err = strconv.Unquote(val) + assert.NoError(t, err) + } + fields[key] = val + } + assertions(fields) +} + +func TestPrint(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Print("test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test") + assert.Equal(t, fields["level"], "info") + }) +} + +func TestInfo(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Info("test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test") + assert.Equal(t, fields["level"], "info") + }) +} + +func TestWarn(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Warn("test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test") + assert.Equal(t, fields["level"], "warning") + }) +} + +func TestInfolnShouldAddSpacesBetweenStrings(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Infoln("test", "test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test test") + }) +} + +func TestInfolnShouldAddSpacesBetweenStringAndNonstring(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Infoln("test", 10) + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test 10") + }) +} + +func TestInfolnShouldAddSpacesBetweenTwoNonStrings(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Infoln(10, 10) + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "10 10") + }) +} + +func TestInfoShouldAddSpacesBetweenTwoNonStrings(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Infoln(10, 10) + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "10 10") + }) +} + +func TestInfoShouldNotAddSpacesBetweenStringAndNonstring(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Info("test", 10) + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test10") + }) +} + +func TestInfoShouldNotAddSpacesBetweenStrings(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.Info("test", "test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "testtest") + }) +} + +func TestWithFieldsShouldAllowAssignments(t *testing.T) { + var buffer bytes.Buffer + var fields Fields + + logger := New() + logger.Out = &buffer + logger.Formatter = new(JSONFormatter) + + localLog := logger.WithFields(Fields{ + "key1": "value1", + }) + + localLog.WithField("key2", "value2").Info("test") + err := json.Unmarshal(buffer.Bytes(), &fields) + assert.Nil(t, err) + + assert.Equal(t, "value2", fields["key2"]) + assert.Equal(t, "value1", fields["key1"]) + + buffer = bytes.Buffer{} + fields = Fields{} + localLog.Info("test") + err = json.Unmarshal(buffer.Bytes(), &fields) + assert.Nil(t, err) + + _, ok := fields["key2"] + assert.Equal(t, false, ok) + assert.Equal(t, "value1", fields["key1"]) +} + +func TestUserSuppliedFieldDoesNotOverwriteDefaults(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.WithField("msg", "hello").Info("test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test") + }) +} + +func TestUserSuppliedMsgFieldHasPrefix(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.WithField("msg", "hello").Info("test") + }, func(fields Fields) { + assert.Equal(t, fields["msg"], "test") + assert.Equal(t, fields["fields.msg"], "hello") + }) +} + +func TestUserSuppliedTimeFieldHasPrefix(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.WithField("time", "hello").Info("test") + }, func(fields Fields) { + assert.Equal(t, fields["fields.time"], "hello") + }) +} + +func TestUserSuppliedLevelFieldHasPrefix(t *testing.T) { + LogAndAssertJSON(t, func(log *Logger) { + log.WithField("level", 1).Info("test") + }, func(fields Fields) { + assert.Equal(t, fields["level"], "info") + assert.Equal(t, fields["fields.level"], 1.0) // JSON has floats only + }) +} + +func TestDefaultFieldsAreNotPrefixed(t *testing.T) { + LogAndAssertText(t, func(log *Logger) { + ll := log.WithField("herp", "derp") + ll.Info("hello") + ll.Info("bye") + }, func(fields map[string]string) { + for _, fieldName := range []string{"fields.level", "fields.time", "fields.msg"} { + if _, ok := fields[fieldName]; ok { + t.Fatalf("should not have prefixed %q: %v", fieldName, fields) + } + } + }) +} + +func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) { + + var buffer bytes.Buffer + var fields Fields + + logger := New() + logger.Out = &buffer + logger.Formatter = new(JSONFormatter) + + llog := logger.WithField("context", "eating raw fish") + + llog.Info("looks delicious") + + err := json.Unmarshal(buffer.Bytes(), &fields) + assert.NoError(t, err, "should have decoded first message") + assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields") + assert.Equal(t, fields["msg"], "looks delicious") + assert.Equal(t, fields["context"], "eating raw fish") + + buffer.Reset() + + llog.Warn("omg it is!") + + err = json.Unmarshal(buffer.Bytes(), &fields) + assert.NoError(t, err, "should have decoded second message") + assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields") + assert.Equal(t, fields["msg"], "omg it is!") + assert.Equal(t, fields["context"], "eating raw fish") + assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry") + +} + +func TestConvertLevelToString(t *testing.T) { + assert.Equal(t, "debug", DebugLevel.String()) + assert.Equal(t, "info", InfoLevel.String()) + assert.Equal(t, "warning", WarnLevel.String()) + assert.Equal(t, "error", ErrorLevel.String()) + assert.Equal(t, "fatal", FatalLevel.String()) + assert.Equal(t, "panic", PanicLevel.String()) +} + +func TestParseLevel(t *testing.T) { + l, err := ParseLevel("panic") + assert.Nil(t, err) + assert.Equal(t, PanicLevel, l) + + l, err = ParseLevel("fatal") + assert.Nil(t, err) + assert.Equal(t, FatalLevel, l) + + l, err = ParseLevel("error") + assert.Nil(t, err) + assert.Equal(t, ErrorLevel, l) + + l, err = ParseLevel("warn") + assert.Nil(t, err) + assert.Equal(t, WarnLevel, l) + + l, err = ParseLevel("warning") + assert.Nil(t, err) + assert.Equal(t, WarnLevel, l) + + l, err = ParseLevel("info") + assert.Nil(t, err) + assert.Equal(t, InfoLevel, l) + + l, err = ParseLevel("debug") + assert.Nil(t, err) + assert.Equal(t, DebugLevel, l) + + l, err = ParseLevel("invalid") + assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error()) +} + +func TestGetSetLevelRace(t *testing.T) { + wg := sync.WaitGroup{} + for i := 0; i < 100; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + if i%2 == 0 { + SetLevel(InfoLevel) + } else { + GetLevel() + } + }(i) + + } + wg.Wait() +} diff --git a/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/vendor/github.com/Sirupsen/logrus/terminal_bsd.go new file mode 100644 index 00000000..71f8d67a --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_bsd.go @@ -0,0 +1,9 @@ +// +build darwin freebsd openbsd netbsd dragonfly + +package logrus + +import "syscall" + +const ioctlReadTermios = syscall.TIOCGETA + +type Termios syscall.Termios diff --git a/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/vendor/github.com/Sirupsen/logrus/terminal_linux.go new file mode 100644 index 00000000..a2c0b40d --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_linux.go @@ -0,0 +1,12 @@ +// Based on ssh/terminal: +// 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 logrus + +import "syscall" + +const ioctlReadTermios = syscall.TCGETS + +type Termios syscall.Termios diff --git a/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go b/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go new file mode 100644 index 00000000..b343b3a3 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go @@ -0,0 +1,21 @@ +// Based on ssh/terminal: +// 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 linux darwin freebsd openbsd netbsd dragonfly + +package logrus + +import ( + "syscall" + "unsafe" +) + +// IsTerminal returns true if stderr's file descriptor is a terminal. +func IsTerminal() bool { + fd := syscall.Stderr + var termios Termios + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 +} diff --git a/vendor/github.com/Sirupsen/logrus/terminal_solaris.go b/vendor/github.com/Sirupsen/logrus/terminal_solaris.go new file mode 100644 index 00000000..3e70bf7b --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_solaris.go @@ -0,0 +1,15 @@ +// +build solaris + +package logrus + +import ( + "os" + + "golang.org/x/sys/unix" +) + +// IsTerminal returns true if the given file descriptor is a terminal. +func IsTerminal() bool { + _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) + return err == nil +} diff --git a/vendor/github.com/Sirupsen/logrus/terminal_windows.go b/vendor/github.com/Sirupsen/logrus/terminal_windows.go new file mode 100644 index 00000000..0146845d --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/terminal_windows.go @@ -0,0 +1,27 @@ +// Based on ssh/terminal: +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package logrus + +import ( + "syscall" + "unsafe" +) + +var kernel32 = syscall.NewLazyDLL("kernel32.dll") + +var ( + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") +) + +// IsTerminal returns true if stderr's file descriptor is a terminal. +func IsTerminal() bool { + fd := syscall.Stderr + var st uint32 + r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) + return r != 0 && e == 0 +} diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter.go b/vendor/github.com/Sirupsen/logrus/text_formatter.go new file mode 100644 index 00000000..06ef2023 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/text_formatter.go @@ -0,0 +1,161 @@ +package logrus + +import ( + "bytes" + "fmt" + "runtime" + "sort" + "strings" + "time" +) + +const ( + nocolor = 0 + red = 31 + green = 32 + yellow = 33 + blue = 34 + gray = 37 +) + +var ( + baseTimestamp time.Time + isTerminal bool +) + +func init() { + baseTimestamp = time.Now() + isTerminal = IsTerminal() +} + +func miniTS() int { + return int(time.Since(baseTimestamp) / time.Second) +} + +type TextFormatter struct { + // Set to true to bypass checking for a TTY before outputting colors. + ForceColors bool + + // Force disabling colors. + DisableColors bool + + // Disable timestamp logging. useful when output is redirected to logging + // system that already adds timestamps. + DisableTimestamp bool + + // Enable logging the full timestamp when a TTY is attached instead of just + // the time passed since beginning of execution. + FullTimestamp bool + + // TimestampFormat to use for display when a full timestamp is printed + TimestampFormat string + + // The fields are sorted by default for a consistent output. For applications + // that log extremely frequently and don't use the JSON formatter this may not + // be desired. + DisableSorting bool +} + +func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { + var keys []string = make([]string, 0, len(entry.Data)) + for k := range entry.Data { + keys = append(keys, k) + } + + if !f.DisableSorting { + sort.Strings(keys) + } + + b := &bytes.Buffer{} + + prefixFieldClashes(entry.Data) + + isColorTerminal := isTerminal && (runtime.GOOS != "windows") + isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors + + timestampFormat := f.TimestampFormat + if timestampFormat == "" { + timestampFormat = DefaultTimestampFormat + } + if isColored { + f.printColored(b, entry, keys, timestampFormat) + } else { + if !f.DisableTimestamp { + f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) + } + f.appendKeyValue(b, "level", entry.Level.String()) + if entry.Message != "" { + f.appendKeyValue(b, "msg", entry.Message) + } + for _, key := range keys { + f.appendKeyValue(b, key, entry.Data[key]) + } + } + + b.WriteByte('\n') + return b.Bytes(), nil +} + +func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { + var levelColor int + switch entry.Level { + case DebugLevel: + levelColor = gray + case WarnLevel: + levelColor = yellow + case ErrorLevel, FatalLevel, PanicLevel: + levelColor = red + default: + levelColor = blue + } + + levelText := strings.ToUpper(entry.Level.String())[0:4] + + if !f.FullTimestamp { + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) + } else { + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) + } + for _, k := range keys { + v := entry.Data[k] + fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) + } +} + +func needsQuoting(text string) bool { + for _, ch := range text { + if !((ch >= 'a' && ch <= 'z') || + (ch >= 'A' && ch <= 'Z') || + (ch >= '0' && ch <= '9') || + ch == '-' || ch == '.') { + return false + } + } + return true +} + +func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { + + b.WriteString(key) + b.WriteByte('=') + + switch value := value.(type) { + case string: + if needsQuoting(value) { + b.WriteString(value) + } else { + fmt.Fprintf(b, "%q", value) + } + case error: + errmsg := value.Error() + if needsQuoting(errmsg) { + b.WriteString(errmsg) + } else { + fmt.Fprintf(b, "%q", value) + } + default: + fmt.Fprint(b, value) + } + + b.WriteByte(' ') +} diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter_test.go b/vendor/github.com/Sirupsen/logrus/text_formatter_test.go new file mode 100644 index 00000000..e25a44f6 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/text_formatter_test.go @@ -0,0 +1,61 @@ +package logrus + +import ( + "bytes" + "errors" + "testing" + "time" +) + +func TestQuoting(t *testing.T) { + tf := &TextFormatter{DisableColors: true} + + checkQuoting := func(q bool, value interface{}) { + b, _ := tf.Format(WithField("test", value)) + idx := bytes.Index(b, ([]byte)("test=")) + cont := bytes.Contains(b[idx+5:], []byte{'"'}) + if cont != q { + if q { + t.Errorf("quoting expected for: %#v", value) + } else { + t.Errorf("quoting not expected for: %#v", value) + } + } + } + + checkQuoting(false, "abcd") + checkQuoting(false, "v1.0") + checkQuoting(false, "1234567890") + checkQuoting(true, "/foobar") + checkQuoting(true, "x y") + checkQuoting(true, "x,y") + checkQuoting(false, errors.New("invalid")) + checkQuoting(true, errors.New("invalid argument")) +} + +func TestTimestampFormat(t *testing.T) { + checkTimeStr := func(format string) { + customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format} + customStr, _ := customFormatter.Format(WithField("test", "test")) + timeStart := bytes.Index(customStr, ([]byte)("time=")) + timeEnd := bytes.Index(customStr, ([]byte)("level=")) + timeStr := customStr[timeStart+5 : timeEnd-1] + if timeStr[0] == '"' && timeStr[len(timeStr)-1] == '"' { + timeStr = timeStr[1 : len(timeStr)-1] + } + if format == "" { + format = time.RFC3339 + } + _, e := time.Parse(format, (string)(timeStr)) + if e != nil { + t.Errorf("time string \"%s\" did not match provided time format \"%s\": %s", timeStr, format, e) + } + } + + checkTimeStr("2006-01-02T15:04:05.000000000Z07:00") + checkTimeStr("Mon Jan _2 15:04:05 2006") + checkTimeStr("") +} + +// TODO add tests for sorting etc., this requires a parser for the text +// formatter output. diff --git a/vendor/github.com/Sirupsen/logrus/writer.go b/vendor/github.com/Sirupsen/logrus/writer.go new file mode 100644 index 00000000..1e30b1c7 --- /dev/null +++ b/vendor/github.com/Sirupsen/logrus/writer.go @@ -0,0 +1,31 @@ +package logrus + +import ( + "bufio" + "io" + "runtime" +) + +func (logger *Logger) Writer() *io.PipeWriter { + reader, writer := io.Pipe() + + go logger.writerScanner(reader) + runtime.SetFinalizer(writer, writerFinalizer) + + return writer +} + +func (logger *Logger) writerScanner(reader *io.PipeReader) { + scanner := bufio.NewScanner(reader) + for scanner.Scan() { + logger.Print(scanner.Text()) + } + if err := scanner.Err(); err != nil { + logger.Errorf("Error while reading from Writer: %s", err) + } + reader.Close() +} + +func writerFinalizer(writer *io.PipeWriter) { + writer.Close() +} From cb6684f065a226bb983ad70d0ee04db17d764a5b Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 8 Apr 2016 14:02:19 -0700 Subject: [PATCH 002/357] Initial Dev --- .dockerignore | 3 + .gitignore | 9 +- Dockerfile.dapper | 60 +- README.md | 5 +- app/controller.go | 108 + app/controller_tcmu.go | 11 + app/replica.go | 86 + backend/dynamic/dynamic.go | 30 + backend/file/file.go | 48 + backend/remote/remote.go | 128 + controller/control.go | 218 + controller/multi_writer_at.go | 53 + controller/replicator.go | 123 + controller/rest/model.go | 101 + controller/rest/replica.go | 89 + controller/rest/router.go | 45 + controller/rest/volume.go | 87 + integration/core/test_controller.py | 127 + integration/core/test_replica.py | 204 + integration/requirements.txt | 4 + integration/setup.py | 10 + integration/tox.ini | 12 + main.go | 25 +- package/Dockerfile | 2 +- replica/diff_disk.go | 134 + replica/replica.go | 430 + replica/replica_test.go | 259 + replica/rest/model.go | 108 + replica/rest/replica.go | 85 + replica/rest/router.go | 31 + replica/rpc/server.go | 48 + replica/server.go | 136 + rpc/client.go | 125 + rpc/server.go | 84 + rpc/types.go | 24 + rpc/wire.go | 73 + scripts/build | 2 +- scripts/ci | 1 + scripts/integration-test | 12 + scripts/package | 4 + scripts/validate | 4 +- trash.yml | 19 + types/types.go | 51 + util/util.go | 23 + vendor/github.com/codegangsta/cli/.travis.yml | 18 + vendor/github.com/codegangsta/cli/LICENSE | 21 + vendor/github.com/codegangsta/cli/README.md | 434 + vendor/github.com/codegangsta/cli/app.go | 363 + vendor/github.com/codegangsta/cli/app_test.go | 1097 + .../github.com/codegangsta/cli/appveyor.yml | 16 + vendor/github.com/codegangsta/cli/category.go | 30 + vendor/github.com/codegangsta/cli/cli.go | 40 + vendor/github.com/codegangsta/cli/command.go | 262 + .../codegangsta/cli/command_test.go | 97 + vendor/github.com/codegangsta/cli/context.go | 393 + .../codegangsta/cli/context_test.go | 121 + vendor/github.com/codegangsta/cli/flag.go | 546 + .../github.com/codegangsta/cli/flag_test.go | 859 + vendor/github.com/codegangsta/cli/help.go | 253 + .../github.com/codegangsta/cli/help_test.go | 110 + .../codegangsta/cli/helpers_test.go | 19 + .../docker/go-units/CONTRIBUTING.md | 67 + .../github.com/docker/go-units/LICENSE.code | 191 + .../github.com/docker/go-units/LICENSE.docs | 425 + vendor/github.com/docker/go-units/MAINTAINERS | 27 + vendor/github.com/docker/go-units/README.md | 18 + vendor/github.com/docker/go-units/circle.yml | 11 + vendor/github.com/docker/go-units/duration.go | 33 + .../docker/go-units/duration_test.go | 81 + vendor/github.com/docker/go-units/size.go | 95 + .../github.com/docker/go-units/size_test.go | 163 + vendor/github.com/docker/go-units/ulimit.go | 118 + .../github.com/docker/go-units/ulimit_test.go | 74 + .../frostschutz/go-fibmap/.gitignore | 23 + .../github.com/frostschutz/go-fibmap/LICENSE | 21 + .../frostschutz/go-fibmap/README.md | 4 + .../frostschutz/go-fibmap/fibmap.go | 222 + vendor/github.com/gorilla/context/.travis.yml | 19 + vendor/github.com/gorilla/context/LICENSE | 27 + vendor/github.com/gorilla/context/README.md | 7 + vendor/github.com/gorilla/context/context.go | 143 + .../gorilla/context/context_test.go | 161 + vendor/github.com/gorilla/context/doc.go | 82 + .../github.com/gorilla/handlers/.travis.yml | 17 + vendor/github.com/gorilla/handlers/LICENSE | 22 + vendor/github.com/gorilla/handlers/README.md | 53 + .../github.com/gorilla/handlers/canonical.go | 74 + .../gorilla/handlers/canonical_test.go | 127 + .../github.com/gorilla/handlers/compress.go | 145 + .../gorilla/handlers/compress_test.go | 154 + vendor/github.com/gorilla/handlers/cors.go | 317 + .../github.com/gorilla/handlers/cors_test.go | 336 + vendor/github.com/gorilla/handlers/doc.go | 9 + .../github.com/gorilla/handlers/handlers.go | 403 + .../gorilla/handlers/handlers_test.go | 354 + .../gorilla/handlers/proxy_headers.go | 113 + .../gorilla/handlers/proxy_headers_test.go | 100 + .../github.com/gorilla/handlers/recovery.go | 86 + .../gorilla/handlers/recovery_test.go | 44 + vendor/github.com/gorilla/mux/.travis.yml | 20 + vendor/github.com/gorilla/mux/LICENSE | 27 + vendor/github.com/gorilla/mux/README.md | 242 + vendor/github.com/gorilla/mux/bench_test.go | 49 + vendor/github.com/gorilla/mux/doc.go | 206 + vendor/github.com/gorilla/mux/mux.go | 481 + vendor/github.com/gorilla/mux/mux_test.go | 1453 + vendor/github.com/gorilla/mux/old_test.go | 710 + vendor/github.com/gorilla/mux/regexp.go | 312 + vendor/github.com/gorilla/mux/route.go | 627 + .../github.com/gorilla/websocket/.gitignore | 22 + .../github.com/gorilla/websocket/.travis.yml | 20 + vendor/github.com/gorilla/websocket/AUTHORS | 8 + vendor/github.com/gorilla/websocket/LICENSE | 22 + vendor/github.com/gorilla/websocket/README.md | 61 + .../gorilla/websocket/bench_test.go | 19 + vendor/github.com/gorilla/websocket/client.go | 350 + .../gorilla/websocket/client_server_test.go | 451 + .../gorilla/websocket/client_test.go | 72 + vendor/github.com/gorilla/websocket/conn.go | 915 + .../github.com/gorilla/websocket/conn_test.go | 367 + vendor/github.com/gorilla/websocket/doc.go | 152 + .../gorilla/websocket/example_test.go | 46 + vendor/github.com/gorilla/websocket/json.go | 55 + .../github.com/gorilla/websocket/json_test.go | 119 + vendor/github.com/gorilla/websocket/server.go | 260 + .../gorilla/websocket/server_test.go | 51 + vendor/github.com/gorilla/websocket/util.go | 44 + .../github.com/gorilla/websocket/util_test.go | 34 + .../github.com/rancher/go-rancher/.drone.yml | 3 + .../github.com/rancher/go-rancher/.gitignore | 5 + vendor/github.com/rancher/go-rancher/.package | 1 + .../rancher/go-rancher/.wrap-docker-args | 1 + .../github.com/rancher/go-rancher/Dockerfile | 4 + vendor/github.com/rancher/go-rancher/LICENSE | 177 + .../github.com/rancher/go-rancher/README.md | 35 + .../github.com/rancher/go-rancher/api/api.go | 141 + .../rancher/go-rancher/api/context.go | 47 + .../rancher/go-rancher/api/handler.go | 115 + .../rancher/go-rancher/api/html_writer.go | 78 + .../rancher/go-rancher/api/json_writer.go | 22 + .../rancher/go-rancher/api/reader.go | 8 + .../github.com/rancher/go-rancher/api/url.go | 270 + .../rancher/go-rancher/api/writer.go | 146 + .../rancher/go-rancher/client/client.go | 7 + .../rancher/go-rancher/client/client_test.go | 218 + .../rancher/go-rancher/client/common.go | 531 + .../go-rancher/client/generated_account.go | 170 + .../client/generated_active_setting.go | 75 + .../client/generated_add_label_input.go | 64 + .../generated_add_load_balancer_input.go | 69 + .../client/generated_add_outputs_input.go | 67 + ...generated_add_remove_cluster_host_input.go | 67 + ...ted_add_remove_load_balancer_host_input.go | 67 + ...add_remove_load_balancer_listener_input.go | 67 + ...remove_load_balancer_service_link_input.go | 67 + ...d_add_remove_load_balancer_target_input.go | 67 + ...generated_add_remove_service_link_input.go | 67 + .../go-rancher/client/generated_agent.go | 183 + .../client/generated_amazonec2config.go | 101 + .../go-rancher/client/generated_api_key.go | 161 + .../go-rancher/client/generated_audit_log.go | 93 + .../client/generated_azure_config.go | 87 + .../client/generated_base_machine_config.go | 65 + .../client/generated_certificate.go | 139 + .../client/generated_change_secret_input.go | 69 + .../go-rancher/client/generated_client.go | 274 + .../go-rancher/client/generated_cluster.go | 223 + .../client/generated_compose_config.go | 69 + .../client/generated_compose_config_input.go | 67 + .../client/generated_config_item.go | 69 + .../client/generated_config_item_status.go | 81 + .../go-rancher/client/generated_container.go | 405 + .../client/generated_container_event.go | 117 + .../client/generated_container_exec.go | 73 + .../client/generated_container_logs.go | 69 + .../go-rancher/client/generated_credential.go | 161 + .../client/generated_databasechangelog.go | 85 + .../client/generated_databasechangeloglock.go | 71 + .../client/generated_digitalocean_config.go | 81 + .../client/generated_dns_service.go | 261 + .../client/generated_docker_build.go | 77 + .../client/generated_dynamic_schema.go | 115 + .../client/generated_environment.go | 248 + .../client/generated_environment_upgrade.go | 73 + .../client/generated_exoscale_config.go | 81 + .../generated_extension_implementation.go | 71 + .../client/generated_extension_point.go | 75 + .../client/generated_external_dns_event.go | 117 + .../client/generated_external_event.go | 111 + .../client/generated_external_handler.go | 174 + ...al_handler_external_handler_process_map.go | 172 + .../generated_external_handler_process.go | 166 + ...nerated_external_handler_process_config.go | 69 + .../client/generated_external_host_event.go | 117 + .../client/generated_external_service.go | 263 + .../generated_external_service_event.go | 115 + .../generated_external_storage_pool_event.go | 115 + .../client/generated_external_volume_event.go | 113 + .../client/generated_field_documentation.go | 67 + .../client/generated_githubconfig.go | 81 + .../client/generated_global_load_balancer.go | 139 + ...rated_global_load_balancer_health_check.go | 67 + .../generated_global_load_balancer_policy.go | 67 + .../client/generated_haproxy_config.go | 69 + ...generated_healthcheck_instance_host_map.go | 119 + .../go-rancher/client/generated_host.go | 197 + .../client/generated_host_access.go | 69 + .../client/generated_host_api_proxy_token.go | 71 + .../go-rancher/client/generated_identity.go | 83 + .../go-rancher/client/generated_image.go | 168 + .../generated_in_service_upgrade_strategy.go | 79 + .../go-rancher/client/generated_instance.go | 258 + .../client/generated_instance_console.go | 71 + .../generated_instance_console_input.go | 65 + .../client/generated_instance_health_check.go | 87 + .../client/generated_instance_link.go | 176 + .../client/generated_instance_stop.go | 71 + .../go-rancher/client/generated_ip_address.go | 183 + .../generated_ip_address_associate_input.go | 67 + .../go-rancher/client/generated_label.go | 117 + .../client/generated_launch_config.go | 413 + .../go-rancher/client/generated_ldapconfig.go | 109 + .../client/generated_load_balancer.go | 224 + ...d_balancer_app_cookie_stickiness_policy.go | 79 + .../client/generated_load_balancer_config.go | 69 + ...rated_load_balancer_config_listener_map.go | 117 + ..._load_balancer_cookie_stickiness_policy.go | 79 + .../generated_load_balancer_health_check.go | 79 + .../generated_load_balancer_host_map.go | 89 + .../generated_load_balancer_listener.go | 127 + .../client/generated_load_balancer_service.go | 273 + .../generated_load_balancer_service_link.go | 71 + .../client/generated_load_balancer_target.go | 132 + .../client/generated_local_auth_config.go | 75 + .../go-rancher/client/generated_log_config.go | 69 + .../go-rancher/client/generated_machine.go | 174 + .../client/generated_machine_driver.go | 163 + .../generated_machine_driver_error_input.go | 67 + .../generated_machine_driver_update_input.go | 71 + .../go-rancher/client/generated_mount.go | 132 + .../go-rancher/client/generated_network.go | 168 + .../client/generated_openldapconfig.go | 109 + .../client/generated_openstack_config.go | 107 + .../client/generated_packet_config.go | 77 + .../go-rancher/client/generated_password.go | 172 + .../client/generated_physical_host.go | 150 + .../go-rancher/client/generated_port.go | 180 + .../client/generated_process_definition.go | 79 + .../client/generated_process_execution.go | 71 + .../client/generated_process_instance.go | 89 + .../go-rancher/client/generated_project.go | 187 + .../client/generated_project_member.go | 174 + .../client/generated_public_endpoint.go | 75 + .../go-rancher/client/generated_publish.go | 87 + .../go-rancher/client/generated_pull_task.go | 99 + .../client/generated_rackspace_config.go | 83 + ...ated_recreate_on_quorum_strategy_config.go | 67 + .../go-rancher/client/generated_register.go | 108 + .../client/generated_registration_token.go | 165 + .../go-rancher/client/generated_registry.go | 174 + .../client/generated_registry_credential.go | 165 + .../client/generated_remove_label_input.go | 62 + .../generated_remove_load_balancer_input.go | 67 + .../client/generated_resource_definition.go | 67 + .../client/generated_restart_policy.go | 69 + .../generated_rolling_restart_strategy.go | 69 + .../generated_secondary_launch_config.go | 415 + .../go-rancher/client/generated_service.go | 275 + .../client/generated_service_consume_map.go | 130 + .../client/generated_service_event.go | 123 + .../client/generated_service_expose_map.go | 121 + .../client/generated_service_link.go | 71 + .../client/generated_service_restart.go | 67 + .../client/generated_service_upgrade.go | 69 + .../generated_service_upgrade_strategy.go | 69 + .../client/generated_services_port_range.go | 69 + .../client/generated_set_labels_input.go | 67 + ...generated_set_load_balancer_hosts_input.go | 67 + ...rated_set_load_balancer_listeners_input.go | 67 + ...d_set_load_balancer_service_links_input.go | 67 + ...nerated_set_load_balancer_targets_input.go | 67 + .../generated_set_project_members_input.go | 67 + .../generated_set_service_links_input.go | 67 + .../go-rancher/client/generated_setting.go | 69 + .../go-rancher/client/generated_snapshot.go | 128 + .../client/generated_softlayer_config.go | 95 + .../client/generated_state_transition.go | 65 + .../client/generated_stats_access.go | 69 + .../client/generated_storage_pool.go | 172 + .../go-rancher/client/generated_subscribe.go | 69 + .../go-rancher/client/generated_task.go | 78 + .../client/generated_task_instance.go | 77 + .../generated_to_service_upgrade_strategy.go | 75 + .../client/generated_type_documentation.go | 69 + .../client/generated_ubiquity_config.go | 77 + .../client/generated_user_preference.go | 165 + .../client/generated_virtual_machine.go | 375 + .../client/generated_virtual_machine_disk.go | 75 + .../client/generated_virtualbox_config.go | 79 + .../generated_vmwarevcloudair_config.go | 93 + .../client/generated_vmwarevsphere_config.go | 89 + .../go-rancher/client/generated_volume.go | 204 + .../rancher/go-rancher/client/schemas.go | 129 + .../rancher/go-rancher/client/types.go | 97 + vendor/github.com/rancher/go-rancher/main.go | 10 + .../rancher/go-rancher/schemas.json | 25862 ++++++++++++++++ vendor/gopkg.in/check.v1/.gitignore | 4 + vendor/gopkg.in/check.v1/LICENSE | 25 + vendor/gopkg.in/check.v1/README.md | 20 + vendor/gopkg.in/check.v1/TODO | 2 + vendor/gopkg.in/check.v1/benchmark.go | 187 + vendor/gopkg.in/check.v1/benchmark_test.go | 91 + vendor/gopkg.in/check.v1/bootstrap_test.go | 82 + vendor/gopkg.in/check.v1/check.go | 873 + vendor/gopkg.in/check.v1/check_test.go | 207 + vendor/gopkg.in/check.v1/checkers.go | 458 + vendor/gopkg.in/check.v1/checkers_test.go | 272 + vendor/gopkg.in/check.v1/export_test.go | 19 + vendor/gopkg.in/check.v1/fixture_test.go | 484 + vendor/gopkg.in/check.v1/foundation_test.go | 335 + vendor/gopkg.in/check.v1/helpers.go | 231 + vendor/gopkg.in/check.v1/helpers_test.go | 519 + vendor/gopkg.in/check.v1/printer.go | 168 + vendor/gopkg.in/check.v1/printer_test.go | 104 + vendor/gopkg.in/check.v1/reporter.go | 88 + vendor/gopkg.in/check.v1/reporter_test.go | 159 + vendor/gopkg.in/check.v1/run.go | 175 + vendor/gopkg.in/check.v1/run_test.go | 419 + 328 files changed, 70320 insertions(+), 17 deletions(-) create mode 100644 app/controller.go create mode 100644 app/controller_tcmu.go create mode 100644 app/replica.go create mode 100644 backend/dynamic/dynamic.go create mode 100644 backend/file/file.go create mode 100644 backend/remote/remote.go create mode 100644 controller/control.go create mode 100644 controller/multi_writer_at.go create mode 100644 controller/replicator.go create mode 100644 controller/rest/model.go create mode 100644 controller/rest/replica.go create mode 100644 controller/rest/router.go create mode 100644 controller/rest/volume.go create mode 100644 integration/core/test_controller.py create mode 100644 integration/core/test_replica.py create mode 100644 integration/requirements.txt create mode 100644 integration/setup.py create mode 100644 integration/tox.ini create mode 100644 replica/diff_disk.go create mode 100644 replica/replica.go create mode 100644 replica/replica_test.go create mode 100644 replica/rest/model.go create mode 100644 replica/rest/replica.go create mode 100644 replica/rest/router.go create mode 100644 replica/rpc/server.go create mode 100644 replica/server.go create mode 100644 rpc/client.go create mode 100644 rpc/server.go create mode 100644 rpc/types.go create mode 100644 rpc/wire.go create mode 100755 scripts/integration-test create mode 100644 types/types.go create mode 100644 util/util.go create mode 100644 vendor/github.com/codegangsta/cli/.travis.yml create mode 100644 vendor/github.com/codegangsta/cli/LICENSE create mode 100644 vendor/github.com/codegangsta/cli/README.md create mode 100644 vendor/github.com/codegangsta/cli/app.go create mode 100644 vendor/github.com/codegangsta/cli/app_test.go create mode 100644 vendor/github.com/codegangsta/cli/appveyor.yml create mode 100644 vendor/github.com/codegangsta/cli/category.go create mode 100644 vendor/github.com/codegangsta/cli/cli.go create mode 100644 vendor/github.com/codegangsta/cli/command.go create mode 100644 vendor/github.com/codegangsta/cli/command_test.go create mode 100644 vendor/github.com/codegangsta/cli/context.go create mode 100644 vendor/github.com/codegangsta/cli/context_test.go create mode 100644 vendor/github.com/codegangsta/cli/flag.go create mode 100644 vendor/github.com/codegangsta/cli/flag_test.go create mode 100644 vendor/github.com/codegangsta/cli/help.go create mode 100644 vendor/github.com/codegangsta/cli/help_test.go create mode 100644 vendor/github.com/codegangsta/cli/helpers_test.go create mode 100644 vendor/github.com/docker/go-units/CONTRIBUTING.md create mode 100644 vendor/github.com/docker/go-units/LICENSE.code create mode 100644 vendor/github.com/docker/go-units/LICENSE.docs create mode 100644 vendor/github.com/docker/go-units/MAINTAINERS create mode 100644 vendor/github.com/docker/go-units/README.md create mode 100644 vendor/github.com/docker/go-units/circle.yml create mode 100644 vendor/github.com/docker/go-units/duration.go create mode 100644 vendor/github.com/docker/go-units/duration_test.go create mode 100644 vendor/github.com/docker/go-units/size.go create mode 100644 vendor/github.com/docker/go-units/size_test.go create mode 100644 vendor/github.com/docker/go-units/ulimit.go create mode 100644 vendor/github.com/docker/go-units/ulimit_test.go create mode 100644 vendor/github.com/frostschutz/go-fibmap/.gitignore create mode 100644 vendor/github.com/frostschutz/go-fibmap/LICENSE create mode 100644 vendor/github.com/frostschutz/go-fibmap/README.md create mode 100644 vendor/github.com/frostschutz/go-fibmap/fibmap.go create mode 100644 vendor/github.com/gorilla/context/.travis.yml create mode 100644 vendor/github.com/gorilla/context/LICENSE create mode 100644 vendor/github.com/gorilla/context/README.md create mode 100644 vendor/github.com/gorilla/context/context.go create mode 100644 vendor/github.com/gorilla/context/context_test.go create mode 100644 vendor/github.com/gorilla/context/doc.go create mode 100644 vendor/github.com/gorilla/handlers/.travis.yml create mode 100644 vendor/github.com/gorilla/handlers/LICENSE create mode 100644 vendor/github.com/gorilla/handlers/README.md create mode 100644 vendor/github.com/gorilla/handlers/canonical.go create mode 100644 vendor/github.com/gorilla/handlers/canonical_test.go create mode 100644 vendor/github.com/gorilla/handlers/compress.go create mode 100644 vendor/github.com/gorilla/handlers/compress_test.go create mode 100644 vendor/github.com/gorilla/handlers/cors.go create mode 100644 vendor/github.com/gorilla/handlers/cors_test.go create mode 100644 vendor/github.com/gorilla/handlers/doc.go create mode 100644 vendor/github.com/gorilla/handlers/handlers.go create mode 100644 vendor/github.com/gorilla/handlers/handlers_test.go create mode 100644 vendor/github.com/gorilla/handlers/proxy_headers.go create mode 100644 vendor/github.com/gorilla/handlers/proxy_headers_test.go create mode 100644 vendor/github.com/gorilla/handlers/recovery.go create mode 100644 vendor/github.com/gorilla/handlers/recovery_test.go create mode 100644 vendor/github.com/gorilla/mux/.travis.yml create mode 100644 vendor/github.com/gorilla/mux/LICENSE create mode 100644 vendor/github.com/gorilla/mux/README.md create mode 100644 vendor/github.com/gorilla/mux/bench_test.go 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/mux_test.go create mode 100644 vendor/github.com/gorilla/mux/old_test.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/gorilla/websocket/.gitignore create mode 100644 vendor/github.com/gorilla/websocket/.travis.yml create mode 100644 vendor/github.com/gorilla/websocket/AUTHORS create mode 100644 vendor/github.com/gorilla/websocket/LICENSE create mode 100644 vendor/github.com/gorilla/websocket/README.md create mode 100644 vendor/github.com/gorilla/websocket/bench_test.go create mode 100644 vendor/github.com/gorilla/websocket/client.go create mode 100644 vendor/github.com/gorilla/websocket/client_server_test.go create mode 100644 vendor/github.com/gorilla/websocket/client_test.go create mode 100644 vendor/github.com/gorilla/websocket/conn.go create mode 100644 vendor/github.com/gorilla/websocket/conn_test.go create mode 100644 vendor/github.com/gorilla/websocket/doc.go create mode 100644 vendor/github.com/gorilla/websocket/example_test.go create mode 100644 vendor/github.com/gorilla/websocket/json.go create mode 100644 vendor/github.com/gorilla/websocket/json_test.go create mode 100644 vendor/github.com/gorilla/websocket/server.go create mode 100644 vendor/github.com/gorilla/websocket/server_test.go create mode 100644 vendor/github.com/gorilla/websocket/util.go create mode 100644 vendor/github.com/gorilla/websocket/util_test.go create mode 100644 vendor/github.com/rancher/go-rancher/.drone.yml create mode 100644 vendor/github.com/rancher/go-rancher/.gitignore create mode 100644 vendor/github.com/rancher/go-rancher/.package create mode 100644 vendor/github.com/rancher/go-rancher/.wrap-docker-args create mode 100644 vendor/github.com/rancher/go-rancher/Dockerfile create mode 100644 vendor/github.com/rancher/go-rancher/LICENSE create mode 100644 vendor/github.com/rancher/go-rancher/README.md create mode 100644 vendor/github.com/rancher/go-rancher/api/api.go create mode 100644 vendor/github.com/rancher/go-rancher/api/context.go create mode 100644 vendor/github.com/rancher/go-rancher/api/handler.go create mode 100644 vendor/github.com/rancher/go-rancher/api/html_writer.go create mode 100644 vendor/github.com/rancher/go-rancher/api/json_writer.go create mode 100644 vendor/github.com/rancher/go-rancher/api/reader.go create mode 100644 vendor/github.com/rancher/go-rancher/api/url.go create mode 100644 vendor/github.com/rancher/go-rancher/api/writer.go create mode 100644 vendor/github.com/rancher/go-rancher/client/client.go create mode 100644 vendor/github.com/rancher/go-rancher/client/client_test.go create mode 100644 vendor/github.com/rancher/go-rancher/client/common.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_account.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_active_setting.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_label_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_load_balancer_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_outputs_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_remove_cluster_host_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_host_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_listener_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_service_link_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_target_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_add_remove_service_link_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_agent.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_amazonec2config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_api_key.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_audit_log.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_azure_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_base_machine_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_certificate.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_change_secret_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_client.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_cluster.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_compose_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_compose_config_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_config_item.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_config_item_status.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_container.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_container_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_container_exec.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_container_logs.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_credential.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_databasechangelog.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_databasechangeloglock.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_digitalocean_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_dns_service.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_docker_build.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_dynamic_schema.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_environment.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_environment_upgrade.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_exoscale_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_extension_implementation.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_extension_point.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_dns_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_handler.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_handler_external_handler_process_map.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_handler_process.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_handler_process_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_host_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_service.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_service_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_storage_pool_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_external_volume_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_field_documentation.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_githubconfig.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_health_check.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_policy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_haproxy_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_healthcheck_instance_host_map.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_host.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_host_access.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_host_api_proxy_token.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_identity.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_image.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_in_service_upgrade_strategy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_instance.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_instance_console.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_instance_console_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_instance_health_check.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_instance_link.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_instance_stop.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_ip_address.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_ip_address_associate_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_label.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_launch_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_ldapconfig.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_app_cookie_stickiness_policy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config_listener_map.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_cookie_stickiness_policy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_health_check.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_host_map.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_listener.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service_link.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_load_balancer_target.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_local_auth_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_log_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_machine.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_machine_driver.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_machine_driver_error_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_machine_driver_update_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_mount.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_network.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_openldapconfig.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_openstack_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_packet_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_password.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_physical_host.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_port.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_process_definition.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_process_execution.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_process_instance.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_project.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_project_member.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_public_endpoint.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_publish.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_pull_task.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_rackspace_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_recreate_on_quorum_strategy_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_register.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_registration_token.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_registry.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_registry_credential.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_remove_label_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_remove_load_balancer_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_resource_definition.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_restart_policy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_rolling_restart_strategy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_consume_map.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_event.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_expose_map.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_link.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_restart.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_upgrade.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_service_upgrade_strategy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_services_port_range.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_labels_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_hosts_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_listeners_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_service_links_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_targets_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_project_members_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_set_service_links_input.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_setting.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_snapshot.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_softlayer_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_state_transition.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_stats_access.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_storage_pool.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_subscribe.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_task.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_task_instance.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_to_service_upgrade_strategy.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_type_documentation.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_ubiquity_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_user_preference.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_virtual_machine.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_virtual_machine_disk.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_virtualbox_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_vmwarevcloudair_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_vmwarevsphere_config.go create mode 100644 vendor/github.com/rancher/go-rancher/client/generated_volume.go create mode 100644 vendor/github.com/rancher/go-rancher/client/schemas.go create mode 100644 vendor/github.com/rancher/go-rancher/client/types.go create mode 100644 vendor/github.com/rancher/go-rancher/main.go create mode 100644 vendor/github.com/rancher/go-rancher/schemas.json create mode 100644 vendor/gopkg.in/check.v1/.gitignore create mode 100644 vendor/gopkg.in/check.v1/LICENSE create mode 100644 vendor/gopkg.in/check.v1/README.md create mode 100644 vendor/gopkg.in/check.v1/TODO create mode 100644 vendor/gopkg.in/check.v1/benchmark.go create mode 100644 vendor/gopkg.in/check.v1/benchmark_test.go create mode 100644 vendor/gopkg.in/check.v1/bootstrap_test.go create mode 100644 vendor/gopkg.in/check.v1/check.go create mode 100644 vendor/gopkg.in/check.v1/check_test.go create mode 100644 vendor/gopkg.in/check.v1/checkers.go create mode 100644 vendor/gopkg.in/check.v1/checkers_test.go create mode 100644 vendor/gopkg.in/check.v1/export_test.go create mode 100644 vendor/gopkg.in/check.v1/fixture_test.go create mode 100644 vendor/gopkg.in/check.v1/foundation_test.go create mode 100644 vendor/gopkg.in/check.v1/helpers.go create mode 100644 vendor/gopkg.in/check.v1/helpers_test.go create mode 100644 vendor/gopkg.in/check.v1/printer.go create mode 100644 vendor/gopkg.in/check.v1/printer_test.go create mode 100644 vendor/gopkg.in/check.v1/reporter.go create mode 100644 vendor/gopkg.in/check.v1/reporter_test.go create mode 100644 vendor/gopkg.in/check.v1/run.go create mode 100644 vendor/gopkg.in/check.v1/run_test.go diff --git a/.dockerignore b/.dockerignore index 6e43c2a9..e6931726 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,6 @@ ./.dapper ./dist ./.trash-cache +./integration/.venv +./integration/.tox +./integration/.idea diff --git a/.gitignore b/.gitignore index d43bb90f..514ba1cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ /.dapper +/.trash-cache /bin +*.pyc +*.pyo *.swp -/.trash-cache + +integration/.idea/ +integration/.tox/ +integration/.venv/ +integration/MANIFEST diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 4a60711a..2c109319 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,15 +1,57 @@ -FROM golang:1.6 -RUN go get github.com/rancher/trash -RUN go get github.com/golang/lint/golint -RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ - chmod +x /usr/bin/docker +FROM ubuntu:16.04 + +# Setup environment ENV PATH /go/bin:$PATH -ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn -ENV DAPPER_OUTPUT bin ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_ENV TAG REPO -ENV GO15VENDOREXPERIMENT 1 +ENV DAPPER_OUTPUT bin +ENV DAPPER_RUN_ARGS --privileged +ENV DAPPER_RUN_ARGS --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec +ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} + +# Install packages +RUN apt-get update && \ + apt-get install -y \ + curl \ + git \ + python-tox \ + cmake \ + pkg-config \ + libglib2.0-dev \ + libkmod-dev \ + libnl-genl-3-dev \ + linux-libc-dev + +# Install Go 1.6 +RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz +RUN echo '6d894da8b4ad3f7f6c295db0d73ccc3646bce630e1c43e662a0120681d47e988 go.tar.gz' | sha256sum -c && \ + tar xvzf go.tar.gz -C /usr/local && \ + rm go.tar.gz +RUN mkdir -p /go +ENV PATH $PATH:/usr/local/go/bin +ENV GOPATH=/go + +# Go tools +RUN go get github.com/rancher/trash +RUN go get github.com/golang/lint/golint + +# Docker +RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ + chmod +x /usr/bin/docker + +# Build TCMU +RUN cd /usr/src && \ + git clone https://github.com/agrover/tcmu-runner.git && \ + cd tcmu-runner && \ + git checkout 9b6d458cd3106ee75b1800cb2fbfb6ffe545b669 +RUN cd /usr/src/tcmu-runner && \ + cmake . -Dwith-glfs=false && \ + make && \ + make install && \ + cp scsi_defs.h /usr/local/include && \ + cp libtcmu_static.a /usr/local/lib/libtcmu.a + ENTRYPOINT ["./scripts/entry"] -CMD ["ci"] +CMD ["build"] diff --git a/README.md b/README.md index 49dd4da6..80b278e2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,10 @@ A microservice that does micro things. ## Running -`./bin/longhorn` + ./bin/longhorn replica --size 10g /opt/volume + ./bin/longhorn controller --frontend tcmu vol-name --replica tcp://localhost:9052 + +That will create the device `/dev/longhorn/vol-name` ## License Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) diff --git a/app/controller.go b/app/controller.go new file mode 100644 index 00000000..a97f7a00 --- /dev/null +++ b/app/controller.go @@ -0,0 +1,108 @@ +package app + +import ( + "errors" + "fmt" + "log" + "net/http" + "os" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/gorilla/handlers" + "github.com/rancher/longhorn/backend/dynamic" + "github.com/rancher/longhorn/backend/file" + "github.com/rancher/longhorn/backend/remote" + "github.com/rancher/longhorn/controller" + "github.com/rancher/longhorn/controller/rest" + "github.com/rancher/longhorn/types" +) + +var ( + frontends = map[string]types.Frontend{} +) + +func ControllerCmd() cli.Command { + return cli.Command{ + Name: "controller", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "listen", + Value: "localhost:9501", + }, + cli.StringFlag{ + Name: "frontend", + Value: "", + }, + cli.StringSliceFlag{ + Name: "enable-backend", + Value: (*cli.StringSlice)(&[]string{"tcp"}), + }, + cli.StringSliceFlag{ + Name: "replica", + }, + cli.BoolFlag{ + Name: "debug", + }, + }, + Action: func(c *cli.Context) { + if err := startController(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func startController(c *cli.Context) error { + if c.NArg() == 0 { + return errors.New("volume name is required") + } + name := c.Args()[0] + + listen := c.String("listen") + backends := c.StringSlice("enable-backend") + replicas := c.StringSlice("replica") + frontendName := c.String("frontend") + + if c.Bool("debug") { + logrus.SetLevel(logrus.DebugLevel) + } + + factories := map[string]types.BackendFactory{} + for _, backend := range backends { + switch backend { + case "file": + factories[backend] = file.New() + case "tcp": + factories[backend] = remote.New() + default: + logrus.Fatalf("Unsupported backend: %s", backend) + } + } + + var frontend types.Frontend + if frontendName != "" { + f, ok := frontends[frontendName] + if !ok { + return fmt.Errorf("Failed to find frontend: %s", frontendName) + } + frontend = f + } + + control := controller.NewController(name, dynamic.New(factories), frontend) + server := rest.NewServer(control) + router := http.Handler(rest.NewRouter(server)) + + router = handlers.LoggingHandler(os.Stdout, router) + router = handlers.ProxyHeaders(router) + + if len(replicas) > 0 { + logrus.Infof("Starting with replicas %q", replicas) + if err := control.Start(replicas...); err != nil { + log.Fatal(err) + } + } + + logrus.Infof("Listening on %s", listen) + return http.ListenAndServe(listen, router) +} diff --git a/app/controller_tcmu.go b/app/controller_tcmu.go new file mode 100644 index 00000000..62097083 --- /dev/null +++ b/app/controller_tcmu.go @@ -0,0 +1,11 @@ +// +build tcmu + +package app + +import ( + "github.com/rancher/longhorn/frontend/tcmu" +) + +func init() { + frontends["tcmu"] = tcmu.New() +} diff --git a/app/replica.go b/app/replica.go new file mode 100644 index 00000000..1e22eec5 --- /dev/null +++ b/app/replica.go @@ -0,0 +1,86 @@ +package app + +import ( + "errors" + "net/http" + "os" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/docker/go-units" + "github.com/gorilla/handlers" + "github.com/rancher/longhorn/replica" + "github.com/rancher/longhorn/replica/rest" + "github.com/rancher/longhorn/replica/rpc" + "github.com/rancher/longhorn/util" +) + +func ReplicaCmd() cli.Command { + return cli.Command{ + Name: "replica", + UsageText: "longhorn controller DIRECTORY SIZE", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "listen", + Value: "localhost:9502", + }, + cli.BoolFlag{ + Name: "debug", + }, + cli.StringFlag{ + Name: "size", + Usage: "Volume size in bytes or human readable 42kb, 42mb, 42gb", + }, + }, + Action: func(c *cli.Context) { + if err := startReplica(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func startReplica(c *cli.Context) error { + if c.NArg() != 1 { + return errors.New("directory name is required") + } + + dir := c.Args()[0] + s := replica.NewServer(dir, 4096) + + address := c.String("listen") + size := c.String("size") + if size != "" { + size, err := units.RAMInBytes(size) + if err != nil { + return err + } + + if err := s.Open(size); err != nil { + return err + } + } + + controlAddress, dataAddress, err := util.ParseAddresses(address) + if err != nil { + return err + } + + resp := make(chan error) + + go func() { + server := rest.NewServer(s) + router := http.Handler(rest.NewRouter(server)) + router = handlers.LoggingHandler(os.Stdout, router) + logrus.Infof("Listening on control %s", controlAddress) + resp <- http.ListenAndServe(controlAddress, router) + }() + + go func() { + rpcServer := rpc.New(dataAddress, s) + logrus.Infof("Listening on data %s", dataAddress) + resp <- rpcServer.ListenAndServe() + }() + + return <-resp +} diff --git a/backend/dynamic/dynamic.go b/backend/dynamic/dynamic.go new file mode 100644 index 00000000..310a4426 --- /dev/null +++ b/backend/dynamic/dynamic.go @@ -0,0 +1,30 @@ +package dynamic + +import ( + "fmt" + "strings" + + "github.com/rancher/longhorn/types" +) + +type Factory struct { + factories map[string]types.BackendFactory +} + +func New(factories map[string]types.BackendFactory) types.BackendFactory { + return &Factory{ + factories: factories, + } +} + +func (d *Factory) Create(address string) (types.Backend, error) { + parts := strings.SplitN(address, "://", 2) + + if len(parts) == 2 { + if factory, ok := d.factories[parts[0]]; ok { + return factory.Create(parts[1]) + } + } + + return nil, fmt.Errorf("Failed to find factory for %s", address) +} diff --git a/backend/file/file.go b/backend/file/file.go new file mode 100644 index 00000000..1e6e35e0 --- /dev/null +++ b/backend/file/file.go @@ -0,0 +1,48 @@ +package file + +import ( + "os" + "syscall" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" +) + +func New() types.BackendFactory { + return &Factory{} +} + +type Factory struct { +} + +type Wrapper struct { + *os.File +} + +func (f *Wrapper) Close() error { + logrus.Infof("Closing: %s", f.Name()) + return f.File.Close() +} + +func (f *Wrapper) Snapshot() error { + return nil +} + +func (f *Wrapper) Size() (int64, error) { + stat, err := f.Stat() + if err != nil { + return 0, err + } + return stat.Size(), nil +} + +func (ff *Factory) Create(address string) (types.Backend, error) { + logrus.Infof("Creating file: %s", address) + file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE|syscall.O_DIRECT, 0600) + if err != nil { + logrus.Infof("Failed to create file %s: %v", address, err) + return nil, err + } + + return &Wrapper{file}, nil +} diff --git a/backend/remote/remote.go b/backend/remote/remote.go new file mode 100644 index 00000000..bb28a21e --- /dev/null +++ b/backend/remote/remote.go @@ -0,0 +1,128 @@ +package remote + +import ( + "encoding/json" + "fmt" + "net" + "net/http" + "strconv" + "time" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/replica/rest" + "github.com/rancher/longhorn/rpc" + "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" +) + +var ( + timeout = 30 * time.Second + requestBuffer = 1024 +) + +func New() types.BackendFactory { + return &Factory{} +} + +type Factory struct { +} + +type Remote struct { + types.ReaderWriterAt + name string + replicaURL string + httpClient *http.Client +} + +func (r *Remote) Close() error { + logrus.Infof("Closing: %s", r.name) + return r.doAction("close") +} + +func (r *Remote) Snapshot() error { + logrus.Infof("Snapshot: %s", r.name) + return r.doAction("snapshot") +} + +func (r *Remote) doAction(action string) error { + req, err := http.NewRequest("POST", r.replicaURL+"?action="+action, nil) + if err != nil { + return err + } + + resp, err := r.httpClient.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("Bad status: %d %s", resp.StatusCode, resp.Status) + } + + return nil +} + +func (r *Remote) Size() (int64, error) { + replica, err := r.info() + if err != nil { + return 0, err + } + return strconv.ParseInt(replica.Size, 10, 0) +} + +func (r *Remote) info() (rest.Replica, error) { + var replica rest.Replica + req, err := http.NewRequest("GET", r.replicaURL, nil) + if err != nil { + return replica, err + } + + resp, err := r.httpClient.Do(req) + if err != nil { + return replica, err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return replica, fmt.Errorf("Bad status: %d %s", resp.StatusCode, resp.Status) + } + + err = json.NewDecoder(resp.Body).Decode(&replica) + return replica, err +} + +func (rf *Factory) Create(address string) (types.Backend, error) { + logrus.Infof("Conneting to remote: %s", address) + + controlAddress, dataAddress, err := util.ParseAddresses(address) + if err != nil { + return nil, err + } + + r := &Remote{ + name: address, + replicaURL: fmt.Sprintf("http://%s/v1/replicas/1", controlAddress), + httpClient: &http.Client{ + Timeout: timeout, + }, + } + + replica, err := r.info() + if err != nil { + return nil, err + } + + if replica.State != rest.StateOpen { + return nil, fmt.Errorf("Can not add replica in state: %s", replica.State) + } + + conn, err := net.Dial("tcp", dataAddress) + if err != nil { + return nil, err + } + + r.ReaderWriterAt = rpc.NewClient(conn) + + return r, nil +} diff --git a/controller/control.go b/controller/control.go new file mode 100644 index 00000000..e4ea01d2 --- /dev/null +++ b/controller/control.go @@ -0,0 +1,218 @@ +package controller + +import ( + "fmt" + "sync" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" +) + +type Controller struct { + sync.RWMutex + Name string + size int64 + replicas []types.Replica + factory types.BackendFactory + backend *replicator + frontend types.Frontend +} + +func NewController(name string, factory types.BackendFactory, frontend types.Frontend) *Controller { + c := &Controller{ + factory: factory, + Name: name, + frontend: frontend, + } + c.reset() + return c +} + +func (c *Controller) AddReplica(address string) error { + return c.addReplica(address, true) +} + +func (c *Controller) addReplica(address string, snapshot bool) error { + newBackend, err := c.factory.Create(address) + if err != nil { + return err + } + + c.Lock() + defer c.Unlock() + + return c.addReplicaNoLock(newBackend, address, snapshot) +} + +func (c *Controller) Snapshot() error { + c.Lock() + defer c.Unlock() + + return c.backend.Snapshot() +} + +func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { + if c.hasReplica(address) { + newBackend.Close() + return nil + } + + if snapshot { + if err := c.backend.Snapshot(); err != nil { + newBackend.Close() + return err + } + } + + c.replicas = append(c.replicas, types.Replica{ + Address: address, + Mode: types.WO, + }) + + c.backend.AddBackend(address, newBackend) + + return nil +} + +func (c *Controller) hasReplica(address string) bool { + for _, i := range c.replicas { + if i.Address == address { + return true + } + } + return false +} + +func (c *Controller) RemoveReplica(address string) error { + c.Lock() + defer c.Unlock() + + if !c.hasReplica(address) { + return nil + } + + for i, r := range c.replicas { + if r.Address == address { + c.replicas = append(c.replicas[:i], c.replicas[i+1:]...) + c.backend.RemoveBackend(r.Address) + } + } + + return nil +} + +func (c *Controller) ListReplicas() []types.Replica { + return c.replicas +} + +func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { + switch mode { + case types.ERR: + c.Lock() + defer c.Unlock() + case types.RW: + c.RLock() + c.RUnlock() + default: + return fmt.Errorf("Can not set to mode %s", mode) + } + + c.setReplicaModeNoLock(address, mode) + return nil +} + +func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { + for i, r := range c.replicas { + if r.Mode != types.ERR && r.Address == address { + r.Mode = mode + c.replicas[i] = r + c.backend.SetMode(address, mode) + } + } +} + +func (c *Controller) Start(addresses ...string) error { + c.Lock() + defer c.Unlock() + + if len(addresses) == 0 { + return nil + } + + if len(c.replicas) > 0 { + return nil + } + + c.reset() + + defer func() { + if len(c.replicas) > 0 && c.frontend != nil { + if err := c.frontend.Activate(c.Name, c.size, c); err != nil { + // FATAL + logrus.Fatalf("Failed to activate frontend: %v", err) + } + } + }() + + first := true + for _, address := range addresses { + newBackend, err := c.factory.Create(address) + if err != nil { + return err + } + + newSize, err := newBackend.Size() + if err != nil { + return err + } + + if first { + first = false + c.size = newSize + } else if c.size != newSize { + return fmt.Errorf("Backend sizes do not match %d != %d", c.size, newSize) + } + + if err := c.addReplicaNoLock(newBackend, address, false); err != nil { + return err + } + c.setReplicaModeNoLock(address, types.RW) + } + + return nil +} + +func (c *Controller) WriteAt(b []byte, off int64) (n int, err error) { + return c.backend.WriteAt(b, off) +} + +func (c *Controller) ReadAt(b []byte, off int64) (n int, err error) { + return c.backend.ReadAt(b, off) +} + +func (c *Controller) reset() { + c.replicas = []types.Replica{} + c.backend = &replicator{} +} + +func (c *Controller) Close() error { + return c.Shutdown() +} + +func (c *Controller) Shutdown() error { + c.Lock() + defer c.Unlock() + + c.backend.Close() + c.reset() + + if c.frontend != nil { + return c.frontend.Shutdown() + } + + return nil +} + +func (c *Controller) Size() (int64, error) { + return c.size, nil +} diff --git a/controller/multi_writer_at.go b/controller/multi_writer_at.go new file mode 100644 index 00000000..ec0182a7 --- /dev/null +++ b/controller/multi_writer_at.go @@ -0,0 +1,53 @@ +package controller + +import ( + "io" + "sync" +) + +type MultiWriterAt struct { + writers []io.WriterAt +} + +type MultiWriterError struct { + Index int + Writers []io.WriterAt + Errors []error +} + +func (m *MultiWriterError) Error() string { + for _, err := range m.Errors { + if err != nil { + return err.Error() + } + } + return "Unknown" +} + +func (m *MultiWriterAt) WriteAt(p []byte, off int64) (n int, err error) { + errs := make([]error, len(m.writers)) + errored := false + wg := sync.WaitGroup{} + + for i, w := range m.writers { + wg.Add(1) + go func(index int, w io.WriterAt) { + _, err := w.WriteAt(p, off) + if err != nil { + errored = true + errs[index] = err + } + wg.Done() + }(i, w) + } + + wg.Wait() + if errored { + return 0, &MultiWriterError{ + Writers: m.writers, + Errors: errs, + } + } + + return len(p), nil +} diff --git a/controller/replicator.go b/controller/replicator.go new file mode 100644 index 00000000..bc963006 --- /dev/null +++ b/controller/replicator.go @@ -0,0 +1,123 @@ +package controller + +import ( + "io" + "sync" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" +) + +type replicator struct { + io.WriterAt + + backends map[string]backendWrapper + readers []io.ReaderAt + readerLength int +} + +func (r *replicator) AddBackend(address string, backend types.Backend) { + if _, ok := r.backends[address]; ok { + return + } + + logrus.Infof("Adding backend: %s", address) + + if r.backends == nil { + r.backends = map[string]backendWrapper{} + } + + r.backends[address] = backendWrapper{ + backend: backend, + mode: types.WO, + } + + r.buildReadWriters() +} + +func (r *replicator) RemoveBackend(address string) { + backend, ok := r.backends[address] + if !ok { + return + } + + logrus.Infof("Removing backend: %s", address) + + backend.backend.Close() + delete(r.backends, address) + r.buildReadWriters() +} + +func (r *replicator) ReadAt(buf []byte, off int64) (n int, err error) { + // Use a poor random algorithm by always selecting 0 :) + return r.readers[0].ReadAt(buf, off) +} + +func (r *replicator) buildReadWriters() { + readers := []io.ReaderAt{} + writers := make([]io.WriterAt, 0, len(r.backends)) + for _, b := range r.backends { + writers = append(writers, b.backend) + readers = append(readers, b.backend) + } + + r.WriterAt = &MultiWriterAt{ + writers: writers, + } + r.readers = readers + r.readerLength = len(readers) +} + +func (r *replicator) SetMode(address string, mode types.Mode) { + b, ok := r.backends[address] + if !ok { + return + } + b.mode = mode + r.backends[address] = b + r.buildReadWriters() +} + +func (r *replicator) Snapshot() error { + var lastErr error + wg := sync.WaitGroup{} + + for _, backend := range r.backends { + wg.Add(1) + go func(backend types.Backend) { + if err := backend.Snapshot(); err != nil { + lastErr = err + } + wg.Done() + }(backend.backend) + } + + wg.Wait() + return lastErr +} + +func (r *replicator) Close() error { + var lastErr error + for _, backend := range r.backends { + if backend.mode == types.ERR { + continue + } + if err := backend.backend.Close(); err != nil { + lastErr = err + } + } + + r.reset() + + return lastErr +} + +func (r *replicator) reset() { + r.WriterAt = nil + r.backends = nil +} + +type backendWrapper struct { + backend types.Backend + mode types.Mode +} diff --git a/controller/rest/model.go b/controller/rest/model.go new file mode 100644 index 00000000..65d35ab4 --- /dev/null +++ b/controller/rest/model.go @@ -0,0 +1,101 @@ +package rest + +import ( + "encoding/base64" + + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" + "github.com/rancher/longhorn/controller" + "github.com/rancher/longhorn/types" +) + +type Replica struct { + client.Resource + Address string `json:"address"` + Mode string `json:"mode"` +} + +type Volume struct { + client.Resource + Name string `json:"name"` + ReplicaCount int `json:"replicaCount"` +} + +type StartInput struct { + client.Resource + Replicas []string `json:"replicas"` +} + +func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { + v := &Volume{ + Resource: client.Resource{ + Id: EncodeID(name), + Type: "volume", + Actions: map[string]string{}, + }, + Name: name, + ReplicaCount: replicas, + } + + v.Actions["start"] = context.UrlBuilder.ActionLink(v.Resource, "start") + v.Actions["shutdown"] = context.UrlBuilder.ActionLink(v.Resource, "shutdown") + return v +} + +func NewReplica(address string, mode types.Mode) *Replica { + return &Replica{ + Resource: client.Resource{ + Id: EncodeID(address), + Type: "replica", + }, + Address: address, + Mode: string(mode), + } +} + +func DencodeID(id string) (string, error) { + b, err := base64.StdEncoding.DecodeString(id) + if err != nil { + return "", err + } + return string(b), nil +} + +func EncodeID(id string) string { + return base64.StdEncoding.EncodeToString([]byte(id)) +} + +func NewSchema() *client.Schemas { + schemas := &client.Schemas{} + + schemas.AddType("error", client.ServerApiError{}) + schemas.AddType("apiVersion", client.Resource{}) + schemas.AddType("schema", client.Schema{}) + + replica := schemas.AddType("replica", Replica{}) + replica.CollectionMethods = []string{"GET", "POST"} + replica.ResourceMethods = []string{"GET", "PUT"} + + volumes := schemas.AddType("volume", Volume{}) + volumes.ResourceActions = map[string]client.Action{ + "start": client.Action{ + Input: "startInput", + Output: "volume", + }, + "shutdown": client.Action{ + Output: "volume", + }, + } + + return schemas +} + +type Server struct { + c *controller.Controller +} + +func NewServer(c *controller.Controller) *Server { + return &Server{ + c: c, + } +} diff --git a/controller/rest/replica.go b/controller/rest/replica.go new file mode 100644 index 00000000..d9abb6bb --- /dev/null +++ b/controller/rest/replica.go @@ -0,0 +1,89 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" + "github.com/rancher/longhorn/types" +) + +func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + resp := client.GenericCollection{} + for _, r := range s.c.ListReplicas() { + resp.Data = append(resp.Data, NewReplica(r.Address, r.Mode)) + } + + apiContext.Write(&resp) + return nil +} + +func (s *Server) GetReplica(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + vars := mux.Vars(req) + id, err := DencodeID(vars["id"]) + if err != nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + apiContext.Write(s.getReplica(id)) + return nil +} + +func (s *Server) CreateReplica(rw http.ResponseWriter, req *http.Request) error { + var replica Replica + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&replica); err != nil { + return err + } + + if err := s.c.AddReplica(replica.Address); err != nil { + return err + } + + apiContext.Write(s.getReplica(replica.Address)) + return nil +} + +func (s *Server) getReplica(id string) *Replica { + for _, r := range s.c.ListReplicas() { + if r.Address == id { + return NewReplica(r.Address, r.Mode) + } + } + return nil +} + +func (s *Server) DeleteReplica(rw http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + id, err := DencodeID(vars["id"]) + if err != nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + return s.c.RemoveReplica(id) +} + +func (s *Server) UpdateReplica(rw http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + id, err := DencodeID(vars["id"]) + if err != nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var replica Replica + apiContext := api.GetApiContext(req) + apiContext.Read(&replica) + + if err := s.c.SetReplicaMode(id, types.Mode(replica.Mode)); err != nil { + return err + } + + apiContext.Write(s.getReplica(id)) + return nil +} diff --git a/controller/rest/router.go b/controller/rest/router.go new file mode 100644 index 00000000..7519c8d1 --- /dev/null +++ b/controller/rest/router.go @@ -0,0 +1,45 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { + return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if err := t(rw, req); err != nil { + apiContext := api.GetApiContext(req) + apiContext.WriteErr(err) + } + })) +} + +func NewRouter(s *Server) *mux.Router { + schemas := NewSchema() + router := mux.NewRouter().StrictSlash(true) + f := HandleError + + // API framework routes + router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) + router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) + router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) + router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + + // Volumes + router.Methods("GET").Path("/v1/volumes").Handler(f(schemas, s.ListVolumes)) + router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "start").Handler(f(schemas, s.StartVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "shutdown").Handler(f(schemas, s.ShutdownVolume)) + + // Replicas + router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) + router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) + router.Methods("POST").Path("/v1/replicas").Handler(f(schemas, s.CreateReplica)) + router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) + router.Methods("PUT").Path("/v1/replicas/{id}").Handler(f(schemas, s.UpdateReplica)) + + return router +} diff --git a/controller/rest/volume.go b/controller/rest/volume.go new file mode 100644 index 00000000..42c6eb59 --- /dev/null +++ b/controller/rest/volume.go @@ -0,0 +1,87 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func (s *Server) ListVolumes(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + apiContext.Write(&client.GenericCollection{ + Data: []interface{}{ + s.listVolumes(apiContext)[0], + }, + }) + return nil +} + +func (s *Server) GetVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + apiContext.Write(v) + return nil +} + +func (s *Server) ShutdownVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + if err := s.c.Shutdown(); err != nil { + return err + } + + return s.GetVolume(rw, req) +} + +func (s *Server) StartVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var input StartInput + if err := apiContext.Read(&input); err != nil { + return err + } + + if err := s.c.Start(input.Replicas...); err != nil { + return err + } + + return s.GetVolume(rw, req) +} + +func (s *Server) listVolumes(context *api.ApiContext) []*Volume { + return []*Volume{ + NewVolume(context, s.c.Name, len(s.c.ListReplicas())), + } +} + +func (s *Server) getVolume(context *api.ApiContext, id string) *Volume { + for _, v := range s.listVolumes(context) { + if v.Id == id { + return v + } + } + return nil +} diff --git a/integration/core/test_controller.py b/integration/core/test_controller.py new file mode 100644 index 00000000..56c8859a --- /dev/null +++ b/integration/core/test_controller.py @@ -0,0 +1,127 @@ +import time +import random + +import pytest +import cattle + + +@pytest.fixture +def client(request): + url = 'http://localhost:9501/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup(c)) + return cleanup(c) + + +def cleanup(client): + for r in client.list_replica(): + client.delete(r) + return client + + +@pytest.fixture +def random_str(): + return 'random-{0}-{1}'.format(random_num(), int(time.time())) + + +def random_num(): + return random.randint(0, 1000000) + + +def test_replica_list(client): + replicas = client.list_replica() + assert len(replicas) == 0 + + +def test_replica_create(client): + f = 'file://' + random_str() + replica = client.create_replica(address=f) + assert replica.address == f + + client.create_replica(address=f) + client.create_replica(address=f) + + r = client.list_replica() + assert len(r) == 1 + assert r[0].address == f + assert r[0].mode == 'WO' + + f2 = 'file://' + random_str() + replica2 = client.create_replica(address=f2) + assert replica2.address == f2 + + r = client.list_replica() + assert len(r) == 2 + + +def test_replica_delete(client): + f = 'file://' + random_str() + r1 = client.create_replica(address=f+'1') + r2 = client.create_replica(address=f+'2') + r3 = client.create_replica(address=f+'3') + + r = client.list_replica() + assert len(r) == 3 + + client.delete(r1) + r = client.list_replica() + assert len(r) == 2 + + client.delete(r1) + r = client.list_replica() + assert len(r) == 2 + + client.delete(r2) + r = client.list_replica() + assert len(r) == 1 + + client.delete(r3) + r = client.list_replica() + assert len(r) == 0 + + +def test_replica_change(client): + f = 'file://' + random_str() + r1 = client.create_replica(address=f) + assert r1.mode == 'WO' + + r1 = client.update(r1, mode='RW') + assert r1.mode == 'RW' + + r1 = client.reload(r1) + assert r1.mode == 'RW' + + +def test_start(client): + vs = client.list_volume() + assert len(vs) == 1 + + v = vs[0] + assert v.replicaCount == 0 + + addresses = ['file://' + random_str(), 'file://' + random_str()] + v = v.start(replicas=addresses) + + rs = client.list_replica() + assert len(rs) == 2 + assert v.replicaCount == 2 + + found_addresses = [r.address for r in rs] + assert set(found_addresses) == set(addresses) + + +def test_shutdown(client): + vs = client.list_volume() + assert len(vs) == 1 + v = vs[0] + assert v.replicaCount == 0 + + addresses = ['file://' + random_str(), 'file://' + random_str()] + v = v.start(replicas=addresses) + assert v.replicaCount == 2 + + v = v.shutdown() + assert v.replicaCount == 0 + + r = client.list_replica() + assert len(r) == 0 diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py new file mode 100644 index 00000000..a5318406 --- /dev/null +++ b/integration/core/test_replica.py @@ -0,0 +1,204 @@ +import time +import random + +import pytest +import cattle + + +@pytest.fixture +def client(request): + url = 'http://localhost:9502/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup(c)) + return cleanup(c) + + +def cleanup(client): + for r in client.list_replica(): + if 'close' in r: + client.delete(r) + else: + client.delete(r.open(size='4096')) + return client + + +@pytest.fixture +def random_str(): + return 'random-{0}-{1}'.format(random_num(), int(time.time())) + + +def random_num(): + return random.randint(0, 1000000) + + +def test_open(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + assert r.state == 'closed' + assert r.size == '' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + r = r.open(size=str(1024*4096)) + + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + +def test_close(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + assert r.state == 'closed' + assert r.size == '' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + r = r.open(size=str(1024*4096)) + + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + r = r.close() + + assert r.state == 'closed' + assert r.size == '' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + +def test_snapshot(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + assert r.state == 'closed' + assert r.size == '' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + r = r.open(size=str(1024*4096)) + + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + r = r.snapshot() + r = r.snapshot() + + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.head == 'volume-head-002.img' + assert r.parent == 'volume-snap-001.img' + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', + 'volume-snap-000.img'] + + +def test_remove_disk(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + r = r.open(size=str(1024*4096)) + r = r.snapshot() + r = r.snapshot() + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', + 'volume-snap-000.img'] + + r = r.removedisk(name='volume-snap-001.img') + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.head == 'volume-head-002.img' + assert r.parent == 'volume-snap-000.img' + assert r.chain == ['volume-head-002.img', 'volume-snap-000.img'] + + +def test_remove_last_disk(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + r = r.open(size=str(1024*4096)) + r = r.snapshot() + r = r.snapshot() + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', + 'volume-snap-000.img'] + + r = r.removedisk(name='volume-snap-000.img') + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.head == 'volume-head-002.img' + assert r.parent == 'volume-snap-001.img' + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] + + +def test_reload(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + r = r.open(size=str(1024*4096)) + r = r.snapshot() + r = r.snapshot() + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', + 'volume-snap-000.img'] + + r = r.removedisk(name='volume-snap-000.img') + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.head == 'volume-head-002.img' + assert r.parent == 'volume-snap-001.img' + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] + + r = r.reload() + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] + assert r.head == 'volume-head-002.img' + assert r.parent == 'volume-snap-001.img' + + +def test_reload_simple(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + assert r.state == 'closed' + assert r.size == '' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + r = r.open(size=str(1024*4096)) + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + r = r.reload() + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' diff --git a/integration/requirements.txt b/integration/requirements.txt new file mode 100644 index 00000000..afcbb445 --- /dev/null +++ b/integration/requirements.txt @@ -0,0 +1,4 @@ +cattle==0.5.1 + +flake8 +pytest==2.3.5 diff --git a/integration/setup.py b/integration/setup.py new file mode 100644 index 00000000..3eed846a --- /dev/null +++ b/integration/setup.py @@ -0,0 +1,10 @@ +from distutils.core import setup + +setup( + name='Longhorn Integration Tests', + version='0.1', + packages=[ + 'core', + ], + license='ASL 2.0', +) diff --git a/integration/tox.ini b/integration/tox.ini new file mode 100644 index 00000000..93f705f7 --- /dev/null +++ b/integration/tox.ini @@ -0,0 +1,12 @@ +[tox] +envlist=flake8, py27 + +[testenv] +deps=-rrequirements.txt +changedir=core +commands=py.test --durations=20 {posargs} + +[testenv:flake8] +deps=-rrequirements.txt +changedir={toxinidir} +commands=flake8 core diff --git a/main.go b/main.go index cca1dc75..cc3c3f74 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,30 @@ package main import ( - "github.com/Sirupsen/logrus" + "log" + "os" + "runtime/pprof" + + "github.com/codegangsta/cli" + "github.com/rancher/longhorn/app" ) func main() { - logrus.Info("I'm a turkey") + pprofFile := os.Getenv("PPROFILE") + if pprofFile != "" { + f, err := os.Create(pprofFile) + if err != nil { + log.Fatal(err) + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } + + a := cli.NewApp() + a.Commands = []cli.Command{ + app.ControllerCmd(), + app.ReplicaCmd(), + } + + a.Run(os.Args) } diff --git a/package/Dockerfile b/package/Dockerfile index 3922aaab..26bc7203 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,3 +1,3 @@ -FROM ubuntu:15.10 +FROM ubuntu:16.04 COPY longhorn /usr/bin/ CMD ["longhorn"] diff --git a/replica/diff_disk.go b/replica/diff_disk.go new file mode 100644 index 00000000..162923c4 --- /dev/null +++ b/replica/diff_disk.go @@ -0,0 +1,134 @@ +package replica + +import ( + "fmt" + "os" + + "github.com/frostschutz/go-fibmap" +) + +type diffDisk struct { + // mapping of sector to index in the files array. a value of 0 is special meaning + // we don't know the location yet. + location []byte + // list of files in child, parent, grandparent, etc order. + // index 0 is nil and index 1 is the active write layer + files []*os.File + sectorSize int64 +} + +func (d *diffDisk) RemoveIndex(index int) error { + if err := d.files[index].Close(); err != nil { + return err + } + + for i := 0; i < len(d.location); i++ { + if d.location[i] >= byte(index) { + d.location[i] = d.location[i] - 1 + } + } + + d.files = append(d.files[:index], d.files[index+1:]...) + + return nil +} + +func (d *diffDisk) WriteAt(buf []byte, offset int64) (int, error) { + if int64(len(buf))%d.sectorSize != 0 || offset%d.sectorSize != 0 { + return 0, fmt.Errorf("Write not a multiple of %d", d.sectorSize) + } + + target := byte(len(d.files) - 1) + startSector := offset / d.sectorSize + sectors := int64(len(buf)) / d.sectorSize + + c, err := d.files[target].WriteAt(buf, offset) + + // Regardless of err mark bytes as written + for i := int64(0); i < sectors; i++ { + d.location[startSector+i] = target + } + + return c, err +} + +func (d *diffDisk) ReadAt(buf []byte, offset int64) (int, error) { + if int64(len(buf))%d.sectorSize != 0 || offset%d.sectorSize != 0 { + return 0, fmt.Errorf("Read not a multiple of %d", d.sectorSize) + } + + count := 0 + sectors := int64(len(buf)) / d.sectorSize + readSectors := int64(1) + startSector := offset / d.sectorSize + target, err := d.lookup(startSector) + if err != nil { + return count, err + } + + for i := int64(1); i < sectors; i++ { + newTarget, err := d.lookup(startSector + i) + if err != nil { + return count, err + } + + if newTarget == target { + readSectors++ + } else { + c, err := d.read(target, buf, offset, i-readSectors, readSectors) + count += c + if err != nil { + return count, err + } + readSectors = 1 + target = newTarget + } + } + + if readSectors > 0 { + c, err := d.read(target, buf, offset, sectors-readSectors, readSectors) + count += c + if err != nil { + return count, err + } + } + + return count, nil +} + +func (d *diffDisk) read(target byte, buf []byte, offset int64, startSector int64, sectors int64) (int, error) { + bufStart := startSector * d.sectorSize + bufEnd := sectors * d.sectorSize + newBuf := buf[bufStart : bufStart+bufEnd] + return d.files[target].ReadAt(newBuf, offset+bufStart) +} + +func (d *diffDisk) lookup(sector int64) (byte, error) { + dlength := int64(len(d.location)) + if sector >= dlength { + // We know the IO will result in EOF + return byte(len(d.files) - 1), nil + } + + // small optimization + if dlength == 2 { + return 1, nil + } + + target := d.location[sector] + + if target == 0 { + for i := len(d.files) - 1; i > 0; i-- { + e, err := fibmap.Fiemap(d.files[i].Fd(), uint64(sector*d.sectorSize), uint64(d.sectorSize), 1) + if err != 0 { + return byte(0), err + } + if len(e) > 0 { + d.location[sector] = byte(i) + return byte(i), nil + } + } + return byte(len(d.files) - 1), nil + } + return target, nil +} diff --git a/replica/replica.go b/replica/replica.go new file mode 100644 index 00000000..fb772aa9 --- /dev/null +++ b/replica/replica.go @@ -0,0 +1,430 @@ +package replica + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "os" + "path" + "regexp" + "strconv" + "strings" + "sync" + "syscall" + + "github.com/Sirupsen/logrus" +) + +const ( + metadataSuffix = ".meta" + imgSuffix = ".img" + volumeMetaData = "volume.meta" + defaultSectorSize = 4096 + headName = "volume-head-%03d.img" + diskName = "volume-snap-%03d.img" +) + +var ( + diskPattern = regexp.MustCompile(`volume-snap-(\d)+.img`) +) + +type Replica struct { + sync.RWMutex + volume diffDisk + dir string + info Info + diskData map[string]disk + activeDiskData []disk +} + +type Info struct { + Size int64 + Head string + Dirty bool + Parent string + SectorSize int64 +} + +type disk struct { + name string + Parent string +} + +func New(size, sectorSize int64, dir string) (*Replica, error) { + if size%sectorSize != 0 { + return nil, fmt.Errorf("Size %d not a multiple of sector size %d", size, sectorSize) + } + + if err := os.Mkdir(dir, 0700); err != nil && !os.IsExist(err) { + return nil, err + } + + r := &Replica{ + dir: dir, + activeDiskData: make([]disk, 1), + } + r.info.Size = size + r.info.SectorSize = sectorSize + r.volume.sectorSize = sectorSize + r.volume.location = make([]byte, size/sectorSize) + r.volume.files = []*os.File{nil} + + exists, err := r.readMetadata() + if err != nil { + return nil, err + } + + if exists { + if err := r.openFiles(); err != nil { + return nil, err + } + } else { + if err := r.createDisk(); err != nil { + return nil, err + } + } + + r.info.Parent = r.diskData[r.info.Head].Parent + + return r, nil +} + +func (r *Replica) Reload() (*Replica, error) { + return New(r.info.Size, r.volume.sectorSize, r.dir) +} + +func (r *Replica) findDisk(name string) int { + for i, d := range r.activeDiskData { + if d.name == name { + return i + } + } + return 0 +} + +func (r *Replica) relinkChild(index int) error { + childData := &r.activeDiskData[index+1] + if index == 1 { + childData.Parent = "" + } else { + childData.Parent = r.activeDiskData[index-1].name + } + + r.diskData[childData.name] = *childData + return r.encodeToFile(*childData, childData.name+metadataSuffix) +} + +func (r *Replica) RemoveDiffDisk(name string) error { + r.Lock() + defer r.Unlock() + + index := r.findDisk(name) + if index <= 0 { + return nil + } + + if len(r.activeDiskData)-1 == index { + return fmt.Errorf("Can not delete the active differencing disk") + } + + if err := r.relinkChild(index); err != nil { + return err + } + + if err := r.volume.RemoveIndex(index); err != nil { + return err + } + + if len(r.activeDiskData)-2 == index { + r.info.Parent = r.diskData[r.info.Head].Parent + } + + r.activeDiskData = append(r.activeDiskData[:index], r.activeDiskData[index+1:]...) + delete(r.diskData, name) + + if err := r.rmDisk(name); err != nil { + // ignore error deleting files + logrus.Errorf("Failed to delete %s: %v", name, err) + } + + return nil +} + +func (r *Replica) Info() Info { + return r.info +} + +func (r *Replica) Chain() ([]string, error) { + result := make([]string, 0, len(r.activeDiskData)) + + cur := r.info.Head + for cur != "" { + result = append(result, cur) + if _, ok := r.diskData[cur]; !ok { + return nil, fmt.Errorf("Failed to find metadata for %s", cur) + } + cur = r.diskData[cur].Parent + } + + return result, nil +} + +func (r *Replica) close(writeMeta bool) error { + for _, f := range r.volume.files { + f.Close() + } + + if writeMeta { + info := r.info + info.Dirty = false + return r.encodeToFile(&info, volumeMetaData) + } + + return nil +} + +func (r *Replica) encodeToFile(obj interface{}, file string) error { + f, err := os.Create(path.Join(r.dir, file+".tmp")) + if err != nil { + return err + } + defer f.Close() + + if err := json.NewEncoder(f).Encode(&obj); err != nil { + return err + } + + if err := f.Close(); err != nil { + return err + } + + return os.Rename(path.Join(r.dir, file+".tmp"), path.Join(r.dir, file)) +} + +func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) (string, error) { + if parent == "" { + return fmt.Sprintf(pattern, 0), nil + } + + matches := parsePattern.FindStringSubmatch(parent) + if matches == nil { + return "", fmt.Errorf("Invalid name %s does not match pattern: %v", parent, parsePattern) + } + + index, _ := strconv.Atoi(matches[1]) + return fmt.Sprintf(pattern, index+1), nil +} + +func (r *Replica) openFile(name string, flag int) (*os.File, error) { + // TODO: need to turn on O_DIRECT + return os.OpenFile(path.Join(r.dir, name), os.O_RDWR|os.O_CREATE|flag, 0666) +} + +func (r *Replica) createNewHead(parent string) (*os.File, disk, error) { + newHeadName, err := r.nextFile(diskPattern, headName, parent) + if err != nil { + return nil, disk{}, err + } + + f, err := r.openFile(newHeadName, os.O_TRUNC) + if err != nil { + return nil, disk{}, err + } + if err := syscall.Truncate(path.Join(r.dir, newHeadName), r.info.Size); err != nil { + return nil, disk{}, err + } + + newDisk := disk{Parent: parent, name: newHeadName} + err = r.encodeToFile(&newDisk, newHeadName+metadataSuffix) + return f, newDisk, err +} + +func (r *Replica) linkDisk(oldname, newname string) error { + if oldname == "" { + return nil + } + + if err := os.Link(path.Join(r.dir, oldname), path.Join(r.dir, newname)); err != nil { + return err + } + + return os.Link(path.Join(r.dir, oldname+metadataSuffix), path.Join(r.dir, newname+metadataSuffix)) +} + +func (r *Replica) rmDisk(name string) error { + if name == "" { + return nil + } + + lastErr := os.Remove(path.Join(r.dir, name)) + if err := os.Remove(path.Join(r.dir, name+metadataSuffix)); err != nil { + lastErr = err + } + return lastErr +} + +func (r *Replica) createDisk() error { + done := false + oldHead := r.info.Head + newSnapName, err := r.nextFile(diskPattern, diskName, r.diskData[oldHead].Parent) + if err != nil { + return err + } + + if oldHead == "" { + newSnapName = "" + } + + f, newHeadDisk, err := r.createNewHead(newSnapName) + if err != nil { + return err + } + defer func() { + if !done { + r.rmDisk(newHeadDisk.name) + r.rmDisk(newHeadDisk.Parent) + f.Close() + return + } + r.rmDisk(oldHead) + }() + + if err := r.linkDisk(r.info.Head, newHeadDisk.Parent); err != nil { + return err + } + + info := r.info + info.Head = newHeadDisk.name + info.Dirty = false + info.Parent = newHeadDisk.Parent + info.SectorSize = r.volume.sectorSize + + if err := r.encodeToFile(&info, volumeMetaData); err != nil { + return err + } + + done = true + r.diskData[newHeadDisk.name] = newHeadDisk + if newHeadDisk.Parent != "" { + r.diskData[newHeadDisk.Parent] = r.diskData[oldHead] + r.activeDiskData[len(r.activeDiskData)-1].name = newHeadDisk.Parent + } + delete(r.diskData, oldHead) + + r.info = info + r.volume.files = append(r.volume.files, f) + r.activeDiskData = append(r.activeDiskData, newHeadDisk) + + return nil +} + +func (r *Replica) openFiles() error { + chain, err := r.Chain() + if err != nil { + return err + } + + for i := len(chain) - 1; i >= 0; i-- { + parent := chain[i] + f, err := r.openFile(parent, 0) + if err != nil { + return err + } + + r.volume.files = append(r.volume.files, f) + r.activeDiskData = append(r.activeDiskData, r.diskData[parent]) + } + + return nil +} + +func (r *Replica) readMetadata() (bool, error) { + r.diskData = map[string]disk{} + + files, err := ioutil.ReadDir(r.dir) + if os.IsNotExist(err) { + return false, nil + } + if err != nil { + return false, err + } + + for _, file := range files { + if file.Name() == volumeMetaData { + if err := r.unmarshalFile(file.Name(), &r.info); err != nil { + return false, err + } + r.volume.sectorSize = r.info.SectorSize + } else if strings.HasSuffix(file.Name(), metadataSuffix) { + if err := r.readDiskData(file.Name()); err != nil { + return false, err + } + } + } + + return len(r.diskData) > 0, nil +} + +func (r *Replica) readDiskData(file string) error { + var data disk + if err := r.unmarshalFile(file, &data); err != nil { + return err + } + + name := file[:len(file)-len(metadataSuffix)] + data.name = name + r.diskData[name] = data + return nil +} + +func (r *Replica) unmarshalFile(file string, obj interface{}) error { + p := path.Join(r.dir, file) + f, err := os.Open(p) + if err != nil { + return err + } + defer f.Close() + + dec := json.NewDecoder(f) + return dec.Decode(obj) +} + +func (r *Replica) Close() error { + r.Lock() + defer r.Unlock() + + return r.close(true) +} + +func (r *Replica) Delete() error { + r.Lock() + defer r.Unlock() + + for name := range r.diskData { + r.rmDisk(name) + } + + os.Remove(path.Join(r.dir, volumeMetaData)) + return nil +} + +func (r *Replica) Snapshot() error { + r.Lock() + defer r.Unlock() + + return r.createDisk() +} + +func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { + r.RLock() + c, err := r.volume.WriteAt(buf, offset) + r.RUnlock() + return c, err +} + +func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { + r.RLock() + c, err := r.volume.ReadAt(buf, offset) + r.RUnlock() + return c, err +} diff --git a/replica/replica_test.go b/replica/replica_test.go new file mode 100644 index 00000000..0cccce91 --- /dev/null +++ b/replica/replica_test.go @@ -0,0 +1,259 @@ +package replica + +import ( + "fmt" + "io/ioutil" + "os" + "testing" + + . "gopkg.in/check.v1" +) + +const ( + b = 4096 +) + +func Test(t *testing.T) { TestingT(t) } + +type TestSuite struct{} + +var _ = Suite(&TestSuite{}) + +func (s *TestSuite) TestCreate(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir) + c.Assert(err, IsNil) + defer r.Close() +} + +func (s *TestSuite) TestSnapshot(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot() + c.Assert(err, IsNil) + + err = r.Snapshot() + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 4) + c.Assert(len(r.volume.files), Equals, 4) + + c.Assert(r.info.Head, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") +} + +func (s *TestSuite) TestRemoveLast(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot() + c.Assert(err, IsNil) + + err = r.Snapshot() + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 4) + c.Assert(len(r.volume.files), Equals, 4) + + c.Assert(r.info.Head, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + err = r.RemoveDiffDisk("volume-snap-000.img") + c.Assert(err, IsNil) + c.Assert(len(r.activeDiskData), Equals, 3) + c.Assert(len(r.volume.files), Equals, 3) + c.Assert(r.info.Head, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") +} + +func (s *TestSuite) TestRemoveMiddle(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot() + c.Assert(err, IsNil) + + err = r.Snapshot() + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 4) + c.Assert(len(r.volume.files), Equals, 4) + + c.Assert(r.info.Head, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + err = r.RemoveDiffDisk("volume-snap-001.img") + c.Assert(err, IsNil) + c.Assert(len(r.activeDiskData), Equals, 3) + c.Assert(len(r.volume.files), Equals, 3) + c.Assert(r.info.Head, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") +} + +func (s *TestSuite) TestRemoveFirst(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot() + c.Assert(err, IsNil) + + err = r.Snapshot() + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 4) + c.Assert(len(r.volume.files), Equals, 4) + + c.Assert(r.info.Head, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + err = r.RemoveDiffDisk("volume-head-002.img") + c.Assert(err, Not(IsNil)) +} + +func byteEquals(c *C, left, right []byte) { + c.Assert(len(left), Equals, len(right)) + + for i := range left { + l := fmt.Sprintf("%d=%x", i, left[i]) + r := fmt.Sprintf("%d=%x", i, right[i]) + c.Assert(l, Equals, r) + } +} + +func fill(buf []byte, val byte) { + for i := 0; i < len(buf); i++ { + buf[i] = val + } +} + +func (s *TestSuite) TestRead(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9*b, b, dir) + c.Assert(err, IsNil) + defer r.Close() + + buf := make([]byte, 3*b) + _, err = r.ReadAt(buf, 0) + c.Assert(err, IsNil) + byteEquals(c, buf, make([]byte, 3*b)) +} + +func (s *TestSuite) TestWrite(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9*b, b, dir) + c.Assert(err, IsNil) + defer r.Close() + + buf := make([]byte, 9*b) + fill(buf, 1) + _, err = r.WriteAt(buf, 0) + c.Assert(err, IsNil) + + readBuf := make([]byte, 9*b) + _, err = r.ReadAt(readBuf, 0) + c.Assert(err, IsNil) + + byteEquals(c, readBuf, buf) +} + +func (s *TestSuite) TestSnapshotReadWrite(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Logf("Volume: %s", dir) + c.Assert(err, IsNil) + //defer os.RemoveAll(dir) + + r, err := New(3*b, b, dir) + c.Assert(err, IsNil) + defer r.Close() + + buf := make([]byte, 3*b) + fill(buf, 3) + count, err := r.WriteAt(buf, 0) + c.Assert(err, IsNil) + c.Assert(count, Equals, 3*b) + err = r.Snapshot() + c.Assert(err, IsNil) + + fill(buf[b:2*b], 2) + count, err = r.WriteAt(buf[b:2*b], b) + c.Assert(count, Equals, b) + err = r.Snapshot() + c.Assert(err, IsNil) + + fill(buf[:b], 1) + count, err = r.WriteAt(buf[:b], 0) + c.Assert(count, Equals, b) + err = r.Snapshot() + c.Assert(err, IsNil) + + readBuf := make([]byte, 3*b) + _, err = r.ReadAt(readBuf, 0) + c.Logf("%v", r.volume.location) + c.Assert(err, IsNil) + byteEquals(c, readBuf, buf) + byteEquals(c, r.volume.location, []byte{3, 2, 1}) + + r, err = r.Reload() + c.Assert(err, IsNil) + + _, err = r.ReadAt(readBuf, 0) + c.Assert(err, IsNil) + byteEquals(c, readBuf, buf) + byteEquals(c, r.volume.location, []byte{3, 2, 1}) +} diff --git a/replica/rest/model.go b/replica/rest/model.go new file mode 100644 index 00000000..649dd945 --- /dev/null +++ b/replica/rest/model.go @@ -0,0 +1,108 @@ +package rest + +import ( + "strconv" + + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" + "github.com/rancher/longhorn/replica" +) + +const ( + StateOpen = "open" + StateClosed = "closed" +) + +type Replica struct { + client.Resource + Dirty bool `json:"dirtry"` + Head string `json:"head"` + Parent string `json:"parent"` + Size string `json:"size"` + SectorSize int64 `json:"sectorSize"` + State string `json:"state"` + Chain []string `json:"chain"` +} + +type OpenInput struct { + client.Resource + Size string `json:"size"` +} + +type RemoveDiskInput struct { + client.Resource + Name string `json:"name"` +} + +func NewReplica(context *api.ApiContext, rep *replica.Replica) *Replica { + r := &Replica{ + Resource: client.Resource{ + Type: "replica", + Id: "1", + Actions: map[string]string{}, + }, + } + + if rep == nil { + r.State = StateClosed + r.Actions["open"] = context.UrlBuilder.ActionLink(r.Resource, "open") + } else { + r.State = StateOpen + info := rep.Info() + r.Dirty = info.Dirty + r.Head = info.Head + r.Parent = info.Parent + r.SectorSize = info.SectorSize + r.Size = strconv.FormatInt(info.Size, 10) + r.Chain, _ = rep.Chain() + r.Actions["reload"] = context.UrlBuilder.ActionLink(r.Resource, "reload") + r.Actions["snapshot"] = context.UrlBuilder.ActionLink(r.Resource, "snapshot") + r.Actions["close"] = context.UrlBuilder.ActionLink(r.Resource, "close") + r.Actions["removedisk"] = context.UrlBuilder.ActionLink(r.Resource, "removedisk") + } + + return r +} + +func NewSchema() *client.Schemas { + schemas := &client.Schemas{} + + schemas.AddType("error", client.ServerApiError{}) + schemas.AddType("apiVersion", client.Resource{}) + schemas.AddType("schema", client.Schema{}) + schemas.AddType("openInput", OpenInput{}) + schemas.AddType("removediskInput", RemoveDiskInput{}) + replica := schemas.AddType("replica", Replica{}) + + replica.ResourceActions = map[string]client.Action{ + "close": client.Action{ + Output: "replica", + }, + "open": client.Action{ + Input: "openInput", + Output: "replica", + }, + "reload": client.Action{ + Output: "replica", + }, + "snapshot": client.Action{ + Output: "replica", + }, + "removedisk": client.Action{ + Input: "removediskInput", + Output: "replica", + }, + } + + return schemas +} + +type Server struct { + s *replica.Server +} + +func NewServer(s *replica.Server) *Server { + return &Server{ + s: s, + } +} diff --git a/replica/rest/replica.go b/replica/rest/replica.go new file mode 100644 index 00000000..955b8148 --- /dev/null +++ b/replica/rest/replica.go @@ -0,0 +1,85 @@ +package rest + +import ( + "net/http" + "strconv" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + resp := client.GenericCollection{} + resp.Data = append(resp.Data, s.getReplica(apiContext)) + + apiContext.Write(&resp) + return nil +} + +func (s *Server) getReplica(apiContext *api.ApiContext) *Replica { + return NewReplica(apiContext, s.s.Replica()) +} + +func (s *Server) GetReplica(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + r := s.getReplica(apiContext) + if mux.Vars(req)["id"] == r.Id { + apiContext.Write(r) + } else { + rw.WriteHeader(http.StatusNotFound) + } + return nil +} + +func (s *Server) doOp(req *http.Request, err error) error { + if err != nil { + return err + } + + apiContext := api.GetApiContext(req) + apiContext.Write(s.getReplica(apiContext)) + return nil +} + +func (s *Server) OpenReplica(rw http.ResponseWriter, req *http.Request) error { + var input OpenInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil { + return err + } + + size, err := strconv.ParseInt(input.Size, 10, 0) + if err != nil { + return err + } + + return s.doOp(req, s.s.Open(size)) +} + +func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { + var input RemoveDiskInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil { + return err + } + + return s.doOp(req, s.s.RemoveDiffDisk(input.Name)) +} + +func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) error { + return s.doOp(req, s.s.Snapshot()) +} + +func (s *Server) ReloadReplica(rw http.ResponseWriter, req *http.Request) error { + return s.doOp(req, s.s.Reload()) +} + +func (s *Server) CloseReplica(rw http.ResponseWriter, req *http.Request) error { + return s.doOp(req, s.s.Close()) +} + +func (s *Server) DeleteReplica(rw http.ResponseWriter, req *http.Request) error { + return s.doOp(req, s.s.Delete()) +} diff --git a/replica/rest/router.go b/replica/rest/router.go new file mode 100644 index 00000000..cb9bbbe5 --- /dev/null +++ b/replica/rest/router.go @@ -0,0 +1,31 @@ +package rest + +import ( + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/longhorn/controller/rest" +) + +func NewRouter(s *Server) *mux.Router { + schemas := NewSchema() + router := mux.NewRouter().StrictSlash(true) + f := rest.HandleError + + // API framework routes + router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) + router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) + router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) + router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + + // Replicas + router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) + router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "reload").Handler(f(schemas, s.ReloadReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "snapshot").Handler(f(schemas, s.SnapshotReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "open").Handler(f(schemas, s.OpenReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "close").Handler(f(schemas, s.CloseReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "removedisk").Handler(f(schemas, s.RemoveDisk)) + router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) + + return router +} diff --git a/replica/rpc/server.go b/replica/rpc/server.go new file mode 100644 index 00000000..9d60d4e7 --- /dev/null +++ b/replica/rpc/server.go @@ -0,0 +1,48 @@ +package rpc + +import ( + "net" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/replica" + "github.com/rancher/longhorn/rpc" +) + +type Server struct { + address string + s *replica.Server +} + +func New(address string, s *replica.Server) *Server { + return &Server{ + address: address, + s: s, + } +} + +func (s *Server) ListenAndServe() error { + addr, err := net.ResolveTCPAddr("tcp", s.address) + if err != nil { + return err + } + + l, err := net.ListenTCP("tcp", addr) + if err != nil { + return err + } + + for { + conn, err := l.AcceptTCP() + if err != nil { + logrus.Errorf("failed to accept connection %v", err) + continue + } + + logrus.Infof("New connection from: %v", conn.RemoteAddr()) + + go func(conn net.Conn) { + server := rpc.NewServer(conn, s.s) + server.Handle() + }(conn) + } +} diff --git a/replica/server.go b/replica/server.go new file mode 100644 index 00000000..57222b05 --- /dev/null +++ b/replica/server.go @@ -0,0 +1,136 @@ +package replica + +import ( + "fmt" + "sync" + + "github.com/Sirupsen/logrus" +) + +type Server struct { + sync.RWMutex + r *Replica + dir string + sectorSize int64 +} + +func NewServer(dir string, sectorSize int64) *Server { + return &Server{ + dir: dir, + sectorSize: sectorSize, + } +} + +func (s *Server) Open(size int64) error { + s.Lock() + defer s.Unlock() + + if s.r != nil { + return fmt.Errorf("Replica is already open") + } + + logrus.Infof("Opening volume %s, size %d/%d", s.dir, size, s.sectorSize) + r, err := New(size, s.sectorSize, s.dir) + if err != nil { + return err + } + s.r = r + return nil +} + +func (s *Server) Reload() error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Reloading volume") + newReplica, err := s.r.Reload() + if err != nil { + return err + } + + oldReplica := s.r + s.r = newReplica + oldReplica.Close() + return nil +} + +func (s *Server) Replica() *Replica { + return s.r +} + +func (s *Server) Snapshot() error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Snapshotting volume") + return s.r.Snapshot() +} + +func (s *Server) RemoveDiffDisk(name string) error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Removing disk: %s", name) + return s.r.RemoveDiffDisk(name) +} + +func (s *Server) Delete() error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Deleting volume") + if err := s.r.Close(); err != nil { + return err + } + + err := s.r.Delete() + s.r = nil + return err +} + +func (s *Server) Close() error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Closing volume") + if err := s.r.Close(); err != nil { + return err + } + + s.r = nil + return nil +} + +func (s *Server) WriteAt(buf []byte, offset int64) (int, error) { + s.RLock() + i, err := s.r.WriteAt(buf, offset) + s.RUnlock() + return i, err +} + +func (s *Server) ReadAt(buf []byte, offset int64) (int, error) { + s.RLock() + i, err := s.r.ReadAt(buf, offset) + s.RUnlock() + return i, err +} diff --git a/rpc/client.go b/rpc/client.go new file mode 100644 index 00000000..ba845236 --- /dev/null +++ b/rpc/client.go @@ -0,0 +1,125 @@ +package rpc + +import ( + "errors" + "io" + "net" + + "github.com/Sirupsen/logrus" +) + +type Client struct { + end chan struct{} + requests chan *Message + send chan *Message + responses chan *Message + seq uint32 + messages map[uint32]*Message + wire *Wire +} + +func NewClient(conn net.Conn) *Client { + c := &Client{ + wire: NewWire(conn), + end: make(chan struct{}, 1024), + requests: make(chan *Message, 1024), + send: make(chan *Message, 1024), + responses: make(chan *Message, 1024), + messages: map[uint32]*Message{}, + } + go c.loop() + go c.write() + go c.read() + return c +} + +func (c *Client) WriteAt(buf []byte, offset int64) (int, error) { + return c.operation(TypeWrite, buf, offset) +} + +func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { + return c.operation(TypeRead, buf, offset) +} + +func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { + msg := Message{ + Type: op, + Offset: offset, + Data: buf, + } + msg.Add(1) + c.requests <- &msg + msg.Wait() + + if msg.Type == TypeError { + return 0, errors.New(string(msg.Data)) + } + + if msg.Type == TypeEOF { + return len(msg.Data), io.EOF + } + + return len(msg.Data), nil +} + +func (c *Client) Close() { + c.end <- struct{}{} + close(c.send) +} + +func (c *Client) loop() { + for { + select { + case <-c.end: + break + case req := <-c.requests: + c.handleRequest(req) + case resp := <-c.responses: + c.handleResponse(resp) + } + } +} + +func (c *Client) nextSeq() uint32 { + c.seq++ + return c.seq +} + +func (c *Client) handleRequest(req *Message) { + req.Seq = c.nextSeq() + c.messages[req.Seq] = req + c.send <- req +} + +func (c *Client) handleResponse(resp *Message) { + if req, ok := c.messages[resp.Seq]; ok { + // can probably optimize away this copy + if len(resp.Data) > 0 { + copy(req.Data, resp.Data) + } + req.Type = resp.Type + req.Done() + } +} + +func (c *Client) write() { + for msg := range c.send { + if err := c.wire.Write(msg); err != nil { + c.responses <- &Message{ + Seq: msg.Seq, + Type: TypeError, + Data: []byte(err.Error()), + } + } + } +} + +func (c *Client) read() { + for { + msg, err := c.wire.Read() + if err != nil { + logrus.Errorf("Error reading from wire: %v", err) + } + c.responses <- msg + } +} diff --git a/rpc/server.go b/rpc/server.go new file mode 100644 index 00000000..97a9d5fa --- /dev/null +++ b/rpc/server.go @@ -0,0 +1,84 @@ +package rpc + +import ( + "io" + "net" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" +) + +type Server struct { + wire *Wire + responses chan *Message + done chan struct{} + data types.ReaderWriterAt +} + +func NewServer(conn net.Conn, data types.ReaderWriterAt) *Server { + return &Server{ + wire: NewWire(conn), + responses: make(chan *Message, 1024), + done: make(chan struct{}), + data: data, + } +} + +func (s *Server) Handle() error { + go s.write() + defer func() { + s.done <- struct{}{} + }() + return s.read() +} + +func (s *Server) read() error { + for { + msg, err := s.wire.Read() + if err != nil { + logrus.Errorf("Failed to read: %v", err) + return err + } + switch msg.Type { + case TypeRead: + go s.handleRead(msg) + case TypeWrite: + go s.handleWrite(msg) + } + } +} + +func (s *Server) handleRead(msg *Message) { + c, err := s.data.ReadAt(msg.Data, msg.Offset) + s.pushResponse(c, msg, err) +} + +func (s *Server) handleWrite(msg *Message) { + c, err := s.data.WriteAt(msg.Data, msg.Offset) + s.pushResponse(c, msg, err) +} + +func (s *Server) pushResponse(count int, msg *Message, err error) { + msg.Type = TypeResponse + if err == io.EOF { + msg.Data = msg.Data[:count] + msg.Type = TypeEOF + } else if err != nil { + msg.Type = TypeError + msg.Data = []byte(err.Error()) + } + s.responses <- msg +} + +func (s *Server) write() { + for { + select { + case msg := <-s.responses: + if err := s.wire.Write(msg); err != nil { + logrus.Errorf("Failed to write: %v", err) + } + case <-s.done: + break + } + } +} diff --git a/rpc/types.go b/rpc/types.go new file mode 100644 index 00000000..056bd0a8 --- /dev/null +++ b/rpc/types.go @@ -0,0 +1,24 @@ +package rpc + +import "sync" + +const ( + TypeRead = iota + TypeWrite + TypeResponse + TypeError + TypeEOF + + messageSize = (32 + 32 + 32 + 64) / 8 + readBufferSize = 8096 + writeBufferSize = 8096 +) + +type Message struct { + sync.WaitGroup + + Seq uint32 + Type uint32 + Offset int64 + Data []byte +} diff --git a/rpc/wire.go b/rpc/wire.go new file mode 100644 index 00000000..ee738c3e --- /dev/null +++ b/rpc/wire.go @@ -0,0 +1,73 @@ +package rpc + +import ( + "bufio" + "encoding/binary" + "io" + "net" +) + +type Wire struct { + writer *bufio.Writer + reader io.Reader +} + +func NewWire(conn net.Conn) *Wire { + return &Wire{ + writer: bufio.NewWriterSize(conn, writeBufferSize), + reader: bufio.NewReaderSize(conn, readBufferSize), + } +} + +func (w *Wire) Write(msg *Message) error { + if err := binary.Write(w.writer, binary.LittleEndian, msg.Seq); err != nil { + return err + } + if err := binary.Write(w.writer, binary.LittleEndian, msg.Type); err != nil { + return err + } + if err := binary.Write(w.writer, binary.LittleEndian, msg.Offset); err != nil { + return err + } + if err := binary.Write(w.writer, binary.LittleEndian, uint32(len(msg.Data))); err != nil { + return err + } + if len(msg.Data) > 0 { + if _, err := w.writer.Write(msg.Data); err != nil { + return err + } + } + return w.writer.Flush() +} + +func (w *Wire) Read() (*Message, error) { + var ( + msg Message + length uint32 + ) + + if err := binary.Read(w.reader, binary.LittleEndian, &msg.Seq); err != nil { + return nil, err + } + + if err := binary.Read(w.reader, binary.LittleEndian, &msg.Type); err != nil { + return nil, err + } + + if err := binary.Read(w.reader, binary.LittleEndian, &msg.Offset); err != nil { + return nil, err + } + + if err := binary.Read(w.reader, binary.LittleEndian, &length); err != nil { + return nil, err + } + + if length > 0 { + msg.Data = make([]byte, length) + if _, err := io.ReadFull(w.reader, msg.Data); err != nil { + return nil, err + } + } + + return &msg, nil +} diff --git a/scripts/build b/scripts/build index e6c78f0d..7f20e771 100755 --- a/scripts/build +++ b/scripts/build @@ -6,4 +6,4 @@ source $(dirname $0)/version cd $(dirname $0)/.. mkdir -p bin -go build -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn +go build -tags tcmu -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn diff --git a/scripts/ci b/scripts/ci index e6fae796..502224c5 100755 --- a/scripts/ci +++ b/scripts/ci @@ -6,4 +6,5 @@ cd $(dirname $0) ./build ./test ./validate +./integration-test ./package diff --git a/scripts/integration-test b/scripts/integration-test new file mode 100755 index 00000000..9465d054 --- /dev/null +++ b/scripts/integration-test @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +temp=$(mktemp -d) +trap "rm -rf $temp" EXIT + +cd $(dirname $0)/.. +./bin/longhorn controller --enable-backend file test-volume & +./bin/longhorn replica $temp & +cd integration +find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; +tox diff --git a/scripts/package b/scripts/package index b08d16d4..37b91174 100755 --- a/scripts/package +++ b/scripts/package @@ -8,6 +8,10 @@ cd $(dirname $0)/../package TAG=${TAG:-${VERSION}} REPO=${REPO:-rancher} +if [ ! -x ../bin/longhorn ]; then + ../scripts/build +fi + cp ../bin/longhorn . docker build -t ${REPO}/longhorn:${TAG} . diff --git a/scripts/validate b/scripts/validate index 888c4554..17f8372e 100755 --- a/scripts/validate +++ b/scripts/validate @@ -11,10 +11,10 @@ echo Running: go vet go vet ${PACKAGES} echo Running: golint for i in ${PACKAGES}; do - if [ -z "$(golint $i | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then + if [ -n "$(golint $i | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then failed=true fi done -test -n "$failed" +test -z "$failed" echo Running: go fmt test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)" diff --git a/trash.yml b/trash.yml index 04e6e49b..70fd3abd 100644 --- a/trash.yml +++ b/trash.yml @@ -1,3 +1,22 @@ import: +- package: gopkg.in/check.v1 + version: 4f90aeace3a26ad7021961c297b22c42160c7b25 +- package: github.com/gorilla/mux + version: 0eeaf8392f5b04950925b8a69fe70f110fa7cbfc +- package: github.com/gorilla/handlers + version: d0f261246491e3a8613039e90764460448dc05f5 +- package: github.com/gorilla/websocket + version: e2e3d8414d0fbae04004f151979f4e27c6747fe7 +- package: github.com/gorilla/context + version: 1ea25387ff6f684839d82767c1733ff4d4d15d0a +- package: github.com/frostschutz/go-fibmap + version: 5fc9f8c1ed479f20414771a17b9686ee77029676 + repo: https://github.com/rancher/go-fibmap.git - package: github.com/Sirupsen/logrus version: 446d1c146faa8ed3f4218f056fcd165f6bcfda81 +- package: github.com/rancher/go-rancher + version: 5ed452cd07a408bc6c96d10766a963c0d7585518 +- package: github.com/docker/go-units + version: 5d2041e26a699eaca682e2ea41c8f891e1060444 +- package: github.com/codegangsta/cli + version: 71f57d300dd6a780ac1856c005c4b518cfd498ec diff --git a/types/types.go b/types/types.go new file mode 100644 index 00000000..b9f2efc1 --- /dev/null +++ b/types/types.go @@ -0,0 +1,51 @@ +package types + +import "io" + +const ( + WO = Mode("WO") + RW = Mode("RW") + ERR = Mode("ERR") +) + +type ReaderWriterAt interface { + io.ReaderAt + io.WriterAt +} + +type Backend interface { + ReaderWriterAt + io.Closer + Snapshot() error + Size() (int64, error) +} + +type BackendFactory interface { + Create(address string) (Backend, error) +} + +type Controller interface { + AddReplica(address string) error + RemoveReplica(address string) error + SetReplicaMode(address string, mode Mode) error + ListReplicas() []Replica + Start(address ...string) error + Shutdown() error +} + +type Server interface { + ReaderWriterAt + Controller +} + +type Mode string + +type Replica struct { + Address string + Mode Mode +} + +type Frontend interface { + Activate(name string, size int64, rw ReaderWriterAt) error + Shutdown() error +} diff --git a/util/util.go b/util/util.go new file mode 100644 index 00000000..caefa318 --- /dev/null +++ b/util/util.go @@ -0,0 +1,23 @@ +package util + +import ( + "fmt" + "regexp" + "strconv" +) + +var ( + parsePattern = regexp.MustCompile(`(.*):(\d+)`) +) + +func ParseAddresses(name string) (string, string, error) { + matches := parsePattern.FindStringSubmatch(name) + if matches == nil { + return "", "", fmt.Errorf("Invalid address %s does not match pattern: %v", name, parsePattern) + } + + host := matches[1] + port, _ := strconv.Atoi(matches[2]) + + return fmt.Sprintf("%s:%d", host, port), fmt.Sprintf("%s:%d", host, port+1), nil +} diff --git a/vendor/github.com/codegangsta/cli/.travis.yml b/vendor/github.com/codegangsta/cli/.travis.yml new file mode 100644 index 00000000..c2b5c8de --- /dev/null +++ b/vendor/github.com/codegangsta/cli/.travis.yml @@ -0,0 +1,18 @@ +language: go +sudo: false + +go: +- 1.1.2 +- 1.2.2 +- 1.3.3 +- 1.4.2 +- 1.5.1 +- tip + +matrix: + allow_failures: + - go: tip + +script: +- go vet ./... +- go test -v ./... diff --git a/vendor/github.com/codegangsta/cli/LICENSE b/vendor/github.com/codegangsta/cli/LICENSE new file mode 100644 index 00000000..5515ccfb --- /dev/null +++ b/vendor/github.com/codegangsta/cli/LICENSE @@ -0,0 +1,21 @@ +Copyright (C) 2013 Jeremy Saenz +All Rights Reserved. + +MIT LICENSE + +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/codegangsta/cli/README.md b/vendor/github.com/codegangsta/cli/README.md new file mode 100644 index 00000000..d9371cfe --- /dev/null +++ b/vendor/github.com/codegangsta/cli/README.md @@ -0,0 +1,434 @@ +[![Coverage](http://gocover.io/_badge/github.com/codegangsta/cli?0)](http://gocover.io/github.com/codegangsta/cli) +[![Build Status](https://travis-ci.org/codegangsta/cli.svg?branch=master)](https://travis-ci.org/codegangsta/cli) +[![GoDoc](https://godoc.org/github.com/codegangsta/cli?status.svg)](https://godoc.org/github.com/codegangsta/cli) +[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-codegangsta-cli) + +# cli.go + +`cli.go` is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way. + +## Overview + +Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app. + +**This is where `cli.go` comes into play.** `cli.go` makes command line programming fun, organized, and expressive! + +## Installation + +Make sure you have a working Go environment (go 1.1+ is *required*). [See the install instructions](http://golang.org/doc/install.html). + +To install `cli.go`, simply run: +``` +$ go get github.com/codegangsta/cli +``` + +Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used: +``` +export PATH=$PATH:$GOPATH/bin +``` + +## Getting Started + +One of the philosophies behind `cli.go` is that an API should be playful and full of discovery. So a `cli.go` app can be as little as one line of code in `main()`. + +``` go +package main + +import ( + "os" + "github.com/codegangsta/cli" +) + +func main() { + cli.NewApp().Run(os.Args) +} +``` + +This app will run and show help text, but is not very useful. Let's give an action to execute and some help documentation: + +``` go +package main + +import ( + "os" + "github.com/codegangsta/cli" +) + +func main() { + app := cli.NewApp() + app.Name = "boom" + app.Usage = "make an explosive entrance" + app.Action = func(c *cli.Context) { + println("boom! I say!") + } + + app.Run(os.Args) +} +``` + +Running this already gives you a ton of functionality, plus support for things like subcommands and flags, which are covered below. + +## Example + +Being a programmer can be a lonely job. Thankfully by the power of automation that is not the case! Let's create a greeter app to fend off our demons of loneliness! + +Start by creating a directory named `greet`, and within it, add a file, `greet.go` with the following code in it: + +``` go +package main + +import ( + "os" + "github.com/codegangsta/cli" +) + +func main() { + app := cli.NewApp() + app.Name = "greet" + app.Usage = "fight the loneliness!" + app.Action = func(c *cli.Context) { + println("Hello friend!") + } + + app.Run(os.Args) +} +``` + +Install our command to the `$GOPATH/bin` directory: + +``` +$ go install +``` + +Finally run our new command: + +``` +$ greet +Hello friend! +``` + +`cli.go` also generates neat help text: + +``` +$ greet help +NAME: + greet - fight the loneliness! + +USAGE: + greet [global options] command [command options] [arguments...] + +VERSION: + 0.0.0 + +COMMANDS: + help, h Shows a list of commands or help for one command + +GLOBAL OPTIONS + --version Shows version information +``` + +### Arguments + +You can lookup arguments by calling the `Args` function on `cli.Context`. + +``` go +... +app.Action = func(c *cli.Context) { + println("Hello", c.Args()[0]) +} +... +``` + +### Flags + +Setting and querying flags is simple. + +``` go +... +app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "lang", + Value: "english", + Usage: "language for the greeting", + }, +} +app.Action = func(c *cli.Context) { + name := "someone" + if c.NArg() > 0 { + name = c.Args()[0] + } + if c.String("lang") == "spanish" { + println("Hola", name) + } else { + println("Hello", name) + } +} +... +``` + +You can also set a destination variable for a flag, to which the content will be scanned. + +``` go +... +var language string +app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "lang", + Value: "english", + Usage: "language for the greeting", + Destination: &language, + }, +} +app.Action = func(c *cli.Context) { + name := "someone" + if c.NArg() > 0 { + name = c.Args()[0] + } + if language == "spanish" { + println("Hola", name) + } else { + println("Hello", name) + } +} +... +``` + +See full list of flags at http://godoc.org/github.com/codegangsta/cli + +#### Alternate Names + +You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g. + +``` go +app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "lang, l", + Value: "english", + Usage: "language for the greeting", + }, +} +``` + +That flag can then be set with `--lang spanish` or `-l spanish`. Note that giving two different forms of the same flag in the same command invocation is an error. + +#### Values from the Environment + +You can also have the default value set from the environment via `EnvVar`. e.g. + +``` go +app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "lang, l", + Value: "english", + Usage: "language for the greeting", + EnvVar: "APP_LANG", + }, +} +``` + +The `EnvVar` may also be given as a comma-delimited "cascade", where the first environment variable that resolves is used as the default. + +``` go +app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "lang, l", + Value: "english", + Usage: "language for the greeting", + EnvVar: "LEGACY_COMPAT_LANG,APP_LANG,LANG", + }, +} +``` + +#### Values from alternate input sources (YAML and others) + +There is a separate package altsrc that adds support for getting flag values from other input sources like YAML. + +In order to get values for a flag from an alternate input source the following code would be added to wrap an existing cli.Flag like below: + +``` go + altsrc.NewIntFlag(cli.IntFlag{Name: "test"}) +``` + +Initialization must also occur for these flags. Below is an example initializing getting data from a yaml file below. + +``` go + command.Before = altsrc.InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) +``` + +The code above will use the "load" string as a flag name to get the file name of a yaml file from the cli.Context. +It will then use that file name to initialize the yaml input source for any flags that are defined on that command. +As a note the "load" flag used would also have to be defined on the command flags in order for this code snipped to work. + +Currently only YAML files are supported but developers can add support for other input sources by implementing the +altsrc.InputSourceContext for their given sources. + +Here is a more complete sample of a command using YAML support: + +``` go + command := &cli.Command{ + Name: "test-cmd", + Aliases: []string{"tc"}, + Usage: "this is for testing", + Description: "testing", + Action: func(c *cli.Context) { + // Action to run + }, + Flags: []cli.Flag{ + NewIntFlag(cli.IntFlag{Name: "test"}), + cli.StringFlag{Name: "load"}}, + } + command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load")) + err := command.Run(c) +``` + +### Subcommands + +Subcommands can be defined for a more git-like command line app. + +```go +... +app.Commands = []cli.Command{ + { + Name: "add", + Aliases: []string{"a"}, + Usage: "add a task to the list", + Action: func(c *cli.Context) { + println("added task: ", c.Args().First()) + }, + }, + { + Name: "complete", + Aliases: []string{"c"}, + Usage: "complete a task on the list", + Action: func(c *cli.Context) { + println("completed task: ", c.Args().First()) + }, + }, + { + Name: "template", + Aliases: []string{"r"}, + Usage: "options for task templates", + Subcommands: []cli.Command{ + { + Name: "add", + Usage: "add a new template", + Action: func(c *cli.Context) { + println("new task template: ", c.Args().First()) + }, + }, + { + Name: "remove", + Usage: "remove an existing template", + Action: func(c *cli.Context) { + println("removed task template: ", c.Args().First()) + }, + }, + }, + }, +} +... +``` + +### Subcommands categories + +For additional organization in apps that have many subcommands, you can +associate a category for each command to group them together in the help +output. + +E.g. + +```go +... + app.Commands = []cli.Command{ + { + Name: "noop", + }, + { + Name: "add", + Category: "template", + }, + { + Name: "remove", + Category: "template", + }, + } +... +``` + +Will include: + +``` +... +COMMANDS: + noop + + Template actions: + add + remove +... +``` + +### Bash Completion + +You can enable completion commands by setting the `EnableBashCompletion` +flag on the `App` object. By default, this setting will only auto-complete to +show an app's subcommands, but you can write your own completion methods for +the App or its subcommands. + +```go +... +var tasks = []string{"cook", "clean", "laundry", "eat", "sleep", "code"} +app := cli.NewApp() +app.EnableBashCompletion = true +app.Commands = []cli.Command{ + { + Name: "complete", + Aliases: []string{"c"}, + Usage: "complete a task on the list", + Action: func(c *cli.Context) { + println("completed task: ", c.Args().First()) + }, + BashComplete: func(c *cli.Context) { + // This will complete if no args are passed + if c.NArg() > 0 { + return + } + for _, t := range tasks { + fmt.Println(t) + } + }, + } +} +... +``` + +#### To Enable + +Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while +setting the `PROG` variable to the name of your program: + +`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete` + +#### To Distribute + +Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename +it to the name of the program you wish to add autocomplete support for (or +automatically install it there if you are distributing a package). Don't forget +to source the file to make it active in the current shell. + +``` +sudo cp src/bash_autocomplete /etc/bash_completion.d/ +source /etc/bash_completion.d/ +``` + +Alternatively, you can just document that users should source the generic +`autocomplete/bash_autocomplete` in their bash configuration with `$PROG` set +to the name of their program (as above). + +## Contribution Guidelines + +Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch. + +If you have contributed something significant to the project, I will most likely add you as a collaborator. As a collaborator you are given the ability to merge others pull requests. It is very important that new code does not break existing code, so be careful about what code you do choose to merge. If you have any questions feel free to link @codegangsta to the issue in question and we can review it together. + +If you feel like you have contributed to the project but have not yet been added as a collaborator, I probably forgot to add you. Hit @codegangsta up over email and we will get it figured out. diff --git a/vendor/github.com/codegangsta/cli/app.go b/vendor/github.com/codegangsta/cli/app.go new file mode 100644 index 00000000..bd20a2d3 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/app.go @@ -0,0 +1,363 @@ +package cli + +import ( + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "sort" + "time" +) + +// App is the main structure of a cli application. It is recommended that +// an app be created with the cli.NewApp() function +type App struct { + // The name of the program. Defaults to path.Base(os.Args[0]) + Name string + // Full name of command for help, defaults to Name + HelpName string + // Description of the program. + Usage string + // Text to override the USAGE section of help + UsageText string + // Description of the program argument format. + ArgsUsage string + // Version of the program + Version string + // List of commands to execute + Commands []Command + // List of flags to parse + Flags []Flag + // Boolean to enable bash completion commands + EnableBashCompletion bool + // Boolean to hide built-in help command + HideHelp bool + // Boolean to hide built-in version flag and the VERSION section of help + HideVersion bool + // Populate on app startup, only gettable throught method Categories() + categories CommandCategories + // An action to execute when the bash-completion flag is set + BashComplete func(context *Context) + // An action to execute before any subcommands are run, but after the context is ready + // If a non-nil error is returned, no subcommands are run + Before func(context *Context) error + // An action to execute after any subcommands are run, but after the subcommand has finished + // It is run even if Action() panics + After func(context *Context) error + // The action to execute when no subcommands are specified + Action func(context *Context) + // Execute this function if the proper command cannot be found + CommandNotFound func(context *Context, command string) + // Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages. + // This function is able to replace the original error messages. + // If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted. + OnUsageError func(context *Context, err error, isSubcommand bool) error + // Compilation date + Compiled time.Time + // List of all authors who contributed + Authors []Author + // Copyright of the binary if any + Copyright string + // Name of Author (Note: Use App.Authors, this is deprecated) + Author string + // Email of Author (Note: Use App.Authors, this is deprecated) + Email string + // Writer writer to write output to + Writer io.Writer +} + +// Tries to find out when this binary was compiled. +// Returns the current time if it fails to find it. +func compileTime() time.Time { + info, err := os.Stat(os.Args[0]) + if err != nil { + return time.Now() + } + return info.ModTime() +} + +// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action. +func NewApp() *App { + return &App{ + Name: filepath.Base(os.Args[0]), + HelpName: filepath.Base(os.Args[0]), + Usage: "A new cli application", + UsageText: "", + Version: "0.0.0", + BashComplete: DefaultAppComplete, + Action: helpCommand.Action, + Compiled: compileTime(), + Writer: os.Stdout, + } +} + +// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination +func (a *App) Run(arguments []string) (err error) { + if a.Author != "" || a.Email != "" { + a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email}) + } + + newCmds := []Command{} + for _, c := range a.Commands { + if c.HelpName == "" { + c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name) + } + newCmds = append(newCmds, c) + } + a.Commands = newCmds + + a.categories = CommandCategories{} + for _, command := range a.Commands { + a.categories = a.categories.AddCommand(command.Category, command) + } + sort.Sort(a.categories) + + // append help to commands + if a.Command(helpCommand.Name) == nil && !a.HideHelp { + a.Commands = append(a.Commands, helpCommand) + if (HelpFlag != BoolFlag{}) { + a.appendFlag(HelpFlag) + } + } + + //append version/help flags + if a.EnableBashCompletion { + a.appendFlag(BashCompletionFlag) + } + + if !a.HideVersion { + a.appendFlag(VersionFlag) + } + + // parse flags + set := flagSet(a.Name, a.Flags) + set.SetOutput(ioutil.Discard) + err = set.Parse(arguments[1:]) + nerr := normalizeFlags(a.Flags, set) + context := NewContext(a, set, nil) + if nerr != nil { + fmt.Fprintln(a.Writer, nerr) + ShowAppHelp(context) + return nerr + } + + if checkCompletions(context) { + return nil + } + + if err != nil { + if a.OnUsageError != nil { + err := a.OnUsageError(context, err, false) + return err + } else { + fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.") + ShowAppHelp(context) + return err + } + } + + if !a.HideHelp && checkHelp(context) { + ShowAppHelp(context) + return nil + } + + if !a.HideVersion && checkVersion(context) { + ShowVersion(context) + return nil + } + + if a.After != nil { + defer func() { + if afterErr := a.After(context); afterErr != nil { + if err != nil { + err = NewMultiError(err, afterErr) + } else { + err = afterErr + } + } + }() + } + + if a.Before != nil { + err = a.Before(context) + if err != nil { + fmt.Fprintf(a.Writer, "%v\n\n", err) + ShowAppHelp(context) + return err + } + } + + args := context.Args() + if args.Present() { + name := args.First() + c := a.Command(name) + if c != nil { + return c.Run(context) + } + } + + // Run default Action + a.Action(context) + return nil +} + +// Another entry point to the cli app, takes care of passing arguments and error handling +func (a *App) RunAndExitOnError() { + if err := a.Run(os.Args); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags +func (a *App) RunAsSubcommand(ctx *Context) (err error) { + // append help to commands + if len(a.Commands) > 0 { + if a.Command(helpCommand.Name) == nil && !a.HideHelp { + a.Commands = append(a.Commands, helpCommand) + if (HelpFlag != BoolFlag{}) { + a.appendFlag(HelpFlag) + } + } + } + + newCmds := []Command{} + for _, c := range a.Commands { + if c.HelpName == "" { + c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name) + } + newCmds = append(newCmds, c) + } + a.Commands = newCmds + + // append flags + if a.EnableBashCompletion { + a.appendFlag(BashCompletionFlag) + } + + // parse flags + set := flagSet(a.Name, a.Flags) + set.SetOutput(ioutil.Discard) + err = set.Parse(ctx.Args().Tail()) + nerr := normalizeFlags(a.Flags, set) + context := NewContext(a, set, ctx) + + if nerr != nil { + fmt.Fprintln(a.Writer, nerr) + fmt.Fprintln(a.Writer) + if len(a.Commands) > 0 { + ShowSubcommandHelp(context) + } else { + ShowCommandHelp(ctx, context.Args().First()) + } + return nerr + } + + if checkCompletions(context) { + return nil + } + + if err != nil { + if a.OnUsageError != nil { + err = a.OnUsageError(context, err, true) + return err + } else { + fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.") + ShowSubcommandHelp(context) + return err + } + } + + if len(a.Commands) > 0 { + if checkSubcommandHelp(context) { + return nil + } + } else { + if checkCommandHelp(ctx, context.Args().First()) { + return nil + } + } + + if a.After != nil { + defer func() { + afterErr := a.After(context) + if afterErr != nil { + if err != nil { + err = NewMultiError(err, afterErr) + } else { + err = afterErr + } + } + }() + } + + if a.Before != nil { + err := a.Before(context) + if err != nil { + return err + } + } + + args := context.Args() + if args.Present() { + name := args.First() + c := a.Command(name) + if c != nil { + return c.Run(context) + } + } + + // Run default Action + a.Action(context) + + return nil +} + +// Returns the named command on App. Returns nil if the command does not exist +func (a *App) Command(name string) *Command { + for _, c := range a.Commands { + if c.HasName(name) { + return &c + } + } + + return nil +} + +// Returnes the array containing all the categories with the commands they contain +func (a *App) Categories() CommandCategories { + return a.categories +} + +func (a *App) hasFlag(flag Flag) bool { + for _, f := range a.Flags { + if flag == f { + return true + } + } + + return false +} + +func (a *App) appendFlag(flag Flag) { + if !a.hasFlag(flag) { + a.Flags = append(a.Flags, flag) + } +} + +// Author represents someone who has contributed to a cli project. +type Author struct { + Name string // The Authors name + Email string // The Authors email +} + +// String makes Author comply to the Stringer interface, to allow an easy print in the templating process +func (a Author) String() string { + e := "" + if a.Email != "" { + e = "<" + a.Email + "> " + } + + return fmt.Sprintf("%v %v", a.Name, e) +} diff --git a/vendor/github.com/codegangsta/cli/app_test.go b/vendor/github.com/codegangsta/cli/app_test.go new file mode 100644 index 00000000..ebf26c70 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/app_test.go @@ -0,0 +1,1097 @@ +package cli + +import ( + "bytes" + "errors" + "flag" + "fmt" + "io" + "io/ioutil" + "os" + "reflect" + "strings" + "testing" +) + +func ExampleApp_Run() { + // set args for examples sake + os.Args = []string{"greet", "--name", "Jeremy"} + + app := NewApp() + app.Name = "greet" + app.Flags = []Flag{ + StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, + } + app.Action = func(c *Context) { + fmt.Printf("Hello %v\n", c.String("name")) + } + app.UsageText = "app [first_arg] [second_arg]" + app.Author = "Harrison" + app.Email = "harrison@lolwut.com" + app.Authors = []Author{Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}} + app.Run(os.Args) + // Output: + // Hello Jeremy +} + +func ExampleApp_Run_subcommand() { + // set args for examples sake + os.Args = []string{"say", "hi", "english", "--name", "Jeremy"} + app := NewApp() + app.Name = "say" + app.Commands = []Command{ + { + Name: "hello", + Aliases: []string{"hi"}, + Usage: "use it to see a description", + Description: "This is how we describe hello the function", + Subcommands: []Command{ + { + Name: "english", + Aliases: []string{"en"}, + Usage: "sends a greeting in english", + Description: "greets someone in english", + Flags: []Flag{ + StringFlag{ + Name: "name", + Value: "Bob", + Usage: "Name of the person to greet", + }, + }, + Action: func(c *Context) { + fmt.Println("Hello,", c.String("name")) + }, + }, + }, + }, + } + + app.Run(os.Args) + // Output: + // Hello, Jeremy +} + +func ExampleApp_Run_help() { + // set args for examples sake + os.Args = []string{"greet", "h", "describeit"} + + app := NewApp() + app.Name = "greet" + app.Flags = []Flag{ + StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, + } + app.Commands = []Command{ + { + Name: "describeit", + Aliases: []string{"d"}, + Usage: "use it to see a description", + Description: "This is how we describe describeit the function", + Action: func(c *Context) { + fmt.Printf("i like to describe things") + }, + }, + } + app.Run(os.Args) + // Output: + // NAME: + // greet describeit - use it to see a description + // + // USAGE: + // greet describeit [arguments...] + // + // DESCRIPTION: + // This is how we describe describeit the function +} + +func ExampleApp_Run_bashComplete() { + // set args for examples sake + os.Args = []string{"greet", "--generate-bash-completion"} + + app := NewApp() + app.Name = "greet" + app.EnableBashCompletion = true + app.Commands = []Command{ + { + Name: "describeit", + Aliases: []string{"d"}, + Usage: "use it to see a description", + Description: "This is how we describe describeit the function", + Action: func(c *Context) { + fmt.Printf("i like to describe things") + }, + }, { + Name: "next", + Usage: "next example", + Description: "more stuff to see when generating bash completion", + Action: func(c *Context) { + fmt.Printf("the next example") + }, + }, + } + + app.Run(os.Args) + // Output: + // describeit + // d + // next + // help + // h +} + +func TestApp_Run(t *testing.T) { + s := "" + + app := NewApp() + app.Action = func(c *Context) { + s = s + c.Args().First() + } + + err := app.Run([]string{"command", "foo"}) + expect(t, err, nil) + err = app.Run([]string{"command", "bar"}) + expect(t, err, nil) + expect(t, s, "foobar") +} + +var commandAppTests = []struct { + name string + expected bool +}{ + {"foobar", true}, + {"batbaz", true}, + {"b", true}, + {"f", true}, + {"bat", false}, + {"nothing", false}, +} + +func TestApp_Command(t *testing.T) { + app := NewApp() + fooCommand := Command{Name: "foobar", Aliases: []string{"f"}} + batCommand := Command{Name: "batbaz", Aliases: []string{"b"}} + app.Commands = []Command{ + fooCommand, + batCommand, + } + + for _, test := range commandAppTests { + expect(t, app.Command(test.name) != nil, test.expected) + } +} + +func TestApp_CommandWithArgBeforeFlags(t *testing.T) { + var parsedOption, firstArg string + + app := NewApp() + command := Command{ + Name: "cmd", + Flags: []Flag{ + StringFlag{Name: "option", Value: "", Usage: "some option"}, + }, + Action: func(c *Context) { + parsedOption = c.String("option") + firstArg = c.Args().First() + }, + } + app.Commands = []Command{command} + + app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"}) + + expect(t, parsedOption, "my-option") + expect(t, firstArg, "my-arg") +} + +func TestApp_RunAsSubcommandParseFlags(t *testing.T) { + var context *Context + + a := NewApp() + a.Commands = []Command{ + { + Name: "foo", + Action: func(c *Context) { + context = c + }, + Flags: []Flag{ + StringFlag{ + Name: "lang", + Value: "english", + Usage: "language for the greeting", + }, + }, + Before: func(_ *Context) error { return nil }, + }, + } + a.Run([]string{"", "foo", "--lang", "spanish", "abcd"}) + + expect(t, context.Args().Get(0), "abcd") + expect(t, context.String("lang"), "spanish") +} + +func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) { + var parsedOption string + var args []string + + app := NewApp() + command := Command{ + Name: "cmd", + Flags: []Flag{ + StringFlag{Name: "option", Value: "", Usage: "some option"}, + }, + Action: func(c *Context) { + parsedOption = c.String("option") + args = c.Args() + }, + } + app.Commands = []Command{command} + + app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"}) + + expect(t, parsedOption, "my-option") + expect(t, args[0], "my-arg") + expect(t, args[1], "--") + expect(t, args[2], "--notARealFlag") +} + +func TestApp_CommandWithDash(t *testing.T) { + var args []string + + app := NewApp() + command := Command{ + Name: "cmd", + Action: func(c *Context) { + args = c.Args() + }, + } + app.Commands = []Command{command} + + app.Run([]string{"", "cmd", "my-arg", "-"}) + + expect(t, args[0], "my-arg") + expect(t, args[1], "-") +} + +func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) { + var args []string + + app := NewApp() + command := Command{ + Name: "cmd", + Action: func(c *Context) { + args = c.Args() + }, + } + app.Commands = []Command{command} + + app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"}) + + expect(t, args[0], "my-arg") + expect(t, args[1], "--") + expect(t, args[2], "notAFlagAtAll") +} + +func TestApp_Float64Flag(t *testing.T) { + var meters float64 + + app := NewApp() + app.Flags = []Flag{ + Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"}, + } + app.Action = func(c *Context) { + meters = c.Float64("height") + } + + app.Run([]string{"", "--height", "1.93"}) + expect(t, meters, 1.93) +} + +func TestApp_ParseSliceFlags(t *testing.T) { + var parsedOption, firstArg string + var parsedIntSlice []int + var parsedStringSlice []string + + app := NewApp() + command := Command{ + Name: "cmd", + Flags: []Flag{ + IntSliceFlag{Name: "p", Value: &IntSlice{}, Usage: "set one or more ip addr"}, + StringSliceFlag{Name: "ip", Value: &StringSlice{}, Usage: "set one or more ports to open"}, + }, + Action: func(c *Context) { + parsedIntSlice = c.IntSlice("p") + parsedStringSlice = c.StringSlice("ip") + parsedOption = c.String("option") + firstArg = c.Args().First() + }, + } + app.Commands = []Command{command} + + app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"}) + + IntsEquals := func(a, b []int) bool { + if len(a) != len(b) { + return false + } + for i, v := range a { + if v != b[i] { + return false + } + } + return true + } + + StrsEquals := func(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i, v := range a { + if v != b[i] { + return false + } + } + return true + } + var expectedIntSlice = []int{22, 80} + var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"} + + if !IntsEquals(parsedIntSlice, expectedIntSlice) { + t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice) + } + + if !StrsEquals(parsedStringSlice, expectedStringSlice) { + t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice) + } +} + +func TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) { + var parsedIntSlice []int + var parsedStringSlice []string + + app := NewApp() + command := Command{ + Name: "cmd", + Flags: []Flag{ + IntSliceFlag{Name: "a", Usage: "set numbers"}, + StringSliceFlag{Name: "str", Usage: "set strings"}, + }, + Action: func(c *Context) { + parsedIntSlice = c.IntSlice("a") + parsedStringSlice = c.StringSlice("str") + }, + } + app.Commands = []Command{command} + + app.Run([]string{"", "cmd", "my-arg", "-a", "2", "-str", "A"}) + + var expectedIntSlice = []int{2} + var expectedStringSlice = []string{"A"} + + if parsedIntSlice[0] != expectedIntSlice[0] { + t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0]) + } + + if parsedStringSlice[0] != expectedStringSlice[0] { + t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0]) + } +} + +func TestApp_DefaultStdout(t *testing.T) { + app := NewApp() + + if app.Writer != os.Stdout { + t.Error("Default output writer not set.") + } +} + +type mockWriter struct { + written []byte +} + +func (fw *mockWriter) Write(p []byte) (n int, err error) { + if fw.written == nil { + fw.written = p + } else { + fw.written = append(fw.written, p...) + } + + return len(p), nil +} + +func (fw *mockWriter) GetWritten() (b []byte) { + return fw.written +} + +func TestApp_SetStdout(t *testing.T) { + w := &mockWriter{} + + app := NewApp() + app.Name = "test" + app.Writer = w + + err := app.Run([]string{"help"}) + + if err != nil { + t.Fatalf("Run error: %s", err) + } + + if len(w.written) == 0 { + t.Error("App did not write output to desired writer.") + } +} + +func TestApp_BeforeFunc(t *testing.T) { + beforeRun, subcommandRun := false, false + beforeError := fmt.Errorf("fail") + var err error + + app := NewApp() + + app.Before = func(c *Context) error { + beforeRun = true + s := c.String("opt") + if s == "fail" { + return beforeError + } + + return nil + } + + app.Commands = []Command{ + Command{ + Name: "sub", + Action: func(c *Context) { + subcommandRun = true + }, + }, + } + + app.Flags = []Flag{ + StringFlag{Name: "opt"}, + } + + // run with the Before() func succeeding + err = app.Run([]string{"command", "--opt", "succeed", "sub"}) + + if err != nil { + t.Fatalf("Run error: %s", err) + } + + if beforeRun == false { + t.Errorf("Before() not executed when expected") + } + + if subcommandRun == false { + t.Errorf("Subcommand not executed when expected") + } + + // reset + beforeRun, subcommandRun = false, false + + // run with the Before() func failing + err = app.Run([]string{"command", "--opt", "fail", "sub"}) + + // should be the same error produced by the Before func + if err != beforeError { + t.Errorf("Run error expected, but not received") + } + + if beforeRun == false { + t.Errorf("Before() not executed when expected") + } + + if subcommandRun == true { + t.Errorf("Subcommand executed when NOT expected") + } + +} + +func TestApp_AfterFunc(t *testing.T) { + afterRun, subcommandRun := false, false + afterError := fmt.Errorf("fail") + var err error + + app := NewApp() + + app.After = func(c *Context) error { + afterRun = true + s := c.String("opt") + if s == "fail" { + return afterError + } + + return nil + } + + app.Commands = []Command{ + Command{ + Name: "sub", + Action: func(c *Context) { + subcommandRun = true + }, + }, + } + + app.Flags = []Flag{ + StringFlag{Name: "opt"}, + } + + // run with the After() func succeeding + err = app.Run([]string{"command", "--opt", "succeed", "sub"}) + + if err != nil { + t.Fatalf("Run error: %s", err) + } + + if afterRun == false { + t.Errorf("After() not executed when expected") + } + + if subcommandRun == false { + t.Errorf("Subcommand not executed when expected") + } + + // reset + afterRun, subcommandRun = false, false + + // run with the Before() func failing + err = app.Run([]string{"command", "--opt", "fail", "sub"}) + + // should be the same error produced by the Before func + if err != afterError { + t.Errorf("Run error expected, but not received") + } + + if afterRun == false { + t.Errorf("After() not executed when expected") + } + + if subcommandRun == false { + t.Errorf("Subcommand not executed when expected") + } +} + +func TestAppNoHelpFlag(t *testing.T) { + oldFlag := HelpFlag + defer func() { + HelpFlag = oldFlag + }() + + HelpFlag = BoolFlag{} + + app := NewApp() + app.Writer = ioutil.Discard + err := app.Run([]string{"test", "-h"}) + + if err != flag.ErrHelp { + t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err) + } +} + +func TestAppHelpPrinter(t *testing.T) { + oldPrinter := HelpPrinter + defer func() { + HelpPrinter = oldPrinter + }() + + var wasCalled = false + HelpPrinter = func(w io.Writer, template string, data interface{}) { + wasCalled = true + } + + app := NewApp() + app.Run([]string{"-h"}) + + if wasCalled == false { + t.Errorf("Help printer expected to be called, but was not") + } +} + +func TestAppVersionPrinter(t *testing.T) { + oldPrinter := VersionPrinter + defer func() { + VersionPrinter = oldPrinter + }() + + var wasCalled = false + VersionPrinter = func(c *Context) { + wasCalled = true + } + + app := NewApp() + ctx := NewContext(app, nil, nil) + ShowVersion(ctx) + + if wasCalled == false { + t.Errorf("Version printer expected to be called, but was not") + } +} + +func TestAppCommandNotFound(t *testing.T) { + beforeRun, subcommandRun := false, false + app := NewApp() + + app.CommandNotFound = func(c *Context, command string) { + beforeRun = true + } + + app.Commands = []Command{ + Command{ + Name: "bar", + Action: func(c *Context) { + subcommandRun = true + }, + }, + } + + app.Run([]string{"command", "foo"}) + + expect(t, beforeRun, true) + expect(t, subcommandRun, false) +} + +func TestGlobalFlag(t *testing.T) { + var globalFlag string + var globalFlagSet bool + app := NewApp() + app.Flags = []Flag{ + StringFlag{Name: "global, g", Usage: "global"}, + } + app.Action = func(c *Context) { + globalFlag = c.GlobalString("global") + globalFlagSet = c.GlobalIsSet("global") + } + app.Run([]string{"command", "-g", "foo"}) + expect(t, globalFlag, "foo") + expect(t, globalFlagSet, true) + +} + +func TestGlobalFlagsInSubcommands(t *testing.T) { + subcommandRun := false + parentFlag := false + app := NewApp() + + app.Flags = []Flag{ + BoolFlag{Name: "debug, d", Usage: "Enable debugging"}, + } + + app.Commands = []Command{ + Command{ + Name: "foo", + Flags: []Flag{ + BoolFlag{Name: "parent, p", Usage: "Parent flag"}, + }, + Subcommands: []Command{ + { + Name: "bar", + Action: func(c *Context) { + if c.GlobalBool("debug") { + subcommandRun = true + } + if c.GlobalBool("parent") { + parentFlag = true + } + }, + }, + }, + }, + } + + app.Run([]string{"command", "-d", "foo", "-p", "bar"}) + + expect(t, subcommandRun, true) + expect(t, parentFlag, true) +} + +func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) { + var subcommandHelpTopics = [][]string{ + {"command", "foo", "--help"}, + {"command", "foo", "-h"}, + {"command", "foo", "help"}, + } + + for _, flagSet := range subcommandHelpTopics { + t.Logf("==> checking with flags %v", flagSet) + + app := NewApp() + buf := new(bytes.Buffer) + app.Writer = buf + + subCmdBar := Command{ + Name: "bar", + Usage: "does bar things", + } + subCmdBaz := Command{ + Name: "baz", + Usage: "does baz things", + } + cmd := Command{ + Name: "foo", + Description: "descriptive wall of text about how it does foo things", + Subcommands: []Command{subCmdBar, subCmdBaz}, + } + + app.Commands = []Command{cmd} + err := app.Run(flagSet) + + if err != nil { + t.Error(err) + } + + output := buf.String() + t.Logf("output: %q\n", buf.Bytes()) + + if strings.Contains(output, "No help topic for") { + t.Errorf("expect a help topic, got none: \n%q", output) + } + + for _, shouldContain := range []string{ + cmd.Name, cmd.Description, + subCmdBar.Name, subCmdBar.Usage, + subCmdBaz.Name, subCmdBaz.Usage, + } { + if !strings.Contains(output, shouldContain) { + t.Errorf("want help to contain %q, did not: \n%q", shouldContain, output) + } + } + } +} + +func TestApp_Run_SubcommandFullPath(t *testing.T) { + app := NewApp() + buf := new(bytes.Buffer) + app.Writer = buf + app.Name = "command" + subCmd := Command{ + Name: "bar", + Usage: "does bar things", + } + cmd := Command{ + Name: "foo", + Description: "foo commands", + Subcommands: []Command{subCmd}, + } + app.Commands = []Command{cmd} + + err := app.Run([]string{"command", "foo", "bar", "--help"}) + if err != nil { + t.Error(err) + } + + output := buf.String() + if !strings.Contains(output, "command foo bar - does bar things") { + t.Errorf("expected full path to subcommand: %s", output) + } + if !strings.Contains(output, "command foo bar [arguments...]") { + t.Errorf("expected full path to subcommand: %s", output) + } +} + +func TestApp_Run_SubcommandHelpName(t *testing.T) { + app := NewApp() + buf := new(bytes.Buffer) + app.Writer = buf + app.Name = "command" + subCmd := Command{ + Name: "bar", + HelpName: "custom", + Usage: "does bar things", + } + cmd := Command{ + Name: "foo", + Description: "foo commands", + Subcommands: []Command{subCmd}, + } + app.Commands = []Command{cmd} + + err := app.Run([]string{"command", "foo", "bar", "--help"}) + if err != nil { + t.Error(err) + } + + output := buf.String() + if !strings.Contains(output, "custom - does bar things") { + t.Errorf("expected HelpName for subcommand: %s", output) + } + if !strings.Contains(output, "custom [arguments...]") { + t.Errorf("expected HelpName to subcommand: %s", output) + } +} + +func TestApp_Run_CommandHelpName(t *testing.T) { + app := NewApp() + buf := new(bytes.Buffer) + app.Writer = buf + app.Name = "command" + subCmd := Command{ + Name: "bar", + Usage: "does bar things", + } + cmd := Command{ + Name: "foo", + HelpName: "custom", + Description: "foo commands", + Subcommands: []Command{subCmd}, + } + app.Commands = []Command{cmd} + + err := app.Run([]string{"command", "foo", "bar", "--help"}) + if err != nil { + t.Error(err) + } + + output := buf.String() + if !strings.Contains(output, "command foo bar - does bar things") { + t.Errorf("expected full path to subcommand: %s", output) + } + if !strings.Contains(output, "command foo bar [arguments...]") { + t.Errorf("expected full path to subcommand: %s", output) + } +} + +func TestApp_Run_CommandSubcommandHelpName(t *testing.T) { + app := NewApp() + buf := new(bytes.Buffer) + app.Writer = buf + app.Name = "base" + subCmd := Command{ + Name: "bar", + HelpName: "custom", + Usage: "does bar things", + } + cmd := Command{ + Name: "foo", + Description: "foo commands", + Subcommands: []Command{subCmd}, + } + app.Commands = []Command{cmd} + + err := app.Run([]string{"command", "foo", "--help"}) + if err != nil { + t.Error(err) + } + + output := buf.String() + if !strings.Contains(output, "base foo - foo commands") { + t.Errorf("expected full path to subcommand: %s", output) + } + if !strings.Contains(output, "base foo command [command options] [arguments...]") { + t.Errorf("expected full path to subcommand: %s", output) + } +} + +func TestApp_Run_Help(t *testing.T) { + var helpArguments = [][]string{{"boom", "--help"}, {"boom", "-h"}, {"boom", "help"}} + + for _, args := range helpArguments { + buf := new(bytes.Buffer) + + t.Logf("==> checking with arguments %v", args) + + app := NewApp() + app.Name = "boom" + app.Usage = "make an explosive entrance" + app.Writer = buf + app.Action = func(c *Context) { + buf.WriteString("boom I say!") + } + + err := app.Run(args) + if err != nil { + t.Error(err) + } + + output := buf.String() + t.Logf("output: %q\n", buf.Bytes()) + + if !strings.Contains(output, "boom - make an explosive entrance") { + t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output) + } + } +} + +func TestApp_Run_Version(t *testing.T) { + var versionArguments = [][]string{{"boom", "--version"}, {"boom", "-v"}} + + for _, args := range versionArguments { + buf := new(bytes.Buffer) + + t.Logf("==> checking with arguments %v", args) + + app := NewApp() + app.Name = "boom" + app.Usage = "make an explosive entrance" + app.Version = "0.1.0" + app.Writer = buf + app.Action = func(c *Context) { + buf.WriteString("boom I say!") + } + + err := app.Run(args) + if err != nil { + t.Error(err) + } + + output := buf.String() + t.Logf("output: %q\n", buf.Bytes()) + + if !strings.Contains(output, "0.1.0") { + t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output) + } + } +} + +func TestApp_Run_Categories(t *testing.T) { + app := NewApp() + app.Name = "categories" + app.Commands = []Command{ + Command{ + Name: "command1", + Category: "1", + }, + Command{ + Name: "command2", + Category: "1", + }, + Command{ + Name: "command3", + Category: "2", + }, + } + buf := new(bytes.Buffer) + app.Writer = buf + + app.Run([]string{"categories"}) + + expect := CommandCategories{ + &CommandCategory{ + Name: "1", + Commands: []Command{ + app.Commands[0], + app.Commands[1], + }, + }, + &CommandCategory{ + Name: "2", + Commands: []Command{ + app.Commands[2], + }, + }, + } + if !reflect.DeepEqual(app.Categories(), expect) { + t.Fatalf("expected categories %#v, to equal %#v", app.Categories(), expect) + } + + output := buf.String() + t.Logf("output: %q\n", buf.Bytes()) + + if !strings.Contains(output, "1:\n command1") { + t.Errorf("want buffer to include category %q, did not: \n%q", "1:\n command1", output) + } +} + +func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) { + app := NewApp() + app.Action = func(c *Context) {} + app.Before = func(c *Context) error { return fmt.Errorf("before error") } + app.After = func(c *Context) error { return fmt.Errorf("after error") } + + err := app.Run([]string{"foo"}) + if err == nil { + t.Fatalf("expected to receive error from Run, got none") + } + + if !strings.Contains(err.Error(), "before error") { + t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) + } + if !strings.Contains(err.Error(), "after error") { + t.Errorf("expected text of error from After method, but got none in \"%v\"", err) + } +} + +func TestApp_Run_SubcommandDoesNotOverwriteErrorFromBefore(t *testing.T) { + app := NewApp() + app.Commands = []Command{ + Command{ + Subcommands: []Command{ + Command{ + Name: "sub", + }, + }, + Name: "bar", + Before: func(c *Context) error { return fmt.Errorf("before error") }, + After: func(c *Context) error { return fmt.Errorf("after error") }, + }, + } + + err := app.Run([]string{"foo", "bar"}) + if err == nil { + t.Fatalf("expected to receive error from Run, got none") + } + + if !strings.Contains(err.Error(), "before error") { + t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) + } + if !strings.Contains(err.Error(), "after error") { + t.Errorf("expected text of error from After method, but got none in \"%v\"", err) + } +} + +func TestApp_OnUsageError_WithWrongFlagValue(t *testing.T) { + app := NewApp() + app.Flags = []Flag{ + IntFlag{Name: "flag"}, + } + app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { + if isSubcommand { + t.Errorf("Expect no subcommand") + } + if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { + t.Errorf("Expect an invalid value error, but got \"%v\"", err) + } + return errors.New("intercepted: " + err.Error()) + } + app.Commands = []Command{ + Command{ + Name: "bar", + }, + } + + err := app.Run([]string{"foo", "--flag=wrong"}) + if err == nil { + t.Fatalf("expected to receive error from Run, got none") + } + + if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { + t.Errorf("Expect an intercepted error, but got \"%v\"", err) + } +} + +func TestApp_OnUsageError_WithWrongFlagValue_ForSubcommand(t *testing.T) { + app := NewApp() + app.Flags = []Flag{ + IntFlag{Name: "flag"}, + } + app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { + if isSubcommand { + t.Errorf("Expect subcommand") + } + if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { + t.Errorf("Expect an invalid value error, but got \"%v\"", err) + } + return errors.New("intercepted: " + err.Error()) + } + app.Commands = []Command{ + Command{ + Name: "bar", + }, + } + + err := app.Run([]string{"foo", "--flag=wrong", "bar"}) + if err == nil { + t.Fatalf("expected to receive error from Run, got none") + } + + if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { + t.Errorf("Expect an intercepted error, but got \"%v\"", err) + } +} diff --git a/vendor/github.com/codegangsta/cli/appveyor.yml b/vendor/github.com/codegangsta/cli/appveyor.yml new file mode 100644 index 00000000..3ca7afab --- /dev/null +++ b/vendor/github.com/codegangsta/cli/appveyor.yml @@ -0,0 +1,16 @@ +version: "{build}" + +os: Windows Server 2012 R2 + +install: + - go version + - go env + +build_script: + - cd %APPVEYOR_BUILD_FOLDER% + - go vet ./... + - go test -v ./... + +test: off + +deploy: off diff --git a/vendor/github.com/codegangsta/cli/category.go b/vendor/github.com/codegangsta/cli/category.go new file mode 100644 index 00000000..7dbf2182 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/category.go @@ -0,0 +1,30 @@ +package cli + +type CommandCategories []*CommandCategory + +type CommandCategory struct { + Name string + Commands Commands +} + +func (c CommandCategories) Less(i, j int) bool { + return c[i].Name < c[j].Name +} + +func (c CommandCategories) Len() int { + return len(c) +} + +func (c CommandCategories) Swap(i, j int) { + c[i], c[j] = c[j], c[i] +} + +func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { + for _, commandCategory := range c { + if commandCategory.Name == category { + commandCategory.Commands = append(commandCategory.Commands, command) + return c + } + } + return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) +} diff --git a/vendor/github.com/codegangsta/cli/cli.go b/vendor/github.com/codegangsta/cli/cli.go new file mode 100644 index 00000000..31dc9124 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/cli.go @@ -0,0 +1,40 @@ +// Package cli provides a minimal framework for creating and organizing command line +// Go applications. cli is designed to be easy to understand and write, the most simple +// cli application can be written as follows: +// func main() { +// cli.NewApp().Run(os.Args) +// } +// +// Of course this application does not do much, so let's make this an actual application: +// func main() { +// app := cli.NewApp() +// app.Name = "greet" +// app.Usage = "say a greeting" +// app.Action = func(c *cli.Context) { +// println("Greetings") +// } +// +// app.Run(os.Args) +// } +package cli + +import ( + "strings" +) + +type MultiError struct { + Errors []error +} + +func NewMultiError(err ...error) MultiError { + return MultiError{Errors: err} +} + +func (m MultiError) Error() string { + errs := make([]string, len(m.Errors)) + for i, err := range m.Errors { + errs[i] = err.Error() + } + + return strings.Join(errs, "\n") +} diff --git a/vendor/github.com/codegangsta/cli/command.go b/vendor/github.com/codegangsta/cli/command.go new file mode 100644 index 00000000..1a05b549 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/command.go @@ -0,0 +1,262 @@ +package cli + +import ( + "fmt" + "io/ioutil" + "sort" + "strings" +) + +// Command is a subcommand for a cli.App. +type Command struct { + // The name of the command + Name string + // short name of the command. Typically one character (deprecated, use `Aliases`) + ShortName string + // A list of aliases for the command + Aliases []string + // A short description of the usage of this command + Usage string + // Custom text to show on USAGE section of help + UsageText string + // A longer explanation of how the command works + Description string + // A short description of the arguments of this command + ArgsUsage string + // The category the command is part of + Category string + // The function to call when checking for bash command completions + BashComplete func(context *Context) + // An action to execute before any sub-subcommands are run, but after the context is ready + // If a non-nil error is returned, no sub-subcommands are run + Before func(context *Context) error + // An action to execute after any subcommands are run, but before the subcommand has finished + // It is run even if Action() panics + After func(context *Context) error + // The function to call when this command is invoked + Action func(context *Context) + // Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages. + // This function is able to replace the original error messages. + // If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted. + OnUsageError func(context *Context, err error) error + // List of child commands + Subcommands Commands + // List of flags to parse + Flags []Flag + // Treat all flags as normal arguments if true + SkipFlagParsing bool + // Boolean to hide built-in help command + HideHelp bool + + // Full name of command for help, defaults to full command name, including parent commands. + HelpName string + commandNamePath []string +} + +// Returns the full name of the command. +// For subcommands this ensures that parent commands are part of the command path +func (c Command) FullName() string { + if c.commandNamePath == nil { + return c.Name + } + return strings.Join(c.commandNamePath, " ") +} + +type Commands []Command + +// Invokes the command given the context, parses ctx.Args() to generate command-specific flags +func (c Command) Run(ctx *Context) (err error) { + if len(c.Subcommands) > 0 { + return c.startApp(ctx) + } + + if !c.HideHelp && (HelpFlag != BoolFlag{}) { + // append help to flags + c.Flags = append( + c.Flags, + HelpFlag, + ) + } + + if ctx.App.EnableBashCompletion { + c.Flags = append(c.Flags, BashCompletionFlag) + } + + set := flagSet(c.Name, c.Flags) + set.SetOutput(ioutil.Discard) + + if !c.SkipFlagParsing { + firstFlagIndex := -1 + terminatorIndex := -1 + for index, arg := range ctx.Args() { + if arg == "--" { + terminatorIndex = index + break + } else if arg == "-" { + // Do nothing. A dash alone is not really a flag. + continue + } else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 { + firstFlagIndex = index + } + } + + if firstFlagIndex > -1 { + args := ctx.Args() + regularArgs := make([]string, len(args[1:firstFlagIndex])) + copy(regularArgs, args[1:firstFlagIndex]) + + var flagArgs []string + if terminatorIndex > -1 { + flagArgs = args[firstFlagIndex:terminatorIndex] + regularArgs = append(regularArgs, args[terminatorIndex:]...) + } else { + flagArgs = args[firstFlagIndex:] + } + + err = set.Parse(append(flagArgs, regularArgs...)) + } else { + err = set.Parse(ctx.Args().Tail()) + } + } else { + if c.SkipFlagParsing { + err = set.Parse(append([]string{"--"}, ctx.Args().Tail()...)) + } + } + + if err != nil { + if c.OnUsageError != nil { + err := c.OnUsageError(ctx, err) + return err + } else { + fmt.Fprintln(ctx.App.Writer, "Incorrect Usage.") + fmt.Fprintln(ctx.App.Writer) + ShowCommandHelp(ctx, c.Name) + return err + } + } + + nerr := normalizeFlags(c.Flags, set) + if nerr != nil { + fmt.Fprintln(ctx.App.Writer, nerr) + fmt.Fprintln(ctx.App.Writer) + ShowCommandHelp(ctx, c.Name) + return nerr + } + context := NewContext(ctx.App, set, ctx) + + if checkCommandCompletions(context, c.Name) { + return nil + } + + if checkCommandHelp(context, c.Name) { + return nil + } + + if c.After != nil { + defer func() { + afterErr := c.After(context) + if afterErr != nil { + if err != nil { + err = NewMultiError(err, afterErr) + } else { + err = afterErr + } + } + }() + } + + if c.Before != nil { + err := c.Before(context) + if err != nil { + fmt.Fprintln(ctx.App.Writer, err) + fmt.Fprintln(ctx.App.Writer) + ShowCommandHelp(ctx, c.Name) + return err + } + } + + context.Command = c + c.Action(context) + return nil +} + +func (c Command) Names() []string { + names := []string{c.Name} + + if c.ShortName != "" { + names = append(names, c.ShortName) + } + + return append(names, c.Aliases...) +} + +// Returns true if Command.Name or Command.ShortName matches given name +func (c Command) HasName(name string) bool { + for _, n := range c.Names() { + if n == name { + return true + } + } + return false +} + +func (c Command) startApp(ctx *Context) error { + app := NewApp() + + // set the name and usage + app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name) + if c.HelpName == "" { + app.HelpName = c.HelpName + } else { + app.HelpName = app.Name + } + + if c.Description != "" { + app.Usage = c.Description + } else { + app.Usage = c.Usage + } + + // set CommandNotFound + app.CommandNotFound = ctx.App.CommandNotFound + + // set the flags and commands + app.Commands = c.Subcommands + app.Flags = c.Flags + app.HideHelp = c.HideHelp + + app.Version = ctx.App.Version + app.HideVersion = ctx.App.HideVersion + app.Compiled = ctx.App.Compiled + app.Author = ctx.App.Author + app.Email = ctx.App.Email + app.Writer = ctx.App.Writer + + app.categories = CommandCategories{} + for _, command := range c.Subcommands { + app.categories = app.categories.AddCommand(command.Category, command) + } + + sort.Sort(app.categories) + + // bash completion + app.EnableBashCompletion = ctx.App.EnableBashCompletion + if c.BashComplete != nil { + app.BashComplete = c.BashComplete + } + + // set the actions + app.Before = c.Before + app.After = c.After + if c.Action != nil { + app.Action = c.Action + } else { + app.Action = helpSubcommand.Action + } + + for index, cc := range app.Commands { + app.Commands[index].commandNamePath = []string{c.Name, cc.Name} + } + + return app.RunAsSubcommand(ctx) +} diff --git a/vendor/github.com/codegangsta/cli/command_test.go b/vendor/github.com/codegangsta/cli/command_test.go new file mode 100644 index 00000000..827da1df --- /dev/null +++ b/vendor/github.com/codegangsta/cli/command_test.go @@ -0,0 +1,97 @@ +package cli + +import ( + "errors" + "flag" + "fmt" + "io/ioutil" + "strings" + "testing" +) + +func TestCommandFlagParsing(t *testing.T) { + cases := []struct { + testArgs []string + skipFlagParsing bool + expectedErr error + }{ + {[]string{"blah", "blah", "-break"}, false, errors.New("flag provided but not defined: -break")}, // Test normal "not ignoring flags" flow + {[]string{"blah", "blah"}, true, nil}, // Test SkipFlagParsing without any args that look like flags + {[]string{"blah", "-break"}, true, nil}, // Test SkipFlagParsing with random flag arg + {[]string{"blah", "-help"}, true, nil}, // Test SkipFlagParsing with "special" help flag arg + } + + for _, c := range cases { + app := NewApp() + app.Writer = ioutil.Discard + set := flag.NewFlagSet("test", 0) + set.Parse(c.testArgs) + + context := NewContext(app, set, nil) + + command := Command{ + Name: "test-cmd", + Aliases: []string{"tc"}, + Usage: "this is for testing", + Description: "testing", + Action: func(_ *Context) {}, + } + + command.SkipFlagParsing = c.skipFlagParsing + + err := command.Run(context) + + expect(t, err, c.expectedErr) + expect(t, []string(context.Args()), c.testArgs) + } +} + +func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) { + app := NewApp() + app.Commands = []Command{ + Command{ + Name: "bar", + Before: func(c *Context) error { return fmt.Errorf("before error") }, + After: func(c *Context) error { return fmt.Errorf("after error") }, + }, + } + + err := app.Run([]string{"foo", "bar"}) + if err == nil { + t.Fatalf("expected to receive error from Run, got none") + } + + if !strings.Contains(err.Error(), "before error") { + t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) + } + if !strings.Contains(err.Error(), "after error") { + t.Errorf("expected text of error from After method, but got none in \"%v\"", err) + } +} + +func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) { + app := NewApp() + app.Commands = []Command{ + Command{ + Name: "bar", + Flags: []Flag{ + IntFlag{Name: "flag"}, + }, + OnUsageError: func(c *Context, err error) error { + if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { + t.Errorf("Expect an invalid value error, but got \"%v\"", err) + } + return errors.New("intercepted: " + err.Error()) + }, + }, + } + + err := app.Run([]string{"foo", "bar", "--flag=wrong"}) + if err == nil { + t.Fatalf("expected to receive error from Run, got none") + } + + if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { + t.Errorf("Expect an intercepted error, but got \"%v\"", err) + } +} diff --git a/vendor/github.com/codegangsta/cli/context.go b/vendor/github.com/codegangsta/cli/context.go new file mode 100644 index 00000000..b66d278d --- /dev/null +++ b/vendor/github.com/codegangsta/cli/context.go @@ -0,0 +1,393 @@ +package cli + +import ( + "errors" + "flag" + "strconv" + "strings" + "time" +) + +// Context is a type that is passed through to +// each Handler action in a cli application. Context +// can be used to retrieve context-specific Args and +// parsed command-line options. +type Context struct { + App *App + Command Command + flagSet *flag.FlagSet + setFlags map[string]bool + globalSetFlags map[string]bool + parentContext *Context +} + +// Creates a new context. For use in when invoking an App or Command action. +func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context { + return &Context{App: app, flagSet: set, parentContext: parentCtx} +} + +// Looks up the value of a local int flag, returns 0 if no int flag exists +func (c *Context) Int(name string) int { + return lookupInt(name, c.flagSet) +} + +// Looks up the value of a local time.Duration flag, returns 0 if no time.Duration flag exists +func (c *Context) Duration(name string) time.Duration { + return lookupDuration(name, c.flagSet) +} + +// Looks up the value of a local float64 flag, returns 0 if no float64 flag exists +func (c *Context) Float64(name string) float64 { + return lookupFloat64(name, c.flagSet) +} + +// Looks up the value of a local bool flag, returns false if no bool flag exists +func (c *Context) Bool(name string) bool { + return lookupBool(name, c.flagSet) +} + +// Looks up the value of a local boolT flag, returns false if no bool flag exists +func (c *Context) BoolT(name string) bool { + return lookupBoolT(name, c.flagSet) +} + +// Looks up the value of a local string flag, returns "" if no string flag exists +func (c *Context) String(name string) string { + return lookupString(name, c.flagSet) +} + +// Looks up the value of a local string slice flag, returns nil if no string slice flag exists +func (c *Context) StringSlice(name string) []string { + return lookupStringSlice(name, c.flagSet) +} + +// Looks up the value of a local int slice flag, returns nil if no int slice flag exists +func (c *Context) IntSlice(name string) []int { + return lookupIntSlice(name, c.flagSet) +} + +// Looks up the value of a local generic flag, returns nil if no generic flag exists +func (c *Context) Generic(name string) interface{} { + return lookupGeneric(name, c.flagSet) +} + +// Looks up the value of a global int flag, returns 0 if no int flag exists +func (c *Context) GlobalInt(name string) int { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupInt(name, fs) + } + return 0 +} + +// Looks up the value of a global time.Duration flag, returns 0 if no time.Duration flag exists +func (c *Context) GlobalDuration(name string) time.Duration { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupDuration(name, fs) + } + return 0 +} + +// Looks up the value of a global bool flag, returns false if no bool flag exists +func (c *Context) GlobalBool(name string) bool { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupBool(name, fs) + } + return false +} + +// Looks up the value of a global string flag, returns "" if no string flag exists +func (c *Context) GlobalString(name string) string { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupString(name, fs) + } + return "" +} + +// Looks up the value of a global string slice flag, returns nil if no string slice flag exists +func (c *Context) GlobalStringSlice(name string) []string { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupStringSlice(name, fs) + } + return nil +} + +// Looks up the value of a global int slice flag, returns nil if no int slice flag exists +func (c *Context) GlobalIntSlice(name string) []int { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupIntSlice(name, fs) + } + return nil +} + +// Looks up the value of a global generic flag, returns nil if no generic flag exists +func (c *Context) GlobalGeneric(name string) interface{} { + if fs := lookupGlobalFlagSet(name, c); fs != nil { + return lookupGeneric(name, fs) + } + return nil +} + +// Returns the number of flags set +func (c *Context) NumFlags() int { + return c.flagSet.NFlag() +} + +// Determines if the flag was actually set +func (c *Context) IsSet(name string) bool { + if c.setFlags == nil { + c.setFlags = make(map[string]bool) + c.flagSet.Visit(func(f *flag.Flag) { + c.setFlags[f.Name] = true + }) + } + return c.setFlags[name] == true +} + +// Determines if the global flag was actually set +func (c *Context) GlobalIsSet(name string) bool { + if c.globalSetFlags == nil { + c.globalSetFlags = make(map[string]bool) + ctx := c + if ctx.parentContext != nil { + ctx = ctx.parentContext + } + for ; ctx != nil && c.globalSetFlags[name] == false; ctx = ctx.parentContext { + ctx.flagSet.Visit(func(f *flag.Flag) { + c.globalSetFlags[f.Name] = true + }) + } + } + return c.globalSetFlags[name] +} + +// Returns a slice of flag names used in this context. +func (c *Context) FlagNames() (names []string) { + for _, flag := range c.Command.Flags { + name := strings.Split(flag.GetName(), ",")[0] + if name == "help" { + continue + } + names = append(names, name) + } + return +} + +// Returns a slice of global flag names used by the app. +func (c *Context) GlobalFlagNames() (names []string) { + for _, flag := range c.App.Flags { + name := strings.Split(flag.GetName(), ",")[0] + if name == "help" || name == "version" { + continue + } + names = append(names, name) + } + return +} + +// Returns the parent context, if any +func (c *Context) Parent() *Context { + return c.parentContext +} + +type Args []string + +// Returns the command line arguments associated with the context. +func (c *Context) Args() Args { + args := Args(c.flagSet.Args()) + return args +} + +// Returns the number of the command line arguments. +func (c *Context) NArg() int { + return len(c.Args()) +} + +// Returns the nth argument, or else a blank string +func (a Args) Get(n int) string { + if len(a) > n { + return a[n] + } + return "" +} + +// Returns the first argument, or else a blank string +func (a Args) First() string { + return a.Get(0) +} + +// Return the rest of the arguments (not the first one) +// or else an empty string slice +func (a Args) Tail() []string { + if len(a) >= 2 { + return []string(a)[1:] + } + return []string{} +} + +// Checks if there are any arguments present +func (a Args) Present() bool { + return len(a) != 0 +} + +// Swaps arguments at the given indexes +func (a Args) Swap(from, to int) error { + if from >= len(a) || to >= len(a) { + return errors.New("index out of range") + } + a[from], a[to] = a[to], a[from] + return nil +} + +func lookupGlobalFlagSet(name string, ctx *Context) *flag.FlagSet { + if ctx.parentContext != nil { + ctx = ctx.parentContext + } + for ; ctx != nil; ctx = ctx.parentContext { + if f := ctx.flagSet.Lookup(name); f != nil { + return ctx.flagSet + } + } + return nil +} + +func lookupInt(name string, set *flag.FlagSet) int { + f := set.Lookup(name) + if f != nil { + val, err := strconv.Atoi(f.Value.String()) + if err != nil { + return 0 + } + return val + } + + return 0 +} + +func lookupDuration(name string, set *flag.FlagSet) time.Duration { + f := set.Lookup(name) + if f != nil { + val, err := time.ParseDuration(f.Value.String()) + if err == nil { + return val + } + } + + return 0 +} + +func lookupFloat64(name string, set *flag.FlagSet) float64 { + f := set.Lookup(name) + if f != nil { + val, err := strconv.ParseFloat(f.Value.String(), 64) + if err != nil { + return 0 + } + return val + } + + return 0 +} + +func lookupString(name string, set *flag.FlagSet) string { + f := set.Lookup(name) + if f != nil { + return f.Value.String() + } + + return "" +} + +func lookupStringSlice(name string, set *flag.FlagSet) []string { + f := set.Lookup(name) + if f != nil { + return (f.Value.(*StringSlice)).Value() + + } + + return nil +} + +func lookupIntSlice(name string, set *flag.FlagSet) []int { + f := set.Lookup(name) + if f != nil { + return (f.Value.(*IntSlice)).Value() + + } + + return nil +} + +func lookupGeneric(name string, set *flag.FlagSet) interface{} { + f := set.Lookup(name) + if f != nil { + return f.Value + } + return nil +} + +func lookupBool(name string, set *flag.FlagSet) bool { + f := set.Lookup(name) + if f != nil { + val, err := strconv.ParseBool(f.Value.String()) + if err != nil { + return false + } + return val + } + + return false +} + +func lookupBoolT(name string, set *flag.FlagSet) bool { + f := set.Lookup(name) + if f != nil { + val, err := strconv.ParseBool(f.Value.String()) + if err != nil { + return true + } + return val + } + + return false +} + +func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) { + switch ff.Value.(type) { + case *StringSlice: + default: + set.Set(name, ff.Value.String()) + } +} + +func normalizeFlags(flags []Flag, set *flag.FlagSet) error { + visited := make(map[string]bool) + set.Visit(func(f *flag.Flag) { + visited[f.Name] = true + }) + for _, f := range flags { + parts := strings.Split(f.GetName(), ",") + if len(parts) == 1 { + continue + } + var ff *flag.Flag + for _, name := range parts { + name = strings.Trim(name, " ") + if visited[name] { + if ff != nil { + return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name) + } + ff = set.Lookup(name) + } + } + if ff == nil { + continue + } + for _, name := range parts { + name = strings.Trim(name, " ") + if !visited[name] { + copyFlag(name, ff, set) + } + } + } + return nil +} diff --git a/vendor/github.com/codegangsta/cli/context_test.go b/vendor/github.com/codegangsta/cli/context_test.go new file mode 100644 index 00000000..b8ab37d4 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/context_test.go @@ -0,0 +1,121 @@ +package cli + +import ( + "flag" + "testing" + "time" +) + +func TestNewContext(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Int("myflag", 12, "doc") + globalSet := flag.NewFlagSet("test", 0) + globalSet.Int("myflag", 42, "doc") + globalCtx := NewContext(nil, globalSet, nil) + command := Command{Name: "mycommand"} + c := NewContext(nil, set, globalCtx) + c.Command = command + expect(t, c.Int("myflag"), 12) + expect(t, c.GlobalInt("myflag"), 42) + expect(t, c.Command.Name, "mycommand") +} + +func TestContext_Int(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Int("myflag", 12, "doc") + c := NewContext(nil, set, nil) + expect(t, c.Int("myflag"), 12) +} + +func TestContext_Duration(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Duration("myflag", time.Duration(12*time.Second), "doc") + c := NewContext(nil, set, nil) + expect(t, c.Duration("myflag"), time.Duration(12*time.Second)) +} + +func TestContext_String(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.String("myflag", "hello world", "doc") + c := NewContext(nil, set, nil) + expect(t, c.String("myflag"), "hello world") +} + +func TestContext_Bool(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", false, "doc") + c := NewContext(nil, set, nil) + expect(t, c.Bool("myflag"), false) +} + +func TestContext_BoolT(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", true, "doc") + c := NewContext(nil, set, nil) + expect(t, c.BoolT("myflag"), true) +} + +func TestContext_Args(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", false, "doc") + c := NewContext(nil, set, nil) + set.Parse([]string{"--myflag", "bat", "baz"}) + expect(t, len(c.Args()), 2) + expect(t, c.Bool("myflag"), true) +} + +func TestContext_NArg(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", false, "doc") + c := NewContext(nil, set, nil) + set.Parse([]string{"--myflag", "bat", "baz"}) + expect(t, c.NArg(), 2) +} + +func TestContext_IsSet(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", false, "doc") + set.String("otherflag", "hello world", "doc") + globalSet := flag.NewFlagSet("test", 0) + globalSet.Bool("myflagGlobal", true, "doc") + globalCtx := NewContext(nil, globalSet, nil) + c := NewContext(nil, set, globalCtx) + set.Parse([]string{"--myflag", "bat", "baz"}) + globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"}) + expect(t, c.IsSet("myflag"), true) + expect(t, c.IsSet("otherflag"), false) + expect(t, c.IsSet("bogusflag"), false) + expect(t, c.IsSet("myflagGlobal"), false) +} + +func TestContext_GlobalIsSet(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", false, "doc") + set.String("otherflag", "hello world", "doc") + globalSet := flag.NewFlagSet("test", 0) + globalSet.Bool("myflagGlobal", true, "doc") + globalSet.Bool("myflagGlobalUnset", true, "doc") + globalCtx := NewContext(nil, globalSet, nil) + c := NewContext(nil, set, globalCtx) + set.Parse([]string{"--myflag", "bat", "baz"}) + globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"}) + expect(t, c.GlobalIsSet("myflag"), false) + expect(t, c.GlobalIsSet("otherflag"), false) + expect(t, c.GlobalIsSet("bogusflag"), false) + expect(t, c.GlobalIsSet("myflagGlobal"), true) + expect(t, c.GlobalIsSet("myflagGlobalUnset"), false) + expect(t, c.GlobalIsSet("bogusGlobal"), false) +} + +func TestContext_NumFlags(t *testing.T) { + set := flag.NewFlagSet("test", 0) + set.Bool("myflag", false, "doc") + set.String("otherflag", "hello world", "doc") + globalSet := flag.NewFlagSet("test", 0) + globalSet.Bool("myflagGlobal", true, "doc") + globalCtx := NewContext(nil, globalSet, nil) + c := NewContext(nil, set, globalCtx) + set.Parse([]string{"--myflag", "--otherflag=foo"}) + globalSet.Parse([]string{"--myflagGlobal"}) + expect(t, c.NumFlags(), 2) +} diff --git a/vendor/github.com/codegangsta/cli/flag.go b/vendor/github.com/codegangsta/cli/flag.go new file mode 100644 index 00000000..e951c2df --- /dev/null +++ b/vendor/github.com/codegangsta/cli/flag.go @@ -0,0 +1,546 @@ +package cli + +import ( + "flag" + "fmt" + "os" + "runtime" + "strconv" + "strings" + "time" +) + +// This flag enables bash-completion for all commands and subcommands +var BashCompletionFlag = BoolFlag{ + Name: "generate-bash-completion", +} + +// This flag prints the version for the application +var VersionFlag = BoolFlag{ + Name: "version, v", + Usage: "print the version", +} + +// This flag prints the help for all commands and subcommands +// Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand +// unless HideHelp is set to true) +var HelpFlag = BoolFlag{ + Name: "help, h", + Usage: "show help", +} + +// Flag is a common interface related to parsing flags in cli. +// For more advanced flag parsing techniques, it is recommended that +// this interface be implemented. +type Flag interface { + fmt.Stringer + // Apply Flag settings to the given flag set + Apply(*flag.FlagSet) + GetName() string +} + +func flagSet(name string, flags []Flag) *flag.FlagSet { + set := flag.NewFlagSet(name, flag.ContinueOnError) + + for _, f := range flags { + f.Apply(set) + } + return set +} + +func eachName(longName string, fn func(string)) { + parts := strings.Split(longName, ",") + for _, name := range parts { + name = strings.Trim(name, " ") + fn(name) + } +} + +// Generic is a generic parseable type identified by a specific flag +type Generic interface { + Set(value string) error + String() string +} + +// GenericFlag is the flag type for types implementing Generic +type GenericFlag struct { + Name string + Value Generic + Usage string + EnvVar string +} + +// String returns the string representation of the generic flag to display the +// help text to the user (uses the String() method of the generic flag to show +// the value) +func (f GenericFlag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s %v\t%v", prefixedNames(f.Name), f.FormatValueHelp(), f.Usage)) +} + +func (f GenericFlag) FormatValueHelp() string { + if f.Value == nil { + return "" + } + s := f.Value.String() + if len(s) == 0 { + return "" + } + return fmt.Sprintf("\"%s\"", s) +} + +// Apply takes the flagset and calls Set on the generic flag with the value +// provided by the user for parsing by the flag +func (f GenericFlag) Apply(set *flag.FlagSet) { + val := f.Value + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + val.Set(envVal) + break + } + } + } + + eachName(f.Name, func(name string) { + set.Var(f.Value, name, f.Usage) + }) +} + +func (f GenericFlag) GetName() string { + return f.Name +} + +// StringSlice is an opaque type for []string to satisfy flag.Value +type StringSlice []string + +// Set appends the string value to the list of values +func (f *StringSlice) Set(value string) error { + *f = append(*f, value) + return nil +} + +// String returns a readable representation of this value (for usage defaults) +func (f *StringSlice) String() string { + return fmt.Sprintf("%s", *f) +} + +// Value returns the slice of strings set by this flag +func (f *StringSlice) Value() []string { + return *f +} + +// StringSlice is a string flag that can be specified multiple times on the +// command-line +type StringSliceFlag struct { + Name string + Value *StringSlice + Usage string + EnvVar string +} + +// String returns the usage +func (f StringSliceFlag) String() string { + firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ") + pref := prefixFor(firstName) + return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f StringSliceFlag) Apply(set *flag.FlagSet) { + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + newVal := &StringSlice{} + for _, s := range strings.Split(envVal, ",") { + s = strings.TrimSpace(s) + newVal.Set(s) + } + f.Value = newVal + break + } + } + } + + eachName(f.Name, func(name string) { + if f.Value == nil { + f.Value = &StringSlice{} + } + set.Var(f.Value, name, f.Usage) + }) +} + +func (f StringSliceFlag) GetName() string { + return f.Name +} + +// StringSlice is an opaque type for []int to satisfy flag.Value +type IntSlice []int + +// Set parses the value into an integer and appends it to the list of values +func (f *IntSlice) Set(value string) error { + tmp, err := strconv.Atoi(value) + if err != nil { + return err + } else { + *f = append(*f, tmp) + } + return nil +} + +// String returns a readable representation of this value (for usage defaults) +func (f *IntSlice) String() string { + return fmt.Sprintf("%d", *f) +} + +// Value returns the slice of ints set by this flag +func (f *IntSlice) Value() []int { + return *f +} + +// IntSliceFlag is an int flag that can be specified multiple times on the +// command-line +type IntSliceFlag struct { + Name string + Value *IntSlice + Usage string + EnvVar string +} + +// String returns the usage +func (f IntSliceFlag) String() string { + firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ") + pref := prefixFor(firstName) + return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f IntSliceFlag) Apply(set *flag.FlagSet) { + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + newVal := &IntSlice{} + for _, s := range strings.Split(envVal, ",") { + s = strings.TrimSpace(s) + err := newVal.Set(s) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + } + } + f.Value = newVal + break + } + } + } + + eachName(f.Name, func(name string) { + if f.Value == nil { + f.Value = &IntSlice{} + } + set.Var(f.Value, name, f.Usage) + }) +} + +func (f IntSliceFlag) GetName() string { + return f.Name +} + +// BoolFlag is a switch that defaults to false +type BoolFlag struct { + Name string + Usage string + EnvVar string + Destination *bool +} + +// String returns a readable representation of this value (for usage defaults) +func (f BoolFlag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f BoolFlag) Apply(set *flag.FlagSet) { + val := false + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + envValBool, err := strconv.ParseBool(envVal) + if err == nil { + val = envValBool + } + break + } + } + } + + eachName(f.Name, func(name string) { + if f.Destination != nil { + set.BoolVar(f.Destination, name, val, f.Usage) + return + } + set.Bool(name, val, f.Usage) + }) +} + +func (f BoolFlag) GetName() string { + return f.Name +} + +// BoolTFlag this represents a boolean flag that is true by default, but can +// still be set to false by --some-flag=false +type BoolTFlag struct { + Name string + Usage string + EnvVar string + Destination *bool +} + +// String returns a readable representation of this value (for usage defaults) +func (f BoolTFlag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f BoolTFlag) Apply(set *flag.FlagSet) { + val := true + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + envValBool, err := strconv.ParseBool(envVal) + if err == nil { + val = envValBool + break + } + } + } + } + + eachName(f.Name, func(name string) { + if f.Destination != nil { + set.BoolVar(f.Destination, name, val, f.Usage) + return + } + set.Bool(name, val, f.Usage) + }) +} + +func (f BoolTFlag) GetName() string { + return f.Name +} + +// StringFlag represents a flag that takes as string value +type StringFlag struct { + Name string + Value string + Usage string + EnvVar string + Destination *string +} + +// String returns the usage +func (f StringFlag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s %v\t%v", prefixedNames(f.Name), f.FormatValueHelp(), f.Usage)) +} + +func (f StringFlag) FormatValueHelp() string { + s := f.Value + if len(s) == 0 { + return "" + } + return fmt.Sprintf("\"%s\"", s) +} + +// Apply populates the flag given the flag set and environment +func (f StringFlag) Apply(set *flag.FlagSet) { + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + f.Value = envVal + break + } + } + } + + eachName(f.Name, func(name string) { + if f.Destination != nil { + set.StringVar(f.Destination, name, f.Value, f.Usage) + return + } + set.String(name, f.Value, f.Usage) + }) +} + +func (f StringFlag) GetName() string { + return f.Name +} + +// IntFlag is a flag that takes an integer +// Errors if the value provided cannot be parsed +type IntFlag struct { + Name string + Value int + Usage string + EnvVar string + Destination *int +} + +// String returns the usage +func (f IntFlag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f IntFlag) Apply(set *flag.FlagSet) { + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + envValInt, err := strconv.ParseInt(envVal, 0, 64) + if err == nil { + f.Value = int(envValInt) + break + } + } + } + } + + eachName(f.Name, func(name string) { + if f.Destination != nil { + set.IntVar(f.Destination, name, f.Value, f.Usage) + return + } + set.Int(name, f.Value, f.Usage) + }) +} + +func (f IntFlag) GetName() string { + return f.Name +} + +// DurationFlag is a flag that takes a duration specified in Go's duration +// format: https://golang.org/pkg/time/#ParseDuration +type DurationFlag struct { + Name string + Value time.Duration + Usage string + EnvVar string + Destination *time.Duration +} + +// String returns a readable representation of this value (for usage defaults) +func (f DurationFlag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f DurationFlag) Apply(set *flag.FlagSet) { + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + envValDuration, err := time.ParseDuration(envVal) + if err == nil { + f.Value = envValDuration + break + } + } + } + } + + eachName(f.Name, func(name string) { + if f.Destination != nil { + set.DurationVar(f.Destination, name, f.Value, f.Usage) + return + } + set.Duration(name, f.Value, f.Usage) + }) +} + +func (f DurationFlag) GetName() string { + return f.Name +} + +// Float64Flag is a flag that takes an float value +// Errors if the value provided cannot be parsed +type Float64Flag struct { + Name string + Value float64 + Usage string + EnvVar string + Destination *float64 +} + +// String returns the usage +func (f Float64Flag) String() string { + return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) +} + +// Apply populates the flag given the flag set and environment +func (f Float64Flag) Apply(set *flag.FlagSet) { + if f.EnvVar != "" { + for _, envVar := range strings.Split(f.EnvVar, ",") { + envVar = strings.TrimSpace(envVar) + if envVal := os.Getenv(envVar); envVal != "" { + envValFloat, err := strconv.ParseFloat(envVal, 10) + if err == nil { + f.Value = float64(envValFloat) + } + } + } + } + + eachName(f.Name, func(name string) { + if f.Destination != nil { + set.Float64Var(f.Destination, name, f.Value, f.Usage) + return + } + set.Float64(name, f.Value, f.Usage) + }) +} + +func (f Float64Flag) GetName() string { + return f.Name +} + +func prefixFor(name string) (prefix string) { + if len(name) == 1 { + prefix = "-" + } else { + prefix = "--" + } + + return +} + +func prefixedNames(fullName string) (prefixed string) { + parts := strings.Split(fullName, ",") + for i, name := range parts { + name = strings.Trim(name, " ") + prefixed += prefixFor(name) + name + if i < len(parts)-1 { + prefixed += ", " + } + } + return +} + +func withEnvHint(envVar, str string) string { + envText := "" + if envVar != "" { + prefix := "$" + suffix := "" + sep := ", $" + if runtime.GOOS == "windows" { + prefix = "%" + suffix = "%" + sep = "%, %" + } + envText = fmt.Sprintf(" [%s%s%s]", prefix, strings.Join(strings.Split(envVar, ","), sep), suffix) + } + return str + envText +} diff --git a/vendor/github.com/codegangsta/cli/flag_test.go b/vendor/github.com/codegangsta/cli/flag_test.go new file mode 100644 index 00000000..3caa70a4 --- /dev/null +++ b/vendor/github.com/codegangsta/cli/flag_test.go @@ -0,0 +1,859 @@ +package cli + +import ( + "fmt" + "os" + "reflect" + "strings" + "testing" + "runtime" +) + +var boolFlagTests = []struct { + name string + expected string +}{ + {"help", "--help\t"}, + {"h", "-h\t"}, +} + +func TestBoolFlagHelpOutput(t *testing.T) { + + for _, test := range boolFlagTests { + flag := BoolFlag{Name: test.name} + output := flag.String() + + if output != test.expected { + t.Errorf("%s does not match %s", output, test.expected) + } + } +} + +var stringFlagTests = []struct { + name string + value string + expected string +}{ + {"help", "", "--help \t"}, + {"h", "", "-h \t"}, + {"h", "", "-h \t"}, + {"test", "Something", "--test \"Something\"\t"}, +} + +func TestStringFlagHelpOutput(t *testing.T) { + + for _, test := range stringFlagTests { + flag := StringFlag{Name: test.name, Value: test.value} + output := flag.String() + + if output != test.expected { + t.Errorf("%s does not match %s", output, test.expected) + } + } +} + +func TestStringFlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_FOO", "derp") + for _, test := range stringFlagTests { + flag := StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"} + output := flag.String() + + expectedSuffix := " [$APP_FOO]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_FOO%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%s does not end with" + expectedSuffix, output) + } + } +} + +var stringSliceFlagTests = []struct { + name string + value *StringSlice + expected string +}{ + {"help", func() *StringSlice { + s := &StringSlice{} + s.Set("") + return s + }(), "--help [--help option --help option]\t"}, + {"h", func() *StringSlice { + s := &StringSlice{} + s.Set("") + return s + }(), "-h [-h option -h option]\t"}, + {"h", func() *StringSlice { + s := &StringSlice{} + s.Set("") + return s + }(), "-h [-h option -h option]\t"}, + {"test", func() *StringSlice { + s := &StringSlice{} + s.Set("Something") + return s + }(), "--test [--test option --test option]\t"}, +} + +func TestStringSliceFlagHelpOutput(t *testing.T) { + + for _, test := range stringSliceFlagTests { + flag := StringSliceFlag{Name: test.name, Value: test.value} + output := flag.String() + + if output != test.expected { + t.Errorf("%q does not match %q", output, test.expected) + } + } +} + +func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_QWWX", "11,4") + for _, test := range stringSliceFlagTests { + flag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"} + output := flag.String() + + expectedSuffix := " [$APP_QWWX]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_QWWX%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%q does not end with" + expectedSuffix, output) + } + } +} + +var intFlagTests = []struct { + name string + expected string +}{ + {"help", "--help \"0\"\t"}, + {"h", "-h \"0\"\t"}, +} + +func TestIntFlagHelpOutput(t *testing.T) { + + for _, test := range intFlagTests { + flag := IntFlag{Name: test.name} + output := flag.String() + + if output != test.expected { + t.Errorf("%s does not match %s", output, test.expected) + } + } +} + +func TestIntFlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_BAR", "2") + for _, test := range intFlagTests { + flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"} + output := flag.String() + + expectedSuffix := " [$APP_BAR]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_BAR%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%s does not end with" + expectedSuffix, output) + } + } +} + +var durationFlagTests = []struct { + name string + expected string +}{ + {"help", "--help \"0\"\t"}, + {"h", "-h \"0\"\t"}, +} + +func TestDurationFlagHelpOutput(t *testing.T) { + + for _, test := range durationFlagTests { + flag := DurationFlag{Name: test.name} + output := flag.String() + + if output != test.expected { + t.Errorf("%s does not match %s", output, test.expected) + } + } +} + +func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_BAR", "2h3m6s") + for _, test := range durationFlagTests { + flag := DurationFlag{Name: test.name, EnvVar: "APP_BAR"} + output := flag.String() + + expectedSuffix := " [$APP_BAR]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_BAR%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%s does not end with" + expectedSuffix, output) + } + } +} + +var intSliceFlagTests = []struct { + name string + value *IntSlice + expected string +}{ + {"help", &IntSlice{}, "--help [--help option --help option]\t"}, + {"h", &IntSlice{}, "-h [-h option -h option]\t"}, + {"h", &IntSlice{}, "-h [-h option -h option]\t"}, + {"test", func() *IntSlice { + i := &IntSlice{} + i.Set("9") + return i + }(), "--test [--test option --test option]\t"}, +} + +func TestIntSliceFlagHelpOutput(t *testing.T) { + + for _, test := range intSliceFlagTests { + flag := IntSliceFlag{Name: test.name, Value: test.value} + output := flag.String() + + if output != test.expected { + t.Errorf("%q does not match %q", output, test.expected) + } + } +} + +func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_SMURF", "42,3") + for _, test := range intSliceFlagTests { + flag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"} + output := flag.String() + + expectedSuffix := " [$APP_SMURF]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_SMURF%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%q does not end with" + expectedSuffix, output) + } + } +} + +var float64FlagTests = []struct { + name string + expected string +}{ + {"help", "--help \"0\"\t"}, + {"h", "-h \"0\"\t"}, +} + +func TestFloat64FlagHelpOutput(t *testing.T) { + + for _, test := range float64FlagTests { + flag := Float64Flag{Name: test.name} + output := flag.String() + + if output != test.expected { + t.Errorf("%s does not match %s", output, test.expected) + } + } +} + +func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_BAZ", "99.4") + for _, test := range float64FlagTests { + flag := Float64Flag{Name: test.name, EnvVar: "APP_BAZ"} + output := flag.String() + + expectedSuffix := " [$APP_BAZ]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_BAZ%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%s does not end with" + expectedSuffix, output) + } + } +} + +var genericFlagTests = []struct { + name string + value Generic + expected string +}{ + {"test", &Parser{"abc", "def"}, "--test \"abc,def\"\ttest flag"}, + {"t", &Parser{"abc", "def"}, "-t \"abc,def\"\ttest flag"}, +} + +func TestGenericFlagHelpOutput(t *testing.T) { + + for _, test := range genericFlagTests { + flag := GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"} + output := flag.String() + + if output != test.expected { + t.Errorf("%q does not match %q", output, test.expected) + } + } +} + +func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) { + os.Clearenv() + os.Setenv("APP_ZAP", "3") + for _, test := range genericFlagTests { + flag := GenericFlag{Name: test.name, EnvVar: "APP_ZAP"} + output := flag.String() + + expectedSuffix := " [$APP_ZAP]" + if runtime.GOOS == "windows" { + expectedSuffix = " [%APP_ZAP%]" + } + if !strings.HasSuffix(output, expectedSuffix) { + t.Errorf("%s does not end with" + expectedSuffix, output) + } + } +} + +func TestParseMultiString(t *testing.T) { + (&App{ + Flags: []Flag{ + StringFlag{Name: "serve, s"}, + }, + Action: func(ctx *Context) { + if ctx.String("serve") != "10" { + t.Errorf("main name not set") + } + if ctx.String("s") != "10" { + t.Errorf("short name not set") + } + }, + }).Run([]string{"run", "-s", "10"}) +} + +func TestParseDestinationString(t *testing.T) { + var dest string + a := App{ + Flags: []Flag{ + StringFlag{ + Name: "dest", + Destination: &dest, + }, + }, + Action: func(ctx *Context) { + if dest != "10" { + t.Errorf("expected destination String 10") + } + }, + } + a.Run([]string{"run", "--dest", "10"}) +} + +func TestParseMultiStringFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_COUNT", "20") + (&App{ + Flags: []Flag{ + StringFlag{Name: "count, c", EnvVar: "APP_COUNT"}, + }, + Action: func(ctx *Context) { + if ctx.String("count") != "20" { + t.Errorf("main name not set") + } + if ctx.String("c") != "20" { + t.Errorf("short name not set") + } + }, + }).Run([]string{"run"}) +} + +func TestParseMultiStringFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_COUNT", "20") + (&App{ + Flags: []Flag{ + StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"}, + }, + Action: func(ctx *Context) { + if ctx.String("count") != "20" { + t.Errorf("main name not set") + } + if ctx.String("c") != "20" { + t.Errorf("short name not set") + } + }, + }).Run([]string{"run"}) +} + +func TestParseMultiStringSlice(t *testing.T) { + (&App{ + Flags: []Flag{ + StringSliceFlag{Name: "serve, s", Value: &StringSlice{}}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) { + t.Errorf("main name not set") + } + if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) { + t.Errorf("short name not set") + } + }, + }).Run([]string{"run", "-s", "10", "-s", "20"}) +} + +func TestParseMultiStringSliceFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_INTERVALS", "20,30,40") + + (&App{ + Flags: []Flag{ + StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "APP_INTERVALS"}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) { + t.Errorf("main name not set from env") + } + if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) { + t.Errorf("short name not set from env") + } + }, + }).Run([]string{"run"}) +} + +func TestParseMultiStringSliceFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_INTERVALS", "20,30,40") + + (&App{ + Flags: []Flag{ + StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) { + t.Errorf("main name not set from env") + } + if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) { + t.Errorf("short name not set from env") + } + }, + }).Run([]string{"run"}) +} + +func TestParseMultiInt(t *testing.T) { + a := App{ + Flags: []Flag{ + IntFlag{Name: "serve, s"}, + }, + Action: func(ctx *Context) { + if ctx.Int("serve") != 10 { + t.Errorf("main name not set") + } + if ctx.Int("s") != 10 { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run", "-s", "10"}) +} + +func TestParseDestinationInt(t *testing.T) { + var dest int + a := App{ + Flags: []Flag{ + IntFlag{ + Name: "dest", + Destination: &dest, + }, + }, + Action: func(ctx *Context) { + if dest != 10 { + t.Errorf("expected destination Int 10") + } + }, + } + a.Run([]string{"run", "--dest", "10"}) +} + +func TestParseMultiIntFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_TIMEOUT_SECONDS", "10") + a := App{ + Flags: []Flag{ + IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, + }, + Action: func(ctx *Context) { + if ctx.Int("timeout") != 10 { + t.Errorf("main name not set") + } + if ctx.Int("t") != 10 { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiIntFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_TIMEOUT_SECONDS", "10") + a := App{ + Flags: []Flag{ + IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"}, + }, + Action: func(ctx *Context) { + if ctx.Int("timeout") != 10 { + t.Errorf("main name not set") + } + if ctx.Int("t") != 10 { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiIntSlice(t *testing.T) { + (&App{ + Flags: []Flag{ + IntSliceFlag{Name: "serve, s", Value: &IntSlice{}}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) { + t.Errorf("main name not set") + } + if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) { + t.Errorf("short name not set") + } + }, + }).Run([]string{"run", "-s", "10", "-s", "20"}) +} + +func TestParseMultiIntSliceFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_INTERVALS", "20,30,40") + + (&App{ + Flags: []Flag{ + IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "APP_INTERVALS"}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) { + t.Errorf("main name not set from env") + } + if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) { + t.Errorf("short name not set from env") + } + }, + }).Run([]string{"run"}) +} + +func TestParseMultiIntSliceFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_INTERVALS", "20,30,40") + + (&App{ + Flags: []Flag{ + IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) { + t.Errorf("main name not set from env") + } + if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) { + t.Errorf("short name not set from env") + } + }, + }).Run([]string{"run"}) +} + +func TestParseMultiFloat64(t *testing.T) { + a := App{ + Flags: []Flag{ + Float64Flag{Name: "serve, s"}, + }, + Action: func(ctx *Context) { + if ctx.Float64("serve") != 10.2 { + t.Errorf("main name not set") + } + if ctx.Float64("s") != 10.2 { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run", "-s", "10.2"}) +} + +func TestParseDestinationFloat64(t *testing.T) { + var dest float64 + a := App{ + Flags: []Flag{ + Float64Flag{ + Name: "dest", + Destination: &dest, + }, + }, + Action: func(ctx *Context) { + if dest != 10.2 { + t.Errorf("expected destination Float64 10.2") + } + }, + } + a.Run([]string{"run", "--dest", "10.2"}) +} + +func TestParseMultiFloat64FromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_TIMEOUT_SECONDS", "15.5") + a := App{ + Flags: []Flag{ + Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, + }, + Action: func(ctx *Context) { + if ctx.Float64("timeout") != 15.5 { + t.Errorf("main name not set") + } + if ctx.Float64("t") != 15.5 { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiFloat64FromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_TIMEOUT_SECONDS", "15.5") + a := App{ + Flags: []Flag{ + Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"}, + }, + Action: func(ctx *Context) { + if ctx.Float64("timeout") != 15.5 { + t.Errorf("main name not set") + } + if ctx.Float64("t") != 15.5 { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiBool(t *testing.T) { + a := App{ + Flags: []Flag{ + BoolFlag{Name: "serve, s"}, + }, + Action: func(ctx *Context) { + if ctx.Bool("serve") != true { + t.Errorf("main name not set") + } + if ctx.Bool("s") != true { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run", "--serve"}) +} + +func TestParseDestinationBool(t *testing.T) { + var dest bool + a := App{ + Flags: []Flag{ + BoolFlag{ + Name: "dest", + Destination: &dest, + }, + }, + Action: func(ctx *Context) { + if dest != true { + t.Errorf("expected destination Bool true") + } + }, + } + a.Run([]string{"run", "--dest"}) +} + +func TestParseMultiBoolFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_DEBUG", "1") + a := App{ + Flags: []Flag{ + BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"}, + }, + Action: func(ctx *Context) { + if ctx.Bool("debug") != true { + t.Errorf("main name not set from env") + } + if ctx.Bool("d") != true { + t.Errorf("short name not set from env") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiBoolFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_DEBUG", "1") + a := App{ + Flags: []Flag{ + BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"}, + }, + Action: func(ctx *Context) { + if ctx.Bool("debug") != true { + t.Errorf("main name not set from env") + } + if ctx.Bool("d") != true { + t.Errorf("short name not set from env") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiBoolT(t *testing.T) { + a := App{ + Flags: []Flag{ + BoolTFlag{Name: "serve, s"}, + }, + Action: func(ctx *Context) { + if ctx.BoolT("serve") != true { + t.Errorf("main name not set") + } + if ctx.BoolT("s") != true { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run", "--serve"}) +} + +func TestParseDestinationBoolT(t *testing.T) { + var dest bool + a := App{ + Flags: []Flag{ + BoolTFlag{ + Name: "dest", + Destination: &dest, + }, + }, + Action: func(ctx *Context) { + if dest != true { + t.Errorf("expected destination BoolT true") + } + }, + } + a.Run([]string{"run", "--dest"}) +} + +func TestParseMultiBoolTFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_DEBUG", "0") + a := App{ + Flags: []Flag{ + BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"}, + }, + Action: func(ctx *Context) { + if ctx.BoolT("debug") != false { + t.Errorf("main name not set from env") + } + if ctx.BoolT("d") != false { + t.Errorf("short name not set from env") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseMultiBoolTFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_DEBUG", "0") + a := App{ + Flags: []Flag{ + BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"}, + }, + Action: func(ctx *Context) { + if ctx.BoolT("debug") != false { + t.Errorf("main name not set from env") + } + if ctx.BoolT("d") != false { + t.Errorf("short name not set from env") + } + }, + } + a.Run([]string{"run"}) +} + +type Parser [2]string + +func (p *Parser) Set(value string) error { + parts := strings.Split(value, ",") + if len(parts) != 2 { + return fmt.Errorf("invalid format") + } + + (*p)[0] = parts[0] + (*p)[1] = parts[1] + + return nil +} + +func (p *Parser) String() string { + return fmt.Sprintf("%s,%s", p[0], p[1]) +} + +func TestParseGeneric(t *testing.T) { + a := App{ + Flags: []Flag{ + GenericFlag{Name: "serve, s", Value: &Parser{}}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) { + t.Errorf("main name not set") + } + if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) { + t.Errorf("short name not set") + } + }, + } + a.Run([]string{"run", "-s", "10,20"}) +} + +func TestParseGenericFromEnv(t *testing.T) { + os.Clearenv() + os.Setenv("APP_SERVE", "20,30") + a := App{ + Flags: []Flag{ + GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) { + t.Errorf("main name not set from env") + } + if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) { + t.Errorf("short name not set from env") + } + }, + } + a.Run([]string{"run"}) +} + +func TestParseGenericFromEnvCascade(t *testing.T) { + os.Clearenv() + os.Setenv("APP_FOO", "99,2000") + a := App{ + Flags: []Flag{ + GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"}, + }, + Action: func(ctx *Context) { + if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) { + t.Errorf("value not set from env") + } + }, + } + a.Run([]string{"run"}) +} diff --git a/vendor/github.com/codegangsta/cli/help.go b/vendor/github.com/codegangsta/cli/help.go new file mode 100644 index 00000000..adf157df --- /dev/null +++ b/vendor/github.com/codegangsta/cli/help.go @@ -0,0 +1,253 @@ +package cli + +import ( + "fmt" + "io" + "strings" + "text/tabwriter" + "text/template" +) + +// The text template for the Default help topic. +// cli.go uses text/template to render templates. You can +// render custom help text by setting this variable. +var AppHelpTemplate = `NAME: + {{.Name}} - {{.Usage}} + +USAGE: + {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}} + {{if .Version}}{{if not .HideVersion}} +VERSION: + {{.Version}} + {{end}}{{end}}{{if len .Authors}} +AUTHOR(S): + {{range .Authors}}{{ . }}{{end}} + {{end}}{{if .Commands}} +COMMANDS:{{range .Categories}}{{if .Name}} + {{.Name}}{{ ":" }}{{end}}{{range .Commands}} + {{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}{{end}} +{{end}}{{end}}{{if .Flags}} +GLOBAL OPTIONS: + {{range .Flags}}{{.}} + {{end}}{{end}}{{if .Copyright }} +COPYRIGHT: + {{.Copyright}} + {{end}} +` + +// The text template for the command help topic. +// cli.go uses text/template to render templates. You can +// render custom help text by setting this variable. +var CommandHelpTemplate = `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}}{{if .Flags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{if .Category}} + +CATEGORY: + {{.Category}}{{end}}{{if .Description}} + +DESCRIPTION: + {{.Description}}{{end}}{{if .Flags}} + +OPTIONS: + {{range .Flags}}{{.}} + {{end}}{{ end }} +` + +// The text template for the subcommand help topic. +// cli.go uses text/template to render templates. You can +// render custom help text by setting this variable. +var SubcommandHelpTemplate = `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} command{{if .Flags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}} + +COMMANDS:{{range .Categories}}{{if .Name}} + {{.Name}}{{ ":" }}{{end}}{{range .Commands}} + {{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}{{end}} +{{end}}{{if .Flags}} +OPTIONS: + {{range .Flags}}{{.}} + {{end}}{{end}} +` + +var helpCommand = Command{ + Name: "help", + Aliases: []string{"h"}, + Usage: "Shows a list of commands or help for one command", + ArgsUsage: "[command]", + Action: func(c *Context) { + args := c.Args() + if args.Present() { + ShowCommandHelp(c, args.First()) + } else { + ShowAppHelp(c) + } + }, +} + +var helpSubcommand = Command{ + Name: "help", + Aliases: []string{"h"}, + Usage: "Shows a list of commands or help for one command", + ArgsUsage: "[command]", + Action: func(c *Context) { + args := c.Args() + if args.Present() { + ShowCommandHelp(c, args.First()) + } else { + ShowSubcommandHelp(c) + } + }, +} + +// Prints help for the App or Command +type helpPrinter func(w io.Writer, templ string, data interface{}) + +var HelpPrinter helpPrinter = printHelp + +// Prints version for the App +var VersionPrinter = printVersion + +func ShowAppHelp(c *Context) { + HelpPrinter(c.App.Writer, AppHelpTemplate, c.App) +} + +// Prints the list of subcommands as the default app completion method +func DefaultAppComplete(c *Context) { + for _, command := range c.App.Commands { + for _, name := range command.Names() { + fmt.Fprintln(c.App.Writer, name) + } + } +} + +// Prints help for the given command +func ShowCommandHelp(ctx *Context, command string) { + // show the subcommand help for a command with subcommands + if command == "" { + HelpPrinter(ctx.App.Writer, SubcommandHelpTemplate, ctx.App) + return + } + + for _, c := range ctx.App.Commands { + if c.HasName(command) { + HelpPrinter(ctx.App.Writer, CommandHelpTemplate, c) + return + } + } + + if ctx.App.CommandNotFound != nil { + ctx.App.CommandNotFound(ctx, command) + } else { + fmt.Fprintf(ctx.App.Writer, "No help topic for '%v'\n", command) + } +} + +// Prints help for the given subcommand +func ShowSubcommandHelp(c *Context) { + ShowCommandHelp(c, c.Command.Name) +} + +// Prints the version number of the App +func ShowVersion(c *Context) { + VersionPrinter(c) +} + +func printVersion(c *Context) { + fmt.Fprintf(c.App.Writer, "%v version %v\n", c.App.Name, c.App.Version) +} + +// Prints the lists of commands within a given context +func ShowCompletions(c *Context) { + a := c.App + if a != nil && a.BashComplete != nil { + a.BashComplete(c) + } +} + +// Prints the custom completions for a given command +func ShowCommandCompletions(ctx *Context, command string) { + c := ctx.App.Command(command) + if c != nil && c.BashComplete != nil { + c.BashComplete(ctx) + } +} + +func printHelp(out io.Writer, templ string, data interface{}) { + funcMap := template.FuncMap{ + "join": strings.Join, + } + + w := tabwriter.NewWriter(out, 0, 8, 1, '\t', 0) + t := template.Must(template.New("help").Funcs(funcMap).Parse(templ)) + err := t.Execute(w, data) + if err != nil { + // If the writer is closed, t.Execute will fail, and there's nothing + // we can do to recover. We could send this to os.Stderr if we need. + return + } + w.Flush() +} + +func checkVersion(c *Context) bool { + found := false + if VersionFlag.Name != "" { + eachName(VersionFlag.Name, func(name string) { + if c.GlobalBool(name) || c.Bool(name) { + found = true + } + }) + } + return found +} + +func checkHelp(c *Context) bool { + found := false + if HelpFlag.Name != "" { + eachName(HelpFlag.Name, func(name string) { + if c.GlobalBool(name) || c.Bool(name) { + found = true + } + }) + } + return found +} + +func checkCommandHelp(c *Context, name string) bool { + if c.Bool("h") || c.Bool("help") { + ShowCommandHelp(c, name) + return true + } + + return false +} + +func checkSubcommandHelp(c *Context) bool { + if c.GlobalBool("h") || c.GlobalBool("help") { + ShowSubcommandHelp(c) + return true + } + + return false +} + +func checkCompletions(c *Context) bool { + if (c.GlobalBool(BashCompletionFlag.Name) || c.Bool(BashCompletionFlag.Name)) && c.App.EnableBashCompletion { + ShowCompletions(c) + return true + } + + return false +} + +func checkCommandCompletions(c *Context, name string) bool { + if c.Bool(BashCompletionFlag.Name) && c.App.EnableBashCompletion { + ShowCommandCompletions(c, name) + return true + } + + return false +} diff --git a/vendor/github.com/codegangsta/cli/help_test.go b/vendor/github.com/codegangsta/cli/help_test.go new file mode 100644 index 00000000..0821f48a --- /dev/null +++ b/vendor/github.com/codegangsta/cli/help_test.go @@ -0,0 +1,110 @@ +package cli + +import ( + "bytes" + "testing" +) + +func Test_ShowAppHelp_NoAuthor(t *testing.T) { + output := new(bytes.Buffer) + app := NewApp() + app.Writer = output + + c := NewContext(app, nil, nil) + + ShowAppHelp(c) + + if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 { + t.Errorf("expected\n%snot to include %s", output.String(), "AUTHOR(S):") + } +} + +func Test_ShowAppHelp_NoVersion(t *testing.T) { + output := new(bytes.Buffer) + app := NewApp() + app.Writer = output + + app.Version = "" + + c := NewContext(app, nil, nil) + + ShowAppHelp(c) + + if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 { + t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:") + } +} + +func Test_ShowAppHelp_HideVersion(t *testing.T) { + output := new(bytes.Buffer) + app := NewApp() + app.Writer = output + + app.HideVersion = true + + c := NewContext(app, nil, nil) + + ShowAppHelp(c) + + if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 { + t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:") + } +} + +func Test_Help_Custom_Flags(t *testing.T) { + oldFlag := HelpFlag + defer func() { + HelpFlag = oldFlag + }() + + HelpFlag = BoolFlag{ + Name: "help, x", + Usage: "show help", + } + + app := App{ + Flags: []Flag{ + BoolFlag{Name: "foo, h"}, + }, + Action: func(ctx *Context) { + if ctx.Bool("h") != true { + t.Errorf("custom help flag not set") + } + }, + } + output := new(bytes.Buffer) + app.Writer = output + app.Run([]string{"test", "-h"}) + if output.Len() > 0 { + t.Errorf("unexpected output: %s", output.String()) + } +} + +func Test_Version_Custom_Flags(t *testing.T) { + oldFlag := VersionFlag + defer func() { + VersionFlag = oldFlag + }() + + VersionFlag = BoolFlag{ + Name: "version, V", + Usage: "show version", + } + + app := App{ + Flags: []Flag{ + BoolFlag{Name: "foo, v"}, + }, + Action: func(ctx *Context) { + if ctx.Bool("v") != true { + t.Errorf("custom version flag not set") + } + }, + } + output := new(bytes.Buffer) + app.Writer = output + app.Run([]string{"test", "-v"}) + if output.Len() > 0 { + t.Errorf("unexpected output: %s", output.String()) + } +} diff --git a/vendor/github.com/codegangsta/cli/helpers_test.go b/vendor/github.com/codegangsta/cli/helpers_test.go new file mode 100644 index 00000000..b1b7339f --- /dev/null +++ b/vendor/github.com/codegangsta/cli/helpers_test.go @@ -0,0 +1,19 @@ +package cli + +import ( + "reflect" + "testing" +) + +/* Test Helpers */ +func expect(t *testing.T, a interface{}, b interface{}) { + if !reflect.DeepEqual(a, b) { + t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) + } +} + +func refute(t *testing.T, a interface{}, b interface{}) { + if reflect.DeepEqual(a, b) { + t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) + } +} diff --git a/vendor/github.com/docker/go-units/CONTRIBUTING.md b/vendor/github.com/docker/go-units/CONTRIBUTING.md new file mode 100644 index 00000000..9ea86d78 --- /dev/null +++ b/vendor/github.com/docker/go-units/CONTRIBUTING.md @@ -0,0 +1,67 @@ +# Contributing to go-units + +Want to hack on go-units? Awesome! Here are instructions to get you started. + +go-units is a part of the [Docker](https://www.docker.com) project, and follows +the same rules and principles. If you're already familiar with the way +Docker does things, you'll feel right at home. + +Otherwise, go read Docker's +[contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md), +[issue triaging](https://github.com/docker/docker/blob/master/project/ISSUE-TRIAGE.md), +[review process](https://github.com/docker/docker/blob/master/project/REVIEWING.md) and +[branches and tags](https://github.com/docker/docker/blob/master/project/BRANCHES-AND-TAGS.md). + +### Sign your work + +The sign-off is a simple line at the end of the explanation for the patch. Your +signature certifies that you wrote the patch or otherwise have the right to pass +it on as an open-source patch. The rules are pretty simple: if you can certify +the below (from [developercertificate.org](http://developercertificate.org/)): + +``` +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +660 York Street, Suite 102, +San Francisco, CA 94110 USA + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. +``` + +Then you just add a line to every git commit message: + + Signed-off-by: Joe Smith + +Use your real name (sorry, no pseudonyms or anonymous contributions.) + +If you set your `user.name` and `user.email` git configs, you can sign your +commit automatically with `git commit -s`. diff --git a/vendor/github.com/docker/go-units/LICENSE.code b/vendor/github.com/docker/go-units/LICENSE.code new file mode 100644 index 00000000..b55b37bc --- /dev/null +++ b/vendor/github.com/docker/go-units/LICENSE.code @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + https://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 + + Copyright 2015 Docker, 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 + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT 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/go-units/LICENSE.docs b/vendor/github.com/docker/go-units/LICENSE.docs new file mode 100644 index 00000000..e26cd4fc --- /dev/null +++ b/vendor/github.com/docker/go-units/LICENSE.docs @@ -0,0 +1,425 @@ +Attribution-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + + including for purposes of Section 3(b); and + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public licenses. +Notwithstanding, Creative Commons may elect to apply one of its public +licenses to material it publishes and in those instances will be +considered the "Licensor." Except for the limited purpose of indicating +that material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the public +licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/vendor/github.com/docker/go-units/MAINTAINERS b/vendor/github.com/docker/go-units/MAINTAINERS new file mode 100644 index 00000000..477be8b2 --- /dev/null +++ b/vendor/github.com/docker/go-units/MAINTAINERS @@ -0,0 +1,27 @@ +# go-connections maintainers file +# +# This file describes who runs the docker/go-connections project and how. +# This is a living document - if you see something out of date or missing, speak up! +# +# It is structured to be consumable by both humans and programs. +# To extract its contents programmatically, use any TOML-compliant parser. +# +# This file is compiled into the MAINTAINERS file in docker/opensource. +# +[Org] + [Org."Core maintainers"] + people = [ + "calavera", + ] + +[people] + +# A reference list of all people associated with the project. +# All other sections should refer to people by their canonical key +# in the people section. + + # ADD YOURSELF HERE IN ALPHABETICAL ORDER + [people.calavera] + Name = "David Calavera" + Email = "david.calavera@gmail.com" + GitHub = "calavera" diff --git a/vendor/github.com/docker/go-units/README.md b/vendor/github.com/docker/go-units/README.md new file mode 100644 index 00000000..3ce4d79d --- /dev/null +++ b/vendor/github.com/docker/go-units/README.md @@ -0,0 +1,18 @@ +[![GoDoc](https://godoc.org/github.com/docker/go-units?status.svg)](https://godoc.org/github.com/docker/go-units) + +# Introduction + +go-units is a library to transform human friendly measurements into machine friendly values. + +## Usage + +See the [docs in godoc](https://godoc.org/github.com/docker/go-units) for examples and documentation. + +## Copyright and license + +Copyright © 2015 Docker, Inc. All rights reserved, except as follows. Code +is released under the Apache 2.0 license. The README.md file, and files in the +"docs" folder are licensed under the Creative Commons Attribution 4.0 +International License under the terms and conditions set forth in the file +"LICENSE.docs". You may obtain a duplicate copy of the same license, titled +CC-BY-SA-4.0, at http://creativecommons.org/licenses/by/4.0/. diff --git a/vendor/github.com/docker/go-units/circle.yml b/vendor/github.com/docker/go-units/circle.yml new file mode 100644 index 00000000..9043b354 --- /dev/null +++ b/vendor/github.com/docker/go-units/circle.yml @@ -0,0 +1,11 @@ +dependencies: + post: + # install golint + - go get github.com/golang/lint/golint + +test: + pre: + # run analysis before tests + - go vet ./... + - test -z "$(golint ./... | tee /dev/stderr)" + - test -z "$(gofmt -s -l . | tee /dev/stderr)" diff --git a/vendor/github.com/docker/go-units/duration.go b/vendor/github.com/docker/go-units/duration.go new file mode 100644 index 00000000..c219a8a9 --- /dev/null +++ b/vendor/github.com/docker/go-units/duration.go @@ -0,0 +1,33 @@ +// Package units provides helper function to parse and print size and time units +// in human-readable format. +package units + +import ( + "fmt" + "time" +) + +// HumanDuration returns a human-readable approximation of a duration +// (eg. "About a minute", "4 hours ago", etc.). +func HumanDuration(d time.Duration) string { + if seconds := int(d.Seconds()); seconds < 1 { + return "Less than a second" + } else if seconds < 60 { + return fmt.Sprintf("%d seconds", seconds) + } else if minutes := int(d.Minutes()); minutes == 1 { + return "About a minute" + } else if minutes < 60 { + return fmt.Sprintf("%d minutes", minutes) + } else if hours := int(d.Hours()); hours == 1 { + return "About an hour" + } else if hours < 48 { + return fmt.Sprintf("%d hours", hours) + } else if hours < 24*7*2 { + return fmt.Sprintf("%d days", hours/24) + } else if hours < 24*30*3 { + return fmt.Sprintf("%d weeks", hours/24/7) + } else if hours < 24*365*2 { + return fmt.Sprintf("%d months", hours/24/30) + } + return fmt.Sprintf("%d years", int(d.Hours())/24/365) +} diff --git a/vendor/github.com/docker/go-units/duration_test.go b/vendor/github.com/docker/go-units/duration_test.go new file mode 100644 index 00000000..63baa515 --- /dev/null +++ b/vendor/github.com/docker/go-units/duration_test.go @@ -0,0 +1,81 @@ +package units + +import ( + "fmt" + "testing" + "time" +) + +func ExampleHumanDuration() { + fmt.Println(HumanDuration(450 * time.Millisecond)) + fmt.Println(HumanDuration(47 * time.Second)) + fmt.Println(HumanDuration(1 * time.Minute)) + fmt.Println(HumanDuration(3 * time.Minute)) + fmt.Println(HumanDuration(35 * time.Minute)) + fmt.Println(HumanDuration(35*time.Minute + 40*time.Second)) + fmt.Println(HumanDuration(1 * time.Hour)) + fmt.Println(HumanDuration(1*time.Hour + 45*time.Minute)) + fmt.Println(HumanDuration(3 * time.Hour)) + fmt.Println(HumanDuration(3*time.Hour + 59*time.Minute)) + fmt.Println(HumanDuration(3*time.Hour + 60*time.Minute)) + fmt.Println(HumanDuration(24 * time.Hour)) + fmt.Println(HumanDuration(24*time.Hour + 12*time.Hour)) + fmt.Println(HumanDuration(2 * 24 * time.Hour)) + fmt.Println(HumanDuration(7 * 24 * time.Hour)) + fmt.Println(HumanDuration(13*24*time.Hour + 5*time.Hour)) + fmt.Println(HumanDuration(2 * 7 * 24 * time.Hour)) + fmt.Println(HumanDuration(2*7*24*time.Hour + 4*24*time.Hour)) + fmt.Println(HumanDuration(3 * 7 * 24 * time.Hour)) + fmt.Println(HumanDuration(4 * 7 * 24 * time.Hour)) + fmt.Println(HumanDuration(4*7*24*time.Hour + 3*24*time.Hour)) + fmt.Println(HumanDuration(1 * 30 * 24 * time.Hour)) + fmt.Println(HumanDuration(1*30*24*time.Hour + 2*7*24*time.Hour)) + fmt.Println(HumanDuration(2 * 30 * 24 * time.Hour)) + fmt.Println(HumanDuration(3*30*24*time.Hour + 1*7*24*time.Hour)) + fmt.Println(HumanDuration(5*30*24*time.Hour + 2*7*24*time.Hour)) + fmt.Println(HumanDuration(13 * 30 * 24 * time.Hour)) + fmt.Println(HumanDuration(23 * 30 * 24 * time.Hour)) + fmt.Println(HumanDuration(24 * 30 * 24 * time.Hour)) + fmt.Println(HumanDuration(24*30*24*time.Hour + 2*7*24*time.Hour)) + fmt.Println(HumanDuration(3*365*24*time.Hour + 2*30*24*time.Hour)) +} + +func TestHumanDuration(t *testing.T) { + // Useful duration abstractions + day := 24 * time.Hour + week := 7 * day + month := 30 * day + year := 365 * day + + assertEquals(t, "Less than a second", HumanDuration(450*time.Millisecond)) + assertEquals(t, "47 seconds", HumanDuration(47*time.Second)) + assertEquals(t, "About a minute", HumanDuration(1*time.Minute)) + assertEquals(t, "3 minutes", HumanDuration(3*time.Minute)) + assertEquals(t, "35 minutes", HumanDuration(35*time.Minute)) + assertEquals(t, "35 minutes", HumanDuration(35*time.Minute+40*time.Second)) + assertEquals(t, "About an hour", HumanDuration(1*time.Hour)) + assertEquals(t, "About an hour", HumanDuration(1*time.Hour+45*time.Minute)) + assertEquals(t, "3 hours", HumanDuration(3*time.Hour)) + assertEquals(t, "3 hours", HumanDuration(3*time.Hour+59*time.Minute)) + assertEquals(t, "4 hours", HumanDuration(3*time.Hour+60*time.Minute)) + assertEquals(t, "24 hours", HumanDuration(24*time.Hour)) + assertEquals(t, "36 hours", HumanDuration(1*day+12*time.Hour)) + assertEquals(t, "2 days", HumanDuration(2*day)) + assertEquals(t, "7 days", HumanDuration(7*day)) + assertEquals(t, "13 days", HumanDuration(13*day+5*time.Hour)) + assertEquals(t, "2 weeks", HumanDuration(2*week)) + assertEquals(t, "2 weeks", HumanDuration(2*week+4*day)) + assertEquals(t, "3 weeks", HumanDuration(3*week)) + assertEquals(t, "4 weeks", HumanDuration(4*week)) + assertEquals(t, "4 weeks", HumanDuration(4*week+3*day)) + assertEquals(t, "4 weeks", HumanDuration(1*month)) + assertEquals(t, "6 weeks", HumanDuration(1*month+2*week)) + assertEquals(t, "8 weeks", HumanDuration(2*month)) + assertEquals(t, "3 months", HumanDuration(3*month+1*week)) + assertEquals(t, "5 months", HumanDuration(5*month+2*week)) + assertEquals(t, "13 months", HumanDuration(13*month)) + assertEquals(t, "23 months", HumanDuration(23*month)) + assertEquals(t, "24 months", HumanDuration(24*month)) + assertEquals(t, "2 years", HumanDuration(24*month+2*week)) + assertEquals(t, "3 years", HumanDuration(3*year+2*month)) +} diff --git a/vendor/github.com/docker/go-units/size.go b/vendor/github.com/docker/go-units/size.go new file mode 100644 index 00000000..989edd29 --- /dev/null +++ b/vendor/github.com/docker/go-units/size.go @@ -0,0 +1,95 @@ +package units + +import ( + "fmt" + "regexp" + "strconv" + "strings" +) + +// See: http://en.wikipedia.org/wiki/Binary_prefix +const ( + // Decimal + + KB = 1000 + MB = 1000 * KB + GB = 1000 * MB + TB = 1000 * GB + PB = 1000 * TB + + // Binary + + KiB = 1024 + MiB = 1024 * KiB + GiB = 1024 * MiB + TiB = 1024 * GiB + PiB = 1024 * TiB +) + +type unitMap map[string]int64 + +var ( + decimalMap = unitMap{"k": KB, "m": MB, "g": GB, "t": TB, "p": PB} + binaryMap = unitMap{"k": KiB, "m": MiB, "g": GiB, "t": TiB, "p": PiB} + sizeRegex = regexp.MustCompile(`^(\d+(\.\d+)*) ?([kKmMgGtTpP])?[bB]?$`) +) + +var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} +var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} + +// CustomSize returns a human-readable approximation of a size +// using custom format. +func CustomSize(format string, size float64, base float64, _map []string) string { + i := 0 + for size >= base { + size = size / base + i++ + } + return fmt.Sprintf(format, size, _map[i]) +} + +// HumanSize returns a human-readable approximation of a size +// capped at 4 valid numbers (eg. "2.746 MB", "796 KB"). +func HumanSize(size float64) string { + return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs) +} + +// BytesSize returns a human-readable size in bytes, kibibytes, +// mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB"). +func BytesSize(size float64) string { + return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs) +} + +// FromHumanSize returns an integer from a human-readable specification of a +// size using SI standard (eg. "44kB", "17MB"). +func FromHumanSize(size string) (int64, error) { + return parseSize(size, decimalMap) +} + +// RAMInBytes parses a human-readable string representing an amount of RAM +// in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and +// returns the number of bytes, or -1 if the string is unparseable. +// Units are case-insensitive, and the 'b' suffix is optional. +func RAMInBytes(size string) (int64, error) { + return parseSize(size, binaryMap) +} + +// Parses the human-readable size string into the amount it represents. +func parseSize(sizeStr string, uMap unitMap) (int64, error) { + matches := sizeRegex.FindStringSubmatch(sizeStr) + if len(matches) != 4 { + return -1, fmt.Errorf("invalid size: '%s'", sizeStr) + } + + size, err := strconv.ParseFloat(matches[1], 64) + if err != nil { + return -1, err + } + + unitPrefix := strings.ToLower(matches[3]) + if mul, ok := uMap[unitPrefix]; ok { + size *= float64(mul) + } + + return int64(size), nil +} diff --git a/vendor/github.com/docker/go-units/size_test.go b/vendor/github.com/docker/go-units/size_test.go new file mode 100644 index 00000000..003bc89a --- /dev/null +++ b/vendor/github.com/docker/go-units/size_test.go @@ -0,0 +1,163 @@ +package units + +import ( + "fmt" + "reflect" + "runtime" + "strings" + "testing" +) + +func ExampleBytesSize() { + fmt.Println(BytesSize(1024)) + fmt.Println(BytesSize(1024 * 1024)) + fmt.Println(BytesSize(1048576)) + fmt.Println(BytesSize(2 * MiB)) + fmt.Println(BytesSize(3.42 * GiB)) + fmt.Println(BytesSize(5.372 * TiB)) + fmt.Println(BytesSize(2.22 * PiB)) +} + +func ExampleHumanSize() { + fmt.Println(HumanSize(1000)) + fmt.Println(HumanSize(1024)) + fmt.Println(HumanSize(1000000)) + fmt.Println(HumanSize(1048576)) + fmt.Println(HumanSize(2 * MB)) + fmt.Println(HumanSize(float64(3.42 * GB))) + fmt.Println(HumanSize(float64(5.372 * TB))) + fmt.Println(HumanSize(float64(2.22 * PB))) +} + +func ExampleFromHumanSize() { + fmt.Println(FromHumanSize("32")) + fmt.Println(FromHumanSize("32b")) + fmt.Println(FromHumanSize("32B")) + fmt.Println(FromHumanSize("32k")) + fmt.Println(FromHumanSize("32K")) + fmt.Println(FromHumanSize("32kb")) + fmt.Println(FromHumanSize("32Kb")) + fmt.Println(FromHumanSize("32Mb")) + fmt.Println(FromHumanSize("32Gb")) + fmt.Println(FromHumanSize("32Tb")) + fmt.Println(FromHumanSize("32Pb")) +} + +func ExampleRAMInBytes() { + fmt.Println(RAMInBytes("32")) + fmt.Println(RAMInBytes("32b")) + fmt.Println(RAMInBytes("32B")) + fmt.Println(RAMInBytes("32k")) + fmt.Println(RAMInBytes("32K")) + fmt.Println(RAMInBytes("32kb")) + fmt.Println(RAMInBytes("32Kb")) + fmt.Println(RAMInBytes("32Mb")) + fmt.Println(RAMInBytes("32Gb")) + fmt.Println(RAMInBytes("32Tb")) + fmt.Println(RAMInBytes("32Pb")) + fmt.Println(RAMInBytes("32PB")) + fmt.Println(RAMInBytes("32P")) +} + +func TestBytesSize(t *testing.T) { + assertEquals(t, "1 KiB", BytesSize(1024)) + assertEquals(t, "1 MiB", BytesSize(1024*1024)) + assertEquals(t, "1 MiB", BytesSize(1048576)) + assertEquals(t, "2 MiB", BytesSize(2*MiB)) + assertEquals(t, "3.42 GiB", BytesSize(3.42*GiB)) + assertEquals(t, "5.372 TiB", BytesSize(5.372*TiB)) + assertEquals(t, "2.22 PiB", BytesSize(2.22*PiB)) +} + +func TestHumanSize(t *testing.T) { + assertEquals(t, "1 kB", HumanSize(1000)) + assertEquals(t, "1.024 kB", HumanSize(1024)) + assertEquals(t, "1 MB", HumanSize(1000000)) + assertEquals(t, "1.049 MB", HumanSize(1048576)) + assertEquals(t, "2 MB", HumanSize(2*MB)) + assertEquals(t, "3.42 GB", HumanSize(float64(3.42*GB))) + assertEquals(t, "5.372 TB", HumanSize(float64(5.372*TB))) + assertEquals(t, "2.22 PB", HumanSize(float64(2.22*PB))) +} + +func TestFromHumanSize(t *testing.T) { + assertSuccessEquals(t, 32, FromHumanSize, "32") + assertSuccessEquals(t, 32, FromHumanSize, "32b") + assertSuccessEquals(t, 32, FromHumanSize, "32B") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32k") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32K") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32kb") + assertSuccessEquals(t, 32*KB, FromHumanSize, "32Kb") + assertSuccessEquals(t, 32*MB, FromHumanSize, "32Mb") + assertSuccessEquals(t, 32*GB, FromHumanSize, "32Gb") + assertSuccessEquals(t, 32*TB, FromHumanSize, "32Tb") + assertSuccessEquals(t, 32*PB, FromHumanSize, "32Pb") + + assertSuccessEquals(t, 32.5*KB, FromHumanSize, "32.5kB") + assertSuccessEquals(t, 32.5*KB, FromHumanSize, "32.5 kB") + assertSuccessEquals(t, 32, FromHumanSize, "32.5 B") + + assertError(t, FromHumanSize, "") + assertError(t, FromHumanSize, "hello") + assertError(t, FromHumanSize, "-32") + assertError(t, FromHumanSize, ".3kB") + assertError(t, FromHumanSize, " 32 ") + assertError(t, FromHumanSize, "32m b") + assertError(t, FromHumanSize, "32bm") +} + +func TestRAMInBytes(t *testing.T) { + assertSuccessEquals(t, 32, RAMInBytes, "32") + assertSuccessEquals(t, 32, RAMInBytes, "32b") + assertSuccessEquals(t, 32, RAMInBytes, "32B") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32k") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32K") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32kb") + assertSuccessEquals(t, 32*KiB, RAMInBytes, "32Kb") + assertSuccessEquals(t, 32*MiB, RAMInBytes, "32Mb") + assertSuccessEquals(t, 32*GiB, RAMInBytes, "32Gb") + assertSuccessEquals(t, 32*TiB, RAMInBytes, "32Tb") + assertSuccessEquals(t, 32*PiB, RAMInBytes, "32Pb") + assertSuccessEquals(t, 32*PiB, RAMInBytes, "32PB") + assertSuccessEquals(t, 32*PiB, RAMInBytes, "32P") + + assertSuccessEquals(t, 32, RAMInBytes, "32.3") + tmp := 32.3 * MiB + assertSuccessEquals(t, int64(tmp), RAMInBytes, "32.3 mb") + + assertError(t, RAMInBytes, "") + assertError(t, RAMInBytes, "hello") + assertError(t, RAMInBytes, "-32") + assertError(t, RAMInBytes, " 32 ") + assertError(t, RAMInBytes, "32m b") + assertError(t, RAMInBytes, "32bm") +} + +func assertEquals(t *testing.T, expected, actual interface{}) { + if expected != actual { + t.Errorf("Expected '%v' but got '%v'", expected, actual) + } +} + +// func that maps to the parse function signatures as testing abstraction +type parseFn func(string) (int64, error) + +// Define 'String()' for pretty-print +func (fn parseFn) String() string { + fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name() + return fnName[strings.LastIndex(fnName, ".")+1:] +} + +func assertSuccessEquals(t *testing.T, expected int64, fn parseFn, arg string) { + res, err := fn(arg) + if err != nil || res != expected { + t.Errorf("%s(\"%s\") -> expected '%d' but got '%d' with error '%v'", fn, arg, expected, res, err) + } +} + +func assertError(t *testing.T, fn parseFn, arg string) { + res, err := fn(arg) + if err == nil && res != -1 { + t.Errorf("%s(\"%s\") -> expected error but got '%d'", fn, arg, res) + } +} diff --git a/vendor/github.com/docker/go-units/ulimit.go b/vendor/github.com/docker/go-units/ulimit.go new file mode 100644 index 00000000..5ac7fd82 --- /dev/null +++ b/vendor/github.com/docker/go-units/ulimit.go @@ -0,0 +1,118 @@ +package units + +import ( + "fmt" + "strconv" + "strings" +) + +// Ulimit is a human friendly version of Rlimit. +type Ulimit struct { + Name string + Hard int64 + Soft int64 +} + +// Rlimit specifies the resource limits, such as max open files. +type Rlimit struct { + Type int `json:"type,omitempty"` + Hard uint64 `json:"hard,omitempty"` + Soft uint64 `json:"soft,omitempty"` +} + +const ( + // magic numbers for making the syscall + // some of these are defined in the syscall package, but not all. + // Also since Windows client doesn't get access to the syscall package, need to + // define these here + rlimitAs = 9 + rlimitCore = 4 + rlimitCPU = 0 + rlimitData = 2 + rlimitFsize = 1 + rlimitLocks = 10 + rlimitMemlock = 8 + rlimitMsgqueue = 12 + rlimitNice = 13 + rlimitNofile = 7 + rlimitNproc = 6 + rlimitRss = 5 + rlimitRtprio = 14 + rlimitRttime = 15 + rlimitSigpending = 11 + rlimitStack = 3 +) + +var ulimitNameMapping = map[string]int{ + //"as": rlimitAs, // Disabled since this doesn't seem usable with the way Docker inits a container. + "core": rlimitCore, + "cpu": rlimitCPU, + "data": rlimitData, + "fsize": rlimitFsize, + "locks": rlimitLocks, + "memlock": rlimitMemlock, + "msgqueue": rlimitMsgqueue, + "nice": rlimitNice, + "nofile": rlimitNofile, + "nproc": rlimitNproc, + "rss": rlimitRss, + "rtprio": rlimitRtprio, + "rttime": rlimitRttime, + "sigpending": rlimitSigpending, + "stack": rlimitStack, +} + +// ParseUlimit parses and returns a Ulimit from the specified string. +func ParseUlimit(val string) (*Ulimit, error) { + parts := strings.SplitN(val, "=", 2) + if len(parts) != 2 { + return nil, fmt.Errorf("invalid ulimit argument: %s", val) + } + + if _, exists := ulimitNameMapping[parts[0]]; !exists { + return nil, fmt.Errorf("invalid ulimit type: %s", parts[0]) + } + + var ( + soft int64 + hard = &soft // default to soft in case no hard was set + temp int64 + err error + ) + switch limitVals := strings.Split(parts[1], ":"); len(limitVals) { + case 2: + temp, err = strconv.ParseInt(limitVals[1], 10, 64) + if err != nil { + return nil, err + } + hard = &temp + fallthrough + case 1: + soft, err = strconv.ParseInt(limitVals[0], 10, 64) + if err != nil { + return nil, err + } + default: + return nil, fmt.Errorf("too many limit value arguments - %s, can only have up to two, `soft[:hard]`", parts[1]) + } + + if soft > *hard { + return nil, fmt.Errorf("ulimit soft limit must be less than or equal to hard limit: %d > %d", soft, *hard) + } + + return &Ulimit{Name: parts[0], Soft: soft, Hard: *hard}, nil +} + +// GetRlimit returns the RLimit corresponding to Ulimit. +func (u *Ulimit) GetRlimit() (*Rlimit, error) { + t, exists := ulimitNameMapping[u.Name] + if !exists { + return nil, fmt.Errorf("invalid ulimit name %s", u.Name) + } + + return &Rlimit{Type: t, Soft: uint64(u.Soft), Hard: uint64(u.Hard)}, nil +} + +func (u *Ulimit) String() string { + return fmt.Sprintf("%s=%d:%d", u.Name, u.Soft, u.Hard) +} diff --git a/vendor/github.com/docker/go-units/ulimit_test.go b/vendor/github.com/docker/go-units/ulimit_test.go new file mode 100644 index 00000000..3e7f10fc --- /dev/null +++ b/vendor/github.com/docker/go-units/ulimit_test.go @@ -0,0 +1,74 @@ +package units + +import ( + "fmt" + "strconv" + "testing" +) + +func ExampleParseUlimit() { + fmt.Println(ParseUlimit("nofile=512:1024")) + fmt.Println(ParseUlimit("nofile=1024")) + fmt.Println(ParseUlimit("cpu=2:4")) + fmt.Println(ParseUlimit("cpu=6")) +} + +func TestParseUlimitValid(t *testing.T) { + u1 := &Ulimit{"nofile", 1024, 512} + if u2, _ := ParseUlimit("nofile=512:1024"); *u1 != *u2 { + t.Fatalf("expected %q, but got %q", u1, u2) + } +} + +func TestParseUlimitInvalidLimitType(t *testing.T) { + if _, err := ParseUlimit("notarealtype=1024:1024"); err == nil { + t.Fatalf("expected error on invalid ulimit type") + } +} + +func TestParseUlimitBadFormat(t *testing.T) { + if _, err := ParseUlimit("nofile:1024:1024"); err == nil { + t.Fatal("expected error on bad syntax") + } + + if _, err := ParseUlimit("nofile"); err == nil { + t.Fatal("expected error on bad syntax") + } + + if _, err := ParseUlimit("nofile="); err == nil { + t.Fatal("expected error on bad syntax") + } + if _, err := ParseUlimit("nofile=:"); err == nil { + t.Fatal("expected error on bad syntax") + } + if _, err := ParseUlimit("nofile=:1024"); err == nil { + t.Fatal("expected error on bad syntax") + } +} + +func TestParseUlimitHardLessThanSoft(t *testing.T) { + if _, err := ParseUlimit("nofile=1024:1"); err == nil { + t.Fatal("expected error on hard limit less than soft limit") + } +} + +func TestParseUlimitInvalidValueType(t *testing.T) { + if _, err := ParseUlimit("nofile=asdf"); err == nil { + t.Fatal("expected error on bad value type, but got no error") + } else if _, ok := err.(*strconv.NumError); !ok { + t.Fatalf("expected error on bad value type, but got `%s`", err) + } + + if _, err := ParseUlimit("nofile=1024:asdf"); err == nil { + t.Fatal("expected error on bad value type, but got no error") + } else if _, ok := err.(*strconv.NumError); !ok { + t.Fatalf("expected error on bad value type, but got `%s`", err) + } +} + +func TestUlimitStringOutput(t *testing.T) { + u := &Ulimit{"nofile", 1024, 512} + if s := u.String(); s != "nofile=512:1024" { + t.Fatal("expected String to return nofile=512:1024, but got", s) + } +} diff --git a/vendor/github.com/frostschutz/go-fibmap/.gitignore b/vendor/github.com/frostschutz/go-fibmap/.gitignore new file mode 100644 index 00000000..83656241 --- /dev/null +++ b/vendor/github.com/frostschutz/go-fibmap/.gitignore @@ -0,0 +1,23 @@ +# 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 diff --git a/vendor/github.com/frostschutz/go-fibmap/LICENSE b/vendor/github.com/frostschutz/go-fibmap/LICENSE new file mode 100644 index 00000000..305a2b29 --- /dev/null +++ b/vendor/github.com/frostschutz/go-fibmap/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Andreas Klauer + +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/frostschutz/go-fibmap/README.md b/vendor/github.com/frostschutz/go-fibmap/README.md new file mode 100644 index 00000000..524e069c --- /dev/null +++ b/vendor/github.com/frostschutz/go-fibmap/README.md @@ -0,0 +1,4 @@ +fibmap +====== + +Golang Linux ioctl FIBMAP, FIEMAP, SEEK_DATA/HOLE, PUNCH_HOLE, ... diff --git a/vendor/github.com/frostschutz/go-fibmap/fibmap.go b/vendor/github.com/frostschutz/go-fibmap/fibmap.go new file mode 100644 index 00000000..3a8250f7 --- /dev/null +++ b/vendor/github.com/frostschutz/go-fibmap/fibmap.go @@ -0,0 +1,222 @@ +// Copyright (C) 2014 Andreas Klauer +// License: MIT + +// Package fibmap implements FIBMAP/FIEMAP and related Linux ioctl +// for dealing with low level file allocation. +package fibmap + +import ( + "os" + "syscall" + "unsafe" +) + +const ( + FiemapExtentSize = 56 // sizeof(struct fiemap_extent) + FiemapSize = 32 // sizeof(struct fiemap) + + // Defined in : + SEEK_SET = 0 // seek relative to beginning of file + SEEK_CUR = 1 // seek relative to current file position + SEEK_END = 2 // seek relative to end of file + SEEK_DATA = 3 // seek to the next data + SEEK_HOLE = 4 // seek to the next hole + SEEK_MAX = SEEK_HOLE + FIBMAP = 1 // bmap access + FIGETBSZ = 2 // get the block size used for bmap + FS_IOC_FIEMAP = 3223348747 + + // Defined in : + FIEMAP_MAX_OFFSET = ^uint64(0) + FIEMAP_FLAG_SYNC = 0x0001 // sync file data before map + FIEMAP_FLAG_XATTR = 0x0002 // map extended attribute tree + FIEMAP_FLAG_CACHE = 0x0004 // request caching of the extents + FIEMAP_FLAGS_COMPAT = (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) + FIEMAP_EXTENT_LAST = 0x0001 // Last extent in file. + FIEMAP_EXTENT_UNKNOWN = 0x0002 // Data location unknown. + FIEMAP_EXTENT_DELALLOC = 0x0004 // Location still pending. Sets EXTENT_UNKNOWN. + FIEMAP_EXTENT_ENCODED = 0x0008 // Data can not be read while fs is unmounted + FIEMAP_EXTENT_DATA_ENCRYPTED = 0x0080 // Data is encrypted by fs. Sets EXTENT_NO_BYPASS. + FIEMAP_EXTENT_NOT_ALIGNED = 0x0100 // Extent offsets may not be block aligned. + FIEMAP_EXTENT_DATA_INLINE = 0x0200 // Data mixed with metadata. Sets EXTENT_NOT_ALIGNED. + FIEMAP_EXTENT_DATA_TAIL = 0x0400 // Multiple files in block. Sets EXTENT_NOT_ALIGNED. + FIEMAP_EXTENT_UNWRITTEN = 0x0800 // Space allocated, but no data (i.e. zero). + FIEMAP_EXTENT_MERGED = 0x1000 // File does not natively support extents. Result merged for efficiency. + FIEMAP_EXTENT_SHARED = 0x2000 // Space shared with other files. + + // Defined in : + FALLOC_FL_KEEP_SIZE = 0x01 // default is extend size + FALLOC_FL_PUNCH_HOLE = 0x02 // de-allocates range + FALLOC_FL_NO_HIDE_STAE = 0x04 // reserved codepoint +) + +// based on struct fiemap from +type fiemap struct { + Start uint64 // logical offset (inclusive) at which to start mapping (in) + Length uint64 // logical length of mapping which userspace wants (in) + Flags uint32 // FIEMAP_FLAG_* flags for request (in/out) + Mapped_extents uint32 // number of extents that were mapped (out) + Extent_count uint32 // size of fm_extents array (in) + Reserved uint32 + // Extents [0]Extent // array of mapped extents (out) +} + +// based on struct fiemap_extent from +type Extent struct { + Logical uint64 // logical offset in bytes for the start of the extent from the beginning of the file + Physical uint64 // physical offset in bytes for the start of the extent from the beginning of the disk + Length uint64 // length in bytes for this extent + Reserved64 [2]uint64 + Flags uint32 // FIEMAP_EXTENT_* flags for this extent + Reserved [3]uint32 +} + +type FibmapFile struct { + *os.File +} + +// return a new FibmapFile +func NewFibmapFile(f *os.File) FibmapFile { + return FibmapFile{f} +} + +// call FIBMAP ioctl +func (f FibmapFile) Fibmap(block uint) (uint, syscall.Errno) { + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIBMAP, uintptr(unsafe.Pointer(&block))) + return block, err +} + +// emulate FIEMAP with FIBMAP +func (f FibmapFile) FibmapExtents() ([]Extent, syscall.Errno) { + result := make([]Extent, 0) + + bsz, err := f.Figetbsz() + if err != 0 { + return nil, err + } + + stat, _ := f.Stat() + size := stat.Size() + if size == 0 { + return result, syscall.Errno(0) + } + + blocks := uint((size-1)/int64(bsz)) + 1 + var block, physical, length uint + var e Extent + + for i := uint(0); i < blocks; i++ { + block = i + _, _, err = syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIBMAP, uintptr(unsafe.Pointer(&block))) + if block == 0 && physical == 0 { + // hole + continue + } + + if block == 0 { + // hole after extent + e.Length = uint64(length) * uint64(bsz) + result = append(result, e) + length = 0 + physical = 0 + continue + } + + if block == physical { + // segment + length++ + physical++ + continue + } + + // new extent + e = Extent{} + e.Logical = uint64(i) * uint64(bsz) + e.Physical = uint64(block) * uint64(bsz) + + length = 1 + physical = block + 1 + } + + if length > 0 { + // final extent + e.Length = uint64(length) * uint64(bsz) + result = append(result, e) + } + + return result, err +} + +// call FIEMAP ioctl +func (f FibmapFile) Fiemap(size uint32) ([]Extent, syscall.Errno) { + extents := make([]Extent, size+1) + ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&extents[1])) - FiemapSize) + + t := (*fiemap)(ptr) + t.Start = 0 + t.Length = FIEMAP_MAX_OFFSET + t.Flags = FIEMAP_FLAG_SYNC + t.Extent_count = size + + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FS_IOC_FIEMAP, uintptr(ptr)) + + return extents[1 : 1+t.Mapped_extents], err +} + +func Fiemap(fd uintptr, start, length uint64, size uint32) ([]Extent, syscall.Errno) { + extents := make([]Extent, size+1) + ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&extents[1])) - FiemapSize) + + t := (*fiemap)(ptr) + t.Start = start + t.Length = length + t.Flags = FIEMAP_FLAG_SYNC + t.Extent_count = size + + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, FS_IOC_FIEMAP, uintptr(ptr)) + + return extents[1 : 1+t.Mapped_extents], err +} + +// call FIGETBSZ ioctl +func (f FibmapFile) Figetbsz() (int, syscall.Errno) { + bsz := int(0) + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIGETBSZ, uintptr(unsafe.Pointer(&bsz))) + return bsz, err +} + +// use SEEK_DATA, SEEK_HOLE to find allocated data ranges in a file +func (f FibmapFile) SeekDataHole() []int64 { + old, _ := f.Seek(0, os.SEEK_CUR) + + var data, hole int64 + var datahole []int64 + + for { + data, _ = f.Seek(hole, SEEK_DATA) + + if data >= hole { + hole, _ = f.Seek(data, SEEK_HOLE) + + if hole > data { + datahole = append(datahole, data, hole-data) + continue + } + } + break + } + + f.Seek(old, os.SEEK_SET) + + return datahole +} + +// allocate using fallocate +func (f FibmapFile) Fallocate(offset int64, length int64) error { + return syscall.Fallocate(int(f.Fd()), 0, offset, length) +} + +// punch hole using fallocate +func (f FibmapFile) PunchHole(offset int64, length int64) error { + return syscall.Fallocate(int(f.Fd()), FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE, offset, length) +} diff --git a/vendor/github.com/gorilla/context/.travis.yml b/vendor/github.com/gorilla/context/.travis.yml new file mode 100644 index 00000000..faca4dad --- /dev/null +++ b/vendor/github.com/gorilla/context/.travis.yml @@ -0,0 +1,19 @@ +language: go +sudo: false + +matrix: + include: + - go: 1.3 + - go: 1.4 + - go: 1.5 + - go: 1.6 + - go: tip + +install: + - go get golang.org/x/tools/cmd/vet + +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d .) + - go tool vet . + - go test -v -race ./... diff --git a/vendor/github.com/gorilla/context/LICENSE b/vendor/github.com/gorilla/context/LICENSE new file mode 100644 index 00000000..0e5fb872 --- /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/README.md b/vendor/github.com/gorilla/context/README.md new file mode 100644 index 00000000..c60a31b0 --- /dev/null +++ b/vendor/github.com/gorilla/context/README.md @@ -0,0 +1,7 @@ +context +======= +[![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) + +gorilla/context is a general purpose registry for global request variables. + +Read the full documentation here: http://www.gorillatoolkit.org/pkg/context diff --git a/vendor/github.com/gorilla/context/context.go b/vendor/github.com/gorilla/context/context.go new file mode 100644 index 00000000..81cb128b --- /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/context_test.go b/vendor/github.com/gorilla/context/context_test.go new file mode 100644 index 00000000..9814c501 --- /dev/null +++ b/vendor/github.com/gorilla/context/context_test.go @@ -0,0 +1,161 @@ +// 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" + "testing" +) + +type keyType int + +const ( + key1 keyType = iota + key2 +) + +func TestContext(t *testing.T) { + assertEqual := func(val interface{}, exp interface{}) { + if val != exp { + t.Errorf("Expected %v, got %v.", exp, val) + } + } + + r, _ := http.NewRequest("GET", "http://localhost:8080/", nil) + emptyR, _ := http.NewRequest("GET", "http://localhost:8080/", nil) + + // Get() + assertEqual(Get(r, key1), nil) + + // Set() + Set(r, key1, "1") + assertEqual(Get(r, key1), "1") + assertEqual(len(data[r]), 1) + + Set(r, key2, "2") + assertEqual(Get(r, key2), "2") + assertEqual(len(data[r]), 2) + + //GetOk + value, ok := GetOk(r, key1) + assertEqual(value, "1") + assertEqual(ok, true) + + value, ok = GetOk(r, "not exists") + assertEqual(value, nil) + assertEqual(ok, false) + + Set(r, "nil value", nil) + value, ok = GetOk(r, "nil value") + assertEqual(value, nil) + assertEqual(ok, true) + + // GetAll() + values := GetAll(r) + assertEqual(len(values), 3) + + // GetAll() for empty request + values = GetAll(emptyR) + if values != nil { + t.Error("GetAll didn't return nil value for invalid request") + } + + // GetAllOk() + values, ok = GetAllOk(r) + assertEqual(len(values), 3) + assertEqual(ok, true) + + // GetAllOk() for empty request + values, ok = GetAllOk(emptyR) + assertEqual(value, nil) + assertEqual(ok, false) + + // Delete() + Delete(r, key1) + assertEqual(Get(r, key1), nil) + assertEqual(len(data[r]), 2) + + Delete(r, key2) + assertEqual(Get(r, key2), nil) + assertEqual(len(data[r]), 1) + + // Clear() + Clear(r) + assertEqual(len(data), 0) +} + +func parallelReader(r *http.Request, key string, iterations int, wait, done chan struct{}) { + <-wait + for i := 0; i < iterations; i++ { + Get(r, key) + } + done <- struct{}{} + +} + +func parallelWriter(r *http.Request, key, value string, iterations int, wait, done chan struct{}) { + <-wait + for i := 0; i < iterations; i++ { + Set(r, key, value) + } + done <- struct{}{} + +} + +func benchmarkMutex(b *testing.B, numReaders, numWriters, iterations int) { + + b.StopTimer() + r, _ := http.NewRequest("GET", "http://localhost:8080/", nil) + done := make(chan struct{}) + b.StartTimer() + + for i := 0; i < b.N; i++ { + wait := make(chan struct{}) + + for i := 0; i < numReaders; i++ { + go parallelReader(r, "test", iterations, wait, done) + } + + for i := 0; i < numWriters; i++ { + go parallelWriter(r, "test", "123", iterations, wait, done) + } + + close(wait) + + for i := 0; i < numReaders+numWriters; i++ { + <-done + } + + } + +} + +func BenchmarkMutexSameReadWrite1(b *testing.B) { + benchmarkMutex(b, 1, 1, 32) +} +func BenchmarkMutexSameReadWrite2(b *testing.B) { + benchmarkMutex(b, 2, 2, 32) +} +func BenchmarkMutexSameReadWrite4(b *testing.B) { + benchmarkMutex(b, 4, 4, 32) +} +func BenchmarkMutex1(b *testing.B) { + benchmarkMutex(b, 2, 8, 32) +} +func BenchmarkMutex2(b *testing.B) { + benchmarkMutex(b, 16, 4, 64) +} +func BenchmarkMutex3(b *testing.B) { + benchmarkMutex(b, 1, 2, 128) +} +func BenchmarkMutex4(b *testing.B) { + benchmarkMutex(b, 128, 32, 256) +} +func BenchmarkMutex5(b *testing.B) { + benchmarkMutex(b, 1024, 2048, 64) +} +func BenchmarkMutex6(b *testing.B) { + benchmarkMutex(b, 2048, 1024, 512) +} diff --git a/vendor/github.com/gorilla/context/doc.go b/vendor/github.com/gorilla/context/doc.go new file mode 100644 index 00000000..73c74003 --- /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/handlers/.travis.yml b/vendor/github.com/gorilla/handlers/.travis.yml new file mode 100644 index 00000000..ad1d76ac --- /dev/null +++ b/vendor/github.com/gorilla/handlers/.travis.yml @@ -0,0 +1,17 @@ +language: go +sudo: false + +matrix: + include: + - go: 1.4 + - go: 1.5 + - go: 1.6 + +install: + - go get golang.org/x/tools/cmd/vet + +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d .) + - go tool vet . + - go test -v -race ./... diff --git a/vendor/github.com/gorilla/handlers/LICENSE b/vendor/github.com/gorilla/handlers/LICENSE new file mode 100644 index 00000000..66ea3c8a --- /dev/null +++ b/vendor/github.com/gorilla/handlers/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013 The Gorilla Handlers 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. + +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/gorilla/handlers/README.md b/vendor/github.com/gorilla/handlers/README.md new file mode 100644 index 00000000..a782c415 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/README.md @@ -0,0 +1,53 @@ +gorilla/handlers +================ +[![GoDoc](https://godoc.org/github.com/gorilla/handlers?status.svg)](https://godoc.org/github.com/gorilla/handlers) [![Build Status](https://travis-ci.org/gorilla/handlers.svg?branch=master)](https://travis-ci.org/gorilla/handlers) + +Package handlers is a collection of handlers (aka "HTTP middleware") for use +with Go's `net/http` package (or any framework supporting `http.Handler`), including: + +* [**LoggingHandler**](https://godoc.org/github.com/gorilla/handlers#LoggingHandler) for logging HTTP requests in the Apache [Common Log + Format](http://httpd.apache.org/docs/2.2/logs.html#common). +* [**CombinedLoggingHandler**](https://godoc.org/github.com/gorilla/handlers#CombinedLoggingHandler) for logging HTTP requests in the Apache [Combined Log + Format](http://httpd.apache.org/docs/2.2/logs.html#combined) commonly used by + both Apache and nginx. +* [**CompressHandler**](https://godoc.org/github.com/gorilla/handlers#CompressHandler) for gzipping responses. +* [**ContentTypeHandler**](https://godoc.org/github.com/gorilla/handlers#ContentTypeHandler) for validating requests against a list of accepted + content types. +* [**MethodHandler**](https://godoc.org/github.com/gorilla/handlers#MethodHandler) for matching HTTP methods against handlers in a + `map[string]http.Handler` +* [**ProxyHeaders**](https://godoc.org/github.com/gorilla/handlers#ProxyHeaders) for populating `r.RemoteAddr` and `r.URL.Scheme` based on the + `X-Forwarded-For`, `X-Real-IP`, `X-Forwarded-Proto` and RFC7239 `Forwarded` + headers when running a Go server behind a HTTP reverse proxy. +* [**CanonicalHost**](https://godoc.org/github.com/gorilla/handlers#CanonicalHost) for re-directing to the preferred host when handling multiple + domains (i.e. multiple CNAME aliases). +* [**RecoveryHandler**](https://godoc.org/github.com/gorilla/handlers#RecoveryHandler) for recovering from unexpected panics. + +Other handlers are documented [on the Gorilla +website](http://www.gorillatoolkit.org/pkg/handlers). + +## Example + +A simple example using `handlers.LoggingHandler` and `handlers.CompressHandler`: + +```go +import ( + "net/http" + "github.com/gorilla/handlers" +) + +func main() { + r := http.NewServeMux() + + // Only log requests to our admin dashboard to stdout + r.Handle("/admin", handlers.LoggingHandler(os.Stdout, http.HandlerFunc(ShowAdminDashboard))) + r.HandleFunc("/", ShowIndex) + + // Wrap our server with our gzip handler to gzip compress all responses. + http.ListenAndServe(":8000", handlers.CompressHandler(r)) +} +``` + +## License + +BSD licensed. See the included LICENSE file for details. + diff --git a/vendor/github.com/gorilla/handlers/canonical.go b/vendor/github.com/gorilla/handlers/canonical.go new file mode 100644 index 00000000..8437fefc --- /dev/null +++ b/vendor/github.com/gorilla/handlers/canonical.go @@ -0,0 +1,74 @@ +package handlers + +import ( + "net/http" + "net/url" + "strings" +) + +type canonical struct { + h http.Handler + domain string + code int +} + +// CanonicalHost is HTTP middleware that re-directs requests to the canonical +// domain. It accepts a domain and a status code (e.g. 301 or 302) and +// re-directs clients to this domain. The existing request path is maintained. +// +// Note: If the provided domain is considered invalid by url.Parse or otherwise +// returns an empty scheme or host, clients are not re-directed. +// +// Example: +// +// r := mux.NewRouter() +// canonical := handlers.CanonicalHost("http://www.gorillatoolkit.org", 302) +// r.HandleFunc("/route", YourHandler) +// +// log.Fatal(http.ListenAndServe(":7000", canonical(r))) +// +func CanonicalHost(domain string, code int) func(h http.Handler) http.Handler { + fn := func(h http.Handler) http.Handler { + return canonical{h, domain, code} + } + + return fn +} + +func (c canonical) ServeHTTP(w http.ResponseWriter, r *http.Request) { + dest, err := url.Parse(c.domain) + if err != nil { + // Call the next handler if the provided domain fails to parse. + c.h.ServeHTTP(w, r) + return + } + + if dest.Scheme == "" || dest.Host == "" { + // Call the next handler if the scheme or host are empty. + // Note that url.Parse won't fail on in this case. + c.h.ServeHTTP(w, r) + return + } + + if !strings.EqualFold(cleanHost(r.Host), dest.Host) { + // Re-build the destination URL + dest := dest.Scheme + "://" + dest.Host + r.URL.Path + if r.URL.RawQuery != "" { + dest += "?" + r.URL.RawQuery + } + http.Redirect(w, r, dest, c.code) + return + } + + c.h.ServeHTTP(w, r) +} + +// cleanHost cleans invalid Host headers by stripping anything after '/' or ' '. +// This is backported from Go 1.5 (in response to issue #11206) and attempts to +// mitigate malformed Host headers that do not match the format in RFC7230. +func cleanHost(in string) string { + if i := strings.IndexAny(in, " /"); i != -1 { + return in[:i] + } + return in +} diff --git a/vendor/github.com/gorilla/handlers/canonical_test.go b/vendor/github.com/gorilla/handlers/canonical_test.go new file mode 100644 index 00000000..615e4b05 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/canonical_test.go @@ -0,0 +1,127 @@ +package handlers + +import ( + "bufio" + "bytes" + "log" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" +) + +func TestCleanHost(t *testing.T) { + tests := []struct { + in, want string + }{ + {"www.google.com", "www.google.com"}, + {"www.google.com foo", "www.google.com"}, + {"www.google.com/foo", "www.google.com"}, + {" first character is a space", ""}, + } + for _, tt := range tests { + got := cleanHost(tt.in) + if tt.want != got { + t.Errorf("cleanHost(%q) = %q, want %q", tt.in, got, tt.want) + } + } +} + +func TestCanonicalHost(t *testing.T) { + gorilla := "http://www.gorillatoolkit.org" + + rr := httptest.NewRecorder() + r := newRequest("GET", "http://www.example.com/") + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + // Test a re-direct: should return a 302 Found. + CanonicalHost(gorilla, http.StatusFound)(testHandler).ServeHTTP(rr, r) + + if rr.Code != http.StatusFound { + t.Fatalf("bad status: got %v want %v", rr.Code, http.StatusFound) + } + + if rr.Header().Get("Location") != gorilla+r.URL.Path { + t.Fatalf("bad re-direct: got %q want %q", rr.Header().Get("Location"), gorilla+r.URL.Path) + } + +} + +func TestKeepsQueryString(t *testing.T) { + google := "https://www.google.com" + + rr := httptest.NewRecorder() + querystring := url.Values{"q": {"golang"}, "format": {"json"}}.Encode() + r := newRequest("GET", "http://www.example.com/search?"+querystring) + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + CanonicalHost(google, http.StatusFound)(testHandler).ServeHTTP(rr, r) + + want := google + r.URL.Path + "?" + querystring + if rr.Header().Get("Location") != want { + t.Fatalf("bad re-direct: got %q want %q", rr.Header().Get("Location"), want) + } +} + +func TestBadDomain(t *testing.T) { + rr := httptest.NewRecorder() + r := newRequest("GET", "http://www.example.com/") + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + // Test a bad domain - should return 200 OK. + CanonicalHost("%", http.StatusFound)(testHandler).ServeHTTP(rr, r) + + if rr.Code != http.StatusOK { + t.Fatalf("bad status: got %v want %v", rr.Code, http.StatusOK) + } +} + +func TestEmptyHost(t *testing.T) { + rr := httptest.NewRecorder() + r := newRequest("GET", "http://www.example.com/") + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + // Test a domain that returns an empty url.Host from url.Parse. + CanonicalHost("hello.com", http.StatusFound)(testHandler).ServeHTTP(rr, r) + + if rr.Code != http.StatusOK { + t.Fatalf("bad status: got %v want %v", rr.Code, http.StatusOK) + } +} + +func TestHeaderWrites(t *testing.T) { + gorilla := "http://www.gorillatoolkit.org" + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + }) + + // Catch the log output to ensure we don't write multiple headers. + var b bytes.Buffer + buf := bufio.NewWriter(&b) + tl := log.New(buf, "test: ", log.Lshortfile) + + srv := httptest.NewServer( + CanonicalHost(gorilla, http.StatusFound)(testHandler)) + defer srv.Close() + srv.Config.ErrorLog = tl + + _, err := http.Get(srv.URL) + if err != nil { + t.Fatal(err) + } + + err = buf.Flush() + if err != nil { + t.Fatal(err) + } + + // We rely on the error not changing: net/http does not export it. + if strings.Contains(b.String(), "multiple response.WriteHeader calls") { + t.Fatalf("re-direct did not return early: multiple header writes") + } +} diff --git a/vendor/github.com/gorilla/handlers/compress.go b/vendor/github.com/gorilla/handlers/compress.go new file mode 100644 index 00000000..5e140c50 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/compress.go @@ -0,0 +1,145 @@ +// Copyright 2013 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 handlers + +import ( + "compress/flate" + "compress/gzip" + "io" + "net/http" + "strings" +) + +type compressResponseWriter struct { + io.Writer + http.ResponseWriter + http.Hijacker + http.Flusher + http.CloseNotifier +} + +func (w *compressResponseWriter) WriteHeader(c int) { + w.ResponseWriter.Header().Del("Content-Length") + w.ResponseWriter.WriteHeader(c) +} + +func (w *compressResponseWriter) Header() http.Header { + return w.ResponseWriter.Header() +} + +func (w *compressResponseWriter) Write(b []byte) (int, error) { + h := w.ResponseWriter.Header() + if h.Get("Content-Type") == "" { + h.Set("Content-Type", http.DetectContentType(b)) + } + h.Del("Content-Length") + + return w.Writer.Write(b) +} + +type flusher interface { + Flush() error +} + +func (w *compressResponseWriter) Flush() { + // Flush compressed data if compressor supports it. + if f, ok := w.Writer.(flusher); ok { + f.Flush() + } + // Flush HTTP response. + if w.Flusher != nil { + w.Flusher.Flush() + } +} + +// CompressHandler gzip compresses HTTP responses for clients that support it +// via the 'Accept-Encoding' header. +func CompressHandler(h http.Handler) http.Handler { + return CompressHandlerLevel(h, gzip.DefaultCompression) +} + +// CompressHandlerLevel gzip compresses HTTP responses with specified compression level +// for clients that support it via the 'Accept-Encoding' header. +// +// The compression level should be gzip.DefaultCompression, gzip.NoCompression, +// or any integer value between gzip.BestSpeed and gzip.BestCompression inclusive. +// gzip.DefaultCompression is used in case of invalid compression level. +func CompressHandlerLevel(h http.Handler, level int) http.Handler { + if level < gzip.DefaultCompression || level > gzip.BestCompression { + level = gzip.DefaultCompression + } + + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + L: + for _, enc := range strings.Split(r.Header.Get("Accept-Encoding"), ",") { + switch strings.TrimSpace(enc) { + case "gzip": + w.Header().Set("Content-Encoding", "gzip") + w.Header().Add("Vary", "Accept-Encoding") + + gw, _ := gzip.NewWriterLevel(w, level) + defer gw.Close() + + h, hok := w.(http.Hijacker) + if !hok { /* w is not Hijacker... oh well... */ + h = nil + } + + f, fok := w.(http.Flusher) + if !fok { + f = nil + } + + cn, cnok := w.(http.CloseNotifier) + if !cnok { + cn = nil + } + + w = &compressResponseWriter{ + Writer: gw, + ResponseWriter: w, + Hijacker: h, + Flusher: f, + CloseNotifier: cn, + } + + break L + case "deflate": + w.Header().Set("Content-Encoding", "deflate") + w.Header().Add("Vary", "Accept-Encoding") + + fw, _ := flate.NewWriter(w, level) + defer fw.Close() + + h, hok := w.(http.Hijacker) + if !hok { /* w is not Hijacker... oh well... */ + h = nil + } + + f, fok := w.(http.Flusher) + if !fok { + f = nil + } + + cn, cnok := w.(http.CloseNotifier) + if !cnok { + cn = nil + } + + w = &compressResponseWriter{ + Writer: fw, + ResponseWriter: w, + Hijacker: h, + Flusher: f, + CloseNotifier: cn, + } + + break L + } + } + + h.ServeHTTP(w, r) + }) +} diff --git a/vendor/github.com/gorilla/handlers/compress_test.go b/vendor/github.com/gorilla/handlers/compress_test.go new file mode 100644 index 00000000..6f07f440 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/compress_test.go @@ -0,0 +1,154 @@ +// Copyright 2013 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 handlers + +import ( + "bufio" + "io" + "net" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +var contentType = "text/plain; charset=utf-8" + +func compressedRequest(w *httptest.ResponseRecorder, compression string) { + CompressHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Length", strconv.Itoa(9*1024)) + w.Header().Set("Content-Type", contentType) + for i := 0; i < 1024; i++ { + io.WriteString(w, "Gorilla!\n") + } + })).ServeHTTP(w, &http.Request{ + Method: "GET", + Header: http.Header{ + "Accept-Encoding": []string{compression}, + }, + }) + +} + +func TestCompressHandlerNoCompression(t *testing.T) { + w := httptest.NewRecorder() + compressedRequest(w, "") + if enc := w.HeaderMap.Get("Content-Encoding"); enc != "" { + t.Errorf("wrong content encoding, got %q want %q", enc, "") + } + if ct := w.HeaderMap.Get("Content-Type"); ct != contentType { + t.Errorf("wrong content type, got %q want %q", ct, contentType) + } + if w.Body.Len() != 1024*9 { + t.Errorf("wrong len, got %d want %d", w.Body.Len(), 1024*9) + } + if l := w.HeaderMap.Get("Content-Length"); l != "9216" { + t.Errorf("wrong content-length. got %q expected %d", l, 1024*9) + } +} + +func TestCompressHandlerGzip(t *testing.T) { + w := httptest.NewRecorder() + compressedRequest(w, "gzip") + if w.HeaderMap.Get("Content-Encoding") != "gzip" { + t.Errorf("wrong content encoding, got %q want %q", w.HeaderMap.Get("Content-Encoding"), "gzip") + } + if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" { + t.Errorf("wrong content type, got %s want %s", w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8") + } + if w.Body.Len() != 72 { + t.Errorf("wrong len, got %d want %d", w.Body.Len(), 72) + } + if l := w.HeaderMap.Get("Content-Length"); l != "" { + t.Errorf("wrong content-length. got %q expected %q", l, "") + } +} + +func TestCompressHandlerDeflate(t *testing.T) { + w := httptest.NewRecorder() + compressedRequest(w, "deflate") + if w.HeaderMap.Get("Content-Encoding") != "deflate" { + t.Fatalf("wrong content encoding, got %q want %q", w.HeaderMap.Get("Content-Encoding"), "deflate") + } + if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" { + t.Fatalf("wrong content type, got %s want %s", w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8") + } + if w.Body.Len() != 54 { + t.Fatalf("wrong len, got %d want %d", w.Body.Len(), 54) + } +} + +func TestCompressHandlerGzipDeflate(t *testing.T) { + w := httptest.NewRecorder() + compressedRequest(w, "gzip, deflate ") + if w.HeaderMap.Get("Content-Encoding") != "gzip" { + t.Fatalf("wrong content encoding, got %q want %q", w.HeaderMap.Get("Content-Encoding"), "gzip") + } + if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" { + t.Fatalf("wrong content type, got %s want %s", w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8") + } +} + +type fullyFeaturedResponseWriter struct{} + +// Header/Write/WriteHeader implement the http.ResponseWriter interface. +func (fullyFeaturedResponseWriter) Header() http.Header { + return http.Header{} +} +func (fullyFeaturedResponseWriter) Write([]byte) (int, error) { + return 0, nil +} +func (fullyFeaturedResponseWriter) WriteHeader(int) {} + +// Flush implements the http.Flusher interface. +func (fullyFeaturedResponseWriter) Flush() {} + +// Hijack implements the http.Hijacker interface. +func (fullyFeaturedResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { + return nil, nil, nil +} + +// CloseNotify implements the http.CloseNotifier interface. +func (fullyFeaturedResponseWriter) CloseNotify() <-chan bool { + return nil +} + +func TestCompressHandlerPreserveInterfaces(t *testing.T) { + // Compile time validation fullyFeaturedResponseWriter implements all the + // interfaces we're asserting in the test case below. + var ( + _ http.Flusher = fullyFeaturedResponseWriter{} + _ http.CloseNotifier = fullyFeaturedResponseWriter{} + _ http.Hijacker = fullyFeaturedResponseWriter{} + ) + var h http.Handler = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + comp := r.Header.Get("Accept-Encoding") + if _, ok := rw.(*compressResponseWriter); !ok { + t.Fatalf("ResponseWriter wasn't wrapped by compressResponseWriter, got %T type", rw) + } + if _, ok := rw.(http.Flusher); !ok { + t.Errorf("ResponseWriter lost http.Flusher interface for %q", comp) + } + if _, ok := rw.(http.CloseNotifier); !ok { + t.Errorf("ResponseWriter lost http.CloseNotifier interface for %q", comp) + } + if _, ok := rw.(http.Hijacker); !ok { + t.Errorf("ResponseWriter lost http.Hijacker interface for %q", comp) + } + }) + h = CompressHandler(h) + var ( + rw fullyFeaturedResponseWriter + ) + r, err := http.NewRequest("GET", "/", nil) + if err != nil { + t.Fatalf("Failed to create test request: %v", err) + } + r.Header.Set("Accept-Encoding", "gzip") + h.ServeHTTP(rw, r) + + r.Header.Set("Accept-Encoding", "deflate") + h.ServeHTTP(rw, r) +} diff --git a/vendor/github.com/gorilla/handlers/cors.go b/vendor/github.com/gorilla/handlers/cors.go new file mode 100644 index 00000000..1f92d1ad --- /dev/null +++ b/vendor/github.com/gorilla/handlers/cors.go @@ -0,0 +1,317 @@ +package handlers + +import ( + "net/http" + "strconv" + "strings" +) + +// CORSOption represents a functional option for configuring the CORS middleware. +type CORSOption func(*cors) error + +type cors struct { + h http.Handler + allowedHeaders []string + allowedMethods []string + allowedOrigins []string + allowedOriginValidator OriginValidator + exposedHeaders []string + maxAge int + ignoreOptions bool + allowCredentials bool +} + +// OriginValidator takes an origin string and returns whether or not that origin is allowed. +type OriginValidator func(string) bool + +var ( + defaultCorsMethods = []string{"GET", "HEAD", "POST"} + defaultCorsHeaders = []string{"Accept", "Accept-Language", "Content-Language", "Origin"} + // (WebKit/Safari v9 sends the Origin header by default in AJAX requests) +) + +const ( + corsOptionMethod string = "OPTIONS" + corsAllowOriginHeader string = "Access-Control-Allow-Origin" + corsExposeHeadersHeader string = "Access-Control-Expose-Headers" + corsMaxAgeHeader string = "Access-Control-Max-Age" + corsAllowMethodsHeader string = "Access-Control-Allow-Methods" + corsAllowHeadersHeader string = "Access-Control-Allow-Headers" + corsAllowCredentialsHeader string = "Access-Control-Allow-Credentials" + corsRequestMethodHeader string = "Access-Control-Request-Method" + corsRequestHeadersHeader string = "Access-Control-Request-Headers" + corsOriginHeader string = "Origin" + corsVaryHeader string = "Vary" + corsOriginMatchAll string = "*" +) + +func (ch *cors) ServeHTTP(w http.ResponseWriter, r *http.Request) { + origin := r.Header.Get(corsOriginHeader) + if !ch.isOriginAllowed(origin) { + ch.h.ServeHTTP(w, r) + return + } + + if r.Method == corsOptionMethod { + if ch.ignoreOptions { + ch.h.ServeHTTP(w, r) + return + } + + if _, ok := r.Header[corsRequestMethodHeader]; !ok { + w.WriteHeader(http.StatusBadRequest) + return + } + + method := r.Header.Get(corsRequestMethodHeader) + if !ch.isMatch(method, ch.allowedMethods) { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + + requestHeaders := strings.Split(r.Header.Get(corsRequestHeadersHeader), ",") + allowedHeaders := []string{} + for _, v := range requestHeaders { + canonicalHeader := http.CanonicalHeaderKey(strings.TrimSpace(v)) + if canonicalHeader == "" || ch.isMatch(canonicalHeader, defaultCorsHeaders) { + continue + } + + if !ch.isMatch(canonicalHeader, ch.allowedHeaders) { + w.WriteHeader(http.StatusForbidden) + return + } + + allowedHeaders = append(allowedHeaders, canonicalHeader) + } + + if len(allowedHeaders) > 0 { + w.Header().Set(corsAllowHeadersHeader, strings.Join(allowedHeaders, ",")) + } + + if ch.maxAge > 0 { + w.Header().Set(corsMaxAgeHeader, strconv.Itoa(ch.maxAge)) + } + + if !ch.isMatch(method, defaultCorsMethods) { + w.Header().Set(corsAllowMethodsHeader, method) + } + } else { + if len(ch.exposedHeaders) > 0 { + w.Header().Set(corsExposeHeadersHeader, strings.Join(ch.exposedHeaders, ",")) + } + } + + if ch.allowCredentials { + w.Header().Set(corsAllowCredentialsHeader, "true") + } + + if len(ch.allowedOrigins) > 1 { + w.Header().Set(corsVaryHeader, corsOriginHeader) + } + + w.Header().Set(corsAllowOriginHeader, origin) + + if r.Method == corsOptionMethod { + return + } + ch.h.ServeHTTP(w, r) +} + +// CORS provides Cross-Origin Resource Sharing middleware. +// Example: +// +// import ( +// "net/http" +// +// "github.com/gorilla/handlers" +// "github.com/gorilla/mux" +// ) +// +// func main() { +// r := mux.NewRouter() +// r.HandleFunc("/users", UserEndpoint) +// r.HandleFunc("/projects", ProjectEndpoint) +// +// // Apply the CORS middleware to our top-level router, with the defaults. +// http.ListenAndServe(":8000", handlers.CORS()(r)) +// } +// +func CORS(opts ...CORSOption) func(http.Handler) http.Handler { + return func(h http.Handler) http.Handler { + ch := parseCORSOptions(opts...) + ch.h = h + return ch + } +} + +func parseCORSOptions(opts ...CORSOption) *cors { + ch := &cors{ + allowedMethods: defaultCorsMethods, + allowedHeaders: defaultCorsHeaders, + allowedOrigins: []string{corsOriginMatchAll}, + } + + for _, option := range opts { + option(ch) + } + + return ch +} + +// +// Functional options for configuring CORS. +// + +// AllowedHeaders adds the provided headers to the list of allowed headers in a +// CORS request. +// This is an append operation so the headers Accept, Accept-Language, +// and Content-Language are always allowed. +// Content-Type must be explicitly declared if accepting Content-Types other than +// application/x-www-form-urlencoded, multipart/form-data, or text/plain. +func AllowedHeaders(headers []string) CORSOption { + return func(ch *cors) error { + for _, v := range headers { + normalizedHeader := http.CanonicalHeaderKey(strings.TrimSpace(v)) + if normalizedHeader == "" { + continue + } + + if !ch.isMatch(normalizedHeader, ch.allowedHeaders) { + ch.allowedHeaders = append(ch.allowedHeaders, normalizedHeader) + } + } + + return nil + } +} + +// AllowedMethods can be used to explicitly allow methods in the +// Access-Control-Allow-Methods header. +// This is a replacement operation so you must also +// pass GET, HEAD, and POST if you wish to support those methods. +func AllowedMethods(methods []string) CORSOption { + return func(ch *cors) error { + ch.allowedMethods = []string{} + for _, v := range methods { + normalizedMethod := strings.ToUpper(strings.TrimSpace(v)) + if normalizedMethod == "" { + continue + } + + if !ch.isMatch(normalizedMethod, ch.allowedMethods) { + ch.allowedMethods = append(ch.allowedMethods, normalizedMethod) + } + } + + return nil + } +} + +// AllowedOrigins sets the allowed origins for CORS requests, as used in the +// 'Allow-Access-Control-Origin' HTTP header. +// Note: Passing in a []string{"*"} will allow any domain. +func AllowedOrigins(origins []string) CORSOption { + return func(ch *cors) error { + for _, v := range origins { + if v == corsOriginMatchAll { + ch.allowedOrigins = []string{corsOriginMatchAll} + return nil + } + } + + ch.allowedOrigins = origins + return nil + } +} + +// AllowedOriginValidator sets a function for evaluating allowed origins in CORS requests, represented by the +// 'Allow-Access-Control-Origin' HTTP header. +func AllowedOriginValidator(fn OriginValidator) CORSOption { + return func(ch *cors) error { + ch.allowedOriginValidator = fn + return nil + } +} + +// ExposeHeaders can be used to specify headers that are available +// and will not be stripped out by the user-agent. +func ExposedHeaders(headers []string) CORSOption { + return func(ch *cors) error { + ch.exposedHeaders = []string{} + for _, v := range headers { + normalizedHeader := http.CanonicalHeaderKey(strings.TrimSpace(v)) + if normalizedHeader == "" { + continue + } + + if !ch.isMatch(normalizedHeader, ch.exposedHeaders) { + ch.exposedHeaders = append(ch.exposedHeaders, normalizedHeader) + } + } + + return nil + } +} + +// MaxAge determines the maximum age (in seconds) between preflight requests. A +// maximum of 10 minutes is allowed. An age above this value will default to 10 +// minutes. +func MaxAge(age int) CORSOption { + return func(ch *cors) error { + // Maximum of 10 minutes. + if age > 600 { + age = 600 + } + + ch.maxAge = age + return nil + } +} + +// IgnoreOptions causes the CORS middleware to ignore OPTIONS requests, instead +// passing them through to the next handler. This is useful when your application +// or framework has a pre-existing mechanism for responding to OPTIONS requests. +func IgnoreOptions() CORSOption { + return func(ch *cors) error { + ch.ignoreOptions = true + return nil + } +} + +// AllowCredentials can be used to specify that the user agent may pass +// authentication details along with the request. +func AllowCredentials() CORSOption { + return func(ch *cors) error { + ch.allowCredentials = true + return nil + } +} + +func (ch *cors) isOriginAllowed(origin string) bool { + if origin == "" { + return false + } + + if ch.allowedOriginValidator != nil { + return ch.allowedOriginValidator(origin) + } + + for _, allowedOrigin := range ch.allowedOrigins { + if allowedOrigin == origin || allowedOrigin == corsOriginMatchAll { + return true + } + } + + return false +} + +func (ch *cors) isMatch(needle string, haystack []string) bool { + for _, v := range haystack { + if v == needle { + return true + } + } + + return false +} diff --git a/vendor/github.com/gorilla/handlers/cors_test.go b/vendor/github.com/gorilla/handlers/cors_test.go new file mode 100644 index 00000000..c63913ee --- /dev/null +++ b/vendor/github.com/gorilla/handlers/cors_test.go @@ -0,0 +1,336 @@ +package handlers + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestDefaultCORSHandlerReturnsOk(t *testing.T) { + r := newRequest("GET", "http://www.example.com/") + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusFound) + } +} + +func TestDefaultCORSHandlerReturnsOkWithOrigin(t *testing.T) { + r := newRequest("GET", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusFound) + } +} + +func TestCORSHandlerIgnoreOptionsFallsThrough(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusTeapot) + }) + + CORS(IgnoreOptions())(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusTeapot { + t.Fatalf("bad status: got %v want %v", status, http.StatusTeapot) + } +} + +func TestCORSHandlerSetsExposedHeaders(t *testing.T) { + // Test default configuration. + r := newRequest("GET", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(ExposedHeaders([]string{"X-CORS-TEST"}))(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsExposeHeadersHeader) + if header != "X-Cors-Test" { + t.Fatal("bad header: expected X-Cors-Test header, got empty header for method.") + } +} + +func TestCORSHandlerUnsetRequestMethodForPreflightBadRequest(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(AllowedMethods([]string{"DELETE"}))(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusBadRequest { + t.Fatalf("bad status: got %v want %v", status, http.StatusBadRequest) + } +} + +func TestCORSHandlerInvalidRequestMethodForPreflightMethodNotAllowed(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "DELETE") + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusMethodNotAllowed { + t.Fatalf("bad status: got %v want %v", status, http.StatusMethodNotAllowed) + } +} + +func TestCORSHandlerOptionsRequestMustNotBePassedToNextHandler(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "GET") + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + t.Fatal("Options request must not be passed to next handler") + }) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } +} + +func TestCORSHandlerAllowedMethodForPreflight(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "DELETE") + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(AllowedMethods([]string{"DELETE"}))(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsAllowMethodsHeader) + if header != "DELETE" { + t.Fatalf("bad header: expected DELETE method header, got empty header.") + } +} + +func TestCORSHandlerAllowMethodsNotSetForSimpleRequestPreflight(t *testing.T) { + for _, method := range defaultCorsMethods { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, method) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsAllowMethodsHeader) + if header != "" { + t.Fatalf("bad header: expected empty method header, got %s.", header) + } + } +} + +func TestCORSHandlerAllowedHeaderNotSetForSimpleRequestPreflight(t *testing.T) { + for _, simpleHeader := range defaultCorsHeaders { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "GET") + r.Header.Set(corsRequestHeadersHeader, simpleHeader) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsAllowHeadersHeader) + if header != "" { + t.Fatalf("bad header: expected empty header, got %s.", header) + } + } +} + +func TestCORSHandlerAllowedHeaderForPreflight(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "POST") + r.Header.Set(corsRequestHeadersHeader, "Content-Type") + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(AllowedHeaders([]string{"Content-Type"}))(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsAllowHeadersHeader) + if header != "Content-Type" { + t.Fatalf("bad header: expected Content-Type header, got empty header.") + } +} + +func TestCORSHandlerInvalidHeaderForPreflightForbidden(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "POST") + r.Header.Set(corsRequestHeadersHeader, "Content-Type") + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS()(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusForbidden { + t.Fatalf("bad status: got %v want %v", status, http.StatusForbidden) + } +} + +func TestCORSHandlerMaxAgeForPreflight(t *testing.T) { + r := newRequest("OPTIONS", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + r.Header.Set(corsRequestMethodHeader, "POST") + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(MaxAge(3500))(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsMaxAgeHeader) + if header != "600" { + t.Fatalf("bad header: expected %s to be %s, got %s.", corsMaxAgeHeader, "600", header) + } +} + +func TestCORSHandlerAllowedCredentials(t *testing.T) { + r := newRequest("GET", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(AllowCredentials())(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsAllowCredentialsHeader) + if header != "true" { + t.Fatalf("bad header: expected %s to be %s, got %s.", corsAllowCredentialsHeader, "true", header) + } +} + +func TestCORSHandlerMultipleAllowOriginsSetsVaryHeader(t *testing.T) { + r := newRequest("GET", "http://www.example.com/") + r.Header.Set("Origin", r.URL.String()) + + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + CORS(AllowedOrigins([]string{r.URL.String(), "http://google.com"}))(testHandler).ServeHTTP(rr, r) + + if status := rr.Code; status != http.StatusOK { + t.Fatalf("bad status: got %v want %v", status, http.StatusOK) + } + + header := rr.HeaderMap.Get(corsVaryHeader) + if header != corsOriginHeader { + t.Fatalf("bad header: expected %s to be %s, got %s.", corsVaryHeader, corsOriginHeader, header) + } +} + +func TestCORSWithMultipleHandlers(t *testing.T) { + var lastHandledBy string + corsMiddleware := CORS() + + testHandler1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + lastHandledBy = "testHandler1" + }) + testHandler2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + lastHandledBy = "testHandler2" + }) + + r1 := newRequest("GET", "http://www.example.com/") + rr1 := httptest.NewRecorder() + handler1 := corsMiddleware(testHandler1) + + corsMiddleware(testHandler2) + + handler1.ServeHTTP(rr1, r1) + if lastHandledBy != "testHandler1" { + t.Fatalf("bad CORS() registration: Handler served should be Handler registered") + } +} + +func TestCORSHandlerWithCustomValidator(t *testing.T) { + r := newRequest("GET", "http://a.example.com") + r.Header.Set("Origin", r.URL.String()) + rr := httptest.NewRecorder() + + testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) + + originValidator := func(origin string) bool { + if strings.HasSuffix(origin, ".example.com") { + return true + } + return false + } + + CORS(AllowedOriginValidator(originValidator))(testHandler).ServeHTTP(rr, r) + header := rr.HeaderMap.Get(corsAllowOriginHeader) + if header != r.URL.String() { + t.Fatalf("bad header: expected %s to be %s, got %s.", corsAllowOriginHeader, r.URL.String(), header) + } + +} diff --git a/vendor/github.com/gorilla/handlers/doc.go b/vendor/github.com/gorilla/handlers/doc.go new file mode 100644 index 00000000..944e5a8a --- /dev/null +++ b/vendor/github.com/gorilla/handlers/doc.go @@ -0,0 +1,9 @@ +/* +Package handlers is a collection of handlers (aka "HTTP middleware") for use +with Go's net/http package (or any framework supporting http.Handler). + +The package includes handlers for logging in standardised formats, compressing +HTTP responses, validating content types and other useful tools for manipulating +requests and responses. +*/ +package handlers diff --git a/vendor/github.com/gorilla/handlers/handlers.go b/vendor/github.com/gorilla/handlers/handlers.go new file mode 100644 index 00000000..9544d2f0 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/handlers.go @@ -0,0 +1,403 @@ +// Copyright 2013 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 handlers + +import ( + "bufio" + "fmt" + "io" + "net" + "net/http" + "net/url" + "sort" + "strconv" + "strings" + "time" + "unicode/utf8" +) + +// MethodHandler is an http.Handler that dispatches to a handler whose key in the +// MethodHandler's map matches the name of the HTTP request's method, eg: GET +// +// If the request's method is OPTIONS and OPTIONS is not a key in the map then +// the handler responds with a status of 200 and sets the Allow header to a +// comma-separated list of available methods. +// +// If the request's method doesn't match any of its keys the handler responds +// with a status of HTTP 405 "Method Not Allowed" and sets the Allow header to a +// comma-separated list of available methods. +type MethodHandler map[string]http.Handler + +func (h MethodHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + if handler, ok := h[req.Method]; ok { + handler.ServeHTTP(w, req) + } else { + allow := []string{} + for k := range h { + allow = append(allow, k) + } + sort.Strings(allow) + w.Header().Set("Allow", strings.Join(allow, ", ")) + if req.Method == "OPTIONS" { + w.WriteHeader(http.StatusOK) + } else { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + } + } +} + +// loggingHandler is the http.Handler implementation for LoggingHandlerTo and its +// friends +type loggingHandler struct { + writer io.Writer + handler http.Handler +} + +// combinedLoggingHandler is the http.Handler implementation for LoggingHandlerTo +// and its friends +type combinedLoggingHandler struct { + writer io.Writer + handler http.Handler +} + +func (h loggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + t := time.Now() + logger := makeLogger(w) + url := *req.URL + h.handler.ServeHTTP(logger, req) + writeLog(h.writer, req, url, t, logger.Status(), logger.Size()) +} + +func (h combinedLoggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + t := time.Now() + logger := makeLogger(w) + url := *req.URL + h.handler.ServeHTTP(logger, req) + writeCombinedLog(h.writer, req, url, t, logger.Status(), logger.Size()) +} + +func makeLogger(w http.ResponseWriter) loggingResponseWriter { + var logger loggingResponseWriter = &responseLogger{w: w} + if _, ok := w.(http.Hijacker); ok { + logger = &hijackLogger{responseLogger{w: w}} + } + h, ok1 := logger.(http.Hijacker) + c, ok2 := w.(http.CloseNotifier) + if ok1 && ok2 { + return hijackCloseNotifier{logger, h, c} + } + if ok2 { + return &closeNotifyWriter{logger, c} + } + return logger +} + +type loggingResponseWriter interface { + http.ResponseWriter + http.Flusher + Status() int + Size() int +} + +// responseLogger is wrapper of http.ResponseWriter that keeps track of its HTTP +// status code and body size +type responseLogger struct { + w http.ResponseWriter + status int + size int +} + +func (l *responseLogger) Header() http.Header { + return l.w.Header() +} + +func (l *responseLogger) Write(b []byte) (int, error) { + if l.status == 0 { + // The status will be StatusOK if WriteHeader has not been called yet + l.status = http.StatusOK + } + size, err := l.w.Write(b) + l.size += size + return size, err +} + +func (l *responseLogger) WriteHeader(s int) { + l.w.WriteHeader(s) + l.status = s +} + +func (l *responseLogger) Status() int { + return l.status +} + +func (l *responseLogger) Size() int { + return l.size +} + +func (l *responseLogger) Flush() { + f, ok := l.w.(http.Flusher) + if ok { + f.Flush() + } +} + +type hijackLogger struct { + responseLogger +} + +func (l *hijackLogger) Hijack() (net.Conn, *bufio.ReadWriter, error) { + h := l.responseLogger.w.(http.Hijacker) + conn, rw, err := h.Hijack() + if err == nil && l.responseLogger.status == 0 { + // The status will be StatusSwitchingProtocols if there was no error and + // WriteHeader has not been called yet + l.responseLogger.status = http.StatusSwitchingProtocols + } + return conn, rw, err +} + +type closeNotifyWriter struct { + loggingResponseWriter + http.CloseNotifier +} + +type hijackCloseNotifier struct { + loggingResponseWriter + http.Hijacker + http.CloseNotifier +} + +const lowerhex = "0123456789abcdef" + +func appendQuoted(buf []byte, s string) []byte { + var runeTmp [utf8.UTFMax]byte + for width := 0; len(s) > 0; s = s[width:] { + r := rune(s[0]) + width = 1 + if r >= utf8.RuneSelf { + r, width = utf8.DecodeRuneInString(s) + } + if width == 1 && r == utf8.RuneError { + buf = append(buf, `\x`...) + buf = append(buf, lowerhex[s[0]>>4]) + buf = append(buf, lowerhex[s[0]&0xF]) + continue + } + if r == rune('"') || r == '\\' { // always backslashed + buf = append(buf, '\\') + buf = append(buf, byte(r)) + continue + } + if strconv.IsPrint(r) { + n := utf8.EncodeRune(runeTmp[:], r) + buf = append(buf, runeTmp[:n]...) + continue + } + switch r { + case '\a': + buf = append(buf, `\a`...) + case '\b': + buf = append(buf, `\b`...) + case '\f': + buf = append(buf, `\f`...) + case '\n': + buf = append(buf, `\n`...) + case '\r': + buf = append(buf, `\r`...) + case '\t': + buf = append(buf, `\t`...) + case '\v': + buf = append(buf, `\v`...) + default: + switch { + case r < ' ': + buf = append(buf, `\x`...) + buf = append(buf, lowerhex[s[0]>>4]) + buf = append(buf, lowerhex[s[0]&0xF]) + case r > utf8.MaxRune: + r = 0xFFFD + fallthrough + case r < 0x10000: + buf = append(buf, `\u`...) + for s := 12; s >= 0; s -= 4 { + buf = append(buf, lowerhex[r>>uint(s)&0xF]) + } + default: + buf = append(buf, `\U`...) + for s := 28; s >= 0; s -= 4 { + buf = append(buf, lowerhex[r>>uint(s)&0xF]) + } + } + } + } + return buf + +} + +// buildCommonLogLine builds a log entry for req in Apache Common Log Format. +// ts is the timestamp with which the entry should be logged. +// status and size are used to provide the response HTTP status and size. +func buildCommonLogLine(req *http.Request, url url.URL, ts time.Time, status int, size int) []byte { + username := "-" + if url.User != nil { + if name := url.User.Username(); name != "" { + username = name + } + } + + host, _, err := net.SplitHostPort(req.RemoteAddr) + + if err != nil { + host = req.RemoteAddr + } + + uri := req.RequestURI + + // Requests using the CONNECT method over HTTP/2.0 must use + // the authority field (aka r.Host) to identify the target. + // Refer: https://httpwg.github.io/specs/rfc7540.html#CONNECT + if req.ProtoMajor == 2 && req.Method == "CONNECT" { + uri = req.Host + } + if uri == "" { + uri = url.RequestURI() + } + + buf := make([]byte, 0, 3*(len(host)+len(username)+len(req.Method)+len(uri)+len(req.Proto)+50)/2) + buf = append(buf, host...) + buf = append(buf, " - "...) + buf = append(buf, username...) + buf = append(buf, " ["...) + buf = append(buf, ts.Format("02/Jan/2006:15:04:05 -0700")...) + buf = append(buf, `] "`...) + buf = append(buf, req.Method...) + buf = append(buf, " "...) + buf = appendQuoted(buf, uri) + buf = append(buf, " "...) + buf = append(buf, req.Proto...) + buf = append(buf, `" `...) + buf = append(buf, strconv.Itoa(status)...) + buf = append(buf, " "...) + buf = append(buf, strconv.Itoa(size)...) + return buf +} + +// writeLog writes a log entry for req to w in Apache Common Log Format. +// ts is the timestamp with which the entry should be logged. +// status and size are used to provide the response HTTP status and size. +func writeLog(w io.Writer, req *http.Request, url url.URL, ts time.Time, status, size int) { + buf := buildCommonLogLine(req, url, ts, status, size) + buf = append(buf, '\n') + w.Write(buf) +} + +// writeCombinedLog writes a log entry for req to w in Apache Combined Log Format. +// ts is the timestamp with which the entry should be logged. +// status and size are used to provide the response HTTP status and size. +func writeCombinedLog(w io.Writer, req *http.Request, url url.URL, ts time.Time, status, size int) { + buf := buildCommonLogLine(req, url, ts, status, size) + buf = append(buf, ` "`...) + buf = appendQuoted(buf, req.Referer()) + buf = append(buf, `" "`...) + buf = appendQuoted(buf, req.UserAgent()) + buf = append(buf, '"', '\n') + w.Write(buf) +} + +// CombinedLoggingHandler return a http.Handler that wraps h and logs requests to out in +// Apache Combined Log Format. +// +// See http://httpd.apache.org/docs/2.2/logs.html#combined for a description of this format. +// +// LoggingHandler always sets the ident field of the log to - +func CombinedLoggingHandler(out io.Writer, h http.Handler) http.Handler { + return combinedLoggingHandler{out, h} +} + +// LoggingHandler return a http.Handler that wraps h and logs requests to out in +// Apache Common Log Format (CLF). +// +// See http://httpd.apache.org/docs/2.2/logs.html#common for a description of this format. +// +// LoggingHandler always sets the ident field of the log to - +// +// Example: +// +// r := mux.NewRouter() +// r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { +// w.Write([]byte("This is a catch-all route")) +// }) +// loggedRouter := handlers.LoggingHandler(os.Stdout, r) +// http.ListenAndServe(":1123", loggedRouter) +// +func LoggingHandler(out io.Writer, h http.Handler) http.Handler { + return loggingHandler{out, h} +} + +// isContentType validates the Content-Type header matches the supplied +// contentType. That is, its type and subtype match. +func isContentType(h http.Header, contentType string) bool { + ct := h.Get("Content-Type") + if i := strings.IndexRune(ct, ';'); i != -1 { + ct = ct[0:i] + } + return ct == contentType +} + +// ContentTypeHandler wraps and returns a http.Handler, validating the request +// content type is compatible with the contentTypes list. It writes a HTTP 415 +// error if that fails. +// +// Only PUT, POST, and PATCH requests are considered. +func ContentTypeHandler(h http.Handler, contentTypes ...string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if !(r.Method == "PUT" || r.Method == "POST" || r.Method == "PATCH") { + h.ServeHTTP(w, r) + return + } + + for _, ct := range contentTypes { + if isContentType(r.Header, ct) { + h.ServeHTTP(w, r) + return + } + } + http.Error(w, fmt.Sprintf("Unsupported content type %q; expected one of %q", r.Header.Get("Content-Type"), contentTypes), http.StatusUnsupportedMediaType) + }) +} + +const ( + // HTTPMethodOverrideHeader is a commonly used + // http header to override a request method. + HTTPMethodOverrideHeader = "X-HTTP-Method-Override" + // HTTPMethodOverrideFormKey is a commonly used + // HTML form key to override a request method. + HTTPMethodOverrideFormKey = "_method" +) + +// HTTPMethodOverrideHandler wraps and returns a http.Handler which checks for +// the X-HTTP-Method-Override header or the _method form key, and overrides (if +// valid) request.Method with its value. +// +// This is especially useful for HTTP clients that don't support many http verbs. +// It isn't secure to override e.g a GET to a POST, so only POST requests are +// considered. Likewise, the override method can only be a "write" method: PUT, +// PATCH or DELETE. +// +// Form method takes precedence over header method. +func HTTPMethodOverrideHandler(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == "POST" { + om := r.FormValue(HTTPMethodOverrideFormKey) + if om == "" { + om = r.Header.Get(HTTPMethodOverrideHeader) + } + if om == "PUT" || om == "PATCH" || om == "DELETE" { + r.Method = om + } + } + h.ServeHTTP(w, r) + }) +} diff --git a/vendor/github.com/gorilla/handlers/handlers_test.go b/vendor/github.com/gorilla/handlers/handlers_test.go new file mode 100644 index 00000000..6ea7c7fa --- /dev/null +++ b/vendor/github.com/gorilla/handlers/handlers_test.go @@ -0,0 +1,354 @@ +// Copyright 2013 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 handlers + +import ( + "bytes" + "net" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + "time" +) + +const ( + ok = "ok\n" + notAllowed = "Method not allowed\n" +) + +var okHandler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + w.Write([]byte(ok)) +}) + +func newRequest(method, url string) *http.Request { + req, err := http.NewRequest(method, url, nil) + if err != nil { + panic(err) + } + return req +} + +func TestMethodHandler(t *testing.T) { + tests := []struct { + req *http.Request + handler http.Handler + code int + allow string // Contents of the Allow header + body string + }{ + // No handlers + {newRequest("GET", "/foo"), MethodHandler{}, http.StatusMethodNotAllowed, "", notAllowed}, + {newRequest("OPTIONS", "/foo"), MethodHandler{}, http.StatusOK, "", ""}, + + // A single handler + {newRequest("GET", "/foo"), MethodHandler{"GET": okHandler}, http.StatusOK, "", ok}, + {newRequest("POST", "/foo"), MethodHandler{"GET": okHandler}, http.StatusMethodNotAllowed, "GET", notAllowed}, + + // Multiple handlers + {newRequest("GET", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusOK, "", ok}, + {newRequest("POST", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusOK, "", ok}, + {newRequest("DELETE", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusMethodNotAllowed, "GET, POST", notAllowed}, + {newRequest("OPTIONS", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusOK, "GET, POST", ""}, + + // Override OPTIONS + {newRequest("OPTIONS", "/foo"), MethodHandler{"OPTIONS": okHandler}, http.StatusOK, "", ok}, + } + + for i, test := range tests { + rec := httptest.NewRecorder() + test.handler.ServeHTTP(rec, test.req) + if rec.Code != test.code { + t.Fatalf("%d: wrong code, got %d want %d", i, rec.Code, test.code) + } + if allow := rec.HeaderMap.Get("Allow"); allow != test.allow { + t.Fatalf("%d: wrong Allow, got %s want %s", i, allow, test.allow) + } + if body := rec.Body.String(); body != test.body { + t.Fatalf("%d: wrong body, got %q want %q", i, body, test.body) + } + } +} + +func TestWriteLog(t *testing.T) { + loc, err := time.LoadLocation("Europe/Warsaw") + if err != nil { + panic(err) + } + ts := time.Date(1983, 05, 26, 3, 30, 45, 0, loc) + + // A typical request with an OK response + req := newRequest("GET", "http://example.com") + req.RemoteAddr = "192.168.100.5" + + buf := new(bytes.Buffer) + writeLog(buf, req, *req.URL, ts, http.StatusOK, 100) + log := buf.String() + + expected := "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // CONNECT request over http/2.0 + req = &http.Request{ + Method: "CONNECT", + Proto: "HTTP/2.0", + ProtoMajor: 2, + ProtoMinor: 0, + URL: &url.URL{Host: "www.example.com:443"}, + Host: "www.example.com:443", + RemoteAddr: "192.168.100.5", + } + + buf = new(bytes.Buffer) + writeLog(buf, req, *req.URL, ts, http.StatusOK, 100) + log = buf.String() + + expected = "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"CONNECT www.example.com:443 HTTP/2.0\" 200 100\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // Request with an unauthorized user + req = newRequest("GET", "http://example.com") + req.RemoteAddr = "192.168.100.5" + req.URL.User = url.User("kamil") + + buf.Reset() + writeLog(buf, req, *req.URL, ts, http.StatusUnauthorized, 500) + log = buf.String() + + expected = "192.168.100.5 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 401 500\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // Request with url encoded parameters + req = newRequest("GET", "http://example.com/test?abc=hello%20world&a=b%3F") + req.RemoteAddr = "192.168.100.5" + + buf.Reset() + writeLog(buf, req, *req.URL, ts, http.StatusOK, 100) + log = buf.String() + + expected = "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"GET /test?abc=hello%20world&a=b%3F HTTP/1.1\" 200 100\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } +} + +func TestWriteCombinedLog(t *testing.T) { + loc, err := time.LoadLocation("Europe/Warsaw") + if err != nil { + panic(err) + } + ts := time.Date(1983, 05, 26, 3, 30, 45, 0, loc) + + // A typical request with an OK response + req := newRequest("GET", "http://example.com") + req.RemoteAddr = "192.168.100.5" + req.Header.Set("Referer", "http://example.com") + req.Header.Set( + "User-Agent", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.33 "+ + "(KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33", + ) + + buf := new(bytes.Buffer) + writeCombinedLog(buf, req, *req.URL, ts, http.StatusOK, 100) + log := buf.String() + + expected := "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100 \"http://example.com\" " + + "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + + "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // CONNECT request over http/2.0 + req1 := &http.Request{ + Method: "CONNECT", + Host: "www.example.com:443", + Proto: "HTTP/2.0", + ProtoMajor: 2, + ProtoMinor: 0, + RemoteAddr: "192.168.100.5", + Header: http.Header{}, + URL: &url.URL{Host: "www.example.com:443"}, + } + req1.Header.Set("Referer", "http://example.com") + req1.Header.Set( + "User-Agent", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.33 "+ + "(KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33", + ) + + buf = new(bytes.Buffer) + writeCombinedLog(buf, req1, *req1.URL, ts, http.StatusOK, 100) + log = buf.String() + + expected = "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"CONNECT www.example.com:443 HTTP/2.0\" 200 100 \"http://example.com\" " + + "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + + "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // Request with an unauthorized user + req.URL.User = url.User("kamil") + + buf.Reset() + writeCombinedLog(buf, req, *req.URL, ts, http.StatusUnauthorized, 500) + log = buf.String() + + expected = "192.168.100.5 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 401 500 \"http://example.com\" " + + "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + + "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // Test with remote ipv6 address + req.RemoteAddr = "::1" + + buf.Reset() + writeCombinedLog(buf, req, *req.URL, ts, http.StatusOK, 100) + log = buf.String() + + expected = "::1 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100 \"http://example.com\" " + + "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + + "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } + + // Test remote ipv6 addr, with port + req.RemoteAddr = net.JoinHostPort("::1", "65000") + + buf.Reset() + writeCombinedLog(buf, req, *req.URL, ts, http.StatusOK, 100) + log = buf.String() + + expected = "::1 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100 \"http://example.com\" " + + "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + + "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" + if log != expected { + t.Fatalf("wrong log, got %q want %q", log, expected) + } +} + +func TestLogPathRewrites(t *testing.T) { + var buf bytes.Buffer + + handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + req.URL.Path = "/" // simulate http.StripPrefix and friends + w.WriteHeader(200) + }) + logger := LoggingHandler(&buf, handler) + + logger.ServeHTTP(httptest.NewRecorder(), newRequest("GET", "/subdir/asdf")) + + if !strings.Contains(buf.String(), "GET /subdir/asdf HTTP") { + t.Fatalf("Got log %#v, wanted substring %#v", buf.String(), "GET /subdir/asdf HTTP") + } +} + +func BenchmarkWriteLog(b *testing.B) { + loc, err := time.LoadLocation("Europe/Warsaw") + if err != nil { + b.Fatalf(err.Error()) + } + ts := time.Date(1983, 05, 26, 3, 30, 45, 0, loc) + + req := newRequest("GET", "http://example.com") + req.RemoteAddr = "192.168.100.5" + + b.ResetTimer() + + buf := &bytes.Buffer{} + for i := 0; i < b.N; i++ { + buf.Reset() + writeLog(buf, req, *req.URL, ts, http.StatusUnauthorized, 500) + } +} + +func TestContentTypeHandler(t *testing.T) { + tests := []struct { + Method string + AllowContentTypes []string + ContentType string + Code int + }{ + {"POST", []string{"application/json"}, "application/json", http.StatusOK}, + {"POST", []string{"application/json", "application/xml"}, "application/json", http.StatusOK}, + {"POST", []string{"application/json"}, "application/json; charset=utf-8", http.StatusOK}, + {"POST", []string{"application/json"}, "application/json+xxx", http.StatusUnsupportedMediaType}, + {"POST", []string{"application/json"}, "text/plain", http.StatusUnsupportedMediaType}, + {"GET", []string{"application/json"}, "", http.StatusOK}, + {"GET", []string{}, "", http.StatusOK}, + } + for _, test := range tests { + r, err := http.NewRequest(test.Method, "/", nil) + if err != nil { + t.Error(err) + continue + } + + h := ContentTypeHandler(okHandler, test.AllowContentTypes...) + r.Header.Set("Content-Type", test.ContentType) + w := httptest.NewRecorder() + h.ServeHTTP(w, r) + if w.Code != test.Code { + t.Errorf("expected %d, got %d", test.Code, w.Code) + } + } +} + +func TestHTTPMethodOverride(t *testing.T) { + var tests = []struct { + Method string + OverrideMethod string + ExpectedMethod string + }{ + {"POST", "PUT", "PUT"}, + {"POST", "PATCH", "PATCH"}, + {"POST", "DELETE", "DELETE"}, + {"PUT", "DELETE", "PUT"}, + {"GET", "GET", "GET"}, + {"HEAD", "HEAD", "HEAD"}, + {"GET", "PUT", "GET"}, + {"HEAD", "DELETE", "HEAD"}, + } + + for _, test := range tests { + h := HTTPMethodOverrideHandler(okHandler) + reqs := make([]*http.Request, 0, 2) + + rHeader, err := http.NewRequest(test.Method, "/", nil) + if err != nil { + t.Error(err) + } + rHeader.Header.Set(HTTPMethodOverrideHeader, test.OverrideMethod) + reqs = append(reqs, rHeader) + + f := url.Values{HTTPMethodOverrideFormKey: []string{test.OverrideMethod}} + rForm, err := http.NewRequest(test.Method, "/", strings.NewReader(f.Encode())) + if err != nil { + t.Error(err) + } + rForm.Header.Set("Content-Type", "application/x-www-form-urlencoded") + reqs = append(reqs, rForm) + + for _, r := range reqs { + w := httptest.NewRecorder() + h.ServeHTTP(w, r) + if r.Method != test.ExpectedMethod { + t.Errorf("Expected %s, got %s", test.ExpectedMethod, r.Method) + } + } + } +} diff --git a/vendor/github.com/gorilla/handlers/proxy_headers.go b/vendor/github.com/gorilla/handlers/proxy_headers.go new file mode 100644 index 00000000..268de9c6 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/proxy_headers.go @@ -0,0 +1,113 @@ +package handlers + +import ( + "net/http" + "regexp" + "strings" +) + +var ( + // De-facto standard header keys. + xForwardedFor = http.CanonicalHeaderKey("X-Forwarded-For") + xRealIP = http.CanonicalHeaderKey("X-Real-IP") + xForwardedProto = http.CanonicalHeaderKey("X-Forwarded-Scheme") +) + +var ( + // RFC7239 defines a new "Forwarded: " header designed to replace the + // existing use of X-Forwarded-* headers. + // e.g. Forwarded: for=192.0.2.60;proto=https;by=203.0.113.43 + forwarded = http.CanonicalHeaderKey("Forwarded") + // Allows for a sub-match of the first value after 'for=' to the next + // comma, semi-colon or space. The match is case-insensitive. + forRegex = regexp.MustCompile(`(?i)(?:for=)([^(;|,| )]+)`) + // Allows for a sub-match for the first instance of scheme (http|https) + // prefixed by 'proto='. The match is case-insensitive. + protoRegex = regexp.MustCompile(`(?i)(?:proto=)(https|http)`) +) + +// ProxyHeaders inspects common reverse proxy headers and sets the corresponding +// fields in the HTTP request struct. These are X-Forwarded-For and X-Real-IP +// for the remote (client) IP address, X-Forwarded-Proto for the scheme +// (http|https) and the RFC7239 Forwarded header, which may include both client +// IPs and schemes. +// +// NOTE: This middleware should only be used when behind a reverse +// proxy like nginx, HAProxy or Apache. Reverse proxies that don't (or are +// configured not to) strip these headers from client requests, or where these +// headers are accepted "as is" from a remote client (e.g. when Go is not behind +// a proxy), can manifest as a vulnerability if your application uses these +// headers for validating the 'trustworthiness' of a request. +func ProxyHeaders(h http.Handler) http.Handler { + fn := func(w http.ResponseWriter, r *http.Request) { + // Set the remote IP with the value passed from the proxy. + if fwd := getIP(r); fwd != "" { + r.RemoteAddr = fwd + } + + // Set the scheme (proto) with the value passed from the proxy. + if scheme := getScheme(r); scheme != "" { + r.URL.Scheme = scheme + } + + // Call the next handler in the chain. + h.ServeHTTP(w, r) + } + + return http.HandlerFunc(fn) +} + +// getIP retrieves the IP from the X-Forwarded-For, X-Real-IP and RFC7239 +// Forwarded headers (in that order). +func getIP(r *http.Request) string { + var addr string + + if fwd := r.Header.Get(xForwardedFor); fwd != "" { + // Only grab the first (client) address. Note that '192.168.0.1, + // 10.1.1.1' is a valid key for X-Forwarded-For where addresses after + // the first may represent forwarding proxies earlier in the chain. + s := strings.Index(fwd, ", ") + if s == -1 { + s = len(fwd) + } + addr = fwd[:s] + } else if fwd := r.Header.Get(xRealIP); fwd != "" { + // X-Real-IP should only contain one IP address (the client making the + // request). + addr = fwd + } else if fwd := r.Header.Get(forwarded); fwd != "" { + // match should contain at least two elements if the protocol was + // specified in the Forwarded header. The first element will always be + // the 'for=' capture, which we ignore. In the case of multiple IP + // addresses (for=8.8.8.8, 8.8.4.4,172.16.1.20 is valid) we only + // extract the first, which should be the client IP. + if match := forRegex.FindStringSubmatch(fwd); len(match) > 1 { + // IPv6 addresses in Forwarded headers are quoted-strings. We strip + // these quotes. + addr = strings.Trim(match[1], `"`) + } + } + + return addr +} + +// getScheme retrieves the scheme from the X-Forwarded-Proto and RFC7239 +// Forwarded headers (in that order). +func getScheme(r *http.Request) string { + var scheme string + + // Retrieve the scheme from X-Forwarded-Proto. + if proto := r.Header.Get(xForwardedProto); proto != "" { + scheme = strings.ToLower(proto) + } else if proto := r.Header.Get(forwarded); proto != "" { + // match should contain at least two elements if the protocol was + // specified in the Forwarded header. The first element will always be + // the 'proto=' capture, which we ignore. In the case of multiple proto + // parameters (invalid) we only extract the first. + if match := protoRegex.FindStringSubmatch(proto); len(match) > 1 { + scheme = strings.ToLower(match[1]) + } + } + + return scheme +} diff --git a/vendor/github.com/gorilla/handlers/proxy_headers_test.go b/vendor/github.com/gorilla/handlers/proxy_headers_test.go new file mode 100644 index 00000000..85282ef7 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/proxy_headers_test.go @@ -0,0 +1,100 @@ +package handlers + +import ( + "net/http" + "net/http/httptest" + "testing" +) + +type headerTable struct { + key string // header key + val string // header val + expected string // expected result +} + +func TestGetIP(t *testing.T) { + headers := []headerTable{ + {xForwardedFor, "8.8.8.8", "8.8.8.8"}, // Single address + {xForwardedFor, "8.8.8.8, 8.8.4.4", "8.8.8.8"}, // Multiple + {xForwardedFor, "[2001:db8:cafe::17]:4711", "[2001:db8:cafe::17]:4711"}, // IPv6 address + {xForwardedFor, "", ""}, // None + {xRealIP, "8.8.8.8", "8.8.8.8"}, // Single address + {xRealIP, "8.8.8.8, 8.8.4.4", "8.8.8.8, 8.8.4.4"}, // Multiple + {xRealIP, "[2001:db8:cafe::17]:4711", "[2001:db8:cafe::17]:4711"}, // IPv6 address + {xRealIP, "", ""}, // None + {forwarded, `for="_gazonk"`, "_gazonk"}, // Hostname + {forwarded, `For="[2001:db8:cafe::17]:4711`, `[2001:db8:cafe::17]:4711`}, // IPv6 address + {forwarded, `for=192.0.2.60;proto=http;by=203.0.113.43`, `192.0.2.60`}, // Multiple params + {forwarded, `for=192.0.2.43, for=198.51.100.17`, "192.0.2.43"}, // Multiple params + {forwarded, `for="workstation.local",for=198.51.100.17`, "workstation.local"}, // Hostname + } + + for _, v := range headers { + req := &http.Request{ + Header: http.Header{ + v.key: []string{v.val}, + }} + res := getIP(req) + if res != v.expected { + t.Fatalf("wrong header for %s: got %s want %s", v.key, res, + v.expected) + } + } +} + +func TestGetScheme(t *testing.T) { + headers := []headerTable{ + {xForwardedProto, "https", "https"}, + {xForwardedProto, "http", "http"}, + {xForwardedProto, "HTTP", "http"}, + {forwarded, `For="[2001:db8:cafe::17]:4711`, ""}, // No proto + {forwarded, `for=192.0.2.43, for=198.51.100.17;proto=https`, "https"}, // Multiple params before proto + {forwarded, `for=172.32.10.15; proto=https;by=127.0.0.1`, "https"}, // Space before proto + {forwarded, `for=192.0.2.60;proto=http;by=203.0.113.43`, "http"}, // Multiple params + } + + for _, v := range headers { + req := &http.Request{ + Header: http.Header{ + v.key: []string{v.val}, + }, + } + res := getScheme(req) + if res != v.expected { + t.Fatalf("wrong header for %s: got %s want %s", v.key, res, + v.expected) + } + } +} + +// Test the middleware end-to-end +func TestProxyHeaders(t *testing.T) { + rr := httptest.NewRecorder() + r := newRequest("GET", "/") + + r.Header.Set(xForwardedFor, "8.8.8.8") + r.Header.Set(xForwardedProto, "https") + + var addr string + var proto string + ProxyHeaders(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + addr = r.RemoteAddr + proto = r.URL.Scheme + })).ServeHTTP(rr, r) + + if rr.Code != http.StatusOK { + t.Fatalf("bad status: got %d want %d", rr.Code, http.StatusOK) + } + + if addr != r.Header.Get(xForwardedFor) { + t.Fatalf("wrong address: got %s want %s", addr, + r.Header.Get(xForwardedFor)) + } + + if proto != r.Header.Get(xForwardedProto) { + t.Fatalf("wrong address: got %s want %s", proto, + r.Header.Get(xForwardedProto)) + } + +} diff --git a/vendor/github.com/gorilla/handlers/recovery.go b/vendor/github.com/gorilla/handlers/recovery.go new file mode 100644 index 00000000..65b7de58 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/recovery.go @@ -0,0 +1,86 @@ +package handlers + +import ( + "log" + "net/http" + "runtime/debug" +) + +type recoveryHandler struct { + handler http.Handler + logger *log.Logger + printStack bool +} + +// RecoveryOption provides a functional approach to define +// configuration for a handler; such as setting the logging +// whether or not to print strack traces on panic. +type RecoveryOption func(http.Handler) + +func parseRecoveryOptions(h http.Handler, opts ...RecoveryOption) http.Handler { + for _, option := range opts { + option(h) + } + + return h +} + +// RecoveryHandler is HTTP middleware that recovers from a panic, +// logs the panic, writes http.StatusInternalServerError, and +// continues to the next handler. +// +// Example: +// +// r := mux.NewRouter() +// r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { +// panic("Unexpected error!") +// }) +// +// http.ListenAndServe(":1123", handlers.RecoveryHandler()(r)) +func RecoveryHandler(opts ...RecoveryOption) func(h http.Handler) http.Handler { + return func(h http.Handler) http.Handler { + r := &recoveryHandler{handler: h} + return parseRecoveryOptions(r, opts...) + } +} + +// RecoveryLogger is a functional option to override +// the default logger +func RecoveryLogger(logger *log.Logger) RecoveryOption { + return func(h http.Handler) { + r := h.(*recoveryHandler) + r.logger = logger + } +} + +// PrintRecoveryStack is a functional option to enable +// or disable printing stack traces on panic. +func PrintRecoveryStack(print bool) RecoveryOption { + return func(h http.Handler) { + r := h.(*recoveryHandler) + r.printStack = print + } +} + +func (h recoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + defer func() { + if err := recover(); err != nil { + w.WriteHeader(http.StatusInternalServerError) + h.log(err) + } + }() + + h.handler.ServeHTTP(w, req) +} + +func (h recoveryHandler) log(message interface{}) { + if h.logger != nil { + h.logger.Println(message) + } else { + log.Println(message) + } + + if h.printStack { + debug.PrintStack() + } +} diff --git a/vendor/github.com/gorilla/handlers/recovery_test.go b/vendor/github.com/gorilla/handlers/recovery_test.go new file mode 100644 index 00000000..1ae0e580 --- /dev/null +++ b/vendor/github.com/gorilla/handlers/recovery_test.go @@ -0,0 +1,44 @@ +package handlers + +import ( + "bytes" + "log" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestRecoveryLoggerWithDefaultOptions(t *testing.T) { + var buf bytes.Buffer + log.SetOutput(&buf) + + handler := RecoveryHandler() + handlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + panic("Unexpected error!") + }) + + recovery := handler(handlerFunc) + recovery.ServeHTTP(httptest.NewRecorder(), newRequest("GET", "/subdir/asdf")) + + if !strings.Contains(buf.String(), "Unexpected error!") { + t.Fatalf("Got log %#v, wanted substring %#v", buf.String(), "Unexpected error!") + } +} + +func TestRecoveryLoggerWithCustomLogger(t *testing.T) { + var buf bytes.Buffer + var logger = log.New(&buf, "", log.LstdFlags) + + handler := RecoveryHandler(RecoveryLogger(logger), PrintRecoveryStack(false)) + handlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + panic("Unexpected error!") + }) + + recovery := handler(handlerFunc) + recovery.ServeHTTP(httptest.NewRecorder(), newRequest("GET", "/subdir/asdf")) + + if !strings.Contains(buf.String(), "Unexpected error!") { + t.Fatalf("Got log %#v, wanted substring %#v", buf.String(), "Unexpected error!") + } +} diff --git a/vendor/github.com/gorilla/mux/.travis.yml b/vendor/github.com/gorilla/mux/.travis.yml new file mode 100644 index 00000000..4dcdacb6 --- /dev/null +++ b/vendor/github.com/gorilla/mux/.travis.yml @@ -0,0 +1,20 @@ +language: go +sudo: false + +matrix: + include: + - go: 1.2 + - go: 1.3 + - go: 1.4 + - go: 1.5 + - go: 1.6 + - go: tip + +install: + - go get golang.org/x/tools/cmd/vet + +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d .) + - go tool vet . + - go test -v -race ./... diff --git a/vendor/github.com/gorilla/mux/LICENSE b/vendor/github.com/gorilla/mux/LICENSE new file mode 100644 index 00000000..0e5fb872 --- /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/README.md b/vendor/github.com/gorilla/mux/README.md new file mode 100644 index 00000000..9516c519 --- /dev/null +++ b/vendor/github.com/gorilla/mux/README.md @@ -0,0 +1,242 @@ +mux +=== +[![GoDoc](https://godoc.org/github.com/gorilla/mux?status.svg)](https://godoc.org/github.com/gorilla/mux) +[![Build Status](https://travis-ci.org/gorilla/mux.svg?branch=master)](https://travis-ci.org/gorilla/mux) + +http://www.gorillatoolkit.org/pkg/mux + +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: + +```go +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: + +```go +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()`: + +```go +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: + +```go +r := mux.NewRouter() +// Only matches if domain is "www.example.com". +r.Host("www.example.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: + +```go +r.PathPrefix("/products/") +``` + +...or HTTP methods: + +```go +r.Methods("GET", "POST") +``` + +...or URL schemes: + +```go +r.Schemes("https") +``` + +...or header values: + +```go +r.Headers("X-Requested-With", "XMLHttpRequest") +``` + +...or query values: + +```go +r.Queries("key", "value") +``` + +...or to use a custom matcher function: + +```go +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: + +```go +r.HandleFunc("/products", ProductsHandler). + Host("www.example.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.example.com`. Create a route for that host and get a "subrouter" from it: + +```go +r := mux.NewRouter() +s := r.Host("www.example.com").Subrouter() +``` + +Then register routes in the subrouter: + +```go +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.example.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: + +```go +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: + +```go +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: + +```go +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: + +```go +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. + +Regex support also exists for matching Headers within a route. For example, we could do: + +```go +r.HeadersRegexp("Content-Type", "application/(text|json)") +``` + +...and the route will match both requests with a Content-Type of `application/json` as well as `application/text` + +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: + +```go +// "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: + +```go +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") +``` + +## Full Example + +Here's a complete, runnable example of a small `mux` based server: + +```go +package main + +import ( + "net/http" + + "github.com/gorilla/mux" +) + +func YourHandler(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("Gorilla!\n")) +} + +func main() { + r := mux.NewRouter() + // Routes consist of a path and a handler function. + r.HandleFunc("/", YourHandler) + + // Bind to a port and pass our router in + http.ListenAndServe(":8000", r) +} +``` + +## License + +BSD licensed. See the LICENSE file for details. diff --git a/vendor/github.com/gorilla/mux/bench_test.go b/vendor/github.com/gorilla/mux/bench_test.go new file mode 100644 index 00000000..946289b9 --- /dev/null +++ b/vendor/github.com/gorilla/mux/bench_test.go @@ -0,0 +1,49 @@ +// 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 ( + "net/http" + "net/http/httptest" + "testing" +) + +func BenchmarkMux(b *testing.B) { + router := new(Router) + handler := func(w http.ResponseWriter, r *http.Request) {} + router.HandleFunc("/v1/{v1}", handler) + + request, _ := http.NewRequest("GET", "/v1/anything", nil) + for i := 0; i < b.N; i++ { + router.ServeHTTP(nil, request) + } +} + +func BenchmarkMuxAlternativeInRegexp(b *testing.B) { + router := new(Router) + handler := func(w http.ResponseWriter, r *http.Request) {} + router.HandleFunc("/v1/{v1:(a|b)}", handler) + + requestA, _ := http.NewRequest("GET", "/v1/a", nil) + requestB, _ := http.NewRequest("GET", "/v1/b", nil) + for i := 0; i < b.N; i++ { + router.ServeHTTP(nil, requestA) + router.ServeHTTP(nil, requestB) + } +} + +func BenchmarkManyPathVariables(b *testing.B) { + router := new(Router) + handler := func(w http.ResponseWriter, r *http.Request) {} + router.HandleFunc("/v1/{v1}/{v2}/{v3}/{v4}/{v5}", handler) + + matchingRequest, _ := http.NewRequest("GET", "/v1/1/2/3/4/5", nil) + notMatchingRequest, _ := http.NewRequest("GET", "/v1/1/2/3/4", nil) + recorder := httptest.NewRecorder() + for i := 0; i < b.N; i++ { + router.ServeHTTP(nil, matchingRequest) + router.ServeHTTP(recorder, notMatchingRequest) + } +} diff --git a/vendor/github.com/gorilla/mux/doc.go b/vendor/github.com/gorilla/mux/doc.go new file mode 100644 index 00000000..835f5342 --- /dev/null +++ b/vendor/github.com/gorilla/mux/doc.go @@ -0,0 +1,206 @@ +// 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 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.example.com". + r.Host("www.example.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.example.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.example.com". Create a route for that host and get a "subrouter" +from it: + + r := mux.NewRouter() + s := r.Host("www.example.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.example.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. + +Regex support also exists for matching Headers within a route. For example, we could do: + + r.HeadersRegexp("Content-Type", "application/(text|json)") + +...and the route will match both requests with a Content-Type of `application/json` as well as +`application/text` + +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 00000000..fbb7f19a --- /dev/null +++ b/vendor/github.com/gorilla/mux/mux.go @@ -0,0 +1,481 @@ +// 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" + "path" + "regexp" + + "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 + } + } + + // Closest match for a router (includes sub-routers) + if r.NotFoundHandler != nil { + match.Handler = r.NotFoundHandler + 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 dropping 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 = 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 +} + +func (r *Router) buildVars(m map[string]string) map[string]string { + if r.parent != nil { + m = r.parent.buildVars(m) + } + return m +} + +// ---------------------------------------------------------------------------- +// 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...) +} + +// BuildVarsFunc registers a new route with a custom function for modifying +// route variables before building a URL. +func (r *Router) BuildVarsFunc(f BuildVarsFunc) *Route { + return r.NewRoute().BuildVarsFunc(f) +} + +// Walk walks the router and all its sub-routers, calling walkFn for each route +// in the tree. The routes are walked in the order they were added. Sub-routers +// are explored depth-first. +func (r *Router) Walk(walkFn WalkFunc) error { + return r.walk(walkFn, []*Route{}) +} + +// SkipRouter is used as a return value from WalkFuncs to indicate that the +// router that walk is about to descend down to should be skipped. +var SkipRouter = errors.New("skip this router") + +// WalkFunc is the type of the function called for each route visited by Walk. +// At every invocation, it is given the current route, and the current router, +// and a list of ancestor routes that lead to the current route. +type WalkFunc func(route *Route, router *Router, ancestors []*Route) error + +func (r *Router) walk(walkFn WalkFunc, ancestors []*Route) error { + for _, t := range r.routes { + if t.regexp == nil || t.regexp.path == nil || t.regexp.path.template == "" { + continue + } + + err := walkFn(t, r, ancestors) + if err == SkipRouter { + continue + } + for _, sr := range t.matchers { + if h, ok := sr.(*Router); ok { + err := h.walk(walkFn, ancestors) + if err != nil { + return err + } + } + } + if h, ok := t.handler.(*Router); ok { + ancestors = append(ancestors, t) + err := h.walk(walkFn, ancestors) + if err != nil { + return err + } + ancestors = ancestors[:len(ancestors)-1] + } + } + return nil +} + +// ---------------------------------------------------------------------------- +// 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. +// This only works when called inside the handler of the matched route +// because the matched route is stored in the request context which is cleared +// after the handler returns, unless the KeepContext option is set on the +// Router. +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{}) { + if val != nil { + context.Set(r, varsKey, val) + } +} + +func setCurrentRoute(r *http.Request, val interface{}) { + if val != nil { + 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 +} + +// checkPairs returns the count of strings passed in, and an error if +// the count is not an even number. +func checkPairs(pairs ...string) (int, error) { + length := len(pairs) + if length%2 != 0 { + return length, fmt.Errorf( + "mux: number of parameters must be multiple of 2, got %v", pairs) + } + return length, nil +} + +// mapFromPairsToString converts variadic string parameters to a +// string to string map. +func mapFromPairsToString(pairs ...string) (map[string]string, error) { + length, err := checkPairs(pairs...) + if err != nil { + return nil, err + } + m := make(map[string]string, length/2) + for i := 0; i < length; i += 2 { + m[pairs[i]] = pairs[i+1] + } + return m, nil +} + +// mapFromPairsToRegex converts variadic string paramers to a +// string to regex map. +func mapFromPairsToRegex(pairs ...string) (map[string]*regexp.Regexp, error) { + length, err := checkPairs(pairs...) + if err != nil { + return nil, err + } + m := make(map[string]*regexp.Regexp, length/2) + for i := 0; i < length; i += 2 { + regex, err := regexp.Compile(pairs[i+1]) + if err != nil { + return nil, err + } + m[pairs[i]] = regex + } + 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 +} + +// matchMapWithString returns true if the given key/value pairs exist in a given map. +func matchMapWithString(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 +} + +// matchMapWithRegex returns true if the given key/value pairs exist in a given map compiled against +// the given regex +func matchMapWithRegex(toCheck map[string]*regexp.Regexp, 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 != nil { + // 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.MatchString(value) { + valueExists = true + break + } + } + if !valueExists { + return false + } + } + } + return true +} diff --git a/vendor/github.com/gorilla/mux/mux_test.go b/vendor/github.com/gorilla/mux/mux_test.go new file mode 100644 index 00000000..a44d03f8 --- /dev/null +++ b/vendor/github.com/gorilla/mux/mux_test.go @@ -0,0 +1,1453 @@ +// 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" + "strings" + "testing" + + "github.com/gorilla/context" +) + +func (r *Route) GoString() string { + matchers := make([]string, len(r.matchers)) + for i, m := range r.matchers { + matchers[i] = fmt.Sprintf("%#v", m) + } + return fmt.Sprintf("&Route{matchers:[]matcher{%s}}", strings.Join(matchers, ", ")) +} + +func (r *routeRegexp) GoString() string { + return fmt.Sprintf("&routeRegexp{template: %q, matchHost: %t, matchQuery: %t, strictSlash: %t, regexp: regexp.MustCompile(%q), reverse: %q, varsN: %v, varsR: %v", r.template, r.matchHost, r.matchQuery, r.strictSlash, r.regexp.String(), r.reverse, r.varsN, r.varsR) +} + +type routeTest struct { + title string // title of the test + route *Route // the route being tested + request *http.Request // a request to test the route + vars map[string]string // the expected vars of the match + host string // the expected host of the match + path string // the expected path of the match + path_template string // the expected path template to match + host_template string // the expected host template to match + shouldMatch bool // whether the request is expected to match the route at all + shouldRedirect bool // whether the request should result in a redirect +} + +func TestHost(t *testing.T) { + // newRequestHost a new request with a method, url, and host header + newRequestHost := func(method, url, host string) *http.Request { + req, err := http.NewRequest(method, url, nil) + if err != nil { + panic(err) + } + req.Host = host + return req + } + + tests := []routeTest{ + { + title: "Host route match", + route: new(Route).Host("aaa.bbb.ccc"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{}, + host: "aaa.bbb.ccc", + path: "", + shouldMatch: true, + }, + { + title: "Host route, wrong host in request URL", + route: new(Route).Host("aaa.bbb.ccc"), + request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), + vars: map[string]string{}, + host: "aaa.bbb.ccc", + path: "", + shouldMatch: false, + }, + { + title: "Host route with port, match", + route: new(Route).Host("aaa.bbb.ccc:1234"), + request: newRequest("GET", "http://aaa.bbb.ccc:1234/111/222/333"), + vars: map[string]string{}, + host: "aaa.bbb.ccc:1234", + path: "", + shouldMatch: true, + }, + { + title: "Host route with port, wrong port in request URL", + route: new(Route).Host("aaa.bbb.ccc:1234"), + request: newRequest("GET", "http://aaa.bbb.ccc:9999/111/222/333"), + vars: map[string]string{}, + host: "aaa.bbb.ccc:1234", + path: "", + shouldMatch: false, + }, + { + title: "Host route, match with host in request header", + route: new(Route).Host("aaa.bbb.ccc"), + request: newRequestHost("GET", "/111/222/333", "aaa.bbb.ccc"), + vars: map[string]string{}, + host: "aaa.bbb.ccc", + path: "", + shouldMatch: true, + }, + { + title: "Host route, wrong host in request header", + route: new(Route).Host("aaa.bbb.ccc"), + request: newRequestHost("GET", "/111/222/333", "aaa.222.ccc"), + vars: map[string]string{}, + host: "aaa.bbb.ccc", + path: "", + shouldMatch: false, + }, + // BUG {new(Route).Host("aaa.bbb.ccc:1234"), newRequestHost("GET", "/111/222/333", "aaa.bbb.ccc:1234"), map[string]string{}, "aaa.bbb.ccc:1234", "", true}, + { + title: "Host route with port, wrong host in request header", + route: new(Route).Host("aaa.bbb.ccc:1234"), + request: newRequestHost("GET", "/111/222/333", "aaa.bbb.ccc:9999"), + vars: map[string]string{}, + host: "aaa.bbb.ccc:1234", + path: "", + shouldMatch: false, + }, + { + title: "Host route with pattern, match", + route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v1": "bbb"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `aaa.{v1:[a-z]{3}}.ccc`, + shouldMatch: true, + }, + { + title: "Host route with pattern, additional capturing group, match", + route: new(Route).Host("aaa.{v1:[a-z]{2}(b|c)}.ccc"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v1": "bbb"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `aaa.{v1:[a-z]{2}(b|c)}.ccc`, + shouldMatch: true, + }, + { + title: "Host route with pattern, wrong host in request URL", + route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc"), + request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), + vars: map[string]string{"v1": "bbb"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `aaa.{v1:[a-z]{3}}.ccc`, + shouldMatch: false, + }, + { + title: "Host route with multiple patterns, match", + route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, + shouldMatch: true, + }, + { + title: "Host route with multiple patterns, wrong host in request URL", + route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}"), + request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), + vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, + shouldMatch: false, + }, + { + title: "Host route with hyphenated name and pattern, match", + route: new(Route).Host("aaa.{v-1:[a-z]{3}}.ccc"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v-1": "bbb"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `aaa.{v-1:[a-z]{3}}.ccc`, + shouldMatch: true, + }, + { + title: "Host route with hyphenated name and pattern, additional capturing group, match", + route: new(Route).Host("aaa.{v-1:[a-z]{2}(b|c)}.ccc"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v-1": "bbb"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `aaa.{v-1:[a-z]{2}(b|c)}.ccc`, + shouldMatch: true, + }, + { + title: "Host route with multiple hyphenated names and patterns, match", + route: new(Route).Host("{v-1:[a-z]{3}}.{v-2:[a-z]{3}}.{v-3:[a-z]{3}}"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v-1": "aaa", "v-2": "bbb", "v-3": "ccc"}, + host: "aaa.bbb.ccc", + path: "", + host_template: `{v-1:[a-z]{3}}.{v-2:[a-z]{3}}.{v-3:[a-z]{3}}`, + shouldMatch: true, + }, + { + title: "Path route with single pattern with pipe, match", + route: new(Route).Path("/{category:a|b/c}"), + request: newRequest("GET", "http://localhost/a"), + vars: map[string]string{"category": "a"}, + host: "", + path: "/a", + path_template: `/{category:a|b/c}`, + shouldMatch: true, + }, + { + title: "Path route with single pattern with pipe, match", + route: new(Route).Path("/{category:a|b/c}"), + request: newRequest("GET", "http://localhost/b/c"), + vars: map[string]string{"category": "b/c"}, + host: "", + path: "/b/c", + path_template: `/{category:a|b/c}`, + shouldMatch: true, + }, + { + title: "Path route with multiple patterns with pipe, match", + route: new(Route).Path("/{category:a|b/c}/{product}/{id:[0-9]+}"), + request: newRequest("GET", "http://localhost/a/product_name/1"), + vars: map[string]string{"category": "a", "product": "product_name", "id": "1"}, + host: "", + path: "/a/product_name/1", + path_template: `/{category:a|b/c}/{product}/{id:[0-9]+}`, + shouldMatch: true, + }, + { + title: "Path route with multiple patterns with pipe, match", + route: new(Route).Path("/{category:a|b/c}/{product}/{id:[0-9]+}"), + request: newRequest("GET", "http://localhost/b/c/product_name/1"), + vars: map[string]string{"category": "b/c", "product": "product_name", "id": "1"}, + host: "", + path: "/b/c/product_name/1", + path_template: `/{category:a|b/c}/{product}/{id:[0-9]+}`, + shouldMatch: true, + }, + } + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestPath(t *testing.T) { + tests := []routeTest{ + { + title: "Path route, match", + route: new(Route).Path("/111/222/333"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{}, + host: "", + path: "/111/222/333", + shouldMatch: true, + }, + { + title: "Path route, match with trailing slash in request and path", + route: new(Route).Path("/111/"), + request: newRequest("GET", "http://localhost/111/"), + vars: map[string]string{}, + host: "", + path: "/111/", + shouldMatch: true, + }, + { + title: "Path route, do not match with trailing slash in path", + route: new(Route).Path("/111/"), + request: newRequest("GET", "http://localhost/111"), + vars: map[string]string{}, + host: "", + path: "/111", + path_template: `/111/`, + shouldMatch: false, + }, + { + title: "Path route, do not match with trailing slash in request", + route: new(Route).Path("/111"), + request: newRequest("GET", "http://localhost/111/"), + vars: map[string]string{}, + host: "", + path: "/111/", + path_template: `/111`, + shouldMatch: false, + }, + { + title: "Path route, wrong path in request in request URL", + route: new(Route).Path("/111/222/333"), + request: newRequest("GET", "http://localhost/1/2/3"), + vars: map[string]string{}, + host: "", + path: "/111/222/333", + shouldMatch: false, + }, + { + title: "Path route with pattern, match", + route: new(Route).Path("/111/{v1:[0-9]{3}}/333"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{"v1": "222"}, + host: "", + path: "/111/222/333", + path_template: `/111/{v1:[0-9]{3}}/333`, + shouldMatch: true, + }, + { + title: "Path route with pattern, URL in request does not match", + route: new(Route).Path("/111/{v1:[0-9]{3}}/333"), + request: newRequest("GET", "http://localhost/111/aaa/333"), + vars: map[string]string{"v1": "222"}, + host: "", + path: "/111/222/333", + path_template: `/111/{v1:[0-9]{3}}/333`, + shouldMatch: false, + }, + { + title: "Path route with multiple patterns, match", + route: new(Route).Path("/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{"v1": "111", "v2": "222", "v3": "333"}, + host: "", + path: "/111/222/333", + path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}`, + shouldMatch: true, + }, + { + title: "Path route with multiple patterns, URL in request does not match", + route: new(Route).Path("/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/aaa/333"), + vars: map[string]string{"v1": "111", "v2": "222", "v3": "333"}, + host: "", + path: "/111/222/333", + path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}`, + shouldMatch: false, + }, + { + title: "Path route with multiple patterns with pipe, match", + route: new(Route).Path("/{category:a|(b/c)}/{product}/{id:[0-9]+}"), + request: newRequest("GET", "http://localhost/a/product_name/1"), + vars: map[string]string{"category": "a", "product": "product_name", "id": "1"}, + host: "", + path: "/a/product_name/1", + path_template: `/{category:a|(b/c)}/{product}/{id:[0-9]+}`, + shouldMatch: true, + }, + { + title: "Path route with hyphenated name and pattern, match", + route: new(Route).Path("/111/{v-1:[0-9]{3}}/333"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{"v-1": "222"}, + host: "", + path: "/111/222/333", + path_template: `/111/{v-1:[0-9]{3}}/333`, + shouldMatch: true, + }, + { + title: "Path route with multiple hyphenated names and patterns, match", + route: new(Route).Path("/{v-1:[0-9]{3}}/{v-2:[0-9]{3}}/{v-3:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{"v-1": "111", "v-2": "222", "v-3": "333"}, + host: "", + path: "/111/222/333", + path_template: `/{v-1:[0-9]{3}}/{v-2:[0-9]{3}}/{v-3:[0-9]{3}}`, + shouldMatch: true, + }, + { + title: "Path route with multiple hyphenated names and patterns with pipe, match", + route: new(Route).Path("/{product-category:a|(b/c)}/{product-name}/{product-id:[0-9]+}"), + request: newRequest("GET", "http://localhost/a/product_name/1"), + vars: map[string]string{"product-category": "a", "product-name": "product_name", "product-id": "1"}, + host: "", + path: "/a/product_name/1", + path_template: `/{product-category:a|(b/c)}/{product-name}/{product-id:[0-9]+}`, + shouldMatch: true, + }, + { + title: "Path route with multiple hyphenated names and patterns with pipe and case insensitive, match", + route: new(Route).Path("/{type:(?i:daily|mini|variety)}-{date:\\d{4,4}-\\d{2,2}-\\d{2,2}}"), + request: newRequest("GET", "http://localhost/daily-2016-01-01"), + vars: map[string]string{"type": "daily", "date": "2016-01-01"}, + host: "", + path: "/daily-2016-01-01", + path_template: `/{type:(?i:daily|mini|variety)}-{date:\d{4,4}-\d{2,2}-\d{2,2}}`, + shouldMatch: true, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestPathPrefix(t *testing.T) { + tests := []routeTest{ + { + title: "PathPrefix route, match", + route: new(Route).PathPrefix("/111"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{}, + host: "", + path: "/111", + shouldMatch: true, + }, + { + title: "PathPrefix route, match substring", + route: new(Route).PathPrefix("/1"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{}, + host: "", + path: "/1", + shouldMatch: true, + }, + { + title: "PathPrefix route, URL prefix in request does not match", + route: new(Route).PathPrefix("/111"), + request: newRequest("GET", "http://localhost/1/2/3"), + vars: map[string]string{}, + host: "", + path: "/111", + shouldMatch: false, + }, + { + title: "PathPrefix route with pattern, match", + route: new(Route).PathPrefix("/111/{v1:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{"v1": "222"}, + host: "", + path: "/111/222", + path_template: `/111/{v1:[0-9]{3}}`, + shouldMatch: true, + }, + { + title: "PathPrefix route with pattern, URL prefix in request does not match", + route: new(Route).PathPrefix("/111/{v1:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/aaa/333"), + vars: map[string]string{"v1": "222"}, + host: "", + path: "/111/222", + path_template: `/111/{v1:[0-9]{3}}`, + shouldMatch: false, + }, + { + title: "PathPrefix route with multiple patterns, match", + route: new(Route).PathPrefix("/{v1:[0-9]{3}}/{v2:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/222/333"), + vars: map[string]string{"v1": "111", "v2": "222"}, + host: "", + path: "/111/222", + path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}`, + shouldMatch: true, + }, + { + title: "PathPrefix route with multiple patterns, URL prefix in request does not match", + route: new(Route).PathPrefix("/{v1:[0-9]{3}}/{v2:[0-9]{3}}"), + request: newRequest("GET", "http://localhost/111/aaa/333"), + vars: map[string]string{"v1": "111", "v2": "222"}, + host: "", + path: "/111/222", + path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}`, + shouldMatch: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestHostPath(t *testing.T) { + tests := []routeTest{ + { + title: "Host and Path route, match", + route: new(Route).Host("aaa.bbb.ccc").Path("/111/222/333"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{}, + host: "", + path: "", + path_template: `/111/222/333`, + host_template: `aaa.bbb.ccc`, + shouldMatch: true, + }, + { + title: "Host and Path route, wrong host in request URL", + route: new(Route).Host("aaa.bbb.ccc").Path("/111/222/333"), + request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), + vars: map[string]string{}, + host: "", + path: "", + path_template: `/111/222/333`, + host_template: `aaa.bbb.ccc`, + shouldMatch: false, + }, + { + title: "Host and Path route with pattern, match", + route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc").Path("/111/{v2:[0-9]{3}}/333"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v1": "bbb", "v2": "222"}, + host: "aaa.bbb.ccc", + path: "/111/222/333", + path_template: `/111/{v2:[0-9]{3}}/333`, + host_template: `aaa.{v1:[a-z]{3}}.ccc`, + shouldMatch: true, + }, + { + title: "Host and Path route with pattern, URL in request does not match", + route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc").Path("/111/{v2:[0-9]{3}}/333"), + request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), + vars: map[string]string{"v1": "bbb", "v2": "222"}, + host: "aaa.bbb.ccc", + path: "/111/222/333", + path_template: `/111/{v2:[0-9]{3}}/333`, + host_template: `aaa.{v1:[a-z]{3}}.ccc`, + shouldMatch: false, + }, + { + title: "Host and Path route with multiple patterns, match", + route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}").Path("/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}"), + request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), + vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc", "v4": "111", "v5": "222", "v6": "333"}, + host: "aaa.bbb.ccc", + path: "/111/222/333", + path_template: `/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}`, + host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, + shouldMatch: true, + }, + { + title: "Host and Path route with multiple patterns, URL in request does not match", + route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}").Path("/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}"), + request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), + vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc", "v4": "111", "v5": "222", "v6": "333"}, + host: "aaa.bbb.ccc", + path: "/111/222/333", + path_template: `/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}`, + host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, + shouldMatch: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestHeaders(t *testing.T) { + // newRequestHeaders creates a new request with a method, url, and headers + newRequestHeaders := func(method, url string, headers map[string]string) *http.Request { + req, err := http.NewRequest(method, url, nil) + if err != nil { + panic(err) + } + for k, v := range headers { + req.Header.Add(k, v) + } + return req + } + + tests := []routeTest{ + { + title: "Headers route, match", + route: new(Route).Headers("foo", "bar", "baz", "ding"), + request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "bar", "baz": "ding"}), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Headers route, bad header values", + route: new(Route).Headers("foo", "bar", "baz", "ding"), + request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "bar", "baz": "dong"}), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Headers route, regex header values to match", + route: new(Route).Headers("foo", "ba[zr]"), + request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "bar"}), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Headers route, regex header values to match", + route: new(Route).HeadersRegexp("foo", "ba[zr]"), + request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "baz"}), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } + +} + +func TestMethods(t *testing.T) { + tests := []routeTest{ + { + title: "Methods route, match GET", + route: new(Route).Methods("GET", "POST"), + request: newRequest("GET", "http://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Methods route, match POST", + route: new(Route).Methods("GET", "POST"), + request: newRequest("POST", "http://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Methods route, bad method", + route: new(Route).Methods("GET", "POST"), + request: newRequest("PUT", "http://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestQueries(t *testing.T) { + tests := []routeTest{ + { + title: "Queries route, match", + route: new(Route).Queries("foo", "bar", "baz", "ding"), + request: newRequest("GET", "http://localhost?foo=bar&baz=ding"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route, match with a query string", + route: new(Route).Host("www.example.com").Path("/api").Queries("foo", "bar", "baz", "ding"), + request: newRequest("GET", "http://www.example.com/api?foo=bar&baz=ding"), + vars: map[string]string{}, + host: "", + path: "", + path_template: `/api`, + host_template: `www.example.com`, + shouldMatch: true, + }, + { + title: "Queries route, match with a query string out of order", + route: new(Route).Host("www.example.com").Path("/api").Queries("foo", "bar", "baz", "ding"), + request: newRequest("GET", "http://www.example.com/api?baz=ding&foo=bar"), + vars: map[string]string{}, + host: "", + path: "", + path_template: `/api`, + host_template: `www.example.com`, + shouldMatch: true, + }, + { + title: "Queries route, bad query", + route: new(Route).Queries("foo", "bar", "baz", "ding"), + request: newRequest("GET", "http://localhost?foo=bar&baz=dong"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with pattern, match", + route: new(Route).Queries("foo", "{v1}"), + request: newRequest("GET", "http://localhost?foo=bar"), + vars: map[string]string{"v1": "bar"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with multiple patterns, match", + route: new(Route).Queries("foo", "{v1}", "baz", "{v2}"), + request: newRequest("GET", "http://localhost?foo=bar&baz=ding"), + vars: map[string]string{"v1": "bar", "v2": "ding"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with regexp pattern, match", + route: new(Route).Queries("foo", "{v1:[0-9]+}"), + request: newRequest("GET", "http://localhost?foo=10"), + vars: map[string]string{"v1": "10"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with regexp pattern, regexp does not match", + route: new(Route).Queries("foo", "{v1:[0-9]+}"), + request: newRequest("GET", "http://localhost?foo=a"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with regexp pattern with quantifier, match", + route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), + request: newRequest("GET", "http://localhost?foo=1"), + vars: map[string]string{"v1": "1"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with regexp pattern with quantifier, additional variable in query string, match", + route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), + request: newRequest("GET", "http://localhost?bar=2&foo=1"), + vars: map[string]string{"v1": "1"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with regexp pattern with quantifier, regexp does not match", + route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), + request: newRequest("GET", "http://localhost?foo=12"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with regexp pattern with quantifier, additional capturing group", + route: new(Route).Queries("foo", "{v1:[0-9]{1}(a|b)}"), + request: newRequest("GET", "http://localhost?foo=1a"), + vars: map[string]string{"v1": "1a"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with regexp pattern with quantifier, additional variable in query string, regexp does not match", + route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), + request: newRequest("GET", "http://localhost?foo=12"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with hyphenated name, match", + route: new(Route).Queries("foo", "{v-1}"), + request: newRequest("GET", "http://localhost?foo=bar"), + vars: map[string]string{"v-1": "bar"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with multiple hyphenated names, match", + route: new(Route).Queries("foo", "{v-1}", "baz", "{v-2}"), + request: newRequest("GET", "http://localhost?foo=bar&baz=ding"), + vars: map[string]string{"v-1": "bar", "v-2": "ding"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with hyphenate name and pattern, match", + route: new(Route).Queries("foo", "{v-1:[0-9]+}"), + request: newRequest("GET", "http://localhost?foo=10"), + vars: map[string]string{"v-1": "10"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with hyphenated name and pattern with quantifier, additional capturing group", + route: new(Route).Queries("foo", "{v-1:[0-9]{1}(a|b)}"), + request: newRequest("GET", "http://localhost?foo=1a"), + vars: map[string]string{"v-1": "1a"}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with empty value, should match", + route: new(Route).Queries("foo", ""), + request: newRequest("GET", "http://localhost?foo=bar"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with empty value and no parameter in request, should not match", + route: new(Route).Queries("foo", ""), + request: newRequest("GET", "http://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with empty value and empty parameter in request, should match", + route: new(Route).Queries("foo", ""), + request: newRequest("GET", "http://localhost?foo="), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route with overlapping value, should not match", + route: new(Route).Queries("foo", "bar"), + request: newRequest("GET", "http://localhost?foo=barfoo"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with no parameter in request, should not match", + route: new(Route).Queries("foo", "{bar}"), + request: newRequest("GET", "http://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + { + title: "Queries route with empty parameter in request, should match", + route: new(Route).Queries("foo", "{bar}"), + request: newRequest("GET", "http://localhost?foo="), + vars: map[string]string{"foo": ""}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Queries route, bad submatch", + route: new(Route).Queries("foo", "bar", "baz", "ding"), + request: newRequest("GET", "http://localhost?fffoo=bar&baz=dingggg"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestSchemes(t *testing.T) { + tests := []routeTest{ + // Schemes + { + title: "Schemes route, match https", + route: new(Route).Schemes("https", "ftp"), + request: newRequest("GET", "https://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Schemes route, match ftp", + route: new(Route).Schemes("https", "ftp"), + request: newRequest("GET", "ftp://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "Schemes route, bad scheme", + route: new(Route).Schemes("https", "ftp"), + request: newRequest("GET", "http://localhost"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + } + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestMatcherFunc(t *testing.T) { + m := func(r *http.Request, m *RouteMatch) bool { + if r.URL.Host == "aaa.bbb.ccc" { + return true + } + return false + } + + tests := []routeTest{ + { + title: "MatchFunc route, match", + route: new(Route).MatcherFunc(m), + request: newRequest("GET", "http://aaa.bbb.ccc"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: true, + }, + { + title: "MatchFunc route, non-match", + route: new(Route).MatcherFunc(m), + request: newRequest("GET", "http://aaa.222.ccc"), + vars: map[string]string{}, + host: "", + path: "", + shouldMatch: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestBuildVarsFunc(t *testing.T) { + tests := []routeTest{ + { + title: "BuildVarsFunc set on route", + route: new(Route).Path(`/111/{v1:\d}{v2:.*}`).BuildVarsFunc(func(vars map[string]string) map[string]string { + vars["v1"] = "3" + vars["v2"] = "a" + return vars + }), + request: newRequest("GET", "http://localhost/111/2"), + path: "/111/3a", + path_template: `/111/{v1:\d}{v2:.*}`, + shouldMatch: true, + }, + { + title: "BuildVarsFunc set on route and parent route", + route: new(Route).PathPrefix(`/{v1:\d}`).BuildVarsFunc(func(vars map[string]string) map[string]string { + vars["v1"] = "2" + return vars + }).Subrouter().Path(`/{v2:\w}`).BuildVarsFunc(func(vars map[string]string) map[string]string { + vars["v2"] = "b" + return vars + }), + request: newRequest("GET", "http://localhost/1/a"), + path: "/2/b", + path_template: `/{v1:\d}/{v2:\w}`, + shouldMatch: true, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestSubRouter(t *testing.T) { + subrouter1 := new(Route).Host("{v1:[a-z]+}.google.com").Subrouter() + subrouter2 := new(Route).PathPrefix("/foo/{v1}").Subrouter() + + tests := []routeTest{ + { + route: subrouter1.Path("/{v2:[a-z]+}"), + request: newRequest("GET", "http://aaa.google.com/bbb"), + vars: map[string]string{"v1": "aaa", "v2": "bbb"}, + host: "aaa.google.com", + path: "/bbb", + path_template: `/{v2:[a-z]+}`, + host_template: `{v1:[a-z]+}.google.com`, + shouldMatch: true, + }, + { + route: subrouter1.Path("/{v2:[a-z]+}"), + request: newRequest("GET", "http://111.google.com/111"), + vars: map[string]string{"v1": "aaa", "v2": "bbb"}, + host: "aaa.google.com", + path: "/bbb", + path_template: `/{v2:[a-z]+}`, + host_template: `{v1:[a-z]+}.google.com`, + shouldMatch: false, + }, + { + route: subrouter2.Path("/baz/{v2}"), + request: newRequest("GET", "http://localhost/foo/bar/baz/ding"), + vars: map[string]string{"v1": "bar", "v2": "ding"}, + host: "", + path: "/foo/bar/baz/ding", + path_template: `/foo/{v1}/baz/{v2}`, + shouldMatch: true, + }, + { + route: subrouter2.Path("/baz/{v2}"), + request: newRequest("GET", "http://localhost/foo/bar"), + vars: map[string]string{"v1": "bar", "v2": "ding"}, + host: "", + path: "/foo/bar/baz/ding", + path_template: `/foo/{v1}/baz/{v2}`, + shouldMatch: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestNamedRoutes(t *testing.T) { + r1 := NewRouter() + r1.NewRoute().Name("a") + r1.NewRoute().Name("b") + r1.NewRoute().Name("c") + + r2 := r1.NewRoute().Subrouter() + r2.NewRoute().Name("d") + r2.NewRoute().Name("e") + r2.NewRoute().Name("f") + + r3 := r2.NewRoute().Subrouter() + r3.NewRoute().Name("g") + r3.NewRoute().Name("h") + r3.NewRoute().Name("i") + + if r1.namedRoutes == nil || len(r1.namedRoutes) != 9 { + t.Errorf("Expected 9 named routes, got %v", r1.namedRoutes) + } else if r1.Get("i") == nil { + t.Errorf("Subroute name not registered") + } +} + +func TestStrictSlash(t *testing.T) { + r := NewRouter() + r.StrictSlash(true) + + tests := []routeTest{ + { + title: "Redirect path without slash", + route: r.NewRoute().Path("/111/"), + request: newRequest("GET", "http://localhost/111"), + vars: map[string]string{}, + host: "", + path: "/111/", + shouldMatch: true, + shouldRedirect: true, + }, + { + title: "Do not redirect path with slash", + route: r.NewRoute().Path("/111/"), + request: newRequest("GET", "http://localhost/111/"), + vars: map[string]string{}, + host: "", + path: "/111/", + shouldMatch: true, + shouldRedirect: false, + }, + { + title: "Redirect path with slash", + route: r.NewRoute().Path("/111"), + request: newRequest("GET", "http://localhost/111/"), + vars: map[string]string{}, + host: "", + path: "/111", + shouldMatch: true, + shouldRedirect: true, + }, + { + title: "Do not redirect path without slash", + route: r.NewRoute().Path("/111"), + request: newRequest("GET", "http://localhost/111"), + vars: map[string]string{}, + host: "", + path: "/111", + shouldMatch: true, + shouldRedirect: false, + }, + { + title: "Propagate StrictSlash to subrouters", + route: r.NewRoute().PathPrefix("/static/").Subrouter().Path("/images/"), + request: newRequest("GET", "http://localhost/static/images"), + vars: map[string]string{}, + host: "", + path: "/static/images/", + shouldMatch: true, + shouldRedirect: true, + }, + { + title: "Ignore StrictSlash for path prefix", + route: r.NewRoute().PathPrefix("/static/"), + request: newRequest("GET", "http://localhost/static/logo.png"), + vars: map[string]string{}, + host: "", + path: "/static/", + shouldMatch: true, + shouldRedirect: false, + }, + } + + for _, test := range tests { + testRoute(t, test) + testTemplate(t, test) + } +} + +func TestWalkSingleDepth(t *testing.T) { + r0 := NewRouter() + r1 := NewRouter() + r2 := NewRouter() + + r0.Path("/g") + r0.Path("/o") + r0.Path("/d").Handler(r1) + r0.Path("/r").Handler(r2) + r0.Path("/a") + + r1.Path("/z") + r1.Path("/i") + r1.Path("/l") + r1.Path("/l") + + r2.Path("/i") + r2.Path("/l") + r2.Path("/l") + + paths := []string{"g", "o", "r", "i", "l", "l", "a"} + depths := []int{0, 0, 0, 1, 1, 1, 0} + i := 0 + err := r0.Walk(func(route *Route, router *Router, ancestors []*Route) error { + matcher := route.matchers[0].(*routeRegexp) + if matcher.template == "/d" { + return SkipRouter + } + if len(ancestors) != depths[i] { + t.Errorf(`Expected depth of %d at i = %d; got "%d"`, depths[i], i, len(ancestors)) + } + if matcher.template != "/"+paths[i] { + t.Errorf(`Expected "/%s" at i = %d; got "%s"`, paths[i], i, matcher.template) + } + i++ + return nil + }) + if err != nil { + panic(err) + } + if i != len(paths) { + t.Errorf("Expected %d routes, found %d", len(paths), i) + } +} + +func TestWalkNested(t *testing.T) { + router := NewRouter() + + g := router.Path("/g").Subrouter() + o := g.PathPrefix("/o").Subrouter() + r := o.PathPrefix("/r").Subrouter() + i := r.PathPrefix("/i").Subrouter() + l1 := i.PathPrefix("/l").Subrouter() + l2 := l1.PathPrefix("/l").Subrouter() + l2.Path("/a") + + paths := []string{"/g", "/g/o", "/g/o/r", "/g/o/r/i", "/g/o/r/i/l", "/g/o/r/i/l/l", "/g/o/r/i/l/l/a"} + idx := 0 + err := router.Walk(func(route *Route, router *Router, ancestors []*Route) error { + path := paths[idx] + tpl := route.regexp.path.template + if tpl != path { + t.Errorf(`Expected %s got %s`, path, tpl) + } + idx++ + return nil + }) + if err != nil { + panic(err) + } + if idx != len(paths) { + t.Errorf("Expected %d routes, found %d", len(paths), idx) + } +} + +func TestSubrouterErrorHandling(t *testing.T) { + superRouterCalled := false + subRouterCalled := false + + router := NewRouter() + router.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + superRouterCalled = true + }) + subRouter := router.PathPrefix("/bign8").Subrouter() + subRouter.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + subRouterCalled = true + }) + + req, _ := http.NewRequest("GET", "http://localhost/bign8/was/here", nil) + router.ServeHTTP(NewRecorder(), req) + + if superRouterCalled { + t.Error("Super router 404 handler called when sub-router 404 handler is available.") + } + if !subRouterCalled { + t.Error("Sub-router 404 handler was not called.") + } +} + +// ---------------------------------------------------------------------------- +// Helpers +// ---------------------------------------------------------------------------- + +func getRouteTemplate(route *Route) string { + host, err := route.GetHostTemplate() + if err != nil { + host = "none" + } + path, err := route.GetPathTemplate() + if err != nil { + path = "none" + } + return fmt.Sprintf("Host: %v, Path: %v", host, path) +} + +func testRoute(t *testing.T, test routeTest) { + request := test.request + route := test.route + vars := test.vars + shouldMatch := test.shouldMatch + host := test.host + path := test.path + url := test.host + test.path + shouldRedirect := test.shouldRedirect + + var match RouteMatch + ok := route.Match(request, &match) + if ok != shouldMatch { + msg := "Should match" + if !shouldMatch { + msg = "Should not match" + } + t.Errorf("(%v) %v:\nRoute: %#v\nRequest: %#v\nVars: %v\n", test.title, msg, route, request, vars) + return + } + if shouldMatch { + if test.vars != nil && !stringMapEqual(test.vars, match.Vars) { + t.Errorf("(%v) Vars not equal: expected %v, got %v", test.title, vars, match.Vars) + return + } + if host != "" { + u, _ := test.route.URLHost(mapToPairs(match.Vars)...) + if host != u.Host { + t.Errorf("(%v) URLHost not equal: expected %v, got %v -- %v", test.title, host, u.Host, getRouteTemplate(route)) + return + } + } + if path != "" { + u, _ := route.URLPath(mapToPairs(match.Vars)...) + if path != u.Path { + t.Errorf("(%v) URLPath not equal: expected %v, got %v -- %v", test.title, path, u.Path, getRouteTemplate(route)) + return + } + } + if url != "" { + u, _ := route.URL(mapToPairs(match.Vars)...) + if url != u.Host+u.Path { + t.Errorf("(%v) URL not equal: expected %v, got %v -- %v", test.title, url, u.Host+u.Path, getRouteTemplate(route)) + return + } + } + if shouldRedirect && match.Handler == nil { + t.Errorf("(%v) Did not redirect", test.title) + return + } + if !shouldRedirect && match.Handler != nil { + t.Errorf("(%v) Unexpected redirect", test.title) + return + } + } +} + +func testTemplate(t *testing.T, test routeTest) { + route := test.route + path_template := test.path_template + if len(path_template) == 0 { + path_template = test.path + } + host_template := test.host_template + if len(host_template) == 0 { + host_template = test.host + } + + path_tmpl, path_err := route.GetPathTemplate() + if path_err == nil && path_tmpl != path_template { + t.Errorf("(%v) GetPathTemplate not equal: expected %v, got %v", test.title, path_template, path_tmpl) + } + + host_tmpl, host_err := route.GetHostTemplate() + if host_err == nil && host_tmpl != host_template { + t.Errorf("(%v) GetHostTemplate not equal: expected %v, got %v", test.title, host_template, host_tmpl) + } +} + +// Tests that the context is cleared or not cleared properly depending on +// the configuration of the router +func TestKeepContext(t *testing.T) { + func1 := func(w http.ResponseWriter, r *http.Request) {} + + r := NewRouter() + r.HandleFunc("/", func1).Name("func1") + + req, _ := http.NewRequest("GET", "http://localhost/", nil) + context.Set(req, "t", 1) + + res := new(http.ResponseWriter) + r.ServeHTTP(*res, req) + + if _, ok := context.GetOk(req, "t"); ok { + t.Error("Context should have been cleared at end of request") + } + + r.KeepContext = true + + req, _ = http.NewRequest("GET", "http://localhost/", nil) + context.Set(req, "t", 1) + + r.ServeHTTP(*res, req) + if _, ok := context.GetOk(req, "t"); !ok { + t.Error("Context should NOT have been cleared at end of request") + } + +} + +type TestA301ResponseWriter struct { + hh http.Header + status int +} + +func (ho TestA301ResponseWriter) Header() http.Header { + return http.Header(ho.hh) +} + +func (ho TestA301ResponseWriter) Write(b []byte) (int, error) { + return 0, nil +} + +func (ho TestA301ResponseWriter) WriteHeader(code int) { + ho.status = code +} + +func Test301Redirect(t *testing.T) { + m := make(http.Header) + + func1 := func(w http.ResponseWriter, r *http.Request) {} + func2 := func(w http.ResponseWriter, r *http.Request) {} + + r := NewRouter() + r.HandleFunc("/api/", func2).Name("func2") + r.HandleFunc("/", func1).Name("func1") + + req, _ := http.NewRequest("GET", "http://localhost//api/?abc=def", nil) + + res := TestA301ResponseWriter{ + hh: m, + status: 0, + } + r.ServeHTTP(&res, req) + + if "http://localhost/api/?abc=def" != res.hh["Location"][0] { + t.Errorf("Should have complete URL with query string") + } +} + +// https://plus.google.com/101022900381697718949/posts/eWy6DjFJ6uW +func TestSubrouterHeader(t *testing.T) { + expected := "func1 response" + func1 := func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, expected) + } + func2 := func(http.ResponseWriter, *http.Request) {} + + r := NewRouter() + s := r.Headers("SomeSpecialHeader", "").Subrouter() + s.HandleFunc("/", func1).Name("func1") + r.HandleFunc("/", func2).Name("func2") + + req, _ := http.NewRequest("GET", "http://localhost/", nil) + req.Header.Add("SomeSpecialHeader", "foo") + match := new(RouteMatch) + matched := r.Match(req, match) + if !matched { + t.Errorf("Should match request") + } + if match.Route.GetName() != "func1" { + t.Errorf("Expecting func1 handler, got %s", match.Route.GetName()) + } + resp := NewRecorder() + match.Handler.ServeHTTP(resp, req) + if resp.Body.String() != expected { + t.Errorf("Expecting %q", expected) + } +} + +// mapToPairs converts a string map to a slice of string pairs +func mapToPairs(m map[string]string) []string { + var i int + p := make([]string, len(m)*2) + for k, v := range m { + p[i] = k + p[i+1] = v + i += 2 + } + return p +} + +// stringMapEqual checks the equality of two string maps +func stringMapEqual(m1, m2 map[string]string) bool { + nil1 := m1 == nil + nil2 := m2 == nil + if nil1 != nil2 || len(m1) != len(m2) { + return false + } + for k, v := range m1 { + if v != m2[k] { + return false + } + } + return true +} + +// newRequest is a helper function to create a new request with a method and url +func newRequest(method, url string) *http.Request { + req, err := http.NewRequest(method, url, nil) + if err != nil { + panic(err) + } + return req +} diff --git a/vendor/github.com/gorilla/mux/old_test.go b/vendor/github.com/gorilla/mux/old_test.go new file mode 100644 index 00000000..c385a251 --- /dev/null +++ b/vendor/github.com/gorilla/mux/old_test.go @@ -0,0 +1,710 @@ +// Old tests ported to Go1. This is a mess. Want to drop it one day. + +// Copyright 2011 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" + "net/http" + "testing" +) + +// ---------------------------------------------------------------------------- +// ResponseRecorder +// ---------------------------------------------------------------------------- +// 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. + +// ResponseRecorder is an implementation of http.ResponseWriter that +// records its mutations for later inspection in tests. +type ResponseRecorder struct { + Code int // the HTTP response code from WriteHeader + HeaderMap http.Header // the HTTP response headers + Body *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to + Flushed bool +} + +// NewRecorder returns an initialized ResponseRecorder. +func NewRecorder() *ResponseRecorder { + return &ResponseRecorder{ + HeaderMap: make(http.Header), + Body: new(bytes.Buffer), + } +} + +// Header returns the response headers. +func (rw *ResponseRecorder) Header() http.Header { + return rw.HeaderMap +} + +// Write always succeeds and writes to rw.Body, if not nil. +func (rw *ResponseRecorder) Write(buf []byte) (int, error) { + if rw.Body != nil { + rw.Body.Write(buf) + } + if rw.Code == 0 { + rw.Code = http.StatusOK + } + return len(buf), nil +} + +// WriteHeader sets rw.Code. +func (rw *ResponseRecorder) WriteHeader(code int) { + rw.Code = code +} + +// Flush sets rw.Flushed to true. +func (rw *ResponseRecorder) Flush() { + rw.Flushed = true +} + +// ---------------------------------------------------------------------------- + +func TestRouteMatchers(t *testing.T) { + var scheme, host, path, query, method string + var headers map[string]string + var resultVars map[bool]map[string]string + + router := NewRouter() + router.NewRoute().Host("{var1}.google.com"). + Path("/{var2:[a-z]+}/{var3:[0-9]+}"). + Queries("foo", "bar"). + Methods("GET"). + Schemes("https"). + Headers("x-requested-with", "XMLHttpRequest") + router.NewRoute().Host("www.{var4}.com"). + PathPrefix("/foo/{var5:[a-z]+}/{var6:[0-9]+}"). + Queries("baz", "ding"). + Methods("POST"). + Schemes("http"). + Headers("Content-Type", "application/json") + + reset := func() { + // Everything match. + scheme = "https" + host = "www.google.com" + path = "/product/42" + query = "?foo=bar" + method = "GET" + headers = map[string]string{"X-Requested-With": "XMLHttpRequest"} + resultVars = map[bool]map[string]string{ + true: {"var1": "www", "var2": "product", "var3": "42"}, + false: {}, + } + } + + reset2 := func() { + // Everything match. + scheme = "http" + host = "www.google.com" + path = "/foo/product/42/path/that/is/ignored" + query = "?baz=ding" + method = "POST" + headers = map[string]string{"Content-Type": "application/json"} + resultVars = map[bool]map[string]string{ + true: {"var4": "google", "var5": "product", "var6": "42"}, + false: {}, + } + } + + match := func(shouldMatch bool) { + url := scheme + "://" + host + path + query + request, _ := http.NewRequest(method, url, nil) + for key, value := range headers { + request.Header.Add(key, value) + } + + var routeMatch RouteMatch + matched := router.Match(request, &routeMatch) + if matched != shouldMatch { + // Need better messages. :) + if matched { + t.Errorf("Should match.") + } else { + t.Errorf("Should not match.") + } + } + + if matched { + currentRoute := routeMatch.Route + if currentRoute == nil { + t.Errorf("Expected a current route.") + } + vars := routeMatch.Vars + expectedVars := resultVars[shouldMatch] + if len(vars) != len(expectedVars) { + t.Errorf("Expected vars: %v Got: %v.", expectedVars, vars) + } + for name, value := range vars { + if expectedVars[name] != value { + t.Errorf("Expected vars: %v Got: %v.", expectedVars, vars) + } + } + } + } + + // 1st route -------------------------------------------------------------- + + // Everything match. + reset() + match(true) + + // Scheme doesn't match. + reset() + scheme = "http" + match(false) + + // Host doesn't match. + reset() + host = "www.mygoogle.com" + match(false) + + // Path doesn't match. + reset() + path = "/product/notdigits" + match(false) + + // Query doesn't match. + reset() + query = "?foo=baz" + match(false) + + // Method doesn't match. + reset() + method = "POST" + match(false) + + // Header doesn't match. + reset() + headers = map[string]string{} + match(false) + + // Everything match, again. + reset() + match(true) + + // 2nd route -------------------------------------------------------------- + + // Everything match. + reset2() + match(true) + + // Scheme doesn't match. + reset2() + scheme = "https" + match(false) + + // Host doesn't match. + reset2() + host = "sub.google.com" + match(false) + + // Path doesn't match. + reset2() + path = "/bar/product/42" + match(false) + + // Query doesn't match. + reset2() + query = "?foo=baz" + match(false) + + // Method doesn't match. + reset2() + method = "GET" + match(false) + + // Header doesn't match. + reset2() + headers = map[string]string{} + match(false) + + // Everything match, again. + reset2() + match(true) +} + +type headerMatcherTest struct { + matcher headerMatcher + headers map[string]string + result bool +} + +var headerMatcherTests = []headerMatcherTest{ + { + matcher: headerMatcher(map[string]string{"x-requested-with": "XMLHttpRequest"}), + headers: map[string]string{"X-Requested-With": "XMLHttpRequest"}, + result: true, + }, + { + matcher: headerMatcher(map[string]string{"x-requested-with": ""}), + headers: map[string]string{"X-Requested-With": "anything"}, + result: true, + }, + { + matcher: headerMatcher(map[string]string{"x-requested-with": "XMLHttpRequest"}), + headers: map[string]string{}, + result: false, + }, +} + +type hostMatcherTest struct { + matcher *Route + url string + vars map[string]string + result bool +} + +var hostMatcherTests = []hostMatcherTest{ + { + matcher: NewRouter().NewRoute().Host("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}"), + url: "http://abc.def.ghi/", + vars: map[string]string{"foo": "abc", "bar": "def", "baz": "ghi"}, + result: true, + }, + { + matcher: NewRouter().NewRoute().Host("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}"), + url: "http://a.b.c/", + vars: map[string]string{"foo": "abc", "bar": "def", "baz": "ghi"}, + result: false, + }, +} + +type methodMatcherTest struct { + matcher methodMatcher + method string + result bool +} + +var methodMatcherTests = []methodMatcherTest{ + { + matcher: methodMatcher([]string{"GET", "POST", "PUT"}), + method: "GET", + result: true, + }, + { + matcher: methodMatcher([]string{"GET", "POST", "PUT"}), + method: "POST", + result: true, + }, + { + matcher: methodMatcher([]string{"GET", "POST", "PUT"}), + method: "PUT", + result: true, + }, + { + matcher: methodMatcher([]string{"GET", "POST", "PUT"}), + method: "DELETE", + result: false, + }, +} + +type pathMatcherTest struct { + matcher *Route + url string + vars map[string]string + result bool +} + +var pathMatcherTests = []pathMatcherTest{ + { + matcher: NewRouter().NewRoute().Path("/{foo:[0-9][0-9][0-9]}/{bar:[0-9][0-9][0-9]}/{baz:[0-9][0-9][0-9]}"), + url: "http://localhost:8080/123/456/789", + vars: map[string]string{"foo": "123", "bar": "456", "baz": "789"}, + result: true, + }, + { + matcher: NewRouter().NewRoute().Path("/{foo:[0-9][0-9][0-9]}/{bar:[0-9][0-9][0-9]}/{baz:[0-9][0-9][0-9]}"), + url: "http://localhost:8080/1/2/3", + vars: map[string]string{"foo": "123", "bar": "456", "baz": "789"}, + result: false, + }, +} + +type schemeMatcherTest struct { + matcher schemeMatcher + url string + result bool +} + +var schemeMatcherTests = []schemeMatcherTest{ + { + matcher: schemeMatcher([]string{"http", "https"}), + url: "http://localhost:8080/", + result: true, + }, + { + matcher: schemeMatcher([]string{"http", "https"}), + url: "https://localhost:8080/", + result: true, + }, + { + matcher: schemeMatcher([]string{"https"}), + url: "http://localhost:8080/", + result: false, + }, + { + matcher: schemeMatcher([]string{"http"}), + url: "https://localhost:8080/", + result: false, + }, +} + +type urlBuildingTest struct { + route *Route + vars []string + url string +} + +var urlBuildingTests = []urlBuildingTest{ + { + route: new(Route).Host("foo.domain.com"), + vars: []string{}, + url: "http://foo.domain.com", + }, + { + route: new(Route).Host("{subdomain}.domain.com"), + vars: []string{"subdomain", "bar"}, + url: "http://bar.domain.com", + }, + { + route: new(Route).Host("foo.domain.com").Path("/articles"), + vars: []string{}, + url: "http://foo.domain.com/articles", + }, + { + route: new(Route).Path("/articles"), + vars: []string{}, + url: "/articles", + }, + { + route: new(Route).Path("/articles/{category}/{id:[0-9]+}"), + vars: []string{"category", "technology", "id", "42"}, + url: "/articles/technology/42", + }, + { + route: new(Route).Host("{subdomain}.domain.com").Path("/articles/{category}/{id:[0-9]+}"), + vars: []string{"subdomain", "foo", "category", "technology", "id", "42"}, + url: "http://foo.domain.com/articles/technology/42", + }, +} + +func TestHeaderMatcher(t *testing.T) { + for _, v := range headerMatcherTests { + request, _ := http.NewRequest("GET", "http://localhost:8080/", nil) + for key, value := range v.headers { + request.Header.Add(key, value) + } + var routeMatch RouteMatch + result := v.matcher.Match(request, &routeMatch) + if result != v.result { + if v.result { + t.Errorf("%#v: should match %v.", v.matcher, request.Header) + } else { + t.Errorf("%#v: should not match %v.", v.matcher, request.Header) + } + } + } +} + +func TestHostMatcher(t *testing.T) { + for _, v := range hostMatcherTests { + request, _ := http.NewRequest("GET", v.url, nil) + var routeMatch RouteMatch + result := v.matcher.Match(request, &routeMatch) + vars := routeMatch.Vars + if result != v.result { + if v.result { + t.Errorf("%#v: should match %v.", v.matcher, v.url) + } else { + t.Errorf("%#v: should not match %v.", v.matcher, v.url) + } + } + if result { + if len(vars) != len(v.vars) { + t.Errorf("%#v: vars length should be %v, got %v.", v.matcher, len(v.vars), len(vars)) + } + for name, value := range vars { + if v.vars[name] != value { + t.Errorf("%#v: expected value %v for key %v, got %v.", v.matcher, v.vars[name], name, value) + } + } + } else { + if len(vars) != 0 { + t.Errorf("%#v: vars length should be 0, got %v.", v.matcher, len(vars)) + } + } + } +} + +func TestMethodMatcher(t *testing.T) { + for _, v := range methodMatcherTests { + request, _ := http.NewRequest(v.method, "http://localhost:8080/", nil) + var routeMatch RouteMatch + result := v.matcher.Match(request, &routeMatch) + if result != v.result { + if v.result { + t.Errorf("%#v: should match %v.", v.matcher, v.method) + } else { + t.Errorf("%#v: should not match %v.", v.matcher, v.method) + } + } + } +} + +func TestPathMatcher(t *testing.T) { + for _, v := range pathMatcherTests { + request, _ := http.NewRequest("GET", v.url, nil) + var routeMatch RouteMatch + result := v.matcher.Match(request, &routeMatch) + vars := routeMatch.Vars + if result != v.result { + if v.result { + t.Errorf("%#v: should match %v.", v.matcher, v.url) + } else { + t.Errorf("%#v: should not match %v.", v.matcher, v.url) + } + } + if result { + if len(vars) != len(v.vars) { + t.Errorf("%#v: vars length should be %v, got %v.", v.matcher, len(v.vars), len(vars)) + } + for name, value := range vars { + if v.vars[name] != value { + t.Errorf("%#v: expected value %v for key %v, got %v.", v.matcher, v.vars[name], name, value) + } + } + } else { + if len(vars) != 0 { + t.Errorf("%#v: vars length should be 0, got %v.", v.matcher, len(vars)) + } + } + } +} + +func TestSchemeMatcher(t *testing.T) { + for _, v := range schemeMatcherTests { + request, _ := http.NewRequest("GET", v.url, nil) + var routeMatch RouteMatch + result := v.matcher.Match(request, &routeMatch) + if result != v.result { + if v.result { + t.Errorf("%#v: should match %v.", v.matcher, v.url) + } else { + t.Errorf("%#v: should not match %v.", v.matcher, v.url) + } + } + } +} + +func TestUrlBuilding(t *testing.T) { + + for _, v := range urlBuildingTests { + u, _ := v.route.URL(v.vars...) + url := u.String() + if url != v.url { + t.Errorf("expected %v, got %v", v.url, url) + /* + reversePath := "" + reverseHost := "" + if v.route.pathTemplate != nil { + reversePath = v.route.pathTemplate.Reverse + } + if v.route.hostTemplate != nil { + reverseHost = v.route.hostTemplate.Reverse + } + + t.Errorf("%#v:\nexpected: %q\ngot: %q\nreverse path: %q\nreverse host: %q", v.route, v.url, url, reversePath, reverseHost) + */ + } + } + + ArticleHandler := func(w http.ResponseWriter, r *http.Request) { + } + + router := NewRouter() + router.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).Name("article") + + url, _ := router.Get("article").URL("category", "technology", "id", "42") + expected := "/articles/technology/42" + if url.String() != expected { + t.Errorf("Expected %v, got %v", expected, url.String()) + } +} + +func TestMatchedRouteName(t *testing.T) { + routeName := "stock" + router := NewRouter() + route := router.NewRoute().Path("/products/").Name(routeName) + + url := "http://www.example.com/products/" + request, _ := http.NewRequest("GET", url, nil) + var rv RouteMatch + ok := router.Match(request, &rv) + + if !ok || rv.Route != route { + t.Errorf("Expected same route, got %+v.", rv.Route) + } + + retName := rv.Route.GetName() + if retName != routeName { + t.Errorf("Expected %q, got %q.", routeName, retName) + } +} + +func TestSubRouting(t *testing.T) { + // Example from docs. + router := NewRouter() + subrouter := router.NewRoute().Host("www.example.com").Subrouter() + route := subrouter.NewRoute().Path("/products/").Name("products") + + url := "http://www.example.com/products/" + request, _ := http.NewRequest("GET", url, nil) + var rv RouteMatch + ok := router.Match(request, &rv) + + if !ok || rv.Route != route { + t.Errorf("Expected same route, got %+v.", rv.Route) + } + + u, _ := router.Get("products").URL() + builtURL := u.String() + // Yay, subroute aware of the domain when building! + if builtURL != url { + t.Errorf("Expected %q, got %q.", url, builtURL) + } +} + +func TestVariableNames(t *testing.T) { + route := new(Route).Host("{arg1}.domain.com").Path("/{arg1}/{arg2:[0-9]+}") + if route.err == nil { + t.Errorf("Expected error for duplicated variable names") + } +} + +func TestRedirectSlash(t *testing.T) { + var route *Route + var routeMatch RouteMatch + r := NewRouter() + + r.StrictSlash(false) + route = r.NewRoute() + if route.strictSlash != false { + t.Errorf("Expected false redirectSlash.") + } + + r.StrictSlash(true) + route = r.NewRoute() + if route.strictSlash != true { + t.Errorf("Expected true redirectSlash.") + } + + route = new(Route) + route.strictSlash = true + route.Path("/{arg1}/{arg2:[0-9]+}/") + request, _ := http.NewRequest("GET", "http://localhost/foo/123", nil) + routeMatch = RouteMatch{} + _ = route.Match(request, &routeMatch) + vars := routeMatch.Vars + if vars["arg1"] != "foo" { + t.Errorf("Expected foo.") + } + if vars["arg2"] != "123" { + t.Errorf("Expected 123.") + } + rsp := NewRecorder() + routeMatch.Handler.ServeHTTP(rsp, request) + if rsp.HeaderMap.Get("Location") != "http://localhost/foo/123/" { + t.Errorf("Expected redirect header.") + } + + route = new(Route) + route.strictSlash = true + route.Path("/{arg1}/{arg2:[0-9]+}") + request, _ = http.NewRequest("GET", "http://localhost/foo/123/", nil) + routeMatch = RouteMatch{} + _ = route.Match(request, &routeMatch) + vars = routeMatch.Vars + if vars["arg1"] != "foo" { + t.Errorf("Expected foo.") + } + if vars["arg2"] != "123" { + t.Errorf("Expected 123.") + } + rsp = NewRecorder() + routeMatch.Handler.ServeHTTP(rsp, request) + if rsp.HeaderMap.Get("Location") != "http://localhost/foo/123" { + t.Errorf("Expected redirect header.") + } +} + +// Test for the new regexp library, still not available in stable Go. +func TestNewRegexp(t *testing.T) { + var p *routeRegexp + var matches []string + + tests := map[string]map[string][]string{ + "/{foo:a{2}}": { + "/a": nil, + "/aa": {"aa"}, + "/aaa": nil, + "/aaaa": nil, + }, + "/{foo:a{2,}}": { + "/a": nil, + "/aa": {"aa"}, + "/aaa": {"aaa"}, + "/aaaa": {"aaaa"}, + }, + "/{foo:a{2,3}}": { + "/a": nil, + "/aa": {"aa"}, + "/aaa": {"aaa"}, + "/aaaa": nil, + }, + "/{foo:[a-z]{3}}/{bar:[a-z]{2}}": { + "/a": nil, + "/ab": nil, + "/abc": nil, + "/abcd": nil, + "/abc/ab": {"abc", "ab"}, + "/abc/abc": nil, + "/abcd/ab": nil, + }, + `/{foo:\w{3,}}/{bar:\d{2,}}`: { + "/a": nil, + "/ab": nil, + "/abc": nil, + "/abc/1": nil, + "/abc/12": {"abc", "12"}, + "/abcd/12": {"abcd", "12"}, + "/abcd/123": {"abcd", "123"}, + }, + } + + for pattern, paths := range tests { + p, _ = newRouteRegexp(pattern, false, false, false, false) + for path, result := range paths { + matches = p.regexp.FindStringSubmatch(path) + if result == nil { + if matches != nil { + t.Errorf("%v should not match %v.", pattern, path) + } + } else { + if len(matches) != len(result)+1 { + t.Errorf("Expected %v matches, got %v.", len(result)+1, len(matches)) + } else { + for k, v := range result { + if matches[k+1] != v { + t.Errorf("Expected %v, got %v.", v, matches[k+1]) + } + } + } + } + } + } +} diff --git a/vendor/github.com/gorilla/mux/regexp.go b/vendor/github.com/gorilla/mux/regexp.go new file mode 100644 index 00000000..08710bc9 --- /dev/null +++ b/vendor/github.com/gorilla/mux/regexp.go @@ -0,0 +1,312 @@ +// 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" + "strconv" + "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 = "[^?&]*" + } 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("") + 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(?P<%s>%s)", regexp.QuoteMeta(raw), varGroupName(i/2), 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 matchQuery { + // Add the default pattern if the query value is empty + if queryVal := strings.SplitN(template, "=", 2)[1]; queryVal == "" { + pattern.WriteString(defaultPattern) + } + } + 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.matchQueryString(req) + } + + 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(values map[string]string) (string, error) { + 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 +} + +// getURLQuery returns a single query parameter from a request URL. +// For a URL with foo=bar&baz=ding, we return only the relevant key +// value pair for the routeRegexp. +func (r *routeRegexp) getURLQuery(req *http.Request) string { + if !r.matchQuery { + return "" + } + templateKey := strings.SplitN(r.template, "=", 2)[0] + for key, vals := range req.URL.Query() { + if key == templateKey && len(vals) > 0 { + return key + "=" + vals[0] + } + } + return "" +} + +func (r *routeRegexp) matchQueryString(req *http.Request) bool { + return r.regexp.MatchString(r.getURLQuery(req)) +} + +// 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 + var idxs []int + 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 +} + +// varGroupName builds a capturing group name for the indexed variable. +func varGroupName(idx int) string { + return "v" + strconv.Itoa(idx) +} + +// ---------------------------------------------------------------------------- +// 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 { + host := getHost(req) + matches := v.host.regexp.FindStringSubmatchIndex(host) + if len(matches) > 0 { + extractVars(host, matches, v.host.varsN, m.Vars) + } + } + // Store path variables. + if v.path != nil { + matches := v.path.regexp.FindStringSubmatchIndex(req.URL.Path) + if len(matches) > 0 { + extractVars(req.URL.Path, matches, v.path.varsN, m.Vars) + // 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. + for _, q := range v.queries { + queryURL := q.getURLQuery(req) + matches := q.regexp.FindStringSubmatchIndex(queryURL) + if len(matches) > 0 { + extractVars(queryURL, matches, q.varsN, m.Vars) + } + } +} + +// 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 + +} + +func extractVars(input string, matches []int, names []string, output map[string]string) { + matchesCount := 0 + prevEnd := -1 + for i := 2; i < len(matches) && matchesCount < len(names); i += 2 { + if prevEnd < matches[i+1] { + value := input[matches[i]:matches[i+1]] + output[names[matchesCount]] = value + prevEnd = matches[i+1] + matchesCount++ + } + } +} diff --git a/vendor/github.com/gorilla/mux/route.go b/vendor/github.com/gorilla/mux/route.go new file mode 100644 index 00000000..bf92af26 --- /dev/null +++ b/vendor/github.com/gorilla/mux/route.go @@ -0,0 +1,627 @@ +// 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" + "regexp" + "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 + + buildVarsFunc BuildVarsFunc +} + +// 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 matchMapWithString(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. +// If 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 = mapFromPairsToString(pairs...) + return r.addMatcher(headerMatcher(headers)) + } + return r +} + +// headerRegexMatcher matches the request against the route given a regex for the header +type headerRegexMatcher map[string]*regexp.Regexp + +func (m headerRegexMatcher) Match(r *http.Request, match *RouteMatch) bool { + return matchMapWithRegex(m, r.Header, true) +} + +// HeadersRegexp accepts a sequence of key/value pairs, where the value has regex +// support. For example: +// +// r := mux.NewRouter() +// r.HeadersRegexp("Content-Type", "application/(text|json)", +// "X-Requested-With", "XMLHttpRequest") +// +// The above route will only match if both the request header matches both regular expressions. +// It the value is an empty string, it will match any value if the key is set. +func (r *Route) HeadersRegexp(pairs ...string) *Route { + if r.err == nil { + var headers map[string]*regexp.Regexp + headers, r.err = mapFromPairsToRegex(pairs...) + return r.addMatcher(headerRegexMatcher(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 be matched: +// +// - {name} matches anything until the next dot. +// +// - {name:pattern} matches the given regexp pattern. +// +// For example: +// +// r := mux.NewRouter() +// r.Host("www.example.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 + +// Match returns the match for a given request. +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 be 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 be 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, false, 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)) +} + +// BuildVarsFunc -------------------------------------------------------------- + +// BuildVarsFunc is the function signature used by custom build variable +// functions (which can modify route variables before a route's URL is built). +type BuildVarsFunc func(map[string]string) map[string]string + +// BuildVarsFunc adds a custom function to be used to modify build variables +// before a route's URL is built. +func (r *Route) BuildVarsFunc(f BuildVarsFunc) *Route { + r.buildVarsFunc = f + return r +} + +// 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.example.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") + } + values, err := r.prepareVars(pairs...) + if err != nil { + return nil, err + } + var scheme, host, path string + if r.regexp.host != nil { + // Set a default scheme. + scheme = "http" + if host, err = r.regexp.host.url(values); err != nil { + return nil, err + } + } + if r.regexp.path != nil { + if path, err = r.regexp.path.url(values); 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") + } + values, err := r.prepareVars(pairs...) + if err != nil { + return nil, err + } + host, err := r.regexp.host.url(values) + 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") + } + values, err := r.prepareVars(pairs...) + if err != nil { + return nil, err + } + path, err := r.regexp.path.url(values) + if err != nil { + return nil, err + } + return &url.URL{ + Path: path, + }, nil +} + +// GetPathTemplate returns the template used to build the +// route match. +// This is useful for building simple REST API documentation and for instrumentation +// against third-party services. +// An error will be returned if the route does not define a path. +func (r *Route) GetPathTemplate() (string, error) { + if r.err != nil { + return "", r.err + } + if r.regexp == nil || r.regexp.path == nil { + return "", errors.New("mux: route doesn't have a path") + } + return r.regexp.path.template, nil +} + +// GetHostTemplate returns the template used to build the +// route match. +// This is useful for building simple REST API documentation and for instrumentation +// against third-party services. +// An error will be returned if the route does not define a host. +func (r *Route) GetHostTemplate() (string, error) { + if r.err != nil { + return "", r.err + } + if r.regexp == nil || r.regexp.host == nil { + return "", errors.New("mux: route doesn't have a host") + } + return r.regexp.host.template, nil +} + +// prepareVars converts the route variable pairs into a map. If the route has a +// BuildVarsFunc, it is invoked. +func (r *Route) prepareVars(pairs ...string) (map[string]string, error) { + m, err := mapFromPairsToString(pairs...) + if err != nil { + return nil, err + } + return r.buildVars(m), nil +} + +func (r *Route) buildVars(m map[string]string) map[string]string { + if r.parent != nil { + m = r.parent.buildVars(m) + } + if r.buildVarsFunc != nil { + m = r.buildVarsFunc(m) + } + return m +} + +// ---------------------------------------------------------------------------- +// parentRoute +// ---------------------------------------------------------------------------- + +// parentRoute allows routes to know about parent host and path definitions. +type parentRoute interface { + getNamedRoutes() map[string]*Route + getRegexpGroup() *routeRegexpGroup + buildVars(map[string]string) map[string]string +} + +// 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/gorilla/websocket/.gitignore b/vendor/github.com/gorilla/websocket/.gitignore new file mode 100644 index 00000000..00268614 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/.gitignore @@ -0,0 +1,22 @@ +# 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 diff --git a/vendor/github.com/gorilla/websocket/.travis.yml b/vendor/github.com/gorilla/websocket/.travis.yml new file mode 100644 index 00000000..ace2e2f4 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/.travis.yml @@ -0,0 +1,20 @@ +language: go +sudo: false + +matrix: + include: + - go: 1.2 + - go: 1.3 + - go: 1.4 + - go: 1.5 + - go: 1.6 + - go: tip + +install: + - go get golang.org/x/tools/cmd/vet + +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d .) + - go vet . + - go test -v -race ./... diff --git a/vendor/github.com/gorilla/websocket/AUTHORS b/vendor/github.com/gorilla/websocket/AUTHORS new file mode 100644 index 00000000..b003eca0 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/AUTHORS @@ -0,0 +1,8 @@ +# This is the official list of Gorilla WebSocket authors for copyright +# purposes. +# +# Please keep the list sorted. + +Gary Burd +Joachim Bauch + diff --git a/vendor/github.com/gorilla/websocket/LICENSE b/vendor/github.com/gorilla/websocket/LICENSE new file mode 100644 index 00000000..9171c972 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013 The Gorilla WebSocket 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. + +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/gorilla/websocket/README.md b/vendor/github.com/gorilla/websocket/README.md new file mode 100644 index 00000000..9d71959e --- /dev/null +++ b/vendor/github.com/gorilla/websocket/README.md @@ -0,0 +1,61 @@ +# Gorilla WebSocket + +Gorilla WebSocket is a [Go](http://golang.org/) implementation of the +[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. + +### Documentation + +* [API Reference](http://godoc.org/github.com/gorilla/websocket) +* [Chat example](https://github.com/gorilla/websocket/tree/master/examples/chat) +* [Command example](https://github.com/gorilla/websocket/tree/master/examples/command) +* [Client and server example](https://github.com/gorilla/websocket/tree/master/examples/echo) +* [File watch example](https://github.com/gorilla/websocket/tree/master/examples/filewatch) + +### Status + +The Gorilla WebSocket package provides a complete and tested implementation of +the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. The +package API is stable. + +### Installation + + go get github.com/gorilla/websocket + +### Protocol Compliance + +The Gorilla WebSocket package passes the server tests in the [Autobahn Test +Suite](http://autobahn.ws/testsuite) using the application in the [examples/autobahn +subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn). + +### Gorilla WebSocket compared with other packages + + + + + + + + + + + + + + + + + + +
github.com/gorillagolang.org/x/net
RFC 6455 Features
Passes Autobahn Test SuiteYesNo
Receive fragmented messageYesNo, see note 1
Send close messageYesNo
Send pings and receive pongsYesNo
Get the type of a received data messageYesYes, see note 2
Other Features
Limit size of received messageYesNo
Read message using io.ReaderYesNo, see note 3
Write message using io.WriteCloserYesNo, see note 3
+ +Notes: + +1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html). +2. The application can get the type of a received data message by implementing + a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal) + function. +3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries. + Read returns when the input buffer is full or a frame boundary is + encountered. Each call to Write sends a single frame message. The Gorilla + io.Reader and io.WriteCloser operate on a single WebSocket message. + diff --git a/vendor/github.com/gorilla/websocket/bench_test.go b/vendor/github.com/gorilla/websocket/bench_test.go new file mode 100644 index 00000000..f66fc36b --- /dev/null +++ b/vendor/github.com/gorilla/websocket/bench_test.go @@ -0,0 +1,19 @@ +// Copyright 2014 The Gorilla WebSocket 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 websocket + +import ( + "testing" +) + +func BenchmarkMaskBytes(b *testing.B) { + var key [4]byte + data := make([]byte, 1024) + pos := 0 + for i := 0; i < b.N; i++ { + pos = maskBytes(key, pos, data) + } + b.SetBytes(int64(len(data))) +} diff --git a/vendor/github.com/gorilla/websocket/client.go b/vendor/github.com/gorilla/websocket/client.go new file mode 100644 index 00000000..a353e185 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/client.go @@ -0,0 +1,350 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "bufio" + "bytes" + "crypto/tls" + "encoding/base64" + "errors" + "io" + "io/ioutil" + "net" + "net/http" + "net/url" + "strings" + "time" +) + +// ErrBadHandshake is returned when the server response to opening handshake is +// invalid. +var ErrBadHandshake = errors.New("websocket: bad handshake") + +// NewClient creates a new client connection using the given net connection. +// The URL u specifies the host and request URI. Use requestHeader to specify +// the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies +// (Cookie). Use the response.Header to get the selected subprotocol +// (Sec-WebSocket-Protocol) and cookies (Set-Cookie). +// +// If the WebSocket handshake fails, ErrBadHandshake is returned along with a +// non-nil *http.Response so that callers can handle redirects, authentication, +// etc. +// +// Deprecated: Use Dialer instead. +func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) { + d := Dialer{ + ReadBufferSize: readBufSize, + WriteBufferSize: writeBufSize, + NetDial: func(net, addr string) (net.Conn, error) { + return netConn, nil + }, + } + return d.Dial(u.String(), requestHeader) +} + +// A Dialer contains options for connecting to WebSocket server. +type Dialer struct { + // NetDial specifies the dial function for creating TCP connections. If + // NetDial is nil, net.Dial is used. + NetDial func(network, addr string) (net.Conn, error) + + // Proxy specifies a function to return a proxy for a given + // Request. If the function returns a non-nil error, the + // request is aborted with the provided error. + // If Proxy is nil or returns a nil *URL, no proxy is used. + Proxy func(*http.Request) (*url.URL, error) + + // TLSClientConfig specifies the TLS configuration to use with tls.Client. + // If nil, the default configuration is used. + TLSClientConfig *tls.Config + + // HandshakeTimeout specifies the duration for the handshake to complete. + HandshakeTimeout time.Duration + + // Input and output buffer sizes. If the buffer size is zero, then a + // default value of 4096 is used. + ReadBufferSize, WriteBufferSize int + + // Subprotocols specifies the client's requested subprotocols. + Subprotocols []string +} + +var errMalformedURL = errors.New("malformed ws or wss URL") + +// parseURL parses the URL. +// +// This function is a replacement for the standard library url.Parse function. +// In Go 1.4 and earlier, url.Parse loses information from the path. +func parseURL(s string) (*url.URL, error) { + // From the RFC: + // + // ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ] + // wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ] + + var u url.URL + switch { + case strings.HasPrefix(s, "ws://"): + u.Scheme = "ws" + s = s[len("ws://"):] + case strings.HasPrefix(s, "wss://"): + u.Scheme = "wss" + s = s[len("wss://"):] + default: + return nil, errMalformedURL + } + + if i := strings.Index(s, "?"); i >= 0 { + u.RawQuery = s[i+1:] + s = s[:i] + } + + if i := strings.Index(s, "/"); i >= 0 { + u.Opaque = s[i:] + s = s[:i] + } else { + u.Opaque = "/" + } + + u.Host = s + + if strings.Contains(u.Host, "@") { + // Don't bother parsing user information because user information is + // not allowed in websocket URIs. + return nil, errMalformedURL + } + + return &u, nil +} + +func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) { + hostPort = u.Host + hostNoPort = u.Host + if i := strings.LastIndex(u.Host, ":"); i > strings.LastIndex(u.Host, "]") { + hostNoPort = hostNoPort[:i] + } else { + switch u.Scheme { + case "wss": + hostPort += ":443" + case "https": + hostPort += ":443" + default: + hostPort += ":80" + } + } + return hostPort, hostNoPort +} + +// DefaultDialer is a dialer with all fields set to the default zero values. +var DefaultDialer = &Dialer{ + Proxy: http.ProxyFromEnvironment, +} + +// Dial creates a new client connection. Use requestHeader to specify the +// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie). +// Use the response.Header to get the selected subprotocol +// (Sec-WebSocket-Protocol) and cookies (Set-Cookie). +// +// If the WebSocket handshake fails, ErrBadHandshake is returned along with a +// non-nil *http.Response so that callers can handle redirects, authentication, +// etcetera. The response body may not contain the entire response and does not +// need to be closed by the application. +func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) { + + if d == nil { + d = &Dialer{ + Proxy: http.ProxyFromEnvironment, + } + } + + challengeKey, err := generateChallengeKey() + if err != nil { + return nil, nil, err + } + + u, err := parseURL(urlStr) + if err != nil { + return nil, nil, err + } + + switch u.Scheme { + case "ws": + u.Scheme = "http" + case "wss": + u.Scheme = "https" + default: + return nil, nil, errMalformedURL + } + + if u.User != nil { + // User name and password are not allowed in websocket URIs. + return nil, nil, errMalformedURL + } + + req := &http.Request{ + Method: "GET", + URL: u, + Proto: "HTTP/1.1", + ProtoMajor: 1, + ProtoMinor: 1, + Header: make(http.Header), + Host: u.Host, + } + + // Set the request headers using the capitalization for names and values in + // RFC examples. Although the capitalization shouldn't matter, there are + // servers that depend on it. The Header.Set method is not used because the + // method canonicalizes the header names. + req.Header["Upgrade"] = []string{"websocket"} + req.Header["Connection"] = []string{"Upgrade"} + req.Header["Sec-WebSocket-Key"] = []string{challengeKey} + req.Header["Sec-WebSocket-Version"] = []string{"13"} + if len(d.Subprotocols) > 0 { + req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")} + } + for k, vs := range requestHeader { + switch { + case k == "Host": + if len(vs) > 0 { + req.Host = vs[0] + } + case k == "Upgrade" || + k == "Connection" || + k == "Sec-Websocket-Key" || + k == "Sec-Websocket-Version" || + (k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0): + return nil, nil, errors.New("websocket: duplicate header not allowed: " + k) + default: + req.Header[k] = vs + } + } + + hostPort, hostNoPort := hostPortNoPort(u) + + var proxyURL *url.URL + // Check wether the proxy method has been configured + if d.Proxy != nil { + proxyURL, err = d.Proxy(req) + } + if err != nil { + return nil, nil, err + } + + var targetHostPort string + if proxyURL != nil { + targetHostPort, _ = hostPortNoPort(proxyURL) + } else { + targetHostPort = hostPort + } + + var deadline time.Time + if d.HandshakeTimeout != 0 { + deadline = time.Now().Add(d.HandshakeTimeout) + } + + netDial := d.NetDial + if netDial == nil { + netDialer := &net.Dialer{Deadline: deadline} + netDial = netDialer.Dial + } + + netConn, err := netDial("tcp", targetHostPort) + if err != nil { + return nil, nil, err + } + + defer func() { + if netConn != nil { + netConn.Close() + } + }() + + if err := netConn.SetDeadline(deadline); err != nil { + return nil, nil, err + } + + if proxyURL != nil { + connectHeader := make(http.Header) + if user := proxyURL.User; user != nil { + proxyUser := user.Username() + if proxyPassword, passwordSet := user.Password(); passwordSet { + credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword)) + connectHeader.Set("Proxy-Authorization", "Basic "+credential) + } + } + connectReq := &http.Request{ + Method: "CONNECT", + URL: &url.URL{Opaque: hostPort}, + Host: hostPort, + Header: connectHeader, + } + + connectReq.Write(netConn) + + // Read response. + // Okay to use and discard buffered reader here, because + // TLS server will not speak until spoken to. + br := bufio.NewReader(netConn) + resp, err := http.ReadResponse(br, connectReq) + if err != nil { + return nil, nil, err + } + if resp.StatusCode != 200 { + f := strings.SplitN(resp.Status, " ", 2) + return nil, nil, errors.New(f[1]) + } + } + + if u.Scheme == "https" { + cfg := d.TLSClientConfig + if cfg == nil { + cfg = &tls.Config{ServerName: hostNoPort} + } else if cfg.ServerName == "" { + shallowCopy := *cfg + cfg = &shallowCopy + cfg.ServerName = hostNoPort + } + tlsConn := tls.Client(netConn, cfg) + netConn = tlsConn + if err := tlsConn.Handshake(); err != nil { + return nil, nil, err + } + if !cfg.InsecureSkipVerify { + if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil { + return nil, nil, err + } + } + } + + conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize) + + if err := req.Write(netConn); err != nil { + return nil, nil, err + } + + resp, err := http.ReadResponse(conn.br, req) + if err != nil { + return nil, nil, err + } + if resp.StatusCode != 101 || + !strings.EqualFold(resp.Header.Get("Upgrade"), "websocket") || + !strings.EqualFold(resp.Header.Get("Connection"), "upgrade") || + resp.Header.Get("Sec-Websocket-Accept") != computeAcceptKey(challengeKey) { + // Before closing the network connection on return from this + // function, slurp up some of the response to aid application + // debugging. + buf := make([]byte, 1024) + n, _ := io.ReadFull(resp.Body, buf) + resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n])) + return nil, resp, ErrBadHandshake + } + + resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{})) + conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol") + + netConn.SetDeadline(time.Time{}) + netConn = nil // to avoid close in defer. + return conn, resp, nil +} diff --git a/vendor/github.com/gorilla/websocket/client_server_test.go b/vendor/github.com/gorilla/websocket/client_server_test.go new file mode 100644 index 00000000..3f7345dd --- /dev/null +++ b/vendor/github.com/gorilla/websocket/client_server_test.go @@ -0,0 +1,451 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "crypto/tls" + "crypto/x509" + "encoding/base64" + "io" + "io/ioutil" + "net" + "net/http" + "net/http/httptest" + "net/url" + "reflect" + "strings" + "testing" + "time" +) + +var cstUpgrader = Upgrader{ + Subprotocols: []string{"p0", "p1"}, + ReadBufferSize: 1024, + WriteBufferSize: 1024, + Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) { + http.Error(w, reason.Error(), status) + }, +} + +var cstDialer = Dialer{ + Subprotocols: []string{"p1", "p2"}, + ReadBufferSize: 1024, + WriteBufferSize: 1024, +} + +type cstHandler struct{ *testing.T } + +type cstServer struct { + *httptest.Server + URL string +} + +const ( + cstPath = "/a/b" + cstRawQuery = "x=y" + cstRequestURI = cstPath + "?" + cstRawQuery +) + +func newServer(t *testing.T) *cstServer { + var s cstServer + s.Server = httptest.NewServer(cstHandler{t}) + s.Server.URL += cstRequestURI + s.URL = makeWsProto(s.Server.URL) + return &s +} + +func newTLSServer(t *testing.T) *cstServer { + var s cstServer + s.Server = httptest.NewTLSServer(cstHandler{t}) + s.Server.URL += cstRequestURI + s.URL = makeWsProto(s.Server.URL) + return &s +} + +func (t cstHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != cstPath { + t.Logf("path=%v, want %v", r.URL.Path, cstPath) + http.Error(w, "bad path", 400) + return + } + if r.URL.RawQuery != cstRawQuery { + t.Logf("query=%v, want %v", r.URL.RawQuery, cstRawQuery) + http.Error(w, "bad path", 400) + return + } + subprotos := Subprotocols(r) + if !reflect.DeepEqual(subprotos, cstDialer.Subprotocols) { + t.Logf("subprotols=%v, want %v", subprotos, cstDialer.Subprotocols) + http.Error(w, "bad protocol", 400) + return + } + ws, err := cstUpgrader.Upgrade(w, r, http.Header{"Set-Cookie": {"sessionID=1234"}}) + if err != nil { + t.Logf("Upgrade: %v", err) + return + } + defer ws.Close() + + if ws.Subprotocol() != "p1" { + t.Logf("Subprotocol() = %s, want p1", ws.Subprotocol()) + ws.Close() + return + } + op, rd, err := ws.NextReader() + if err != nil { + t.Logf("NextReader: %v", err) + return + } + wr, err := ws.NextWriter(op) + if err != nil { + t.Logf("NextWriter: %v", err) + return + } + if _, err = io.Copy(wr, rd); err != nil { + t.Logf("NextWriter: %v", err) + return + } + if err := wr.Close(); err != nil { + t.Logf("Close: %v", err) + return + } +} + +func makeWsProto(s string) string { + return "ws" + strings.TrimPrefix(s, "http") +} + +func sendRecv(t *testing.T, ws *Conn) { + const message = "Hello World!" + if err := ws.SetWriteDeadline(time.Now().Add(time.Second)); err != nil { + t.Fatalf("SetWriteDeadline: %v", err) + } + if err := ws.WriteMessage(TextMessage, []byte(message)); err != nil { + t.Fatalf("WriteMessage: %v", err) + } + if err := ws.SetReadDeadline(time.Now().Add(time.Second)); err != nil { + t.Fatalf("SetReadDeadline: %v", err) + } + _, p, err := ws.ReadMessage() + if err != nil { + t.Fatalf("ReadMessage: %v", err) + } + if string(p) != message { + t.Fatalf("message=%s, want %s", p, message) + } +} + +func TestProxyDial(t *testing.T) { + + s := newServer(t) + defer s.Close() + + surl, _ := url.Parse(s.URL) + + cstDialer.Proxy = http.ProxyURL(surl) + + connect := false + origHandler := s.Server.Config.Handler + + // Capture the request Host header. + s.Server.Config.Handler = http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + if r.Method == "CONNECT" { + connect = true + w.WriteHeader(200) + return + } + + if !connect { + t.Log("connect not recieved") + http.Error(w, "connect not recieved", 405) + return + } + origHandler.ServeHTTP(w, r) + }) + + ws, _, err := cstDialer.Dial(s.URL, nil) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + sendRecv(t, ws) + + cstDialer.Proxy = http.ProxyFromEnvironment +} + +func TestProxyAuthorizationDial(t *testing.T) { + s := newServer(t) + defer s.Close() + + surl, _ := url.Parse(s.URL) + surl.User = url.UserPassword("username", "password") + cstDialer.Proxy = http.ProxyURL(surl) + + connect := false + origHandler := s.Server.Config.Handler + + // Capture the request Host header. + s.Server.Config.Handler = http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + proxyAuth := r.Header.Get("Proxy-Authorization") + expectedProxyAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte("username:password")) + if r.Method == "CONNECT" && proxyAuth == expectedProxyAuth { + connect = true + w.WriteHeader(200) + return + } + + if !connect { + t.Log("connect with proxy authorization not recieved") + http.Error(w, "connect with proxy authorization not recieved", 405) + return + } + origHandler.ServeHTTP(w, r) + }) + + ws, _, err := cstDialer.Dial(s.URL, nil) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + sendRecv(t, ws) + + cstDialer.Proxy = http.ProxyFromEnvironment +} + +func TestDial(t *testing.T) { + s := newServer(t) + defer s.Close() + + ws, _, err := cstDialer.Dial(s.URL, nil) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + sendRecv(t, ws) +} + +func TestDialTLS(t *testing.T) { + s := newTLSServer(t) + defer s.Close() + + certs := x509.NewCertPool() + for _, c := range s.TLS.Certificates { + roots, err := x509.ParseCertificates(c.Certificate[len(c.Certificate)-1]) + if err != nil { + t.Fatalf("error parsing server's root cert: %v", err) + } + for _, root := range roots { + certs.AddCert(root) + } + } + + u, _ := url.Parse(s.URL) + d := cstDialer + d.NetDial = func(network, addr string) (net.Conn, error) { return net.Dial(network, u.Host) } + d.TLSClientConfig = &tls.Config{RootCAs: certs} + ws, _, err := d.Dial("wss://example.com"+cstRequestURI, nil) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + sendRecv(t, ws) +} + +func xTestDialTLSBadCert(t *testing.T) { + // This test is deactivated because of noisy logging from the net/http package. + s := newTLSServer(t) + defer s.Close() + + ws, _, err := cstDialer.Dial(s.URL, nil) + if err == nil { + ws.Close() + t.Fatalf("Dial: nil") + } +} + +func xTestDialTLSNoVerify(t *testing.T) { + s := newTLSServer(t) + defer s.Close() + + d := cstDialer + d.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + ws, _, err := d.Dial(s.URL, nil) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + sendRecv(t, ws) +} + +func TestDialTimeout(t *testing.T) { + s := newServer(t) + defer s.Close() + + d := cstDialer + d.HandshakeTimeout = -1 + ws, _, err := d.Dial(s.URL, nil) + if err == nil { + ws.Close() + t.Fatalf("Dial: nil") + } +} + +func TestDialBadScheme(t *testing.T) { + s := newServer(t) + defer s.Close() + + ws, _, err := cstDialer.Dial(s.Server.URL, nil) + if err == nil { + ws.Close() + t.Fatalf("Dial: nil") + } +} + +func TestDialBadOrigin(t *testing.T) { + s := newServer(t) + defer s.Close() + + ws, resp, err := cstDialer.Dial(s.URL, http.Header{"Origin": {"bad"}}) + if err == nil { + ws.Close() + t.Fatalf("Dial: nil") + } + if resp == nil { + t.Fatalf("resp=nil, err=%v", err) + } + if resp.StatusCode != http.StatusForbidden { + t.Fatalf("status=%d, want %d", resp.StatusCode, http.StatusForbidden) + } +} + +func TestDialBadHeader(t *testing.T) { + s := newServer(t) + defer s.Close() + + for _, k := range []string{"Upgrade", + "Connection", + "Sec-Websocket-Key", + "Sec-Websocket-Version", + "Sec-Websocket-Protocol"} { + h := http.Header{} + h.Set(k, "bad") + ws, _, err := cstDialer.Dial(s.URL, http.Header{"Origin": {"bad"}}) + if err == nil { + ws.Close() + t.Errorf("Dial with header %s returned nil", k) + } + } +} + +func TestBadMethod(t *testing.T) { + s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ws, err := cstUpgrader.Upgrade(w, r, nil) + if err == nil { + t.Errorf("handshake succeeded, expect fail") + ws.Close() + } + })) + defer s.Close() + + resp, err := http.PostForm(s.URL, url.Values{}) + if err != nil { + t.Fatalf("PostForm returned error %v", err) + } + resp.Body.Close() + if resp.StatusCode != http.StatusMethodNotAllowed { + t.Errorf("Status = %d, want %d", resp.StatusCode, http.StatusMethodNotAllowed) + } +} + +func TestHandshake(t *testing.T) { + s := newServer(t) + defer s.Close() + + ws, resp, err := cstDialer.Dial(s.URL, http.Header{"Origin": {s.URL}}) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + + var sessionID string + for _, c := range resp.Cookies() { + if c.Name == "sessionID" { + sessionID = c.Value + } + } + if sessionID != "1234" { + t.Error("Set-Cookie not received from the server.") + } + + if ws.Subprotocol() != "p1" { + t.Errorf("ws.Subprotocol() = %s, want p1", ws.Subprotocol()) + } + sendRecv(t, ws) +} + +func TestRespOnBadHandshake(t *testing.T) { + const expectedStatus = http.StatusGone + const expectedBody = "This is the response body." + + s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(expectedStatus) + io.WriteString(w, expectedBody) + })) + defer s.Close() + + ws, resp, err := cstDialer.Dial(makeWsProto(s.URL), nil) + if err == nil { + ws.Close() + t.Fatalf("Dial: nil") + } + + if resp == nil { + t.Fatalf("resp=nil, err=%v", err) + } + + if resp.StatusCode != expectedStatus { + t.Errorf("resp.StatusCode=%d, want %d", resp.StatusCode, expectedStatus) + } + + p, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Fatalf("ReadFull(resp.Body) returned error %v", err) + } + + if string(p) != expectedBody { + t.Errorf("resp.Body=%s, want %s", p, expectedBody) + } +} + +// TestHostHeader confirms that the host header provided in the call to Dial is +// sent to the server. +func TestHostHeader(t *testing.T) { + s := newServer(t) + defer s.Close() + + specifiedHost := make(chan string, 1) + origHandler := s.Server.Config.Handler + + // Capture the request Host header. + s.Server.Config.Handler = http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + specifiedHost <- r.Host + origHandler.ServeHTTP(w, r) + }) + + ws, _, err := cstDialer.Dial(s.URL, http.Header{"Host": {"testhost"}}) + if err != nil { + t.Fatalf("Dial: %v", err) + } + defer ws.Close() + + if gotHost := <-specifiedHost; gotHost != "testhost" { + t.Fatalf("gotHost = %q, want \"testhost\"", gotHost) + } + + sendRecv(t, ws) +} diff --git a/vendor/github.com/gorilla/websocket/client_test.go b/vendor/github.com/gorilla/websocket/client_test.go new file mode 100644 index 00000000..7d2b0844 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/client_test.go @@ -0,0 +1,72 @@ +// Copyright 2014 The Gorilla WebSocket 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 websocket + +import ( + "net/url" + "reflect" + "testing" +) + +var parseURLTests = []struct { + s string + u *url.URL + rui string +}{ + {"ws://example.com/", &url.URL{Scheme: "ws", Host: "example.com", Opaque: "/"}, "/"}, + {"ws://example.com", &url.URL{Scheme: "ws", Host: "example.com", Opaque: "/"}, "/"}, + {"ws://example.com:7777/", &url.URL{Scheme: "ws", Host: "example.com:7777", Opaque: "/"}, "/"}, + {"wss://example.com/", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/"}, "/"}, + {"wss://example.com/a/b", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/a/b"}, "/a/b"}, + {"ss://example.com/a/b", nil, ""}, + {"ws://webmaster@example.com/", nil, ""}, + {"wss://example.com/a/b?x=y", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/a/b", RawQuery: "x=y"}, "/a/b?x=y"}, + {"wss://example.com?x=y", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/", RawQuery: "x=y"}, "/?x=y"}, +} + +func TestParseURL(t *testing.T) { + for _, tt := range parseURLTests { + u, err := parseURL(tt.s) + if tt.u != nil && err != nil { + t.Errorf("parseURL(%q) returned error %v", tt.s, err) + continue + } + if tt.u == nil { + if err == nil { + t.Errorf("parseURL(%q) did not return error", tt.s) + } + continue + } + if !reflect.DeepEqual(u, tt.u) { + t.Errorf("parseURL(%q) = %v, want %v", tt.s, u, tt.u) + continue + } + if u.RequestURI() != tt.rui { + t.Errorf("parseURL(%q).RequestURI() = %v, want %v", tt.s, u.RequestURI(), tt.rui) + } + } +} + +var hostPortNoPortTests = []struct { + u *url.URL + hostPort, hostNoPort string +}{ + {&url.URL{Scheme: "ws", Host: "example.com"}, "example.com:80", "example.com"}, + {&url.URL{Scheme: "wss", Host: "example.com"}, "example.com:443", "example.com"}, + {&url.URL{Scheme: "ws", Host: "example.com:7777"}, "example.com:7777", "example.com"}, + {&url.URL{Scheme: "wss", Host: "example.com:7777"}, "example.com:7777", "example.com"}, +} + +func TestHostPortNoPort(t *testing.T) { + for _, tt := range hostPortNoPortTests { + hostPort, hostNoPort := hostPortNoPort(tt.u) + if hostPort != tt.hostPort { + t.Errorf("hostPortNoPort(%v) returned hostPort %q, want %q", tt.u, hostPort, tt.hostPort) + } + if hostNoPort != tt.hostNoPort { + t.Errorf("hostPortNoPort(%v) returned hostNoPort %q, want %q", tt.u, hostNoPort, tt.hostNoPort) + } + } +} diff --git a/vendor/github.com/gorilla/websocket/conn.go b/vendor/github.com/gorilla/websocket/conn.go new file mode 100644 index 00000000..eff26c63 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/conn.go @@ -0,0 +1,915 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "bufio" + "encoding/binary" + "errors" + "io" + "io/ioutil" + "math/rand" + "net" + "strconv" + "time" +) + +const ( + maxFrameHeaderSize = 2 + 8 + 4 // Fixed header + length + mask + maxControlFramePayloadSize = 125 + finalBit = 1 << 7 + maskBit = 1 << 7 + writeWait = time.Second + + defaultReadBufferSize = 4096 + defaultWriteBufferSize = 4096 + + continuationFrame = 0 + noFrame = -1 +) + +// Close codes defined in RFC 6455, section 11.7. +const ( + CloseNormalClosure = 1000 + CloseGoingAway = 1001 + CloseProtocolError = 1002 + CloseUnsupportedData = 1003 + CloseNoStatusReceived = 1005 + CloseAbnormalClosure = 1006 + CloseInvalidFramePayloadData = 1007 + ClosePolicyViolation = 1008 + CloseMessageTooBig = 1009 + CloseMandatoryExtension = 1010 + CloseInternalServerErr = 1011 + CloseTLSHandshake = 1015 +) + +// The message types are defined in RFC 6455, section 11.8. +const ( + // TextMessage denotes a text data message. The text message payload is + // interpreted as UTF-8 encoded text data. + TextMessage = 1 + + // BinaryMessage denotes a binary data message. + BinaryMessage = 2 + + // CloseMessage denotes a close control message. The optional message + // payload contains a numeric code and text. Use the FormatCloseMessage + // function to format a close message payload. + CloseMessage = 8 + + // PingMessage denotes a ping control message. The optional message payload + // is UTF-8 encoded text. + PingMessage = 9 + + // PongMessage denotes a ping control message. The optional message payload + // is UTF-8 encoded text. + PongMessage = 10 +) + +// ErrCloseSent is returned when the application writes a message to the +// connection after sending a close message. +var ErrCloseSent = errors.New("websocket: close sent") + +// ErrReadLimit is returned when reading a message that is larger than the +// read limit set for the connection. +var ErrReadLimit = errors.New("websocket: read limit exceeded") + +// netError satisfies the net Error interface. +type netError struct { + msg string + temporary bool + timeout bool +} + +func (e *netError) Error() string { return e.msg } +func (e *netError) Temporary() bool { return e.temporary } +func (e *netError) Timeout() bool { return e.timeout } + +// CloseError represents close frame. +type CloseError struct { + + // Code is defined in RFC 6455, section 11.7. + Code int + + // Text is the optional text payload. + Text string +} + +func (e *CloseError) Error() string { + s := []byte("websocket: close ") + s = strconv.AppendInt(s, int64(e.Code), 10) + switch e.Code { + case CloseNormalClosure: + s = append(s, " (normal)"...) + case CloseGoingAway: + s = append(s, " (going away)"...) + case CloseProtocolError: + s = append(s, " (protocol error)"...) + case CloseUnsupportedData: + s = append(s, " (unsupported data)"...) + case CloseNoStatusReceived: + s = append(s, " (no status)"...) + case CloseAbnormalClosure: + s = append(s, " (abnormal closure)"...) + case CloseInvalidFramePayloadData: + s = append(s, " (invalid payload data)"...) + case ClosePolicyViolation: + s = append(s, " (policy violation)"...) + case CloseMessageTooBig: + s = append(s, " (message too big)"...) + case CloseMandatoryExtension: + s = append(s, " (mandatory extension missing)"...) + case CloseInternalServerErr: + s = append(s, " (internal server error)"...) + case CloseTLSHandshake: + s = append(s, " (TLS handshake error)"...) + } + if e.Text != "" { + s = append(s, ": "...) + s = append(s, e.Text...) + } + return string(s) +} + +// IsCloseError returns boolean indicating whether the error is a *CloseError +// with one of the specified codes. +func IsCloseError(err error, codes ...int) bool { + if e, ok := err.(*CloseError); ok { + for _, code := range codes { + if e.Code == code { + return true + } + } + } + return false +} + +// IsUnexpectedCloseError returns boolean indicating whether the error is a +// *CloseError with a code not in the list of expected codes. +func IsUnexpectedCloseError(err error, expectedCodes ...int) bool { + if e, ok := err.(*CloseError); ok { + for _, code := range expectedCodes { + if e.Code == code { + return false + } + } + return true + } + return false +} + +var ( + errWriteTimeout = &netError{msg: "websocket: write timeout", timeout: true, temporary: true} + errUnexpectedEOF = &CloseError{Code: CloseAbnormalClosure, Text: io.ErrUnexpectedEOF.Error()} + errBadWriteOpCode = errors.New("websocket: bad write message type") + errWriteClosed = errors.New("websocket: write closed") + errInvalidControlFrame = errors.New("websocket: invalid control frame") +) + +func hideTempErr(err error) error { + if e, ok := err.(net.Error); ok && e.Temporary() { + err = &netError{msg: e.Error(), timeout: e.Timeout()} + } + return err +} + +func isControl(frameType int) bool { + return frameType == CloseMessage || frameType == PingMessage || frameType == PongMessage +} + +func isData(frameType int) bool { + return frameType == TextMessage || frameType == BinaryMessage +} + +func maskBytes(key [4]byte, pos int, b []byte) int { + for i := range b { + b[i] ^= key[pos&3] + pos++ + } + return pos & 3 +} + +func newMaskKey() [4]byte { + n := rand.Uint32() + return [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)} +} + +// Conn represents a WebSocket connection. +type Conn struct { + conn net.Conn + isServer bool + subprotocol string + + // Write fields + mu chan bool // used as mutex to protect write to conn and closeSent + closeSent bool // true if close message was sent + + // Message writer fields. + writeErr error + writeBuf []byte // frame is constructed in this buffer. + writePos int // end of data in writeBuf. + writeFrameType int // type of the current frame. + writeSeq int // incremented to invalidate message writers. + writeDeadline time.Time + isWriting bool // for best-effort concurrent write detection + + // Read fields + readErr error + br *bufio.Reader + readRemaining int64 // bytes remaining in current frame. + readFinal bool // true the current message has more frames. + readSeq int // incremented to invalidate message readers. + readLength int64 // Message size. + readLimit int64 // Maximum message size. + readMaskPos int + readMaskKey [4]byte + handlePong func(string) error + handlePing func(string) error + readErrCount int +} + +func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn { + mu := make(chan bool, 1) + mu <- true + + if readBufferSize == 0 { + readBufferSize = defaultReadBufferSize + } + if writeBufferSize == 0 { + writeBufferSize = defaultWriteBufferSize + } + + c := &Conn{ + isServer: isServer, + br: bufio.NewReaderSize(conn, readBufferSize), + conn: conn, + mu: mu, + readFinal: true, + writeBuf: make([]byte, writeBufferSize+maxFrameHeaderSize), + writeFrameType: noFrame, + writePos: maxFrameHeaderSize, + } + c.SetPingHandler(nil) + c.SetPongHandler(nil) + return c +} + +// Subprotocol returns the negotiated protocol for the connection. +func (c *Conn) Subprotocol() string { + return c.subprotocol +} + +// Close closes the underlying network connection without sending or waiting for a close frame. +func (c *Conn) Close() error { + return c.conn.Close() +} + +// LocalAddr returns the local network address. +func (c *Conn) LocalAddr() net.Addr { + return c.conn.LocalAddr() +} + +// RemoteAddr returns the remote network address. +func (c *Conn) RemoteAddr() net.Addr { + return c.conn.RemoteAddr() +} + +// Write methods + +func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error { + <-c.mu + defer func() { c.mu <- true }() + + if c.closeSent { + return ErrCloseSent + } else if frameType == CloseMessage { + c.closeSent = true + } + + c.conn.SetWriteDeadline(deadline) + for _, buf := range bufs { + if len(buf) > 0 { + n, err := c.conn.Write(buf) + if n != len(buf) { + // Close on partial write. + c.conn.Close() + } + if err != nil { + return err + } + } + } + return nil +} + +// WriteControl writes a control message with the given deadline. The allowed +// message types are CloseMessage, PingMessage and PongMessage. +func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error { + if !isControl(messageType) { + return errBadWriteOpCode + } + if len(data) > maxControlFramePayloadSize { + return errInvalidControlFrame + } + + b0 := byte(messageType) | finalBit + b1 := byte(len(data)) + if !c.isServer { + b1 |= maskBit + } + + buf := make([]byte, 0, maxFrameHeaderSize+maxControlFramePayloadSize) + buf = append(buf, b0, b1) + + if c.isServer { + buf = append(buf, data...) + } else { + key := newMaskKey() + buf = append(buf, key[:]...) + buf = append(buf, data...) + maskBytes(key, 0, buf[6:]) + } + + d := time.Hour * 1000 + if !deadline.IsZero() { + d = deadline.Sub(time.Now()) + if d < 0 { + return errWriteTimeout + } + } + + timer := time.NewTimer(d) + select { + case <-c.mu: + timer.Stop() + case <-timer.C: + return errWriteTimeout + } + defer func() { c.mu <- true }() + + if c.closeSent { + return ErrCloseSent + } else if messageType == CloseMessage { + c.closeSent = true + } + + c.conn.SetWriteDeadline(deadline) + n, err := c.conn.Write(buf) + if n != 0 && n != len(buf) { + c.conn.Close() + } + return hideTempErr(err) +} + +// NextWriter returns a writer for the next message to send. The writer's +// Close method flushes the complete message to the network. +// +// There can be at most one open writer on a connection. NextWriter closes the +// previous writer if the application has not already done so. +func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) { + if c.writeErr != nil { + return nil, c.writeErr + } + + if c.writeFrameType != noFrame { + if err := c.flushFrame(true, nil); err != nil { + return nil, err + } + } + + if !isControl(messageType) && !isData(messageType) { + return nil, errBadWriteOpCode + } + + c.writeFrameType = messageType + return messageWriter{c, c.writeSeq}, nil +} + +func (c *Conn) flushFrame(final bool, extra []byte) error { + length := c.writePos - maxFrameHeaderSize + len(extra) + + // Check for invalid control frames. + if isControl(c.writeFrameType) && + (!final || length > maxControlFramePayloadSize) { + c.writeSeq++ + c.writeFrameType = noFrame + c.writePos = maxFrameHeaderSize + return errInvalidControlFrame + } + + b0 := byte(c.writeFrameType) + if final { + b0 |= finalBit + } + b1 := byte(0) + if !c.isServer { + b1 |= maskBit + } + + // Assume that the frame starts at beginning of c.writeBuf. + framePos := 0 + if c.isServer { + // Adjust up if mask not included in the header. + framePos = 4 + } + + switch { + case length >= 65536: + c.writeBuf[framePos] = b0 + c.writeBuf[framePos+1] = b1 | 127 + binary.BigEndian.PutUint64(c.writeBuf[framePos+2:], uint64(length)) + case length > 125: + framePos += 6 + c.writeBuf[framePos] = b0 + c.writeBuf[framePos+1] = b1 | 126 + binary.BigEndian.PutUint16(c.writeBuf[framePos+2:], uint16(length)) + default: + framePos += 8 + c.writeBuf[framePos] = b0 + c.writeBuf[framePos+1] = b1 | byte(length) + } + + if !c.isServer { + key := newMaskKey() + copy(c.writeBuf[maxFrameHeaderSize-4:], key[:]) + maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:c.writePos]) + if len(extra) > 0 { + c.writeErr = errors.New("websocket: internal error, extra used in client mode") + return c.writeErr + } + } + + // Write the buffers to the connection with best-effort detection of + // concurrent writes. See the concurrency section in the package + // documentation for more info. + + if c.isWriting { + panic("concurrent write to websocket connection") + } + c.isWriting = true + + c.writeErr = c.write(c.writeFrameType, c.writeDeadline, c.writeBuf[framePos:c.writePos], extra) + + if !c.isWriting { + panic("concurrent write to websocket connection") + } + c.isWriting = false + + // Setup for next frame. + c.writePos = maxFrameHeaderSize + c.writeFrameType = continuationFrame + if final { + c.writeSeq++ + c.writeFrameType = noFrame + } + return c.writeErr +} + +type messageWriter struct { + c *Conn + seq int +} + +func (w messageWriter) err() error { + c := w.c + if c.writeSeq != w.seq { + return errWriteClosed + } + if c.writeErr != nil { + return c.writeErr + } + return nil +} + +func (w messageWriter) ncopy(max int) (int, error) { + n := len(w.c.writeBuf) - w.c.writePos + if n <= 0 { + if err := w.c.flushFrame(false, nil); err != nil { + return 0, err + } + n = len(w.c.writeBuf) - w.c.writePos + } + if n > max { + n = max + } + return n, nil +} + +func (w messageWriter) write(final bool, p []byte) (int, error) { + if err := w.err(); err != nil { + return 0, err + } + + if len(p) > 2*len(w.c.writeBuf) && w.c.isServer { + // Don't buffer large messages. + err := w.c.flushFrame(final, p) + if err != nil { + return 0, err + } + return len(p), nil + } + + nn := len(p) + for len(p) > 0 { + n, err := w.ncopy(len(p)) + if err != nil { + return 0, err + } + copy(w.c.writeBuf[w.c.writePos:], p[:n]) + w.c.writePos += n + p = p[n:] + } + return nn, nil +} + +func (w messageWriter) Write(p []byte) (int, error) { + return w.write(false, p) +} + +func (w messageWriter) WriteString(p string) (int, error) { + if err := w.err(); err != nil { + return 0, err + } + + nn := len(p) + for len(p) > 0 { + n, err := w.ncopy(len(p)) + if err != nil { + return 0, err + } + copy(w.c.writeBuf[w.c.writePos:], p[:n]) + w.c.writePos += n + p = p[n:] + } + return nn, nil +} + +func (w messageWriter) ReadFrom(r io.Reader) (nn int64, err error) { + if err := w.err(); err != nil { + return 0, err + } + for { + if w.c.writePos == len(w.c.writeBuf) { + err = w.c.flushFrame(false, nil) + if err != nil { + break + } + } + var n int + n, err = r.Read(w.c.writeBuf[w.c.writePos:]) + w.c.writePos += n + nn += int64(n) + if err != nil { + if err == io.EOF { + err = nil + } + break + } + } + return nn, err +} + +func (w messageWriter) Close() error { + if err := w.err(); err != nil { + return err + } + return w.c.flushFrame(true, nil) +} + +// WriteMessage is a helper method for getting a writer using NextWriter, +// writing the message and closing the writer. +func (c *Conn) WriteMessage(messageType int, data []byte) error { + wr, err := c.NextWriter(messageType) + if err != nil { + return err + } + w := wr.(messageWriter) + if _, err := w.write(true, data); err != nil { + return err + } + if c.writeSeq == w.seq { + if err := c.flushFrame(true, nil); err != nil { + return err + } + } + return nil +} + +// SetWriteDeadline sets the write deadline on the underlying network +// connection. After a write has timed out, the websocket state is corrupt and +// all future writes will return an error. A zero value for t means writes will +// not time out. +func (c *Conn) SetWriteDeadline(t time.Time) error { + c.writeDeadline = t + return nil +} + +// Read methods + +// readFull is like io.ReadFull except that io.EOF is never returned. +func (c *Conn) readFull(p []byte) (err error) { + var n int + for n < len(p) && err == nil { + var nn int + nn, err = c.br.Read(p[n:]) + n += nn + } + if n == len(p) { + err = nil + } else if err == io.EOF { + err = errUnexpectedEOF + } + return +} + +func (c *Conn) advanceFrame() (int, error) { + + // 1. Skip remainder of previous frame. + + if c.readRemaining > 0 { + if _, err := io.CopyN(ioutil.Discard, c.br, c.readRemaining); err != nil { + return noFrame, err + } + } + + // 2. Read and parse first two bytes of frame header. + + var b [8]byte + if err := c.readFull(b[:2]); err != nil { + return noFrame, err + } + + final := b[0]&finalBit != 0 + frameType := int(b[0] & 0xf) + reserved := int((b[0] >> 4) & 0x7) + mask := b[1]&maskBit != 0 + c.readRemaining = int64(b[1] & 0x7f) + + if reserved != 0 { + return noFrame, c.handleProtocolError("unexpected reserved bits " + strconv.Itoa(reserved)) + } + + switch frameType { + case CloseMessage, PingMessage, PongMessage: + if c.readRemaining > maxControlFramePayloadSize { + return noFrame, c.handleProtocolError("control frame length > 125") + } + if !final { + return noFrame, c.handleProtocolError("control frame not final") + } + case TextMessage, BinaryMessage: + if !c.readFinal { + return noFrame, c.handleProtocolError("message start before final message frame") + } + c.readFinal = final + case continuationFrame: + if c.readFinal { + return noFrame, c.handleProtocolError("continuation after final message frame") + } + c.readFinal = final + default: + return noFrame, c.handleProtocolError("unknown opcode " + strconv.Itoa(frameType)) + } + + // 3. Read and parse frame length. + + switch c.readRemaining { + case 126: + if err := c.readFull(b[:2]); err != nil { + return noFrame, err + } + c.readRemaining = int64(binary.BigEndian.Uint16(b[:2])) + case 127: + if err := c.readFull(b[:8]); err != nil { + return noFrame, err + } + c.readRemaining = int64(binary.BigEndian.Uint64(b[:8])) + } + + // 4. Handle frame masking. + + if mask != c.isServer { + return noFrame, c.handleProtocolError("incorrect mask flag") + } + + if mask { + c.readMaskPos = 0 + if err := c.readFull(c.readMaskKey[:]); err != nil { + return noFrame, err + } + } + + // 5. For text and binary messages, enforce read limit and return. + + if frameType == continuationFrame || frameType == TextMessage || frameType == BinaryMessage { + + c.readLength += c.readRemaining + if c.readLimit > 0 && c.readLength > c.readLimit { + c.WriteControl(CloseMessage, FormatCloseMessage(CloseMessageTooBig, ""), time.Now().Add(writeWait)) + return noFrame, ErrReadLimit + } + + return frameType, nil + } + + // 6. Read control frame payload. + + var payload []byte + if c.readRemaining > 0 { + payload = make([]byte, c.readRemaining) + c.readRemaining = 0 + if err := c.readFull(payload); err != nil { + return noFrame, err + } + if c.isServer { + maskBytes(c.readMaskKey, 0, payload) + } + } + + // 7. Process control frame payload. + + switch frameType { + case PongMessage: + if err := c.handlePong(string(payload)); err != nil { + return noFrame, err + } + case PingMessage: + if err := c.handlePing(string(payload)); err != nil { + return noFrame, err + } + case CloseMessage: + echoMessage := []byte{} + closeCode := CloseNoStatusReceived + closeText := "" + if len(payload) >= 2 { + echoMessage = payload[:2] + closeCode = int(binary.BigEndian.Uint16(payload)) + closeText = string(payload[2:]) + } + c.WriteControl(CloseMessage, echoMessage, time.Now().Add(writeWait)) + return noFrame, &CloseError{Code: closeCode, Text: closeText} + } + + return frameType, nil +} + +func (c *Conn) handleProtocolError(message string) error { + c.WriteControl(CloseMessage, FormatCloseMessage(CloseProtocolError, message), time.Now().Add(writeWait)) + return errors.New("websocket: " + message) +} + +// NextReader returns the next data message received from the peer. The +// returned messageType is either TextMessage or BinaryMessage. +// +// There can be at most one open reader on a connection. NextReader discards +// the previous message if the application has not already consumed it. +// +// Applications must break out of the application's read loop when this method +// returns a non-nil error value. Errors returned from this method are +// permanent. Once this method returns a non-nil error, all subsequent calls to +// this method return the same error. +func (c *Conn) NextReader() (messageType int, r io.Reader, err error) { + + c.readSeq++ + c.readLength = 0 + + for c.readErr == nil { + frameType, err := c.advanceFrame() + if err != nil { + c.readErr = hideTempErr(err) + break + } + if frameType == TextMessage || frameType == BinaryMessage { + return frameType, messageReader{c, c.readSeq}, nil + } + } + + // Applications that do handle the error returned from this method spin in + // tight loop on connection failure. To help application developers detect + // this error, panic on repeated reads to the failed connection. + c.readErrCount++ + if c.readErrCount >= 1000 { + panic("repeated read on failed websocket connection") + } + + return noFrame, nil, c.readErr +} + +type messageReader struct { + c *Conn + seq int +} + +func (r messageReader) Read(b []byte) (int, error) { + + if r.seq != r.c.readSeq { + return 0, io.EOF + } + + for r.c.readErr == nil { + + if r.c.readRemaining > 0 { + if int64(len(b)) > r.c.readRemaining { + b = b[:r.c.readRemaining] + } + n, err := r.c.br.Read(b) + r.c.readErr = hideTempErr(err) + if r.c.isServer { + r.c.readMaskPos = maskBytes(r.c.readMaskKey, r.c.readMaskPos, b[:n]) + } + r.c.readRemaining -= int64(n) + return n, r.c.readErr + } + + if r.c.readFinal { + r.c.readSeq++ + return 0, io.EOF + } + + frameType, err := r.c.advanceFrame() + switch { + case err != nil: + r.c.readErr = hideTempErr(err) + case frameType == TextMessage || frameType == BinaryMessage: + r.c.readErr = errors.New("websocket: internal error, unexpected text or binary in Reader") + } + } + + err := r.c.readErr + if err == io.EOF && r.seq == r.c.readSeq { + err = errUnexpectedEOF + } + return 0, err +} + +// ReadMessage is a helper method for getting a reader using NextReader and +// reading from that reader to a buffer. +func (c *Conn) ReadMessage() (messageType int, p []byte, err error) { + var r io.Reader + messageType, r, err = c.NextReader() + if err != nil { + return messageType, nil, err + } + p, err = ioutil.ReadAll(r) + return messageType, p, err +} + +// SetReadDeadline sets the read deadline on the underlying network connection. +// After a read has timed out, the websocket connection state is corrupt and +// all future reads will return an error. A zero value for t means reads will +// not time out. +func (c *Conn) SetReadDeadline(t time.Time) error { + return c.conn.SetReadDeadline(t) +} + +// SetReadLimit sets the maximum size for a message read from the peer. If a +// message exceeds the limit, the connection sends a close frame to the peer +// and returns ErrReadLimit to the application. +func (c *Conn) SetReadLimit(limit int64) { + c.readLimit = limit +} + +// SetPingHandler sets the handler for ping messages received from the peer. +// The appData argument to h is the PING frame application data. The default +// ping handler sends a pong to the peer. +func (c *Conn) SetPingHandler(h func(appData string) error) { + if h == nil { + h = func(message string) error { + err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait)) + if err == ErrCloseSent { + return nil + } else if e, ok := err.(net.Error); ok && e.Temporary() { + return nil + } + return err + } + } + c.handlePing = h +} + +// SetPongHandler sets the handler for pong messages received from the peer. +// The appData argument to h is the PONG frame application data. The default +// pong handler does nothing. +func (c *Conn) SetPongHandler(h func(appData string) error) { + if h == nil { + h = func(string) error { return nil } + } + c.handlePong = h +} + +// UnderlyingConn returns the internal net.Conn. This can be used to further +// modifications to connection specific flags. +func (c *Conn) UnderlyingConn() net.Conn { + return c.conn +} + +// FormatCloseMessage formats closeCode and text as a WebSocket close message. +func FormatCloseMessage(closeCode int, text string) []byte { + buf := make([]byte, 2+len(text)) + binary.BigEndian.PutUint16(buf, uint16(closeCode)) + copy(buf[2:], text) + return buf +} diff --git a/vendor/github.com/gorilla/websocket/conn_test.go b/vendor/github.com/gorilla/websocket/conn_test.go new file mode 100644 index 00000000..04c8dd8d --- /dev/null +++ b/vendor/github.com/gorilla/websocket/conn_test.go @@ -0,0 +1,367 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "net" + "reflect" + "testing" + "testing/iotest" + "time" +) + +var _ net.Error = errWriteTimeout + +type fakeNetConn struct { + io.Reader + io.Writer +} + +func (c fakeNetConn) Close() error { return nil } +func (c fakeNetConn) LocalAddr() net.Addr { return nil } +func (c fakeNetConn) RemoteAddr() net.Addr { return nil } +func (c fakeNetConn) SetDeadline(t time.Time) error { return nil } +func (c fakeNetConn) SetReadDeadline(t time.Time) error { return nil } +func (c fakeNetConn) SetWriteDeadline(t time.Time) error { return nil } + +func TestFraming(t *testing.T) { + frameSizes := []int{0, 1, 2, 124, 125, 126, 127, 128, 129, 65534, 65535, 65536, 65537} + var readChunkers = []struct { + name string + f func(io.Reader) io.Reader + }{ + {"half", iotest.HalfReader}, + {"one", iotest.OneByteReader}, + {"asis", func(r io.Reader) io.Reader { return r }}, + } + + writeBuf := make([]byte, 65537) + for i := range writeBuf { + writeBuf[i] = byte(i) + } + + for _, isServer := range []bool{true, false} { + for _, chunker := range readChunkers { + + var connBuf bytes.Buffer + wc := newConn(fakeNetConn{Reader: nil, Writer: &connBuf}, isServer, 1024, 1024) + rc := newConn(fakeNetConn{Reader: chunker.f(&connBuf), Writer: nil}, !isServer, 1024, 1024) + + for _, n := range frameSizes { + for _, iocopy := range []bool{true, false} { + name := fmt.Sprintf("s:%v, r:%s, n:%d c:%v", isServer, chunker.name, n, iocopy) + + w, err := wc.NextWriter(TextMessage) + if err != nil { + t.Errorf("%s: wc.NextWriter() returned %v", name, err) + continue + } + var nn int + if iocopy { + var n64 int64 + n64, err = io.Copy(w, bytes.NewReader(writeBuf[:n])) + nn = int(n64) + } else { + nn, err = w.Write(writeBuf[:n]) + } + if err != nil || nn != n { + t.Errorf("%s: w.Write(writeBuf[:n]) returned %d, %v", name, nn, err) + continue + } + err = w.Close() + if err != nil { + t.Errorf("%s: w.Close() returned %v", name, err) + continue + } + + opCode, r, err := rc.NextReader() + if err != nil || opCode != TextMessage { + t.Errorf("%s: NextReader() returned %d, r, %v", name, opCode, err) + continue + } + rbuf, err := ioutil.ReadAll(r) + if err != nil { + t.Errorf("%s: ReadFull() returned rbuf, %v", name, err) + continue + } + + if len(rbuf) != n { + t.Errorf("%s: len(rbuf) is %d, want %d", name, len(rbuf), n) + continue + } + + for i, b := range rbuf { + if byte(i) != b { + t.Errorf("%s: bad byte at offset %d", name, i) + break + } + } + } + } + } + } +} + +func TestControl(t *testing.T) { + const message = "this is a ping/pong messsage" + for _, isServer := range []bool{true, false} { + for _, isWriteControl := range []bool{true, false} { + name := fmt.Sprintf("s:%v, wc:%v", isServer, isWriteControl) + var connBuf bytes.Buffer + wc := newConn(fakeNetConn{Reader: nil, Writer: &connBuf}, isServer, 1024, 1024) + rc := newConn(fakeNetConn{Reader: &connBuf, Writer: nil}, !isServer, 1024, 1024) + if isWriteControl { + wc.WriteControl(PongMessage, []byte(message), time.Now().Add(time.Second)) + } else { + w, err := wc.NextWriter(PongMessage) + if err != nil { + t.Errorf("%s: wc.NextWriter() returned %v", name, err) + continue + } + if _, err := w.Write([]byte(message)); err != nil { + t.Errorf("%s: w.Write() returned %v", name, err) + continue + } + if err := w.Close(); err != nil { + t.Errorf("%s: w.Close() returned %v", name, err) + continue + } + var actualMessage string + rc.SetPongHandler(func(s string) error { actualMessage = s; return nil }) + rc.NextReader() + if actualMessage != message { + t.Errorf("%s: pong=%q, want %q", name, actualMessage, message) + continue + } + } + } + } +} + +func TestCloseBeforeFinalFrame(t *testing.T) { + const bufSize = 512 + + expectedErr := &CloseError{Code: CloseNormalClosure, Text: "hello"} + + var b1, b2 bytes.Buffer + wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, 1024, bufSize) + rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, 1024, 1024) + + w, _ := wc.NextWriter(BinaryMessage) + w.Write(make([]byte, bufSize+bufSize/2)) + wc.WriteControl(CloseMessage, FormatCloseMessage(expectedErr.Code, expectedErr.Text), time.Now().Add(10*time.Second)) + w.Close() + + op, r, err := rc.NextReader() + if op != BinaryMessage || err != nil { + t.Fatalf("NextReader() returned %d, %v", op, err) + } + _, err = io.Copy(ioutil.Discard, r) + if !reflect.DeepEqual(err, expectedErr) { + t.Fatalf("io.Copy() returned %v, want %v", err, expectedErr) + } + _, _, err = rc.NextReader() + if !reflect.DeepEqual(err, expectedErr) { + t.Fatalf("NextReader() returned %v, want %v", err, expectedErr) + } +} + +func TestEOFBeforeFinalFrame(t *testing.T) { + const bufSize = 512 + + var b1, b2 bytes.Buffer + wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, 1024, bufSize) + rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, 1024, 1024) + + w, _ := wc.NextWriter(BinaryMessage) + w.Write(make([]byte, bufSize+bufSize/2)) + + op, r, err := rc.NextReader() + if op != BinaryMessage || err != nil { + t.Fatalf("NextReader() returned %d, %v", op, err) + } + _, err = io.Copy(ioutil.Discard, r) + if err != errUnexpectedEOF { + t.Fatalf("io.Copy() returned %v, want %v", err, errUnexpectedEOF) + } + _, _, err = rc.NextReader() + if err != errUnexpectedEOF { + t.Fatalf("NextReader() returned %v, want %v", err, errUnexpectedEOF) + } +} + +func TestReadLimit(t *testing.T) { + + const readLimit = 512 + message := make([]byte, readLimit+1) + + var b1, b2 bytes.Buffer + wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, 1024, readLimit-2) + rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, 1024, 1024) + rc.SetReadLimit(readLimit) + + // Send message at the limit with interleaved pong. + w, _ := wc.NextWriter(BinaryMessage) + w.Write(message[:readLimit-1]) + wc.WriteControl(PongMessage, []byte("this is a pong"), time.Now().Add(10*time.Second)) + w.Write(message[:1]) + w.Close() + + // Send message larger than the limit. + wc.WriteMessage(BinaryMessage, message[:readLimit+1]) + + op, _, err := rc.NextReader() + if op != BinaryMessage || err != nil { + t.Fatalf("1: NextReader() returned %d, %v", op, err) + } + op, r, err := rc.NextReader() + if op != BinaryMessage || err != nil { + t.Fatalf("2: NextReader() returned %d, %v", op, err) + } + _, err = io.Copy(ioutil.Discard, r) + if err != ErrReadLimit { + t.Fatalf("io.Copy() returned %v", err) + } +} + +func TestUnderlyingConn(t *testing.T) { + var b1, b2 bytes.Buffer + fc := fakeNetConn{Reader: &b1, Writer: &b2} + c := newConn(fc, true, 1024, 1024) + ul := c.UnderlyingConn() + if ul != fc { + t.Fatalf("Underlying conn is not what it should be.") + } +} + +func TestBufioReadBytes(t *testing.T) { + + // Test calling bufio.ReadBytes for value longer than read buffer size. + + m := make([]byte, 512) + m[len(m)-1] = '\n' + + var b1, b2 bytes.Buffer + wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, len(m)+64, len(m)+64) + rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, len(m)-64, len(m)-64) + + w, _ := wc.NextWriter(BinaryMessage) + w.Write(m) + w.Close() + + op, r, err := rc.NextReader() + if op != BinaryMessage || err != nil { + t.Fatalf("NextReader() returned %d, %v", op, err) + } + + br := bufio.NewReader(r) + p, err := br.ReadBytes('\n') + if err != nil { + t.Fatalf("ReadBytes() returned %v", err) + } + if len(p) != len(m) { + t.Fatalf("read returnd %d bytes, want %d bytes", len(p), len(m)) + } +} + +var closeErrorTests = []struct { + err error + codes []int + ok bool +}{ + {&CloseError{Code: CloseNormalClosure}, []int{CloseNormalClosure}, true}, + {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived}, false}, + {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived, CloseNormalClosure}, true}, + {errors.New("hello"), []int{CloseNormalClosure}, false}, +} + +func TestCloseError(t *testing.T) { + for _, tt := range closeErrorTests { + ok := IsCloseError(tt.err, tt.codes...) + if ok != tt.ok { + t.Errorf("IsCloseError(%#v, %#v) returned %v, want %v", tt.err, tt.codes, ok, tt.ok) + } + } +} + +var unexpectedCloseErrorTests = []struct { + err error + codes []int + ok bool +}{ + {&CloseError{Code: CloseNormalClosure}, []int{CloseNormalClosure}, false}, + {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived}, true}, + {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived, CloseNormalClosure}, false}, + {errors.New("hello"), []int{CloseNormalClosure}, false}, +} + +func TestUnexpectedCloseErrors(t *testing.T) { + for _, tt := range unexpectedCloseErrorTests { + ok := IsUnexpectedCloseError(tt.err, tt.codes...) + if ok != tt.ok { + t.Errorf("IsUnexpectedCloseError(%#v, %#v) returned %v, want %v", tt.err, tt.codes, ok, tt.ok) + } + } +} + +type blockingWriter struct { + c1, c2 chan struct{} +} + +func (w blockingWriter) Write(p []byte) (int, error) { + // Allow main to continue + close(w.c1) + // Wait for panic in main + <-w.c2 + return len(p), nil +} + +func TestConcurrentWritePanic(t *testing.T) { + w := blockingWriter{make(chan struct{}), make(chan struct{})} + c := newConn(fakeNetConn{Reader: nil, Writer: w}, false, 1024, 1024) + go func() { + c.WriteMessage(TextMessage, []byte{}) + }() + + // wait for goroutine to block in write. + <-w.c1 + + defer func() { + close(w.c2) + if v := recover(); v != nil { + return + } + }() + + c.WriteMessage(TextMessage, []byte{}) + t.Fatal("should not get here") +} + +type failingReader struct{} + +func (r failingReader) Read(p []byte) (int, error) { + return 0, io.EOF +} + +func TestFailedConnectionReadPanic(t *testing.T) { + c := newConn(fakeNetConn{Reader: failingReader{}, Writer: nil}, false, 1024, 1024) + + defer func() { + if v := recover(); v != nil { + return + } + }() + + for i := 0; i < 20000; i++ { + c.ReadMessage() + } + t.Fatal("should not get here") +} diff --git a/vendor/github.com/gorilla/websocket/doc.go b/vendor/github.com/gorilla/websocket/doc.go new file mode 100644 index 00000000..c901a7a9 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/doc.go @@ -0,0 +1,152 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket implements the WebSocket protocol defined in RFC 6455. +// +// Overview +// +// The Conn type represents a WebSocket connection. A server application uses +// the Upgrade function from an Upgrader object with a HTTP request handler +// to get a pointer to a Conn: +// +// var upgrader = websocket.Upgrader{ +// ReadBufferSize: 1024, +// WriteBufferSize: 1024, +// } +// +// func handler(w http.ResponseWriter, r *http.Request) { +// conn, err := upgrader.Upgrade(w, r, nil) +// if err != nil { +// log.Println(err) +// return +// } +// ... Use conn to send and receive messages. +// } +// +// Call the connection's WriteMessage and ReadMessage methods to send and +// receive messages as a slice of bytes. This snippet of code shows how to echo +// messages using these methods: +// +// for { +// messageType, p, err := conn.ReadMessage() +// if err != nil { +// return +// } +// if err = conn.WriteMessage(messageType, p); err != nil { +// return err +// } +// } +// +// In above snippet of code, p is a []byte and messageType is an int with value +// websocket.BinaryMessage or websocket.TextMessage. +// +// An application can also send and receive messages using the io.WriteCloser +// and io.Reader interfaces. To send a message, call the connection NextWriter +// method to get an io.WriteCloser, write the message to the writer and close +// the writer when done. To receive a message, call the connection NextReader +// method to get an io.Reader and read until io.EOF is returned. This snippet +// shows how to echo messages using the NextWriter and NextReader methods: +// +// for { +// messageType, r, err := conn.NextReader() +// if err != nil { +// return +// } +// w, err := conn.NextWriter(messageType) +// if err != nil { +// return err +// } +// if _, err := io.Copy(w, r); err != nil { +// return err +// } +// if err := w.Close(); err != nil { +// return err +// } +// } +// +// Data Messages +// +// The WebSocket protocol distinguishes between text and binary data messages. +// Text messages are interpreted as UTF-8 encoded text. The interpretation of +// binary messages is left to the application. +// +// This package uses the TextMessage and BinaryMessage integer constants to +// identify the two data message types. The ReadMessage and NextReader methods +// return the type of the received message. The messageType argument to the +// WriteMessage and NextWriter methods specifies the type of a sent message. +// +// It is the application's responsibility to ensure that text messages are +// valid UTF-8 encoded text. +// +// Control Messages +// +// The WebSocket protocol defines three types of control messages: close, ping +// and pong. Call the connection WriteControl, WriteMessage or NextWriter +// methods to send a control message to the peer. +// +// Connections handle received close messages by sending a close message to the +// peer and returning a *CloseError from the the NextReader, ReadMessage or the +// message Read method. +// +// Connections handle received ping and pong messages by invoking callback +// functions set with SetPingHandler and SetPongHandler methods. The callback +// functions are called from the NextReader, ReadMessage and the message Read +// methods. +// +// The default ping handler sends a pong to the peer. The application's reading +// goroutine can block for a short time while the handler writes the pong data +// to the connection. +// +// The application must read the connection to process ping, pong and close +// messages sent from the peer. If the application is not otherwise interested +// in messages from the peer, then the application should start a goroutine to +// read and discard messages from the peer. A simple example is: +// +// func readLoop(c *websocket.Conn) { +// for { +// if _, _, err := c.NextReader(); err != nil { +// c.Close() +// break +// } +// } +// } +// +// Concurrency +// +// Connections support one concurrent reader and one concurrent writer. +// +// Applications are responsible for ensuring that no more than one goroutine +// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage, +// WriteJSON) concurrently and that no more than one goroutine calls the read +// methods (NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, +// SetPingHandler) concurrently. +// +// The Close and WriteControl methods can be called concurrently with all other +// methods. +// +// Origin Considerations +// +// Web browsers allow Javascript applications to open a WebSocket connection to +// any host. It's up to the server to enforce an origin policy using the Origin +// request header sent by the browser. +// +// The Upgrader calls the function specified in the CheckOrigin field to check +// the origin. If the CheckOrigin function returns false, then the Upgrade +// method fails the WebSocket handshake with HTTP status 403. +// +// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail +// the handshake if the Origin request header is present and not equal to the +// Host request header. +// +// An application can allow connections from any origin by specifying a +// function that always returns true: +// +// var upgrader = websocket.Upgrader{ +// CheckOrigin: func(r *http.Request) bool { return true }, +// } +// +// The deprecated Upgrade function does not enforce an origin policy. It's the +// application's responsibility to check the Origin header before calling +// Upgrade. +package websocket diff --git a/vendor/github.com/gorilla/websocket/example_test.go b/vendor/github.com/gorilla/websocket/example_test.go new file mode 100644 index 00000000..96449eac --- /dev/null +++ b/vendor/github.com/gorilla/websocket/example_test.go @@ -0,0 +1,46 @@ +// Copyright 2015 The Gorilla WebSocket 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 websocket_test + +import ( + "log" + "net/http" + "testing" + + "github.com/gorilla/websocket" +) + +var ( + c *websocket.Conn + req *http.Request +) + +// The websocket.IsUnexpectedCloseError function is useful for identifying +// application and protocol errors. +// +// This server application works with a client application running in the +// browser. The client application does not explicitly close the websocket. The +// only expected close message from the client has the code +// websocket.CloseGoingAway. All other other close messages are likely the +// result of an application or protocol error and are logged to aid debugging. +func ExampleIsUnexpectedCloseError() { + + for { + messageType, p, err := c.ReadMessage() + if err != nil { + if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) { + log.Printf("error: %v, user-agent: %v", err, req.Header.Get("User-Agent")) + } + return + } + processMesage(messageType, p) + } +} + +func processMesage(mt int, p []byte) {} + +// TestX prevents godoc from showing this entire file in the example. Remove +// this function when a second example is added. +func TestX(t *testing.T) {} diff --git a/vendor/github.com/gorilla/websocket/json.go b/vendor/github.com/gorilla/websocket/json.go new file mode 100644 index 00000000..4f0e3687 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/json.go @@ -0,0 +1,55 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "encoding/json" + "io" +) + +// WriteJSON is deprecated, use c.WriteJSON instead. +func WriteJSON(c *Conn, v interface{}) error { + return c.WriteJSON(v) +} + +// WriteJSON writes the JSON encoding of v to the connection. +// +// See the documentation for encoding/json Marshal for details about the +// conversion of Go values to JSON. +func (c *Conn) WriteJSON(v interface{}) error { + w, err := c.NextWriter(TextMessage) + if err != nil { + return err + } + err1 := json.NewEncoder(w).Encode(v) + err2 := w.Close() + if err1 != nil { + return err1 + } + return err2 +} + +// ReadJSON is deprecated, use c.ReadJSON instead. +func ReadJSON(c *Conn, v interface{}) error { + return c.ReadJSON(v) +} + +// ReadJSON reads the next JSON-encoded message from the connection and stores +// it in the value pointed to by v. +// +// See the documentation for the encoding/json Unmarshal function for details +// about the conversion of JSON to a Go value. +func (c *Conn) ReadJSON(v interface{}) error { + _, r, err := c.NextReader() + if err != nil { + return err + } + err = json.NewDecoder(r).Decode(v) + if err == io.EOF { + // One value is expected in the message. + err = io.ErrUnexpectedEOF + } + return err +} diff --git a/vendor/github.com/gorilla/websocket/json_test.go b/vendor/github.com/gorilla/websocket/json_test.go new file mode 100644 index 00000000..61100e48 --- /dev/null +++ b/vendor/github.com/gorilla/websocket/json_test.go @@ -0,0 +1,119 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "bytes" + "encoding/json" + "io" + "reflect" + "testing" +) + +func TestJSON(t *testing.T) { + var buf bytes.Buffer + c := fakeNetConn{&buf, &buf} + wc := newConn(c, true, 1024, 1024) + rc := newConn(c, false, 1024, 1024) + + var actual, expect struct { + A int + B string + } + expect.A = 1 + expect.B = "hello" + + if err := wc.WriteJSON(&expect); err != nil { + t.Fatal("write", err) + } + + if err := rc.ReadJSON(&actual); err != nil { + t.Fatal("read", err) + } + + if !reflect.DeepEqual(&actual, &expect) { + t.Fatal("equal", actual, expect) + } +} + +func TestPartialJSONRead(t *testing.T) { + var buf bytes.Buffer + c := fakeNetConn{&buf, &buf} + wc := newConn(c, true, 1024, 1024) + rc := newConn(c, false, 1024, 1024) + + var v struct { + A int + B string + } + v.A = 1 + v.B = "hello" + + messageCount := 0 + + // Partial JSON values. + + data, err := json.Marshal(v) + if err != nil { + t.Fatal(err) + } + for i := len(data) - 1; i >= 0; i-- { + if err := wc.WriteMessage(TextMessage, data[:i]); err != nil { + t.Fatal(err) + } + messageCount++ + } + + // Whitespace. + + if err := wc.WriteMessage(TextMessage, []byte(" ")); err != nil { + t.Fatal(err) + } + messageCount++ + + // Close. + + if err := wc.WriteMessage(CloseMessage, FormatCloseMessage(CloseNormalClosure, "")); err != nil { + t.Fatal(err) + } + + for i := 0; i < messageCount; i++ { + err := rc.ReadJSON(&v) + if err != io.ErrUnexpectedEOF { + t.Error("read", i, err) + } + } + + err = rc.ReadJSON(&v) + if _, ok := err.(*CloseError); !ok { + t.Error("final", err) + } +} + +func TestDeprecatedJSON(t *testing.T) { + var buf bytes.Buffer + c := fakeNetConn{&buf, &buf} + wc := newConn(c, true, 1024, 1024) + rc := newConn(c, false, 1024, 1024) + + var actual, expect struct { + A int + B string + } + expect.A = 1 + expect.B = "hello" + + if err := WriteJSON(wc, &expect); err != nil { + t.Fatal("write", err) + } + + if err := ReadJSON(rc, &actual); err != nil { + t.Fatal("read", err) + } + + if !reflect.DeepEqual(&actual, &expect) { + t.Fatal("equal", actual, expect) + } +} diff --git a/vendor/github.com/gorilla/websocket/server.go b/vendor/github.com/gorilla/websocket/server.go new file mode 100644 index 00000000..8d7137de --- /dev/null +++ b/vendor/github.com/gorilla/websocket/server.go @@ -0,0 +1,260 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "bufio" + "errors" + "net" + "net/http" + "net/url" + "strings" + "time" +) + +// HandshakeError describes an error with the handshake from the peer. +type HandshakeError struct { + message string +} + +func (e HandshakeError) Error() string { return e.message } + +// Upgrader specifies parameters for upgrading an HTTP connection to a +// WebSocket connection. +type Upgrader struct { + // HandshakeTimeout specifies the duration for the handshake to complete. + HandshakeTimeout time.Duration + + // ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer + // size is zero, then a default value of 4096 is used. The I/O buffer sizes + // do not limit the size of the messages that can be sent or received. + ReadBufferSize, WriteBufferSize int + + // Subprotocols specifies the server's supported protocols in order of + // preference. If this field is set, then the Upgrade method negotiates a + // subprotocol by selecting the first match in this list with a protocol + // requested by the client. + Subprotocols []string + + // Error specifies the function for generating HTTP error responses. If Error + // is nil, then http.Error is used to generate the HTTP response. + Error func(w http.ResponseWriter, r *http.Request, status int, reason error) + + // CheckOrigin returns true if the request Origin header is acceptable. If + // CheckOrigin is nil, the host in the Origin header must not be set or + // must match the host of the request. + CheckOrigin func(r *http.Request) bool +} + +func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status int, reason string) (*Conn, error) { + err := HandshakeError{reason} + if u.Error != nil { + u.Error(w, r, status, err) + } else { + http.Error(w, http.StatusText(status), status) + } + return nil, err +} + +// checkSameOrigin returns true if the origin is not set or is equal to the request host. +func checkSameOrigin(r *http.Request) bool { + origin := r.Header["Origin"] + if len(origin) == 0 { + return true + } + u, err := url.Parse(origin[0]) + if err != nil { + return false + } + return u.Host == r.Host +} + +func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string { + if u.Subprotocols != nil { + clientProtocols := Subprotocols(r) + for _, serverProtocol := range u.Subprotocols { + for _, clientProtocol := range clientProtocols { + if clientProtocol == serverProtocol { + return clientProtocol + } + } + } + } else if responseHeader != nil { + return responseHeader.Get("Sec-Websocket-Protocol") + } + return "" +} + +// Upgrade upgrades the HTTP server connection to the WebSocket protocol. +// +// The responseHeader is included in the response to the client's upgrade +// request. Use the responseHeader to specify cookies (Set-Cookie) and the +// application negotiated subprotocol (Sec-Websocket-Protocol). +// +// If the upgrade fails, then Upgrade replies to the client with an HTTP error +// response. +func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) { + if r.Method != "GET" { + return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: method not GET") + } + if values := r.Header["Sec-Websocket-Version"]; len(values) == 0 || values[0] != "13" { + return u.returnError(w, r, http.StatusBadRequest, "websocket: version != 13") + } + + if !tokenListContainsValue(r.Header, "Connection", "upgrade") { + return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find connection header with token 'upgrade'") + } + + if !tokenListContainsValue(r.Header, "Upgrade", "websocket") { + return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find upgrade header with token 'websocket'") + } + + checkOrigin := u.CheckOrigin + if checkOrigin == nil { + checkOrigin = checkSameOrigin + } + if !checkOrigin(r) { + return u.returnError(w, r, http.StatusForbidden, "websocket: origin not allowed") + } + + challengeKey := r.Header.Get("Sec-Websocket-Key") + if challengeKey == "" { + return u.returnError(w, r, http.StatusBadRequest, "websocket: key missing or blank") + } + + subprotocol := u.selectSubprotocol(r, responseHeader) + + var ( + netConn net.Conn + br *bufio.Reader + err error + ) + + h, ok := w.(http.Hijacker) + if !ok { + return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker") + } + var rw *bufio.ReadWriter + netConn, rw, err = h.Hijack() + if err != nil { + return u.returnError(w, r, http.StatusInternalServerError, err.Error()) + } + br = rw.Reader + + if br.Buffered() > 0 { + netConn.Close() + return nil, errors.New("websocket: client sent data before handshake is complete") + } + + c := newConn(netConn, true, u.ReadBufferSize, u.WriteBufferSize) + c.subprotocol = subprotocol + + p := c.writeBuf[:0] + p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...) + p = append(p, computeAcceptKey(challengeKey)...) + p = append(p, "\r\n"...) + if c.subprotocol != "" { + p = append(p, "Sec-Websocket-Protocol: "...) + p = append(p, c.subprotocol...) + p = append(p, "\r\n"...) + } + for k, vs := range responseHeader { + if k == "Sec-Websocket-Protocol" { + continue + } + for _, v := range vs { + p = append(p, k...) + p = append(p, ": "...) + for i := 0; i < len(v); i++ { + b := v[i] + if b <= 31 { + // prevent response splitting. + b = ' ' + } + p = append(p, b) + } + p = append(p, "\r\n"...) + } + } + p = append(p, "\r\n"...) + + // Clear deadlines set by HTTP server. + netConn.SetDeadline(time.Time{}) + + if u.HandshakeTimeout > 0 { + netConn.SetWriteDeadline(time.Now().Add(u.HandshakeTimeout)) + } + if _, err = netConn.Write(p); err != nil { + netConn.Close() + return nil, err + } + if u.HandshakeTimeout > 0 { + netConn.SetWriteDeadline(time.Time{}) + } + + return c, nil +} + +// Upgrade upgrades the HTTP server connection to the WebSocket protocol. +// +// This function is deprecated, use websocket.Upgrader instead. +// +// The application is responsible for checking the request origin before +// calling Upgrade. An example implementation of the same origin policy is: +// +// if req.Header.Get("Origin") != "http://"+req.Host { +// http.Error(w, "Origin not allowed", 403) +// return +// } +// +// If the endpoint supports subprotocols, then the application is responsible +// for negotiating the protocol used on the connection. Use the Subprotocols() +// function to get the subprotocols requested by the client. Use the +// Sec-Websocket-Protocol response header to specify the subprotocol selected +// by the application. +// +// The responseHeader is included in the response to the client's upgrade +// request. Use the responseHeader to specify cookies (Set-Cookie) and the +// negotiated subprotocol (Sec-Websocket-Protocol). +// +// The connection buffers IO to the underlying network connection. The +// readBufSize and writeBufSize parameters specify the size of the buffers to +// use. Messages can be larger than the buffers. +// +// If the request is not a valid WebSocket handshake, then Upgrade returns an +// error of type HandshakeError. Applications should handle this error by +// replying to the client with an HTTP error response. +func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) { + u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize} + u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) { + // don't return errors to maintain backwards compatibility + } + u.CheckOrigin = func(r *http.Request) bool { + // allow all connections by default + return true + } + return u.Upgrade(w, r, responseHeader) +} + +// Subprotocols returns the subprotocols requested by the client in the +// Sec-Websocket-Protocol header. +func Subprotocols(r *http.Request) []string { + h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol")) + if h == "" { + return nil + } + protocols := strings.Split(h, ",") + for i := range protocols { + protocols[i] = strings.TrimSpace(protocols[i]) + } + return protocols +} + +// IsWebSocketUpgrade returns true if the client requested upgrade to the +// WebSocket protocol. +func IsWebSocketUpgrade(r *http.Request) bool { + return tokenListContainsValue(r.Header, "Connection", "upgrade") && + tokenListContainsValue(r.Header, "Upgrade", "websocket") +} diff --git a/vendor/github.com/gorilla/websocket/server_test.go b/vendor/github.com/gorilla/websocket/server_test.go new file mode 100644 index 00000000..0a28141d --- /dev/null +++ b/vendor/github.com/gorilla/websocket/server_test.go @@ -0,0 +1,51 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "net/http" + "reflect" + "testing" +) + +var subprotocolTests = []struct { + h string + protocols []string +}{ + {"", nil}, + {"foo", []string{"foo"}}, + {"foo,bar", []string{"foo", "bar"}}, + {"foo, bar", []string{"foo", "bar"}}, + {" foo, bar", []string{"foo", "bar"}}, + {" foo, bar ", []string{"foo", "bar"}}, +} + +func TestSubprotocols(t *testing.T) { + for _, st := range subprotocolTests { + r := http.Request{Header: http.Header{"Sec-Websocket-Protocol": {st.h}}} + protocols := Subprotocols(&r) + if !reflect.DeepEqual(st.protocols, protocols) { + t.Errorf("SubProtocols(%q) returned %#v, want %#v", st.h, protocols, st.protocols) + } + } +} + +var isWebSocketUpgradeTests = []struct { + ok bool + h http.Header +}{ + {false, http.Header{"Upgrade": {"websocket"}}}, + {false, http.Header{"Connection": {"upgrade"}}}, + {true, http.Header{"Connection": {"upgRade"}, "Upgrade": {"WebSocket"}}}, +} + +func TestIsWebSocketUpgrade(t *testing.T) { + for _, tt := range isWebSocketUpgradeTests { + ok := IsWebSocketUpgrade(&http.Request{Header: tt.h}) + if tt.ok != ok { + t.Errorf("IsWebSocketUpgrade(%v) returned %v, want %v", tt.h, ok, tt.ok) + } + } +} diff --git a/vendor/github.com/gorilla/websocket/util.go b/vendor/github.com/gorilla/websocket/util.go new file mode 100644 index 00000000..ffdc265e --- /dev/null +++ b/vendor/github.com/gorilla/websocket/util.go @@ -0,0 +1,44 @@ +// Copyright 2013 The Gorilla WebSocket 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 websocket + +import ( + "crypto/rand" + "crypto/sha1" + "encoding/base64" + "io" + "net/http" + "strings" +) + +// tokenListContainsValue returns true if the 1#token header with the given +// name contains token. +func tokenListContainsValue(header http.Header, name string, value string) bool { + for _, v := range header[name] { + for _, s := range strings.Split(v, ",") { + if strings.EqualFold(value, strings.TrimSpace(s)) { + return true + } + } + } + return false +} + +var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11") + +func computeAcceptKey(challengeKey string) string { + h := sha1.New() + h.Write([]byte(challengeKey)) + h.Write(keyGUID) + return base64.StdEncoding.EncodeToString(h.Sum(nil)) +} + +func generateChallengeKey() (string, error) { + p := make([]byte, 16) + if _, err := io.ReadFull(rand.Reader, p); err != nil { + return "", err + } + return base64.StdEncoding.EncodeToString(p), nil +} diff --git a/vendor/github.com/gorilla/websocket/util_test.go b/vendor/github.com/gorilla/websocket/util_test.go new file mode 100644 index 00000000..91f70ceb --- /dev/null +++ b/vendor/github.com/gorilla/websocket/util_test.go @@ -0,0 +1,34 @@ +// Copyright 2014 The Gorilla WebSocket 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 websocket + +import ( + "net/http" + "testing" +) + +var tokenListContainsValueTests = []struct { + value string + ok bool +}{ + {"WebSocket", true}, + {"WEBSOCKET", true}, + {"websocket", true}, + {"websockets", false}, + {"x websocket", false}, + {"websocket x", false}, + {"other,websocket,more", true}, + {"other, websocket, more", true}, +} + +func TestTokenListContainsValue(t *testing.T) { + for _, tt := range tokenListContainsValueTests { + h := http.Header{"Upgrade": {tt.value}} + ok := tokenListContainsValue(h, "Upgrade", "websocket") + if ok != tt.ok { + t.Errorf("tokenListContainsValue(h, n, %q) = %v, want %v", tt.value, ok, tt.ok) + } + } +} diff --git a/vendor/github.com/rancher/go-rancher/.drone.yml b/vendor/github.com/rancher/go-rancher/.drone.yml new file mode 100644 index 00000000..0cbfb150 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/.drone.yml @@ -0,0 +1,3 @@ +image: rancher/dind:v0.3.0 +script: + - ./scripts/ci diff --git a/vendor/github.com/rancher/go-rancher/.gitignore b/vendor/github.com/rancher/go-rancher/.gitignore new file mode 100644 index 00000000..62d2c27b --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/.gitignore @@ -0,0 +1,5 @@ +*.swp + +/build +/bin +/gopath diff --git a/vendor/github.com/rancher/go-rancher/.package b/vendor/github.com/rancher/go-rancher/.package new file mode 100644 index 00000000..c2777322 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/.package @@ -0,0 +1 @@ +github.com/rancher/go-rancher diff --git a/vendor/github.com/rancher/go-rancher/.wrap-docker-args b/vendor/github.com/rancher/go-rancher/.wrap-docker-args new file mode 100644 index 00000000..3c1a8ef1 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/.wrap-docker-args @@ -0,0 +1 @@ +--privileged diff --git a/vendor/github.com/rancher/go-rancher/Dockerfile b/vendor/github.com/rancher/go-rancher/Dockerfile new file mode 100644 index 00000000..77c736ba --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/Dockerfile @@ -0,0 +1,4 @@ +FROM rancher/dind:v0.3.0 +COPY ./scripts/bootstrap /scripts/bootstrap +RUN /scripts/bootstrap +WORKDIR /source diff --git a/vendor/github.com/rancher/go-rancher/LICENSE b/vendor/github.com/rancher/go-rancher/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/LICENSE @@ -0,0 +1,177 @@ + + 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/vendor/github.com/rancher/go-rancher/README.md b/vendor/github.com/rancher/go-rancher/README.md new file mode 100644 index 00000000..247a6b90 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/README.md @@ -0,0 +1,35 @@ +# Go Bindings for Rancher API + +# Building + +```sh +godep go build ./client +``` + +# Tests + +```sh +godep go test ./client +``` +# Contact +For bugs, questions, comments, corrections, suggestions, etc., open an issue in + [rancher/rancher](//github.com/rancher/rancher/issues) with a title starting with `[go-rancher] `. + +Or just [click here](//github.com/rancher/rancher/issues/new?title=%5Bgo-rancher%5D%20) to create a new issue. + + +# License +Copyright (c) 2014-2015 [Rancher Labs, Inc.](http://rancher.com) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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/rancher/go-rancher/api/api.go b/vendor/github.com/rancher/go-rancher/api/api.go new file mode 100644 index 00000000..83717a2d --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/api.go @@ -0,0 +1,141 @@ +package api + +import ( + "encoding/json" + "errors" + "reflect" + + "github.com/Sirupsen/logrus" + "github.com/rancher/go-rancher/client" +) + +func toMap(obj interface{}) (map[string]interface{}, error) { + result := map[string]interface{}{} + bytes, err := json.Marshal(obj) + if err != nil { + return result, err + } + + err = json.Unmarshal(bytes, &result) + return result, err +} + +func getEmbedded(obj interface{}, checkType reflect.Type) interface{} { + val := reflect.ValueOf(obj) + for val.Kind() == reflect.Ptr || val.Kind() == reflect.Interface { + val = val.Elem() + } + + if val.Kind() != reflect.Struct { + panic("Passed type is not a struct got: " + val.Kind().String()) + } + + t := val.Type() + for i := 0; i < val.NumField(); i++ { + if t.Field(i).Anonymous && t.Field(i).Type == checkType { + if !val.Field(i).CanAddr() { + panic("Field " + t.Field(i).Name + " is not addressable, pass pointer") + } + return val.Field(i).Addr().Interface() + } + } + + return nil +} + +func getCollection(obj interface{}) *client.Collection { + val := getEmbedded(obj, reflect.TypeOf(client.Collection{})) + if val == nil { + return nil + } + return val.(*client.Collection) +} + +func getResource(obj interface{}) *client.Resource { + r, ok := obj.(*client.Resource) + if ok { + return r + } + rObj, ok := obj.(client.Resource) + if ok { + return &rObj + } + val := getEmbedded(obj, reflect.TypeOf(client.Resource{})) + if val == nil { + return nil + } + return val.(*client.Resource) +} + +func CollectionToMap(obj interface{}, schemas *client.Schemas) (map[string]interface{}, []map[string]interface{}, error) { + result := map[string]interface{}{} + data := []map[string]interface{}{} + if obj == nil { + return result, data, nil + } + + c := getCollection(obj) + if c == nil { + return result, data, errors.New("value is not a Collection") + } + + val := reflect.ValueOf(obj) + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + + val = val.FieldByName("Data") + for i := 0; i < val.Len(); i++ { + obj := val.Index(i) + if obj.Kind() != reflect.Ptr && obj.Kind() != reflect.Interface { + obj = obj.Addr() + } + dataObj, err := ResourceToMap(obj.Interface(), schemas) + if err != nil { + return result, data, err + } + + data = append(data, dataObj) + } + + collectionMap, err := toMap(obj) + if err != nil { + return result, data, err + } + + collectionMap["data"] = data + return collectionMap, data, nil +} + +func ResourceToMap(obj interface{}, schemas *client.Schemas) (map[string]interface{}, error) { + result := map[string]interface{}{} + if obj == nil { + return result, nil + } + + resource := getResource(obj) + if resource == nil { + return result, errors.New("value is not a Resource") + } + + objMap, err := toMap(obj) + if err != nil { + return result, err + } + + schema, ok := schemas.CheckSchema(resource.Type) + if !ok { + logrus.Errorf("Attempting to Write an unknown type: %s", resource.Type) + return result, nil + } + + for k, v := range objMap { + _, ok := schema.CheckField(k) + if !ok { + continue + } + result[k] = v + } + + return result, nil +} diff --git a/vendor/github.com/rancher/go-rancher/api/context.go b/vendor/github.com/rancher/go-rancher/api/context.go new file mode 100644 index 00000000..01125009 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/context.go @@ -0,0 +1,47 @@ +package api + +import ( + "net/http" + + "github.com/gorilla/context" + "github.com/rancher/go-rancher/client" +) + +type key int + +const ( + contextKey key = 0 +) + +type ApiContext struct { + r *http.Request + schemas *client.Schemas + UrlBuilder UrlBuilder + apiResponseWriter ApiResponseWriter + responseWriter http.ResponseWriter +} + +func GetApiContext(r *http.Request) *ApiContext { + if rv := context.Get(r, contextKey); rv != nil { + return rv.(*ApiContext) + } + return nil +} + +func CreateApiContext(rw http.ResponseWriter, r *http.Request, schemas *client.Schemas) error { + urlBuilder, err := NewUrlBuilder(r, schemas) + if err != nil { + return err + } + + apiContext := &ApiContext{ + r: r, + schemas: schemas, + UrlBuilder: urlBuilder, + apiResponseWriter: parseResponseType(r), + responseWriter: rw, + } + + context.Set(r, contextKey, apiContext) + return nil +} diff --git a/vendor/github.com/rancher/go-rancher/api/handler.go b/vendor/github.com/rancher/go-rancher/api/handler.go new file mode 100644 index 00000000..aa8aeb0f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/handler.go @@ -0,0 +1,115 @@ +package api + +import ( + "net/http" + + "github.com/Sirupsen/logrus" + "github.com/gorilla/context" + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/client" +) + +func ApiHandlerFunc(schemas *client.Schemas, f http.HandlerFunc) http.HandlerFunc { + return func(rw http.ResponseWriter, r *http.Request) { + ApiHandler(schemas, f).ServeHTTP(rw, r) + } +} + +func ApiHandler(schemas *client.Schemas, f http.Handler) http.Handler { + return context.ClearHandler(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if err := CreateApiContext(rw, r, schemas); err != nil { + logrus.WithField("err", err).Errorf("Failed to create API context") + rw.WriteHeader(500) + return + } + + f.ServeHTTP(rw, r) + })) +} + +func VersionsHandler(schemas *client.Schemas, versions ...string) http.Handler { + return ApiHandler(schemas, http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + apiContext := GetApiContext(r) + + collection := client.GenericCollection{ + Collection: client.Collection{ + Links: map[string]string{}, + }, + Data: []interface{}{}, + } + + for i, version := range versions { + collection.Data = append(collection.Data, client.Resource{ + Id: version, + Links: map[string]string{ + SELF: apiContext.UrlBuilder.Version(version), + }, + Type: "apiVersion", + }) + + if i == len(versions)-1 { + collection.Links[LATEST] = apiContext.UrlBuilder.Version(version) + } + } + + apiContext.Write(&collection) + })) +} + +func contains(list []string, item string) bool { + for _, i := range list { + if i == item { + return true + } + } + return false +} + +func VersionHandler(schemas *client.Schemas, version string) http.Handler { + return ApiHandler(schemas, http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + apiContext := GetApiContext(r) + + versionResource := client.Resource{ + Id: version, + Type: "apiVersion", + Links: map[string]string{}, + } + + for _, schema := range schemas.Data { + if contains(schema.CollectionMethods, "GET") { + versionResource.Links[schema.PluralName] = apiContext.UrlBuilder.Collection(schema.Id) + } + } + + apiContext.Write(&versionResource) + })) +} + +func SchemasHandler(schemas *client.Schemas) http.Handler { + return ApiHandler(schemas, http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + apiContext := GetApiContext(r) + schemasCopy := *schemas + for i := range schemasCopy.Data { + populateSchema(apiContext, &schemasCopy.Data[i]) + } + apiContext.Write(&schemasCopy) + })) +} + +func populateSchema(apiContext *ApiContext, schema *client.Schema) { + if contains(schema.CollectionMethods, "GET") { + schema.Links["collection"] = apiContext.UrlBuilder.Collection(schema.Id) + } +} + +func SchemaHandler(schemas *client.Schemas) http.Handler { + return ApiHandler(schemas, http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + apiContext := GetApiContext(r) + + schema := schemas.Schema(mux.Vars(r)["id"]) + + populateSchema(apiContext, &schema) + + apiContext.Write(&schema) + })) +} diff --git a/vendor/github.com/rancher/go-rancher/api/html_writer.go b/vendor/github.com/rancher/go-rancher/api/html_writer.go new file mode 100644 index 00000000..fb456038 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/html_writer.go @@ -0,0 +1,78 @@ +package api + +import ( + "encoding/json" + "net/http" + "strings" +) + +const ( + before = ` + + + +`) +) + +type HtmlWriter struct { + CssUrl, JsUrl string + r *http.Request +} + +func (j *HtmlWriter) Write(obj interface{}, rw http.ResponseWriter) error { + apiContext := GetApiContext(j.r) + rw.Header().Set("X-API-Schemas", apiContext.UrlBuilder.Collection("schema")) + + if rw.Header().Get("Content-Type") == "" { + rw.Header().Set("Content-Type", "text/html; charset=utf-8") + } + + if _, err := rw.Write([]byte(j.before())); err != nil { + return err + } + + enc := json.NewEncoder(rw) + if err := enc.Encode(obj); err != nil { + return err + } + + if _, err := rw.Write([]byte(after)); err != nil { + return err + } + + return nil +} + +func (j *HtmlWriter) before() string { + css := j.CssUrl + if css == "" { + css = defaultCssUrl + } + + js := j.JsUrl + if js == "" { + js = defaultJsUrl + } + + apiContext := GetApiContext(j.r) + + content := strings.Replace(before, "%CSS%", css, -1) + content = strings.Replace(content, "%JS%", js, -1) + content = strings.Replace(content, "%SCHEMAS%", apiContext.UrlBuilder.Collection("schema"), -1) + + return content +} diff --git a/vendor/github.com/rancher/go-rancher/api/json_writer.go b/vendor/github.com/rancher/go-rancher/api/json_writer.go new file mode 100644 index 00000000..e0626a3d --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/json_writer.go @@ -0,0 +1,22 @@ +package api + +import ( + "encoding/json" + "net/http" +) + +type JsonWriter struct { + r *http.Request +} + +func (j *JsonWriter) Write(obj interface{}, rw http.ResponseWriter) error { + apiContext := GetApiContext(j.r) + rw.Header().Set("X-API-Schemas", apiContext.UrlBuilder.Collection("schema")) + + if rw.Header().Get("Content-Type") == "" { + rw.Header().Set("Content-Type", "application/json") + } + + enc := json.NewEncoder(rw) + return enc.Encode(obj) +} diff --git a/vendor/github.com/rancher/go-rancher/api/reader.go b/vendor/github.com/rancher/go-rancher/api/reader.go new file mode 100644 index 00000000..92e720f5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/reader.go @@ -0,0 +1,8 @@ +package api + +import "encoding/json" + +func (a *ApiContext) Read(obj interface{}) error { + decoder := json.NewDecoder(a.r.Body) + return decoder.Decode(obj) +} diff --git a/vendor/github.com/rancher/go-rancher/api/url.go b/vendor/github.com/rancher/go-rancher/api/url.go new file mode 100644 index 00000000..d25f94bf --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/url.go @@ -0,0 +1,270 @@ +package api + +import ( + "bytes" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/rancher/go-rancher/client" +) + +const ( + DEFAULT_OVERRIDE_URL_HEADER = "X-API-request-url" + DEFAULT_OVERRIDE_CLIENT_IP_HEADER = "X-API-client-ip" + FORWARDED_FOR_HEADER = "X-Forwarded-For" + FORWARDED_HOST_HEADER = "X-Forwarded-Host" + FORWARDED_PROTO_HEADER = "X-Forwarded-Proto" + FORWARDED_PORT_HEADER = "X-Forwarded-Port" + SELF = "self" + COLLECTION = "collection" + LATEST = "latest" + HTML = "html" + JSON = "json" +) + +var ( + allowedFormats = map[string]bool{ + HTML: true, + JSON: true, + } +) + +type UrlBuilder interface { + ActionLink(resource client.Resource, name string) string + Current() string + Collection(resourceType string) string + Link(resource client.Resource, name string) string + ReferenceLink(resource client.Resource) string + ReferenceByIdLink(resourceType string, id string) string + Version(version string) string +} + +func NewUrlBuilder(r *http.Request, schemas *client.Schemas) (UrlBuilder, error) { + requestUrl := parseRequestUrl(r) + responseUrlBase, err := parseResponseUrlBase(requestUrl, r) + if err != nil { + return nil, err + } + + builder := &urlBuilder{ + schemas: schemas, + requestUrl: requestUrl, + responseUrlBase: responseUrlBase, + apiVersion: parseRequestVersion(r), + } + + return builder, err +} + +type urlBuilder struct { + schemas *client.Schemas + //r *http.Request + requestUrl string + responseUrlBase string + //query string + apiVersion string + subContext string +} + +func (u *urlBuilder) Current() string { + return u.requestUrl +} + +func (u *urlBuilder) Collection(resourceType string) string { + plural := u.getPluralName(resourceType) + return u.constructBasicUrl(plural) +} + +func (u *urlBuilder) Link(resource client.Resource, name string) string { + if name == "" { + return "" + } + + return u.constructBasicUrl(u.getPluralName(resource.Type), resource.Id, strings.ToLower(name)) +} + +func (u *urlBuilder) ReferenceLink(resource client.Resource) string { + return u.ReferenceByIdLink(resource.Type, resource.Id) +} + +func (u *urlBuilder) ReferenceByIdLink(resourceType string, id string) string { + return u.constructBasicUrl(u.getPluralName(resourceType), id) +} + +func (u *urlBuilder) ActionLink(resource client.Resource, action string) string { + return u.constructBasicUrl(u.getPluralName(resource.Type), resource.Id) + "?action=" + action +} + +func (u *urlBuilder) Version(version string) string { + return fmt.Sprintf("%s/%s", u.responseUrlBase, version) +} + +func (u *urlBuilder) constructBasicUrl(parts ...string) string { + buffer := bytes.Buffer{} + + buffer.WriteString(u.responseUrlBase) + buffer.WriteString("/") + buffer.WriteString(u.apiVersion) + buffer.WriteString(u.subContext) + + for _, part := range parts { + if part == "" { + return "" + } + buffer.WriteString("/") + buffer.WriteString(part) + } + + return buffer.String() +} + +func (u *urlBuilder) getPluralName(resourceType string) string { + schema := u.schemas.Schema(resourceType) + if schema.PluralName == "" { + return strings.ToLower(resourceType) + } + return strings.ToLower(schema.PluralName) +} + +// Constructs the request URL based off of standard headers in the request, falling back to the HttpServletRequest.getRequestURL() +// if the headers aren't available. Here is the ordered list of how we'll attempt to construct the URL: +// - x-api-request-url +// - x-forwarded-proto://x-forwarded-host:x-forwarded-port/HttpServletRequest.getRequestURI() +// - x-forwarded-proto://x-forwarded-host/HttpServletRequest.getRequestURI() +// - x-forwarded-proto://host:x-forwarded-port/HttpServletRequest.getRequestURI() +// - x-forwarded-proto://host/HttpServletRequest.getRequestURI() request.getRequestURL() +// +// Additional notes: +// - With x-api-request-url, the query string is passed, it will be dropped to match the other formats. +// - If the x-forwarded-host/host header has a port and x-forwarded-port has been passed, x-forwarded-port will be used. +func parseRequestUrl(r *http.Request) string { + // Get url from custom x-api-request-url header + requestUrl := getOverrideHeader(r, DEFAULT_OVERRIDE_URL_HEADER, "") + if requestUrl != "" { + return strings.SplitN(requestUrl, "?", 2)[0] + } + + // Get url from standard headers + requestUrl = getUrlFromStandardHeaders(r) + if requestUrl != "" { + return requestUrl + } + + // Use incoming url + return fmt.Sprintf("http://%s%s", r.Host, r.URL.Path) +} + +func getUrlFromStandardHeaders(r *http.Request) string { + xForwardedProto := getOverrideHeader(r, FORWARDED_PROTO_HEADER, "") + if xForwardedProto == "" { + return "" + } + + host := getOverrideHeader(r, FORWARDED_HOST_HEADER, "") + if host == "" { + host = r.Host + } + + if host == "" { + return "" + } + + port := getOverrideHeader(r, FORWARDED_PORT_HEADER, "") + if port == "443" || port == "80" { + port = "" // Don't include default ports in url + } + + if port != "" && strings.Contains(host, ":") { + // Have to strip the port that is in the host. Handle IPv6, which has this format: [::1]:8080 + if (strings.HasPrefix(host, "[") && strings.Contains(host, "]:")) || !strings.HasPrefix(host, "[") { + host = host[0:strings.LastIndex(host, ":")] + } + } + + if port != "" { + port = ":" + port + } + + return fmt.Sprintf("%s://%s%s%s", xForwardedProto, host, port, r.URL.Path) +} + +func getOverrideHeader(r *http.Request, header string, defaultValue string) string { + // Need to handle comma separated hosts in X-Forwarded-For + value := r.Header.Get(header) + if value != "" { + return strings.TrimSpace(strings.Split(value, ",")[0]) + } + return defaultValue +} + +func parseResponseUrlBase(requestUrl string, r *http.Request) (string, error) { + path := r.URL.Path + + index := strings.LastIndex(requestUrl, path) + if index == -1 { + // Fallback, if we can't find path in requestUrl, then we just assume the base is the root of the web request + u, err := url.Parse(requestUrl) + if err != nil { + return "", err + } + + buffer := bytes.Buffer{} + buffer.WriteString(u.Scheme) + buffer.WriteString("://") + buffer.WriteString(u.Host) + return buffer.String(), nil + } else { + return requestUrl[0:index], nil + } +} + +func parseRequestVersion(r *http.Request) string { + path := r.URL.Path + + if !strings.HasPrefix(path, "/") || len(path) < 2 { + return "" + } + + return strings.Split(path, "/")[1] +} + +func parseResponseType(r *http.Request) ApiResponseWriter { + format := r.URL.Query().Get("_format") + + if format != "" { + format = strings.ToLower(strings.TrimSpace(format)) + } + + /* Format specified */ + if format != "" && allowedFormats[format] { + switch { + case format == HTML: + return &HtmlWriter{r: r} + case format == JSON: + return &JsonWriter{r: r} + } + } + + // User agent has Mozilla and browser accepts */* + if IsBrowser(r, true) { + return &HtmlWriter{r: r} + } else { + return &JsonWriter{r: r} + } +} + +func IsBrowser(r *http.Request, checkAccepts bool) bool { + accepts := r.Header.Get("Accept") + userAgent := r.Header.Get("User-Agent") + + if accepts == "" || !checkAccepts { + accepts = "*/*" + } + + accepts = strings.ToLower(accepts) + + // User agent has Mozilla and browser accepts */* + return strings.Contains(strings.ToLower(userAgent), "mozilla") && strings.Contains(accepts, "*/*") +} diff --git a/vendor/github.com/rancher/go-rancher/api/writer.go b/vendor/github.com/rancher/go-rancher/api/writer.go new file mode 100644 index 00000000..eb3c94a2 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/api/writer.go @@ -0,0 +1,146 @@ +package api + +import ( + "fmt" + "net/http" + "reflect" + + "github.com/Sirupsen/logrus" + "github.com/rancher/go-rancher/client" +) + +type ApiResponseWriter interface { + Write(obj interface{}, rw http.ResponseWriter) error +} + +func (a *ApiContext) WriteErr(err error) { + logrus.Errorf("Error in request: %v", err) + a.responseWriter.WriteHeader(500) + writeErr := a.WriteResource(&client.ServerApiError{ + Resource: client.Resource{ + Type: "error", + }, + Status: 500, + Code: "Server Error", + Message: err.Error(), + }) + if writeErr != nil { + logrus.Errorf("Failed to write err: %v", err) + } +} + +func (a *ApiContext) Write(obj interface{}) { + var err error + collection := getCollection(obj) + if collection != nil { + err = a.WriteCollection(obj) + } else { + err = a.WriteResource(obj) + } + + if err != nil { + logrus.WithField("err", err).Errorf("Failed to write response") + a.WriteErr(err) + } +} + +func stringSetIfNot(data map[string]string, key, value string) map[string]string { + if v, ok := data[key]; !ok || v == "" { + data[key] = value + } + + return data +} + +func setIfNot(data map[string]interface{}, key string, value interface{}) map[string]interface{} { + if v, ok := data[key]; !ok || v == nil { + data[key] = value + } + + return data +} + +func (a *ApiContext) WriteCollection(obj interface{}) error { + collectionData, resourcesData, err := CollectionToMap(obj, a.schemas) + if err != nil { + return err + } + + a.populateCollection(collectionData, resourcesData) + for _, resource := range resourcesData { + a.populateResource(resource) + } + + return a.apiResponseWriter.Write(collectionData, a.responseWriter) +} + +func (a *ApiContext) WriteResource(obj interface{}) error { + resourceData, err := ResourceToMap(obj, a.schemas) + if err != nil { + return err + } + + a.populateResource(resourceData) + return a.apiResponseWriter.Write(resourceData, a.responseWriter) +} + +func mapInterfaceToString(input interface{}) map[string]string { + result := map[string]string{} + if input == nil { + return result + } + switch i := input.(type) { + case map[string]string: + return i + case map[string]interface{}: + for k, v := range i { + result[k] = fmt.Sprintf("%s", v) + } + default: + logrus.Infof("Unknown type", reflect.TypeOf(input)) + } + return result +} + +func getString(data map[string]interface{}, key string) string { + if v, ok := data[key]; ok { + return fmt.Sprintf("%s", v) + } else { + return "" + } + +} + +func getStringMap(data map[string]interface{}, key string) map[string]string { + result := map[string]string{} + if v, ok := data[key]; ok { + result = mapInterfaceToString(v) + } + data[key] = result + return result +} + +func (a *ApiContext) populateCollection(c map[string]interface{}, data []map[string]interface{}) { + stringSetIfNot(getStringMap(c, "links"), "self", a.UrlBuilder.Current()) + + if _, ok := c["type"]; !ok { + c["type"] = "collection" + } + + if len(data) > 0 { + setIfNot(c, "resourceType", data[0]["type"]) + } +} + +func (a *ApiContext) populateResource(c map[string]interface{}) { + resourceType := getString(c, "type") + resourceId := getString(c, "id") + + if resourceType != "" && resourceId != "" { + stringSetIfNot(getStringMap(c, "links"), "self", a.UrlBuilder.ReferenceByIdLink(resourceType, resourceId)) + } + + stringSetIfNot(getStringMap(c, "links"), "self", a.UrlBuilder.Current()) + // This will create an empty map if not + getStringMap(c, "actions") +} diff --git a/vendor/github.com/rancher/go-rancher/client/client.go b/vendor/github.com/rancher/go-rancher/client/client.go new file mode 100644 index 00000000..0b14ada3 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/client.go @@ -0,0 +1,7 @@ +package client + +type RancherBaseClient struct { + Opts *ClientOpts + Schemas *Schemas + Types map[string]Schema +} diff --git a/vendor/github.com/rancher/go-rancher/client/client_test.go b/vendor/github.com/rancher/go-rancher/client/client_test.go new file mode 100644 index 00000000..ec71ef07 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/client_test.go @@ -0,0 +1,218 @@ +package client + +import ( + "testing" + "time" +) + +const ( + PROJECT_URL = "http://localhost:8080/v1/projects/1a5/schemas" + URL = "http://localhost:8080/v1" + ACCESS_KEY = "admin" + SECRET_KEY = "adminpass" + MAX_WAIT = time.Duration(time.Second * 10) +) + +func newClient(t *testing.T, url string) *RancherClient { + client, err := NewRancherClient(&ClientOpts{ + Url: url, + AccessKey: ACCESS_KEY, + SecretKey: SECRET_KEY, + }) + + if err != nil { + t.Fatal("Failed to create client", err) + } + + return client +} + +func TestClientLoad(t *testing.T) { + client := newClient(t, URL) + if client.Schemas == nil { + t.Fatal("Failed to load schema") + } + + if len(client.Schemas.Data) == 0 { + t.Fatal("Schemas is empty") + } + + if _, ok := client.Types["container"]; !ok { + t.Fatal("Failed to find container type") + } +} + +func TestContainerList(t *testing.T) { + client := newClient(t, PROJECT_URL) + + /* Create a container to ensure list will return something */ + container, err := client.Container.Create(&Container{ + Name: "a name", + ImageUuid: "docker:nginx", + }) + if err != nil { + t.Fatal(err) + } + + defer client.Container.Delete(container) + + containers, err := client.Container.List(nil) + + if err != nil { + t.Fatal("Failed to list containers", err) + } + + if len(containers.Data) == 0 { + t.Fatal("No containers found") + } + + if len(containers.Data[0].Id) == 0 { + t.Fatal("Container ID is not set") + } + + listOpts := NewListOpts() + listOpts.Filters["id"] = "comeBackEmpty" + containers, err = client.Container.List(listOpts) + + if err != nil { + t.Fatal("Failed to list containers", err) + } + + if len(containers.Data) != 0 { + t.Fatal("Filter should have found no contianers.") + } +} + +func TestContainerCreate(t *testing.T) { + client := newClient(t, PROJECT_URL) + container, err := client.Container.Create(&Container{ + Name: "a name", + ImageUuid: "docker:nginx", + }) + + if err != nil { + t.Fatal(err) + } + + defer client.Container.Delete(container) + + if container.Name != "a name" { + t.Fatal("Field name is wrong [" + container.Name + "]") + } + + if container.ImageUuid != "docker:nginx" { + t.Fatal("Field imageUuid is wrong [" + container.ImageUuid + "]") + } +} + +func TestContainerUpdate(t *testing.T) { + client := newClient(t, PROJECT_URL) + container, err := client.Container.Create(&Container{ + Name: "a name", + ImageUuid: "docker:nginx", + }) + + if err != nil { + t.Fatal(err) + } + + defer client.Container.Delete(container) + + if container.Name != "a name" { + t.Fatal("Field name is wrong [" + container.Name + "]") + } + + container, err = client.Container.Update(container, &Container{ + Name: "a different name", + }) + + if container.Name != "a different name" { + t.Fatal("Field name is wrong [" + container.Name + "]") + } + + by_id_container, err := client.Container.ById(string(container.Id)) + if err != nil { + t.Fatal(err) + } + + if by_id_container.Id != container.Id { + t.Fatal("Container from by ID did not match") + } + + if by_id_container.Name != container.Name { + t.Fatal("Container from by ID did not match for name") + } +} + +func TestContainerDelete(t *testing.T) { + client := newClient(t, PROJECT_URL) + container, err := client.Container.Create(&Container{ + Name: "a name", + ImageUuid: "docker:nginx", + }) + + if err != nil { + t.Fatal(err) + } + + err = client.Container.Delete(container) + if err != nil { + t.Fatal("Failed to delete", err) + } +} + +func TestContainerNotExists(t *testing.T) { + client := newClient(t, PROJECT_URL) + ret, err := client.Container.ById("badId1") + if ret != nil || err != nil { + t.Fatal("Should receive nothing on 404") + } +} + +func TestAccountAction(t *testing.T) { + client := newClient(t, URL) + account, err := client.Account.Create(&Account{ + Name: "a name", + }) + + if err != nil { + t.Fatal(err) + } + + defer client.Account.Delete(account) + + account = waitAccountTransition(account, client, t) + if account.State == "inactive" { + t.Fatal("Account shouldnt be inactive.") + } + + account, err = client.Account.ActionDeactivate(account) + if err != nil { + t.Fatal(err) + } + + account = waitAccountTransition(account, client, t) + if account.State != "inactive" { + t.Fatal("Account didnt deactivate") + } +} + +func waitAccountTransition(account *Account, client *RancherClient, t *testing.T) *Account { + timeoutAt := time.Now().Add(MAX_WAIT) + ticker := time.NewTicker(time.Millisecond * 250) + defer ticker.Stop() + for tick := range ticker.C { + account, err := client.Account.ById(account.Id) + if err != nil { + t.Fatal("Couldn't get account") + } + if account.Transitioning != "yes" { + return account + } + if tick.After(timeoutAt) { + t.Fatal("Timed out waiting for account to activate.") + } + } + t.Fatal("Timed out waiting for account to activate.") + return nil +} diff --git a/vendor/github.com/rancher/go-rancher/client/common.go b/vendor/github.com/rancher/go-rancher/client/common.go new file mode 100644 index 00000000..07b5e920 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/common.go @@ -0,0 +1,531 @@ +package client + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "os" + "regexp" + + "github.com/gorilla/websocket" + "time" +) + +const ( + SELF = "self" + COLLECTION = "collection" +) + +var ( + debug = false + dialer = &websocket.Dialer{} +) + +type ClientOpts struct { + Url string + AccessKey string + SecretKey string + Timeout time.Duration +} + +type ApiError struct { + StatusCode int + Url string + Msg string + Status string + Body string +} + +func (e *ApiError) Error() string { + return e.Msg +} + +func newApiError(resp *http.Response, url string) *ApiError { + contents, err := ioutil.ReadAll(resp.Body) + var body string + if err != nil { + body = "Unreadable body." + } else { + body = string(contents) + } + + data := map[string]interface{}{} + if json.Unmarshal(contents, &data) == nil { + delete(data, "id") + delete(data, "links") + delete(data, "actions") + delete(data, "type") + delete(data, "status") + buf := &bytes.Buffer{} + for k, v := range data { + if v == nil { + continue + } + if buf.Len() > 0 { + buf.WriteString(", ") + } + fmt.Fprintf(buf, "%s=%v", k, v) + } + body = buf.String() + } + formattedMsg := fmt.Sprintf("Bad response statusCode [%d]. Status [%s]. Body: [%s] from [%s]", + resp.StatusCode, resp.Status, body, url) + return &ApiError{ + Url: url, + Msg: formattedMsg, + StatusCode: resp.StatusCode, + Status: resp.Status, + Body: body, + } +} + +func contains(array []string, item string) bool { + for _, check := range array { + if check == item { + return true + } + } + + return false +} + +func appendFilters(urlString string, filters map[string]interface{}) (string, error) { + if len(filters) == 0 { + return urlString, nil + } + + u, err := url.Parse(urlString) + if err != nil { + return "", err + } + + q := u.Query() + for k, v := range filters { + q.Add(k, fmt.Sprintf("%v", v)) + } + + u.RawQuery = q.Encode() + return u.String(), nil +} + +func setupRancherBaseClient(rancherClient *RancherBaseClient, opts *ClientOpts) error { + if opts.Timeout == 0 { + opts.Timeout = time.Second * 10 + } + client := &http.Client{Timeout: opts.Timeout} + req, err := http.NewRequest("GET", opts.Url, nil) + if err != nil { + return err + } + + req.SetBasicAuth(opts.AccessKey, opts.SecretKey) + + resp, err := client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return newApiError(resp, opts.Url) + } + + schemasUrls := resp.Header.Get("X-API-Schemas") + if len(schemasUrls) == 0 { + return errors.New("Failed to find schema at [" + opts.Url + "]") + } + + if schemasUrls != opts.Url { + req, err = http.NewRequest("GET", schemasUrls, nil) + req.SetBasicAuth(opts.AccessKey, opts.SecretKey) + if err != nil { + return err + } + + resp, err = client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return newApiError(resp, opts.Url) + } + } + + var schemas Schemas + bytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + + err = json.Unmarshal(bytes, &schemas) + if err != nil { + return err + } + + rancherClient.Opts = opts + rancherClient.Schemas = &schemas + + for _, schema := range schemas.Data { + rancherClient.Types[schema.Id] = schema + } + + return nil +} + +func NewListOpts() *ListOpts { + return &ListOpts{ + Filters: map[string]interface{}{}, + } +} + +func (rancherClient *RancherBaseClient) setupRequest(req *http.Request) { + req.SetBasicAuth(rancherClient.Opts.AccessKey, rancherClient.Opts.SecretKey) +} + +func (rancherClient *RancherBaseClient) newHttpClient() *http.Client { + if rancherClient.Opts.Timeout == 0 { + rancherClient.Opts.Timeout = time.Second * 10 + } + return &http.Client{Timeout: rancherClient.Opts.Timeout} +} + +func (rancherClient *RancherBaseClient) doDelete(url string) error { + client := rancherClient.newHttpClient() + req, err := http.NewRequest("DELETE", url, nil) + if err != nil { + return err + } + + rancherClient.setupRequest(req) + + resp, err := client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode >= 300 { + return newApiError(resp, url) + } + + return nil +} + +func (rancherClient *RancherBaseClient) Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error) { + return dialer.Dial(url, http.Header(headers)) +} + +func (rancherClient *RancherBaseClient) doGet(url string, opts *ListOpts, respObject interface{}) error { + if opts == nil { + opts = NewListOpts() + } + url, err := appendFilters(url, opts.Filters) + if err != nil { + return err + } + + if debug { + fmt.Println("GET " + url) + } + + client := rancherClient.newHttpClient() + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return err + } + + rancherClient.setupRequest(req) + + resp, err := client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return newApiError(resp, url) + } + + byteContent, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + + if debug { + fmt.Println("Response <= " + string(byteContent)) + } + + return json.Unmarshal(byteContent, respObject) +} + +func (rancherClient *RancherBaseClient) doList(schemaType string, opts *ListOpts, respObject interface{}) error { + schema, ok := rancherClient.Types[schemaType] + if !ok { + return errors.New("Unknown schema type [" + schemaType + "]") + } + + if !contains(schema.CollectionMethods, "GET") { + return errors.New("Resource type [" + schemaType + "] is not listable") + } + + collectionUrl, ok := schema.Links[COLLECTION] + if !ok { + return errors.New("Failed to find collection URL for [" + schemaType + "]") + } + + return rancherClient.doGet(collectionUrl, opts, respObject) +} + +func (rancherClient *RancherBaseClient) Post(url string, createObj interface{}, respObject interface{}) error { + return rancherClient.doModify("POST", url, createObj, respObject) +} + +func (rancherClient *RancherBaseClient) GetLink(resource Resource, link string, respObject interface{}) error { + url := resource.Links[link] + if url == "" { + return fmt.Errorf("Failed to find link: %s", link) + } + + return rancherClient.doGet(url, &ListOpts{}, respObject) +} + +func (rancherClient *RancherBaseClient) doModify(method string, url string, createObj interface{}, respObject interface{}) error { + bodyContent, err := json.Marshal(createObj) + if err != nil { + return err + } + + if debug { + fmt.Println(method + " " + url) + fmt.Println("Request => " + string(bodyContent)) + } + + client := rancherClient.newHttpClient() + req, err := http.NewRequest(method, url, bytes.NewBuffer(bodyContent)) + if err != nil { + return err + } + + rancherClient.setupRequest(req) + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Content-Length", string(len(bodyContent))) + + resp, err := client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode >= 300 { + return newApiError(resp, url) + } + + byteContent, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + + if len(byteContent) > 0 { + if debug { + fmt.Println("Response <= " + string(byteContent)) + } + return json.Unmarshal(byteContent, respObject) + } + + return nil +} + +func (rancherClient *RancherBaseClient) Create(schemaType string, createObj interface{}, respObject interface{}) error { + return rancherClient.doCreate(schemaType, createObj, respObject) +} + +func (rancherClient *RancherBaseClient) doCreate(schemaType string, createObj interface{}, respObject interface{}) error { + if createObj == nil { + createObj = map[string]string{} + } + if respObject == nil { + respObject = &map[string]interface{}{} + } + schema, ok := rancherClient.Types[schemaType] + if !ok { + return errors.New("Unknown schema type [" + schemaType + "]") + } + + if !contains(schema.CollectionMethods, "POST") { + return errors.New("Resource type [" + schemaType + "] is not creatable") + } + + var collectionUrl string + collectionUrl, ok = schema.Links[COLLECTION] + if !ok { + // return errors.New("Failed to find collection URL for [" + schemaType + "]") + // This is a hack to address https://github.com/rancher/cattle/issues/254 + re := regexp.MustCompile("schemas.*") + collectionUrl = re.ReplaceAllString(schema.Links[SELF], schema.PluralName) + } + + return rancherClient.doModify("POST", collectionUrl, createObj, respObject) +} + +func (rancherClient *RancherBaseClient) Update(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error { + return rancherClient.doUpdate(schemaType, existing, updates, respObject) +} + +func (rancherClient *RancherBaseClient) doUpdate(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error { + if existing == nil { + return errors.New("Existing object is nil") + } + + selfUrl, ok := existing.Links[SELF] + if !ok { + return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing)) + } + + if updates == nil { + updates = map[string]string{} + } + + if respObject == nil { + respObject = &map[string]interface{}{} + } + + schema, ok := rancherClient.Types[schemaType] + if !ok { + return errors.New("Unknown schema type [" + schemaType + "]") + } + + if !contains(schema.ResourceMethods, "PUT") { + return errors.New("Resource type [" + schemaType + "] is not updatable") + } + + return rancherClient.doModify("PUT", selfUrl, updates, respObject) +} + +func (rancherClient *RancherBaseClient) doById(schemaType string, id string, respObject interface{}) error { + schema, ok := rancherClient.Types[schemaType] + if !ok { + return errors.New("Unknown schema type [" + schemaType + "]") + } + + if !contains(schema.ResourceMethods, "GET") { + return errors.New("Resource type [" + schemaType + "] can not be looked up by ID") + } + + collectionUrl, ok := schema.Links[COLLECTION] + if !ok { + return errors.New("Failed to find collection URL for [" + schemaType + "]") + } + + err := rancherClient.doGet(collectionUrl+"/"+id, nil, respObject) + //TODO check for 404 and return nil, nil + return err +} + +func (rancherClient *RancherBaseClient) doResourceDelete(schemaType string, existing *Resource) error { + schema, ok := rancherClient.Types[schemaType] + if !ok { + return errors.New("Unknown schema type [" + schemaType + "]") + } + + if !contains(schema.ResourceMethods, "DELETE") { + return errors.New("Resource type [" + schemaType + "] can not be deleted") + } + + selfUrl, ok := existing.Links[SELF] + if !ok { + return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing)) + } + + return rancherClient.doDelete(selfUrl) +} + +func (rancherClient *RancherBaseClient) Reload(existing *Resource, output interface{}) error { + selfUrl, ok := existing.Links[SELF] + if !ok { + return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing)) + } + + return rancherClient.doGet(selfUrl, NewListOpts(), output) +} + +func (rancherClient *RancherBaseClient) doAction(schemaType string, action string, + existing *Resource, inputObject, respObject interface{}) error { + + if existing == nil { + return errors.New("Existing object is nil") + } + + actionUrl, ok := existing.Actions[action] + if !ok { + return errors.New(fmt.Sprintf("Action [%v] not available on [%v]", action, existing)) + } + + _, ok = rancherClient.Types[schemaType] + if !ok { + return errors.New("Unknown schema type [" + schemaType + "]") + } + + var input io.Reader + + if inputObject != nil { + bodyContent, err := json.Marshal(inputObject) + if err != nil { + return err + } + if debug { + fmt.Println("Request => " + string(bodyContent)) + } + input = bytes.NewBuffer(bodyContent) + } + + client := rancherClient.newHttpClient() + req, err := http.NewRequest("POST", actionUrl, input) + if err != nil { + return err + } + + rancherClient.setupRequest(req) + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Content-Length", "0") + + resp, err := client.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode >= 300 { + return newApiError(resp, actionUrl) + } + + byteContent, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + + if debug { + fmt.Println("Response <= " + string(byteContent)) + } + + return json.Unmarshal(byteContent, respObject) +} + +func init() { + debug = os.Getenv("RANCHER_CLIENT_DEBUG") == "true" + if debug { + fmt.Println("Rancher client debug on") + } +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_account.go b/vendor/github.com/rancher/go-rancher/client/generated_account.go new file mode 100644 index 00000000..4436daeb --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_account.go @@ -0,0 +1,170 @@ +package client + +const ( + ACCOUNT_TYPE = "account" +) + +type Account struct { + Resource + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type AccountCollection struct { + Collection + Data []Account `json:"data,omitempty"` +} + +type AccountClient struct { + rancherClient *RancherClient +} + +type AccountOperations interface { + List(opts *ListOpts) (*AccountCollection, error) + Create(opts *Account) (*Account, error) + Update(existing *Account, updates interface{}) (*Account, error) + ById(id string) (*Account, error) + Delete(container *Account) error + + ActionActivate(*Account) (*Account, error) + + ActionCreate(*Account) (*Account, error) + + ActionDeactivate(*Account) (*Account, error) + + ActionPurge(*Account) (*Account, error) + + ActionRemove(*Account) (*Account, error) + + ActionRestore(*Account) (*Account, error) + + ActionUpdate(*Account) (*Account, error) +} + +func newAccountClient(rancherClient *RancherClient) *AccountClient { + return &AccountClient{ + rancherClient: rancherClient, + } +} + +func (c *AccountClient) Create(container *Account) (*Account, error) { + resp := &Account{} + err := c.rancherClient.doCreate(ACCOUNT_TYPE, container, resp) + return resp, err +} + +func (c *AccountClient) Update(existing *Account, updates interface{}) (*Account, error) { + resp := &Account{} + err := c.rancherClient.doUpdate(ACCOUNT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AccountClient) List(opts *ListOpts) (*AccountCollection, error) { + resp := &AccountCollection{} + err := c.rancherClient.doList(ACCOUNT_TYPE, opts, resp) + return resp, err +} + +func (c *AccountClient) ById(id string) (*Account, error) { + resp := &Account{} + err := c.rancherClient.doById(ACCOUNT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AccountClient) Delete(container *Account) error { + return c.rancherClient.doResourceDelete(ACCOUNT_TYPE, &container.Resource) +} + +func (c *AccountClient) ActionActivate(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AccountClient) ActionCreate(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AccountClient) ActionDeactivate(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AccountClient) ActionPurge(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AccountClient) ActionRemove(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AccountClient) ActionRestore(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AccountClient) ActionUpdate(resource *Account) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(ACCOUNT_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_active_setting.go b/vendor/github.com/rancher/go-rancher/client/generated_active_setting.go new file mode 100644 index 00000000..c8db8470 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_active_setting.go @@ -0,0 +1,75 @@ +package client + +const ( + ACTIVE_SETTING_TYPE = "activeSetting" +) + +type ActiveSetting struct { + Resource + + ActiveValue interface{} `json:"activeValue,omitempty" yaml:"active_value,omitempty"` + + InDb bool `json:"inDb,omitempty" yaml:"in_db,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Source string `json:"source,omitempty" yaml:"source,omitempty"` + + Value string `json:"value,omitempty" yaml:"value,omitempty"` +} + +type ActiveSettingCollection struct { + Collection + Data []ActiveSetting `json:"data,omitempty"` +} + +type ActiveSettingClient struct { + rancherClient *RancherClient +} + +type ActiveSettingOperations interface { + List(opts *ListOpts) (*ActiveSettingCollection, error) + Create(opts *ActiveSetting) (*ActiveSetting, error) + Update(existing *ActiveSetting, updates interface{}) (*ActiveSetting, error) + ById(id string) (*ActiveSetting, error) + Delete(container *ActiveSetting) error +} + +func newActiveSettingClient(rancherClient *RancherClient) *ActiveSettingClient { + return &ActiveSettingClient{ + rancherClient: rancherClient, + } +} + +func (c *ActiveSettingClient) Create(container *ActiveSetting) (*ActiveSetting, error) { + resp := &ActiveSetting{} + err := c.rancherClient.doCreate(ACTIVE_SETTING_TYPE, container, resp) + return resp, err +} + +func (c *ActiveSettingClient) Update(existing *ActiveSetting, updates interface{}) (*ActiveSetting, error) { + resp := &ActiveSetting{} + err := c.rancherClient.doUpdate(ACTIVE_SETTING_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ActiveSettingClient) List(opts *ListOpts) (*ActiveSettingCollection, error) { + resp := &ActiveSettingCollection{} + err := c.rancherClient.doList(ACTIVE_SETTING_TYPE, opts, resp) + return resp, err +} + +func (c *ActiveSettingClient) ById(id string) (*ActiveSetting, error) { + resp := &ActiveSetting{} + err := c.rancherClient.doById(ACTIVE_SETTING_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ActiveSettingClient) Delete(container *ActiveSetting) error { + return c.rancherClient.doResourceDelete(ACTIVE_SETTING_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_label_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_label_input.go new file mode 100644 index 00000000..97afedd0 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_label_input.go @@ -0,0 +1,64 @@ +package client + +const ( + ADD_LABEL_INPUT_TYPE = "addLabelInput" +) + +type AddLabelInput struct { + Resource + + Key string `json:"key,omitempty"` + + Value string `json:"value,omitempty"` +} + +type AddLabelInputCollection struct { + Collection + Data []AddLabelInput `json:"data,omitempty"` +} + +type AddLabelInputClient struct { + rancherClient *RancherClient +} + +type AddLabelInputOperations interface { + List(opts *ListOpts) (*AddLabelInputCollection, error) + Create(opts *AddLabelInput) (*AddLabelInput, error) + Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error) + ById(id string) (*AddLabelInput, error) + Delete(container *AddLabelInput) error +} + +func newAddLabelInputClient(rancherClient *RancherClient) *AddLabelInputClient { + return &AddLabelInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddLabelInputClient) Create(container *AddLabelInput) (*AddLabelInput, error) { + resp := &AddLabelInput{} + err := c.rancherClient.doCreate(ADD_LABEL_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddLabelInputClient) Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error) { + resp := &AddLabelInput{} + err := c.rancherClient.doUpdate(ADD_LABEL_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddLabelInputClient) List(opts *ListOpts) (*AddLabelInputCollection, error) { + resp := &AddLabelInputCollection{} + err := c.rancherClient.doList(ADD_LABEL_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddLabelInputClient) ById(id string) (*AddLabelInput, error) { + resp := &AddLabelInput{} + err := c.rancherClient.doById(ADD_LABEL_INPUT_TYPE, id, resp) + return resp, err +} + +func (c *AddLabelInputClient) Delete(container *AddLabelInput) error { + return c.rancherClient.doResourceDelete(ADD_LABEL_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_load_balancer_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_load_balancer_input.go new file mode 100644 index 00000000..1afdbada --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_load_balancer_input.go @@ -0,0 +1,69 @@ +package client + +const ( + ADD_LOAD_BALANCER_INPUT_TYPE = "addLoadBalancerInput" +) + +type AddLoadBalancerInput struct { + Resource + + LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"` + + Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"` +} + +type AddLoadBalancerInputCollection struct { + Collection + Data []AddLoadBalancerInput `json:"data,omitempty"` +} + +type AddLoadBalancerInputClient struct { + rancherClient *RancherClient +} + +type AddLoadBalancerInputOperations interface { + List(opts *ListOpts) (*AddLoadBalancerInputCollection, error) + Create(opts *AddLoadBalancerInput) (*AddLoadBalancerInput, error) + Update(existing *AddLoadBalancerInput, updates interface{}) (*AddLoadBalancerInput, error) + ById(id string) (*AddLoadBalancerInput, error) + Delete(container *AddLoadBalancerInput) error +} + +func newAddLoadBalancerInputClient(rancherClient *RancherClient) *AddLoadBalancerInputClient { + return &AddLoadBalancerInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddLoadBalancerInputClient) Create(container *AddLoadBalancerInput) (*AddLoadBalancerInput, error) { + resp := &AddLoadBalancerInput{} + err := c.rancherClient.doCreate(ADD_LOAD_BALANCER_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddLoadBalancerInputClient) Update(existing *AddLoadBalancerInput, updates interface{}) (*AddLoadBalancerInput, error) { + resp := &AddLoadBalancerInput{} + err := c.rancherClient.doUpdate(ADD_LOAD_BALANCER_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddLoadBalancerInputClient) List(opts *ListOpts) (*AddLoadBalancerInputCollection, error) { + resp := &AddLoadBalancerInputCollection{} + err := c.rancherClient.doList(ADD_LOAD_BALANCER_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddLoadBalancerInputClient) ById(id string) (*AddLoadBalancerInput, error) { + resp := &AddLoadBalancerInput{} + err := c.rancherClient.doById(ADD_LOAD_BALANCER_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddLoadBalancerInputClient) Delete(container *AddLoadBalancerInput) error { + return c.rancherClient.doResourceDelete(ADD_LOAD_BALANCER_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_outputs_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_outputs_input.go new file mode 100644 index 00000000..b2d51c73 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_outputs_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_OUTPUTS_INPUT_TYPE = "addOutputsInput" +) + +type AddOutputsInput struct { + Resource + + Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"` +} + +type AddOutputsInputCollection struct { + Collection + Data []AddOutputsInput `json:"data,omitempty"` +} + +type AddOutputsInputClient struct { + rancherClient *RancherClient +} + +type AddOutputsInputOperations interface { + List(opts *ListOpts) (*AddOutputsInputCollection, error) + Create(opts *AddOutputsInput) (*AddOutputsInput, error) + Update(existing *AddOutputsInput, updates interface{}) (*AddOutputsInput, error) + ById(id string) (*AddOutputsInput, error) + Delete(container *AddOutputsInput) error +} + +func newAddOutputsInputClient(rancherClient *RancherClient) *AddOutputsInputClient { + return &AddOutputsInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddOutputsInputClient) Create(container *AddOutputsInput) (*AddOutputsInput, error) { + resp := &AddOutputsInput{} + err := c.rancherClient.doCreate(ADD_OUTPUTS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddOutputsInputClient) Update(existing *AddOutputsInput, updates interface{}) (*AddOutputsInput, error) { + resp := &AddOutputsInput{} + err := c.rancherClient.doUpdate(ADD_OUTPUTS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddOutputsInputClient) List(opts *ListOpts) (*AddOutputsInputCollection, error) { + resp := &AddOutputsInputCollection{} + err := c.rancherClient.doList(ADD_OUTPUTS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddOutputsInputClient) ById(id string) (*AddOutputsInput, error) { + resp := &AddOutputsInput{} + err := c.rancherClient.doById(ADD_OUTPUTS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddOutputsInputClient) Delete(container *AddOutputsInput) error { + return c.rancherClient.doResourceDelete(ADD_OUTPUTS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_remove_cluster_host_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_cluster_host_input.go new file mode 100644 index 00000000..09d79e6a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_cluster_host_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE = "addRemoveClusterHostInput" +) + +type AddRemoveClusterHostInput struct { + Resource + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` +} + +type AddRemoveClusterHostInputCollection struct { + Collection + Data []AddRemoveClusterHostInput `json:"data,omitempty"` +} + +type AddRemoveClusterHostInputClient struct { + rancherClient *RancherClient +} + +type AddRemoveClusterHostInputOperations interface { + List(opts *ListOpts) (*AddRemoveClusterHostInputCollection, error) + Create(opts *AddRemoveClusterHostInput) (*AddRemoveClusterHostInput, error) + Update(existing *AddRemoveClusterHostInput, updates interface{}) (*AddRemoveClusterHostInput, error) + ById(id string) (*AddRemoveClusterHostInput, error) + Delete(container *AddRemoveClusterHostInput) error +} + +func newAddRemoveClusterHostInputClient(rancherClient *RancherClient) *AddRemoveClusterHostInputClient { + return &AddRemoveClusterHostInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddRemoveClusterHostInputClient) Create(container *AddRemoveClusterHostInput) (*AddRemoveClusterHostInput, error) { + resp := &AddRemoveClusterHostInput{} + err := c.rancherClient.doCreate(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddRemoveClusterHostInputClient) Update(existing *AddRemoveClusterHostInput, updates interface{}) (*AddRemoveClusterHostInput, error) { + resp := &AddRemoveClusterHostInput{} + err := c.rancherClient.doUpdate(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddRemoveClusterHostInputClient) List(opts *ListOpts) (*AddRemoveClusterHostInputCollection, error) { + resp := &AddRemoveClusterHostInputCollection{} + err := c.rancherClient.doList(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddRemoveClusterHostInputClient) ById(id string) (*AddRemoveClusterHostInput, error) { + resp := &AddRemoveClusterHostInput{} + err := c.rancherClient.doById(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddRemoveClusterHostInputClient) Delete(container *AddRemoveClusterHostInput) error { + return c.rancherClient.doResourceDelete(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_host_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_host_input.go new file mode 100644 index 00000000..39a7d175 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_host_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE = "addRemoveLoadBalancerHostInput" +) + +type AddRemoveLoadBalancerHostInput struct { + Resource + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` +} + +type AddRemoveLoadBalancerHostInputCollection struct { + Collection + Data []AddRemoveLoadBalancerHostInput `json:"data,omitempty"` +} + +type AddRemoveLoadBalancerHostInputClient struct { + rancherClient *RancherClient +} + +type AddRemoveLoadBalancerHostInputOperations interface { + List(opts *ListOpts) (*AddRemoveLoadBalancerHostInputCollection, error) + Create(opts *AddRemoveLoadBalancerHostInput) (*AddRemoveLoadBalancerHostInput, error) + Update(existing *AddRemoveLoadBalancerHostInput, updates interface{}) (*AddRemoveLoadBalancerHostInput, error) + ById(id string) (*AddRemoveLoadBalancerHostInput, error) + Delete(container *AddRemoveLoadBalancerHostInput) error +} + +func newAddRemoveLoadBalancerHostInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerHostInputClient { + return &AddRemoveLoadBalancerHostInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddRemoveLoadBalancerHostInputClient) Create(container *AddRemoveLoadBalancerHostInput) (*AddRemoveLoadBalancerHostInput, error) { + resp := &AddRemoveLoadBalancerHostInput{} + err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerHostInputClient) Update(existing *AddRemoveLoadBalancerHostInput, updates interface{}) (*AddRemoveLoadBalancerHostInput, error) { + resp := &AddRemoveLoadBalancerHostInput{} + err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerHostInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerHostInputCollection, error) { + resp := &AddRemoveLoadBalancerHostInputCollection{} + err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerHostInputClient) ById(id string) (*AddRemoveLoadBalancerHostInput, error) { + resp := &AddRemoveLoadBalancerHostInput{} + err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddRemoveLoadBalancerHostInputClient) Delete(container *AddRemoveLoadBalancerHostInput) error { + return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_listener_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_listener_input.go new file mode 100644 index 00000000..df5a7195 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_listener_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE = "addRemoveLoadBalancerListenerInput" +) + +type AddRemoveLoadBalancerListenerInput struct { + Resource + + LoadBalancerListenerId string `json:"loadBalancerListenerId,omitempty" yaml:"load_balancer_listener_id,omitempty"` +} + +type AddRemoveLoadBalancerListenerInputCollection struct { + Collection + Data []AddRemoveLoadBalancerListenerInput `json:"data,omitempty"` +} + +type AddRemoveLoadBalancerListenerInputClient struct { + rancherClient *RancherClient +} + +type AddRemoveLoadBalancerListenerInputOperations interface { + List(opts *ListOpts) (*AddRemoveLoadBalancerListenerInputCollection, error) + Create(opts *AddRemoveLoadBalancerListenerInput) (*AddRemoveLoadBalancerListenerInput, error) + Update(existing *AddRemoveLoadBalancerListenerInput, updates interface{}) (*AddRemoveLoadBalancerListenerInput, error) + ById(id string) (*AddRemoveLoadBalancerListenerInput, error) + Delete(container *AddRemoveLoadBalancerListenerInput) error +} + +func newAddRemoveLoadBalancerListenerInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerListenerInputClient { + return &AddRemoveLoadBalancerListenerInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddRemoveLoadBalancerListenerInputClient) Create(container *AddRemoveLoadBalancerListenerInput) (*AddRemoveLoadBalancerListenerInput, error) { + resp := &AddRemoveLoadBalancerListenerInput{} + err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerListenerInputClient) Update(existing *AddRemoveLoadBalancerListenerInput, updates interface{}) (*AddRemoveLoadBalancerListenerInput, error) { + resp := &AddRemoveLoadBalancerListenerInput{} + err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerListenerInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerListenerInputCollection, error) { + resp := &AddRemoveLoadBalancerListenerInputCollection{} + err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerListenerInputClient) ById(id string) (*AddRemoveLoadBalancerListenerInput, error) { + resp := &AddRemoveLoadBalancerListenerInput{} + err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddRemoveLoadBalancerListenerInputClient) Delete(container *AddRemoveLoadBalancerListenerInput) error { + return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_service_link_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_service_link_input.go new file mode 100644 index 00000000..a5f010ef --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_service_link_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE = "addRemoveLoadBalancerServiceLinkInput" +) + +type AddRemoveLoadBalancerServiceLinkInput struct { + Resource + + ServiceLink LoadBalancerServiceLink `json:"serviceLink,omitempty" yaml:"service_link,omitempty"` +} + +type AddRemoveLoadBalancerServiceLinkInputCollection struct { + Collection + Data []AddRemoveLoadBalancerServiceLinkInput `json:"data,omitempty"` +} + +type AddRemoveLoadBalancerServiceLinkInputClient struct { + rancherClient *RancherClient +} + +type AddRemoveLoadBalancerServiceLinkInputOperations interface { + List(opts *ListOpts) (*AddRemoveLoadBalancerServiceLinkInputCollection, error) + Create(opts *AddRemoveLoadBalancerServiceLinkInput) (*AddRemoveLoadBalancerServiceLinkInput, error) + Update(existing *AddRemoveLoadBalancerServiceLinkInput, updates interface{}) (*AddRemoveLoadBalancerServiceLinkInput, error) + ById(id string) (*AddRemoveLoadBalancerServiceLinkInput, error) + Delete(container *AddRemoveLoadBalancerServiceLinkInput) error +} + +func newAddRemoveLoadBalancerServiceLinkInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerServiceLinkInputClient { + return &AddRemoveLoadBalancerServiceLinkInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddRemoveLoadBalancerServiceLinkInputClient) Create(container *AddRemoveLoadBalancerServiceLinkInput) (*AddRemoveLoadBalancerServiceLinkInput, error) { + resp := &AddRemoveLoadBalancerServiceLinkInput{} + err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerServiceLinkInputClient) Update(existing *AddRemoveLoadBalancerServiceLinkInput, updates interface{}) (*AddRemoveLoadBalancerServiceLinkInput, error) { + resp := &AddRemoveLoadBalancerServiceLinkInput{} + err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerServiceLinkInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerServiceLinkInputCollection, error) { + resp := &AddRemoveLoadBalancerServiceLinkInputCollection{} + err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerServiceLinkInputClient) ById(id string) (*AddRemoveLoadBalancerServiceLinkInput, error) { + resp := &AddRemoveLoadBalancerServiceLinkInput{} + err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddRemoveLoadBalancerServiceLinkInputClient) Delete(container *AddRemoveLoadBalancerServiceLinkInput) error { + return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_target_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_target_input.go new file mode 100644 index 00000000..c352aad8 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_target_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE = "addRemoveLoadBalancerTargetInput" +) + +type AddRemoveLoadBalancerTargetInput struct { + Resource + + LoadBalancerTarget LoadBalancerTarget `json:"loadBalancerTarget,omitempty" yaml:"load_balancer_target,omitempty"` +} + +type AddRemoveLoadBalancerTargetInputCollection struct { + Collection + Data []AddRemoveLoadBalancerTargetInput `json:"data,omitempty"` +} + +type AddRemoveLoadBalancerTargetInputClient struct { + rancherClient *RancherClient +} + +type AddRemoveLoadBalancerTargetInputOperations interface { + List(opts *ListOpts) (*AddRemoveLoadBalancerTargetInputCollection, error) + Create(opts *AddRemoveLoadBalancerTargetInput) (*AddRemoveLoadBalancerTargetInput, error) + Update(existing *AddRemoveLoadBalancerTargetInput, updates interface{}) (*AddRemoveLoadBalancerTargetInput, error) + ById(id string) (*AddRemoveLoadBalancerTargetInput, error) + Delete(container *AddRemoveLoadBalancerTargetInput) error +} + +func newAddRemoveLoadBalancerTargetInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerTargetInputClient { + return &AddRemoveLoadBalancerTargetInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddRemoveLoadBalancerTargetInputClient) Create(container *AddRemoveLoadBalancerTargetInput) (*AddRemoveLoadBalancerTargetInput, error) { + resp := &AddRemoveLoadBalancerTargetInput{} + err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerTargetInputClient) Update(existing *AddRemoveLoadBalancerTargetInput, updates interface{}) (*AddRemoveLoadBalancerTargetInput, error) { + resp := &AddRemoveLoadBalancerTargetInput{} + err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerTargetInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerTargetInputCollection, error) { + resp := &AddRemoveLoadBalancerTargetInputCollection{} + err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddRemoveLoadBalancerTargetInputClient) ById(id string) (*AddRemoveLoadBalancerTargetInput, error) { + resp := &AddRemoveLoadBalancerTargetInput{} + err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddRemoveLoadBalancerTargetInputClient) Delete(container *AddRemoveLoadBalancerTargetInput) error { + return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_add_remove_service_link_input.go b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_service_link_input.go new file mode 100644 index 00000000..82c7d18b --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_add_remove_service_link_input.go @@ -0,0 +1,67 @@ +package client + +const ( + ADD_REMOVE_SERVICE_LINK_INPUT_TYPE = "addRemoveServiceLinkInput" +) + +type AddRemoveServiceLinkInput struct { + Resource + + ServiceLink ServiceLink `json:"serviceLink,omitempty" yaml:"service_link,omitempty"` +} + +type AddRemoveServiceLinkInputCollection struct { + Collection + Data []AddRemoveServiceLinkInput `json:"data,omitempty"` +} + +type AddRemoveServiceLinkInputClient struct { + rancherClient *RancherClient +} + +type AddRemoveServiceLinkInputOperations interface { + List(opts *ListOpts) (*AddRemoveServiceLinkInputCollection, error) + Create(opts *AddRemoveServiceLinkInput) (*AddRemoveServiceLinkInput, error) + Update(existing *AddRemoveServiceLinkInput, updates interface{}) (*AddRemoveServiceLinkInput, error) + ById(id string) (*AddRemoveServiceLinkInput, error) + Delete(container *AddRemoveServiceLinkInput) error +} + +func newAddRemoveServiceLinkInputClient(rancherClient *RancherClient) *AddRemoveServiceLinkInputClient { + return &AddRemoveServiceLinkInputClient{ + rancherClient: rancherClient, + } +} + +func (c *AddRemoveServiceLinkInputClient) Create(container *AddRemoveServiceLinkInput) (*AddRemoveServiceLinkInput, error) { + resp := &AddRemoveServiceLinkInput{} + err := c.rancherClient.doCreate(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *AddRemoveServiceLinkInputClient) Update(existing *AddRemoveServiceLinkInput, updates interface{}) (*AddRemoveServiceLinkInput, error) { + resp := &AddRemoveServiceLinkInput{} + err := c.rancherClient.doUpdate(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AddRemoveServiceLinkInputClient) List(opts *ListOpts) (*AddRemoveServiceLinkInputCollection, error) { + resp := &AddRemoveServiceLinkInputCollection{} + err := c.rancherClient.doList(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *AddRemoveServiceLinkInputClient) ById(id string) (*AddRemoveServiceLinkInput, error) { + resp := &AddRemoveServiceLinkInput{} + err := c.rancherClient.doById(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AddRemoveServiceLinkInputClient) Delete(container *AddRemoveServiceLinkInput) error { + return c.rancherClient.doResourceDelete(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_agent.go b/vendor/github.com/rancher/go-rancher/client/generated_agent.go new file mode 100644 index 00000000..557ca618 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_agent.go @@ -0,0 +1,183 @@ +package client + +const ( + AGENT_TYPE = "agent" +) + +type Agent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ManagedConfig bool `json:"managedConfig,omitempty" yaml:"managed_config,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type AgentCollection struct { + Collection + Data []Agent `json:"data,omitempty"` +} + +type AgentClient struct { + rancherClient *RancherClient +} + +type AgentOperations interface { + List(opts *ListOpts) (*AgentCollection, error) + Create(opts *Agent) (*Agent, error) + Update(existing *Agent, updates interface{}) (*Agent, error) + ById(id string) (*Agent, error) + Delete(container *Agent) error + + ActionActivate(*Agent) (*Agent, error) + + ActionCreate(*Agent) (*Agent, error) + + ActionDeactivate(*Agent) (*Agent, error) + + ActionPurge(*Agent) (*Agent, error) + + ActionReconnect(*Agent) (*Agent, error) + + ActionRemove(*Agent) (*Agent, error) + + ActionRestore(*Agent) (*Agent, error) + + ActionUpdate(*Agent) (*Agent, error) +} + +func newAgentClient(rancherClient *RancherClient) *AgentClient { + return &AgentClient{ + rancherClient: rancherClient, + } +} + +func (c *AgentClient) Create(container *Agent) (*Agent, error) { + resp := &Agent{} + err := c.rancherClient.doCreate(AGENT_TYPE, container, resp) + return resp, err +} + +func (c *AgentClient) Update(existing *Agent, updates interface{}) (*Agent, error) { + resp := &Agent{} + err := c.rancherClient.doUpdate(AGENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AgentClient) List(opts *ListOpts) (*AgentCollection, error) { + resp := &AgentCollection{} + err := c.rancherClient.doList(AGENT_TYPE, opts, resp) + return resp, err +} + +func (c *AgentClient) ById(id string) (*Agent, error) { + resp := &Agent{} + err := c.rancherClient.doById(AGENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AgentClient) Delete(container *Agent) error { + return c.rancherClient.doResourceDelete(AGENT_TYPE, &container.Resource) +} + +func (c *AgentClient) ActionActivate(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionCreate(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionDeactivate(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionPurge(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionReconnect(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "reconnect", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionRemove(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionRestore(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *AgentClient) ActionUpdate(resource *Agent) (*Agent, error) { + + resp := &Agent{} + + err := c.rancherClient.doAction(AGENT_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_amazonec2config.go b/vendor/github.com/rancher/go-rancher/client/generated_amazonec2config.go new file mode 100644 index 00000000..8306f1ff --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_amazonec2config.go @@ -0,0 +1,101 @@ +package client + +const ( + AMAZONEC2CONFIG_TYPE = "amazonec2Config" +) + +type Amazonec2Config struct { + Resource + + AccessKey string `json:"accessKey,omitempty" yaml:"access_key,omitempty"` + + Ami string `json:"ami,omitempty" yaml:"ami,omitempty"` + + IamInstanceProfile string `json:"iamInstanceProfile,omitempty" yaml:"iam_instance_profile,omitempty"` + + InstanceType string `json:"instanceType,omitempty" yaml:"instance_type,omitempty"` + + Monitoring bool `json:"monitoring,omitempty" yaml:"monitoring,omitempty"` + + PrivateAddressOnly bool `json:"privateAddressOnly,omitempty" yaml:"private_address_only,omitempty"` + + Region string `json:"region,omitempty" yaml:"region,omitempty"` + + RequestSpotInstance bool `json:"requestSpotInstance,omitempty" yaml:"request_spot_instance,omitempty"` + + RootSize string `json:"rootSize,omitempty" yaml:"root_size,omitempty"` + + SecretKey string `json:"secretKey,omitempty" yaml:"secret_key,omitempty"` + + SecurityGroup string `json:"securityGroup,omitempty" yaml:"security_group,omitempty"` + + SessionToken string `json:"sessionToken,omitempty" yaml:"session_token,omitempty"` + + SpotPrice string `json:"spotPrice,omitempty" yaml:"spot_price,omitempty"` + + SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"` + + SubnetId string `json:"subnetId,omitempty" yaml:"subnet_id,omitempty"` + + UsePrivateAddress bool `json:"usePrivateAddress,omitempty" yaml:"use_private_address,omitempty"` + + VpcId string `json:"vpcId,omitempty" yaml:"vpc_id,omitempty"` + + Zone string `json:"zone,omitempty" yaml:"zone,omitempty"` +} + +type Amazonec2ConfigCollection struct { + Collection + Data []Amazonec2Config `json:"data,omitempty"` +} + +type Amazonec2ConfigClient struct { + rancherClient *RancherClient +} + +type Amazonec2ConfigOperations interface { + List(opts *ListOpts) (*Amazonec2ConfigCollection, error) + Create(opts *Amazonec2Config) (*Amazonec2Config, error) + Update(existing *Amazonec2Config, updates interface{}) (*Amazonec2Config, error) + ById(id string) (*Amazonec2Config, error) + Delete(container *Amazonec2Config) error +} + +func newAmazonec2ConfigClient(rancherClient *RancherClient) *Amazonec2ConfigClient { + return &Amazonec2ConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *Amazonec2ConfigClient) Create(container *Amazonec2Config) (*Amazonec2Config, error) { + resp := &Amazonec2Config{} + err := c.rancherClient.doCreate(AMAZONEC2CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *Amazonec2ConfigClient) Update(existing *Amazonec2Config, updates interface{}) (*Amazonec2Config, error) { + resp := &Amazonec2Config{} + err := c.rancherClient.doUpdate(AMAZONEC2CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *Amazonec2ConfigClient) List(opts *ListOpts) (*Amazonec2ConfigCollection, error) { + resp := &Amazonec2ConfigCollection{} + err := c.rancherClient.doList(AMAZONEC2CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *Amazonec2ConfigClient) ById(id string) (*Amazonec2Config, error) { + resp := &Amazonec2Config{} + err := c.rancherClient.doById(AMAZONEC2CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *Amazonec2ConfigClient) Delete(container *Amazonec2Config) error { + return c.rancherClient.doResourceDelete(AMAZONEC2CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_api_key.go b/vendor/github.com/rancher/go-rancher/client/generated_api_key.go new file mode 100644 index 00000000..c0f9c50e --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_api_key.go @@ -0,0 +1,161 @@ +package client + +const ( + API_KEY_TYPE = "apiKey" +) + +type ApiKey struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ApiKeyCollection struct { + Collection + Data []ApiKey `json:"data,omitempty"` +} + +type ApiKeyClient struct { + rancherClient *RancherClient +} + +type ApiKeyOperations interface { + List(opts *ListOpts) (*ApiKeyCollection, error) + Create(opts *ApiKey) (*ApiKey, error) + Update(existing *ApiKey, updates interface{}) (*ApiKey, error) + ById(id string) (*ApiKey, error) + Delete(container *ApiKey) error + + ActionActivate(*ApiKey) (*Credential, error) + + ActionCreate(*ApiKey) (*Credential, error) + + ActionDeactivate(*ApiKey) (*Credential, error) + + ActionPurge(*ApiKey) (*Credential, error) + + ActionRemove(*ApiKey) (*Credential, error) + + ActionUpdate(*ApiKey) (*Credential, error) +} + +func newApiKeyClient(rancherClient *RancherClient) *ApiKeyClient { + return &ApiKeyClient{ + rancherClient: rancherClient, + } +} + +func (c *ApiKeyClient) Create(container *ApiKey) (*ApiKey, error) { + resp := &ApiKey{} + err := c.rancherClient.doCreate(API_KEY_TYPE, container, resp) + return resp, err +} + +func (c *ApiKeyClient) Update(existing *ApiKey, updates interface{}) (*ApiKey, error) { + resp := &ApiKey{} + err := c.rancherClient.doUpdate(API_KEY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ApiKeyClient) List(opts *ListOpts) (*ApiKeyCollection, error) { + resp := &ApiKeyCollection{} + err := c.rancherClient.doList(API_KEY_TYPE, opts, resp) + return resp, err +} + +func (c *ApiKeyClient) ById(id string) (*ApiKey, error) { + resp := &ApiKey{} + err := c.rancherClient.doById(API_KEY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ApiKeyClient) Delete(container *ApiKey) error { + return c.rancherClient.doResourceDelete(API_KEY_TYPE, &container.Resource) +} + +func (c *ApiKeyClient) ActionActivate(resource *ApiKey) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(API_KEY_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ApiKeyClient) ActionCreate(resource *ApiKey) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(API_KEY_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ApiKeyClient) ActionDeactivate(resource *ApiKey) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(API_KEY_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ApiKeyClient) ActionPurge(resource *ApiKey) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(API_KEY_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ApiKeyClient) ActionRemove(resource *ApiKey) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(API_KEY_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ApiKeyClient) ActionUpdate(resource *ApiKey) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(API_KEY_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_audit_log.go b/vendor/github.com/rancher/go-rancher/client/generated_audit_log.go new file mode 100644 index 00000000..d8ff08fb --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_audit_log.go @@ -0,0 +1,93 @@ +package client + +const ( + AUDIT_LOG_TYPE = "auditLog" +) + +type AuditLog struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AuthType string `json:"authType,omitempty" yaml:"auth_type,omitempty"` + + AuthenticatedAsAccountId string `json:"authenticatedAsAccountId,omitempty" yaml:"authenticated_as_account_id,omitempty"` + + AuthenticatedAsIdentityId string `json:"authenticatedAsIdentityId,omitempty" yaml:"authenticated_as_identity_id,omitempty"` + + ClientIp string `json:"clientIp,omitempty" yaml:"client_ip,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + RequestObject string `json:"requestObject,omitempty" yaml:"request_object,omitempty"` + + ResourceId int64 `json:"resourceId,omitempty" yaml:"resource_id,omitempty"` + + ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"` + + ResponseCode string `json:"responseCode,omitempty" yaml:"response_code,omitempty"` + + ResponseObject string `json:"responseObject,omitempty" yaml:"response_object,omitempty"` +} + +type AuditLogCollection struct { + Collection + Data []AuditLog `json:"data,omitempty"` +} + +type AuditLogClient struct { + rancherClient *RancherClient +} + +type AuditLogOperations interface { + List(opts *ListOpts) (*AuditLogCollection, error) + Create(opts *AuditLog) (*AuditLog, error) + Update(existing *AuditLog, updates interface{}) (*AuditLog, error) + ById(id string) (*AuditLog, error) + Delete(container *AuditLog) error +} + +func newAuditLogClient(rancherClient *RancherClient) *AuditLogClient { + return &AuditLogClient{ + rancherClient: rancherClient, + } +} + +func (c *AuditLogClient) Create(container *AuditLog) (*AuditLog, error) { + resp := &AuditLog{} + err := c.rancherClient.doCreate(AUDIT_LOG_TYPE, container, resp) + return resp, err +} + +func (c *AuditLogClient) Update(existing *AuditLog, updates interface{}) (*AuditLog, error) { + resp := &AuditLog{} + err := c.rancherClient.doUpdate(AUDIT_LOG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AuditLogClient) List(opts *ListOpts) (*AuditLogCollection, error) { + resp := &AuditLogCollection{} + err := c.rancherClient.doList(AUDIT_LOG_TYPE, opts, resp) + return resp, err +} + +func (c *AuditLogClient) ById(id string) (*AuditLog, error) { + resp := &AuditLog{} + err := c.rancherClient.doById(AUDIT_LOG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AuditLogClient) Delete(container *AuditLog) error { + return c.rancherClient.doResourceDelete(AUDIT_LOG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_azure_config.go b/vendor/github.com/rancher/go-rancher/client/generated_azure_config.go new file mode 100644 index 00000000..afe230f8 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_azure_config.go @@ -0,0 +1,87 @@ +package client + +const ( + AZURE_CONFIG_TYPE = "azureConfig" +) + +type AzureConfig struct { + Resource + + DockerPort string `json:"dockerPort,omitempty" yaml:"docker_port,omitempty"` + + DockerSwarmMasterPort string `json:"dockerSwarmMasterPort,omitempty" yaml:"docker_swarm_master_port,omitempty"` + + Image string `json:"image,omitempty" yaml:"image,omitempty"` + + Location string `json:"location,omitempty" yaml:"location,omitempty"` + + Password string `json:"password,omitempty" yaml:"password,omitempty"` + + PublishSettingsFile string `json:"publishSettingsFile,omitempty" yaml:"publish_settings_file,omitempty"` + + Size string `json:"size,omitempty" yaml:"size,omitempty"` + + SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"` + + SubscriptionCert string `json:"subscriptionCert,omitempty" yaml:"subscription_cert,omitempty"` + + SubscriptionId string `json:"subscriptionId,omitempty" yaml:"subscription_id,omitempty"` + + Username string `json:"username,omitempty" yaml:"username,omitempty"` +} + +type AzureConfigCollection struct { + Collection + Data []AzureConfig `json:"data,omitempty"` +} + +type AzureConfigClient struct { + rancherClient *RancherClient +} + +type AzureConfigOperations interface { + List(opts *ListOpts) (*AzureConfigCollection, error) + Create(opts *AzureConfig) (*AzureConfig, error) + Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error) + ById(id string) (*AzureConfig, error) + Delete(container *AzureConfig) error +} + +func newAzureConfigClient(rancherClient *RancherClient) *AzureConfigClient { + return &AzureConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *AzureConfigClient) Create(container *AzureConfig) (*AzureConfig, error) { + resp := &AzureConfig{} + err := c.rancherClient.doCreate(AZURE_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *AzureConfigClient) Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error) { + resp := &AzureConfig{} + err := c.rancherClient.doUpdate(AZURE_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *AzureConfigClient) List(opts *ListOpts) (*AzureConfigCollection, error) { + resp := &AzureConfigCollection{} + err := c.rancherClient.doList(AZURE_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *AzureConfigClient) ById(id string) (*AzureConfig, error) { + resp := &AzureConfig{} + err := c.rancherClient.doById(AZURE_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *AzureConfigClient) Delete(container *AzureConfig) error { + return c.rancherClient.doResourceDelete(AZURE_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_base_machine_config.go b/vendor/github.com/rancher/go-rancher/client/generated_base_machine_config.go new file mode 100644 index 00000000..a0193424 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_base_machine_config.go @@ -0,0 +1,65 @@ +package client + +const ( + BASE_MACHINE_CONFIG_TYPE = "baseMachineConfig" +) + +type BaseMachineConfig struct { + Resource +} + +type BaseMachineConfigCollection struct { + Collection + Data []BaseMachineConfig `json:"data,omitempty"` +} + +type BaseMachineConfigClient struct { + rancherClient *RancherClient +} + +type BaseMachineConfigOperations interface { + List(opts *ListOpts) (*BaseMachineConfigCollection, error) + Create(opts *BaseMachineConfig) (*BaseMachineConfig, error) + Update(existing *BaseMachineConfig, updates interface{}) (*BaseMachineConfig, error) + ById(id string) (*BaseMachineConfig, error) + Delete(container *BaseMachineConfig) error +} + +func newBaseMachineConfigClient(rancherClient *RancherClient) *BaseMachineConfigClient { + return &BaseMachineConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *BaseMachineConfigClient) Create(container *BaseMachineConfig) (*BaseMachineConfig, error) { + resp := &BaseMachineConfig{} + err := c.rancherClient.doCreate(BASE_MACHINE_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *BaseMachineConfigClient) Update(existing *BaseMachineConfig, updates interface{}) (*BaseMachineConfig, error) { + resp := &BaseMachineConfig{} + err := c.rancherClient.doUpdate(BASE_MACHINE_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *BaseMachineConfigClient) List(opts *ListOpts) (*BaseMachineConfigCollection, error) { + resp := &BaseMachineConfigCollection{} + err := c.rancherClient.doList(BASE_MACHINE_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *BaseMachineConfigClient) ById(id string) (*BaseMachineConfig, error) { + resp := &BaseMachineConfig{} + err := c.rancherClient.doById(BASE_MACHINE_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *BaseMachineConfigClient) Delete(container *BaseMachineConfig) error { + return c.rancherClient.doResourceDelete(BASE_MACHINE_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_certificate.go b/vendor/github.com/rancher/go-rancher/client/generated_certificate.go new file mode 100644 index 00000000..5871bb13 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_certificate.go @@ -0,0 +1,139 @@ +package client + +const ( + CERTIFICATE_TYPE = "certificate" +) + +type Certificate struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"` + + CN string `json:"cN,omitempty" yaml:"cn,omitempty"` + + Cert string `json:"cert,omitempty" yaml:"cert,omitempty"` + + CertChain string `json:"certChain,omitempty" yaml:"cert_chain,omitempty"` + + CertFingerprint string `json:"certFingerprint,omitempty" yaml:"cert_fingerprint,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ExpiresAt string `json:"expiresAt,omitempty" yaml:"expires_at,omitempty"` + + IssuedAt string `json:"issuedAt,omitempty" yaml:"issued_at,omitempty"` + + Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty"` + + Key string `json:"key,omitempty" yaml:"key,omitempty"` + + KeySize int64 `json:"keySize,omitempty" yaml:"key_size,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SerialNumber string `json:"serialNumber,omitempty" yaml:"serial_number,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + SubjectAlternativeNames []string `json:"subjectAlternativeNames,omitempty" yaml:"subject_alternative_names,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Version string `json:"version,omitempty" yaml:"version,omitempty"` +} + +type CertificateCollection struct { + Collection + Data []Certificate `json:"data,omitempty"` +} + +type CertificateClient struct { + rancherClient *RancherClient +} + +type CertificateOperations interface { + List(opts *ListOpts) (*CertificateCollection, error) + Create(opts *Certificate) (*Certificate, error) + Update(existing *Certificate, updates interface{}) (*Certificate, error) + ById(id string) (*Certificate, error) + Delete(container *Certificate) error + + ActionCreate(*Certificate) (*Certificate, error) + + ActionRemove(*Certificate) (*Certificate, error) +} + +func newCertificateClient(rancherClient *RancherClient) *CertificateClient { + return &CertificateClient{ + rancherClient: rancherClient, + } +} + +func (c *CertificateClient) Create(container *Certificate) (*Certificate, error) { + resp := &Certificate{} + err := c.rancherClient.doCreate(CERTIFICATE_TYPE, container, resp) + return resp, err +} + +func (c *CertificateClient) Update(existing *Certificate, updates interface{}) (*Certificate, error) { + resp := &Certificate{} + err := c.rancherClient.doUpdate(CERTIFICATE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *CertificateClient) List(opts *ListOpts) (*CertificateCollection, error) { + resp := &CertificateCollection{} + err := c.rancherClient.doList(CERTIFICATE_TYPE, opts, resp) + return resp, err +} + +func (c *CertificateClient) ById(id string) (*Certificate, error) { + resp := &Certificate{} + err := c.rancherClient.doById(CERTIFICATE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *CertificateClient) Delete(container *Certificate) error { + return c.rancherClient.doResourceDelete(CERTIFICATE_TYPE, &container.Resource) +} + +func (c *CertificateClient) ActionCreate(resource *Certificate) (*Certificate, error) { + + resp := &Certificate{} + + err := c.rancherClient.doAction(CERTIFICATE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *CertificateClient) ActionRemove(resource *Certificate) (*Certificate, error) { + + resp := &Certificate{} + + err := c.rancherClient.doAction(CERTIFICATE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_change_secret_input.go b/vendor/github.com/rancher/go-rancher/client/generated_change_secret_input.go new file mode 100644 index 00000000..913c2eea --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_change_secret_input.go @@ -0,0 +1,69 @@ +package client + +const ( + CHANGE_SECRET_INPUT_TYPE = "changeSecretInput" +) + +type ChangeSecretInput struct { + Resource + + NewSecret string `json:"newSecret,omitempty" yaml:"new_secret,omitempty"` + + OldSecret string `json:"oldSecret,omitempty" yaml:"old_secret,omitempty"` +} + +type ChangeSecretInputCollection struct { + Collection + Data []ChangeSecretInput `json:"data,omitempty"` +} + +type ChangeSecretInputClient struct { + rancherClient *RancherClient +} + +type ChangeSecretInputOperations interface { + List(opts *ListOpts) (*ChangeSecretInputCollection, error) + Create(opts *ChangeSecretInput) (*ChangeSecretInput, error) + Update(existing *ChangeSecretInput, updates interface{}) (*ChangeSecretInput, error) + ById(id string) (*ChangeSecretInput, error) + Delete(container *ChangeSecretInput) error +} + +func newChangeSecretInputClient(rancherClient *RancherClient) *ChangeSecretInputClient { + return &ChangeSecretInputClient{ + rancherClient: rancherClient, + } +} + +func (c *ChangeSecretInputClient) Create(container *ChangeSecretInput) (*ChangeSecretInput, error) { + resp := &ChangeSecretInput{} + err := c.rancherClient.doCreate(CHANGE_SECRET_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *ChangeSecretInputClient) Update(existing *ChangeSecretInput, updates interface{}) (*ChangeSecretInput, error) { + resp := &ChangeSecretInput{} + err := c.rancherClient.doUpdate(CHANGE_SECRET_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ChangeSecretInputClient) List(opts *ListOpts) (*ChangeSecretInputCollection, error) { + resp := &ChangeSecretInputCollection{} + err := c.rancherClient.doList(CHANGE_SECRET_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *ChangeSecretInputClient) ById(id string) (*ChangeSecretInput, error) { + resp := &ChangeSecretInput{} + err := c.rancherClient.doById(CHANGE_SECRET_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ChangeSecretInputClient) Delete(container *ChangeSecretInput) error { + return c.rancherClient.doResourceDelete(CHANGE_SECRET_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_client.go b/vendor/github.com/rancher/go-rancher/client/generated_client.go new file mode 100644 index 00000000..0c9cc1cf --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_client.go @@ -0,0 +1,274 @@ +package client + +type RancherClient struct { + RancherBaseClient + + Subscribe SubscribeOperations + Publish PublishOperations + LogConfig LogConfigOperations + RestartPolicy RestartPolicyOperations + LoadBalancerCookieStickinessPolicy LoadBalancerCookieStickinessPolicyOperations + LoadBalancerAppCookieStickinessPolicy LoadBalancerAppCookieStickinessPolicyOperations + ExternalHandlerProcessConfig ExternalHandlerProcessConfigOperations + ComposeConfig ComposeConfigOperations + InstanceHealthCheck InstanceHealthCheckOperations + ServiceLink ServiceLinkOperations + ServiceUpgrade ServiceUpgradeOperations + ServiceUpgradeStrategy ServiceUpgradeStrategyOperations + InServiceUpgradeStrategy InServiceUpgradeStrategyOperations + ToServiceUpgradeStrategy ToServiceUpgradeStrategyOperations + PublicEndpoint PublicEndpointOperations + VirtualMachineDisk VirtualMachineDiskOperations + HaproxyConfig HaproxyConfigOperations + RollingRestartStrategy RollingRestartStrategyOperations + ServiceRestart ServiceRestartOperations + ServicesPortRange ServicesPortRangeOperations + RecreateOnQuorumStrategyConfig RecreateOnQuorumStrategyConfigOperations + AddOutputsInput AddOutputsInputOperations + AddRemoveClusterHostInput AddRemoveClusterHostInputOperations + AddRemoveServiceLinkInput AddRemoveServiceLinkInputOperations + ChangeSecretInput ChangeSecretInputOperations + SetLabelsInput SetLabelsInputOperations + ApiKey ApiKeyOperations + Cluster ClusterOperations + ComposeConfigInput ComposeConfigInputOperations + Container ContainerOperations + InstanceConsole InstanceConsoleOperations + InstanceConsoleInput InstanceConsoleInputOperations + InstanceStop InstanceStopOperations + IpAddressAssociateInput IpAddressAssociateInputOperations + Project ProjectOperations + Password PasswordOperations + Registry RegistryOperations + RegistryCredential RegistryCredentialOperations + SetProjectMembersInput SetProjectMembersInputOperations + SetServiceLinksInput SetServiceLinksInputOperations + VirtualMachine VirtualMachineOperations + LoadBalancerService LoadBalancerServiceOperations + ExternalService ExternalServiceOperations + DnsService DnsServiceOperations + LaunchConfig LaunchConfigOperations + SecondaryLaunchConfig SecondaryLaunchConfigOperations + AddRemoveLoadBalancerServiceLinkInput AddRemoveLoadBalancerServiceLinkInputOperations + SetLoadBalancerServiceLinksInput SetLoadBalancerServiceLinksInputOperations + LoadBalancerServiceLink LoadBalancerServiceLinkOperations + PullTask PullTaskOperations + ExternalVolumeEvent ExternalVolumeEventOperations + ExternalStoragePoolEvent ExternalStoragePoolEventOperations + ExternalServiceEvent ExternalServiceEventOperations + EnvironmentUpgrade EnvironmentUpgradeOperations + ExternalDnsEvent ExternalDnsEventOperations + ExternalHostEvent ExternalHostEventOperations + LoadBalancerConfig LoadBalancerConfigOperations + MachineDriverUpdateInput MachineDriverUpdateInputOperations + MachineDriverErrorInput MachineDriverErrorInputOperations + Account AccountOperations + Agent AgentOperations + AuditLog AuditLogOperations + Certificate CertificateOperations + ConfigItem ConfigItemOperations + ConfigItemStatus ConfigItemStatusOperations + ContainerEvent ContainerEventOperations + Credential CredentialOperations + Databasechangelog DatabasechangelogOperations + Databasechangeloglock DatabasechangeloglockOperations + DynamicSchema DynamicSchemaOperations + Environment EnvironmentOperations + ExternalEvent ExternalEventOperations + ExternalHandler ExternalHandlerOperations + ExternalHandlerExternalHandlerProcessMap ExternalHandlerExternalHandlerProcessMapOperations + ExternalHandlerProcess ExternalHandlerProcessOperations + HealthcheckInstanceHostMap HealthcheckInstanceHostMapOperations + Host HostOperations + Image ImageOperations + Instance InstanceOperations + InstanceLink InstanceLinkOperations + IpAddress IpAddressOperations + Label LabelOperations + MachineDriver MachineDriverOperations + Mount MountOperations + Network NetworkOperations + PhysicalHost PhysicalHostOperations + Port PortOperations + ProcessExecution ProcessExecutionOperations + ProcessInstance ProcessInstanceOperations + ProjectMember ProjectMemberOperations + Service ServiceOperations + ServiceConsumeMap ServiceConsumeMapOperations + ServiceEvent ServiceEventOperations + ServiceExposeMap ServiceExposeMapOperations + Setting SettingOperations + Snapshot SnapshotOperations + StoragePool StoragePoolOperations + Task TaskOperations + TaskInstance TaskInstanceOperations + Volume VolumeOperations + TypeDocumentation TypeDocumentationOperations + FieldDocumentation FieldDocumentationOperations + ContainerExec ContainerExecOperations + ContainerLogs ContainerLogsOperations + HostAccess HostAccessOperations + DockerBuild DockerBuildOperations + ActiveSetting ActiveSettingOperations + ExtensionImplementation ExtensionImplementationOperations + ExtensionPoint ExtensionPointOperations + ProcessDefinition ProcessDefinitionOperations + ResourceDefinition ResourceDefinitionOperations + StateTransition StateTransitionOperations + Githubconfig GithubconfigOperations + Identity IdentityOperations + Ldapconfig LdapconfigOperations + Openldapconfig OpenldapconfigOperations + LocalAuthConfig LocalAuthConfigOperations + StatsAccess StatsAccessOperations + BaseMachineConfig BaseMachineConfigOperations + HostApiProxyToken HostApiProxyTokenOperations + Register RegisterOperations + RegistrationToken RegistrationTokenOperations + Machine MachineOperations +} + +func constructClient() *RancherClient { + client := &RancherClient{ + RancherBaseClient: RancherBaseClient{ + Types: map[string]Schema{}, + }, + } + + client.Subscribe = newSubscribeClient(client) + client.Publish = newPublishClient(client) + client.LogConfig = newLogConfigClient(client) + client.RestartPolicy = newRestartPolicyClient(client) + client.LoadBalancerCookieStickinessPolicy = newLoadBalancerCookieStickinessPolicyClient(client) + client.LoadBalancerAppCookieStickinessPolicy = newLoadBalancerAppCookieStickinessPolicyClient(client) + client.ExternalHandlerProcessConfig = newExternalHandlerProcessConfigClient(client) + client.ComposeConfig = newComposeConfigClient(client) + client.InstanceHealthCheck = newInstanceHealthCheckClient(client) + client.ServiceLink = newServiceLinkClient(client) + client.ServiceUpgrade = newServiceUpgradeClient(client) + client.ServiceUpgradeStrategy = newServiceUpgradeStrategyClient(client) + client.InServiceUpgradeStrategy = newInServiceUpgradeStrategyClient(client) + client.ToServiceUpgradeStrategy = newToServiceUpgradeStrategyClient(client) + client.PublicEndpoint = newPublicEndpointClient(client) + client.VirtualMachineDisk = newVirtualMachineDiskClient(client) + client.HaproxyConfig = newHaproxyConfigClient(client) + client.RollingRestartStrategy = newRollingRestartStrategyClient(client) + client.ServiceRestart = newServiceRestartClient(client) + client.ServicesPortRange = newServicesPortRangeClient(client) + client.RecreateOnQuorumStrategyConfig = newRecreateOnQuorumStrategyConfigClient(client) + client.AddOutputsInput = newAddOutputsInputClient(client) + client.AddRemoveClusterHostInput = newAddRemoveClusterHostInputClient(client) + client.AddRemoveServiceLinkInput = newAddRemoveServiceLinkInputClient(client) + client.ChangeSecretInput = newChangeSecretInputClient(client) + client.SetLabelsInput = newSetLabelsInputClient(client) + client.ApiKey = newApiKeyClient(client) + client.Cluster = newClusterClient(client) + client.ComposeConfigInput = newComposeConfigInputClient(client) + client.Container = newContainerClient(client) + client.InstanceConsole = newInstanceConsoleClient(client) + client.InstanceConsoleInput = newInstanceConsoleInputClient(client) + client.InstanceStop = newInstanceStopClient(client) + client.IpAddressAssociateInput = newIpAddressAssociateInputClient(client) + client.Project = newProjectClient(client) + client.Password = newPasswordClient(client) + client.Registry = newRegistryClient(client) + client.RegistryCredential = newRegistryCredentialClient(client) + client.SetProjectMembersInput = newSetProjectMembersInputClient(client) + client.SetServiceLinksInput = newSetServiceLinksInputClient(client) + client.VirtualMachine = newVirtualMachineClient(client) + client.LoadBalancerService = newLoadBalancerServiceClient(client) + client.ExternalService = newExternalServiceClient(client) + client.DnsService = newDnsServiceClient(client) + client.LaunchConfig = newLaunchConfigClient(client) + client.SecondaryLaunchConfig = newSecondaryLaunchConfigClient(client) + client.AddRemoveLoadBalancerServiceLinkInput = newAddRemoveLoadBalancerServiceLinkInputClient(client) + client.SetLoadBalancerServiceLinksInput = newSetLoadBalancerServiceLinksInputClient(client) + client.LoadBalancerServiceLink = newLoadBalancerServiceLinkClient(client) + client.PullTask = newPullTaskClient(client) + client.ExternalVolumeEvent = newExternalVolumeEventClient(client) + client.ExternalStoragePoolEvent = newExternalStoragePoolEventClient(client) + client.ExternalServiceEvent = newExternalServiceEventClient(client) + client.EnvironmentUpgrade = newEnvironmentUpgradeClient(client) + client.ExternalDnsEvent = newExternalDnsEventClient(client) + client.ExternalHostEvent = newExternalHostEventClient(client) + client.LoadBalancerConfig = newLoadBalancerConfigClient(client) + client.MachineDriverUpdateInput = newMachineDriverUpdateInputClient(client) + client.MachineDriverErrorInput = newMachineDriverErrorInputClient(client) + client.Account = newAccountClient(client) + client.Agent = newAgentClient(client) + client.AuditLog = newAuditLogClient(client) + client.Certificate = newCertificateClient(client) + client.ConfigItem = newConfigItemClient(client) + client.ConfigItemStatus = newConfigItemStatusClient(client) + client.ContainerEvent = newContainerEventClient(client) + client.Credential = newCredentialClient(client) + client.Databasechangelog = newDatabasechangelogClient(client) + client.Databasechangeloglock = newDatabasechangeloglockClient(client) + client.DynamicSchema = newDynamicSchemaClient(client) + client.Environment = newEnvironmentClient(client) + client.ExternalEvent = newExternalEventClient(client) + client.ExternalHandler = newExternalHandlerClient(client) + client.ExternalHandlerExternalHandlerProcessMap = newExternalHandlerExternalHandlerProcessMapClient(client) + client.ExternalHandlerProcess = newExternalHandlerProcessClient(client) + client.HealthcheckInstanceHostMap = newHealthcheckInstanceHostMapClient(client) + client.Host = newHostClient(client) + client.Image = newImageClient(client) + client.Instance = newInstanceClient(client) + client.InstanceLink = newInstanceLinkClient(client) + client.IpAddress = newIpAddressClient(client) + client.Label = newLabelClient(client) + client.MachineDriver = newMachineDriverClient(client) + client.Mount = newMountClient(client) + client.Network = newNetworkClient(client) + client.PhysicalHost = newPhysicalHostClient(client) + client.Port = newPortClient(client) + client.ProcessExecution = newProcessExecutionClient(client) + client.ProcessInstance = newProcessInstanceClient(client) + client.ProjectMember = newProjectMemberClient(client) + client.Service = newServiceClient(client) + client.ServiceConsumeMap = newServiceConsumeMapClient(client) + client.ServiceEvent = newServiceEventClient(client) + client.ServiceExposeMap = newServiceExposeMapClient(client) + client.Setting = newSettingClient(client) + client.Snapshot = newSnapshotClient(client) + client.StoragePool = newStoragePoolClient(client) + client.Task = newTaskClient(client) + client.TaskInstance = newTaskInstanceClient(client) + client.Volume = newVolumeClient(client) + client.TypeDocumentation = newTypeDocumentationClient(client) + client.FieldDocumentation = newFieldDocumentationClient(client) + client.ContainerExec = newContainerExecClient(client) + client.ContainerLogs = newContainerLogsClient(client) + client.HostAccess = newHostAccessClient(client) + client.DockerBuild = newDockerBuildClient(client) + client.ActiveSetting = newActiveSettingClient(client) + client.ExtensionImplementation = newExtensionImplementationClient(client) + client.ExtensionPoint = newExtensionPointClient(client) + client.ProcessDefinition = newProcessDefinitionClient(client) + client.ResourceDefinition = newResourceDefinitionClient(client) + client.StateTransition = newStateTransitionClient(client) + client.Githubconfig = newGithubconfigClient(client) + client.Identity = newIdentityClient(client) + client.Ldapconfig = newLdapconfigClient(client) + client.Openldapconfig = newOpenldapconfigClient(client) + client.LocalAuthConfig = newLocalAuthConfigClient(client) + client.StatsAccess = newStatsAccessClient(client) + client.BaseMachineConfig = newBaseMachineConfigClient(client) + client.HostApiProxyToken = newHostApiProxyTokenClient(client) + client.Register = newRegisterClient(client) + client.RegistrationToken = newRegistrationTokenClient(client) + client.Machine = newMachineClient(client) + + return client +} + +func NewRancherClient(opts *ClientOpts) (*RancherClient, error) { + client := constructClient() + + err := setupRancherBaseClient(&client.RancherBaseClient, opts) + if err != nil { + return nil, err + } + + return client, nil +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_cluster.go b/vendor/github.com/rancher/go-rancher/client/generated_cluster.go new file mode 100644 index 00000000..0374af96 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_cluster.go @@ -0,0 +1,223 @@ +package client + +const ( + CLUSTER_TYPE = "cluster" +) + +type Cluster struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AgentState string `json:"agentState,omitempty" yaml:"agent_state,omitempty"` + + ApiProxy string `json:"apiProxy,omitempty" yaml:"api_proxy,omitempty"` + + ComputeTotal int64 `json:"computeTotal,omitempty" yaml:"compute_total,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + DiscoverySpec string `json:"discoverySpec,omitempty" yaml:"discovery_spec,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + Info interface{} `json:"info,omitempty" yaml:"info,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PhysicalHostId string `json:"physicalHostId,omitempty" yaml:"physical_host_id,omitempty"` + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ClusterCollection struct { + Collection + Data []Cluster `json:"data,omitempty"` +} + +type ClusterClient struct { + rancherClient *RancherClient +} + +type ClusterOperations interface { + List(opts *ListOpts) (*ClusterCollection, error) + Create(opts *Cluster) (*Cluster, error) + Update(existing *Cluster, updates interface{}) (*Cluster, error) + ById(id string) (*Cluster, error) + Delete(container *Cluster) error + + ActionActivate(*Cluster) (*Host, error) + + ActionAddhost(*Cluster, *AddRemoveClusterHostInput) (*Cluster, error) + + ActionCreate(*Cluster) (*Host, error) + + ActionDeactivate(*Cluster) (*Host, error) + + ActionDockersocket(*Cluster) (*HostAccess, error) + + ActionPurge(*Cluster) (*Host, error) + + ActionRemove(*Cluster) (*Host, error) + + ActionRemovehost(*Cluster, *AddRemoveClusterHostInput) (*Cluster, error) + + ActionRestore(*Cluster) (*Host, error) + + ActionUpdate(*Cluster) (*Host, error) +} + +func newClusterClient(rancherClient *RancherClient) *ClusterClient { + return &ClusterClient{ + rancherClient: rancherClient, + } +} + +func (c *ClusterClient) Create(container *Cluster) (*Cluster, error) { + resp := &Cluster{} + err := c.rancherClient.doCreate(CLUSTER_TYPE, container, resp) + return resp, err +} + +func (c *ClusterClient) Update(existing *Cluster, updates interface{}) (*Cluster, error) { + resp := &Cluster{} + err := c.rancherClient.doUpdate(CLUSTER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ClusterClient) List(opts *ListOpts) (*ClusterCollection, error) { + resp := &ClusterCollection{} + err := c.rancherClient.doList(CLUSTER_TYPE, opts, resp) + return resp, err +} + +func (c *ClusterClient) ById(id string) (*Cluster, error) { + resp := &Cluster{} + err := c.rancherClient.doById(CLUSTER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ClusterClient) Delete(container *Cluster) error { + return c.rancherClient.doResourceDelete(CLUSTER_TYPE, &container.Resource) +} + +func (c *ClusterClient) ActionActivate(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionAddhost(resource *Cluster, input *AddRemoveClusterHostInput) (*Cluster, error) { + + resp := &Cluster{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "addhost", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ClusterClient) ActionCreate(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionDeactivate(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionDockersocket(resource *Cluster) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "dockersocket", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionPurge(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionRemove(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionRemovehost(resource *Cluster, input *AddRemoveClusterHostInput) (*Cluster, error) { + + resp := &Cluster{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "removehost", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ClusterClient) ActionRestore(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ClusterClient) ActionUpdate(resource *Cluster) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(CLUSTER_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_compose_config.go b/vendor/github.com/rancher/go-rancher/client/generated_compose_config.go new file mode 100644 index 00000000..49ee5ba1 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_compose_config.go @@ -0,0 +1,69 @@ +package client + +const ( + COMPOSE_CONFIG_TYPE = "composeConfig" +) + +type ComposeConfig struct { + Resource + + DockerComposeConfig string `json:"dockerComposeConfig,omitempty" yaml:"docker_compose_config,omitempty"` + + RancherComposeConfig string `json:"rancherComposeConfig,omitempty" yaml:"rancher_compose_config,omitempty"` +} + +type ComposeConfigCollection struct { + Collection + Data []ComposeConfig `json:"data,omitempty"` +} + +type ComposeConfigClient struct { + rancherClient *RancherClient +} + +type ComposeConfigOperations interface { + List(opts *ListOpts) (*ComposeConfigCollection, error) + Create(opts *ComposeConfig) (*ComposeConfig, error) + Update(existing *ComposeConfig, updates interface{}) (*ComposeConfig, error) + ById(id string) (*ComposeConfig, error) + Delete(container *ComposeConfig) error +} + +func newComposeConfigClient(rancherClient *RancherClient) *ComposeConfigClient { + return &ComposeConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *ComposeConfigClient) Create(container *ComposeConfig) (*ComposeConfig, error) { + resp := &ComposeConfig{} + err := c.rancherClient.doCreate(COMPOSE_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *ComposeConfigClient) Update(existing *ComposeConfig, updates interface{}) (*ComposeConfig, error) { + resp := &ComposeConfig{} + err := c.rancherClient.doUpdate(COMPOSE_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ComposeConfigClient) List(opts *ListOpts) (*ComposeConfigCollection, error) { + resp := &ComposeConfigCollection{} + err := c.rancherClient.doList(COMPOSE_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *ComposeConfigClient) ById(id string) (*ComposeConfig, error) { + resp := &ComposeConfig{} + err := c.rancherClient.doById(COMPOSE_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ComposeConfigClient) Delete(container *ComposeConfig) error { + return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_compose_config_input.go b/vendor/github.com/rancher/go-rancher/client/generated_compose_config_input.go new file mode 100644 index 00000000..e0cdc76f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_compose_config_input.go @@ -0,0 +1,67 @@ +package client + +const ( + COMPOSE_CONFIG_INPUT_TYPE = "composeConfigInput" +) + +type ComposeConfigInput struct { + Resource + + ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"` +} + +type ComposeConfigInputCollection struct { + Collection + Data []ComposeConfigInput `json:"data,omitempty"` +} + +type ComposeConfigInputClient struct { + rancherClient *RancherClient +} + +type ComposeConfigInputOperations interface { + List(opts *ListOpts) (*ComposeConfigInputCollection, error) + Create(opts *ComposeConfigInput) (*ComposeConfigInput, error) + Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error) + ById(id string) (*ComposeConfigInput, error) + Delete(container *ComposeConfigInput) error +} + +func newComposeConfigInputClient(rancherClient *RancherClient) *ComposeConfigInputClient { + return &ComposeConfigInputClient{ + rancherClient: rancherClient, + } +} + +func (c *ComposeConfigInputClient) Create(container *ComposeConfigInput) (*ComposeConfigInput, error) { + resp := &ComposeConfigInput{} + err := c.rancherClient.doCreate(COMPOSE_CONFIG_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *ComposeConfigInputClient) Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error) { + resp := &ComposeConfigInput{} + err := c.rancherClient.doUpdate(COMPOSE_CONFIG_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ComposeConfigInputClient) List(opts *ListOpts) (*ComposeConfigInputCollection, error) { + resp := &ComposeConfigInputCollection{} + err := c.rancherClient.doList(COMPOSE_CONFIG_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *ComposeConfigInputClient) ById(id string) (*ComposeConfigInput, error) { + resp := &ComposeConfigInput{} + err := c.rancherClient.doById(COMPOSE_CONFIG_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ComposeConfigInputClient) Delete(container *ComposeConfigInput) error { + return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_config_item.go b/vendor/github.com/rancher/go-rancher/client/generated_config_item.go new file mode 100644 index 00000000..71e687d2 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_config_item.go @@ -0,0 +1,69 @@ +package client + +const ( + CONFIG_ITEM_TYPE = "configItem" +) + +type ConfigItem struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + SourceVersion string `json:"sourceVersion,omitempty" yaml:"source_version,omitempty"` +} + +type ConfigItemCollection struct { + Collection + Data []ConfigItem `json:"data,omitempty"` +} + +type ConfigItemClient struct { + rancherClient *RancherClient +} + +type ConfigItemOperations interface { + List(opts *ListOpts) (*ConfigItemCollection, error) + Create(opts *ConfigItem) (*ConfigItem, error) + Update(existing *ConfigItem, updates interface{}) (*ConfigItem, error) + ById(id string) (*ConfigItem, error) + Delete(container *ConfigItem) error +} + +func newConfigItemClient(rancherClient *RancherClient) *ConfigItemClient { + return &ConfigItemClient{ + rancherClient: rancherClient, + } +} + +func (c *ConfigItemClient) Create(container *ConfigItem) (*ConfigItem, error) { + resp := &ConfigItem{} + err := c.rancherClient.doCreate(CONFIG_ITEM_TYPE, container, resp) + return resp, err +} + +func (c *ConfigItemClient) Update(existing *ConfigItem, updates interface{}) (*ConfigItem, error) { + resp := &ConfigItem{} + err := c.rancherClient.doUpdate(CONFIG_ITEM_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ConfigItemClient) List(opts *ListOpts) (*ConfigItemCollection, error) { + resp := &ConfigItemCollection{} + err := c.rancherClient.doList(CONFIG_ITEM_TYPE, opts, resp) + return resp, err +} + +func (c *ConfigItemClient) ById(id string) (*ConfigItem, error) { + resp := &ConfigItem{} + err := c.rancherClient.doById(CONFIG_ITEM_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ConfigItemClient) Delete(container *ConfigItem) error { + return c.rancherClient.doResourceDelete(CONFIG_ITEM_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_config_item_status.go b/vendor/github.com/rancher/go-rancher/client/generated_config_item_status.go new file mode 100644 index 00000000..0ffef351 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_config_item_status.go @@ -0,0 +1,81 @@ +package client + +const ( + CONFIG_ITEM_STATUS_TYPE = "configItemStatus" +) + +type ConfigItemStatus struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AppliedUpdated string `json:"appliedUpdated,omitempty" yaml:"applied_updated,omitempty"` + + AppliedVersion int64 `json:"appliedVersion,omitempty" yaml:"applied_version,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RequestedUpdated string `json:"requestedUpdated,omitempty" yaml:"requested_updated,omitempty"` + + RequestedVersion int64 `json:"requestedVersion,omitempty" yaml:"requested_version,omitempty"` + + SourceVersion string `json:"sourceVersion,omitempty" yaml:"source_version,omitempty"` +} + +type ConfigItemStatusCollection struct { + Collection + Data []ConfigItemStatus `json:"data,omitempty"` +} + +type ConfigItemStatusClient struct { + rancherClient *RancherClient +} + +type ConfigItemStatusOperations interface { + List(opts *ListOpts) (*ConfigItemStatusCollection, error) + Create(opts *ConfigItemStatus) (*ConfigItemStatus, error) + Update(existing *ConfigItemStatus, updates interface{}) (*ConfigItemStatus, error) + ById(id string) (*ConfigItemStatus, error) + Delete(container *ConfigItemStatus) error +} + +func newConfigItemStatusClient(rancherClient *RancherClient) *ConfigItemStatusClient { + return &ConfigItemStatusClient{ + rancherClient: rancherClient, + } +} + +func (c *ConfigItemStatusClient) Create(container *ConfigItemStatus) (*ConfigItemStatus, error) { + resp := &ConfigItemStatus{} + err := c.rancherClient.doCreate(CONFIG_ITEM_STATUS_TYPE, container, resp) + return resp, err +} + +func (c *ConfigItemStatusClient) Update(existing *ConfigItemStatus, updates interface{}) (*ConfigItemStatus, error) { + resp := &ConfigItemStatus{} + err := c.rancherClient.doUpdate(CONFIG_ITEM_STATUS_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ConfigItemStatusClient) List(opts *ListOpts) (*ConfigItemStatusCollection, error) { + resp := &ConfigItemStatusCollection{} + err := c.rancherClient.doList(CONFIG_ITEM_STATUS_TYPE, opts, resp) + return resp, err +} + +func (c *ConfigItemStatusClient) ById(id string) (*ConfigItemStatus, error) { + resp := &ConfigItemStatus{} + err := c.rancherClient.doById(CONFIG_ITEM_STATUS_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ConfigItemStatusClient) Delete(container *ConfigItemStatus) error { + return c.rancherClient.doResourceDelete(CONFIG_ITEM_STATUS_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_container.go b/vendor/github.com/rancher/go-rancher/client/generated_container.go new file mode 100644 index 00000000..bc75af6a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_container.go @@ -0,0 +1,405 @@ +package client + +const ( + CONTAINER_TYPE = "container" +) + +type Container struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AllocationState string `json:"allocationState,omitempty" yaml:"allocation_state,omitempty"` + + Build *DockerBuild `json:"build,omitempty" yaml:"build,omitempty"` + + CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"` + + CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"` + + Command []string `json:"command,omitempty" yaml:"command,omitempty"` + + Count int64 `json:"count,omitempty" yaml:"count,omitempty"` + + CpuSet string `json:"cpuSet,omitempty" yaml:"cpu_set,omitempty"` + + CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"` + + CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DataVolumeMounts map[string]interface{} `json:"dataVolumeMounts,omitempty" yaml:"data_volume_mounts,omitempty"` + + DataVolumes []string `json:"dataVolumes,omitempty" yaml:"data_volumes,omitempty"` + + DataVolumesFrom []string `json:"dataVolumesFrom,omitempty" yaml:"data_volumes_from,omitempty"` + + DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"` + + Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"` + + DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"` + + DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"` + + EntryPoint []string `json:"entryPoint,omitempty" yaml:"entry_point,omitempty"` + + Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"` + + FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"` + + HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` + + InstanceLinks map[string]interface{} `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"` + + LxcConf map[string]interface{} `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"` + + Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"` + + MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"` + + NetworkContainerId string `json:"networkContainerId,omitempty" yaml:"network_container_id,omitempty"` + + NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"` + + NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"` + + PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"` + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"` + + Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"` + + PublishAllPorts bool `json:"publishAllPorts,omitempty" yaml:"publish_all_ports,omitempty"` + + ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"` + + RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"` + + RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty" yaml:"restart_policy,omitempty"` + + SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"` + + StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"` + + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"` + + SystemContainer string `json:"systemContainer,omitempty" yaml:"system_container,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"` + + User string `json:"user,omitempty" yaml:"user,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Version string `json:"version,omitempty" yaml:"version,omitempty"` + + VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"` + + WorkingDir string `json:"workingDir,omitempty" yaml:"working_dir,omitempty"` +} + +type ContainerCollection struct { + Collection + Data []Container `json:"data,omitempty"` +} + +type ContainerClient struct { + rancherClient *RancherClient +} + +type ContainerOperations interface { + List(opts *ListOpts) (*ContainerCollection, error) + Create(opts *Container) (*Container, error) + Update(existing *Container, updates interface{}) (*Container, error) + ById(id string) (*Container, error) + Delete(container *Container) error + + ActionAllocate(*Container) (*Instance, error) + + ActionConsole(*Container, *InstanceConsoleInput) (*InstanceConsole, error) + + ActionCreate(*Container) (*Instance, error) + + ActionDeallocate(*Container) (*Instance, error) + + ActionExecute(*Container, *ContainerExec) (*HostAccess, error) + + ActionLogs(*Container, *ContainerLogs) (*HostAccess, error) + + ActionMigrate(*Container) (*Instance, error) + + ActionPurge(*Container) (*Instance, error) + + ActionRemove(*Container) (*Instance, error) + + ActionRestart(*Container) (*Instance, error) + + ActionRestore(*Container) (*Instance, error) + + ActionSetlabels(*Container, *SetLabelsInput) (*Container, error) + + ActionStart(*Container) (*Instance, error) + + ActionStop(*Container, *InstanceStop) (*Instance, error) + + ActionUpdate(*Container) (*Instance, error) + + ActionUpdatehealthy(*Container) (*Instance, error) + + ActionUpdatereinitializing(*Container) (*Instance, error) + + ActionUpdateunhealthy(*Container) (*Instance, error) +} + +func newContainerClient(rancherClient *RancherClient) *ContainerClient { + return &ContainerClient{ + rancherClient: rancherClient, + } +} + +func (c *ContainerClient) Create(container *Container) (*Container, error) { + resp := &Container{} + err := c.rancherClient.doCreate(CONTAINER_TYPE, container, resp) + return resp, err +} + +func (c *ContainerClient) Update(existing *Container, updates interface{}) (*Container, error) { + resp := &Container{} + err := c.rancherClient.doUpdate(CONTAINER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ContainerClient) List(opts *ListOpts) (*ContainerCollection, error) { + resp := &ContainerCollection{} + err := c.rancherClient.doList(CONTAINER_TYPE, opts, resp) + return resp, err +} + +func (c *ContainerClient) ById(id string) (*Container, error) { + resp := &Container{} + err := c.rancherClient.doById(CONTAINER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ContainerClient) Delete(container *Container) error { + return c.rancherClient.doResourceDelete(CONTAINER_TYPE, &container.Resource) +} + +func (c *ContainerClient) ActionAllocate(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "allocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionConsole(resource *Container, input *InstanceConsoleInput) (*InstanceConsole, error) { + + resp := &InstanceConsole{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "console", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ContainerClient) ActionCreate(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionDeallocate(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "deallocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionExecute(resource *Container, input *ContainerExec) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "execute", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ContainerClient) ActionLogs(resource *Container, input *ContainerLogs) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "logs", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ContainerClient) ActionMigrate(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "migrate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionPurge(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionRemove(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionRestart(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "restart", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionRestore(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionSetlabels(resource *Container, input *SetLabelsInput) (*Container, error) { + + resp := &Container{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "setlabels", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ContainerClient) ActionStart(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "start", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionStop(resource *Container, input *InstanceStop) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "stop", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ContainerClient) ActionUpdate(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionUpdatehealthy(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "updatehealthy", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionUpdatereinitializing(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "updatereinitializing", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerClient) ActionUpdateunhealthy(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "updateunhealthy", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_container_event.go b/vendor/github.com/rancher/go-rancher/client/generated_container_event.go new file mode 100644 index 00000000..414030bd --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_container_event.go @@ -0,0 +1,117 @@ +package client + +const ( + CONTAINER_EVENT_TYPE = "containerEvent" +) + +type ContainerEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DockerInspect interface{} `json:"dockerInspect,omitempty" yaml:"docker_inspect,omitempty"` + + ExternalFrom string `json:"externalFrom,omitempty" yaml:"external_from,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExternalStatus string `json:"externalStatus,omitempty" yaml:"external_status,omitempty"` + + ExternalTimestamp int64 `json:"externalTimestamp,omitempty" yaml:"external_timestamp,omitempty"` + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedHostUuid string `json:"reportedHostUuid,omitempty" yaml:"reported_host_uuid,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` +} + +type ContainerEventCollection struct { + Collection + Data []ContainerEvent `json:"data,omitempty"` +} + +type ContainerEventClient struct { + rancherClient *RancherClient +} + +type ContainerEventOperations interface { + List(opts *ListOpts) (*ContainerEventCollection, error) + Create(opts *ContainerEvent) (*ContainerEvent, error) + Update(existing *ContainerEvent, updates interface{}) (*ContainerEvent, error) + ById(id string) (*ContainerEvent, error) + Delete(container *ContainerEvent) error + + ActionCreate(*ContainerEvent) (*ContainerEvent, error) + + ActionRemove(*ContainerEvent) (*ContainerEvent, error) +} + +func newContainerEventClient(rancherClient *RancherClient) *ContainerEventClient { + return &ContainerEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ContainerEventClient) Create(container *ContainerEvent) (*ContainerEvent, error) { + resp := &ContainerEvent{} + err := c.rancherClient.doCreate(CONTAINER_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ContainerEventClient) Update(existing *ContainerEvent, updates interface{}) (*ContainerEvent, error) { + resp := &ContainerEvent{} + err := c.rancherClient.doUpdate(CONTAINER_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ContainerEventClient) List(opts *ListOpts) (*ContainerEventCollection, error) { + resp := &ContainerEventCollection{} + err := c.rancherClient.doList(CONTAINER_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ContainerEventClient) ById(id string) (*ContainerEvent, error) { + resp := &ContainerEvent{} + err := c.rancherClient.doById(CONTAINER_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ContainerEventClient) Delete(container *ContainerEvent) error { + return c.rancherClient.doResourceDelete(CONTAINER_EVENT_TYPE, &container.Resource) +} + +func (c *ContainerEventClient) ActionCreate(resource *ContainerEvent) (*ContainerEvent, error) { + + resp := &ContainerEvent{} + + err := c.rancherClient.doAction(CONTAINER_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ContainerEventClient) ActionRemove(resource *ContainerEvent) (*ContainerEvent, error) { + + resp := &ContainerEvent{} + + err := c.rancherClient.doAction(CONTAINER_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_container_exec.go b/vendor/github.com/rancher/go-rancher/client/generated_container_exec.go new file mode 100644 index 00000000..c97f7703 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_container_exec.go @@ -0,0 +1,73 @@ +package client + +const ( + CONTAINER_EXEC_TYPE = "containerExec" +) + +type ContainerExec struct { + Resource + + AttachStdin bool `json:"attachStdin,omitempty" yaml:"attach_stdin,omitempty"` + + AttachStdout bool `json:"attachStdout,omitempty" yaml:"attach_stdout,omitempty"` + + Command []string `json:"command,omitempty" yaml:"command,omitempty"` + + Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"` +} + +type ContainerExecCollection struct { + Collection + Data []ContainerExec `json:"data,omitempty"` +} + +type ContainerExecClient struct { + rancherClient *RancherClient +} + +type ContainerExecOperations interface { + List(opts *ListOpts) (*ContainerExecCollection, error) + Create(opts *ContainerExec) (*ContainerExec, error) + Update(existing *ContainerExec, updates interface{}) (*ContainerExec, error) + ById(id string) (*ContainerExec, error) + Delete(container *ContainerExec) error +} + +func newContainerExecClient(rancherClient *RancherClient) *ContainerExecClient { + return &ContainerExecClient{ + rancherClient: rancherClient, + } +} + +func (c *ContainerExecClient) Create(container *ContainerExec) (*ContainerExec, error) { + resp := &ContainerExec{} + err := c.rancherClient.doCreate(CONTAINER_EXEC_TYPE, container, resp) + return resp, err +} + +func (c *ContainerExecClient) Update(existing *ContainerExec, updates interface{}) (*ContainerExec, error) { + resp := &ContainerExec{} + err := c.rancherClient.doUpdate(CONTAINER_EXEC_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ContainerExecClient) List(opts *ListOpts) (*ContainerExecCollection, error) { + resp := &ContainerExecCollection{} + err := c.rancherClient.doList(CONTAINER_EXEC_TYPE, opts, resp) + return resp, err +} + +func (c *ContainerExecClient) ById(id string) (*ContainerExec, error) { + resp := &ContainerExec{} + err := c.rancherClient.doById(CONTAINER_EXEC_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ContainerExecClient) Delete(container *ContainerExec) error { + return c.rancherClient.doResourceDelete(CONTAINER_EXEC_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_container_logs.go b/vendor/github.com/rancher/go-rancher/client/generated_container_logs.go new file mode 100644 index 00000000..4d37dab9 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_container_logs.go @@ -0,0 +1,69 @@ +package client + +const ( + CONTAINER_LOGS_TYPE = "containerLogs" +) + +type ContainerLogs struct { + Resource + + Follow bool `json:"follow,omitempty" yaml:"follow,omitempty"` + + Lines int64 `json:"lines,omitempty" yaml:"lines,omitempty"` +} + +type ContainerLogsCollection struct { + Collection + Data []ContainerLogs `json:"data,omitempty"` +} + +type ContainerLogsClient struct { + rancherClient *RancherClient +} + +type ContainerLogsOperations interface { + List(opts *ListOpts) (*ContainerLogsCollection, error) + Create(opts *ContainerLogs) (*ContainerLogs, error) + Update(existing *ContainerLogs, updates interface{}) (*ContainerLogs, error) + ById(id string) (*ContainerLogs, error) + Delete(container *ContainerLogs) error +} + +func newContainerLogsClient(rancherClient *RancherClient) *ContainerLogsClient { + return &ContainerLogsClient{ + rancherClient: rancherClient, + } +} + +func (c *ContainerLogsClient) Create(container *ContainerLogs) (*ContainerLogs, error) { + resp := &ContainerLogs{} + err := c.rancherClient.doCreate(CONTAINER_LOGS_TYPE, container, resp) + return resp, err +} + +func (c *ContainerLogsClient) Update(existing *ContainerLogs, updates interface{}) (*ContainerLogs, error) { + resp := &ContainerLogs{} + err := c.rancherClient.doUpdate(CONTAINER_LOGS_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ContainerLogsClient) List(opts *ListOpts) (*ContainerLogsCollection, error) { + resp := &ContainerLogsCollection{} + err := c.rancherClient.doList(CONTAINER_LOGS_TYPE, opts, resp) + return resp, err +} + +func (c *ContainerLogsClient) ById(id string) (*ContainerLogs, error) { + resp := &ContainerLogs{} + err := c.rancherClient.doById(CONTAINER_LOGS_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ContainerLogsClient) Delete(container *ContainerLogs) error { + return c.rancherClient.doResourceDelete(CONTAINER_LOGS_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_credential.go b/vendor/github.com/rancher/go-rancher/client/generated_credential.go new file mode 100644 index 00000000..e1586db2 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_credential.go @@ -0,0 +1,161 @@ +package client + +const ( + CREDENTIAL_TYPE = "credential" +) + +type Credential struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type CredentialCollection struct { + Collection + Data []Credential `json:"data,omitempty"` +} + +type CredentialClient struct { + rancherClient *RancherClient +} + +type CredentialOperations interface { + List(opts *ListOpts) (*CredentialCollection, error) + Create(opts *Credential) (*Credential, error) + Update(existing *Credential, updates interface{}) (*Credential, error) + ById(id string) (*Credential, error) + Delete(container *Credential) error + + ActionActivate(*Credential) (*Credential, error) + + ActionCreate(*Credential) (*Credential, error) + + ActionDeactivate(*Credential) (*Credential, error) + + ActionPurge(*Credential) (*Credential, error) + + ActionRemove(*Credential) (*Credential, error) + + ActionUpdate(*Credential) (*Credential, error) +} + +func newCredentialClient(rancherClient *RancherClient) *CredentialClient { + return &CredentialClient{ + rancherClient: rancherClient, + } +} + +func (c *CredentialClient) Create(container *Credential) (*Credential, error) { + resp := &Credential{} + err := c.rancherClient.doCreate(CREDENTIAL_TYPE, container, resp) + return resp, err +} + +func (c *CredentialClient) Update(existing *Credential, updates interface{}) (*Credential, error) { + resp := &Credential{} + err := c.rancherClient.doUpdate(CREDENTIAL_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *CredentialClient) List(opts *ListOpts) (*CredentialCollection, error) { + resp := &CredentialCollection{} + err := c.rancherClient.doList(CREDENTIAL_TYPE, opts, resp) + return resp, err +} + +func (c *CredentialClient) ById(id string) (*Credential, error) { + resp := &Credential{} + err := c.rancherClient.doById(CREDENTIAL_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *CredentialClient) Delete(container *Credential) error { + return c.rancherClient.doResourceDelete(CREDENTIAL_TYPE, &container.Resource) +} + +func (c *CredentialClient) ActionActivate(resource *Credential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(CREDENTIAL_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *CredentialClient) ActionCreate(resource *Credential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(CREDENTIAL_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *CredentialClient) ActionDeactivate(resource *Credential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(CREDENTIAL_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *CredentialClient) ActionPurge(resource *Credential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(CREDENTIAL_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *CredentialClient) ActionRemove(resource *Credential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(CREDENTIAL_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *CredentialClient) ActionUpdate(resource *Credential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(CREDENTIAL_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_databasechangelog.go b/vendor/github.com/rancher/go-rancher/client/generated_databasechangelog.go new file mode 100644 index 00000000..63b3ca6c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_databasechangelog.go @@ -0,0 +1,85 @@ +package client + +const ( + DATABASECHANGELOG_TYPE = "databasechangelog" +) + +type Databasechangelog struct { + Resource + + Author string `json:"author,omitempty" yaml:"author,omitempty"` + + Comments string `json:"comments,omitempty" yaml:"comments,omitempty"` + + Dateexecuted string `json:"dateexecuted,omitempty" yaml:"dateexecuted,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Exectype string `json:"exectype,omitempty" yaml:"exectype,omitempty"` + + Filename string `json:"filename,omitempty" yaml:"filename,omitempty"` + + Liquibase string `json:"liquibase,omitempty" yaml:"liquibase,omitempty"` + + Md5sum string `json:"md5sum,omitempty" yaml:"md5sum,omitempty"` + + Orderexecuted int64 `json:"orderexecuted,omitempty" yaml:"orderexecuted,omitempty"` + + Tag string `json:"tag,omitempty" yaml:"tag,omitempty"` +} + +type DatabasechangelogCollection struct { + Collection + Data []Databasechangelog `json:"data,omitempty"` +} + +type DatabasechangelogClient struct { + rancherClient *RancherClient +} + +type DatabasechangelogOperations interface { + List(opts *ListOpts) (*DatabasechangelogCollection, error) + Create(opts *Databasechangelog) (*Databasechangelog, error) + Update(existing *Databasechangelog, updates interface{}) (*Databasechangelog, error) + ById(id string) (*Databasechangelog, error) + Delete(container *Databasechangelog) error +} + +func newDatabasechangelogClient(rancherClient *RancherClient) *DatabasechangelogClient { + return &DatabasechangelogClient{ + rancherClient: rancherClient, + } +} + +func (c *DatabasechangelogClient) Create(container *Databasechangelog) (*Databasechangelog, error) { + resp := &Databasechangelog{} + err := c.rancherClient.doCreate(DATABASECHANGELOG_TYPE, container, resp) + return resp, err +} + +func (c *DatabasechangelogClient) Update(existing *Databasechangelog, updates interface{}) (*Databasechangelog, error) { + resp := &Databasechangelog{} + err := c.rancherClient.doUpdate(DATABASECHANGELOG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *DatabasechangelogClient) List(opts *ListOpts) (*DatabasechangelogCollection, error) { + resp := &DatabasechangelogCollection{} + err := c.rancherClient.doList(DATABASECHANGELOG_TYPE, opts, resp) + return resp, err +} + +func (c *DatabasechangelogClient) ById(id string) (*Databasechangelog, error) { + resp := &Databasechangelog{} + err := c.rancherClient.doById(DATABASECHANGELOG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *DatabasechangelogClient) Delete(container *Databasechangelog) error { + return c.rancherClient.doResourceDelete(DATABASECHANGELOG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_databasechangeloglock.go b/vendor/github.com/rancher/go-rancher/client/generated_databasechangeloglock.go new file mode 100644 index 00000000..f01b7bbc --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_databasechangeloglock.go @@ -0,0 +1,71 @@ +package client + +const ( + DATABASECHANGELOGLOCK_TYPE = "databasechangeloglock" +) + +type Databasechangeloglock struct { + Resource + + Locked bool `json:"locked,omitempty" yaml:"locked,omitempty"` + + Lockedby string `json:"lockedby,omitempty" yaml:"lockedby,omitempty"` + + Lockgranted string `json:"lockgranted,omitempty" yaml:"lockgranted,omitempty"` +} + +type DatabasechangeloglockCollection struct { + Collection + Data []Databasechangeloglock `json:"data,omitempty"` +} + +type DatabasechangeloglockClient struct { + rancherClient *RancherClient +} + +type DatabasechangeloglockOperations interface { + List(opts *ListOpts) (*DatabasechangeloglockCollection, error) + Create(opts *Databasechangeloglock) (*Databasechangeloglock, error) + Update(existing *Databasechangeloglock, updates interface{}) (*Databasechangeloglock, error) + ById(id string) (*Databasechangeloglock, error) + Delete(container *Databasechangeloglock) error +} + +func newDatabasechangeloglockClient(rancherClient *RancherClient) *DatabasechangeloglockClient { + return &DatabasechangeloglockClient{ + rancherClient: rancherClient, + } +} + +func (c *DatabasechangeloglockClient) Create(container *Databasechangeloglock) (*Databasechangeloglock, error) { + resp := &Databasechangeloglock{} + err := c.rancherClient.doCreate(DATABASECHANGELOGLOCK_TYPE, container, resp) + return resp, err +} + +func (c *DatabasechangeloglockClient) Update(existing *Databasechangeloglock, updates interface{}) (*Databasechangeloglock, error) { + resp := &Databasechangeloglock{} + err := c.rancherClient.doUpdate(DATABASECHANGELOGLOCK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *DatabasechangeloglockClient) List(opts *ListOpts) (*DatabasechangeloglockCollection, error) { + resp := &DatabasechangeloglockCollection{} + err := c.rancherClient.doList(DATABASECHANGELOGLOCK_TYPE, opts, resp) + return resp, err +} + +func (c *DatabasechangeloglockClient) ById(id string) (*Databasechangeloglock, error) { + resp := &Databasechangeloglock{} + err := c.rancherClient.doById(DATABASECHANGELOGLOCK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *DatabasechangeloglockClient) Delete(container *Databasechangeloglock) error { + return c.rancherClient.doResourceDelete(DATABASECHANGELOGLOCK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_digitalocean_config.go b/vendor/github.com/rancher/go-rancher/client/generated_digitalocean_config.go new file mode 100644 index 00000000..c30234b9 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_digitalocean_config.go @@ -0,0 +1,81 @@ +package client + +const ( + DIGITALOCEAN_CONFIG_TYPE = "digitaloceanConfig" +) + +type DigitaloceanConfig struct { + Resource + + AccessToken string `json:"accessToken,omitempty" yaml:"access_token,omitempty"` + + Backups bool `json:"backups,omitempty" yaml:"backups,omitempty"` + + Image string `json:"image,omitempty" yaml:"image,omitempty"` + + Ipv6 bool `json:"ipv6,omitempty" yaml:"ipv6,omitempty"` + + PrivateNetworking bool `json:"privateNetworking,omitempty" yaml:"private_networking,omitempty"` + + Region string `json:"region,omitempty" yaml:"region,omitempty"` + + Size string `json:"size,omitempty" yaml:"size,omitempty"` + + SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"` +} + +type DigitaloceanConfigCollection struct { + Collection + Data []DigitaloceanConfig `json:"data,omitempty"` +} + +type DigitaloceanConfigClient struct { + rancherClient *RancherClient +} + +type DigitaloceanConfigOperations interface { + List(opts *ListOpts) (*DigitaloceanConfigCollection, error) + Create(opts *DigitaloceanConfig) (*DigitaloceanConfig, error) + Update(existing *DigitaloceanConfig, updates interface{}) (*DigitaloceanConfig, error) + ById(id string) (*DigitaloceanConfig, error) + Delete(container *DigitaloceanConfig) error +} + +func newDigitaloceanConfigClient(rancherClient *RancherClient) *DigitaloceanConfigClient { + return &DigitaloceanConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *DigitaloceanConfigClient) Create(container *DigitaloceanConfig) (*DigitaloceanConfig, error) { + resp := &DigitaloceanConfig{} + err := c.rancherClient.doCreate(DIGITALOCEAN_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *DigitaloceanConfigClient) Update(existing *DigitaloceanConfig, updates interface{}) (*DigitaloceanConfig, error) { + resp := &DigitaloceanConfig{} + err := c.rancherClient.doUpdate(DIGITALOCEAN_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *DigitaloceanConfigClient) List(opts *ListOpts) (*DigitaloceanConfigCollection, error) { + resp := &DigitaloceanConfigCollection{} + err := c.rancherClient.doList(DIGITALOCEAN_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *DigitaloceanConfigClient) ById(id string) (*DigitaloceanConfig, error) { + resp := &DigitaloceanConfig{} + err := c.rancherClient.doById(DIGITALOCEAN_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *DigitaloceanConfigClient) Delete(container *DigitaloceanConfig) error { + return c.rancherClient.doResourceDelete(DIGITALOCEAN_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_dns_service.go b/vendor/github.com/rancher/go-rancher/client/generated_dns_service.go new file mode 100644 index 00000000..ee043962 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_dns_service.go @@ -0,0 +1,261 @@ +package client + +const ( + DNS_SERVICE_TYPE = "dnsService" +) + +type DnsService struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` + + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"` + + SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type DnsServiceCollection struct { + Collection + Data []DnsService `json:"data,omitempty"` +} + +type DnsServiceClient struct { + rancherClient *RancherClient +} + +type DnsServiceOperations interface { + List(opts *ListOpts) (*DnsServiceCollection, error) + Create(opts *DnsService) (*DnsService, error) + Update(existing *DnsService, updates interface{}) (*DnsService, error) + ById(id string) (*DnsService, error) + Delete(container *DnsService) error + + ActionActivate(*DnsService) (*Service, error) + + ActionAddservicelink(*DnsService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionCancelrollback(*DnsService) (*Service, error) + + ActionCancelupgrade(*DnsService) (*Service, error) + + ActionCreate(*DnsService) (*Service, error) + + ActionDeactivate(*DnsService) (*Service, error) + + ActionFinishupgrade(*DnsService) (*Service, error) + + ActionRemove(*DnsService) (*Service, error) + + ActionRemoveservicelink(*DnsService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionRestart(*DnsService, *ServiceRestart) (*Service, error) + + ActionRollback(*DnsService) (*Service, error) + + ActionSetservicelinks(*DnsService, *SetServiceLinksInput) (*Service, error) + + ActionUpdate(*DnsService) (*Service, error) + + ActionUpgrade(*DnsService, *ServiceUpgrade) (*Service, error) +} + +func newDnsServiceClient(rancherClient *RancherClient) *DnsServiceClient { + return &DnsServiceClient{ + rancherClient: rancherClient, + } +} + +func (c *DnsServiceClient) Create(container *DnsService) (*DnsService, error) { + resp := &DnsService{} + err := c.rancherClient.doCreate(DNS_SERVICE_TYPE, container, resp) + return resp, err +} + +func (c *DnsServiceClient) Update(existing *DnsService, updates interface{}) (*DnsService, error) { + resp := &DnsService{} + err := c.rancherClient.doUpdate(DNS_SERVICE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *DnsServiceClient) List(opts *ListOpts) (*DnsServiceCollection, error) { + resp := &DnsServiceCollection{} + err := c.rancherClient.doList(DNS_SERVICE_TYPE, opts, resp) + return resp, err +} + +func (c *DnsServiceClient) ById(id string) (*DnsService, error) { + resp := &DnsService{} + err := c.rancherClient.doById(DNS_SERVICE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *DnsServiceClient) Delete(container *DnsService) error { + return c.rancherClient.doResourceDelete(DNS_SERVICE_TYPE, &container.Resource) +} + +func (c *DnsServiceClient) ActionActivate(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionAddservicelink(resource *DnsService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionCancelrollback(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionCancelupgrade(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionCreate(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionDeactivate(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionFinishupgrade(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionRemove(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionRemoveservicelink(resource *DnsService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionRestart(resource *DnsService, input *ServiceRestart) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "restart", &resource.Resource, input, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionRollback(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionSetservicelinks(resource *DnsService, input *SetServiceLinksInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionUpdate(resource *DnsService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DnsServiceClient) ActionUpgrade(resource *DnsService, input *ServiceUpgrade) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_docker_build.go b/vendor/github.com/rancher/go-rancher/client/generated_docker_build.go new file mode 100644 index 00000000..cd91f65b --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_docker_build.go @@ -0,0 +1,77 @@ +package client + +const ( + DOCKER_BUILD_TYPE = "dockerBuild" +) + +type DockerBuild struct { + Resource + + Context string `json:"context,omitempty" yaml:"context,omitempty"` + + Dockerfile string `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"` + + Forcerm bool `json:"forcerm,omitempty" yaml:"forcerm,omitempty"` + + Nocache bool `json:"nocache,omitempty" yaml:"nocache,omitempty"` + + Remote string `json:"remote,omitempty" yaml:"remote,omitempty"` + + Rm bool `json:"rm,omitempty" yaml:"rm,omitempty"` +} + +type DockerBuildCollection struct { + Collection + Data []DockerBuild `json:"data,omitempty"` +} + +type DockerBuildClient struct { + rancherClient *RancherClient +} + +type DockerBuildOperations interface { + List(opts *ListOpts) (*DockerBuildCollection, error) + Create(opts *DockerBuild) (*DockerBuild, error) + Update(existing *DockerBuild, updates interface{}) (*DockerBuild, error) + ById(id string) (*DockerBuild, error) + Delete(container *DockerBuild) error +} + +func newDockerBuildClient(rancherClient *RancherClient) *DockerBuildClient { + return &DockerBuildClient{ + rancherClient: rancherClient, + } +} + +func (c *DockerBuildClient) Create(container *DockerBuild) (*DockerBuild, error) { + resp := &DockerBuild{} + err := c.rancherClient.doCreate(DOCKER_BUILD_TYPE, container, resp) + return resp, err +} + +func (c *DockerBuildClient) Update(existing *DockerBuild, updates interface{}) (*DockerBuild, error) { + resp := &DockerBuild{} + err := c.rancherClient.doUpdate(DOCKER_BUILD_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *DockerBuildClient) List(opts *ListOpts) (*DockerBuildCollection, error) { + resp := &DockerBuildCollection{} + err := c.rancherClient.doList(DOCKER_BUILD_TYPE, opts, resp) + return resp, err +} + +func (c *DockerBuildClient) ById(id string) (*DockerBuild, error) { + resp := &DockerBuild{} + err := c.rancherClient.doById(DOCKER_BUILD_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *DockerBuildClient) Delete(container *DockerBuild) error { + return c.rancherClient.doResourceDelete(DOCKER_BUILD_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_dynamic_schema.go b/vendor/github.com/rancher/go-rancher/client/generated_dynamic_schema.go new file mode 100644 index 00000000..b828c4c7 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_dynamic_schema.go @@ -0,0 +1,115 @@ +package client + +const ( + DYNAMIC_SCHEMA_TYPE = "dynamicSchema" +) + +type DynamicSchema struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Definition string `json:"definition,omitempty" yaml:"definition,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Parent string `json:"parent,omitempty" yaml:"parent,omitempty"` + + Roles []string `json:"roles,omitempty" yaml:"roles,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type DynamicSchemaCollection struct { + Collection + Data []DynamicSchema `json:"data,omitempty"` +} + +type DynamicSchemaClient struct { + rancherClient *RancherClient +} + +type DynamicSchemaOperations interface { + List(opts *ListOpts) (*DynamicSchemaCollection, error) + Create(opts *DynamicSchema) (*DynamicSchema, error) + Update(existing *DynamicSchema, updates interface{}) (*DynamicSchema, error) + ById(id string) (*DynamicSchema, error) + Delete(container *DynamicSchema) error + + ActionCreate(*DynamicSchema) (*DynamicSchema, error) + + ActionRemove(*DynamicSchema) (*DynamicSchema, error) +} + +func newDynamicSchemaClient(rancherClient *RancherClient) *DynamicSchemaClient { + return &DynamicSchemaClient{ + rancherClient: rancherClient, + } +} + +func (c *DynamicSchemaClient) Create(container *DynamicSchema) (*DynamicSchema, error) { + resp := &DynamicSchema{} + err := c.rancherClient.doCreate(DYNAMIC_SCHEMA_TYPE, container, resp) + return resp, err +} + +func (c *DynamicSchemaClient) Update(existing *DynamicSchema, updates interface{}) (*DynamicSchema, error) { + resp := &DynamicSchema{} + err := c.rancherClient.doUpdate(DYNAMIC_SCHEMA_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *DynamicSchemaClient) List(opts *ListOpts) (*DynamicSchemaCollection, error) { + resp := &DynamicSchemaCollection{} + err := c.rancherClient.doList(DYNAMIC_SCHEMA_TYPE, opts, resp) + return resp, err +} + +func (c *DynamicSchemaClient) ById(id string) (*DynamicSchema, error) { + resp := &DynamicSchema{} + err := c.rancherClient.doById(DYNAMIC_SCHEMA_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *DynamicSchemaClient) Delete(container *DynamicSchema) error { + return c.rancherClient.doResourceDelete(DYNAMIC_SCHEMA_TYPE, &container.Resource) +} + +func (c *DynamicSchemaClient) ActionCreate(resource *DynamicSchema) (*DynamicSchema, error) { + + resp := &DynamicSchema{} + + err := c.rancherClient.doAction(DYNAMIC_SCHEMA_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *DynamicSchemaClient) ActionRemove(resource *DynamicSchema) (*DynamicSchema, error) { + + resp := &DynamicSchema{} + + err := c.rancherClient.doAction(DYNAMIC_SCHEMA_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_environment.go b/vendor/github.com/rancher/go-rancher/client/generated_environment.go new file mode 100644 index 00000000..fd837bfe --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_environment.go @@ -0,0 +1,248 @@ +package client + +const ( + ENVIRONMENT_TYPE = "environment" +) + +type Environment struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"` + + Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"` + + PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,omitempty"` + + RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type EnvironmentCollection struct { + Collection + Data []Environment `json:"data,omitempty"` +} + +type EnvironmentClient struct { + rancherClient *RancherClient +} + +type EnvironmentOperations interface { + List(opts *ListOpts) (*EnvironmentCollection, error) + Create(opts *Environment) (*Environment, error) + Update(existing *Environment, updates interface{}) (*Environment, error) + ById(id string) (*Environment, error) + Delete(container *Environment) error + + ActionActivateservices(*Environment) (*Environment, error) + + ActionAddoutputs(*Environment, *AddOutputsInput) (*Environment, error) + + ActionCancelrollback(*Environment) (*Environment, error) + + ActionCancelupgrade(*Environment) (*Environment, error) + + ActionCreate(*Environment) (*Environment, error) + + ActionDeactivateservices(*Environment) (*Environment, error) + + ActionError(*Environment) (*Environment, error) + + ActionExportconfig(*Environment, *ComposeConfigInput) (*ComposeConfig, error) + + ActionFinishupgrade(*Environment) (*Environment, error) + + ActionRemove(*Environment) (*Environment, error) + + ActionRollback(*Environment) (*Environment, error) + + ActionUpdate(*Environment) (*Environment, error) + + ActionUpgrade(*Environment, *EnvironmentUpgrade) (*Environment, error) +} + +func newEnvironmentClient(rancherClient *RancherClient) *EnvironmentClient { + return &EnvironmentClient{ + rancherClient: rancherClient, + } +} + +func (c *EnvironmentClient) Create(container *Environment) (*Environment, error) { + resp := &Environment{} + err := c.rancherClient.doCreate(ENVIRONMENT_TYPE, container, resp) + return resp, err +} + +func (c *EnvironmentClient) Update(existing *Environment, updates interface{}) (*Environment, error) { + resp := &Environment{} + err := c.rancherClient.doUpdate(ENVIRONMENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *EnvironmentClient) List(opts *ListOpts) (*EnvironmentCollection, error) { + resp := &EnvironmentCollection{} + err := c.rancherClient.doList(ENVIRONMENT_TYPE, opts, resp) + return resp, err +} + +func (c *EnvironmentClient) ById(id string) (*Environment, error) { + resp := &Environment{} + err := c.rancherClient.doById(ENVIRONMENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *EnvironmentClient) Delete(container *Environment) error { + return c.rancherClient.doResourceDelete(ENVIRONMENT_TYPE, &container.Resource) +} + +func (c *EnvironmentClient) ActionActivateservices(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "activateservices", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionAddoutputs(resource *Environment, input *AddOutputsInput) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "addoutputs", &resource.Resource, input, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionCancelrollback(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionCancelupgrade(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionCreate(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionDeactivateservices(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "deactivateservices", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionError(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionExportconfig(resource *Environment, input *ComposeConfigInput) (*ComposeConfig, error) { + + resp := &ComposeConfig{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "exportconfig", &resource.Resource, input, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionFinishupgrade(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionRemove(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionRollback(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionUpdate(resource *Environment) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *EnvironmentClient) ActionUpgrade(resource *Environment, input *EnvironmentUpgrade) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_environment_upgrade.go b/vendor/github.com/rancher/go-rancher/client/generated_environment_upgrade.go new file mode 100644 index 00000000..23a9afc4 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_environment_upgrade.go @@ -0,0 +1,73 @@ +package client + +const ( + ENVIRONMENT_UPGRADE_TYPE = "environmentUpgrade" +) + +type EnvironmentUpgrade struct { + Resource + + DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"` + + Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"` +} + +type EnvironmentUpgradeCollection struct { + Collection + Data []EnvironmentUpgrade `json:"data,omitempty"` +} + +type EnvironmentUpgradeClient struct { + rancherClient *RancherClient +} + +type EnvironmentUpgradeOperations interface { + List(opts *ListOpts) (*EnvironmentUpgradeCollection, error) + Create(opts *EnvironmentUpgrade) (*EnvironmentUpgrade, error) + Update(existing *EnvironmentUpgrade, updates interface{}) (*EnvironmentUpgrade, error) + ById(id string) (*EnvironmentUpgrade, error) + Delete(container *EnvironmentUpgrade) error +} + +func newEnvironmentUpgradeClient(rancherClient *RancherClient) *EnvironmentUpgradeClient { + return &EnvironmentUpgradeClient{ + rancherClient: rancherClient, + } +} + +func (c *EnvironmentUpgradeClient) Create(container *EnvironmentUpgrade) (*EnvironmentUpgrade, error) { + resp := &EnvironmentUpgrade{} + err := c.rancherClient.doCreate(ENVIRONMENT_UPGRADE_TYPE, container, resp) + return resp, err +} + +func (c *EnvironmentUpgradeClient) Update(existing *EnvironmentUpgrade, updates interface{}) (*EnvironmentUpgrade, error) { + resp := &EnvironmentUpgrade{} + err := c.rancherClient.doUpdate(ENVIRONMENT_UPGRADE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *EnvironmentUpgradeClient) List(opts *ListOpts) (*EnvironmentUpgradeCollection, error) { + resp := &EnvironmentUpgradeCollection{} + err := c.rancherClient.doList(ENVIRONMENT_UPGRADE_TYPE, opts, resp) + return resp, err +} + +func (c *EnvironmentUpgradeClient) ById(id string) (*EnvironmentUpgrade, error) { + resp := &EnvironmentUpgrade{} + err := c.rancherClient.doById(ENVIRONMENT_UPGRADE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *EnvironmentUpgradeClient) Delete(container *EnvironmentUpgrade) error { + return c.rancherClient.doResourceDelete(ENVIRONMENT_UPGRADE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_exoscale_config.go b/vendor/github.com/rancher/go-rancher/client/generated_exoscale_config.go new file mode 100644 index 00000000..5fbda9b7 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_exoscale_config.go @@ -0,0 +1,81 @@ +package client + +const ( + EXOSCALE_CONFIG_TYPE = "exoscaleConfig" +) + +type ExoscaleConfig struct { + Resource + + ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"` + + ApiSecretKey string `json:"apiSecretKey,omitempty" yaml:"api_secret_key,omitempty"` + + AvailabilityZone string `json:"availabilityZone,omitempty" yaml:"availability_zone,omitempty"` + + DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"` + + Image string `json:"image,omitempty" yaml:"image,omitempty"` + + InstanceProfile string `json:"instanceProfile,omitempty" yaml:"instance_profile,omitempty"` + + SecurityGroup []string `json:"securityGroup,omitempty" yaml:"security_group,omitempty"` + + Url string `json:"url,omitempty" yaml:"url,omitempty"` +} + +type ExoscaleConfigCollection struct { + Collection + Data []ExoscaleConfig `json:"data,omitempty"` +} + +type ExoscaleConfigClient struct { + rancherClient *RancherClient +} + +type ExoscaleConfigOperations interface { + List(opts *ListOpts) (*ExoscaleConfigCollection, error) + Create(opts *ExoscaleConfig) (*ExoscaleConfig, error) + Update(existing *ExoscaleConfig, updates interface{}) (*ExoscaleConfig, error) + ById(id string) (*ExoscaleConfig, error) + Delete(container *ExoscaleConfig) error +} + +func newExoscaleConfigClient(rancherClient *RancherClient) *ExoscaleConfigClient { + return &ExoscaleConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *ExoscaleConfigClient) Create(container *ExoscaleConfig) (*ExoscaleConfig, error) { + resp := &ExoscaleConfig{} + err := c.rancherClient.doCreate(EXOSCALE_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *ExoscaleConfigClient) Update(existing *ExoscaleConfig, updates interface{}) (*ExoscaleConfig, error) { + resp := &ExoscaleConfig{} + err := c.rancherClient.doUpdate(EXOSCALE_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExoscaleConfigClient) List(opts *ListOpts) (*ExoscaleConfigCollection, error) { + resp := &ExoscaleConfigCollection{} + err := c.rancherClient.doList(EXOSCALE_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *ExoscaleConfigClient) ById(id string) (*ExoscaleConfig, error) { + resp := &ExoscaleConfig{} + err := c.rancherClient.doById(EXOSCALE_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExoscaleConfigClient) Delete(container *ExoscaleConfig) error { + return c.rancherClient.doResourceDelete(EXOSCALE_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_extension_implementation.go b/vendor/github.com/rancher/go-rancher/client/generated_extension_implementation.go new file mode 100644 index 00000000..cfa7b4aa --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_extension_implementation.go @@ -0,0 +1,71 @@ +package client + +const ( + EXTENSION_IMPLEMENTATION_TYPE = "extensionImplementation" +) + +type ExtensionImplementation struct { + Resource + + ClassName string `json:"className,omitempty" yaml:"class_name,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Properties map[string]interface{} `json:"properties,omitempty" yaml:"properties,omitempty"` +} + +type ExtensionImplementationCollection struct { + Collection + Data []ExtensionImplementation `json:"data,omitempty"` +} + +type ExtensionImplementationClient struct { + rancherClient *RancherClient +} + +type ExtensionImplementationOperations interface { + List(opts *ListOpts) (*ExtensionImplementationCollection, error) + Create(opts *ExtensionImplementation) (*ExtensionImplementation, error) + Update(existing *ExtensionImplementation, updates interface{}) (*ExtensionImplementation, error) + ById(id string) (*ExtensionImplementation, error) + Delete(container *ExtensionImplementation) error +} + +func newExtensionImplementationClient(rancherClient *RancherClient) *ExtensionImplementationClient { + return &ExtensionImplementationClient{ + rancherClient: rancherClient, + } +} + +func (c *ExtensionImplementationClient) Create(container *ExtensionImplementation) (*ExtensionImplementation, error) { + resp := &ExtensionImplementation{} + err := c.rancherClient.doCreate(EXTENSION_IMPLEMENTATION_TYPE, container, resp) + return resp, err +} + +func (c *ExtensionImplementationClient) Update(existing *ExtensionImplementation, updates interface{}) (*ExtensionImplementation, error) { + resp := &ExtensionImplementation{} + err := c.rancherClient.doUpdate(EXTENSION_IMPLEMENTATION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExtensionImplementationClient) List(opts *ListOpts) (*ExtensionImplementationCollection, error) { + resp := &ExtensionImplementationCollection{} + err := c.rancherClient.doList(EXTENSION_IMPLEMENTATION_TYPE, opts, resp) + return resp, err +} + +func (c *ExtensionImplementationClient) ById(id string) (*ExtensionImplementation, error) { + resp := &ExtensionImplementation{} + err := c.rancherClient.doById(EXTENSION_IMPLEMENTATION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExtensionImplementationClient) Delete(container *ExtensionImplementation) error { + return c.rancherClient.doResourceDelete(EXTENSION_IMPLEMENTATION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_extension_point.go b/vendor/github.com/rancher/go-rancher/client/generated_extension_point.go new file mode 100644 index 00000000..0b13cf54 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_extension_point.go @@ -0,0 +1,75 @@ +package client + +const ( + EXTENSION_POINT_TYPE = "extensionPoint" +) + +type ExtensionPoint struct { + Resource + + ExcludeSetting string `json:"excludeSetting,omitempty" yaml:"exclude_setting,omitempty"` + + Implementations []interface{} `json:"implementations,omitempty" yaml:"implementations,omitempty"` + + IncludeSetting string `json:"includeSetting,omitempty" yaml:"include_setting,omitempty"` + + ListSetting string `json:"listSetting,omitempty" yaml:"list_setting,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` +} + +type ExtensionPointCollection struct { + Collection + Data []ExtensionPoint `json:"data,omitempty"` +} + +type ExtensionPointClient struct { + rancherClient *RancherClient +} + +type ExtensionPointOperations interface { + List(opts *ListOpts) (*ExtensionPointCollection, error) + Create(opts *ExtensionPoint) (*ExtensionPoint, error) + Update(existing *ExtensionPoint, updates interface{}) (*ExtensionPoint, error) + ById(id string) (*ExtensionPoint, error) + Delete(container *ExtensionPoint) error +} + +func newExtensionPointClient(rancherClient *RancherClient) *ExtensionPointClient { + return &ExtensionPointClient{ + rancherClient: rancherClient, + } +} + +func (c *ExtensionPointClient) Create(container *ExtensionPoint) (*ExtensionPoint, error) { + resp := &ExtensionPoint{} + err := c.rancherClient.doCreate(EXTENSION_POINT_TYPE, container, resp) + return resp, err +} + +func (c *ExtensionPointClient) Update(existing *ExtensionPoint, updates interface{}) (*ExtensionPoint, error) { + resp := &ExtensionPoint{} + err := c.rancherClient.doUpdate(EXTENSION_POINT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExtensionPointClient) List(opts *ListOpts) (*ExtensionPointCollection, error) { + resp := &ExtensionPointCollection{} + err := c.rancherClient.doList(EXTENSION_POINT_TYPE, opts, resp) + return resp, err +} + +func (c *ExtensionPointClient) ById(id string) (*ExtensionPoint, error) { + resp := &ExtensionPoint{} + err := c.rancherClient.doById(EXTENSION_POINT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExtensionPointClient) Delete(container *ExtensionPoint) error { + return c.rancherClient.doResourceDelete(EXTENSION_POINT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_dns_event.go b/vendor/github.com/rancher/go-rancher/client/generated_external_dns_event.go new file mode 100644 index 00000000..7f4ce256 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_dns_event.go @@ -0,0 +1,117 @@ +package client + +const ( + EXTERNAL_DNS_EVENT_TYPE = "externalDnsEvent" +) + +type ExternalDnsEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"` + + ServiceName string `json:"serviceName,omitempty" yaml:"service_name,omitempty"` + + StackName string `json:"stackName,omitempty" yaml:"stack_name,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalDnsEventCollection struct { + Collection + Data []ExternalDnsEvent `json:"data,omitempty"` +} + +type ExternalDnsEventClient struct { + rancherClient *RancherClient +} + +type ExternalDnsEventOperations interface { + List(opts *ListOpts) (*ExternalDnsEventCollection, error) + Create(opts *ExternalDnsEvent) (*ExternalDnsEvent, error) + Update(existing *ExternalDnsEvent, updates interface{}) (*ExternalDnsEvent, error) + ById(id string) (*ExternalDnsEvent, error) + Delete(container *ExternalDnsEvent) error + + ActionCreate(*ExternalDnsEvent) (*ExternalEvent, error) + + ActionRemove(*ExternalDnsEvent) (*ExternalEvent, error) +} + +func newExternalDnsEventClient(rancherClient *RancherClient) *ExternalDnsEventClient { + return &ExternalDnsEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalDnsEventClient) Create(container *ExternalDnsEvent) (*ExternalDnsEvent, error) { + resp := &ExternalDnsEvent{} + err := c.rancherClient.doCreate(EXTERNAL_DNS_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ExternalDnsEventClient) Update(existing *ExternalDnsEvent, updates interface{}) (*ExternalDnsEvent, error) { + resp := &ExternalDnsEvent{} + err := c.rancherClient.doUpdate(EXTERNAL_DNS_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalDnsEventClient) List(opts *ListOpts) (*ExternalDnsEventCollection, error) { + resp := &ExternalDnsEventCollection{} + err := c.rancherClient.doList(EXTERNAL_DNS_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalDnsEventClient) ById(id string) (*ExternalDnsEvent, error) { + resp := &ExternalDnsEvent{} + err := c.rancherClient.doById(EXTERNAL_DNS_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalDnsEventClient) Delete(container *ExternalDnsEvent) error { + return c.rancherClient.doResourceDelete(EXTERNAL_DNS_EVENT_TYPE, &container.Resource) +} + +func (c *ExternalDnsEventClient) ActionCreate(resource *ExternalDnsEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_DNS_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalDnsEventClient) ActionRemove(resource *ExternalDnsEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_DNS_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_event.go b/vendor/github.com/rancher/go-rancher/client/generated_external_event.go new file mode 100644 index 00000000..a1bf8180 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_event.go @@ -0,0 +1,111 @@ +package client + +const ( + EXTERNAL_EVENT_TYPE = "externalEvent" +) + +type ExternalEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalEventCollection struct { + Collection + Data []ExternalEvent `json:"data,omitempty"` +} + +type ExternalEventClient struct { + rancherClient *RancherClient +} + +type ExternalEventOperations interface { + List(opts *ListOpts) (*ExternalEventCollection, error) + Create(opts *ExternalEvent) (*ExternalEvent, error) + Update(existing *ExternalEvent, updates interface{}) (*ExternalEvent, error) + ById(id string) (*ExternalEvent, error) + Delete(container *ExternalEvent) error + + ActionCreate(*ExternalEvent) (*ExternalEvent, error) + + ActionRemove(*ExternalEvent) (*ExternalEvent, error) +} + +func newExternalEventClient(rancherClient *RancherClient) *ExternalEventClient { + return &ExternalEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalEventClient) Create(container *ExternalEvent) (*ExternalEvent, error) { + resp := &ExternalEvent{} + err := c.rancherClient.doCreate(EXTERNAL_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ExternalEventClient) Update(existing *ExternalEvent, updates interface{}) (*ExternalEvent, error) { + resp := &ExternalEvent{} + err := c.rancherClient.doUpdate(EXTERNAL_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalEventClient) List(opts *ListOpts) (*ExternalEventCollection, error) { + resp := &ExternalEventCollection{} + err := c.rancherClient.doList(EXTERNAL_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalEventClient) ById(id string) (*ExternalEvent, error) { + resp := &ExternalEvent{} + err := c.rancherClient.doById(EXTERNAL_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalEventClient) Delete(container *ExternalEvent) error { + return c.rancherClient.doResourceDelete(EXTERNAL_EVENT_TYPE, &container.Resource) +} + +func (c *ExternalEventClient) ActionCreate(resource *ExternalEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalEventClient) ActionRemove(resource *ExternalEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_handler.go b/vendor/github.com/rancher/go-rancher/client/generated_external_handler.go new file mode 100644 index 00000000..d325b8d5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_handler.go @@ -0,0 +1,174 @@ +package client + +const ( + EXTERNAL_HANDLER_TYPE = "externalHandler" +) + +type ExternalHandler struct { + Resource + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Priority int64 `json:"priority,omitempty" yaml:"priority,omitempty"` + + ProcessConfigs []interface{} `json:"processConfigs,omitempty" yaml:"process_configs,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + Retries int64 `json:"retries,omitempty" yaml:"retries,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + TimeoutMillis int64 `json:"timeoutMillis,omitempty" yaml:"timeout_millis,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalHandlerCollection struct { + Collection + Data []ExternalHandler `json:"data,omitempty"` +} + +type ExternalHandlerClient struct { + rancherClient *RancherClient +} + +type ExternalHandlerOperations interface { + List(opts *ListOpts) (*ExternalHandlerCollection, error) + Create(opts *ExternalHandler) (*ExternalHandler, error) + Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error) + ById(id string) (*ExternalHandler, error) + Delete(container *ExternalHandler) error + + ActionActivate(*ExternalHandler) (*ExternalHandler, error) + + ActionCreate(*ExternalHandler) (*ExternalHandler, error) + + ActionDeactivate(*ExternalHandler) (*ExternalHandler, error) + + ActionPurge(*ExternalHandler) (*ExternalHandler, error) + + ActionRemove(*ExternalHandler) (*ExternalHandler, error) + + ActionRestore(*ExternalHandler) (*ExternalHandler, error) + + ActionUpdate(*ExternalHandler) (*ExternalHandler, error) +} + +func newExternalHandlerClient(rancherClient *RancherClient) *ExternalHandlerClient { + return &ExternalHandlerClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalHandlerClient) Create(container *ExternalHandler) (*ExternalHandler, error) { + resp := &ExternalHandler{} + err := c.rancherClient.doCreate(EXTERNAL_HANDLER_TYPE, container, resp) + return resp, err +} + +func (c *ExternalHandlerClient) Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error) { + resp := &ExternalHandler{} + err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalHandlerClient) List(opts *ListOpts) (*ExternalHandlerCollection, error) { + resp := &ExternalHandlerCollection{} + err := c.rancherClient.doList(EXTERNAL_HANDLER_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalHandlerClient) ById(id string) (*ExternalHandler, error) { + resp := &ExternalHandler{} + err := c.rancherClient.doById(EXTERNAL_HANDLER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalHandlerClient) Delete(container *ExternalHandler) error { + return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_TYPE, &container.Resource) +} + +func (c *ExternalHandlerClient) ActionActivate(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerClient) ActionCreate(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerClient) ActionDeactivate(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerClient) ActionPurge(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerClient) ActionRemove(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerClient) ActionRestore(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerClient) ActionUpdate(resource *ExternalHandler) (*ExternalHandler, error) { + + resp := &ExternalHandler{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_handler_external_handler_process_map.go b/vendor/github.com/rancher/go-rancher/client/generated_external_handler_external_handler_process_map.go new file mode 100644 index 00000000..9852fa89 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_handler_external_handler_process_map.go @@ -0,0 +1,172 @@ +package client + +const ( + EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE = "externalHandlerExternalHandlerProcessMap" +) + +type ExternalHandlerExternalHandlerProcessMap struct { + Resource + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ExternalHandlerId string `json:"externalHandlerId,omitempty" yaml:"external_handler_id,omitempty"` + + ExternalHandlerProcessId string `json:"externalHandlerProcessId,omitempty" yaml:"external_handler_process_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + OnError string `json:"onError,omitempty" yaml:"on_error,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalHandlerExternalHandlerProcessMapCollection struct { + Collection + Data []ExternalHandlerExternalHandlerProcessMap `json:"data,omitempty"` +} + +type ExternalHandlerExternalHandlerProcessMapClient struct { + rancherClient *RancherClient +} + +type ExternalHandlerExternalHandlerProcessMapOperations interface { + List(opts *ListOpts) (*ExternalHandlerExternalHandlerProcessMapCollection, error) + Create(opts *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + Update(existing *ExternalHandlerExternalHandlerProcessMap, updates interface{}) (*ExternalHandlerExternalHandlerProcessMap, error) + ById(id string) (*ExternalHandlerExternalHandlerProcessMap, error) + Delete(container *ExternalHandlerExternalHandlerProcessMap) error + + ActionActivate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + + ActionCreate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + + ActionDeactivate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + + ActionPurge(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + + ActionRemove(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + + ActionRestore(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) + + ActionUpdate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) +} + +func newExternalHandlerExternalHandlerProcessMapClient(rancherClient *RancherClient) *ExternalHandlerExternalHandlerProcessMapClient { + return &ExternalHandlerExternalHandlerProcessMapClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) Create(container *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + resp := &ExternalHandlerExternalHandlerProcessMap{} + err := c.rancherClient.doCreate(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, container, resp) + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) Update(existing *ExternalHandlerExternalHandlerProcessMap, updates interface{}) (*ExternalHandlerExternalHandlerProcessMap, error) { + resp := &ExternalHandlerExternalHandlerProcessMap{} + err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) List(opts *ListOpts) (*ExternalHandlerExternalHandlerProcessMapCollection, error) { + resp := &ExternalHandlerExternalHandlerProcessMapCollection{} + err := c.rancherClient.doList(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ById(id string) (*ExternalHandlerExternalHandlerProcessMap, error) { + resp := &ExternalHandlerExternalHandlerProcessMap{} + err := c.rancherClient.doById(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) Delete(container *ExternalHandlerExternalHandlerProcessMap) error { + return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, &container.Resource) +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionActivate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionCreate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionDeactivate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionPurge(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionRemove(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionRestore(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionUpdate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) { + + resp := &ExternalHandlerExternalHandlerProcessMap{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_handler_process.go b/vendor/github.com/rancher/go-rancher/client/generated_external_handler_process.go new file mode 100644 index 00000000..a6133657 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_handler_process.go @@ -0,0 +1,166 @@ +package client + +const ( + EXTERNAL_HANDLER_PROCESS_TYPE = "externalHandlerProcess" +) + +type ExternalHandlerProcess struct { + Resource + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalHandlerProcessCollection struct { + Collection + Data []ExternalHandlerProcess `json:"data,omitempty"` +} + +type ExternalHandlerProcessClient struct { + rancherClient *RancherClient +} + +type ExternalHandlerProcessOperations interface { + List(opts *ListOpts) (*ExternalHandlerProcessCollection, error) + Create(opts *ExternalHandlerProcess) (*ExternalHandlerProcess, error) + Update(existing *ExternalHandlerProcess, updates interface{}) (*ExternalHandlerProcess, error) + ById(id string) (*ExternalHandlerProcess, error) + Delete(container *ExternalHandlerProcess) error + + ActionActivate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) + + ActionCreate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) + + ActionDeactivate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) + + ActionPurge(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) + + ActionRemove(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) + + ActionRestore(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) + + ActionUpdate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error) +} + +func newExternalHandlerProcessClient(rancherClient *RancherClient) *ExternalHandlerProcessClient { + return &ExternalHandlerProcessClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalHandlerProcessClient) Create(container *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + resp := &ExternalHandlerProcess{} + err := c.rancherClient.doCreate(EXTERNAL_HANDLER_PROCESS_TYPE, container, resp) + return resp, err +} + +func (c *ExternalHandlerProcessClient) Update(existing *ExternalHandlerProcess, updates interface{}) (*ExternalHandlerProcess, error) { + resp := &ExternalHandlerProcess{} + err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_PROCESS_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalHandlerProcessClient) List(opts *ListOpts) (*ExternalHandlerProcessCollection, error) { + resp := &ExternalHandlerProcessCollection{} + err := c.rancherClient.doList(EXTERNAL_HANDLER_PROCESS_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalHandlerProcessClient) ById(id string) (*ExternalHandlerProcess, error) { + resp := &ExternalHandlerProcess{} + err := c.rancherClient.doById(EXTERNAL_HANDLER_PROCESS_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalHandlerProcessClient) Delete(container *ExternalHandlerProcess) error { + return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_PROCESS_TYPE, &container.Resource) +} + +func (c *ExternalHandlerProcessClient) ActionActivate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerProcessClient) ActionCreate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerProcessClient) ActionDeactivate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerProcessClient) ActionPurge(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerProcessClient) ActionRemove(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerProcessClient) ActionRestore(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHandlerProcessClient) ActionUpdate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) { + + resp := &ExternalHandlerProcess{} + + err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_handler_process_config.go b/vendor/github.com/rancher/go-rancher/client/generated_external_handler_process_config.go new file mode 100644 index 00000000..de0d49eb --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_handler_process_config.go @@ -0,0 +1,69 @@ +package client + +const ( + EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE = "externalHandlerProcessConfig" +) + +type ExternalHandlerProcessConfig struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + OnError string `json:"onError,omitempty" yaml:"on_error,omitempty"` +} + +type ExternalHandlerProcessConfigCollection struct { + Collection + Data []ExternalHandlerProcessConfig `json:"data,omitempty"` +} + +type ExternalHandlerProcessConfigClient struct { + rancherClient *RancherClient +} + +type ExternalHandlerProcessConfigOperations interface { + List(opts *ListOpts) (*ExternalHandlerProcessConfigCollection, error) + Create(opts *ExternalHandlerProcessConfig) (*ExternalHandlerProcessConfig, error) + Update(existing *ExternalHandlerProcessConfig, updates interface{}) (*ExternalHandlerProcessConfig, error) + ById(id string) (*ExternalHandlerProcessConfig, error) + Delete(container *ExternalHandlerProcessConfig) error +} + +func newExternalHandlerProcessConfigClient(rancherClient *RancherClient) *ExternalHandlerProcessConfigClient { + return &ExternalHandlerProcessConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalHandlerProcessConfigClient) Create(container *ExternalHandlerProcessConfig) (*ExternalHandlerProcessConfig, error) { + resp := &ExternalHandlerProcessConfig{} + err := c.rancherClient.doCreate(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *ExternalHandlerProcessConfigClient) Update(existing *ExternalHandlerProcessConfig, updates interface{}) (*ExternalHandlerProcessConfig, error) { + resp := &ExternalHandlerProcessConfig{} + err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalHandlerProcessConfigClient) List(opts *ListOpts) (*ExternalHandlerProcessConfigCollection, error) { + resp := &ExternalHandlerProcessConfigCollection{} + err := c.rancherClient.doList(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalHandlerProcessConfigClient) ById(id string) (*ExternalHandlerProcessConfig, error) { + resp := &ExternalHandlerProcessConfig{} + err := c.rancherClient.doById(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalHandlerProcessConfigClient) Delete(container *ExternalHandlerProcessConfig) error { + return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_host_event.go b/vendor/github.com/rancher/go-rancher/client/generated_external_host_event.go new file mode 100644 index 00000000..ae8ec14c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_host_event.go @@ -0,0 +1,117 @@ +package client + +const ( + EXTERNAL_HOST_EVENT_TYPE = "externalHostEvent" +) + +type ExternalHostEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DeleteHost bool `json:"deleteHost,omitempty" yaml:"delete_host,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + + HostLabel string `json:"hostLabel,omitempty" yaml:"host_label,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalHostEventCollection struct { + Collection + Data []ExternalHostEvent `json:"data,omitempty"` +} + +type ExternalHostEventClient struct { + rancherClient *RancherClient +} + +type ExternalHostEventOperations interface { + List(opts *ListOpts) (*ExternalHostEventCollection, error) + Create(opts *ExternalHostEvent) (*ExternalHostEvent, error) + Update(existing *ExternalHostEvent, updates interface{}) (*ExternalHostEvent, error) + ById(id string) (*ExternalHostEvent, error) + Delete(container *ExternalHostEvent) error + + ActionCreate(*ExternalHostEvent) (*ExternalEvent, error) + + ActionRemove(*ExternalHostEvent) (*ExternalEvent, error) +} + +func newExternalHostEventClient(rancherClient *RancherClient) *ExternalHostEventClient { + return &ExternalHostEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalHostEventClient) Create(container *ExternalHostEvent) (*ExternalHostEvent, error) { + resp := &ExternalHostEvent{} + err := c.rancherClient.doCreate(EXTERNAL_HOST_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ExternalHostEventClient) Update(existing *ExternalHostEvent, updates interface{}) (*ExternalHostEvent, error) { + resp := &ExternalHostEvent{} + err := c.rancherClient.doUpdate(EXTERNAL_HOST_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalHostEventClient) List(opts *ListOpts) (*ExternalHostEventCollection, error) { + resp := &ExternalHostEventCollection{} + err := c.rancherClient.doList(EXTERNAL_HOST_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalHostEventClient) ById(id string) (*ExternalHostEvent, error) { + resp := &ExternalHostEvent{} + err := c.rancherClient.doById(EXTERNAL_HOST_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalHostEventClient) Delete(container *ExternalHostEvent) error { + return c.rancherClient.doResourceDelete(EXTERNAL_HOST_EVENT_TYPE, &container.Resource) +} + +func (c *ExternalHostEventClient) ActionCreate(resource *ExternalHostEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_HOST_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalHostEventClient) ActionRemove(resource *ExternalHostEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_HOST_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_service.go b/vendor/github.com/rancher/go-rancher/client/generated_external_service.go new file mode 100644 index 00000000..411bde8a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_service.go @@ -0,0 +1,263 @@ +package client + +const ( + EXTERNAL_SERVICE_TYPE = "externalService" +) + +type ExternalService struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExternalIpAddresses []string `json:"externalIpAddresses,omitempty" yaml:"external_ip_addresses,omitempty"` + + Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + + HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` + + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalServiceCollection struct { + Collection + Data []ExternalService `json:"data,omitempty"` +} + +type ExternalServiceClient struct { + rancherClient *RancherClient +} + +type ExternalServiceOperations interface { + List(opts *ListOpts) (*ExternalServiceCollection, error) + Create(opts *ExternalService) (*ExternalService, error) + Update(existing *ExternalService, updates interface{}) (*ExternalService, error) + ById(id string) (*ExternalService, error) + Delete(container *ExternalService) error + + ActionActivate(*ExternalService) (*Service, error) + + ActionAddservicelink(*ExternalService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionCancelrollback(*ExternalService) (*Service, error) + + ActionCancelupgrade(*ExternalService) (*Service, error) + + ActionCreate(*ExternalService) (*Service, error) + + ActionDeactivate(*ExternalService) (*Service, error) + + ActionFinishupgrade(*ExternalService) (*Service, error) + + ActionRemove(*ExternalService) (*Service, error) + + ActionRemoveservicelink(*ExternalService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionRestart(*ExternalService, *ServiceRestart) (*Service, error) + + ActionRollback(*ExternalService) (*Service, error) + + ActionSetservicelinks(*ExternalService, *SetServiceLinksInput) (*Service, error) + + ActionUpdate(*ExternalService) (*Service, error) + + ActionUpgrade(*ExternalService, *ServiceUpgrade) (*Service, error) +} + +func newExternalServiceClient(rancherClient *RancherClient) *ExternalServiceClient { + return &ExternalServiceClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalServiceClient) Create(container *ExternalService) (*ExternalService, error) { + resp := &ExternalService{} + err := c.rancherClient.doCreate(EXTERNAL_SERVICE_TYPE, container, resp) + return resp, err +} + +func (c *ExternalServiceClient) Update(existing *ExternalService, updates interface{}) (*ExternalService, error) { + resp := &ExternalService{} + err := c.rancherClient.doUpdate(EXTERNAL_SERVICE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalServiceClient) List(opts *ListOpts) (*ExternalServiceCollection, error) { + resp := &ExternalServiceCollection{} + err := c.rancherClient.doList(EXTERNAL_SERVICE_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalServiceClient) ById(id string) (*ExternalService, error) { + resp := &ExternalService{} + err := c.rancherClient.doById(EXTERNAL_SERVICE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalServiceClient) Delete(container *ExternalService) error { + return c.rancherClient.doResourceDelete(EXTERNAL_SERVICE_TYPE, &container.Resource) +} + +func (c *ExternalServiceClient) ActionActivate(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionAddservicelink(resource *ExternalService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionCancelrollback(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionCancelupgrade(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionCreate(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionDeactivate(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionFinishupgrade(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionRemove(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionRemoveservicelink(resource *ExternalService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionRestart(resource *ExternalService, input *ServiceRestart) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "restart", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionRollback(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionSetservicelinks(resource *ExternalService, input *SetServiceLinksInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionUpdate(resource *ExternalService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceClient) ActionUpgrade(resource *ExternalService, input *ServiceUpgrade) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_service_event.go b/vendor/github.com/rancher/go-rancher/client/generated_external_service_event.go new file mode 100644 index 00000000..1eb53a59 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_service_event.go @@ -0,0 +1,115 @@ +package client + +const ( + EXTERNAL_SERVICE_EVENT_TYPE = "externalServiceEvent" +) + +type ExternalServiceEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Environment interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"` + + Service interface{} `json:"service,omitempty" yaml:"service,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalServiceEventCollection struct { + Collection + Data []ExternalServiceEvent `json:"data,omitempty"` +} + +type ExternalServiceEventClient struct { + rancherClient *RancherClient +} + +type ExternalServiceEventOperations interface { + List(opts *ListOpts) (*ExternalServiceEventCollection, error) + Create(opts *ExternalServiceEvent) (*ExternalServiceEvent, error) + Update(existing *ExternalServiceEvent, updates interface{}) (*ExternalServiceEvent, error) + ById(id string) (*ExternalServiceEvent, error) + Delete(container *ExternalServiceEvent) error + + ActionCreate(*ExternalServiceEvent) (*ExternalEvent, error) + + ActionRemove(*ExternalServiceEvent) (*ExternalEvent, error) +} + +func newExternalServiceEventClient(rancherClient *RancherClient) *ExternalServiceEventClient { + return &ExternalServiceEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalServiceEventClient) Create(container *ExternalServiceEvent) (*ExternalServiceEvent, error) { + resp := &ExternalServiceEvent{} + err := c.rancherClient.doCreate(EXTERNAL_SERVICE_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ExternalServiceEventClient) Update(existing *ExternalServiceEvent, updates interface{}) (*ExternalServiceEvent, error) { + resp := &ExternalServiceEvent{} + err := c.rancherClient.doUpdate(EXTERNAL_SERVICE_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalServiceEventClient) List(opts *ListOpts) (*ExternalServiceEventCollection, error) { + resp := &ExternalServiceEventCollection{} + err := c.rancherClient.doList(EXTERNAL_SERVICE_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalServiceEventClient) ById(id string) (*ExternalServiceEvent, error) { + resp := &ExternalServiceEvent{} + err := c.rancherClient.doById(EXTERNAL_SERVICE_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalServiceEventClient) Delete(container *ExternalServiceEvent) error { + return c.rancherClient.doResourceDelete(EXTERNAL_SERVICE_EVENT_TYPE, &container.Resource) +} + +func (c *ExternalServiceEventClient) ActionCreate(resource *ExternalServiceEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalServiceEventClient) ActionRemove(resource *ExternalServiceEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_SERVICE_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_storage_pool_event.go b/vendor/github.com/rancher/go-rancher/client/generated_external_storage_pool_event.go new file mode 100644 index 00000000..21d4ef36 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_storage_pool_event.go @@ -0,0 +1,115 @@ +package client + +const ( + EXTERNAL_STORAGE_POOL_EVENT_TYPE = "externalStoragePoolEvent" +) + +type ExternalStoragePoolEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + HostUuids []string `json:"hostUuids,omitempty" yaml:"host_uuids,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + StoragePool StoragePool `json:"storagePool,omitempty" yaml:"storage_pool,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ExternalStoragePoolEventCollection struct { + Collection + Data []ExternalStoragePoolEvent `json:"data,omitempty"` +} + +type ExternalStoragePoolEventClient struct { + rancherClient *RancherClient +} + +type ExternalStoragePoolEventOperations interface { + List(opts *ListOpts) (*ExternalStoragePoolEventCollection, error) + Create(opts *ExternalStoragePoolEvent) (*ExternalStoragePoolEvent, error) + Update(existing *ExternalStoragePoolEvent, updates interface{}) (*ExternalStoragePoolEvent, error) + ById(id string) (*ExternalStoragePoolEvent, error) + Delete(container *ExternalStoragePoolEvent) error + + ActionCreate(*ExternalStoragePoolEvent) (*ExternalEvent, error) + + ActionRemove(*ExternalStoragePoolEvent) (*ExternalEvent, error) +} + +func newExternalStoragePoolEventClient(rancherClient *RancherClient) *ExternalStoragePoolEventClient { + return &ExternalStoragePoolEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalStoragePoolEventClient) Create(container *ExternalStoragePoolEvent) (*ExternalStoragePoolEvent, error) { + resp := &ExternalStoragePoolEvent{} + err := c.rancherClient.doCreate(EXTERNAL_STORAGE_POOL_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ExternalStoragePoolEventClient) Update(existing *ExternalStoragePoolEvent, updates interface{}) (*ExternalStoragePoolEvent, error) { + resp := &ExternalStoragePoolEvent{} + err := c.rancherClient.doUpdate(EXTERNAL_STORAGE_POOL_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalStoragePoolEventClient) List(opts *ListOpts) (*ExternalStoragePoolEventCollection, error) { + resp := &ExternalStoragePoolEventCollection{} + err := c.rancherClient.doList(EXTERNAL_STORAGE_POOL_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalStoragePoolEventClient) ById(id string) (*ExternalStoragePoolEvent, error) { + resp := &ExternalStoragePoolEvent{} + err := c.rancherClient.doById(EXTERNAL_STORAGE_POOL_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalStoragePoolEventClient) Delete(container *ExternalStoragePoolEvent) error { + return c.rancherClient.doResourceDelete(EXTERNAL_STORAGE_POOL_EVENT_TYPE, &container.Resource) +} + +func (c *ExternalStoragePoolEventClient) ActionCreate(resource *ExternalStoragePoolEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_STORAGE_POOL_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalStoragePoolEventClient) ActionRemove(resource *ExternalStoragePoolEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_STORAGE_POOL_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_external_volume_event.go b/vendor/github.com/rancher/go-rancher/client/generated_external_volume_event.go new file mode 100644 index 00000000..2c1fae7d --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_external_volume_event.go @@ -0,0 +1,113 @@ +package client + +const ( + EXTERNAL_VOLUME_EVENT_TYPE = "externalVolumeEvent" +) + +type ExternalVolumeEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Volume Volume `json:"volume,omitempty" yaml:"volume,omitempty"` +} + +type ExternalVolumeEventCollection struct { + Collection + Data []ExternalVolumeEvent `json:"data,omitempty"` +} + +type ExternalVolumeEventClient struct { + rancherClient *RancherClient +} + +type ExternalVolumeEventOperations interface { + List(opts *ListOpts) (*ExternalVolumeEventCollection, error) + Create(opts *ExternalVolumeEvent) (*ExternalVolumeEvent, error) + Update(existing *ExternalVolumeEvent, updates interface{}) (*ExternalVolumeEvent, error) + ById(id string) (*ExternalVolumeEvent, error) + Delete(container *ExternalVolumeEvent) error + + ActionCreate(*ExternalVolumeEvent) (*ExternalEvent, error) + + ActionRemove(*ExternalVolumeEvent) (*ExternalEvent, error) +} + +func newExternalVolumeEventClient(rancherClient *RancherClient) *ExternalVolumeEventClient { + return &ExternalVolumeEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ExternalVolumeEventClient) Create(container *ExternalVolumeEvent) (*ExternalVolumeEvent, error) { + resp := &ExternalVolumeEvent{} + err := c.rancherClient.doCreate(EXTERNAL_VOLUME_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ExternalVolumeEventClient) Update(existing *ExternalVolumeEvent, updates interface{}) (*ExternalVolumeEvent, error) { + resp := &ExternalVolumeEvent{} + err := c.rancherClient.doUpdate(EXTERNAL_VOLUME_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ExternalVolumeEventClient) List(opts *ListOpts) (*ExternalVolumeEventCollection, error) { + resp := &ExternalVolumeEventCollection{} + err := c.rancherClient.doList(EXTERNAL_VOLUME_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ExternalVolumeEventClient) ById(id string) (*ExternalVolumeEvent, error) { + resp := &ExternalVolumeEvent{} + err := c.rancherClient.doById(EXTERNAL_VOLUME_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ExternalVolumeEventClient) Delete(container *ExternalVolumeEvent) error { + return c.rancherClient.doResourceDelete(EXTERNAL_VOLUME_EVENT_TYPE, &container.Resource) +} + +func (c *ExternalVolumeEventClient) ActionCreate(resource *ExternalVolumeEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_VOLUME_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ExternalVolumeEventClient) ActionRemove(resource *ExternalVolumeEvent) (*ExternalEvent, error) { + + resp := &ExternalEvent{} + + err := c.rancherClient.doAction(EXTERNAL_VOLUME_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_field_documentation.go b/vendor/github.com/rancher/go-rancher/client/generated_field_documentation.go new file mode 100644 index 00000000..035ac23f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_field_documentation.go @@ -0,0 +1,67 @@ +package client + +const ( + FIELD_DOCUMENTATION_TYPE = "fieldDocumentation" +) + +type FieldDocumentation struct { + Resource + + Description string `json:"description,omitempty" yaml:"description,omitempty"` +} + +type FieldDocumentationCollection struct { + Collection + Data []FieldDocumentation `json:"data,omitempty"` +} + +type FieldDocumentationClient struct { + rancherClient *RancherClient +} + +type FieldDocumentationOperations interface { + List(opts *ListOpts) (*FieldDocumentationCollection, error) + Create(opts *FieldDocumentation) (*FieldDocumentation, error) + Update(existing *FieldDocumentation, updates interface{}) (*FieldDocumentation, error) + ById(id string) (*FieldDocumentation, error) + Delete(container *FieldDocumentation) error +} + +func newFieldDocumentationClient(rancherClient *RancherClient) *FieldDocumentationClient { + return &FieldDocumentationClient{ + rancherClient: rancherClient, + } +} + +func (c *FieldDocumentationClient) Create(container *FieldDocumentation) (*FieldDocumentation, error) { + resp := &FieldDocumentation{} + err := c.rancherClient.doCreate(FIELD_DOCUMENTATION_TYPE, container, resp) + return resp, err +} + +func (c *FieldDocumentationClient) Update(existing *FieldDocumentation, updates interface{}) (*FieldDocumentation, error) { + resp := &FieldDocumentation{} + err := c.rancherClient.doUpdate(FIELD_DOCUMENTATION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *FieldDocumentationClient) List(opts *ListOpts) (*FieldDocumentationCollection, error) { + resp := &FieldDocumentationCollection{} + err := c.rancherClient.doList(FIELD_DOCUMENTATION_TYPE, opts, resp) + return resp, err +} + +func (c *FieldDocumentationClient) ById(id string) (*FieldDocumentation, error) { + resp := &FieldDocumentation{} + err := c.rancherClient.doById(FIELD_DOCUMENTATION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *FieldDocumentationClient) Delete(container *FieldDocumentation) error { + return c.rancherClient.doResourceDelete(FIELD_DOCUMENTATION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_githubconfig.go b/vendor/github.com/rancher/go-rancher/client/generated_githubconfig.go new file mode 100644 index 00000000..cafb4334 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_githubconfig.go @@ -0,0 +1,81 @@ +package client + +const ( + GITHUBCONFIG_TYPE = "githubconfig" +) + +type Githubconfig struct { + Resource + + AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"` + + AllowedIdentities []interface{} `json:"allowedIdentities,omitempty" yaml:"allowed_identities,omitempty"` + + ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"` + + ClientSecret string `json:"clientSecret,omitempty" yaml:"client_secret,omitempty"` + + Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` +} + +type GithubconfigCollection struct { + Collection + Data []Githubconfig `json:"data,omitempty"` +} + +type GithubconfigClient struct { + rancherClient *RancherClient +} + +type GithubconfigOperations interface { + List(opts *ListOpts) (*GithubconfigCollection, error) + Create(opts *Githubconfig) (*Githubconfig, error) + Update(existing *Githubconfig, updates interface{}) (*Githubconfig, error) + ById(id string) (*Githubconfig, error) + Delete(container *Githubconfig) error +} + +func newGithubconfigClient(rancherClient *RancherClient) *GithubconfigClient { + return &GithubconfigClient{ + rancherClient: rancherClient, + } +} + +func (c *GithubconfigClient) Create(container *Githubconfig) (*Githubconfig, error) { + resp := &Githubconfig{} + err := c.rancherClient.doCreate(GITHUBCONFIG_TYPE, container, resp) + return resp, err +} + +func (c *GithubconfigClient) Update(existing *Githubconfig, updates interface{}) (*Githubconfig, error) { + resp := &Githubconfig{} + err := c.rancherClient.doUpdate(GITHUBCONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *GithubconfigClient) List(opts *ListOpts) (*GithubconfigCollection, error) { + resp := &GithubconfigCollection{} + err := c.rancherClient.doList(GITHUBCONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *GithubconfigClient) ById(id string) (*Githubconfig, error) { + resp := &Githubconfig{} + err := c.rancherClient.doById(GITHUBCONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *GithubconfigClient) Delete(container *Githubconfig) error { + return c.rancherClient.doResourceDelete(GITHUBCONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer.go b/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer.go new file mode 100644 index 00000000..881b13fd --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer.go @@ -0,0 +1,139 @@ +package client + +const ( + GLOBAL_LOAD_BALANCER_TYPE = "globalLoadBalancer" +) + +type GlobalLoadBalancer struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + GlobalLoadBalancerHealthCheck []interface{} `json:"globalLoadBalancerHealthCheck,omitempty" yaml:"global_load_balancer_health_check,omitempty"` + + GlobalLoadBalancerPolicy []interface{} `json:"globalLoadBalancerPolicy,omitempty" yaml:"global_load_balancer_policy,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type GlobalLoadBalancerCollection struct { + Collection + Data []GlobalLoadBalancer `json:"data,omitempty"` +} + +type GlobalLoadBalancerClient struct { + rancherClient *RancherClient +} + +type GlobalLoadBalancerOperations interface { + List(opts *ListOpts) (*GlobalLoadBalancerCollection, error) + Create(opts *GlobalLoadBalancer) (*GlobalLoadBalancer, error) + Update(existing *GlobalLoadBalancer, updates interface{}) (*GlobalLoadBalancer, error) + ById(id string) (*GlobalLoadBalancer, error) + Delete(container *GlobalLoadBalancer) error + + ActionAddloadbalancer(*GlobalLoadBalancer, *AddLoadBalancerInput) (*GlobalLoadBalancer, error) + + ActionCreate(*GlobalLoadBalancer) (*GlobalLoadBalancer, error) + + ActionRemove(*GlobalLoadBalancer) (*GlobalLoadBalancer, error) + + ActionRemoveloadbalancer(*GlobalLoadBalancer, *RemoveLoadBalancerInput) (*GlobalLoadBalancer, error) +} + +func newGlobalLoadBalancerClient(rancherClient *RancherClient) *GlobalLoadBalancerClient { + return &GlobalLoadBalancerClient{ + rancherClient: rancherClient, + } +} + +func (c *GlobalLoadBalancerClient) Create(container *GlobalLoadBalancer) (*GlobalLoadBalancer, error) { + resp := &GlobalLoadBalancer{} + err := c.rancherClient.doCreate(GLOBAL_LOAD_BALANCER_TYPE, container, resp) + return resp, err +} + +func (c *GlobalLoadBalancerClient) Update(existing *GlobalLoadBalancer, updates interface{}) (*GlobalLoadBalancer, error) { + resp := &GlobalLoadBalancer{} + err := c.rancherClient.doUpdate(GLOBAL_LOAD_BALANCER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *GlobalLoadBalancerClient) List(opts *ListOpts) (*GlobalLoadBalancerCollection, error) { + resp := &GlobalLoadBalancerCollection{} + err := c.rancherClient.doList(GLOBAL_LOAD_BALANCER_TYPE, opts, resp) + return resp, err +} + +func (c *GlobalLoadBalancerClient) ById(id string) (*GlobalLoadBalancer, error) { + resp := &GlobalLoadBalancer{} + err := c.rancherClient.doById(GLOBAL_LOAD_BALANCER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *GlobalLoadBalancerClient) Delete(container *GlobalLoadBalancer) error { + return c.rancherClient.doResourceDelete(GLOBAL_LOAD_BALANCER_TYPE, &container.Resource) +} + +func (c *GlobalLoadBalancerClient) ActionAddloadbalancer(resource *GlobalLoadBalancer, input *AddLoadBalancerInput) (*GlobalLoadBalancer, error) { + + resp := &GlobalLoadBalancer{} + + err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "addloadbalancer", &resource.Resource, input, resp) + + return resp, err +} + +func (c *GlobalLoadBalancerClient) ActionCreate(resource *GlobalLoadBalancer) (*GlobalLoadBalancer, error) { + + resp := &GlobalLoadBalancer{} + + err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *GlobalLoadBalancerClient) ActionRemove(resource *GlobalLoadBalancer) (*GlobalLoadBalancer, error) { + + resp := &GlobalLoadBalancer{} + + err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *GlobalLoadBalancerClient) ActionRemoveloadbalancer(resource *GlobalLoadBalancer, input *RemoveLoadBalancerInput) (*GlobalLoadBalancer, error) { + + resp := &GlobalLoadBalancer{} + + err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "removeloadbalancer", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_health_check.go b/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_health_check.go new file mode 100644 index 00000000..a461de95 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_health_check.go @@ -0,0 +1,67 @@ +package client + +const ( + GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE = "globalLoadBalancerHealthCheck" +) + +type GlobalLoadBalancerHealthCheck struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` +} + +type GlobalLoadBalancerHealthCheckCollection struct { + Collection + Data []GlobalLoadBalancerHealthCheck `json:"data,omitempty"` +} + +type GlobalLoadBalancerHealthCheckClient struct { + rancherClient *RancherClient +} + +type GlobalLoadBalancerHealthCheckOperations interface { + List(opts *ListOpts) (*GlobalLoadBalancerHealthCheckCollection, error) + Create(opts *GlobalLoadBalancerHealthCheck) (*GlobalLoadBalancerHealthCheck, error) + Update(existing *GlobalLoadBalancerHealthCheck, updates interface{}) (*GlobalLoadBalancerHealthCheck, error) + ById(id string) (*GlobalLoadBalancerHealthCheck, error) + Delete(container *GlobalLoadBalancerHealthCheck) error +} + +func newGlobalLoadBalancerHealthCheckClient(rancherClient *RancherClient) *GlobalLoadBalancerHealthCheckClient { + return &GlobalLoadBalancerHealthCheckClient{ + rancherClient: rancherClient, + } +} + +func (c *GlobalLoadBalancerHealthCheckClient) Create(container *GlobalLoadBalancerHealthCheck) (*GlobalLoadBalancerHealthCheck, error) { + resp := &GlobalLoadBalancerHealthCheck{} + err := c.rancherClient.doCreate(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, container, resp) + return resp, err +} + +func (c *GlobalLoadBalancerHealthCheckClient) Update(existing *GlobalLoadBalancerHealthCheck, updates interface{}) (*GlobalLoadBalancerHealthCheck, error) { + resp := &GlobalLoadBalancerHealthCheck{} + err := c.rancherClient.doUpdate(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *GlobalLoadBalancerHealthCheckClient) List(opts *ListOpts) (*GlobalLoadBalancerHealthCheckCollection, error) { + resp := &GlobalLoadBalancerHealthCheckCollection{} + err := c.rancherClient.doList(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, opts, resp) + return resp, err +} + +func (c *GlobalLoadBalancerHealthCheckClient) ById(id string) (*GlobalLoadBalancerHealthCheck, error) { + resp := &GlobalLoadBalancerHealthCheck{} + err := c.rancherClient.doById(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *GlobalLoadBalancerHealthCheckClient) Delete(container *GlobalLoadBalancerHealthCheck) error { + return c.rancherClient.doResourceDelete(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_policy.go b/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_policy.go new file mode 100644 index 00000000..e6089064 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_global_load_balancer_policy.go @@ -0,0 +1,67 @@ +package client + +const ( + GLOBAL_LOAD_BALANCER_POLICY_TYPE = "globalLoadBalancerPolicy" +) + +type GlobalLoadBalancerPolicy struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` +} + +type GlobalLoadBalancerPolicyCollection struct { + Collection + Data []GlobalLoadBalancerPolicy `json:"data,omitempty"` +} + +type GlobalLoadBalancerPolicyClient struct { + rancherClient *RancherClient +} + +type GlobalLoadBalancerPolicyOperations interface { + List(opts *ListOpts) (*GlobalLoadBalancerPolicyCollection, error) + Create(opts *GlobalLoadBalancerPolicy) (*GlobalLoadBalancerPolicy, error) + Update(existing *GlobalLoadBalancerPolicy, updates interface{}) (*GlobalLoadBalancerPolicy, error) + ById(id string) (*GlobalLoadBalancerPolicy, error) + Delete(container *GlobalLoadBalancerPolicy) error +} + +func newGlobalLoadBalancerPolicyClient(rancherClient *RancherClient) *GlobalLoadBalancerPolicyClient { + return &GlobalLoadBalancerPolicyClient{ + rancherClient: rancherClient, + } +} + +func (c *GlobalLoadBalancerPolicyClient) Create(container *GlobalLoadBalancerPolicy) (*GlobalLoadBalancerPolicy, error) { + resp := &GlobalLoadBalancerPolicy{} + err := c.rancherClient.doCreate(GLOBAL_LOAD_BALANCER_POLICY_TYPE, container, resp) + return resp, err +} + +func (c *GlobalLoadBalancerPolicyClient) Update(existing *GlobalLoadBalancerPolicy, updates interface{}) (*GlobalLoadBalancerPolicy, error) { + resp := &GlobalLoadBalancerPolicy{} + err := c.rancherClient.doUpdate(GLOBAL_LOAD_BALANCER_POLICY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *GlobalLoadBalancerPolicyClient) List(opts *ListOpts) (*GlobalLoadBalancerPolicyCollection, error) { + resp := &GlobalLoadBalancerPolicyCollection{} + err := c.rancherClient.doList(GLOBAL_LOAD_BALANCER_POLICY_TYPE, opts, resp) + return resp, err +} + +func (c *GlobalLoadBalancerPolicyClient) ById(id string) (*GlobalLoadBalancerPolicy, error) { + resp := &GlobalLoadBalancerPolicy{} + err := c.rancherClient.doById(GLOBAL_LOAD_BALANCER_POLICY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *GlobalLoadBalancerPolicyClient) Delete(container *GlobalLoadBalancerPolicy) error { + return c.rancherClient.doResourceDelete(GLOBAL_LOAD_BALANCER_POLICY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_haproxy_config.go b/vendor/github.com/rancher/go-rancher/client/generated_haproxy_config.go new file mode 100644 index 00000000..a1e27bcd --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_haproxy_config.go @@ -0,0 +1,69 @@ +package client + +const ( + HAPROXY_CONFIG_TYPE = "haproxyConfig" +) + +type HaproxyConfig struct { + Resource + + Defaults string `json:"defaults,omitempty" yaml:"defaults,omitempty"` + + Global string `json:"global,omitempty" yaml:"global,omitempty"` +} + +type HaproxyConfigCollection struct { + Collection + Data []HaproxyConfig `json:"data,omitempty"` +} + +type HaproxyConfigClient struct { + rancherClient *RancherClient +} + +type HaproxyConfigOperations interface { + List(opts *ListOpts) (*HaproxyConfigCollection, error) + Create(opts *HaproxyConfig) (*HaproxyConfig, error) + Update(existing *HaproxyConfig, updates interface{}) (*HaproxyConfig, error) + ById(id string) (*HaproxyConfig, error) + Delete(container *HaproxyConfig) error +} + +func newHaproxyConfigClient(rancherClient *RancherClient) *HaproxyConfigClient { + return &HaproxyConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *HaproxyConfigClient) Create(container *HaproxyConfig) (*HaproxyConfig, error) { + resp := &HaproxyConfig{} + err := c.rancherClient.doCreate(HAPROXY_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *HaproxyConfigClient) Update(existing *HaproxyConfig, updates interface{}) (*HaproxyConfig, error) { + resp := &HaproxyConfig{} + err := c.rancherClient.doUpdate(HAPROXY_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *HaproxyConfigClient) List(opts *ListOpts) (*HaproxyConfigCollection, error) { + resp := &HaproxyConfigCollection{} + err := c.rancherClient.doList(HAPROXY_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *HaproxyConfigClient) ById(id string) (*HaproxyConfig, error) { + resp := &HaproxyConfig{} + err := c.rancherClient.doById(HAPROXY_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *HaproxyConfigClient) Delete(container *HaproxyConfig) error { + return c.rancherClient.doResourceDelete(HAPROXY_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_healthcheck_instance_host_map.go b/vendor/github.com/rancher/go-rancher/client/generated_healthcheck_instance_host_map.go new file mode 100644 index 00000000..6329d2f8 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_healthcheck_instance_host_map.go @@ -0,0 +1,119 @@ +package client + +const ( + HEALTHCHECK_INSTANCE_HOST_MAP_TYPE = "healthcheckInstanceHostMap" +) + +type HealthcheckInstanceHostMap struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type HealthcheckInstanceHostMapCollection struct { + Collection + Data []HealthcheckInstanceHostMap `json:"data,omitempty"` +} + +type HealthcheckInstanceHostMapClient struct { + rancherClient *RancherClient +} + +type HealthcheckInstanceHostMapOperations interface { + List(opts *ListOpts) (*HealthcheckInstanceHostMapCollection, error) + Create(opts *HealthcheckInstanceHostMap) (*HealthcheckInstanceHostMap, error) + Update(existing *HealthcheckInstanceHostMap, updates interface{}) (*HealthcheckInstanceHostMap, error) + ById(id string) (*HealthcheckInstanceHostMap, error) + Delete(container *HealthcheckInstanceHostMap) error + + ActionCreate(*HealthcheckInstanceHostMap) (*HealthcheckInstanceHostMap, error) + + ActionRemove(*HealthcheckInstanceHostMap) (*HealthcheckInstanceHostMap, error) +} + +func newHealthcheckInstanceHostMapClient(rancherClient *RancherClient) *HealthcheckInstanceHostMapClient { + return &HealthcheckInstanceHostMapClient{ + rancherClient: rancherClient, + } +} + +func (c *HealthcheckInstanceHostMapClient) Create(container *HealthcheckInstanceHostMap) (*HealthcheckInstanceHostMap, error) { + resp := &HealthcheckInstanceHostMap{} + err := c.rancherClient.doCreate(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, container, resp) + return resp, err +} + +func (c *HealthcheckInstanceHostMapClient) Update(existing *HealthcheckInstanceHostMap, updates interface{}) (*HealthcheckInstanceHostMap, error) { + resp := &HealthcheckInstanceHostMap{} + err := c.rancherClient.doUpdate(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *HealthcheckInstanceHostMapClient) List(opts *ListOpts) (*HealthcheckInstanceHostMapCollection, error) { + resp := &HealthcheckInstanceHostMapCollection{} + err := c.rancherClient.doList(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, opts, resp) + return resp, err +} + +func (c *HealthcheckInstanceHostMapClient) ById(id string) (*HealthcheckInstanceHostMap, error) { + resp := &HealthcheckInstanceHostMap{} + err := c.rancherClient.doById(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *HealthcheckInstanceHostMapClient) Delete(container *HealthcheckInstanceHostMap) error { + return c.rancherClient.doResourceDelete(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, &container.Resource) +} + +func (c *HealthcheckInstanceHostMapClient) ActionCreate(resource *HealthcheckInstanceHostMap) (*HealthcheckInstanceHostMap, error) { + + resp := &HealthcheckInstanceHostMap{} + + err := c.rancherClient.doAction(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HealthcheckInstanceHostMapClient) ActionRemove(resource *HealthcheckInstanceHostMap) (*HealthcheckInstanceHostMap, error) { + + resp := &HealthcheckInstanceHostMap{} + + err := c.rancherClient.doAction(HEALTHCHECK_INSTANCE_HOST_MAP_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_host.go b/vendor/github.com/rancher/go-rancher/client/generated_host.go new file mode 100644 index 00000000..f1ee9436 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_host.go @@ -0,0 +1,197 @@ +package client + +const ( + HOST_TYPE = "host" +) + +type Host struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AgentState string `json:"agentState,omitempty" yaml:"agent_state,omitempty"` + + ApiProxy string `json:"apiProxy,omitempty" yaml:"api_proxy,omitempty"` + + ComputeTotal int64 `json:"computeTotal,omitempty" yaml:"compute_total,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + Info interface{} `json:"info,omitempty" yaml:"info,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PhysicalHostId string `json:"physicalHostId,omitempty" yaml:"physical_host_id,omitempty"` + + PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type HostCollection struct { + Collection + Data []Host `json:"data,omitempty"` +} + +type HostClient struct { + rancherClient *RancherClient +} + +type HostOperations interface { + List(opts *ListOpts) (*HostCollection, error) + Create(opts *Host) (*Host, error) + Update(existing *Host, updates interface{}) (*Host, error) + ById(id string) (*Host, error) + Delete(container *Host) error + + ActionActivate(*Host) (*Host, error) + + ActionCreate(*Host) (*Host, error) + + ActionDeactivate(*Host) (*Host, error) + + ActionDockersocket(*Host) (*HostAccess, error) + + ActionPurge(*Host) (*Host, error) + + ActionRemove(*Host) (*Host, error) + + ActionRestore(*Host) (*Host, error) + + ActionUpdate(*Host) (*Host, error) +} + +func newHostClient(rancherClient *RancherClient) *HostClient { + return &HostClient{ + rancherClient: rancherClient, + } +} + +func (c *HostClient) Create(container *Host) (*Host, error) { + resp := &Host{} + err := c.rancherClient.doCreate(HOST_TYPE, container, resp) + return resp, err +} + +func (c *HostClient) Update(existing *Host, updates interface{}) (*Host, error) { + resp := &Host{} + err := c.rancherClient.doUpdate(HOST_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *HostClient) List(opts *ListOpts) (*HostCollection, error) { + resp := &HostCollection{} + err := c.rancherClient.doList(HOST_TYPE, opts, resp) + return resp, err +} + +func (c *HostClient) ById(id string) (*Host, error) { + resp := &Host{} + err := c.rancherClient.doById(HOST_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *HostClient) Delete(container *Host) error { + return c.rancherClient.doResourceDelete(HOST_TYPE, &container.Resource) +} + +func (c *HostClient) ActionActivate(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionCreate(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionDeactivate(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionDockersocket(resource *Host) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(HOST_TYPE, "dockersocket", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionPurge(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionRemove(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionRestore(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *HostClient) ActionUpdate(resource *Host) (*Host, error) { + + resp := &Host{} + + err := c.rancherClient.doAction(HOST_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_host_access.go b/vendor/github.com/rancher/go-rancher/client/generated_host_access.go new file mode 100644 index 00000000..ee4ab399 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_host_access.go @@ -0,0 +1,69 @@ +package client + +const ( + HOST_ACCESS_TYPE = "hostAccess" +) + +type HostAccess struct { + Resource + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Url string `json:"url,omitempty" yaml:"url,omitempty"` +} + +type HostAccessCollection struct { + Collection + Data []HostAccess `json:"data,omitempty"` +} + +type HostAccessClient struct { + rancherClient *RancherClient +} + +type HostAccessOperations interface { + List(opts *ListOpts) (*HostAccessCollection, error) + Create(opts *HostAccess) (*HostAccess, error) + Update(existing *HostAccess, updates interface{}) (*HostAccess, error) + ById(id string) (*HostAccess, error) + Delete(container *HostAccess) error +} + +func newHostAccessClient(rancherClient *RancherClient) *HostAccessClient { + return &HostAccessClient{ + rancherClient: rancherClient, + } +} + +func (c *HostAccessClient) Create(container *HostAccess) (*HostAccess, error) { + resp := &HostAccess{} + err := c.rancherClient.doCreate(HOST_ACCESS_TYPE, container, resp) + return resp, err +} + +func (c *HostAccessClient) Update(existing *HostAccess, updates interface{}) (*HostAccess, error) { + resp := &HostAccess{} + err := c.rancherClient.doUpdate(HOST_ACCESS_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *HostAccessClient) List(opts *ListOpts) (*HostAccessCollection, error) { + resp := &HostAccessCollection{} + err := c.rancherClient.doList(HOST_ACCESS_TYPE, opts, resp) + return resp, err +} + +func (c *HostAccessClient) ById(id string) (*HostAccess, error) { + resp := &HostAccess{} + err := c.rancherClient.doById(HOST_ACCESS_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *HostAccessClient) Delete(container *HostAccess) error { + return c.rancherClient.doResourceDelete(HOST_ACCESS_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_host_api_proxy_token.go b/vendor/github.com/rancher/go-rancher/client/generated_host_api_proxy_token.go new file mode 100644 index 00000000..e4c508a2 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_host_api_proxy_token.go @@ -0,0 +1,71 @@ +package client + +const ( + HOST_API_PROXY_TOKEN_TYPE = "hostApiProxyToken" +) + +type HostApiProxyToken struct { + Resource + + ReportedUuid string `json:"reportedUuid,omitempty" yaml:"reported_uuid,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Url string `json:"url,omitempty" yaml:"url,omitempty"` +} + +type HostApiProxyTokenCollection struct { + Collection + Data []HostApiProxyToken `json:"data,omitempty"` +} + +type HostApiProxyTokenClient struct { + rancherClient *RancherClient +} + +type HostApiProxyTokenOperations interface { + List(opts *ListOpts) (*HostApiProxyTokenCollection, error) + Create(opts *HostApiProxyToken) (*HostApiProxyToken, error) + Update(existing *HostApiProxyToken, updates interface{}) (*HostApiProxyToken, error) + ById(id string) (*HostApiProxyToken, error) + Delete(container *HostApiProxyToken) error +} + +func newHostApiProxyTokenClient(rancherClient *RancherClient) *HostApiProxyTokenClient { + return &HostApiProxyTokenClient{ + rancherClient: rancherClient, + } +} + +func (c *HostApiProxyTokenClient) Create(container *HostApiProxyToken) (*HostApiProxyToken, error) { + resp := &HostApiProxyToken{} + err := c.rancherClient.doCreate(HOST_API_PROXY_TOKEN_TYPE, container, resp) + return resp, err +} + +func (c *HostApiProxyTokenClient) Update(existing *HostApiProxyToken, updates interface{}) (*HostApiProxyToken, error) { + resp := &HostApiProxyToken{} + err := c.rancherClient.doUpdate(HOST_API_PROXY_TOKEN_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *HostApiProxyTokenClient) List(opts *ListOpts) (*HostApiProxyTokenCollection, error) { + resp := &HostApiProxyTokenCollection{} + err := c.rancherClient.doList(HOST_API_PROXY_TOKEN_TYPE, opts, resp) + return resp, err +} + +func (c *HostApiProxyTokenClient) ById(id string) (*HostApiProxyToken, error) { + resp := &HostApiProxyToken{} + err := c.rancherClient.doById(HOST_API_PROXY_TOKEN_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *HostApiProxyTokenClient) Delete(container *HostApiProxyToken) error { + return c.rancherClient.doResourceDelete(HOST_API_PROXY_TOKEN_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_identity.go b/vendor/github.com/rancher/go-rancher/client/generated_identity.go new file mode 100644 index 00000000..f78f7c76 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_identity.go @@ -0,0 +1,83 @@ +package client + +const ( + IDENTITY_TYPE = "identity" +) + +type Identity struct { + Resource + + All string `json:"all,omitempty" yaml:"all,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"` + + Login string `json:"login,omitempty" yaml:"login,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + ProfilePicture string `json:"profilePicture,omitempty" yaml:"profile_picture,omitempty"` + + ProfileUrl string `json:"profileUrl,omitempty" yaml:"profile_url,omitempty"` + + ProjectId string `json:"projectId,omitempty" yaml:"project_id,omitempty"` + + Role string `json:"role,omitempty" yaml:"role,omitempty"` +} + +type IdentityCollection struct { + Collection + Data []Identity `json:"data,omitempty"` +} + +type IdentityClient struct { + rancherClient *RancherClient +} + +type IdentityOperations interface { + List(opts *ListOpts) (*IdentityCollection, error) + Create(opts *Identity) (*Identity, error) + Update(existing *Identity, updates interface{}) (*Identity, error) + ById(id string) (*Identity, error) + Delete(container *Identity) error +} + +func newIdentityClient(rancherClient *RancherClient) *IdentityClient { + return &IdentityClient{ + rancherClient: rancherClient, + } +} + +func (c *IdentityClient) Create(container *Identity) (*Identity, error) { + resp := &Identity{} + err := c.rancherClient.doCreate(IDENTITY_TYPE, container, resp) + return resp, err +} + +func (c *IdentityClient) Update(existing *Identity, updates interface{}) (*Identity, error) { + resp := &Identity{} + err := c.rancherClient.doUpdate(IDENTITY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *IdentityClient) List(opts *ListOpts) (*IdentityCollection, error) { + resp := &IdentityCollection{} + err := c.rancherClient.doList(IDENTITY_TYPE, opts, resp) + return resp, err +} + +func (c *IdentityClient) ById(id string) (*Identity, error) { + resp := &Identity{} + err := c.rancherClient.doById(IDENTITY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *IdentityClient) Delete(container *Identity) error { + return c.rancherClient.doResourceDelete(IDENTITY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_image.go b/vendor/github.com/rancher/go-rancher/client/generated_image.go new file mode 100644 index 00000000..84d1d0ff --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_image.go @@ -0,0 +1,168 @@ +package client + +const ( + IMAGE_TYPE = "image" +) + +type Image struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ImageCollection struct { + Collection + Data []Image `json:"data,omitempty"` +} + +type ImageClient struct { + rancherClient *RancherClient +} + +type ImageOperations interface { + List(opts *ListOpts) (*ImageCollection, error) + Create(opts *Image) (*Image, error) + Update(existing *Image, updates interface{}) (*Image, error) + ById(id string) (*Image, error) + Delete(container *Image) error + + ActionActivate(*Image) (*Image, error) + + ActionCreate(*Image) (*Image, error) + + ActionDeactivate(*Image) (*Image, error) + + ActionPurge(*Image) (*Image, error) + + ActionRemove(*Image) (*Image, error) + + ActionRestore(*Image) (*Image, error) + + ActionUpdate(*Image) (*Image, error) +} + +func newImageClient(rancherClient *RancherClient) *ImageClient { + return &ImageClient{ + rancherClient: rancherClient, + } +} + +func (c *ImageClient) Create(container *Image) (*Image, error) { + resp := &Image{} + err := c.rancherClient.doCreate(IMAGE_TYPE, container, resp) + return resp, err +} + +func (c *ImageClient) Update(existing *Image, updates interface{}) (*Image, error) { + resp := &Image{} + err := c.rancherClient.doUpdate(IMAGE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ImageClient) List(opts *ListOpts) (*ImageCollection, error) { + resp := &ImageCollection{} + err := c.rancherClient.doList(IMAGE_TYPE, opts, resp) + return resp, err +} + +func (c *ImageClient) ById(id string) (*Image, error) { + resp := &Image{} + err := c.rancherClient.doById(IMAGE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ImageClient) Delete(container *Image) error { + return c.rancherClient.doResourceDelete(IMAGE_TYPE, &container.Resource) +} + +func (c *ImageClient) ActionActivate(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ImageClient) ActionCreate(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ImageClient) ActionDeactivate(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ImageClient) ActionPurge(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ImageClient) ActionRemove(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ImageClient) ActionRestore(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ImageClient) ActionUpdate(resource *Image) (*Image, error) { + + resp := &Image{} + + err := c.rancherClient.doAction(IMAGE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_in_service_upgrade_strategy.go b/vendor/github.com/rancher/go-rancher/client/generated_in_service_upgrade_strategy.go new file mode 100644 index 00000000..a9288579 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_in_service_upgrade_strategy.go @@ -0,0 +1,79 @@ +package client + +const ( + IN_SERVICE_UPGRADE_STRATEGY_TYPE = "inServiceUpgradeStrategy" +) + +type InServiceUpgradeStrategy struct { + Resource + + BatchSize int64 `json:"batchSize,omitempty" yaml:"batch_size,omitempty"` + + IntervalMillis int64 `json:"intervalMillis,omitempty" yaml:"interval_millis,omitempty"` + + LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` + + PreviousLaunchConfig *LaunchConfig `json:"previousLaunchConfig,omitempty" yaml:"previous_launch_config,omitempty"` + + PreviousSecondaryLaunchConfigs []interface{} `json:"previousSecondaryLaunchConfigs,omitempty" yaml:"previous_secondary_launch_configs,omitempty"` + + SecondaryLaunchConfigs []interface{} `json:"secondaryLaunchConfigs,omitempty" yaml:"secondary_launch_configs,omitempty"` + + StartFirst bool `json:"startFirst,omitempty" yaml:"start_first,omitempty"` +} + +type InServiceUpgradeStrategyCollection struct { + Collection + Data []InServiceUpgradeStrategy `json:"data,omitempty"` +} + +type InServiceUpgradeStrategyClient struct { + rancherClient *RancherClient +} + +type InServiceUpgradeStrategyOperations interface { + List(opts *ListOpts) (*InServiceUpgradeStrategyCollection, error) + Create(opts *InServiceUpgradeStrategy) (*InServiceUpgradeStrategy, error) + Update(existing *InServiceUpgradeStrategy, updates interface{}) (*InServiceUpgradeStrategy, error) + ById(id string) (*InServiceUpgradeStrategy, error) + Delete(container *InServiceUpgradeStrategy) error +} + +func newInServiceUpgradeStrategyClient(rancherClient *RancherClient) *InServiceUpgradeStrategyClient { + return &InServiceUpgradeStrategyClient{ + rancherClient: rancherClient, + } +} + +func (c *InServiceUpgradeStrategyClient) Create(container *InServiceUpgradeStrategy) (*InServiceUpgradeStrategy, error) { + resp := &InServiceUpgradeStrategy{} + err := c.rancherClient.doCreate(IN_SERVICE_UPGRADE_STRATEGY_TYPE, container, resp) + return resp, err +} + +func (c *InServiceUpgradeStrategyClient) Update(existing *InServiceUpgradeStrategy, updates interface{}) (*InServiceUpgradeStrategy, error) { + resp := &InServiceUpgradeStrategy{} + err := c.rancherClient.doUpdate(IN_SERVICE_UPGRADE_STRATEGY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InServiceUpgradeStrategyClient) List(opts *ListOpts) (*InServiceUpgradeStrategyCollection, error) { + resp := &InServiceUpgradeStrategyCollection{} + err := c.rancherClient.doList(IN_SERVICE_UPGRADE_STRATEGY_TYPE, opts, resp) + return resp, err +} + +func (c *InServiceUpgradeStrategyClient) ById(id string) (*InServiceUpgradeStrategy, error) { + resp := &InServiceUpgradeStrategy{} + err := c.rancherClient.doById(IN_SERVICE_UPGRADE_STRATEGY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InServiceUpgradeStrategyClient) Delete(container *InServiceUpgradeStrategy) error { + return c.rancherClient.doResourceDelete(IN_SERVICE_UPGRADE_STRATEGY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_instance.go b/vendor/github.com/rancher/go-rancher/client/generated_instance.go new file mode 100644 index 00000000..6487935a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_instance.go @@ -0,0 +1,258 @@ +package client + +const ( + INSTANCE_TYPE = "instance" +) + +type Instance struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type InstanceCollection struct { + Collection + Data []Instance `json:"data,omitempty"` +} + +type InstanceClient struct { + rancherClient *RancherClient +} + +type InstanceOperations interface { + List(opts *ListOpts) (*InstanceCollection, error) + Create(opts *Instance) (*Instance, error) + Update(existing *Instance, updates interface{}) (*Instance, error) + ById(id string) (*Instance, error) + Delete(container *Instance) error + + ActionAllocate(*Instance) (*Instance, error) + + ActionConsole(*Instance, *InstanceConsoleInput) (*InstanceConsole, error) + + ActionCreate(*Instance) (*Instance, error) + + ActionDeallocate(*Instance) (*Instance, error) + + ActionMigrate(*Instance) (*Instance, error) + + ActionPurge(*Instance) (*Instance, error) + + ActionRemove(*Instance) (*Instance, error) + + ActionRestart(*Instance) (*Instance, error) + + ActionRestore(*Instance) (*Instance, error) + + ActionStart(*Instance) (*Instance, error) + + ActionStop(*Instance, *InstanceStop) (*Instance, error) + + ActionUpdate(*Instance) (*Instance, error) + + ActionUpdatehealthy(*Instance) (*Instance, error) + + ActionUpdatereinitializing(*Instance) (*Instance, error) + + ActionUpdateunhealthy(*Instance) (*Instance, error) +} + +func newInstanceClient(rancherClient *RancherClient) *InstanceClient { + return &InstanceClient{ + rancherClient: rancherClient, + } +} + +func (c *InstanceClient) Create(container *Instance) (*Instance, error) { + resp := &Instance{} + err := c.rancherClient.doCreate(INSTANCE_TYPE, container, resp) + return resp, err +} + +func (c *InstanceClient) Update(existing *Instance, updates interface{}) (*Instance, error) { + resp := &Instance{} + err := c.rancherClient.doUpdate(INSTANCE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InstanceClient) List(opts *ListOpts) (*InstanceCollection, error) { + resp := &InstanceCollection{} + err := c.rancherClient.doList(INSTANCE_TYPE, opts, resp) + return resp, err +} + +func (c *InstanceClient) ById(id string) (*Instance, error) { + resp := &Instance{} + err := c.rancherClient.doById(INSTANCE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InstanceClient) Delete(container *Instance) error { + return c.rancherClient.doResourceDelete(INSTANCE_TYPE, &container.Resource) +} + +func (c *InstanceClient) ActionAllocate(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "allocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionConsole(resource *Instance, input *InstanceConsoleInput) (*InstanceConsole, error) { + + resp := &InstanceConsole{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "console", &resource.Resource, input, resp) + + return resp, err +} + +func (c *InstanceClient) ActionCreate(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionDeallocate(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "deallocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionMigrate(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "migrate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionPurge(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionRemove(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionRestart(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "restart", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionRestore(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionStart(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "start", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionStop(resource *Instance, input *InstanceStop) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "stop", &resource.Resource, input, resp) + + return resp, err +} + +func (c *InstanceClient) ActionUpdate(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionUpdatehealthy(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "updatehealthy", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionUpdatereinitializing(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "updatereinitializing", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceClient) ActionUpdateunhealthy(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "updateunhealthy", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_instance_console.go b/vendor/github.com/rancher/go-rancher/client/generated_instance_console.go new file mode 100644 index 00000000..bf38cb4c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_instance_console.go @@ -0,0 +1,71 @@ +package client + +const ( + INSTANCE_CONSOLE_TYPE = "instanceConsole" +) + +type InstanceConsole struct { + Resource + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Password string `json:"password,omitempty" yaml:"password,omitempty"` + + Url string `json:"url,omitempty" yaml:"url,omitempty"` +} + +type InstanceConsoleCollection struct { + Collection + Data []InstanceConsole `json:"data,omitempty"` +} + +type InstanceConsoleClient struct { + rancherClient *RancherClient +} + +type InstanceConsoleOperations interface { + List(opts *ListOpts) (*InstanceConsoleCollection, error) + Create(opts *InstanceConsole) (*InstanceConsole, error) + Update(existing *InstanceConsole, updates interface{}) (*InstanceConsole, error) + ById(id string) (*InstanceConsole, error) + Delete(container *InstanceConsole) error +} + +func newInstanceConsoleClient(rancherClient *RancherClient) *InstanceConsoleClient { + return &InstanceConsoleClient{ + rancherClient: rancherClient, + } +} + +func (c *InstanceConsoleClient) Create(container *InstanceConsole) (*InstanceConsole, error) { + resp := &InstanceConsole{} + err := c.rancherClient.doCreate(INSTANCE_CONSOLE_TYPE, container, resp) + return resp, err +} + +func (c *InstanceConsoleClient) Update(existing *InstanceConsole, updates interface{}) (*InstanceConsole, error) { + resp := &InstanceConsole{} + err := c.rancherClient.doUpdate(INSTANCE_CONSOLE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InstanceConsoleClient) List(opts *ListOpts) (*InstanceConsoleCollection, error) { + resp := &InstanceConsoleCollection{} + err := c.rancherClient.doList(INSTANCE_CONSOLE_TYPE, opts, resp) + return resp, err +} + +func (c *InstanceConsoleClient) ById(id string) (*InstanceConsole, error) { + resp := &InstanceConsole{} + err := c.rancherClient.doById(INSTANCE_CONSOLE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InstanceConsoleClient) Delete(container *InstanceConsole) error { + return c.rancherClient.doResourceDelete(INSTANCE_CONSOLE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_instance_console_input.go b/vendor/github.com/rancher/go-rancher/client/generated_instance_console_input.go new file mode 100644 index 00000000..11a126f7 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_instance_console_input.go @@ -0,0 +1,65 @@ +package client + +const ( + INSTANCE_CONSOLE_INPUT_TYPE = "instanceConsoleInput" +) + +type InstanceConsoleInput struct { + Resource +} + +type InstanceConsoleInputCollection struct { + Collection + Data []InstanceConsoleInput `json:"data,omitempty"` +} + +type InstanceConsoleInputClient struct { + rancherClient *RancherClient +} + +type InstanceConsoleInputOperations interface { + List(opts *ListOpts) (*InstanceConsoleInputCollection, error) + Create(opts *InstanceConsoleInput) (*InstanceConsoleInput, error) + Update(existing *InstanceConsoleInput, updates interface{}) (*InstanceConsoleInput, error) + ById(id string) (*InstanceConsoleInput, error) + Delete(container *InstanceConsoleInput) error +} + +func newInstanceConsoleInputClient(rancherClient *RancherClient) *InstanceConsoleInputClient { + return &InstanceConsoleInputClient{ + rancherClient: rancherClient, + } +} + +func (c *InstanceConsoleInputClient) Create(container *InstanceConsoleInput) (*InstanceConsoleInput, error) { + resp := &InstanceConsoleInput{} + err := c.rancherClient.doCreate(INSTANCE_CONSOLE_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *InstanceConsoleInputClient) Update(existing *InstanceConsoleInput, updates interface{}) (*InstanceConsoleInput, error) { + resp := &InstanceConsoleInput{} + err := c.rancherClient.doUpdate(INSTANCE_CONSOLE_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InstanceConsoleInputClient) List(opts *ListOpts) (*InstanceConsoleInputCollection, error) { + resp := &InstanceConsoleInputCollection{} + err := c.rancherClient.doList(INSTANCE_CONSOLE_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *InstanceConsoleInputClient) ById(id string) (*InstanceConsoleInput, error) { + resp := &InstanceConsoleInput{} + err := c.rancherClient.doById(INSTANCE_CONSOLE_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InstanceConsoleInputClient) Delete(container *InstanceConsoleInput) error { + return c.rancherClient.doResourceDelete(INSTANCE_CONSOLE_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_instance_health_check.go b/vendor/github.com/rancher/go-rancher/client/generated_instance_health_check.go new file mode 100644 index 00000000..305798bf --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_instance_health_check.go @@ -0,0 +1,87 @@ +package client + +const ( + INSTANCE_HEALTH_CHECK_TYPE = "instanceHealthCheck" +) + +type InstanceHealthCheck struct { + Resource + + HealthyThreshold int64 `json:"healthyThreshold,omitempty" yaml:"healthy_threshold,omitempty"` + + InitializingTimeout int64 `json:"initializingTimeout,omitempty" yaml:"initializing_timeout,omitempty"` + + Interval int64 `json:"interval,omitempty" yaml:"interval,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + RecreateOnQuorumStrategyConfig *RecreateOnQuorumStrategyConfig `json:"recreateOnQuorumStrategyConfig,omitempty" yaml:"recreate_on_quorum_strategy_config,omitempty"` + + ReinitializingTimeout int64 `json:"reinitializingTimeout,omitempty" yaml:"reinitializing_timeout,omitempty"` + + RequestLine string `json:"requestLine,omitempty" yaml:"request_line,omitempty"` + + ResponseTimeout int64 `json:"responseTimeout,omitempty" yaml:"response_timeout,omitempty"` + + Strategy string `json:"strategy,omitempty" yaml:"strategy,omitempty"` + + UnhealthyThreshold int64 `json:"unhealthyThreshold,omitempty" yaml:"unhealthy_threshold,omitempty"` +} + +type InstanceHealthCheckCollection struct { + Collection + Data []InstanceHealthCheck `json:"data,omitempty"` +} + +type InstanceHealthCheckClient struct { + rancherClient *RancherClient +} + +type InstanceHealthCheckOperations interface { + List(opts *ListOpts) (*InstanceHealthCheckCollection, error) + Create(opts *InstanceHealthCheck) (*InstanceHealthCheck, error) + Update(existing *InstanceHealthCheck, updates interface{}) (*InstanceHealthCheck, error) + ById(id string) (*InstanceHealthCheck, error) + Delete(container *InstanceHealthCheck) error +} + +func newInstanceHealthCheckClient(rancherClient *RancherClient) *InstanceHealthCheckClient { + return &InstanceHealthCheckClient{ + rancherClient: rancherClient, + } +} + +func (c *InstanceHealthCheckClient) Create(container *InstanceHealthCheck) (*InstanceHealthCheck, error) { + resp := &InstanceHealthCheck{} + err := c.rancherClient.doCreate(INSTANCE_HEALTH_CHECK_TYPE, container, resp) + return resp, err +} + +func (c *InstanceHealthCheckClient) Update(existing *InstanceHealthCheck, updates interface{}) (*InstanceHealthCheck, error) { + resp := &InstanceHealthCheck{} + err := c.rancherClient.doUpdate(INSTANCE_HEALTH_CHECK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InstanceHealthCheckClient) List(opts *ListOpts) (*InstanceHealthCheckCollection, error) { + resp := &InstanceHealthCheckCollection{} + err := c.rancherClient.doList(INSTANCE_HEALTH_CHECK_TYPE, opts, resp) + return resp, err +} + +func (c *InstanceHealthCheckClient) ById(id string) (*InstanceHealthCheck, error) { + resp := &InstanceHealthCheck{} + err := c.rancherClient.doById(INSTANCE_HEALTH_CHECK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InstanceHealthCheckClient) Delete(container *InstanceHealthCheck) error { + return c.rancherClient.doResourceDelete(INSTANCE_HEALTH_CHECK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_instance_link.go b/vendor/github.com/rancher/go-rancher/client/generated_instance_link.go new file mode 100644 index 00000000..5e714651 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_instance_link.go @@ -0,0 +1,176 @@ +package client + +const ( + INSTANCE_LINK_TYPE = "instanceLink" +) + +type InstanceLink struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LinkName string `json:"linkName,omitempty" yaml:"link_name,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Ports []interface{} `json:"ports,omitempty" yaml:"ports,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + TargetInstanceId string `json:"targetInstanceId,omitempty" yaml:"target_instance_id,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type InstanceLinkCollection struct { + Collection + Data []InstanceLink `json:"data,omitempty"` +} + +type InstanceLinkClient struct { + rancherClient *RancherClient +} + +type InstanceLinkOperations interface { + List(opts *ListOpts) (*InstanceLinkCollection, error) + Create(opts *InstanceLink) (*InstanceLink, error) + Update(existing *InstanceLink, updates interface{}) (*InstanceLink, error) + ById(id string) (*InstanceLink, error) + Delete(container *InstanceLink) error + + ActionActivate(*InstanceLink) (*InstanceLink, error) + + ActionCreate(*InstanceLink) (*InstanceLink, error) + + ActionDeactivate(*InstanceLink) (*InstanceLink, error) + + ActionPurge(*InstanceLink) (*InstanceLink, error) + + ActionRemove(*InstanceLink) (*InstanceLink, error) + + ActionRestore(*InstanceLink) (*InstanceLink, error) + + ActionUpdate(*InstanceLink) (*InstanceLink, error) +} + +func newInstanceLinkClient(rancherClient *RancherClient) *InstanceLinkClient { + return &InstanceLinkClient{ + rancherClient: rancherClient, + } +} + +func (c *InstanceLinkClient) Create(container *InstanceLink) (*InstanceLink, error) { + resp := &InstanceLink{} + err := c.rancherClient.doCreate(INSTANCE_LINK_TYPE, container, resp) + return resp, err +} + +func (c *InstanceLinkClient) Update(existing *InstanceLink, updates interface{}) (*InstanceLink, error) { + resp := &InstanceLink{} + err := c.rancherClient.doUpdate(INSTANCE_LINK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InstanceLinkClient) List(opts *ListOpts) (*InstanceLinkCollection, error) { + resp := &InstanceLinkCollection{} + err := c.rancherClient.doList(INSTANCE_LINK_TYPE, opts, resp) + return resp, err +} + +func (c *InstanceLinkClient) ById(id string) (*InstanceLink, error) { + resp := &InstanceLink{} + err := c.rancherClient.doById(INSTANCE_LINK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InstanceLinkClient) Delete(container *InstanceLink) error { + return c.rancherClient.doResourceDelete(INSTANCE_LINK_TYPE, &container.Resource) +} + +func (c *InstanceLinkClient) ActionActivate(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceLinkClient) ActionCreate(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceLinkClient) ActionDeactivate(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceLinkClient) ActionPurge(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceLinkClient) ActionRemove(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceLinkClient) ActionRestore(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *InstanceLinkClient) ActionUpdate(resource *InstanceLink) (*InstanceLink, error) { + + resp := &InstanceLink{} + + err := c.rancherClient.doAction(INSTANCE_LINK_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_instance_stop.go b/vendor/github.com/rancher/go-rancher/client/generated_instance_stop.go new file mode 100644 index 00000000..9d5564f6 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_instance_stop.go @@ -0,0 +1,71 @@ +package client + +const ( + INSTANCE_STOP_TYPE = "instanceStop" +) + +type InstanceStop struct { + Resource + + DeallocateFromHost bool `json:"deallocateFromHost,omitempty" yaml:"deallocate_from_host,omitempty"` + + Remove bool `json:"remove,omitempty" yaml:"remove,omitempty"` + + Timeout int64 `json:"timeout,omitempty" yaml:"timeout,omitempty"` +} + +type InstanceStopCollection struct { + Collection + Data []InstanceStop `json:"data,omitempty"` +} + +type InstanceStopClient struct { + rancherClient *RancherClient +} + +type InstanceStopOperations interface { + List(opts *ListOpts) (*InstanceStopCollection, error) + Create(opts *InstanceStop) (*InstanceStop, error) + Update(existing *InstanceStop, updates interface{}) (*InstanceStop, error) + ById(id string) (*InstanceStop, error) + Delete(container *InstanceStop) error +} + +func newInstanceStopClient(rancherClient *RancherClient) *InstanceStopClient { + return &InstanceStopClient{ + rancherClient: rancherClient, + } +} + +func (c *InstanceStopClient) Create(container *InstanceStop) (*InstanceStop, error) { + resp := &InstanceStop{} + err := c.rancherClient.doCreate(INSTANCE_STOP_TYPE, container, resp) + return resp, err +} + +func (c *InstanceStopClient) Update(existing *InstanceStop, updates interface{}) (*InstanceStop, error) { + resp := &InstanceStop{} + err := c.rancherClient.doUpdate(INSTANCE_STOP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *InstanceStopClient) List(opts *ListOpts) (*InstanceStopCollection, error) { + resp := &InstanceStopCollection{} + err := c.rancherClient.doList(INSTANCE_STOP_TYPE, opts, resp) + return resp, err +} + +func (c *InstanceStopClient) ById(id string) (*InstanceStop, error) { + resp := &InstanceStop{} + err := c.rancherClient.doById(INSTANCE_STOP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *InstanceStopClient) Delete(container *InstanceStop) error { + return c.rancherClient.doResourceDelete(INSTANCE_STOP_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_ip_address.go b/vendor/github.com/rancher/go-rancher/client/generated_ip_address.go new file mode 100644 index 00000000..ba7a0f39 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_ip_address.go @@ -0,0 +1,183 @@ +package client + +const ( + IP_ADDRESS_TYPE = "ipAddress" +) + +type IpAddress struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Address string `json:"address,omitempty" yaml:"address,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + NetworkId string `json:"networkId,omitempty" yaml:"network_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type IpAddressCollection struct { + Collection + Data []IpAddress `json:"data,omitempty"` +} + +type IpAddressClient struct { + rancherClient *RancherClient +} + +type IpAddressOperations interface { + List(opts *ListOpts) (*IpAddressCollection, error) + Create(opts *IpAddress) (*IpAddress, error) + Update(existing *IpAddress, updates interface{}) (*IpAddress, error) + ById(id string) (*IpAddress, error) + Delete(container *IpAddress) error + + ActionActivate(*IpAddress) (*IpAddress, error) + + ActionCreate(*IpAddress) (*IpAddress, error) + + ActionDeactivate(*IpAddress) (*IpAddress, error) + + ActionDisassociate(*IpAddress) (*IpAddress, error) + + ActionPurge(*IpAddress) (*IpAddress, error) + + ActionRemove(*IpAddress) (*IpAddress, error) + + ActionRestore(*IpAddress) (*IpAddress, error) + + ActionUpdate(*IpAddress) (*IpAddress, error) +} + +func newIpAddressClient(rancherClient *RancherClient) *IpAddressClient { + return &IpAddressClient{ + rancherClient: rancherClient, + } +} + +func (c *IpAddressClient) Create(container *IpAddress) (*IpAddress, error) { + resp := &IpAddress{} + err := c.rancherClient.doCreate(IP_ADDRESS_TYPE, container, resp) + return resp, err +} + +func (c *IpAddressClient) Update(existing *IpAddress, updates interface{}) (*IpAddress, error) { + resp := &IpAddress{} + err := c.rancherClient.doUpdate(IP_ADDRESS_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *IpAddressClient) List(opts *ListOpts) (*IpAddressCollection, error) { + resp := &IpAddressCollection{} + err := c.rancherClient.doList(IP_ADDRESS_TYPE, opts, resp) + return resp, err +} + +func (c *IpAddressClient) ById(id string) (*IpAddress, error) { + resp := &IpAddress{} + err := c.rancherClient.doById(IP_ADDRESS_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *IpAddressClient) Delete(container *IpAddress) error { + return c.rancherClient.doResourceDelete(IP_ADDRESS_TYPE, &container.Resource) +} + +func (c *IpAddressClient) ActionActivate(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionCreate(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionDeactivate(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionDisassociate(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "disassociate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionPurge(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionRemove(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionRestore(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *IpAddressClient) ActionUpdate(resource *IpAddress) (*IpAddress, error) { + + resp := &IpAddress{} + + err := c.rancherClient.doAction(IP_ADDRESS_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_ip_address_associate_input.go b/vendor/github.com/rancher/go-rancher/client/generated_ip_address_associate_input.go new file mode 100644 index 00000000..2184ae9a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_ip_address_associate_input.go @@ -0,0 +1,67 @@ +package client + +const ( + IP_ADDRESS_ASSOCIATE_INPUT_TYPE = "ipAddressAssociateInput" +) + +type IpAddressAssociateInput struct { + Resource + + IpAddressId string `json:"ipAddressId,omitempty" yaml:"ip_address_id,omitempty"` +} + +type IpAddressAssociateInputCollection struct { + Collection + Data []IpAddressAssociateInput `json:"data,omitempty"` +} + +type IpAddressAssociateInputClient struct { + rancherClient *RancherClient +} + +type IpAddressAssociateInputOperations interface { + List(opts *ListOpts) (*IpAddressAssociateInputCollection, error) + Create(opts *IpAddressAssociateInput) (*IpAddressAssociateInput, error) + Update(existing *IpAddressAssociateInput, updates interface{}) (*IpAddressAssociateInput, error) + ById(id string) (*IpAddressAssociateInput, error) + Delete(container *IpAddressAssociateInput) error +} + +func newIpAddressAssociateInputClient(rancherClient *RancherClient) *IpAddressAssociateInputClient { + return &IpAddressAssociateInputClient{ + rancherClient: rancherClient, + } +} + +func (c *IpAddressAssociateInputClient) Create(container *IpAddressAssociateInput) (*IpAddressAssociateInput, error) { + resp := &IpAddressAssociateInput{} + err := c.rancherClient.doCreate(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *IpAddressAssociateInputClient) Update(existing *IpAddressAssociateInput, updates interface{}) (*IpAddressAssociateInput, error) { + resp := &IpAddressAssociateInput{} + err := c.rancherClient.doUpdate(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *IpAddressAssociateInputClient) List(opts *ListOpts) (*IpAddressAssociateInputCollection, error) { + resp := &IpAddressAssociateInputCollection{} + err := c.rancherClient.doList(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *IpAddressAssociateInputClient) ById(id string) (*IpAddressAssociateInput, error) { + resp := &IpAddressAssociateInput{} + err := c.rancherClient.doById(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *IpAddressAssociateInputClient) Delete(container *IpAddressAssociateInput) error { + return c.rancherClient.doResourceDelete(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_label.go b/vendor/github.com/rancher/go-rancher/client/generated_label.go new file mode 100644 index 00000000..004a75d9 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_label.go @@ -0,0 +1,117 @@ +package client + +const ( + LABEL_TYPE = "label" +) + +type Label struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Key string `json:"key,omitempty" yaml:"key,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Value string `json:"value,omitempty" yaml:"value,omitempty"` +} + +type LabelCollection struct { + Collection + Data []Label `json:"data,omitempty"` +} + +type LabelClient struct { + rancherClient *RancherClient +} + +type LabelOperations interface { + List(opts *ListOpts) (*LabelCollection, error) + Create(opts *Label) (*Label, error) + Update(existing *Label, updates interface{}) (*Label, error) + ById(id string) (*Label, error) + Delete(container *Label) error + + ActionCreate(*Label) (*Label, error) + + ActionRemove(*Label) (*Label, error) +} + +func newLabelClient(rancherClient *RancherClient) *LabelClient { + return &LabelClient{ + rancherClient: rancherClient, + } +} + +func (c *LabelClient) Create(container *Label) (*Label, error) { + resp := &Label{} + err := c.rancherClient.doCreate(LABEL_TYPE, container, resp) + return resp, err +} + +func (c *LabelClient) Update(existing *Label, updates interface{}) (*Label, error) { + resp := &Label{} + err := c.rancherClient.doUpdate(LABEL_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LabelClient) List(opts *ListOpts) (*LabelCollection, error) { + resp := &LabelCollection{} + err := c.rancherClient.doList(LABEL_TYPE, opts, resp) + return resp, err +} + +func (c *LabelClient) ById(id string) (*Label, error) { + resp := &Label{} + err := c.rancherClient.doById(LABEL_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LabelClient) Delete(container *Label) error { + return c.rancherClient.doResourceDelete(LABEL_TYPE, &container.Resource) +} + +func (c *LabelClient) ActionCreate(resource *Label) (*Label, error) { + + resp := &Label{} + + err := c.rancherClient.doAction(LABEL_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LabelClient) ActionRemove(resource *Label) (*Label, error) { + + resp := &Label{} + + err := c.rancherClient.doAction(LABEL_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_launch_config.go b/vendor/github.com/rancher/go-rancher/client/generated_launch_config.go new file mode 100644 index 00000000..a7791965 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_launch_config.go @@ -0,0 +1,413 @@ +package client + +const ( + LAUNCH_CONFIG_TYPE = "launchConfig" +) + +type LaunchConfig struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AllocationState string `json:"allocationState,omitempty" yaml:"allocation_state,omitempty"` + + Build *DockerBuild `json:"build,omitempty" yaml:"build,omitempty"` + + CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"` + + CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"` + + Command []string `json:"command,omitempty" yaml:"command,omitempty"` + + Count int64 `json:"count,omitempty" yaml:"count,omitempty"` + + CpuSet string `json:"cpuSet,omitempty" yaml:"cpu_set,omitempty"` + + CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"` + + CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DataVolumeMounts map[string]interface{} `json:"dataVolumeMounts,omitempty" yaml:"data_volume_mounts,omitempty"` + + DataVolumes []string `json:"dataVolumes,omitempty" yaml:"data_volumes,omitempty"` + + DataVolumesFrom []string `json:"dataVolumesFrom,omitempty" yaml:"data_volumes_from,omitempty"` + + DataVolumesFromLaunchConfigs []string `json:"dataVolumesFromLaunchConfigs,omitempty" yaml:"data_volumes_from_launch_configs,omitempty"` + + DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"` + + Disks []interface{} `json:"disks,omitempty" yaml:"disks,omitempty"` + + Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"` + + DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"` + + DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"` + + EntryPoint []string `json:"entryPoint,omitempty" yaml:"entry_point,omitempty"` + + Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"` + + FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"` + + HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` + + InstanceLinks map[string]interface{} `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"` + + LxcConf map[string]interface{} `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"` + + Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"` + + MemoryMb int64 `json:"memoryMb,omitempty" yaml:"memory_mb,omitempty"` + + MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"` + + NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"` + + NetworkContainerId string `json:"networkContainerId,omitempty" yaml:"network_container_id,omitempty"` + + NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"` + + NetworkLaunchConfig string `json:"networkLaunchConfig,omitempty" yaml:"network_launch_config,omitempty"` + + NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"` + + PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"` + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"` + + Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"` + + PublishAllPorts bool `json:"publishAllPorts,omitempty" yaml:"publish_all_ports,omitempty"` + + ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"` + + RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"` + + SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"` + + StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"` + + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"` + + SystemContainer string `json:"systemContainer,omitempty" yaml:"system_container,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"` + + User string `json:"user,omitempty" yaml:"user,omitempty"` + + Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vcpu int64 `json:"vcpu,omitempty" yaml:"vcpu,omitempty"` + + Version string `json:"version,omitempty" yaml:"version,omitempty"` + + VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"` + + WorkingDir string `json:"workingDir,omitempty" yaml:"working_dir,omitempty"` +} + +type LaunchConfigCollection struct { + Collection + Data []LaunchConfig `json:"data,omitempty"` +} + +type LaunchConfigClient struct { + rancherClient *RancherClient +} + +type LaunchConfigOperations interface { + List(opts *ListOpts) (*LaunchConfigCollection, error) + Create(opts *LaunchConfig) (*LaunchConfig, error) + Update(existing *LaunchConfig, updates interface{}) (*LaunchConfig, error) + ById(id string) (*LaunchConfig, error) + Delete(container *LaunchConfig) error + + ActionAllocate(*LaunchConfig) (*Instance, error) + + ActionConsole(*LaunchConfig, *InstanceConsoleInput) (*InstanceConsole, error) + + ActionCreate(*LaunchConfig) (*Instance, error) + + ActionDeallocate(*LaunchConfig) (*Instance, error) + + ActionExecute(*LaunchConfig, *ContainerExec) (*HostAccess, error) + + ActionLogs(*LaunchConfig, *ContainerLogs) (*HostAccess, error) + + ActionMigrate(*LaunchConfig) (*Instance, error) + + ActionPurge(*LaunchConfig) (*Instance, error) + + ActionRemove(*LaunchConfig) (*Instance, error) + + ActionRestart(*LaunchConfig) (*Instance, error) + + ActionRestore(*LaunchConfig) (*Instance, error) + + ActionSetlabels(*LaunchConfig, *SetLabelsInput) (*Container, error) + + ActionStart(*LaunchConfig) (*Instance, error) + + ActionStop(*LaunchConfig, *InstanceStop) (*Instance, error) + + ActionUpdate(*LaunchConfig) (*Instance, error) + + ActionUpdatehealthy(*LaunchConfig) (*Instance, error) + + ActionUpdatereinitializing(*LaunchConfig) (*Instance, error) + + ActionUpdateunhealthy(*LaunchConfig) (*Instance, error) +} + +func newLaunchConfigClient(rancherClient *RancherClient) *LaunchConfigClient { + return &LaunchConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *LaunchConfigClient) Create(container *LaunchConfig) (*LaunchConfig, error) { + resp := &LaunchConfig{} + err := c.rancherClient.doCreate(LAUNCH_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *LaunchConfigClient) Update(existing *LaunchConfig, updates interface{}) (*LaunchConfig, error) { + resp := &LaunchConfig{} + err := c.rancherClient.doUpdate(LAUNCH_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LaunchConfigClient) List(opts *ListOpts) (*LaunchConfigCollection, error) { + resp := &LaunchConfigCollection{} + err := c.rancherClient.doList(LAUNCH_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *LaunchConfigClient) ById(id string) (*LaunchConfig, error) { + resp := &LaunchConfig{} + err := c.rancherClient.doById(LAUNCH_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LaunchConfigClient) Delete(container *LaunchConfig) error { + return c.rancherClient.doResourceDelete(LAUNCH_CONFIG_TYPE, &container.Resource) +} + +func (c *LaunchConfigClient) ActionAllocate(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "allocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionConsole(resource *LaunchConfig, input *InstanceConsoleInput) (*InstanceConsole, error) { + + resp := &InstanceConsole{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "console", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionCreate(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionDeallocate(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "deallocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionExecute(resource *LaunchConfig, input *ContainerExec) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "execute", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionLogs(resource *LaunchConfig, input *ContainerLogs) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "logs", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionMigrate(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "migrate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionPurge(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionRemove(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionRestart(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "restart", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionRestore(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionSetlabels(resource *LaunchConfig, input *SetLabelsInput) (*Container, error) { + + resp := &Container{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "setlabels", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionStart(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "start", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionStop(resource *LaunchConfig, input *InstanceStop) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "stop", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionUpdate(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionUpdatehealthy(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "updatehealthy", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionUpdatereinitializing(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "updatereinitializing", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LaunchConfigClient) ActionUpdateunhealthy(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "updateunhealthy", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_ldapconfig.go b/vendor/github.com/rancher/go-rancher/client/generated_ldapconfig.go new file mode 100644 index 00000000..94ddbf4f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_ldapconfig.go @@ -0,0 +1,109 @@ +package client + +const ( + LDAPCONFIG_TYPE = "ldapconfig" +) + +type Ldapconfig struct { + Resource + + AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"` + + ConnectionTimeout int64 `json:"connectionTimeout,omitempty" yaml:"connection_timeout,omitempty"` + + Domain string `json:"domain,omitempty" yaml:"domain,omitempty"` + + Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` + + GroupMemberMappingAttribute string `json:"groupMemberMappingAttribute,omitempty" yaml:"group_member_mapping_attribute,omitempty"` + + GroupNameField string `json:"groupNameField,omitempty" yaml:"group_name_field,omitempty"` + + GroupObjectClass string `json:"groupObjectClass,omitempty" yaml:"group_object_class,omitempty"` + + GroupSearchField string `json:"groupSearchField,omitempty" yaml:"group_search_field,omitempty"` + + LoginDomain string `json:"loginDomain,omitempty" yaml:"login_domain,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + Server string `json:"server,omitempty" yaml:"server,omitempty"` + + ServiceAccountPassword string `json:"serviceAccountPassword,omitempty" yaml:"service_account_password,omitempty"` + + ServiceAccountUsername string `json:"serviceAccountUsername,omitempty" yaml:"service_account_username,omitempty"` + + Tls bool `json:"tls,omitempty" yaml:"tls,omitempty"` + + UserDisabledBitMask int64 `json:"userDisabledBitMask,omitempty" yaml:"user_disabled_bit_mask,omitempty"` + + UserEnabledAttribute string `json:"userEnabledAttribute,omitempty" yaml:"user_enabled_attribute,omitempty"` + + UserLoginField string `json:"userLoginField,omitempty" yaml:"user_login_field,omitempty"` + + UserMemberAttribute string `json:"userMemberAttribute,omitempty" yaml:"user_member_attribute,omitempty"` + + UserNameField string `json:"userNameField,omitempty" yaml:"user_name_field,omitempty"` + + UserObjectClass string `json:"userObjectClass,omitempty" yaml:"user_object_class,omitempty"` + + UserSearchField string `json:"userSearchField,omitempty" yaml:"user_search_field,omitempty"` +} + +type LdapconfigCollection struct { + Collection + Data []Ldapconfig `json:"data,omitempty"` +} + +type LdapconfigClient struct { + rancherClient *RancherClient +} + +type LdapconfigOperations interface { + List(opts *ListOpts) (*LdapconfigCollection, error) + Create(opts *Ldapconfig) (*Ldapconfig, error) + Update(existing *Ldapconfig, updates interface{}) (*Ldapconfig, error) + ById(id string) (*Ldapconfig, error) + Delete(container *Ldapconfig) error +} + +func newLdapconfigClient(rancherClient *RancherClient) *LdapconfigClient { + return &LdapconfigClient{ + rancherClient: rancherClient, + } +} + +func (c *LdapconfigClient) Create(container *Ldapconfig) (*Ldapconfig, error) { + resp := &Ldapconfig{} + err := c.rancherClient.doCreate(LDAPCONFIG_TYPE, container, resp) + return resp, err +} + +func (c *LdapconfigClient) Update(existing *Ldapconfig, updates interface{}) (*Ldapconfig, error) { + resp := &Ldapconfig{} + err := c.rancherClient.doUpdate(LDAPCONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LdapconfigClient) List(opts *ListOpts) (*LdapconfigCollection, error) { + resp := &LdapconfigCollection{} + err := c.rancherClient.doList(LDAPCONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *LdapconfigClient) ById(id string) (*Ldapconfig, error) { + resp := &Ldapconfig{} + err := c.rancherClient.doById(LDAPCONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LdapconfigClient) Delete(container *Ldapconfig) error { + return c.rancherClient.doResourceDelete(LDAPCONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer.go new file mode 100644 index 00000000..6b870b82 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer.go @@ -0,0 +1,224 @@ +package client + +const ( + LOAD_BALANCER_TYPE = "loadBalancer" +) + +type LoadBalancer struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + CertificateIds []string `json:"certificateIds,omitempty" yaml:"certificate_ids,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DefaultCertificateId string `json:"defaultCertificateId,omitempty" yaml:"default_certificate_id,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + GlobalLoadBalancerId string `json:"globalLoadBalancerId,omitempty" yaml:"global_load_balancer_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LoadBalancerConfigId string `json:"loadBalancerConfigId,omitempty" yaml:"load_balancer_config_id,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"` +} + +type LoadBalancerCollection struct { + Collection + Data []LoadBalancer `json:"data,omitempty"` +} + +type LoadBalancerClient struct { + rancherClient *RancherClient +} + +type LoadBalancerOperations interface { + List(opts *ListOpts) (*LoadBalancerCollection, error) + Create(opts *LoadBalancer) (*LoadBalancer, error) + Update(existing *LoadBalancer, updates interface{}) (*LoadBalancer, error) + ById(id string) (*LoadBalancer, error) + Delete(container *LoadBalancer) error + + ActionActivate(*LoadBalancer) (*LoadBalancer, error) + + ActionAddhost(*LoadBalancer, *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error) + + ActionAddtarget(*LoadBalancer, *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error) + + ActionCreate(*LoadBalancer) (*LoadBalancer, error) + + ActionDeactivate(*LoadBalancer) (*LoadBalancer, error) + + ActionRemove(*LoadBalancer) (*LoadBalancer, error) + + ActionRemovehost(*LoadBalancer, *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error) + + ActionRemovetarget(*LoadBalancer, *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error) + + ActionSethosts(*LoadBalancer, *SetLoadBalancerHostsInput) (*LoadBalancer, error) + + ActionSettargets(*LoadBalancer, *SetLoadBalancerTargetsInput) (*LoadBalancer, error) + + ActionUpdate(*LoadBalancer) (*LoadBalancer, error) +} + +func newLoadBalancerClient(rancherClient *RancherClient) *LoadBalancerClient { + return &LoadBalancerClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerClient) Create(container *LoadBalancer) (*LoadBalancer, error) { + resp := &LoadBalancer{} + err := c.rancherClient.doCreate(LOAD_BALANCER_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerClient) Update(existing *LoadBalancer, updates interface{}) (*LoadBalancer, error) { + resp := &LoadBalancer{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerClient) List(opts *ListOpts) (*LoadBalancerCollection, error) { + resp := &LoadBalancerCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerClient) ById(id string) (*LoadBalancer, error) { + resp := &LoadBalancer{} + err := c.rancherClient.doById(LOAD_BALANCER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerClient) Delete(container *LoadBalancer) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_TYPE, &container.Resource) +} + +func (c *LoadBalancerClient) ActionActivate(resource *LoadBalancer) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionAddhost(resource *LoadBalancer, input *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "addhost", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionAddtarget(resource *LoadBalancer, input *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "addtarget", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionCreate(resource *LoadBalancer) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionDeactivate(resource *LoadBalancer) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionRemove(resource *LoadBalancer) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionRemovehost(resource *LoadBalancer, input *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "removehost", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionRemovetarget(resource *LoadBalancer, input *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "removetarget", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionSethosts(resource *LoadBalancer, input *SetLoadBalancerHostsInput) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "sethosts", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionSettargets(resource *LoadBalancer, input *SetLoadBalancerTargetsInput) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "settargets", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerClient) ActionUpdate(resource *LoadBalancer) (*LoadBalancer, error) { + + resp := &LoadBalancer{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_app_cookie_stickiness_policy.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_app_cookie_stickiness_policy.go new file mode 100644 index 00000000..235252cd --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_app_cookie_stickiness_policy.go @@ -0,0 +1,79 @@ +package client + +const ( + LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE = "loadBalancerAppCookieStickinessPolicy" +) + +type LoadBalancerAppCookieStickinessPolicy struct { + Resource + + Cookie string `json:"cookie,omitempty" yaml:"cookie,omitempty"` + + MaxLength int64 `json:"maxLength,omitempty" yaml:"max_length,omitempty"` + + Mode string `json:"mode,omitempty" yaml:"mode,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Prefix bool `json:"prefix,omitempty" yaml:"prefix,omitempty"` + + RequestLearn bool `json:"requestLearn,omitempty" yaml:"request_learn,omitempty"` + + Timeout int64 `json:"timeout,omitempty" yaml:"timeout,omitempty"` +} + +type LoadBalancerAppCookieStickinessPolicyCollection struct { + Collection + Data []LoadBalancerAppCookieStickinessPolicy `json:"data,omitempty"` +} + +type LoadBalancerAppCookieStickinessPolicyClient struct { + rancherClient *RancherClient +} + +type LoadBalancerAppCookieStickinessPolicyOperations interface { + List(opts *ListOpts) (*LoadBalancerAppCookieStickinessPolicyCollection, error) + Create(opts *LoadBalancerAppCookieStickinessPolicy) (*LoadBalancerAppCookieStickinessPolicy, error) + Update(existing *LoadBalancerAppCookieStickinessPolicy, updates interface{}) (*LoadBalancerAppCookieStickinessPolicy, error) + ById(id string) (*LoadBalancerAppCookieStickinessPolicy, error) + Delete(container *LoadBalancerAppCookieStickinessPolicy) error +} + +func newLoadBalancerAppCookieStickinessPolicyClient(rancherClient *RancherClient) *LoadBalancerAppCookieStickinessPolicyClient { + return &LoadBalancerAppCookieStickinessPolicyClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerAppCookieStickinessPolicyClient) Create(container *LoadBalancerAppCookieStickinessPolicy) (*LoadBalancerAppCookieStickinessPolicy, error) { + resp := &LoadBalancerAppCookieStickinessPolicy{} + err := c.rancherClient.doCreate(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerAppCookieStickinessPolicyClient) Update(existing *LoadBalancerAppCookieStickinessPolicy, updates interface{}) (*LoadBalancerAppCookieStickinessPolicy, error) { + resp := &LoadBalancerAppCookieStickinessPolicy{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerAppCookieStickinessPolicyClient) List(opts *ListOpts) (*LoadBalancerAppCookieStickinessPolicyCollection, error) { + resp := &LoadBalancerAppCookieStickinessPolicyCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerAppCookieStickinessPolicyClient) ById(id string) (*LoadBalancerAppCookieStickinessPolicy, error) { + resp := &LoadBalancerAppCookieStickinessPolicy{} + err := c.rancherClient.doById(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerAppCookieStickinessPolicyClient) Delete(container *LoadBalancerAppCookieStickinessPolicy) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config.go new file mode 100644 index 00000000..8c23c42e --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config.go @@ -0,0 +1,69 @@ +package client + +const ( + LOAD_BALANCER_CONFIG_TYPE = "loadBalancerConfig" +) + +type LoadBalancerConfig struct { + Resource + + HaproxyConfig *HaproxyConfig `json:"haproxyConfig,omitempty" yaml:"haproxy_config,omitempty"` + + LbCookieStickinessPolicy *LoadBalancerCookieStickinessPolicy `json:"lbCookieStickinessPolicy,omitempty" yaml:"lb_cookie_stickiness_policy,omitempty"` +} + +type LoadBalancerConfigCollection struct { + Collection + Data []LoadBalancerConfig `json:"data,omitempty"` +} + +type LoadBalancerConfigClient struct { + rancherClient *RancherClient +} + +type LoadBalancerConfigOperations interface { + List(opts *ListOpts) (*LoadBalancerConfigCollection, error) + Create(opts *LoadBalancerConfig) (*LoadBalancerConfig, error) + Update(existing *LoadBalancerConfig, updates interface{}) (*LoadBalancerConfig, error) + ById(id string) (*LoadBalancerConfig, error) + Delete(container *LoadBalancerConfig) error +} + +func newLoadBalancerConfigClient(rancherClient *RancherClient) *LoadBalancerConfigClient { + return &LoadBalancerConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerConfigClient) Create(container *LoadBalancerConfig) (*LoadBalancerConfig, error) { + resp := &LoadBalancerConfig{} + err := c.rancherClient.doCreate(LOAD_BALANCER_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerConfigClient) Update(existing *LoadBalancerConfig, updates interface{}) (*LoadBalancerConfig, error) { + resp := &LoadBalancerConfig{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerConfigClient) List(opts *ListOpts) (*LoadBalancerConfigCollection, error) { + resp := &LoadBalancerConfigCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerConfigClient) ById(id string) (*LoadBalancerConfig, error) { + resp := &LoadBalancerConfig{} + err := c.rancherClient.doById(LOAD_BALANCER_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerConfigClient) Delete(container *LoadBalancerConfig) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config_listener_map.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config_listener_map.go new file mode 100644 index 00000000..b8e4d515 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_config_listener_map.go @@ -0,0 +1,117 @@ +package client + +const ( + LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE = "loadBalancerConfigListenerMap" +) + +type LoadBalancerConfigListenerMap struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LoadBalancerConfigId string `json:"loadBalancerConfigId,omitempty" yaml:"load_balancer_config_id,omitempty"` + + LoadBalancerListenerId string `json:"loadBalancerListenerId,omitempty" yaml:"load_balancer_listener_id,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type LoadBalancerConfigListenerMapCollection struct { + Collection + Data []LoadBalancerConfigListenerMap `json:"data,omitempty"` +} + +type LoadBalancerConfigListenerMapClient struct { + rancherClient *RancherClient +} + +type LoadBalancerConfigListenerMapOperations interface { + List(opts *ListOpts) (*LoadBalancerConfigListenerMapCollection, error) + Create(opts *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) + Update(existing *LoadBalancerConfigListenerMap, updates interface{}) (*LoadBalancerConfigListenerMap, error) + ById(id string) (*LoadBalancerConfigListenerMap, error) + Delete(container *LoadBalancerConfigListenerMap) error + + ActionCreate(*LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) + + ActionRemove(*LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) +} + +func newLoadBalancerConfigListenerMapClient(rancherClient *RancherClient) *LoadBalancerConfigListenerMapClient { + return &LoadBalancerConfigListenerMapClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerConfigListenerMapClient) Create(container *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) { + resp := &LoadBalancerConfigListenerMap{} + err := c.rancherClient.doCreate(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerConfigListenerMapClient) Update(existing *LoadBalancerConfigListenerMap, updates interface{}) (*LoadBalancerConfigListenerMap, error) { + resp := &LoadBalancerConfigListenerMap{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerConfigListenerMapClient) List(opts *ListOpts) (*LoadBalancerConfigListenerMapCollection, error) { + resp := &LoadBalancerConfigListenerMapCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerConfigListenerMapClient) ById(id string) (*LoadBalancerConfigListenerMap, error) { + resp := &LoadBalancerConfigListenerMap{} + err := c.rancherClient.doById(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerConfigListenerMapClient) Delete(container *LoadBalancerConfigListenerMap) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, &container.Resource) +} + +func (c *LoadBalancerConfigListenerMapClient) ActionCreate(resource *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) { + + resp := &LoadBalancerConfigListenerMap{} + + err := c.rancherClient.doAction(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerConfigListenerMapClient) ActionRemove(resource *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) { + + resp := &LoadBalancerConfigListenerMap{} + + err := c.rancherClient.doAction(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_cookie_stickiness_policy.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_cookie_stickiness_policy.go new file mode 100644 index 00000000..0fc5699a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_cookie_stickiness_policy.go @@ -0,0 +1,79 @@ +package client + +const ( + LOAD_BALANCER_COOKIE_STICKINESS_POLICY_TYPE = "loadBalancerCookieStickinessPolicy" +) + +type LoadBalancerCookieStickinessPolicy struct { + Resource + + Cookie string `json:"cookie,omitempty" yaml:"cookie,omitempty"` + + Domain string `json:"domain,omitempty" yaml:"domain,omitempty"` + + Indirect bool `json:"indirect,omitempty" yaml:"indirect,omitempty"` + + Mode string `json:"mode,omitempty" yaml:"mode,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Nocache bool `json:"nocache,omitempty" yaml:"nocache,omitempty"` + + Postonly bool `json:"postonly,omitempty" yaml:"postonly,omitempty"` +} + +type LoadBalancerCookieStickinessPolicyCollection struct { + Collection + Data []LoadBalancerCookieStickinessPolicy `json:"data,omitempty"` +} + +type LoadBalancerCookieStickinessPolicyClient struct { + rancherClient *RancherClient +} + +type LoadBalancerCookieStickinessPolicyOperations interface { + List(opts *ListOpts) (*LoadBalancerCookieStickinessPolicyCollection, error) + Create(opts *LoadBalancerCookieStickinessPolicy) (*LoadBalancerCookieStickinessPolicy, error) + Update(existing *LoadBalancerCookieStickinessPolicy, updates interface{}) (*LoadBalancerCookieStickinessPolicy, error) + ById(id string) (*LoadBalancerCookieStickinessPolicy, error) + Delete(container *LoadBalancerCookieStickinessPolicy) error +} + +func newLoadBalancerCookieStickinessPolicyClient(rancherClient *RancherClient) *LoadBalancerCookieStickinessPolicyClient { + return &LoadBalancerCookieStickinessPolicyClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerCookieStickinessPolicyClient) Create(container *LoadBalancerCookieStickinessPolicy) (*LoadBalancerCookieStickinessPolicy, error) { + resp := &LoadBalancerCookieStickinessPolicy{} + err := c.rancherClient.doCreate(LOAD_BALANCER_COOKIE_STICKINESS_POLICY_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerCookieStickinessPolicyClient) Update(existing *LoadBalancerCookieStickinessPolicy, updates interface{}) (*LoadBalancerCookieStickinessPolicy, error) { + resp := &LoadBalancerCookieStickinessPolicy{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_COOKIE_STICKINESS_POLICY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerCookieStickinessPolicyClient) List(opts *ListOpts) (*LoadBalancerCookieStickinessPolicyCollection, error) { + resp := &LoadBalancerCookieStickinessPolicyCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_COOKIE_STICKINESS_POLICY_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerCookieStickinessPolicyClient) ById(id string) (*LoadBalancerCookieStickinessPolicy, error) { + resp := &LoadBalancerCookieStickinessPolicy{} + err := c.rancherClient.doById(LOAD_BALANCER_COOKIE_STICKINESS_POLICY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerCookieStickinessPolicyClient) Delete(container *LoadBalancerCookieStickinessPolicy) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_COOKIE_STICKINESS_POLICY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_health_check.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_health_check.go new file mode 100644 index 00000000..1d96ec64 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_health_check.go @@ -0,0 +1,79 @@ +package client + +const ( + LOAD_BALANCER_HEALTH_CHECK_TYPE = "loadBalancerHealthCheck" +) + +type LoadBalancerHealthCheck struct { + Resource + + HealthyThreshold int64 `json:"healthyThreshold,omitempty" yaml:"healthy_threshold,omitempty"` + + Interval int64 `json:"interval,omitempty" yaml:"interval,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + RequestLine string `json:"requestLine,omitempty" yaml:"request_line,omitempty"` + + ResponseTimeout int64 `json:"responseTimeout,omitempty" yaml:"response_timeout,omitempty"` + + UnhealthyThreshold int64 `json:"unhealthyThreshold,omitempty" yaml:"unhealthy_threshold,omitempty"` +} + +type LoadBalancerHealthCheckCollection struct { + Collection + Data []LoadBalancerHealthCheck `json:"data,omitempty"` +} + +type LoadBalancerHealthCheckClient struct { + rancherClient *RancherClient +} + +type LoadBalancerHealthCheckOperations interface { + List(opts *ListOpts) (*LoadBalancerHealthCheckCollection, error) + Create(opts *LoadBalancerHealthCheck) (*LoadBalancerHealthCheck, error) + Update(existing *LoadBalancerHealthCheck, updates interface{}) (*LoadBalancerHealthCheck, error) + ById(id string) (*LoadBalancerHealthCheck, error) + Delete(container *LoadBalancerHealthCheck) error +} + +func newLoadBalancerHealthCheckClient(rancherClient *RancherClient) *LoadBalancerHealthCheckClient { + return &LoadBalancerHealthCheckClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerHealthCheckClient) Create(container *LoadBalancerHealthCheck) (*LoadBalancerHealthCheck, error) { + resp := &LoadBalancerHealthCheck{} + err := c.rancherClient.doCreate(LOAD_BALANCER_HEALTH_CHECK_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerHealthCheckClient) Update(existing *LoadBalancerHealthCheck, updates interface{}) (*LoadBalancerHealthCheck, error) { + resp := &LoadBalancerHealthCheck{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_HEALTH_CHECK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerHealthCheckClient) List(opts *ListOpts) (*LoadBalancerHealthCheckCollection, error) { + resp := &LoadBalancerHealthCheckCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_HEALTH_CHECK_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerHealthCheckClient) ById(id string) (*LoadBalancerHealthCheck, error) { + resp := &LoadBalancerHealthCheck{} + err := c.rancherClient.doById(LOAD_BALANCER_HEALTH_CHECK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerHealthCheckClient) Delete(container *LoadBalancerHealthCheck) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_HEALTH_CHECK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_host_map.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_host_map.go new file mode 100644 index 00000000..b135d29c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_host_map.go @@ -0,0 +1,89 @@ +package client + +const ( + LOAD_BALANCER_HOST_MAP_TYPE = "loadBalancerHostMap" +) + +type LoadBalancerHostMap struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type LoadBalancerHostMapCollection struct { + Collection + Data []LoadBalancerHostMap `json:"data,omitempty"` +} + +type LoadBalancerHostMapClient struct { + rancherClient *RancherClient +} + +type LoadBalancerHostMapOperations interface { + List(opts *ListOpts) (*LoadBalancerHostMapCollection, error) + Create(opts *LoadBalancerHostMap) (*LoadBalancerHostMap, error) + Update(existing *LoadBalancerHostMap, updates interface{}) (*LoadBalancerHostMap, error) + ById(id string) (*LoadBalancerHostMap, error) + Delete(container *LoadBalancerHostMap) error +} + +func newLoadBalancerHostMapClient(rancherClient *RancherClient) *LoadBalancerHostMapClient { + return &LoadBalancerHostMapClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerHostMapClient) Create(container *LoadBalancerHostMap) (*LoadBalancerHostMap, error) { + resp := &LoadBalancerHostMap{} + err := c.rancherClient.doCreate(LOAD_BALANCER_HOST_MAP_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerHostMapClient) Update(existing *LoadBalancerHostMap, updates interface{}) (*LoadBalancerHostMap, error) { + resp := &LoadBalancerHostMap{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_HOST_MAP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerHostMapClient) List(opts *ListOpts) (*LoadBalancerHostMapCollection, error) { + resp := &LoadBalancerHostMapCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_HOST_MAP_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerHostMapClient) ById(id string) (*LoadBalancerHostMap, error) { + resp := &LoadBalancerHostMap{} + err := c.rancherClient.doById(LOAD_BALANCER_HOST_MAP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerHostMapClient) Delete(container *LoadBalancerHostMap) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_HOST_MAP_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_listener.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_listener.go new file mode 100644 index 00000000..5d0e983f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_listener.go @@ -0,0 +1,127 @@ +package client + +const ( + LOAD_BALANCER_LISTENER_TYPE = "loadBalancerListener" +) + +type LoadBalancerListener struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PrivatePort int64 `json:"privatePort,omitempty" yaml:"private_port,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` + + SourcePort int64 `json:"sourcePort,omitempty" yaml:"source_port,omitempty"` + + SourceProtocol string `json:"sourceProtocol,omitempty" yaml:"source_protocol,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + TargetPort int64 `json:"targetPort,omitempty" yaml:"target_port,omitempty"` + + TargetProtocol string `json:"targetProtocol,omitempty" yaml:"target_protocol,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type LoadBalancerListenerCollection struct { + Collection + Data []LoadBalancerListener `json:"data,omitempty"` +} + +type LoadBalancerListenerClient struct { + rancherClient *RancherClient +} + +type LoadBalancerListenerOperations interface { + List(opts *ListOpts) (*LoadBalancerListenerCollection, error) + Create(opts *LoadBalancerListener) (*LoadBalancerListener, error) + Update(existing *LoadBalancerListener, updates interface{}) (*LoadBalancerListener, error) + ById(id string) (*LoadBalancerListener, error) + Delete(container *LoadBalancerListener) error + + ActionCreate(*LoadBalancerListener) (*LoadBalancerListener, error) + + ActionRemove(*LoadBalancerListener) (*LoadBalancerListener, error) +} + +func newLoadBalancerListenerClient(rancherClient *RancherClient) *LoadBalancerListenerClient { + return &LoadBalancerListenerClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerListenerClient) Create(container *LoadBalancerListener) (*LoadBalancerListener, error) { + resp := &LoadBalancerListener{} + err := c.rancherClient.doCreate(LOAD_BALANCER_LISTENER_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerListenerClient) Update(existing *LoadBalancerListener, updates interface{}) (*LoadBalancerListener, error) { + resp := &LoadBalancerListener{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_LISTENER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerListenerClient) List(opts *ListOpts) (*LoadBalancerListenerCollection, error) { + resp := &LoadBalancerListenerCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_LISTENER_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerListenerClient) ById(id string) (*LoadBalancerListener, error) { + resp := &LoadBalancerListener{} + err := c.rancherClient.doById(LOAD_BALANCER_LISTENER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerListenerClient) Delete(container *LoadBalancerListener) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_LISTENER_TYPE, &container.Resource) +} + +func (c *LoadBalancerListenerClient) ActionCreate(resource *LoadBalancerListener) (*LoadBalancerListener, error) { + + resp := &LoadBalancerListener{} + + err := c.rancherClient.doAction(LOAD_BALANCER_LISTENER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerListenerClient) ActionRemove(resource *LoadBalancerListener) (*LoadBalancerListener, error) { + + resp := &LoadBalancerListener{} + + err := c.rancherClient.doAction(LOAD_BALANCER_LISTENER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service.go new file mode 100644 index 00000000..118fcca9 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service.go @@ -0,0 +1,273 @@ +package client + +const ( + LOAD_BALANCER_SERVICE_TYPE = "loadBalancerService" +) + +type LoadBalancerService struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + CertificateIds []string `json:"certificateIds,omitempty" yaml:"certificate_ids,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DefaultCertificateId string `json:"defaultCertificateId,omitempty" yaml:"default_certificate_id,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` + + LoadBalancerConfig *LoadBalancerConfig `json:"loadBalancerConfig,omitempty" yaml:"load_balancer_config,omitempty"` + + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"` + + Scale int64 `json:"scale,omitempty" yaml:"scale,omitempty"` + + SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vip string `json:"vip,omitempty" yaml:"vip,omitempty"` +} + +type LoadBalancerServiceCollection struct { + Collection + Data []LoadBalancerService `json:"data,omitempty"` +} + +type LoadBalancerServiceClient struct { + rancherClient *RancherClient +} + +type LoadBalancerServiceOperations interface { + List(opts *ListOpts) (*LoadBalancerServiceCollection, error) + Create(opts *LoadBalancerService) (*LoadBalancerService, error) + Update(existing *LoadBalancerService, updates interface{}) (*LoadBalancerService, error) + ById(id string) (*LoadBalancerService, error) + Delete(container *LoadBalancerService) error + + ActionActivate(*LoadBalancerService) (*Service, error) + + ActionAddservicelink(*LoadBalancerService, *AddRemoveLoadBalancerServiceLinkInput) (*Service, error) + + ActionCancelrollback(*LoadBalancerService) (*Service, error) + + ActionCancelupgrade(*LoadBalancerService) (*Service, error) + + ActionCreate(*LoadBalancerService) (*Service, error) + + ActionDeactivate(*LoadBalancerService) (*Service, error) + + ActionFinishupgrade(*LoadBalancerService) (*Service, error) + + ActionRemove(*LoadBalancerService) (*Service, error) + + ActionRemoveservicelink(*LoadBalancerService, *AddRemoveLoadBalancerServiceLinkInput) (*Service, error) + + ActionRestart(*LoadBalancerService, *ServiceRestart) (*Service, error) + + ActionRollback(*LoadBalancerService) (*Service, error) + + ActionSetservicelinks(*LoadBalancerService, *SetLoadBalancerServiceLinksInput) (*Service, error) + + ActionUpdate(*LoadBalancerService) (*Service, error) + + ActionUpgrade(*LoadBalancerService, *ServiceUpgrade) (*Service, error) +} + +func newLoadBalancerServiceClient(rancherClient *RancherClient) *LoadBalancerServiceClient { + return &LoadBalancerServiceClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerServiceClient) Create(container *LoadBalancerService) (*LoadBalancerService, error) { + resp := &LoadBalancerService{} + err := c.rancherClient.doCreate(LOAD_BALANCER_SERVICE_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerServiceClient) Update(existing *LoadBalancerService, updates interface{}) (*LoadBalancerService, error) { + resp := &LoadBalancerService{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_SERVICE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerServiceClient) List(opts *ListOpts) (*LoadBalancerServiceCollection, error) { + resp := &LoadBalancerServiceCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_SERVICE_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerServiceClient) ById(id string) (*LoadBalancerService, error) { + resp := &LoadBalancerService{} + err := c.rancherClient.doById(LOAD_BALANCER_SERVICE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerServiceClient) Delete(container *LoadBalancerService) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_SERVICE_TYPE, &container.Resource) +} + +func (c *LoadBalancerServiceClient) ActionActivate(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionAddservicelink(resource *LoadBalancerService, input *AddRemoveLoadBalancerServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionCancelrollback(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionCancelupgrade(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionCreate(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionDeactivate(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionFinishupgrade(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionRemove(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionRemoveservicelink(resource *LoadBalancerService, input *AddRemoveLoadBalancerServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionRestart(resource *LoadBalancerService, input *ServiceRestart) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "restart", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionRollback(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionSetservicelinks(resource *LoadBalancerService, input *SetLoadBalancerServiceLinksInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionUpdate(resource *LoadBalancerService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerServiceClient) ActionUpgrade(resource *LoadBalancerService, input *ServiceUpgrade) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(LOAD_BALANCER_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service_link.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service_link.go new file mode 100644 index 00000000..b30c45be --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_service_link.go @@ -0,0 +1,71 @@ +package client + +const ( + LOAD_BALANCER_SERVICE_LINK_TYPE = "loadBalancerServiceLink" +) + +type LoadBalancerServiceLink struct { + Resource + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type LoadBalancerServiceLinkCollection struct { + Collection + Data []LoadBalancerServiceLink `json:"data,omitempty"` +} + +type LoadBalancerServiceLinkClient struct { + rancherClient *RancherClient +} + +type LoadBalancerServiceLinkOperations interface { + List(opts *ListOpts) (*LoadBalancerServiceLinkCollection, error) + Create(opts *LoadBalancerServiceLink) (*LoadBalancerServiceLink, error) + Update(existing *LoadBalancerServiceLink, updates interface{}) (*LoadBalancerServiceLink, error) + ById(id string) (*LoadBalancerServiceLink, error) + Delete(container *LoadBalancerServiceLink) error +} + +func newLoadBalancerServiceLinkClient(rancherClient *RancherClient) *LoadBalancerServiceLinkClient { + return &LoadBalancerServiceLinkClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerServiceLinkClient) Create(container *LoadBalancerServiceLink) (*LoadBalancerServiceLink, error) { + resp := &LoadBalancerServiceLink{} + err := c.rancherClient.doCreate(LOAD_BALANCER_SERVICE_LINK_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerServiceLinkClient) Update(existing *LoadBalancerServiceLink, updates interface{}) (*LoadBalancerServiceLink, error) { + resp := &LoadBalancerServiceLink{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_SERVICE_LINK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerServiceLinkClient) List(opts *ListOpts) (*LoadBalancerServiceLinkCollection, error) { + resp := &LoadBalancerServiceLinkCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_SERVICE_LINK_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerServiceLinkClient) ById(id string) (*LoadBalancerServiceLink, error) { + resp := &LoadBalancerServiceLink{} + err := c.rancherClient.doById(LOAD_BALANCER_SERVICE_LINK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerServiceLinkClient) Delete(container *LoadBalancerServiceLink) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_SERVICE_LINK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_target.go b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_target.go new file mode 100644 index 00000000..b0037f7b --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_load_balancer_target.go @@ -0,0 +1,132 @@ +package client + +const ( + LOAD_BALANCER_TARGET_TYPE = "loadBalancerTarget" +) + +type LoadBalancerTarget struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + IpAddress string `json:"ipAddress,omitempty" yaml:"ip_address,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type LoadBalancerTargetCollection struct { + Collection + Data []LoadBalancerTarget `json:"data,omitempty"` +} + +type LoadBalancerTargetClient struct { + rancherClient *RancherClient +} + +type LoadBalancerTargetOperations interface { + List(opts *ListOpts) (*LoadBalancerTargetCollection, error) + Create(opts *LoadBalancerTarget) (*LoadBalancerTarget, error) + Update(existing *LoadBalancerTarget, updates interface{}) (*LoadBalancerTarget, error) + ById(id string) (*LoadBalancerTarget, error) + Delete(container *LoadBalancerTarget) error + + ActionCreate(*LoadBalancerTarget) (*LoadBalancerTarget, error) + + ActionRemove(*LoadBalancerTarget) (*LoadBalancerTarget, error) + + ActionUpdate(*LoadBalancerTarget) (*LoadBalancerTarget, error) +} + +func newLoadBalancerTargetClient(rancherClient *RancherClient) *LoadBalancerTargetClient { + return &LoadBalancerTargetClient{ + rancherClient: rancherClient, + } +} + +func (c *LoadBalancerTargetClient) Create(container *LoadBalancerTarget) (*LoadBalancerTarget, error) { + resp := &LoadBalancerTarget{} + err := c.rancherClient.doCreate(LOAD_BALANCER_TARGET_TYPE, container, resp) + return resp, err +} + +func (c *LoadBalancerTargetClient) Update(existing *LoadBalancerTarget, updates interface{}) (*LoadBalancerTarget, error) { + resp := &LoadBalancerTarget{} + err := c.rancherClient.doUpdate(LOAD_BALANCER_TARGET_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LoadBalancerTargetClient) List(opts *ListOpts) (*LoadBalancerTargetCollection, error) { + resp := &LoadBalancerTargetCollection{} + err := c.rancherClient.doList(LOAD_BALANCER_TARGET_TYPE, opts, resp) + return resp, err +} + +func (c *LoadBalancerTargetClient) ById(id string) (*LoadBalancerTarget, error) { + resp := &LoadBalancerTarget{} + err := c.rancherClient.doById(LOAD_BALANCER_TARGET_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LoadBalancerTargetClient) Delete(container *LoadBalancerTarget) error { + return c.rancherClient.doResourceDelete(LOAD_BALANCER_TARGET_TYPE, &container.Resource) +} + +func (c *LoadBalancerTargetClient) ActionCreate(resource *LoadBalancerTarget) (*LoadBalancerTarget, error) { + + resp := &LoadBalancerTarget{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TARGET_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerTargetClient) ActionRemove(resource *LoadBalancerTarget) (*LoadBalancerTarget, error) { + + resp := &LoadBalancerTarget{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TARGET_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *LoadBalancerTargetClient) ActionUpdate(resource *LoadBalancerTarget) (*LoadBalancerTarget, error) { + + resp := &LoadBalancerTarget{} + + err := c.rancherClient.doAction(LOAD_BALANCER_TARGET_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_local_auth_config.go b/vendor/github.com/rancher/go-rancher/client/generated_local_auth_config.go new file mode 100644 index 00000000..fe223efe --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_local_auth_config.go @@ -0,0 +1,75 @@ +package client + +const ( + LOCAL_AUTH_CONFIG_TYPE = "localAuthConfig" +) + +type LocalAuthConfig struct { + Resource + + AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"` + + Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Password Password `json:"password,omitempty" yaml:"password,omitempty"` + + Username string `json:"username,omitempty" yaml:"username,omitempty"` +} + +type LocalAuthConfigCollection struct { + Collection + Data []LocalAuthConfig `json:"data,omitempty"` +} + +type LocalAuthConfigClient struct { + rancherClient *RancherClient +} + +type LocalAuthConfigOperations interface { + List(opts *ListOpts) (*LocalAuthConfigCollection, error) + Create(opts *LocalAuthConfig) (*LocalAuthConfig, error) + Update(existing *LocalAuthConfig, updates interface{}) (*LocalAuthConfig, error) + ById(id string) (*LocalAuthConfig, error) + Delete(container *LocalAuthConfig) error +} + +func newLocalAuthConfigClient(rancherClient *RancherClient) *LocalAuthConfigClient { + return &LocalAuthConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *LocalAuthConfigClient) Create(container *LocalAuthConfig) (*LocalAuthConfig, error) { + resp := &LocalAuthConfig{} + err := c.rancherClient.doCreate(LOCAL_AUTH_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *LocalAuthConfigClient) Update(existing *LocalAuthConfig, updates interface{}) (*LocalAuthConfig, error) { + resp := &LocalAuthConfig{} + err := c.rancherClient.doUpdate(LOCAL_AUTH_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LocalAuthConfigClient) List(opts *ListOpts) (*LocalAuthConfigCollection, error) { + resp := &LocalAuthConfigCollection{} + err := c.rancherClient.doList(LOCAL_AUTH_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *LocalAuthConfigClient) ById(id string) (*LocalAuthConfig, error) { + resp := &LocalAuthConfig{} + err := c.rancherClient.doById(LOCAL_AUTH_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LocalAuthConfigClient) Delete(container *LocalAuthConfig) error { + return c.rancherClient.doResourceDelete(LOCAL_AUTH_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_log_config.go b/vendor/github.com/rancher/go-rancher/client/generated_log_config.go new file mode 100644 index 00000000..1abfc4c9 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_log_config.go @@ -0,0 +1,69 @@ +package client + +const ( + LOG_CONFIG_TYPE = "logConfig" +) + +type LogConfig struct { + Resource + + Config map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty"` + + Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` +} + +type LogConfigCollection struct { + Collection + Data []LogConfig `json:"data,omitempty"` +} + +type LogConfigClient struct { + rancherClient *RancherClient +} + +type LogConfigOperations interface { + List(opts *ListOpts) (*LogConfigCollection, error) + Create(opts *LogConfig) (*LogConfig, error) + Update(existing *LogConfig, updates interface{}) (*LogConfig, error) + ById(id string) (*LogConfig, error) + Delete(container *LogConfig) error +} + +func newLogConfigClient(rancherClient *RancherClient) *LogConfigClient { + return &LogConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *LogConfigClient) Create(container *LogConfig) (*LogConfig, error) { + resp := &LogConfig{} + err := c.rancherClient.doCreate(LOG_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *LogConfigClient) Update(existing *LogConfig, updates interface{}) (*LogConfig, error) { + resp := &LogConfig{} + err := c.rancherClient.doUpdate(LOG_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *LogConfigClient) List(opts *ListOpts) (*LogConfigCollection, error) { + resp := &LogConfigCollection{} + err := c.rancherClient.doList(LOG_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *LogConfigClient) ById(id string) (*LogConfig, error) { + resp := &LogConfig{} + err := c.rancherClient.doById(LOG_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *LogConfigClient) Delete(container *LogConfig) error { + return c.rancherClient.doResourceDelete(LOG_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_machine.go b/vendor/github.com/rancher/go-rancher/client/generated_machine.go new file mode 100644 index 00000000..a62d0779 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_machine.go @@ -0,0 +1,174 @@ +package client + +const ( + MACHINE_TYPE = "machine" +) + +type Machine struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AuthCertificateAuthority string `json:"authCertificateAuthority,omitempty" yaml:"auth_certificate_authority,omitempty"` + + AuthKey string `json:"authKey,omitempty" yaml:"auth_key,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + DockerVersion string `json:"dockerVersion,omitempty" yaml:"docker_version,omitempty"` + + Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` + + EngineEnv map[string]interface{} `json:"engineEnv,omitempty" yaml:"engine_env,omitempty"` + + EngineInsecureRegistry []string `json:"engineInsecureRegistry,omitempty" yaml:"engine_insecure_registry,omitempty"` + + EngineInstallUrl string `json:"engineInstallUrl,omitempty" yaml:"engine_install_url,omitempty"` + + EngineLabel map[string]interface{} `json:"engineLabel,omitempty" yaml:"engine_label,omitempty"` + + EngineOpt map[string]interface{} `json:"engineOpt,omitempty" yaml:"engine_opt,omitempty"` + + EngineRegistryMirror []string `json:"engineRegistryMirror,omitempty" yaml:"engine_registry_mirror,omitempty"` + + EngineStorageDriver string `json:"engineStorageDriver,omitempty" yaml:"engine_storage_driver,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExtractedConfig string `json:"extractedConfig,omitempty" yaml:"extracted_config,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type MachineCollection struct { + Collection + Data []Machine `json:"data,omitempty"` +} + +type MachineClient struct { + rancherClient *RancherClient +} + +type MachineOperations interface { + List(opts *ListOpts) (*MachineCollection, error) + Create(opts *Machine) (*Machine, error) + Update(existing *Machine, updates interface{}) (*Machine, error) + ById(id string) (*Machine, error) + Delete(container *Machine) error + + ActionBootstrap(*Machine) (*PhysicalHost, error) + + ActionCreate(*Machine) (*PhysicalHost, error) + + ActionError(*Machine) (*PhysicalHost, error) + + ActionRemove(*Machine) (*PhysicalHost, error) + + ActionUpdate(*Machine) (*PhysicalHost, error) +} + +func newMachineClient(rancherClient *RancherClient) *MachineClient { + return &MachineClient{ + rancherClient: rancherClient, + } +} + +func (c *MachineClient) Create(container *Machine) (*Machine, error) { + resp := &Machine{} + err := c.rancherClient.doCreate(MACHINE_TYPE, container, resp) + return resp, err +} + +func (c *MachineClient) Update(existing *Machine, updates interface{}) (*Machine, error) { + resp := &Machine{} + err := c.rancherClient.doUpdate(MACHINE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *MachineClient) List(opts *ListOpts) (*MachineCollection, error) { + resp := &MachineCollection{} + err := c.rancherClient.doList(MACHINE_TYPE, opts, resp) + return resp, err +} + +func (c *MachineClient) ById(id string) (*Machine, error) { + resp := &Machine{} + err := c.rancherClient.doById(MACHINE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *MachineClient) Delete(container *Machine) error { + return c.rancherClient.doResourceDelete(MACHINE_TYPE, &container.Resource) +} + +func (c *MachineClient) ActionBootstrap(resource *Machine) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(MACHINE_TYPE, "bootstrap", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineClient) ActionCreate(resource *Machine) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(MACHINE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineClient) ActionError(resource *Machine) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(MACHINE_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineClient) ActionRemove(resource *Machine) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(MACHINE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineClient) ActionUpdate(resource *Machine) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(MACHINE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_machine_driver.go b/vendor/github.com/rancher/go-rancher/client/generated_machine_driver.go new file mode 100644 index 00000000..0ecc12af --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_machine_driver.go @@ -0,0 +1,163 @@ +package client + +const ( + MACHINE_DRIVER_TYPE = "machineDriver" +) + +type MachineDriver struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ErrorMessage string `json:"errorMessage,omitempty" yaml:"error_message,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Md5checksum string `json:"md5checksum,omitempty" yaml:"md5checksum,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type MachineDriverCollection struct { + Collection + Data []MachineDriver `json:"data,omitempty"` +} + +type MachineDriverClient struct { + rancherClient *RancherClient +} + +type MachineDriverOperations interface { + List(opts *ListOpts) (*MachineDriverCollection, error) + Create(opts *MachineDriver) (*MachineDriver, error) + Update(existing *MachineDriver, updates interface{}) (*MachineDriver, error) + ById(id string) (*MachineDriver, error) + Delete(container *MachineDriver) error + + ActionActivate(*MachineDriver) (*MachineDriver, error) + + ActionCreate(*MachineDriver) (*MachineDriver, error) + + ActionError(*MachineDriver, *MachineDriverErrorInput) (*MachineDriver, error) + + ActionPurge(*MachineDriver) (*MachineDriver, error) + + ActionRemove(*MachineDriver) (*MachineDriver, error) + + ActionUpdate(*MachineDriver, *MachineDriverUpdateInput) (*MachineDriver, error) +} + +func newMachineDriverClient(rancherClient *RancherClient) *MachineDriverClient { + return &MachineDriverClient{ + rancherClient: rancherClient, + } +} + +func (c *MachineDriverClient) Create(container *MachineDriver) (*MachineDriver, error) { + resp := &MachineDriver{} + err := c.rancherClient.doCreate(MACHINE_DRIVER_TYPE, container, resp) + return resp, err +} + +func (c *MachineDriverClient) Update(existing *MachineDriver, updates interface{}) (*MachineDriver, error) { + resp := &MachineDriver{} + err := c.rancherClient.doUpdate(MACHINE_DRIVER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *MachineDriverClient) List(opts *ListOpts) (*MachineDriverCollection, error) { + resp := &MachineDriverCollection{} + err := c.rancherClient.doList(MACHINE_DRIVER_TYPE, opts, resp) + return resp, err +} + +func (c *MachineDriverClient) ById(id string) (*MachineDriver, error) { + resp := &MachineDriver{} + err := c.rancherClient.doById(MACHINE_DRIVER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *MachineDriverClient) Delete(container *MachineDriver) error { + return c.rancherClient.doResourceDelete(MACHINE_DRIVER_TYPE, &container.Resource) +} + +func (c *MachineDriverClient) ActionActivate(resource *MachineDriver) (*MachineDriver, error) { + + resp := &MachineDriver{} + + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineDriverClient) ActionCreate(resource *MachineDriver) (*MachineDriver, error) { + + resp := &MachineDriver{} + + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineDriverClient) ActionError(resource *MachineDriver, input *MachineDriverErrorInput) (*MachineDriver, error) { + + resp := &MachineDriver{} + + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "error", &resource.Resource, input, resp) + + return resp, err +} + +func (c *MachineDriverClient) ActionPurge(resource *MachineDriver) (*MachineDriver, error) { + + resp := &MachineDriver{} + + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineDriverClient) ActionRemove(resource *MachineDriver) (*MachineDriver, error) { + + resp := &MachineDriver{} + + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MachineDriverClient) ActionUpdate(resource *MachineDriver, input *MachineDriverUpdateInput) (*MachineDriver, error) { + + resp := &MachineDriver{} + + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "update", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_machine_driver_error_input.go b/vendor/github.com/rancher/go-rancher/client/generated_machine_driver_error_input.go new file mode 100644 index 00000000..f00ec798 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_machine_driver_error_input.go @@ -0,0 +1,67 @@ +package client + +const ( + MACHINE_DRIVER_ERROR_INPUT_TYPE = "machineDriverErrorInput" +) + +type MachineDriverErrorInput struct { + Resource + + ErrorMessage string `json:"errorMessage,omitempty" yaml:"error_message,omitempty"` +} + +type MachineDriverErrorInputCollection struct { + Collection + Data []MachineDriverErrorInput `json:"data,omitempty"` +} + +type MachineDriverErrorInputClient struct { + rancherClient *RancherClient +} + +type MachineDriverErrorInputOperations interface { + List(opts *ListOpts) (*MachineDriverErrorInputCollection, error) + Create(opts *MachineDriverErrorInput) (*MachineDriverErrorInput, error) + Update(existing *MachineDriverErrorInput, updates interface{}) (*MachineDriverErrorInput, error) + ById(id string) (*MachineDriverErrorInput, error) + Delete(container *MachineDriverErrorInput) error +} + +func newMachineDriverErrorInputClient(rancherClient *RancherClient) *MachineDriverErrorInputClient { + return &MachineDriverErrorInputClient{ + rancherClient: rancherClient, + } +} + +func (c *MachineDriverErrorInputClient) Create(container *MachineDriverErrorInput) (*MachineDriverErrorInput, error) { + resp := &MachineDriverErrorInput{} + err := c.rancherClient.doCreate(MACHINE_DRIVER_ERROR_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *MachineDriverErrorInputClient) Update(existing *MachineDriverErrorInput, updates interface{}) (*MachineDriverErrorInput, error) { + resp := &MachineDriverErrorInput{} + err := c.rancherClient.doUpdate(MACHINE_DRIVER_ERROR_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *MachineDriverErrorInputClient) List(opts *ListOpts) (*MachineDriverErrorInputCollection, error) { + resp := &MachineDriverErrorInputCollection{} + err := c.rancherClient.doList(MACHINE_DRIVER_ERROR_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *MachineDriverErrorInputClient) ById(id string) (*MachineDriverErrorInput, error) { + resp := &MachineDriverErrorInput{} + err := c.rancherClient.doById(MACHINE_DRIVER_ERROR_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *MachineDriverErrorInputClient) Delete(container *MachineDriverErrorInput) error { + return c.rancherClient.doResourceDelete(MACHINE_DRIVER_ERROR_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_machine_driver_update_input.go b/vendor/github.com/rancher/go-rancher/client/generated_machine_driver_update_input.go new file mode 100644 index 00000000..7e046af5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_machine_driver_update_input.go @@ -0,0 +1,71 @@ +package client + +const ( + MACHINE_DRIVER_UPDATE_INPUT_TYPE = "machineDriverUpdateInput" +) + +type MachineDriverUpdateInput struct { + Resource + + Md5checksum string `json:"md5checksum,omitempty" yaml:"md5checksum,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` +} + +type MachineDriverUpdateInputCollection struct { + Collection + Data []MachineDriverUpdateInput `json:"data,omitempty"` +} + +type MachineDriverUpdateInputClient struct { + rancherClient *RancherClient +} + +type MachineDriverUpdateInputOperations interface { + List(opts *ListOpts) (*MachineDriverUpdateInputCollection, error) + Create(opts *MachineDriverUpdateInput) (*MachineDriverUpdateInput, error) + Update(existing *MachineDriverUpdateInput, updates interface{}) (*MachineDriverUpdateInput, error) + ById(id string) (*MachineDriverUpdateInput, error) + Delete(container *MachineDriverUpdateInput) error +} + +func newMachineDriverUpdateInputClient(rancherClient *RancherClient) *MachineDriverUpdateInputClient { + return &MachineDriverUpdateInputClient{ + rancherClient: rancherClient, + } +} + +func (c *MachineDriverUpdateInputClient) Create(container *MachineDriverUpdateInput) (*MachineDriverUpdateInput, error) { + resp := &MachineDriverUpdateInput{} + err := c.rancherClient.doCreate(MACHINE_DRIVER_UPDATE_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *MachineDriverUpdateInputClient) Update(existing *MachineDriverUpdateInput, updates interface{}) (*MachineDriverUpdateInput, error) { + resp := &MachineDriverUpdateInput{} + err := c.rancherClient.doUpdate(MACHINE_DRIVER_UPDATE_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *MachineDriverUpdateInputClient) List(opts *ListOpts) (*MachineDriverUpdateInputCollection, error) { + resp := &MachineDriverUpdateInputCollection{} + err := c.rancherClient.doList(MACHINE_DRIVER_UPDATE_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *MachineDriverUpdateInputClient) ById(id string) (*MachineDriverUpdateInput, error) { + resp := &MachineDriverUpdateInput{} + err := c.rancherClient.doById(MACHINE_DRIVER_UPDATE_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *MachineDriverUpdateInputClient) Delete(container *MachineDriverUpdateInput) error { + return c.rancherClient.doResourceDelete(MACHINE_DRIVER_UPDATE_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_mount.go b/vendor/github.com/rancher/go-rancher/client/generated_mount.go new file mode 100644 index 00000000..59c97630 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_mount.go @@ -0,0 +1,132 @@ +package client + +const ( + MOUNT_TYPE = "mount" +) + +type Mount struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Path string `json:"path,omitempty" yaml:"path,omitempty"` + + Permissions string `json:"permissions,omitempty" yaml:"permissions,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + VolumeId string `json:"volumeId,omitempty" yaml:"volume_id,omitempty"` +} + +type MountCollection struct { + Collection + Data []Mount `json:"data,omitempty"` +} + +type MountClient struct { + rancherClient *RancherClient +} + +type MountOperations interface { + List(opts *ListOpts) (*MountCollection, error) + Create(opts *Mount) (*Mount, error) + Update(existing *Mount, updates interface{}) (*Mount, error) + ById(id string) (*Mount, error) + Delete(container *Mount) error + + ActionCreate(*Mount) (*Mount, error) + + ActionDeactivate(*Mount) (*Mount, error) + + ActionRemove(*Mount) (*Mount, error) +} + +func newMountClient(rancherClient *RancherClient) *MountClient { + return &MountClient{ + rancherClient: rancherClient, + } +} + +func (c *MountClient) Create(container *Mount) (*Mount, error) { + resp := &Mount{} + err := c.rancherClient.doCreate(MOUNT_TYPE, container, resp) + return resp, err +} + +func (c *MountClient) Update(existing *Mount, updates interface{}) (*Mount, error) { + resp := &Mount{} + err := c.rancherClient.doUpdate(MOUNT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *MountClient) List(opts *ListOpts) (*MountCollection, error) { + resp := &MountCollection{} + err := c.rancherClient.doList(MOUNT_TYPE, opts, resp) + return resp, err +} + +func (c *MountClient) ById(id string) (*Mount, error) { + resp := &Mount{} + err := c.rancherClient.doById(MOUNT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *MountClient) Delete(container *Mount) error { + return c.rancherClient.doResourceDelete(MOUNT_TYPE, &container.Resource) +} + +func (c *MountClient) ActionCreate(resource *Mount) (*Mount, error) { + + resp := &Mount{} + + err := c.rancherClient.doAction(MOUNT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MountClient) ActionDeactivate(resource *Mount) (*Mount, error) { + + resp := &Mount{} + + err := c.rancherClient.doAction(MOUNT_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *MountClient) ActionRemove(resource *Mount) (*Mount, error) { + + resp := &Mount{} + + err := c.rancherClient.doAction(MOUNT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_network.go b/vendor/github.com/rancher/go-rancher/client/generated_network.go new file mode 100644 index 00000000..53c59be4 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_network.go @@ -0,0 +1,168 @@ +package client + +const ( + NETWORK_TYPE = "network" +) + +type Network struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type NetworkCollection struct { + Collection + Data []Network `json:"data,omitempty"` +} + +type NetworkClient struct { + rancherClient *RancherClient +} + +type NetworkOperations interface { + List(opts *ListOpts) (*NetworkCollection, error) + Create(opts *Network) (*Network, error) + Update(existing *Network, updates interface{}) (*Network, error) + ById(id string) (*Network, error) + Delete(container *Network) error + + ActionActivate(*Network) (*Network, error) + + ActionCreate(*Network) (*Network, error) + + ActionDeactivate(*Network) (*Network, error) + + ActionPurge(*Network) (*Network, error) + + ActionRemove(*Network) (*Network, error) + + ActionRestore(*Network) (*Network, error) + + ActionUpdate(*Network) (*Network, error) +} + +func newNetworkClient(rancherClient *RancherClient) *NetworkClient { + return &NetworkClient{ + rancherClient: rancherClient, + } +} + +func (c *NetworkClient) Create(container *Network) (*Network, error) { + resp := &Network{} + err := c.rancherClient.doCreate(NETWORK_TYPE, container, resp) + return resp, err +} + +func (c *NetworkClient) Update(existing *Network, updates interface{}) (*Network, error) { + resp := &Network{} + err := c.rancherClient.doUpdate(NETWORK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *NetworkClient) List(opts *ListOpts) (*NetworkCollection, error) { + resp := &NetworkCollection{} + err := c.rancherClient.doList(NETWORK_TYPE, opts, resp) + return resp, err +} + +func (c *NetworkClient) ById(id string) (*Network, error) { + resp := &Network{} + err := c.rancherClient.doById(NETWORK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *NetworkClient) Delete(container *Network) error { + return c.rancherClient.doResourceDelete(NETWORK_TYPE, &container.Resource) +} + +func (c *NetworkClient) ActionActivate(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *NetworkClient) ActionCreate(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *NetworkClient) ActionDeactivate(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *NetworkClient) ActionPurge(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *NetworkClient) ActionRemove(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *NetworkClient) ActionRestore(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *NetworkClient) ActionUpdate(resource *Network) (*Network, error) { + + resp := &Network{} + + err := c.rancherClient.doAction(NETWORK_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_openldapconfig.go b/vendor/github.com/rancher/go-rancher/client/generated_openldapconfig.go new file mode 100644 index 00000000..7b24f413 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_openldapconfig.go @@ -0,0 +1,109 @@ +package client + +const ( + OPENLDAPCONFIG_TYPE = "openldapconfig" +) + +type Openldapconfig struct { + Resource + + AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"` + + ConnectionTimeout int64 `json:"connectionTimeout,omitempty" yaml:"connection_timeout,omitempty"` + + Domain string `json:"domain,omitempty" yaml:"domain,omitempty"` + + Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` + + GroupMemberMappingAttribute string `json:"groupMemberMappingAttribute,omitempty" yaml:"group_member_mapping_attribute,omitempty"` + + GroupNameField string `json:"groupNameField,omitempty" yaml:"group_name_field,omitempty"` + + GroupObjectClass string `json:"groupObjectClass,omitempty" yaml:"group_object_class,omitempty"` + + GroupSearchField string `json:"groupSearchField,omitempty" yaml:"group_search_field,omitempty"` + + LoginDomain string `json:"loginDomain,omitempty" yaml:"login_domain,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + Server string `json:"server,omitempty" yaml:"server,omitempty"` + + ServiceAccountPassword string `json:"serviceAccountPassword,omitempty" yaml:"service_account_password,omitempty"` + + ServiceAccountUsername string `json:"serviceAccountUsername,omitempty" yaml:"service_account_username,omitempty"` + + Tls bool `json:"tls,omitempty" yaml:"tls,omitempty"` + + UserDisabledBitMask int64 `json:"userDisabledBitMask,omitempty" yaml:"user_disabled_bit_mask,omitempty"` + + UserEnabledAttribute string `json:"userEnabledAttribute,omitempty" yaml:"user_enabled_attribute,omitempty"` + + UserLoginField string `json:"userLoginField,omitempty" yaml:"user_login_field,omitempty"` + + UserMemberAttribute string `json:"userMemberAttribute,omitempty" yaml:"user_member_attribute,omitempty"` + + UserNameField string `json:"userNameField,omitempty" yaml:"user_name_field,omitempty"` + + UserObjectClass string `json:"userObjectClass,omitempty" yaml:"user_object_class,omitempty"` + + UserSearchField string `json:"userSearchField,omitempty" yaml:"user_search_field,omitempty"` +} + +type OpenldapconfigCollection struct { + Collection + Data []Openldapconfig `json:"data,omitempty"` +} + +type OpenldapconfigClient struct { + rancherClient *RancherClient +} + +type OpenldapconfigOperations interface { + List(opts *ListOpts) (*OpenldapconfigCollection, error) + Create(opts *Openldapconfig) (*Openldapconfig, error) + Update(existing *Openldapconfig, updates interface{}) (*Openldapconfig, error) + ById(id string) (*Openldapconfig, error) + Delete(container *Openldapconfig) error +} + +func newOpenldapconfigClient(rancherClient *RancherClient) *OpenldapconfigClient { + return &OpenldapconfigClient{ + rancherClient: rancherClient, + } +} + +func (c *OpenldapconfigClient) Create(container *Openldapconfig) (*Openldapconfig, error) { + resp := &Openldapconfig{} + err := c.rancherClient.doCreate(OPENLDAPCONFIG_TYPE, container, resp) + return resp, err +} + +func (c *OpenldapconfigClient) Update(existing *Openldapconfig, updates interface{}) (*Openldapconfig, error) { + resp := &Openldapconfig{} + err := c.rancherClient.doUpdate(OPENLDAPCONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *OpenldapconfigClient) List(opts *ListOpts) (*OpenldapconfigCollection, error) { + resp := &OpenldapconfigCollection{} + err := c.rancherClient.doList(OPENLDAPCONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *OpenldapconfigClient) ById(id string) (*Openldapconfig, error) { + resp := &Openldapconfig{} + err := c.rancherClient.doById(OPENLDAPCONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *OpenldapconfigClient) Delete(container *Openldapconfig) error { + return c.rancherClient.doResourceDelete(OPENLDAPCONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_openstack_config.go b/vendor/github.com/rancher/go-rancher/client/generated_openstack_config.go new file mode 100644 index 00000000..db914acf --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_openstack_config.go @@ -0,0 +1,107 @@ +package client + +const ( + OPENSTACK_CONFIG_TYPE = "openstackConfig" +) + +type OpenstackConfig struct { + Resource + + AuthUrl string `json:"authUrl,omitempty" yaml:"auth_url,omitempty"` + + AvailabilityZone string `json:"availabilityZone,omitempty" yaml:"availability_zone,omitempty"` + + DomainId string `json:"domainId,omitempty" yaml:"domain_id,omitempty"` + + DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"` + + EndpointType string `json:"endpointType,omitempty" yaml:"endpoint_type,omitempty"` + + FlavorId string `json:"flavorId,omitempty" yaml:"flavor_id,omitempty"` + + FlavorName string `json:"flavorName,omitempty" yaml:"flavor_name,omitempty"` + + FloatingipPool string `json:"floatingipPool,omitempty" yaml:"floatingip_pool,omitempty"` + + ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"` + + ImageName string `json:"imageName,omitempty" yaml:"image_name,omitempty"` + + Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty"` + + NetId string `json:"netId,omitempty" yaml:"net_id,omitempty"` + + NetName string `json:"netName,omitempty" yaml:"net_name,omitempty"` + + Password string `json:"password,omitempty" yaml:"password,omitempty"` + + Region string `json:"region,omitempty" yaml:"region,omitempty"` + + SecGroups string `json:"secGroups,omitempty" yaml:"sec_groups,omitempty"` + + SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"` + + SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"` + + TenantId string `json:"tenantId,omitempty" yaml:"tenant_id,omitempty"` + + TenantName string `json:"tenantName,omitempty" yaml:"tenant_name,omitempty"` + + Username string `json:"username,omitempty" yaml:"username,omitempty"` +} + +type OpenstackConfigCollection struct { + Collection + Data []OpenstackConfig `json:"data,omitempty"` +} + +type OpenstackConfigClient struct { + rancherClient *RancherClient +} + +type OpenstackConfigOperations interface { + List(opts *ListOpts) (*OpenstackConfigCollection, error) + Create(opts *OpenstackConfig) (*OpenstackConfig, error) + Update(existing *OpenstackConfig, updates interface{}) (*OpenstackConfig, error) + ById(id string) (*OpenstackConfig, error) + Delete(container *OpenstackConfig) error +} + +func newOpenstackConfigClient(rancherClient *RancherClient) *OpenstackConfigClient { + return &OpenstackConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *OpenstackConfigClient) Create(container *OpenstackConfig) (*OpenstackConfig, error) { + resp := &OpenstackConfig{} + err := c.rancherClient.doCreate(OPENSTACK_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *OpenstackConfigClient) Update(existing *OpenstackConfig, updates interface{}) (*OpenstackConfig, error) { + resp := &OpenstackConfig{} + err := c.rancherClient.doUpdate(OPENSTACK_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *OpenstackConfigClient) List(opts *ListOpts) (*OpenstackConfigCollection, error) { + resp := &OpenstackConfigCollection{} + err := c.rancherClient.doList(OPENSTACK_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *OpenstackConfigClient) ById(id string) (*OpenstackConfig, error) { + resp := &OpenstackConfig{} + err := c.rancherClient.doById(OPENSTACK_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *OpenstackConfigClient) Delete(container *OpenstackConfig) error { + return c.rancherClient.doResourceDelete(OPENSTACK_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_packet_config.go b/vendor/github.com/rancher/go-rancher/client/generated_packet_config.go new file mode 100644 index 00000000..f0d03e51 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_packet_config.go @@ -0,0 +1,77 @@ +package client + +const ( + PACKET_CONFIG_TYPE = "packetConfig" +) + +type PacketConfig struct { + Resource + + ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"` + + BillingCycle string `json:"billingCycle,omitempty" yaml:"billing_cycle,omitempty"` + + FacilityCode string `json:"facilityCode,omitempty" yaml:"facility_code,omitempty"` + + Os string `json:"os,omitempty" yaml:"os,omitempty"` + + Plan string `json:"plan,omitempty" yaml:"plan,omitempty"` + + ProjectId string `json:"projectId,omitempty" yaml:"project_id,omitempty"` +} + +type PacketConfigCollection struct { + Collection + Data []PacketConfig `json:"data,omitempty"` +} + +type PacketConfigClient struct { + rancherClient *RancherClient +} + +type PacketConfigOperations interface { + List(opts *ListOpts) (*PacketConfigCollection, error) + Create(opts *PacketConfig) (*PacketConfig, error) + Update(existing *PacketConfig, updates interface{}) (*PacketConfig, error) + ById(id string) (*PacketConfig, error) + Delete(container *PacketConfig) error +} + +func newPacketConfigClient(rancherClient *RancherClient) *PacketConfigClient { + return &PacketConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *PacketConfigClient) Create(container *PacketConfig) (*PacketConfig, error) { + resp := &PacketConfig{} + err := c.rancherClient.doCreate(PACKET_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *PacketConfigClient) Update(existing *PacketConfig, updates interface{}) (*PacketConfig, error) { + resp := &PacketConfig{} + err := c.rancherClient.doUpdate(PACKET_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PacketConfigClient) List(opts *ListOpts) (*PacketConfigCollection, error) { + resp := &PacketConfigCollection{} + err := c.rancherClient.doList(PACKET_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *PacketConfigClient) ById(id string) (*PacketConfig, error) { + resp := &PacketConfig{} + err := c.rancherClient.doById(PACKET_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PacketConfigClient) Delete(container *PacketConfig) error { + return c.rancherClient.doResourceDelete(PACKET_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_password.go b/vendor/github.com/rancher/go-rancher/client/generated_password.go new file mode 100644 index 00000000..427eca31 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_password.go @@ -0,0 +1,172 @@ +package client + +const ( + PASSWORD_TYPE = "password" +) + +type Password struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type PasswordCollection struct { + Collection + Data []Password `json:"data,omitempty"` +} + +type PasswordClient struct { + rancherClient *RancherClient +} + +type PasswordOperations interface { + List(opts *ListOpts) (*PasswordCollection, error) + Create(opts *Password) (*Password, error) + Update(existing *Password, updates interface{}) (*Password, error) + ById(id string) (*Password, error) + Delete(container *Password) error + + ActionActivate(*Password) (*Credential, error) + + ActionChangesecret(*Password, *ChangeSecretInput) (*ChangeSecretInput, error) + + ActionCreate(*Password) (*Credential, error) + + ActionDeactivate(*Password) (*Credential, error) + + ActionPurge(*Password) (*Credential, error) + + ActionRemove(*Password) (*Credential, error) + + ActionUpdate(*Password) (*Credential, error) +} + +func newPasswordClient(rancherClient *RancherClient) *PasswordClient { + return &PasswordClient{ + rancherClient: rancherClient, + } +} + +func (c *PasswordClient) Create(container *Password) (*Password, error) { + resp := &Password{} + err := c.rancherClient.doCreate(PASSWORD_TYPE, container, resp) + return resp, err +} + +func (c *PasswordClient) Update(existing *Password, updates interface{}) (*Password, error) { + resp := &Password{} + err := c.rancherClient.doUpdate(PASSWORD_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PasswordClient) List(opts *ListOpts) (*PasswordCollection, error) { + resp := &PasswordCollection{} + err := c.rancherClient.doList(PASSWORD_TYPE, opts, resp) + return resp, err +} + +func (c *PasswordClient) ById(id string) (*Password, error) { + resp := &Password{} + err := c.rancherClient.doById(PASSWORD_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PasswordClient) Delete(container *Password) error { + return c.rancherClient.doResourceDelete(PASSWORD_TYPE, &container.Resource) +} + +func (c *PasswordClient) ActionActivate(resource *Password) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PasswordClient) ActionChangesecret(resource *Password, input *ChangeSecretInput) (*ChangeSecretInput, error) { + + resp := &ChangeSecretInput{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "changesecret", &resource.Resource, input, resp) + + return resp, err +} + +func (c *PasswordClient) ActionCreate(resource *Password) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PasswordClient) ActionDeactivate(resource *Password) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PasswordClient) ActionPurge(resource *Password) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PasswordClient) ActionRemove(resource *Password) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PasswordClient) ActionUpdate(resource *Password) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(PASSWORD_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_physical_host.go b/vendor/github.com/rancher/go-rancher/client/generated_physical_host.go new file mode 100644 index 00000000..99b62367 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_physical_host.go @@ -0,0 +1,150 @@ +package client + +const ( + PHYSICAL_HOST_TYPE = "physicalHost" +) + +type PhysicalHost struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type PhysicalHostCollection struct { + Collection + Data []PhysicalHost `json:"data,omitempty"` +} + +type PhysicalHostClient struct { + rancherClient *RancherClient +} + +type PhysicalHostOperations interface { + List(opts *ListOpts) (*PhysicalHostCollection, error) + Create(opts *PhysicalHost) (*PhysicalHost, error) + Update(existing *PhysicalHost, updates interface{}) (*PhysicalHost, error) + ById(id string) (*PhysicalHost, error) + Delete(container *PhysicalHost) error + + ActionBootstrap(*PhysicalHost) (*PhysicalHost, error) + + ActionCreate(*PhysicalHost) (*PhysicalHost, error) + + ActionError(*PhysicalHost) (*PhysicalHost, error) + + ActionRemove(*PhysicalHost) (*PhysicalHost, error) + + ActionUpdate(*PhysicalHost) (*PhysicalHost, error) +} + +func newPhysicalHostClient(rancherClient *RancherClient) *PhysicalHostClient { + return &PhysicalHostClient{ + rancherClient: rancherClient, + } +} + +func (c *PhysicalHostClient) Create(container *PhysicalHost) (*PhysicalHost, error) { + resp := &PhysicalHost{} + err := c.rancherClient.doCreate(PHYSICAL_HOST_TYPE, container, resp) + return resp, err +} + +func (c *PhysicalHostClient) Update(existing *PhysicalHost, updates interface{}) (*PhysicalHost, error) { + resp := &PhysicalHost{} + err := c.rancherClient.doUpdate(PHYSICAL_HOST_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PhysicalHostClient) List(opts *ListOpts) (*PhysicalHostCollection, error) { + resp := &PhysicalHostCollection{} + err := c.rancherClient.doList(PHYSICAL_HOST_TYPE, opts, resp) + return resp, err +} + +func (c *PhysicalHostClient) ById(id string) (*PhysicalHost, error) { + resp := &PhysicalHost{} + err := c.rancherClient.doById(PHYSICAL_HOST_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PhysicalHostClient) Delete(container *PhysicalHost) error { + return c.rancherClient.doResourceDelete(PHYSICAL_HOST_TYPE, &container.Resource) +} + +func (c *PhysicalHostClient) ActionBootstrap(resource *PhysicalHost) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(PHYSICAL_HOST_TYPE, "bootstrap", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PhysicalHostClient) ActionCreate(resource *PhysicalHost) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(PHYSICAL_HOST_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PhysicalHostClient) ActionError(resource *PhysicalHost) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(PHYSICAL_HOST_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PhysicalHostClient) ActionRemove(resource *PhysicalHost) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(PHYSICAL_HOST_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PhysicalHostClient) ActionUpdate(resource *PhysicalHost) (*PhysicalHost, error) { + + resp := &PhysicalHost{} + + err := c.rancherClient.doAction(PHYSICAL_HOST_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_port.go b/vendor/github.com/rancher/go-rancher/client/generated_port.go new file mode 100644 index 00000000..739fd836 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_port.go @@ -0,0 +1,180 @@ +package client + +const ( + PORT_TYPE = "port" +) + +type Port struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PrivateIpAddressId string `json:"privateIpAddressId,omitempty" yaml:"private_ip_address_id,omitempty"` + + PrivatePort int64 `json:"privatePort,omitempty" yaml:"private_port,omitempty"` + + Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"` + + PublicIpAddressId string `json:"publicIpAddressId,omitempty" yaml:"public_ip_address_id,omitempty"` + + PublicPort int64 `json:"publicPort,omitempty" yaml:"public_port,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type PortCollection struct { + Collection + Data []Port `json:"data,omitempty"` +} + +type PortClient struct { + rancherClient *RancherClient +} + +type PortOperations interface { + List(opts *ListOpts) (*PortCollection, error) + Create(opts *Port) (*Port, error) + Update(existing *Port, updates interface{}) (*Port, error) + ById(id string) (*Port, error) + Delete(container *Port) error + + ActionActivate(*Port) (*Port, error) + + ActionCreate(*Port) (*Port, error) + + ActionDeactivate(*Port) (*Port, error) + + ActionPurge(*Port) (*Port, error) + + ActionRemove(*Port) (*Port, error) + + ActionRestore(*Port) (*Port, error) + + ActionUpdate(*Port) (*Port, error) +} + +func newPortClient(rancherClient *RancherClient) *PortClient { + return &PortClient{ + rancherClient: rancherClient, + } +} + +func (c *PortClient) Create(container *Port) (*Port, error) { + resp := &Port{} + err := c.rancherClient.doCreate(PORT_TYPE, container, resp) + return resp, err +} + +func (c *PortClient) Update(existing *Port, updates interface{}) (*Port, error) { + resp := &Port{} + err := c.rancherClient.doUpdate(PORT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PortClient) List(opts *ListOpts) (*PortCollection, error) { + resp := &PortCollection{} + err := c.rancherClient.doList(PORT_TYPE, opts, resp) + return resp, err +} + +func (c *PortClient) ById(id string) (*Port, error) { + resp := &Port{} + err := c.rancherClient.doById(PORT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PortClient) Delete(container *Port) error { + return c.rancherClient.doResourceDelete(PORT_TYPE, &container.Resource) +} + +func (c *PortClient) ActionActivate(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PortClient) ActionCreate(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PortClient) ActionDeactivate(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PortClient) ActionPurge(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PortClient) ActionRemove(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PortClient) ActionRestore(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *PortClient) ActionUpdate(resource *Port) (*Port, error) { + + resp := &Port{} + + err := c.rancherClient.doAction(PORT_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_process_definition.go b/vendor/github.com/rancher/go-rancher/client/generated_process_definition.go new file mode 100644 index 00000000..e6403303 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_process_definition.go @@ -0,0 +1,79 @@ +package client + +const ( + PROCESS_DEFINITION_TYPE = "processDefinition" +) + +type ProcessDefinition struct { + Resource + + ExtensionBased bool `json:"extensionBased,omitempty" yaml:"extension_based,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PostProcessListeners interface{} `json:"postProcessListeners,omitempty" yaml:"post_process_listeners,omitempty"` + + PreProcessListeners interface{} `json:"preProcessListeners,omitempty" yaml:"pre_process_listeners,omitempty"` + + ProcessHandlers interface{} `json:"processHandlers,omitempty" yaml:"process_handlers,omitempty"` + + ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"` + + StateTransitions []interface{} `json:"stateTransitions,omitempty" yaml:"state_transitions,omitempty"` +} + +type ProcessDefinitionCollection struct { + Collection + Data []ProcessDefinition `json:"data,omitempty"` +} + +type ProcessDefinitionClient struct { + rancherClient *RancherClient +} + +type ProcessDefinitionOperations interface { + List(opts *ListOpts) (*ProcessDefinitionCollection, error) + Create(opts *ProcessDefinition) (*ProcessDefinition, error) + Update(existing *ProcessDefinition, updates interface{}) (*ProcessDefinition, error) + ById(id string) (*ProcessDefinition, error) + Delete(container *ProcessDefinition) error +} + +func newProcessDefinitionClient(rancherClient *RancherClient) *ProcessDefinitionClient { + return &ProcessDefinitionClient{ + rancherClient: rancherClient, + } +} + +func (c *ProcessDefinitionClient) Create(container *ProcessDefinition) (*ProcessDefinition, error) { + resp := &ProcessDefinition{} + err := c.rancherClient.doCreate(PROCESS_DEFINITION_TYPE, container, resp) + return resp, err +} + +func (c *ProcessDefinitionClient) Update(existing *ProcessDefinition, updates interface{}) (*ProcessDefinition, error) { + resp := &ProcessDefinition{} + err := c.rancherClient.doUpdate(PROCESS_DEFINITION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ProcessDefinitionClient) List(opts *ListOpts) (*ProcessDefinitionCollection, error) { + resp := &ProcessDefinitionCollection{} + err := c.rancherClient.doList(PROCESS_DEFINITION_TYPE, opts, resp) + return resp, err +} + +func (c *ProcessDefinitionClient) ById(id string) (*ProcessDefinition, error) { + resp := &ProcessDefinition{} + err := c.rancherClient.doById(PROCESS_DEFINITION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ProcessDefinitionClient) Delete(container *ProcessDefinition) error { + return c.rancherClient.doResourceDelete(PROCESS_DEFINITION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_process_execution.go b/vendor/github.com/rancher/go-rancher/client/generated_process_execution.go new file mode 100644 index 00000000..7a046619 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_process_execution.go @@ -0,0 +1,71 @@ +package client + +const ( + PROCESS_EXECUTION_TYPE = "processExecution" +) + +type ProcessExecution struct { + Resource + + Log map[string]interface{} `json:"log,omitempty" yaml:"log,omitempty"` + + ProcessInstanceId string `json:"processInstanceId,omitempty" yaml:"process_instance_id,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ProcessExecutionCollection struct { + Collection + Data []ProcessExecution `json:"data,omitempty"` +} + +type ProcessExecutionClient struct { + rancherClient *RancherClient +} + +type ProcessExecutionOperations interface { + List(opts *ListOpts) (*ProcessExecutionCollection, error) + Create(opts *ProcessExecution) (*ProcessExecution, error) + Update(existing *ProcessExecution, updates interface{}) (*ProcessExecution, error) + ById(id string) (*ProcessExecution, error) + Delete(container *ProcessExecution) error +} + +func newProcessExecutionClient(rancherClient *RancherClient) *ProcessExecutionClient { + return &ProcessExecutionClient{ + rancherClient: rancherClient, + } +} + +func (c *ProcessExecutionClient) Create(container *ProcessExecution) (*ProcessExecution, error) { + resp := &ProcessExecution{} + err := c.rancherClient.doCreate(PROCESS_EXECUTION_TYPE, container, resp) + return resp, err +} + +func (c *ProcessExecutionClient) Update(existing *ProcessExecution, updates interface{}) (*ProcessExecution, error) { + resp := &ProcessExecution{} + err := c.rancherClient.doUpdate(PROCESS_EXECUTION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ProcessExecutionClient) List(opts *ListOpts) (*ProcessExecutionCollection, error) { + resp := &ProcessExecutionCollection{} + err := c.rancherClient.doList(PROCESS_EXECUTION_TYPE, opts, resp) + return resp, err +} + +func (c *ProcessExecutionClient) ById(id string) (*ProcessExecution, error) { + resp := &ProcessExecution{} + err := c.rancherClient.doById(PROCESS_EXECUTION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ProcessExecutionClient) Delete(container *ProcessExecution) error { + return c.rancherClient.doResourceDelete(PROCESS_EXECUTION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_process_instance.go b/vendor/github.com/rancher/go-rancher/client/generated_process_instance.go new file mode 100644 index 00000000..6ba08dfe --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_process_instance.go @@ -0,0 +1,89 @@ +package client + +const ( + PROCESS_INSTANCE_TYPE = "processInstance" +) + +type ProcessInstance struct { + Resource + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + EndTime string `json:"endTime,omitempty" yaml:"end_time,omitempty"` + + ExitReason string `json:"exitReason,omitempty" yaml:"exit_reason,omitempty"` + + Phase string `json:"phase,omitempty" yaml:"phase,omitempty"` + + Priority int64 `json:"priority,omitempty" yaml:"priority,omitempty"` + + ProcessName string `json:"processName,omitempty" yaml:"process_name,omitempty"` + + ResourceId string `json:"resourceId,omitempty" yaml:"resource_id,omitempty"` + + ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"` + + Result string `json:"result,omitempty" yaml:"result,omitempty"` + + RunningProcessServerId string `json:"runningProcessServerId,omitempty" yaml:"running_process_server_id,omitempty"` + + StartProcessServerId string `json:"startProcessServerId,omitempty" yaml:"start_process_server_id,omitempty"` + + StartTime string `json:"startTime,omitempty" yaml:"start_time,omitempty"` +} + +type ProcessInstanceCollection struct { + Collection + Data []ProcessInstance `json:"data,omitempty"` +} + +type ProcessInstanceClient struct { + rancherClient *RancherClient +} + +type ProcessInstanceOperations interface { + List(opts *ListOpts) (*ProcessInstanceCollection, error) + Create(opts *ProcessInstance) (*ProcessInstance, error) + Update(existing *ProcessInstance, updates interface{}) (*ProcessInstance, error) + ById(id string) (*ProcessInstance, error) + Delete(container *ProcessInstance) error +} + +func newProcessInstanceClient(rancherClient *RancherClient) *ProcessInstanceClient { + return &ProcessInstanceClient{ + rancherClient: rancherClient, + } +} + +func (c *ProcessInstanceClient) Create(container *ProcessInstance) (*ProcessInstance, error) { + resp := &ProcessInstance{} + err := c.rancherClient.doCreate(PROCESS_INSTANCE_TYPE, container, resp) + return resp, err +} + +func (c *ProcessInstanceClient) Update(existing *ProcessInstance, updates interface{}) (*ProcessInstance, error) { + resp := &ProcessInstance{} + err := c.rancherClient.doUpdate(PROCESS_INSTANCE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ProcessInstanceClient) List(opts *ListOpts) (*ProcessInstanceCollection, error) { + resp := &ProcessInstanceCollection{} + err := c.rancherClient.doList(PROCESS_INSTANCE_TYPE, opts, resp) + return resp, err +} + +func (c *ProcessInstanceClient) ById(id string) (*ProcessInstance, error) { + resp := &ProcessInstance{} + err := c.rancherClient.doById(PROCESS_INSTANCE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ProcessInstanceClient) Delete(container *ProcessInstance) error { + return c.rancherClient.doResourceDelete(PROCESS_INSTANCE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_project.go b/vendor/github.com/rancher/go-rancher/client/generated_project.go new file mode 100644 index 00000000..eb24acb0 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_project.go @@ -0,0 +1,187 @@ +package client + +const ( + PROJECT_TYPE = "project" +) + +type Project struct { + Resource + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Kubernetes bool `json:"kubernetes,omitempty" yaml:"kubernetes,omitempty"` + + Members []interface{} `json:"members,omitempty" yaml:"members,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicDns bool `json:"publicDns,omitempty" yaml:"public_dns,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ServicesPortRange *ServicesPortRange `json:"servicesPortRange,omitempty" yaml:"services_port_range,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Swarm bool `json:"swarm,omitempty" yaml:"swarm,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ProjectCollection struct { + Collection + Data []Project `json:"data,omitempty"` +} + +type ProjectClient struct { + rancherClient *RancherClient +} + +type ProjectOperations interface { + List(opts *ListOpts) (*ProjectCollection, error) + Create(opts *Project) (*Project, error) + Update(existing *Project, updates interface{}) (*Project, error) + ById(id string) (*Project, error) + Delete(container *Project) error + + ActionActivate(*Project) (*Account, error) + + ActionCreate(*Project) (*Account, error) + + ActionDeactivate(*Project) (*Account, error) + + ActionPurge(*Project) (*Account, error) + + ActionRemove(*Project) (*Account, error) + + ActionRestore(*Project) (*Account, error) + + ActionSetmembers(*Project, *SetProjectMembersInput) (*SetProjectMembersInput, error) + + ActionUpdate(*Project) (*Account, error) +} + +func newProjectClient(rancherClient *RancherClient) *ProjectClient { + return &ProjectClient{ + rancherClient: rancherClient, + } +} + +func (c *ProjectClient) Create(container *Project) (*Project, error) { + resp := &Project{} + err := c.rancherClient.doCreate(PROJECT_TYPE, container, resp) + return resp, err +} + +func (c *ProjectClient) Update(existing *Project, updates interface{}) (*Project, error) { + resp := &Project{} + err := c.rancherClient.doUpdate(PROJECT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ProjectClient) List(opts *ListOpts) (*ProjectCollection, error) { + resp := &ProjectCollection{} + err := c.rancherClient.doList(PROJECT_TYPE, opts, resp) + return resp, err +} + +func (c *ProjectClient) ById(id string) (*Project, error) { + resp := &Project{} + err := c.rancherClient.doById(PROJECT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ProjectClient) Delete(container *Project) error { + return c.rancherClient.doResourceDelete(PROJECT_TYPE, &container.Resource) +} + +func (c *ProjectClient) ActionActivate(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectClient) ActionCreate(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectClient) ActionDeactivate(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectClient) ActionPurge(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectClient) ActionRemove(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectClient) ActionRestore(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectClient) ActionSetmembers(resource *Project, input *SetProjectMembersInput) (*SetProjectMembersInput, error) { + + resp := &SetProjectMembersInput{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "setmembers", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ProjectClient) ActionUpdate(resource *Project) (*Account, error) { + + resp := &Account{} + + err := c.rancherClient.doAction(PROJECT_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_project_member.go b/vendor/github.com/rancher/go-rancher/client/generated_project_member.go new file mode 100644 index 00000000..82ba10bd --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_project_member.go @@ -0,0 +1,174 @@ +package client + +const ( + PROJECT_MEMBER_TYPE = "projectMember" +) + +type ProjectMember struct { + Resource + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + ProjectId string `json:"projectId,omitempty" yaml:"project_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + Role string `json:"role,omitempty" yaml:"role,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ProjectMemberCollection struct { + Collection + Data []ProjectMember `json:"data,omitempty"` +} + +type ProjectMemberClient struct { + rancherClient *RancherClient +} + +type ProjectMemberOperations interface { + List(opts *ListOpts) (*ProjectMemberCollection, error) + Create(opts *ProjectMember) (*ProjectMember, error) + Update(existing *ProjectMember, updates interface{}) (*ProjectMember, error) + ById(id string) (*ProjectMember, error) + Delete(container *ProjectMember) error + + ActionActivate(*ProjectMember) (*ProjectMember, error) + + ActionCreate(*ProjectMember) (*ProjectMember, error) + + ActionDeactivate(*ProjectMember) (*ProjectMember, error) + + ActionPurge(*ProjectMember) (*ProjectMember, error) + + ActionRemove(*ProjectMember) (*ProjectMember, error) + + ActionRestore(*ProjectMember) (*ProjectMember, error) + + ActionUpdate(*ProjectMember) (*ProjectMember, error) +} + +func newProjectMemberClient(rancherClient *RancherClient) *ProjectMemberClient { + return &ProjectMemberClient{ + rancherClient: rancherClient, + } +} + +func (c *ProjectMemberClient) Create(container *ProjectMember) (*ProjectMember, error) { + resp := &ProjectMember{} + err := c.rancherClient.doCreate(PROJECT_MEMBER_TYPE, container, resp) + return resp, err +} + +func (c *ProjectMemberClient) Update(existing *ProjectMember, updates interface{}) (*ProjectMember, error) { + resp := &ProjectMember{} + err := c.rancherClient.doUpdate(PROJECT_MEMBER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ProjectMemberClient) List(opts *ListOpts) (*ProjectMemberCollection, error) { + resp := &ProjectMemberCollection{} + err := c.rancherClient.doList(PROJECT_MEMBER_TYPE, opts, resp) + return resp, err +} + +func (c *ProjectMemberClient) ById(id string) (*ProjectMember, error) { + resp := &ProjectMember{} + err := c.rancherClient.doById(PROJECT_MEMBER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ProjectMemberClient) Delete(container *ProjectMember) error { + return c.rancherClient.doResourceDelete(PROJECT_MEMBER_TYPE, &container.Resource) +} + +func (c *ProjectMemberClient) ActionActivate(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectMemberClient) ActionCreate(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectMemberClient) ActionDeactivate(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectMemberClient) ActionPurge(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectMemberClient) ActionRemove(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectMemberClient) ActionRestore(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ProjectMemberClient) ActionUpdate(resource *ProjectMember) (*ProjectMember, error) { + + resp := &ProjectMember{} + + err := c.rancherClient.doAction(PROJECT_MEMBER_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_public_endpoint.go b/vendor/github.com/rancher/go-rancher/client/generated_public_endpoint.go new file mode 100644 index 00000000..3d85858e --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_public_endpoint.go @@ -0,0 +1,75 @@ +package client + +const ( + PUBLIC_ENDPOINT_TYPE = "publicEndpoint" +) + +type PublicEndpoint struct { + Resource + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + IpAddress string `json:"ipAddress,omitempty" yaml:"ip_address,omitempty"` + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` +} + +type PublicEndpointCollection struct { + Collection + Data []PublicEndpoint `json:"data,omitempty"` +} + +type PublicEndpointClient struct { + rancherClient *RancherClient +} + +type PublicEndpointOperations interface { + List(opts *ListOpts) (*PublicEndpointCollection, error) + Create(opts *PublicEndpoint) (*PublicEndpoint, error) + Update(existing *PublicEndpoint, updates interface{}) (*PublicEndpoint, error) + ById(id string) (*PublicEndpoint, error) + Delete(container *PublicEndpoint) error +} + +func newPublicEndpointClient(rancherClient *RancherClient) *PublicEndpointClient { + return &PublicEndpointClient{ + rancherClient: rancherClient, + } +} + +func (c *PublicEndpointClient) Create(container *PublicEndpoint) (*PublicEndpoint, error) { + resp := &PublicEndpoint{} + err := c.rancherClient.doCreate(PUBLIC_ENDPOINT_TYPE, container, resp) + return resp, err +} + +func (c *PublicEndpointClient) Update(existing *PublicEndpoint, updates interface{}) (*PublicEndpoint, error) { + resp := &PublicEndpoint{} + err := c.rancherClient.doUpdate(PUBLIC_ENDPOINT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PublicEndpointClient) List(opts *ListOpts) (*PublicEndpointCollection, error) { + resp := &PublicEndpointCollection{} + err := c.rancherClient.doList(PUBLIC_ENDPOINT_TYPE, opts, resp) + return resp, err +} + +func (c *PublicEndpointClient) ById(id string) (*PublicEndpoint, error) { + resp := &PublicEndpoint{} + err := c.rancherClient.doById(PUBLIC_ENDPOINT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PublicEndpointClient) Delete(container *PublicEndpoint) error { + return c.rancherClient.doResourceDelete(PUBLIC_ENDPOINT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_publish.go b/vendor/github.com/rancher/go-rancher/client/generated_publish.go new file mode 100644 index 00000000..9071207f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_publish.go @@ -0,0 +1,87 @@ +package client + +const ( + PUBLISH_TYPE = "publish" +) + +type Publish struct { + Resource + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PreviousIds []string `json:"previousIds,omitempty" yaml:"previous_ids,omitempty"` + + Publisher string `json:"publisher,omitempty" yaml:"publisher,omitempty"` + + ResourceId string `json:"resourceId,omitempty" yaml:"resource_id,omitempty"` + + ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"` + + Time int64 `json:"time,omitempty" yaml:"time,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningInternalMessage string `json:"transitioningInternalMessage,omitempty" yaml:"transitioning_internal_message,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` +} + +type PublishCollection struct { + Collection + Data []Publish `json:"data,omitempty"` +} + +type PublishClient struct { + rancherClient *RancherClient +} + +type PublishOperations interface { + List(opts *ListOpts) (*PublishCollection, error) + Create(opts *Publish) (*Publish, error) + Update(existing *Publish, updates interface{}) (*Publish, error) + ById(id string) (*Publish, error) + Delete(container *Publish) error +} + +func newPublishClient(rancherClient *RancherClient) *PublishClient { + return &PublishClient{ + rancherClient: rancherClient, + } +} + +func (c *PublishClient) Create(container *Publish) (*Publish, error) { + resp := &Publish{} + err := c.rancherClient.doCreate(PUBLISH_TYPE, container, resp) + return resp, err +} + +func (c *PublishClient) Update(existing *Publish, updates interface{}) (*Publish, error) { + resp := &Publish{} + err := c.rancherClient.doUpdate(PUBLISH_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PublishClient) List(opts *ListOpts) (*PublishCollection, error) { + resp := &PublishCollection{} + err := c.rancherClient.doList(PUBLISH_TYPE, opts, resp) + return resp, err +} + +func (c *PublishClient) ById(id string) (*Publish, error) { + resp := &Publish{} + err := c.rancherClient.doById(PUBLISH_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PublishClient) Delete(container *Publish) error { + return c.rancherClient.doResourceDelete(PUBLISH_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_pull_task.go b/vendor/github.com/rancher/go-rancher/client/generated_pull_task.go new file mode 100644 index 00000000..a077e888 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_pull_task.go @@ -0,0 +1,99 @@ +package client + +const ( + PULL_TASK_TYPE = "pullTask" +) + +type PullTask struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Image string `json:"image,omitempty" yaml:"image,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + Mode string `json:"mode,omitempty" yaml:"mode,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Status map[string]interface{} `json:"status,omitempty" yaml:"status,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type PullTaskCollection struct { + Collection + Data []PullTask `json:"data,omitempty"` +} + +type PullTaskClient struct { + rancherClient *RancherClient +} + +type PullTaskOperations interface { + List(opts *ListOpts) (*PullTaskCollection, error) + Create(opts *PullTask) (*PullTask, error) + Update(existing *PullTask, updates interface{}) (*PullTask, error) + ById(id string) (*PullTask, error) + Delete(container *PullTask) error +} + +func newPullTaskClient(rancherClient *RancherClient) *PullTaskClient { + return &PullTaskClient{ + rancherClient: rancherClient, + } +} + +func (c *PullTaskClient) Create(container *PullTask) (*PullTask, error) { + resp := &PullTask{} + err := c.rancherClient.doCreate(PULL_TASK_TYPE, container, resp) + return resp, err +} + +func (c *PullTaskClient) Update(existing *PullTask, updates interface{}) (*PullTask, error) { + resp := &PullTask{} + err := c.rancherClient.doUpdate(PULL_TASK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *PullTaskClient) List(opts *ListOpts) (*PullTaskCollection, error) { + resp := &PullTaskCollection{} + err := c.rancherClient.doList(PULL_TASK_TYPE, opts, resp) + return resp, err +} + +func (c *PullTaskClient) ById(id string) (*PullTask, error) { + resp := &PullTask{} + err := c.rancherClient.doById(PULL_TASK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *PullTaskClient) Delete(container *PullTask) error { + return c.rancherClient.doResourceDelete(PULL_TASK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_rackspace_config.go b/vendor/github.com/rancher/go-rancher/client/generated_rackspace_config.go new file mode 100644 index 00000000..868e96f4 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_rackspace_config.go @@ -0,0 +1,83 @@ +package client + +const ( + RACKSPACE_CONFIG_TYPE = "rackspaceConfig" +) + +type RackspaceConfig struct { + Resource + + ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"` + + DockerInstall string `json:"dockerInstall,omitempty" yaml:"docker_install,omitempty"` + + EndpointType string `json:"endpointType,omitempty" yaml:"endpoint_type,omitempty"` + + FlavorId string `json:"flavorId,omitempty" yaml:"flavor_id,omitempty"` + + ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"` + + Region string `json:"region,omitempty" yaml:"region,omitempty"` + + SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"` + + SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"` + + Username string `json:"username,omitempty" yaml:"username,omitempty"` +} + +type RackspaceConfigCollection struct { + Collection + Data []RackspaceConfig `json:"data,omitempty"` +} + +type RackspaceConfigClient struct { + rancherClient *RancherClient +} + +type RackspaceConfigOperations interface { + List(opts *ListOpts) (*RackspaceConfigCollection, error) + Create(opts *RackspaceConfig) (*RackspaceConfig, error) + Update(existing *RackspaceConfig, updates interface{}) (*RackspaceConfig, error) + ById(id string) (*RackspaceConfig, error) + Delete(container *RackspaceConfig) error +} + +func newRackspaceConfigClient(rancherClient *RancherClient) *RackspaceConfigClient { + return &RackspaceConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *RackspaceConfigClient) Create(container *RackspaceConfig) (*RackspaceConfig, error) { + resp := &RackspaceConfig{} + err := c.rancherClient.doCreate(RACKSPACE_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *RackspaceConfigClient) Update(existing *RackspaceConfig, updates interface{}) (*RackspaceConfig, error) { + resp := &RackspaceConfig{} + err := c.rancherClient.doUpdate(RACKSPACE_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RackspaceConfigClient) List(opts *ListOpts) (*RackspaceConfigCollection, error) { + resp := &RackspaceConfigCollection{} + err := c.rancherClient.doList(RACKSPACE_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *RackspaceConfigClient) ById(id string) (*RackspaceConfig, error) { + resp := &RackspaceConfig{} + err := c.rancherClient.doById(RACKSPACE_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RackspaceConfigClient) Delete(container *RackspaceConfig) error { + return c.rancherClient.doResourceDelete(RACKSPACE_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_recreate_on_quorum_strategy_config.go b/vendor/github.com/rancher/go-rancher/client/generated_recreate_on_quorum_strategy_config.go new file mode 100644 index 00000000..a8a89ed8 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_recreate_on_quorum_strategy_config.go @@ -0,0 +1,67 @@ +package client + +const ( + RECREATE_ON_QUORUM_STRATEGY_CONFIG_TYPE = "recreateOnQuorumStrategyConfig" +) + +type RecreateOnQuorumStrategyConfig struct { + Resource + + Quorum int64 `json:"quorum,omitempty" yaml:"quorum,omitempty"` +} + +type RecreateOnQuorumStrategyConfigCollection struct { + Collection + Data []RecreateOnQuorumStrategyConfig `json:"data,omitempty"` +} + +type RecreateOnQuorumStrategyConfigClient struct { + rancherClient *RancherClient +} + +type RecreateOnQuorumStrategyConfigOperations interface { + List(opts *ListOpts) (*RecreateOnQuorumStrategyConfigCollection, error) + Create(opts *RecreateOnQuorumStrategyConfig) (*RecreateOnQuorumStrategyConfig, error) + Update(existing *RecreateOnQuorumStrategyConfig, updates interface{}) (*RecreateOnQuorumStrategyConfig, error) + ById(id string) (*RecreateOnQuorumStrategyConfig, error) + Delete(container *RecreateOnQuorumStrategyConfig) error +} + +func newRecreateOnQuorumStrategyConfigClient(rancherClient *RancherClient) *RecreateOnQuorumStrategyConfigClient { + return &RecreateOnQuorumStrategyConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *RecreateOnQuorumStrategyConfigClient) Create(container *RecreateOnQuorumStrategyConfig) (*RecreateOnQuorumStrategyConfig, error) { + resp := &RecreateOnQuorumStrategyConfig{} + err := c.rancherClient.doCreate(RECREATE_ON_QUORUM_STRATEGY_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *RecreateOnQuorumStrategyConfigClient) Update(existing *RecreateOnQuorumStrategyConfig, updates interface{}) (*RecreateOnQuorumStrategyConfig, error) { + resp := &RecreateOnQuorumStrategyConfig{} + err := c.rancherClient.doUpdate(RECREATE_ON_QUORUM_STRATEGY_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RecreateOnQuorumStrategyConfigClient) List(opts *ListOpts) (*RecreateOnQuorumStrategyConfigCollection, error) { + resp := &RecreateOnQuorumStrategyConfigCollection{} + err := c.rancherClient.doList(RECREATE_ON_QUORUM_STRATEGY_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *RecreateOnQuorumStrategyConfigClient) ById(id string) (*RecreateOnQuorumStrategyConfig, error) { + resp := &RecreateOnQuorumStrategyConfig{} + err := c.rancherClient.doById(RECREATE_ON_QUORUM_STRATEGY_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RecreateOnQuorumStrategyConfigClient) Delete(container *RecreateOnQuorumStrategyConfig) error { + return c.rancherClient.doResourceDelete(RECREATE_ON_QUORUM_STRATEGY_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_register.go b/vendor/github.com/rancher/go-rancher/client/generated_register.go new file mode 100644 index 00000000..510cd160 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_register.go @@ -0,0 +1,108 @@ +package client + +const ( + REGISTER_TYPE = "register" +) + +type Register struct { + Resource + + AccessKey string `json:"accessKey,omitempty" yaml:"access_key,omitempty"` + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Key string `json:"key,omitempty" yaml:"key,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SecretKey string `json:"secretKey,omitempty" yaml:"secret_key,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type RegisterCollection struct { + Collection + Data []Register `json:"data,omitempty"` +} + +type RegisterClient struct { + rancherClient *RancherClient +} + +type RegisterOperations interface { + List(opts *ListOpts) (*RegisterCollection, error) + Create(opts *Register) (*Register, error) + Update(existing *Register, updates interface{}) (*Register, error) + ById(id string) (*Register, error) + Delete(container *Register) error + + ActionStop(*Register, *InstanceStop) (*Instance, error) +} + +func newRegisterClient(rancherClient *RancherClient) *RegisterClient { + return &RegisterClient{ + rancherClient: rancherClient, + } +} + +func (c *RegisterClient) Create(container *Register) (*Register, error) { + resp := &Register{} + err := c.rancherClient.doCreate(REGISTER_TYPE, container, resp) + return resp, err +} + +func (c *RegisterClient) Update(existing *Register, updates interface{}) (*Register, error) { + resp := &Register{} + err := c.rancherClient.doUpdate(REGISTER_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RegisterClient) List(opts *ListOpts) (*RegisterCollection, error) { + resp := &RegisterCollection{} + err := c.rancherClient.doList(REGISTER_TYPE, opts, resp) + return resp, err +} + +func (c *RegisterClient) ById(id string) (*Register, error) { + resp := &Register{} + err := c.rancherClient.doById(REGISTER_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RegisterClient) Delete(container *Register) error { + return c.rancherClient.doResourceDelete(REGISTER_TYPE, &container.Resource) +} + +func (c *RegisterClient) ActionStop(resource *Register, input *InstanceStop) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(REGISTER_TYPE, "stop", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_registration_token.go b/vendor/github.com/rancher/go-rancher/client/generated_registration_token.go new file mode 100644 index 00000000..01b8cd8e --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_registration_token.go @@ -0,0 +1,165 @@ +package client + +const ( + REGISTRATION_TOKEN_TYPE = "registrationToken" +) + +type RegistrationToken struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Command string `json:"command,omitempty" yaml:"command,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Image string `json:"image,omitempty" yaml:"image,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RegistrationUrl string `json:"registrationUrl,omitempty" yaml:"registration_url,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type RegistrationTokenCollection struct { + Collection + Data []RegistrationToken `json:"data,omitempty"` +} + +type RegistrationTokenClient struct { + rancherClient *RancherClient +} + +type RegistrationTokenOperations interface { + List(opts *ListOpts) (*RegistrationTokenCollection, error) + Create(opts *RegistrationToken) (*RegistrationToken, error) + Update(existing *RegistrationToken, updates interface{}) (*RegistrationToken, error) + ById(id string) (*RegistrationToken, error) + Delete(container *RegistrationToken) error + + ActionActivate(*RegistrationToken) (*Credential, error) + + ActionCreate(*RegistrationToken) (*Credential, error) + + ActionDeactivate(*RegistrationToken) (*Credential, error) + + ActionPurge(*RegistrationToken) (*Credential, error) + + ActionRemove(*RegistrationToken) (*Credential, error) + + ActionUpdate(*RegistrationToken) (*Credential, error) +} + +func newRegistrationTokenClient(rancherClient *RancherClient) *RegistrationTokenClient { + return &RegistrationTokenClient{ + rancherClient: rancherClient, + } +} + +func (c *RegistrationTokenClient) Create(container *RegistrationToken) (*RegistrationToken, error) { + resp := &RegistrationToken{} + err := c.rancherClient.doCreate(REGISTRATION_TOKEN_TYPE, container, resp) + return resp, err +} + +func (c *RegistrationTokenClient) Update(existing *RegistrationToken, updates interface{}) (*RegistrationToken, error) { + resp := &RegistrationToken{} + err := c.rancherClient.doUpdate(REGISTRATION_TOKEN_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RegistrationTokenClient) List(opts *ListOpts) (*RegistrationTokenCollection, error) { + resp := &RegistrationTokenCollection{} + err := c.rancherClient.doList(REGISTRATION_TOKEN_TYPE, opts, resp) + return resp, err +} + +func (c *RegistrationTokenClient) ById(id string) (*RegistrationToken, error) { + resp := &RegistrationToken{} + err := c.rancherClient.doById(REGISTRATION_TOKEN_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RegistrationTokenClient) Delete(container *RegistrationToken) error { + return c.rancherClient.doResourceDelete(REGISTRATION_TOKEN_TYPE, &container.Resource) +} + +func (c *RegistrationTokenClient) ActionActivate(resource *RegistrationToken) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRATION_TOKEN_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistrationTokenClient) ActionCreate(resource *RegistrationToken) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRATION_TOKEN_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistrationTokenClient) ActionDeactivate(resource *RegistrationToken) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRATION_TOKEN_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistrationTokenClient) ActionPurge(resource *RegistrationToken) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRATION_TOKEN_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistrationTokenClient) ActionRemove(resource *RegistrationToken) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRATION_TOKEN_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistrationTokenClient) ActionUpdate(resource *RegistrationToken) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRATION_TOKEN_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_registry.go b/vendor/github.com/rancher/go-rancher/client/generated_registry.go new file mode 100644 index 00000000..60180455 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_registry.go @@ -0,0 +1,174 @@ +package client + +const ( + REGISTRY_TYPE = "registry" +) + +type Registry struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + DriverName string `json:"driverName,omitempty" yaml:"driver_name,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ServerAddress string `json:"serverAddress,omitempty" yaml:"server_address,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type RegistryCollection struct { + Collection + Data []Registry `json:"data,omitempty"` +} + +type RegistryClient struct { + rancherClient *RancherClient +} + +type RegistryOperations interface { + List(opts *ListOpts) (*RegistryCollection, error) + Create(opts *Registry) (*Registry, error) + Update(existing *Registry, updates interface{}) (*Registry, error) + ById(id string) (*Registry, error) + Delete(container *Registry) error + + ActionActivate(*Registry) (*StoragePool, error) + + ActionCreate(*Registry) (*StoragePool, error) + + ActionDeactivate(*Registry) (*StoragePool, error) + + ActionPurge(*Registry) (*StoragePool, error) + + ActionRemove(*Registry) (*StoragePool, error) + + ActionRestore(*Registry) (*StoragePool, error) + + ActionUpdate(*Registry) (*StoragePool, error) +} + +func newRegistryClient(rancherClient *RancherClient) *RegistryClient { + return &RegistryClient{ + rancherClient: rancherClient, + } +} + +func (c *RegistryClient) Create(container *Registry) (*Registry, error) { + resp := &Registry{} + err := c.rancherClient.doCreate(REGISTRY_TYPE, container, resp) + return resp, err +} + +func (c *RegistryClient) Update(existing *Registry, updates interface{}) (*Registry, error) { + resp := &Registry{} + err := c.rancherClient.doUpdate(REGISTRY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RegistryClient) List(opts *ListOpts) (*RegistryCollection, error) { + resp := &RegistryCollection{} + err := c.rancherClient.doList(REGISTRY_TYPE, opts, resp) + return resp, err +} + +func (c *RegistryClient) ById(id string) (*Registry, error) { + resp := &Registry{} + err := c.rancherClient.doById(REGISTRY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RegistryClient) Delete(container *Registry) error { + return c.rancherClient.doResourceDelete(REGISTRY_TYPE, &container.Resource) +} + +func (c *RegistryClient) ActionActivate(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryClient) ActionCreate(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryClient) ActionDeactivate(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryClient) ActionPurge(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryClient) ActionRemove(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryClient) ActionRestore(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryClient) ActionUpdate(resource *Registry) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(REGISTRY_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_registry_credential.go b/vendor/github.com/rancher/go-rancher/client/generated_registry_credential.go new file mode 100644 index 00000000..e17ab42d --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_registry_credential.go @@ -0,0 +1,165 @@ +package client + +const ( + REGISTRY_CREDENTIAL_TYPE = "registryCredential" +) + +type RegistryCredential struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Email string `json:"email,omitempty" yaml:"email,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"` + + RegistryId string `json:"registryId,omitempty" yaml:"registry_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type RegistryCredentialCollection struct { + Collection + Data []RegistryCredential `json:"data,omitempty"` +} + +type RegistryCredentialClient struct { + rancherClient *RancherClient +} + +type RegistryCredentialOperations interface { + List(opts *ListOpts) (*RegistryCredentialCollection, error) + Create(opts *RegistryCredential) (*RegistryCredential, error) + Update(existing *RegistryCredential, updates interface{}) (*RegistryCredential, error) + ById(id string) (*RegistryCredential, error) + Delete(container *RegistryCredential) error + + ActionActivate(*RegistryCredential) (*Credential, error) + + ActionCreate(*RegistryCredential) (*Credential, error) + + ActionDeactivate(*RegistryCredential) (*Credential, error) + + ActionPurge(*RegistryCredential) (*Credential, error) + + ActionRemove(*RegistryCredential) (*Credential, error) + + ActionUpdate(*RegistryCredential) (*Credential, error) +} + +func newRegistryCredentialClient(rancherClient *RancherClient) *RegistryCredentialClient { + return &RegistryCredentialClient{ + rancherClient: rancherClient, + } +} + +func (c *RegistryCredentialClient) Create(container *RegistryCredential) (*RegistryCredential, error) { + resp := &RegistryCredential{} + err := c.rancherClient.doCreate(REGISTRY_CREDENTIAL_TYPE, container, resp) + return resp, err +} + +func (c *RegistryCredentialClient) Update(existing *RegistryCredential, updates interface{}) (*RegistryCredential, error) { + resp := &RegistryCredential{} + err := c.rancherClient.doUpdate(REGISTRY_CREDENTIAL_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RegistryCredentialClient) List(opts *ListOpts) (*RegistryCredentialCollection, error) { + resp := &RegistryCredentialCollection{} + err := c.rancherClient.doList(REGISTRY_CREDENTIAL_TYPE, opts, resp) + return resp, err +} + +func (c *RegistryCredentialClient) ById(id string) (*RegistryCredential, error) { + resp := &RegistryCredential{} + err := c.rancherClient.doById(REGISTRY_CREDENTIAL_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RegistryCredentialClient) Delete(container *RegistryCredential) error { + return c.rancherClient.doResourceDelete(REGISTRY_CREDENTIAL_TYPE, &container.Resource) +} + +func (c *RegistryCredentialClient) ActionActivate(resource *RegistryCredential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRY_CREDENTIAL_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryCredentialClient) ActionCreate(resource *RegistryCredential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRY_CREDENTIAL_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryCredentialClient) ActionDeactivate(resource *RegistryCredential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRY_CREDENTIAL_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryCredentialClient) ActionPurge(resource *RegistryCredential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRY_CREDENTIAL_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryCredentialClient) ActionRemove(resource *RegistryCredential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRY_CREDENTIAL_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *RegistryCredentialClient) ActionUpdate(resource *RegistryCredential) (*Credential, error) { + + resp := &Credential{} + + err := c.rancherClient.doAction(REGISTRY_CREDENTIAL_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_remove_label_input.go b/vendor/github.com/rancher/go-rancher/client/generated_remove_label_input.go new file mode 100644 index 00000000..84e47e7c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_remove_label_input.go @@ -0,0 +1,62 @@ +package client + +const ( + REMOVE_LABEL_INPUT_TYPE = "removeLabelInput" +) + +type RemoveLabelInput struct { + Resource + + Label string `json:"label,omitempty"` +} + +type RemoveLabelInputCollection struct { + Collection + Data []RemoveLabelInput `json:"data,omitempty"` +} + +type RemoveLabelInputClient struct { + rancherClient *RancherClient +} + +type RemoveLabelInputOperations interface { + List(opts *ListOpts) (*RemoveLabelInputCollection, error) + Create(opts *RemoveLabelInput) (*RemoveLabelInput, error) + Update(existing *RemoveLabelInput, updates interface{}) (*RemoveLabelInput, error) + ById(id string) (*RemoveLabelInput, error) + Delete(container *RemoveLabelInput) error +} + +func newRemoveLabelInputClient(rancherClient *RancherClient) *RemoveLabelInputClient { + return &RemoveLabelInputClient{ + rancherClient: rancherClient, + } +} + +func (c *RemoveLabelInputClient) Create(container *RemoveLabelInput) (*RemoveLabelInput, error) { + resp := &RemoveLabelInput{} + err := c.rancherClient.doCreate(REMOVE_LABEL_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *RemoveLabelInputClient) Update(existing *RemoveLabelInput, updates interface{}) (*RemoveLabelInput, error) { + resp := &RemoveLabelInput{} + err := c.rancherClient.doUpdate(REMOVE_LABEL_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RemoveLabelInputClient) List(opts *ListOpts) (*RemoveLabelInputCollection, error) { + resp := &RemoveLabelInputCollection{} + err := c.rancherClient.doList(REMOVE_LABEL_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *RemoveLabelInputClient) ById(id string) (*RemoveLabelInput, error) { + resp := &RemoveLabelInput{} + err := c.rancherClient.doById(REMOVE_LABEL_INPUT_TYPE, id, resp) + return resp, err +} + +func (c *RemoveLabelInputClient) Delete(container *RemoveLabelInput) error { + return c.rancherClient.doResourceDelete(REMOVE_LABEL_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_remove_load_balancer_input.go b/vendor/github.com/rancher/go-rancher/client/generated_remove_load_balancer_input.go new file mode 100644 index 00000000..f6a2c1b9 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_remove_load_balancer_input.go @@ -0,0 +1,67 @@ +package client + +const ( + REMOVE_LOAD_BALANCER_INPUT_TYPE = "removeLoadBalancerInput" +) + +type RemoveLoadBalancerInput struct { + Resource + + LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"` +} + +type RemoveLoadBalancerInputCollection struct { + Collection + Data []RemoveLoadBalancerInput `json:"data,omitempty"` +} + +type RemoveLoadBalancerInputClient struct { + rancherClient *RancherClient +} + +type RemoveLoadBalancerInputOperations interface { + List(opts *ListOpts) (*RemoveLoadBalancerInputCollection, error) + Create(opts *RemoveLoadBalancerInput) (*RemoveLoadBalancerInput, error) + Update(existing *RemoveLoadBalancerInput, updates interface{}) (*RemoveLoadBalancerInput, error) + ById(id string) (*RemoveLoadBalancerInput, error) + Delete(container *RemoveLoadBalancerInput) error +} + +func newRemoveLoadBalancerInputClient(rancherClient *RancherClient) *RemoveLoadBalancerInputClient { + return &RemoveLoadBalancerInputClient{ + rancherClient: rancherClient, + } +} + +func (c *RemoveLoadBalancerInputClient) Create(container *RemoveLoadBalancerInput) (*RemoveLoadBalancerInput, error) { + resp := &RemoveLoadBalancerInput{} + err := c.rancherClient.doCreate(REMOVE_LOAD_BALANCER_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *RemoveLoadBalancerInputClient) Update(existing *RemoveLoadBalancerInput, updates interface{}) (*RemoveLoadBalancerInput, error) { + resp := &RemoveLoadBalancerInput{} + err := c.rancherClient.doUpdate(REMOVE_LOAD_BALANCER_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RemoveLoadBalancerInputClient) List(opts *ListOpts) (*RemoveLoadBalancerInputCollection, error) { + resp := &RemoveLoadBalancerInputCollection{} + err := c.rancherClient.doList(REMOVE_LOAD_BALANCER_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *RemoveLoadBalancerInputClient) ById(id string) (*RemoveLoadBalancerInput, error) { + resp := &RemoveLoadBalancerInput{} + err := c.rancherClient.doById(REMOVE_LOAD_BALANCER_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RemoveLoadBalancerInputClient) Delete(container *RemoveLoadBalancerInput) error { + return c.rancherClient.doResourceDelete(REMOVE_LOAD_BALANCER_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_resource_definition.go b/vendor/github.com/rancher/go-rancher/client/generated_resource_definition.go new file mode 100644 index 00000000..bb9a4a17 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_resource_definition.go @@ -0,0 +1,67 @@ +package client + +const ( + RESOURCE_DEFINITION_TYPE = "resourceDefinition" +) + +type ResourceDefinition struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` +} + +type ResourceDefinitionCollection struct { + Collection + Data []ResourceDefinition `json:"data,omitempty"` +} + +type ResourceDefinitionClient struct { + rancherClient *RancherClient +} + +type ResourceDefinitionOperations interface { + List(opts *ListOpts) (*ResourceDefinitionCollection, error) + Create(opts *ResourceDefinition) (*ResourceDefinition, error) + Update(existing *ResourceDefinition, updates interface{}) (*ResourceDefinition, error) + ById(id string) (*ResourceDefinition, error) + Delete(container *ResourceDefinition) error +} + +func newResourceDefinitionClient(rancherClient *RancherClient) *ResourceDefinitionClient { + return &ResourceDefinitionClient{ + rancherClient: rancherClient, + } +} + +func (c *ResourceDefinitionClient) Create(container *ResourceDefinition) (*ResourceDefinition, error) { + resp := &ResourceDefinition{} + err := c.rancherClient.doCreate(RESOURCE_DEFINITION_TYPE, container, resp) + return resp, err +} + +func (c *ResourceDefinitionClient) Update(existing *ResourceDefinition, updates interface{}) (*ResourceDefinition, error) { + resp := &ResourceDefinition{} + err := c.rancherClient.doUpdate(RESOURCE_DEFINITION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ResourceDefinitionClient) List(opts *ListOpts) (*ResourceDefinitionCollection, error) { + resp := &ResourceDefinitionCollection{} + err := c.rancherClient.doList(RESOURCE_DEFINITION_TYPE, opts, resp) + return resp, err +} + +func (c *ResourceDefinitionClient) ById(id string) (*ResourceDefinition, error) { + resp := &ResourceDefinition{} + err := c.rancherClient.doById(RESOURCE_DEFINITION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ResourceDefinitionClient) Delete(container *ResourceDefinition) error { + return c.rancherClient.doResourceDelete(RESOURCE_DEFINITION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_restart_policy.go b/vendor/github.com/rancher/go-rancher/client/generated_restart_policy.go new file mode 100644 index 00000000..f301adb5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_restart_policy.go @@ -0,0 +1,69 @@ +package client + +const ( + RESTART_POLICY_TYPE = "restartPolicy" +) + +type RestartPolicy struct { + Resource + + MaximumRetryCount int64 `json:"maximumRetryCount,omitempty" yaml:"maximum_retry_count,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` +} + +type RestartPolicyCollection struct { + Collection + Data []RestartPolicy `json:"data,omitempty"` +} + +type RestartPolicyClient struct { + rancherClient *RancherClient +} + +type RestartPolicyOperations interface { + List(opts *ListOpts) (*RestartPolicyCollection, error) + Create(opts *RestartPolicy) (*RestartPolicy, error) + Update(existing *RestartPolicy, updates interface{}) (*RestartPolicy, error) + ById(id string) (*RestartPolicy, error) + Delete(container *RestartPolicy) error +} + +func newRestartPolicyClient(rancherClient *RancherClient) *RestartPolicyClient { + return &RestartPolicyClient{ + rancherClient: rancherClient, + } +} + +func (c *RestartPolicyClient) Create(container *RestartPolicy) (*RestartPolicy, error) { + resp := &RestartPolicy{} + err := c.rancherClient.doCreate(RESTART_POLICY_TYPE, container, resp) + return resp, err +} + +func (c *RestartPolicyClient) Update(existing *RestartPolicy, updates interface{}) (*RestartPolicy, error) { + resp := &RestartPolicy{} + err := c.rancherClient.doUpdate(RESTART_POLICY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RestartPolicyClient) List(opts *ListOpts) (*RestartPolicyCollection, error) { + resp := &RestartPolicyCollection{} + err := c.rancherClient.doList(RESTART_POLICY_TYPE, opts, resp) + return resp, err +} + +func (c *RestartPolicyClient) ById(id string) (*RestartPolicy, error) { + resp := &RestartPolicy{} + err := c.rancherClient.doById(RESTART_POLICY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RestartPolicyClient) Delete(container *RestartPolicy) error { + return c.rancherClient.doResourceDelete(RESTART_POLICY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_rolling_restart_strategy.go b/vendor/github.com/rancher/go-rancher/client/generated_rolling_restart_strategy.go new file mode 100644 index 00000000..443f9f1e --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_rolling_restart_strategy.go @@ -0,0 +1,69 @@ +package client + +const ( + ROLLING_RESTART_STRATEGY_TYPE = "rollingRestartStrategy" +) + +type RollingRestartStrategy struct { + Resource + + BatchSize int64 `json:"batchSize,omitempty" yaml:"batch_size,omitempty"` + + IntervalMillis int64 `json:"intervalMillis,omitempty" yaml:"interval_millis,omitempty"` +} + +type RollingRestartStrategyCollection struct { + Collection + Data []RollingRestartStrategy `json:"data,omitempty"` +} + +type RollingRestartStrategyClient struct { + rancherClient *RancherClient +} + +type RollingRestartStrategyOperations interface { + List(opts *ListOpts) (*RollingRestartStrategyCollection, error) + Create(opts *RollingRestartStrategy) (*RollingRestartStrategy, error) + Update(existing *RollingRestartStrategy, updates interface{}) (*RollingRestartStrategy, error) + ById(id string) (*RollingRestartStrategy, error) + Delete(container *RollingRestartStrategy) error +} + +func newRollingRestartStrategyClient(rancherClient *RancherClient) *RollingRestartStrategyClient { + return &RollingRestartStrategyClient{ + rancherClient: rancherClient, + } +} + +func (c *RollingRestartStrategyClient) Create(container *RollingRestartStrategy) (*RollingRestartStrategy, error) { + resp := &RollingRestartStrategy{} + err := c.rancherClient.doCreate(ROLLING_RESTART_STRATEGY_TYPE, container, resp) + return resp, err +} + +func (c *RollingRestartStrategyClient) Update(existing *RollingRestartStrategy, updates interface{}) (*RollingRestartStrategy, error) { + resp := &RollingRestartStrategy{} + err := c.rancherClient.doUpdate(ROLLING_RESTART_STRATEGY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *RollingRestartStrategyClient) List(opts *ListOpts) (*RollingRestartStrategyCollection, error) { + resp := &RollingRestartStrategyCollection{} + err := c.rancherClient.doList(ROLLING_RESTART_STRATEGY_TYPE, opts, resp) + return resp, err +} + +func (c *RollingRestartStrategyClient) ById(id string) (*RollingRestartStrategy, error) { + resp := &RollingRestartStrategy{} + err := c.rancherClient.doById(ROLLING_RESTART_STRATEGY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *RollingRestartStrategyClient) Delete(container *RollingRestartStrategy) error { + return c.rancherClient.doResourceDelete(ROLLING_RESTART_STRATEGY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go b/vendor/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go new file mode 100644 index 00000000..9a901774 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go @@ -0,0 +1,415 @@ +package client + +const ( + SECONDARY_LAUNCH_CONFIG_TYPE = "secondaryLaunchConfig" +) + +type SecondaryLaunchConfig struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AllocationState string `json:"allocationState,omitempty" yaml:"allocation_state,omitempty"` + + Build *DockerBuild `json:"build,omitempty" yaml:"build,omitempty"` + + CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"` + + CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"` + + Command []string `json:"command,omitempty" yaml:"command,omitempty"` + + Count int64 `json:"count,omitempty" yaml:"count,omitempty"` + + CpuSet string `json:"cpuSet,omitempty" yaml:"cpu_set,omitempty"` + + CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"` + + CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DataVolumeMounts map[string]interface{} `json:"dataVolumeMounts,omitempty" yaml:"data_volume_mounts,omitempty"` + + DataVolumes []string `json:"dataVolumes,omitempty" yaml:"data_volumes,omitempty"` + + DataVolumesFrom []string `json:"dataVolumesFrom,omitempty" yaml:"data_volumes_from,omitempty"` + + DataVolumesFromLaunchConfigs []string `json:"dataVolumesFromLaunchConfigs,omitempty" yaml:"data_volumes_from_launch_configs,omitempty"` + + DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"` + + Disks []interface{} `json:"disks,omitempty" yaml:"disks,omitempty"` + + Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"` + + DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"` + + DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"` + + EntryPoint []string `json:"entryPoint,omitempty" yaml:"entry_point,omitempty"` + + Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"` + + FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"` + + HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` + + InstanceLinks map[string]interface{} `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"` + + LxcConf map[string]interface{} `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"` + + Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"` + + MemoryMb int64 `json:"memoryMb,omitempty" yaml:"memory_mb,omitempty"` + + MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"` + + NetworkContainerId string `json:"networkContainerId,omitempty" yaml:"network_container_id,omitempty"` + + NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"` + + NetworkLaunchConfig string `json:"networkLaunchConfig,omitempty" yaml:"network_launch_config,omitempty"` + + NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"` + + PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"` + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"` + + Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"` + + PublishAllPorts bool `json:"publishAllPorts,omitempty" yaml:"publish_all_ports,omitempty"` + + ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"` + + RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"` + + SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"` + + StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"` + + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"` + + SystemContainer string `json:"systemContainer,omitempty" yaml:"system_container,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"` + + User string `json:"user,omitempty" yaml:"user,omitempty"` + + Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vcpu int64 `json:"vcpu,omitempty" yaml:"vcpu,omitempty"` + + Version string `json:"version,omitempty" yaml:"version,omitempty"` + + VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"` + + WorkingDir string `json:"workingDir,omitempty" yaml:"working_dir,omitempty"` +} + +type SecondaryLaunchConfigCollection struct { + Collection + Data []SecondaryLaunchConfig `json:"data,omitempty"` +} + +type SecondaryLaunchConfigClient struct { + rancherClient *RancherClient +} + +type SecondaryLaunchConfigOperations interface { + List(opts *ListOpts) (*SecondaryLaunchConfigCollection, error) + Create(opts *SecondaryLaunchConfig) (*SecondaryLaunchConfig, error) + Update(existing *SecondaryLaunchConfig, updates interface{}) (*SecondaryLaunchConfig, error) + ById(id string) (*SecondaryLaunchConfig, error) + Delete(container *SecondaryLaunchConfig) error + + ActionAllocate(*SecondaryLaunchConfig) (*Instance, error) + + ActionConsole(*SecondaryLaunchConfig, *InstanceConsoleInput) (*InstanceConsole, error) + + ActionCreate(*SecondaryLaunchConfig) (*Instance, error) + + ActionDeallocate(*SecondaryLaunchConfig) (*Instance, error) + + ActionExecute(*SecondaryLaunchConfig, *ContainerExec) (*HostAccess, error) + + ActionLogs(*SecondaryLaunchConfig, *ContainerLogs) (*HostAccess, error) + + ActionMigrate(*SecondaryLaunchConfig) (*Instance, error) + + ActionPurge(*SecondaryLaunchConfig) (*Instance, error) + + ActionRemove(*SecondaryLaunchConfig) (*Instance, error) + + ActionRestart(*SecondaryLaunchConfig) (*Instance, error) + + ActionRestore(*SecondaryLaunchConfig) (*Instance, error) + + ActionSetlabels(*SecondaryLaunchConfig, *SetLabelsInput) (*Container, error) + + ActionStart(*SecondaryLaunchConfig) (*Instance, error) + + ActionStop(*SecondaryLaunchConfig, *InstanceStop) (*Instance, error) + + ActionUpdate(*SecondaryLaunchConfig) (*Instance, error) + + ActionUpdatehealthy(*SecondaryLaunchConfig) (*Instance, error) + + ActionUpdatereinitializing(*SecondaryLaunchConfig) (*Instance, error) + + ActionUpdateunhealthy(*SecondaryLaunchConfig) (*Instance, error) +} + +func newSecondaryLaunchConfigClient(rancherClient *RancherClient) *SecondaryLaunchConfigClient { + return &SecondaryLaunchConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *SecondaryLaunchConfigClient) Create(container *SecondaryLaunchConfig) (*SecondaryLaunchConfig, error) { + resp := &SecondaryLaunchConfig{} + err := c.rancherClient.doCreate(SECONDARY_LAUNCH_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *SecondaryLaunchConfigClient) Update(existing *SecondaryLaunchConfig, updates interface{}) (*SecondaryLaunchConfig, error) { + resp := &SecondaryLaunchConfig{} + err := c.rancherClient.doUpdate(SECONDARY_LAUNCH_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SecondaryLaunchConfigClient) List(opts *ListOpts) (*SecondaryLaunchConfigCollection, error) { + resp := &SecondaryLaunchConfigCollection{} + err := c.rancherClient.doList(SECONDARY_LAUNCH_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ById(id string) (*SecondaryLaunchConfig, error) { + resp := &SecondaryLaunchConfig{} + err := c.rancherClient.doById(SECONDARY_LAUNCH_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SecondaryLaunchConfigClient) Delete(container *SecondaryLaunchConfig) error { + return c.rancherClient.doResourceDelete(SECONDARY_LAUNCH_CONFIG_TYPE, &container.Resource) +} + +func (c *SecondaryLaunchConfigClient) ActionAllocate(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "allocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionConsole(resource *SecondaryLaunchConfig, input *InstanceConsoleInput) (*InstanceConsole, error) { + + resp := &InstanceConsole{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "console", &resource.Resource, input, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionCreate(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionDeallocate(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "deallocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionExecute(resource *SecondaryLaunchConfig, input *ContainerExec) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "execute", &resource.Resource, input, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionLogs(resource *SecondaryLaunchConfig, input *ContainerLogs) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "logs", &resource.Resource, input, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionMigrate(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "migrate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionPurge(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionRemove(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionRestart(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "restart", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionRestore(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionSetlabels(resource *SecondaryLaunchConfig, input *SetLabelsInput) (*Container, error) { + + resp := &Container{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "setlabels", &resource.Resource, input, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionStart(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "start", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionStop(resource *SecondaryLaunchConfig, input *InstanceStop) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "stop", &resource.Resource, input, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionUpdate(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionUpdatehealthy(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "updatehealthy", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionUpdatereinitializing(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "updatereinitializing", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SecondaryLaunchConfigClient) ActionUpdateunhealthy(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "updateunhealthy", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service.go b/vendor/github.com/rancher/go-rancher/client/generated_service.go new file mode 100644 index 00000000..d6ba6ad7 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service.go @@ -0,0 +1,275 @@ +package client + +const ( + SERVICE_TYPE = "service" +) + +type Service struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` + + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"` + + Scale int64 `json:"scale,omitempty" yaml:"scale,omitempty"` + + SecondaryLaunchConfigs []interface{} `json:"secondaryLaunchConfigs,omitempty" yaml:"secondary_launch_configs,omitempty"` + + SelectorContainer string `json:"selectorContainer,omitempty" yaml:"selector_container,omitempty"` + + SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` + + ServiceSchemas map[string]interface{} `json:"serviceSchemas,omitempty" yaml:"service_schemas,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vip string `json:"vip,omitempty" yaml:"vip,omitempty"` +} + +type ServiceCollection struct { + Collection + Data []Service `json:"data,omitempty"` +} + +type ServiceClient struct { + rancherClient *RancherClient +} + +type ServiceOperations interface { + List(opts *ListOpts) (*ServiceCollection, error) + Create(opts *Service) (*Service, error) + Update(existing *Service, updates interface{}) (*Service, error) + ById(id string) (*Service, error) + Delete(container *Service) error + + ActionActivate(*Service) (*Service, error) + + ActionAddservicelink(*Service, *AddRemoveServiceLinkInput) (*Service, error) + + ActionCancelrollback(*Service) (*Service, error) + + ActionCancelupgrade(*Service) (*Service, error) + + ActionCreate(*Service) (*Service, error) + + ActionDeactivate(*Service) (*Service, error) + + ActionFinishupgrade(*Service) (*Service, error) + + ActionRemove(*Service) (*Service, error) + + ActionRemoveservicelink(*Service, *AddRemoveServiceLinkInput) (*Service, error) + + ActionRestart(*Service, *ServiceRestart) (*Service, error) + + ActionRollback(*Service) (*Service, error) + + ActionSetservicelinks(*Service, *SetServiceLinksInput) (*Service, error) + + ActionUpdate(*Service) (*Service, error) + + ActionUpgrade(*Service, *ServiceUpgrade) (*Service, error) +} + +func newServiceClient(rancherClient *RancherClient) *ServiceClient { + return &ServiceClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceClient) Create(container *Service) (*Service, error) { + resp := &Service{} + err := c.rancherClient.doCreate(SERVICE_TYPE, container, resp) + return resp, err +} + +func (c *ServiceClient) Update(existing *Service, updates interface{}) (*Service, error) { + resp := &Service{} + err := c.rancherClient.doUpdate(SERVICE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceClient) List(opts *ListOpts) (*ServiceCollection, error) { + resp := &ServiceCollection{} + err := c.rancherClient.doList(SERVICE_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceClient) ById(id string) (*Service, error) { + resp := &Service{} + err := c.rancherClient.doById(SERVICE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceClient) Delete(container *Service) error { + return c.rancherClient.doResourceDelete(SERVICE_TYPE, &container.Resource) +} + +func (c *ServiceClient) ActionActivate(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionAddservicelink(resource *Service, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ServiceClient) ActionCancelrollback(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionCancelupgrade(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionCreate(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionDeactivate(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionFinishupgrade(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionRemove(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionRemoveservicelink(resource *Service, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ServiceClient) ActionRestart(resource *Service, input *ServiceRestart) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "restart", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ServiceClient) ActionRollback(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionSetservicelinks(resource *Service, input *SetServiceLinksInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ServiceClient) ActionUpdate(resource *Service) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceClient) ActionUpgrade(resource *Service, input *ServiceUpgrade) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(SERVICE_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_consume_map.go b/vendor/github.com/rancher/go-rancher/client/generated_service_consume_map.go new file mode 100644 index 00000000..822a9aac --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_consume_map.go @@ -0,0 +1,130 @@ +package client + +const ( + SERVICE_CONSUME_MAP_TYPE = "serviceConsumeMap" +) + +type ServiceConsumeMap struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + ConsumedServiceId string `json:"consumedServiceId,omitempty" yaml:"consumed_service_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ServiceConsumeMapCollection struct { + Collection + Data []ServiceConsumeMap `json:"data,omitempty"` +} + +type ServiceConsumeMapClient struct { + rancherClient *RancherClient +} + +type ServiceConsumeMapOperations interface { + List(opts *ListOpts) (*ServiceConsumeMapCollection, error) + Create(opts *ServiceConsumeMap) (*ServiceConsumeMap, error) + Update(existing *ServiceConsumeMap, updates interface{}) (*ServiceConsumeMap, error) + ById(id string) (*ServiceConsumeMap, error) + Delete(container *ServiceConsumeMap) error + + ActionCreate(*ServiceConsumeMap) (*ServiceConsumeMap, error) + + ActionRemove(*ServiceConsumeMap) (*ServiceConsumeMap, error) + + ActionUpdate(*ServiceConsumeMap) (*ServiceConsumeMap, error) +} + +func newServiceConsumeMapClient(rancherClient *RancherClient) *ServiceConsumeMapClient { + return &ServiceConsumeMapClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceConsumeMapClient) Create(container *ServiceConsumeMap) (*ServiceConsumeMap, error) { + resp := &ServiceConsumeMap{} + err := c.rancherClient.doCreate(SERVICE_CONSUME_MAP_TYPE, container, resp) + return resp, err +} + +func (c *ServiceConsumeMapClient) Update(existing *ServiceConsumeMap, updates interface{}) (*ServiceConsumeMap, error) { + resp := &ServiceConsumeMap{} + err := c.rancherClient.doUpdate(SERVICE_CONSUME_MAP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceConsumeMapClient) List(opts *ListOpts) (*ServiceConsumeMapCollection, error) { + resp := &ServiceConsumeMapCollection{} + err := c.rancherClient.doList(SERVICE_CONSUME_MAP_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceConsumeMapClient) ById(id string) (*ServiceConsumeMap, error) { + resp := &ServiceConsumeMap{} + err := c.rancherClient.doById(SERVICE_CONSUME_MAP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceConsumeMapClient) Delete(container *ServiceConsumeMap) error { + return c.rancherClient.doResourceDelete(SERVICE_CONSUME_MAP_TYPE, &container.Resource) +} + +func (c *ServiceConsumeMapClient) ActionCreate(resource *ServiceConsumeMap) (*ServiceConsumeMap, error) { + + resp := &ServiceConsumeMap{} + + err := c.rancherClient.doAction(SERVICE_CONSUME_MAP_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceConsumeMapClient) ActionRemove(resource *ServiceConsumeMap) (*ServiceConsumeMap, error) { + + resp := &ServiceConsumeMap{} + + err := c.rancherClient.doAction(SERVICE_CONSUME_MAP_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceConsumeMapClient) ActionUpdate(resource *ServiceConsumeMap) (*ServiceConsumeMap, error) { + + resp := &ServiceConsumeMap{} + + err := c.rancherClient.doAction(SERVICE_CONSUME_MAP_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_event.go b/vendor/github.com/rancher/go-rancher/client/generated_service_event.go new file mode 100644 index 00000000..7d046b38 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_event.go @@ -0,0 +1,123 @@ +package client + +const ( + SERVICE_EVENT_TYPE = "serviceEvent" +) + +type ServiceEvent struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ExternalTimestamp int64 `json:"externalTimestamp,omitempty" yaml:"external_timestamp,omitempty"` + + HealthcheckUuid string `json:"healthcheckUuid,omitempty" yaml:"healthcheck_uuid,omitempty"` + + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ReportedHealth string `json:"reportedHealth,omitempty" yaml:"reported_health,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ServiceEventCollection struct { + Collection + Data []ServiceEvent `json:"data,omitempty"` +} + +type ServiceEventClient struct { + rancherClient *RancherClient +} + +type ServiceEventOperations interface { + List(opts *ListOpts) (*ServiceEventCollection, error) + Create(opts *ServiceEvent) (*ServiceEvent, error) + Update(existing *ServiceEvent, updates interface{}) (*ServiceEvent, error) + ById(id string) (*ServiceEvent, error) + Delete(container *ServiceEvent) error + + ActionCreate(*ServiceEvent) (*ServiceEvent, error) + + ActionRemove(*ServiceEvent) (*ServiceEvent, error) +} + +func newServiceEventClient(rancherClient *RancherClient) *ServiceEventClient { + return &ServiceEventClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceEventClient) Create(container *ServiceEvent) (*ServiceEvent, error) { + resp := &ServiceEvent{} + err := c.rancherClient.doCreate(SERVICE_EVENT_TYPE, container, resp) + return resp, err +} + +func (c *ServiceEventClient) Update(existing *ServiceEvent, updates interface{}) (*ServiceEvent, error) { + resp := &ServiceEvent{} + err := c.rancherClient.doUpdate(SERVICE_EVENT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceEventClient) List(opts *ListOpts) (*ServiceEventCollection, error) { + resp := &ServiceEventCollection{} + err := c.rancherClient.doList(SERVICE_EVENT_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceEventClient) ById(id string) (*ServiceEvent, error) { + resp := &ServiceEvent{} + err := c.rancherClient.doById(SERVICE_EVENT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceEventClient) Delete(container *ServiceEvent) error { + return c.rancherClient.doResourceDelete(SERVICE_EVENT_TYPE, &container.Resource) +} + +func (c *ServiceEventClient) ActionCreate(resource *ServiceEvent) (*ServiceEvent, error) { + + resp := &ServiceEvent{} + + err := c.rancherClient.doAction(SERVICE_EVENT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceEventClient) ActionRemove(resource *ServiceEvent) (*ServiceEvent, error) { + + resp := &ServiceEvent{} + + err := c.rancherClient.doAction(SERVICE_EVENT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_expose_map.go b/vendor/github.com/rancher/go-rancher/client/generated_service_expose_map.go new file mode 100644 index 00000000..60fe5f2f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_expose_map.go @@ -0,0 +1,121 @@ +package client + +const ( + SERVICE_EXPOSE_MAP_TYPE = "serviceExposeMap" +) + +type ServiceExposeMap struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + IpAddress string `json:"ipAddress,omitempty" yaml:"ip_address,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Managed bool `json:"managed,omitempty" yaml:"managed,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ServiceExposeMapCollection struct { + Collection + Data []ServiceExposeMap `json:"data,omitempty"` +} + +type ServiceExposeMapClient struct { + rancherClient *RancherClient +} + +type ServiceExposeMapOperations interface { + List(opts *ListOpts) (*ServiceExposeMapCollection, error) + Create(opts *ServiceExposeMap) (*ServiceExposeMap, error) + Update(existing *ServiceExposeMap, updates interface{}) (*ServiceExposeMap, error) + ById(id string) (*ServiceExposeMap, error) + Delete(container *ServiceExposeMap) error + + ActionCreate(*ServiceExposeMap) (*ServiceExposeMap, error) + + ActionRemove(*ServiceExposeMap) (*ServiceExposeMap, error) +} + +func newServiceExposeMapClient(rancherClient *RancherClient) *ServiceExposeMapClient { + return &ServiceExposeMapClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceExposeMapClient) Create(container *ServiceExposeMap) (*ServiceExposeMap, error) { + resp := &ServiceExposeMap{} + err := c.rancherClient.doCreate(SERVICE_EXPOSE_MAP_TYPE, container, resp) + return resp, err +} + +func (c *ServiceExposeMapClient) Update(existing *ServiceExposeMap, updates interface{}) (*ServiceExposeMap, error) { + resp := &ServiceExposeMap{} + err := c.rancherClient.doUpdate(SERVICE_EXPOSE_MAP_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceExposeMapClient) List(opts *ListOpts) (*ServiceExposeMapCollection, error) { + resp := &ServiceExposeMapCollection{} + err := c.rancherClient.doList(SERVICE_EXPOSE_MAP_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceExposeMapClient) ById(id string) (*ServiceExposeMap, error) { + resp := &ServiceExposeMap{} + err := c.rancherClient.doById(SERVICE_EXPOSE_MAP_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceExposeMapClient) Delete(container *ServiceExposeMap) error { + return c.rancherClient.doResourceDelete(SERVICE_EXPOSE_MAP_TYPE, &container.Resource) +} + +func (c *ServiceExposeMapClient) ActionCreate(resource *ServiceExposeMap) (*ServiceExposeMap, error) { + + resp := &ServiceExposeMap{} + + err := c.rancherClient.doAction(SERVICE_EXPOSE_MAP_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ServiceExposeMapClient) ActionRemove(resource *ServiceExposeMap) (*ServiceExposeMap, error) { + + resp := &ServiceExposeMap{} + + err := c.rancherClient.doAction(SERVICE_EXPOSE_MAP_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_link.go b/vendor/github.com/rancher/go-rancher/client/generated_service_link.go new file mode 100644 index 00000000..52c75ac5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_link.go @@ -0,0 +1,71 @@ +package client + +const ( + SERVICE_LINK_TYPE = "serviceLink" +) + +type ServiceLink struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ServiceLinkCollection struct { + Collection + Data []ServiceLink `json:"data,omitempty"` +} + +type ServiceLinkClient struct { + rancherClient *RancherClient +} + +type ServiceLinkOperations interface { + List(opts *ListOpts) (*ServiceLinkCollection, error) + Create(opts *ServiceLink) (*ServiceLink, error) + Update(existing *ServiceLink, updates interface{}) (*ServiceLink, error) + ById(id string) (*ServiceLink, error) + Delete(container *ServiceLink) error +} + +func newServiceLinkClient(rancherClient *RancherClient) *ServiceLinkClient { + return &ServiceLinkClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceLinkClient) Create(container *ServiceLink) (*ServiceLink, error) { + resp := &ServiceLink{} + err := c.rancherClient.doCreate(SERVICE_LINK_TYPE, container, resp) + return resp, err +} + +func (c *ServiceLinkClient) Update(existing *ServiceLink, updates interface{}) (*ServiceLink, error) { + resp := &ServiceLink{} + err := c.rancherClient.doUpdate(SERVICE_LINK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceLinkClient) List(opts *ListOpts) (*ServiceLinkCollection, error) { + resp := &ServiceLinkCollection{} + err := c.rancherClient.doList(SERVICE_LINK_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceLinkClient) ById(id string) (*ServiceLink, error) { + resp := &ServiceLink{} + err := c.rancherClient.doById(SERVICE_LINK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceLinkClient) Delete(container *ServiceLink) error { + return c.rancherClient.doResourceDelete(SERVICE_LINK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_restart.go b/vendor/github.com/rancher/go-rancher/client/generated_service_restart.go new file mode 100644 index 00000000..5b95e8c6 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_restart.go @@ -0,0 +1,67 @@ +package client + +const ( + SERVICE_RESTART_TYPE = "serviceRestart" +) + +type ServiceRestart struct { + Resource + + RollingRestartStrategy RollingRestartStrategy `json:"rollingRestartStrategy,omitempty" yaml:"rolling_restart_strategy,omitempty"` +} + +type ServiceRestartCollection struct { + Collection + Data []ServiceRestart `json:"data,omitempty"` +} + +type ServiceRestartClient struct { + rancherClient *RancherClient +} + +type ServiceRestartOperations interface { + List(opts *ListOpts) (*ServiceRestartCollection, error) + Create(opts *ServiceRestart) (*ServiceRestart, error) + Update(existing *ServiceRestart, updates interface{}) (*ServiceRestart, error) + ById(id string) (*ServiceRestart, error) + Delete(container *ServiceRestart) error +} + +func newServiceRestartClient(rancherClient *RancherClient) *ServiceRestartClient { + return &ServiceRestartClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceRestartClient) Create(container *ServiceRestart) (*ServiceRestart, error) { + resp := &ServiceRestart{} + err := c.rancherClient.doCreate(SERVICE_RESTART_TYPE, container, resp) + return resp, err +} + +func (c *ServiceRestartClient) Update(existing *ServiceRestart, updates interface{}) (*ServiceRestart, error) { + resp := &ServiceRestart{} + err := c.rancherClient.doUpdate(SERVICE_RESTART_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceRestartClient) List(opts *ListOpts) (*ServiceRestartCollection, error) { + resp := &ServiceRestartCollection{} + err := c.rancherClient.doList(SERVICE_RESTART_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceRestartClient) ById(id string) (*ServiceRestart, error) { + resp := &ServiceRestart{} + err := c.rancherClient.doById(SERVICE_RESTART_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceRestartClient) Delete(container *ServiceRestart) error { + return c.rancherClient.doResourceDelete(SERVICE_RESTART_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_upgrade.go b/vendor/github.com/rancher/go-rancher/client/generated_service_upgrade.go new file mode 100644 index 00000000..25b453f2 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_upgrade.go @@ -0,0 +1,69 @@ +package client + +const ( + SERVICE_UPGRADE_TYPE = "serviceUpgrade" +) + +type ServiceUpgrade struct { + Resource + + InServiceStrategy *InServiceUpgradeStrategy `json:"inServiceStrategy,omitempty" yaml:"in_service_strategy,omitempty"` + + ToServiceStrategy *ToServiceUpgradeStrategy `json:"toServiceStrategy,omitempty" yaml:"to_service_strategy,omitempty"` +} + +type ServiceUpgradeCollection struct { + Collection + Data []ServiceUpgrade `json:"data,omitempty"` +} + +type ServiceUpgradeClient struct { + rancherClient *RancherClient +} + +type ServiceUpgradeOperations interface { + List(opts *ListOpts) (*ServiceUpgradeCollection, error) + Create(opts *ServiceUpgrade) (*ServiceUpgrade, error) + Update(existing *ServiceUpgrade, updates interface{}) (*ServiceUpgrade, error) + ById(id string) (*ServiceUpgrade, error) + Delete(container *ServiceUpgrade) error +} + +func newServiceUpgradeClient(rancherClient *RancherClient) *ServiceUpgradeClient { + return &ServiceUpgradeClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceUpgradeClient) Create(container *ServiceUpgrade) (*ServiceUpgrade, error) { + resp := &ServiceUpgrade{} + err := c.rancherClient.doCreate(SERVICE_UPGRADE_TYPE, container, resp) + return resp, err +} + +func (c *ServiceUpgradeClient) Update(existing *ServiceUpgrade, updates interface{}) (*ServiceUpgrade, error) { + resp := &ServiceUpgrade{} + err := c.rancherClient.doUpdate(SERVICE_UPGRADE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceUpgradeClient) List(opts *ListOpts) (*ServiceUpgradeCollection, error) { + resp := &ServiceUpgradeCollection{} + err := c.rancherClient.doList(SERVICE_UPGRADE_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceUpgradeClient) ById(id string) (*ServiceUpgrade, error) { + resp := &ServiceUpgrade{} + err := c.rancherClient.doById(SERVICE_UPGRADE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceUpgradeClient) Delete(container *ServiceUpgrade) error { + return c.rancherClient.doResourceDelete(SERVICE_UPGRADE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_service_upgrade_strategy.go b/vendor/github.com/rancher/go-rancher/client/generated_service_upgrade_strategy.go new file mode 100644 index 00000000..834606b6 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_service_upgrade_strategy.go @@ -0,0 +1,69 @@ +package client + +const ( + SERVICE_UPGRADE_STRATEGY_TYPE = "serviceUpgradeStrategy" +) + +type ServiceUpgradeStrategy struct { + Resource + + BatchSize int64 `json:"batchSize,omitempty" yaml:"batch_size,omitempty"` + + IntervalMillis int64 `json:"intervalMillis,omitempty" yaml:"interval_millis,omitempty"` +} + +type ServiceUpgradeStrategyCollection struct { + Collection + Data []ServiceUpgradeStrategy `json:"data,omitempty"` +} + +type ServiceUpgradeStrategyClient struct { + rancherClient *RancherClient +} + +type ServiceUpgradeStrategyOperations interface { + List(opts *ListOpts) (*ServiceUpgradeStrategyCollection, error) + Create(opts *ServiceUpgradeStrategy) (*ServiceUpgradeStrategy, error) + Update(existing *ServiceUpgradeStrategy, updates interface{}) (*ServiceUpgradeStrategy, error) + ById(id string) (*ServiceUpgradeStrategy, error) + Delete(container *ServiceUpgradeStrategy) error +} + +func newServiceUpgradeStrategyClient(rancherClient *RancherClient) *ServiceUpgradeStrategyClient { + return &ServiceUpgradeStrategyClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceUpgradeStrategyClient) Create(container *ServiceUpgradeStrategy) (*ServiceUpgradeStrategy, error) { + resp := &ServiceUpgradeStrategy{} + err := c.rancherClient.doCreate(SERVICE_UPGRADE_STRATEGY_TYPE, container, resp) + return resp, err +} + +func (c *ServiceUpgradeStrategyClient) Update(existing *ServiceUpgradeStrategy, updates interface{}) (*ServiceUpgradeStrategy, error) { + resp := &ServiceUpgradeStrategy{} + err := c.rancherClient.doUpdate(SERVICE_UPGRADE_STRATEGY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceUpgradeStrategyClient) List(opts *ListOpts) (*ServiceUpgradeStrategyCollection, error) { + resp := &ServiceUpgradeStrategyCollection{} + err := c.rancherClient.doList(SERVICE_UPGRADE_STRATEGY_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceUpgradeStrategyClient) ById(id string) (*ServiceUpgradeStrategy, error) { + resp := &ServiceUpgradeStrategy{} + err := c.rancherClient.doById(SERVICE_UPGRADE_STRATEGY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceUpgradeStrategyClient) Delete(container *ServiceUpgradeStrategy) error { + return c.rancherClient.doResourceDelete(SERVICE_UPGRADE_STRATEGY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_services_port_range.go b/vendor/github.com/rancher/go-rancher/client/generated_services_port_range.go new file mode 100644 index 00000000..d3c0eb91 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_services_port_range.go @@ -0,0 +1,69 @@ +package client + +const ( + SERVICES_PORT_RANGE_TYPE = "servicesPortRange" +) + +type ServicesPortRange struct { + Resource + + EndPort int64 `json:"endPort,omitempty" yaml:"end_port,omitempty"` + + StartPort int64 `json:"startPort,omitempty" yaml:"start_port,omitempty"` +} + +type ServicesPortRangeCollection struct { + Collection + Data []ServicesPortRange `json:"data,omitempty"` +} + +type ServicesPortRangeClient struct { + rancherClient *RancherClient +} + +type ServicesPortRangeOperations interface { + List(opts *ListOpts) (*ServicesPortRangeCollection, error) + Create(opts *ServicesPortRange) (*ServicesPortRange, error) + Update(existing *ServicesPortRange, updates interface{}) (*ServicesPortRange, error) + ById(id string) (*ServicesPortRange, error) + Delete(container *ServicesPortRange) error +} + +func newServicesPortRangeClient(rancherClient *RancherClient) *ServicesPortRangeClient { + return &ServicesPortRangeClient{ + rancherClient: rancherClient, + } +} + +func (c *ServicesPortRangeClient) Create(container *ServicesPortRange) (*ServicesPortRange, error) { + resp := &ServicesPortRange{} + err := c.rancherClient.doCreate(SERVICES_PORT_RANGE_TYPE, container, resp) + return resp, err +} + +func (c *ServicesPortRangeClient) Update(existing *ServicesPortRange, updates interface{}) (*ServicesPortRange, error) { + resp := &ServicesPortRange{} + err := c.rancherClient.doUpdate(SERVICES_PORT_RANGE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServicesPortRangeClient) List(opts *ListOpts) (*ServicesPortRangeCollection, error) { + resp := &ServicesPortRangeCollection{} + err := c.rancherClient.doList(SERVICES_PORT_RANGE_TYPE, opts, resp) + return resp, err +} + +func (c *ServicesPortRangeClient) ById(id string) (*ServicesPortRange, error) { + resp := &ServicesPortRange{} + err := c.rancherClient.doById(SERVICES_PORT_RANGE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServicesPortRangeClient) Delete(container *ServicesPortRange) error { + return c.rancherClient.doResourceDelete(SERVICES_PORT_RANGE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_labels_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_labels_input.go new file mode 100644 index 00000000..96d89451 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_labels_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_LABELS_INPUT_TYPE = "setLabelsInput" +) + +type SetLabelsInput struct { + Resource + + Labels interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` +} + +type SetLabelsInputCollection struct { + Collection + Data []SetLabelsInput `json:"data,omitempty"` +} + +type SetLabelsInputClient struct { + rancherClient *RancherClient +} + +type SetLabelsInputOperations interface { + List(opts *ListOpts) (*SetLabelsInputCollection, error) + Create(opts *SetLabelsInput) (*SetLabelsInput, error) + Update(existing *SetLabelsInput, updates interface{}) (*SetLabelsInput, error) + ById(id string) (*SetLabelsInput, error) + Delete(container *SetLabelsInput) error +} + +func newSetLabelsInputClient(rancherClient *RancherClient) *SetLabelsInputClient { + return &SetLabelsInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetLabelsInputClient) Create(container *SetLabelsInput) (*SetLabelsInput, error) { + resp := &SetLabelsInput{} + err := c.rancherClient.doCreate(SET_LABELS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetLabelsInputClient) Update(existing *SetLabelsInput, updates interface{}) (*SetLabelsInput, error) { + resp := &SetLabelsInput{} + err := c.rancherClient.doUpdate(SET_LABELS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetLabelsInputClient) List(opts *ListOpts) (*SetLabelsInputCollection, error) { + resp := &SetLabelsInputCollection{} + err := c.rancherClient.doList(SET_LABELS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetLabelsInputClient) ById(id string) (*SetLabelsInput, error) { + resp := &SetLabelsInput{} + err := c.rancherClient.doById(SET_LABELS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetLabelsInputClient) Delete(container *SetLabelsInput) error { + return c.rancherClient.doResourceDelete(SET_LABELS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_hosts_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_hosts_input.go new file mode 100644 index 00000000..753abc62 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_hosts_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_LOAD_BALANCER_HOSTS_INPUT_TYPE = "setLoadBalancerHostsInput" +) + +type SetLoadBalancerHostsInput struct { + Resource + + HostIds []string `json:"hostIds,omitempty" yaml:"host_ids,omitempty"` +} + +type SetLoadBalancerHostsInputCollection struct { + Collection + Data []SetLoadBalancerHostsInput `json:"data,omitempty"` +} + +type SetLoadBalancerHostsInputClient struct { + rancherClient *RancherClient +} + +type SetLoadBalancerHostsInputOperations interface { + List(opts *ListOpts) (*SetLoadBalancerHostsInputCollection, error) + Create(opts *SetLoadBalancerHostsInput) (*SetLoadBalancerHostsInput, error) + Update(existing *SetLoadBalancerHostsInput, updates interface{}) (*SetLoadBalancerHostsInput, error) + ById(id string) (*SetLoadBalancerHostsInput, error) + Delete(container *SetLoadBalancerHostsInput) error +} + +func newSetLoadBalancerHostsInputClient(rancherClient *RancherClient) *SetLoadBalancerHostsInputClient { + return &SetLoadBalancerHostsInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetLoadBalancerHostsInputClient) Create(container *SetLoadBalancerHostsInput) (*SetLoadBalancerHostsInput, error) { + resp := &SetLoadBalancerHostsInput{} + err := c.rancherClient.doCreate(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetLoadBalancerHostsInputClient) Update(existing *SetLoadBalancerHostsInput, updates interface{}) (*SetLoadBalancerHostsInput, error) { + resp := &SetLoadBalancerHostsInput{} + err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetLoadBalancerHostsInputClient) List(opts *ListOpts) (*SetLoadBalancerHostsInputCollection, error) { + resp := &SetLoadBalancerHostsInputCollection{} + err := c.rancherClient.doList(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetLoadBalancerHostsInputClient) ById(id string) (*SetLoadBalancerHostsInput, error) { + resp := &SetLoadBalancerHostsInput{} + err := c.rancherClient.doById(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetLoadBalancerHostsInputClient) Delete(container *SetLoadBalancerHostsInput) error { + return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_listeners_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_listeners_input.go new file mode 100644 index 00000000..31aaa9c5 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_listeners_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE = "setLoadBalancerListenersInput" +) + +type SetLoadBalancerListenersInput struct { + Resource + + LoadBalancerListenerIds []string `json:"loadBalancerListenerIds,omitempty" yaml:"load_balancer_listener_ids,omitempty"` +} + +type SetLoadBalancerListenersInputCollection struct { + Collection + Data []SetLoadBalancerListenersInput `json:"data,omitempty"` +} + +type SetLoadBalancerListenersInputClient struct { + rancherClient *RancherClient +} + +type SetLoadBalancerListenersInputOperations interface { + List(opts *ListOpts) (*SetLoadBalancerListenersInputCollection, error) + Create(opts *SetLoadBalancerListenersInput) (*SetLoadBalancerListenersInput, error) + Update(existing *SetLoadBalancerListenersInput, updates interface{}) (*SetLoadBalancerListenersInput, error) + ById(id string) (*SetLoadBalancerListenersInput, error) + Delete(container *SetLoadBalancerListenersInput) error +} + +func newSetLoadBalancerListenersInputClient(rancherClient *RancherClient) *SetLoadBalancerListenersInputClient { + return &SetLoadBalancerListenersInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetLoadBalancerListenersInputClient) Create(container *SetLoadBalancerListenersInput) (*SetLoadBalancerListenersInput, error) { + resp := &SetLoadBalancerListenersInput{} + err := c.rancherClient.doCreate(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetLoadBalancerListenersInputClient) Update(existing *SetLoadBalancerListenersInput, updates interface{}) (*SetLoadBalancerListenersInput, error) { + resp := &SetLoadBalancerListenersInput{} + err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetLoadBalancerListenersInputClient) List(opts *ListOpts) (*SetLoadBalancerListenersInputCollection, error) { + resp := &SetLoadBalancerListenersInputCollection{} + err := c.rancherClient.doList(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetLoadBalancerListenersInputClient) ById(id string) (*SetLoadBalancerListenersInput, error) { + resp := &SetLoadBalancerListenersInput{} + err := c.rancherClient.doById(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetLoadBalancerListenersInputClient) Delete(container *SetLoadBalancerListenersInput) error { + return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_service_links_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_service_links_input.go new file mode 100644 index 00000000..76d8684c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_service_links_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE = "setLoadBalancerServiceLinksInput" +) + +type SetLoadBalancerServiceLinksInput struct { + Resource + + ServiceLinks []interface{} `json:"serviceLinks,omitempty" yaml:"service_links,omitempty"` +} + +type SetLoadBalancerServiceLinksInputCollection struct { + Collection + Data []SetLoadBalancerServiceLinksInput `json:"data,omitempty"` +} + +type SetLoadBalancerServiceLinksInputClient struct { + rancherClient *RancherClient +} + +type SetLoadBalancerServiceLinksInputOperations interface { + List(opts *ListOpts) (*SetLoadBalancerServiceLinksInputCollection, error) + Create(opts *SetLoadBalancerServiceLinksInput) (*SetLoadBalancerServiceLinksInput, error) + Update(existing *SetLoadBalancerServiceLinksInput, updates interface{}) (*SetLoadBalancerServiceLinksInput, error) + ById(id string) (*SetLoadBalancerServiceLinksInput, error) + Delete(container *SetLoadBalancerServiceLinksInput) error +} + +func newSetLoadBalancerServiceLinksInputClient(rancherClient *RancherClient) *SetLoadBalancerServiceLinksInputClient { + return &SetLoadBalancerServiceLinksInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetLoadBalancerServiceLinksInputClient) Create(container *SetLoadBalancerServiceLinksInput) (*SetLoadBalancerServiceLinksInput, error) { + resp := &SetLoadBalancerServiceLinksInput{} + err := c.rancherClient.doCreate(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetLoadBalancerServiceLinksInputClient) Update(existing *SetLoadBalancerServiceLinksInput, updates interface{}) (*SetLoadBalancerServiceLinksInput, error) { + resp := &SetLoadBalancerServiceLinksInput{} + err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetLoadBalancerServiceLinksInputClient) List(opts *ListOpts) (*SetLoadBalancerServiceLinksInputCollection, error) { + resp := &SetLoadBalancerServiceLinksInputCollection{} + err := c.rancherClient.doList(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetLoadBalancerServiceLinksInputClient) ById(id string) (*SetLoadBalancerServiceLinksInput, error) { + resp := &SetLoadBalancerServiceLinksInput{} + err := c.rancherClient.doById(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetLoadBalancerServiceLinksInputClient) Delete(container *SetLoadBalancerServiceLinksInput) error { + return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_targets_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_targets_input.go new file mode 100644 index 00000000..cef13a35 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_load_balancer_targets_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_LOAD_BALANCER_TARGETS_INPUT_TYPE = "setLoadBalancerTargetsInput" +) + +type SetLoadBalancerTargetsInput struct { + Resource + + LoadBalancerTargets []interface{} `json:"loadBalancerTargets,omitempty" yaml:"load_balancer_targets,omitempty"` +} + +type SetLoadBalancerTargetsInputCollection struct { + Collection + Data []SetLoadBalancerTargetsInput `json:"data,omitempty"` +} + +type SetLoadBalancerTargetsInputClient struct { + rancherClient *RancherClient +} + +type SetLoadBalancerTargetsInputOperations interface { + List(opts *ListOpts) (*SetLoadBalancerTargetsInputCollection, error) + Create(opts *SetLoadBalancerTargetsInput) (*SetLoadBalancerTargetsInput, error) + Update(existing *SetLoadBalancerTargetsInput, updates interface{}) (*SetLoadBalancerTargetsInput, error) + ById(id string) (*SetLoadBalancerTargetsInput, error) + Delete(container *SetLoadBalancerTargetsInput) error +} + +func newSetLoadBalancerTargetsInputClient(rancherClient *RancherClient) *SetLoadBalancerTargetsInputClient { + return &SetLoadBalancerTargetsInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetLoadBalancerTargetsInputClient) Create(container *SetLoadBalancerTargetsInput) (*SetLoadBalancerTargetsInput, error) { + resp := &SetLoadBalancerTargetsInput{} + err := c.rancherClient.doCreate(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetLoadBalancerTargetsInputClient) Update(existing *SetLoadBalancerTargetsInput, updates interface{}) (*SetLoadBalancerTargetsInput, error) { + resp := &SetLoadBalancerTargetsInput{} + err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetLoadBalancerTargetsInputClient) List(opts *ListOpts) (*SetLoadBalancerTargetsInputCollection, error) { + resp := &SetLoadBalancerTargetsInputCollection{} + err := c.rancherClient.doList(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetLoadBalancerTargetsInputClient) ById(id string) (*SetLoadBalancerTargetsInput, error) { + resp := &SetLoadBalancerTargetsInput{} + err := c.rancherClient.doById(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetLoadBalancerTargetsInputClient) Delete(container *SetLoadBalancerTargetsInput) error { + return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_project_members_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_project_members_input.go new file mode 100644 index 00000000..bc8c2f20 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_project_members_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_PROJECT_MEMBERS_INPUT_TYPE = "setProjectMembersInput" +) + +type SetProjectMembersInput struct { + Resource + + Members []interface{} `json:"members,omitempty" yaml:"members,omitempty"` +} + +type SetProjectMembersInputCollection struct { + Collection + Data []SetProjectMembersInput `json:"data,omitempty"` +} + +type SetProjectMembersInputClient struct { + rancherClient *RancherClient +} + +type SetProjectMembersInputOperations interface { + List(opts *ListOpts) (*SetProjectMembersInputCollection, error) + Create(opts *SetProjectMembersInput) (*SetProjectMembersInput, error) + Update(existing *SetProjectMembersInput, updates interface{}) (*SetProjectMembersInput, error) + ById(id string) (*SetProjectMembersInput, error) + Delete(container *SetProjectMembersInput) error +} + +func newSetProjectMembersInputClient(rancherClient *RancherClient) *SetProjectMembersInputClient { + return &SetProjectMembersInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetProjectMembersInputClient) Create(container *SetProjectMembersInput) (*SetProjectMembersInput, error) { + resp := &SetProjectMembersInput{} + err := c.rancherClient.doCreate(SET_PROJECT_MEMBERS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetProjectMembersInputClient) Update(existing *SetProjectMembersInput, updates interface{}) (*SetProjectMembersInput, error) { + resp := &SetProjectMembersInput{} + err := c.rancherClient.doUpdate(SET_PROJECT_MEMBERS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetProjectMembersInputClient) List(opts *ListOpts) (*SetProjectMembersInputCollection, error) { + resp := &SetProjectMembersInputCollection{} + err := c.rancherClient.doList(SET_PROJECT_MEMBERS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetProjectMembersInputClient) ById(id string) (*SetProjectMembersInput, error) { + resp := &SetProjectMembersInput{} + err := c.rancherClient.doById(SET_PROJECT_MEMBERS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetProjectMembersInputClient) Delete(container *SetProjectMembersInput) error { + return c.rancherClient.doResourceDelete(SET_PROJECT_MEMBERS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_set_service_links_input.go b/vendor/github.com/rancher/go-rancher/client/generated_set_service_links_input.go new file mode 100644 index 00000000..b471e96c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_set_service_links_input.go @@ -0,0 +1,67 @@ +package client + +const ( + SET_SERVICE_LINKS_INPUT_TYPE = "setServiceLinksInput" +) + +type SetServiceLinksInput struct { + Resource + + ServiceLinks []interface{} `json:"serviceLinks,omitempty" yaml:"service_links,omitempty"` +} + +type SetServiceLinksInputCollection struct { + Collection + Data []SetServiceLinksInput `json:"data,omitempty"` +} + +type SetServiceLinksInputClient struct { + rancherClient *RancherClient +} + +type SetServiceLinksInputOperations interface { + List(opts *ListOpts) (*SetServiceLinksInputCollection, error) + Create(opts *SetServiceLinksInput) (*SetServiceLinksInput, error) + Update(existing *SetServiceLinksInput, updates interface{}) (*SetServiceLinksInput, error) + ById(id string) (*SetServiceLinksInput, error) + Delete(container *SetServiceLinksInput) error +} + +func newSetServiceLinksInputClient(rancherClient *RancherClient) *SetServiceLinksInputClient { + return &SetServiceLinksInputClient{ + rancherClient: rancherClient, + } +} + +func (c *SetServiceLinksInputClient) Create(container *SetServiceLinksInput) (*SetServiceLinksInput, error) { + resp := &SetServiceLinksInput{} + err := c.rancherClient.doCreate(SET_SERVICE_LINKS_INPUT_TYPE, container, resp) + return resp, err +} + +func (c *SetServiceLinksInputClient) Update(existing *SetServiceLinksInput, updates interface{}) (*SetServiceLinksInput, error) { + resp := &SetServiceLinksInput{} + err := c.rancherClient.doUpdate(SET_SERVICE_LINKS_INPUT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SetServiceLinksInputClient) List(opts *ListOpts) (*SetServiceLinksInputCollection, error) { + resp := &SetServiceLinksInputCollection{} + err := c.rancherClient.doList(SET_SERVICE_LINKS_INPUT_TYPE, opts, resp) + return resp, err +} + +func (c *SetServiceLinksInputClient) ById(id string) (*SetServiceLinksInput, error) { + resp := &SetServiceLinksInput{} + err := c.rancherClient.doById(SET_SERVICE_LINKS_INPUT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SetServiceLinksInputClient) Delete(container *SetServiceLinksInput) error { + return c.rancherClient.doResourceDelete(SET_SERVICE_LINKS_INPUT_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_setting.go b/vendor/github.com/rancher/go-rancher/client/generated_setting.go new file mode 100644 index 00000000..1b65322d --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_setting.go @@ -0,0 +1,69 @@ +package client + +const ( + SETTING_TYPE = "setting" +) + +type Setting struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Value string `json:"value,omitempty" yaml:"value,omitempty"` +} + +type SettingCollection struct { + Collection + Data []Setting `json:"data,omitempty"` +} + +type SettingClient struct { + rancherClient *RancherClient +} + +type SettingOperations interface { + List(opts *ListOpts) (*SettingCollection, error) + Create(opts *Setting) (*Setting, error) + Update(existing *Setting, updates interface{}) (*Setting, error) + ById(id string) (*Setting, error) + Delete(container *Setting) error +} + +func newSettingClient(rancherClient *RancherClient) *SettingClient { + return &SettingClient{ + rancherClient: rancherClient, + } +} + +func (c *SettingClient) Create(container *Setting) (*Setting, error) { + resp := &Setting{} + err := c.rancherClient.doCreate(SETTING_TYPE, container, resp) + return resp, err +} + +func (c *SettingClient) Update(existing *Setting, updates interface{}) (*Setting, error) { + resp := &Setting{} + err := c.rancherClient.doUpdate(SETTING_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SettingClient) List(opts *ListOpts) (*SettingCollection, error) { + resp := &SettingCollection{} + err := c.rancherClient.doList(SETTING_TYPE, opts, resp) + return resp, err +} + +func (c *SettingClient) ById(id string) (*Setting, error) { + resp := &Setting{} + err := c.rancherClient.doById(SETTING_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SettingClient) Delete(container *Setting) error { + return c.rancherClient.doResourceDelete(SETTING_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_snapshot.go b/vendor/github.com/rancher/go-rancher/client/generated_snapshot.go new file mode 100644 index 00000000..770d54b7 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_snapshot.go @@ -0,0 +1,128 @@ +package client + +const ( + SNAPSHOT_TYPE = "snapshot" +) + +type Snapshot struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + ManagedVolumeUUID string `json:"managedVolumeUUID,omitempty" yaml:"managed_volume_uuid,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + VolumeId string `json:"volumeId,omitempty" yaml:"volume_id,omitempty"` +} + +type SnapshotCollection struct { + Collection + Data []Snapshot `json:"data,omitempty"` +} + +type SnapshotClient struct { + rancherClient *RancherClient +} + +type SnapshotOperations interface { + List(opts *ListOpts) (*SnapshotCollection, error) + Create(opts *Snapshot) (*Snapshot, error) + Update(existing *Snapshot, updates interface{}) (*Snapshot, error) + ById(id string) (*Snapshot, error) + Delete(container *Snapshot) error + + ActionBackup(*Snapshot) (*Snapshot, error) + + ActionCreate(*Snapshot) (*Snapshot, error) + + ActionRemove(*Snapshot) (*Snapshot, error) +} + +func newSnapshotClient(rancherClient *RancherClient) *SnapshotClient { + return &SnapshotClient{ + rancherClient: rancherClient, + } +} + +func (c *SnapshotClient) Create(container *Snapshot) (*Snapshot, error) { + resp := &Snapshot{} + err := c.rancherClient.doCreate(SNAPSHOT_TYPE, container, resp) + return resp, err +} + +func (c *SnapshotClient) Update(existing *Snapshot, updates interface{}) (*Snapshot, error) { + resp := &Snapshot{} + err := c.rancherClient.doUpdate(SNAPSHOT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SnapshotClient) List(opts *ListOpts) (*SnapshotCollection, error) { + resp := &SnapshotCollection{} + err := c.rancherClient.doList(SNAPSHOT_TYPE, opts, resp) + return resp, err +} + +func (c *SnapshotClient) ById(id string) (*Snapshot, error) { + resp := &Snapshot{} + err := c.rancherClient.doById(SNAPSHOT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SnapshotClient) Delete(container *Snapshot) error { + return c.rancherClient.doResourceDelete(SNAPSHOT_TYPE, &container.Resource) +} + +func (c *SnapshotClient) ActionBackup(resource *Snapshot) (*Snapshot, error) { + + resp := &Snapshot{} + + err := c.rancherClient.doAction(SNAPSHOT_TYPE, "backup", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SnapshotClient) ActionCreate(resource *Snapshot) (*Snapshot, error) { + + resp := &Snapshot{} + + err := c.rancherClient.doAction(SNAPSHOT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *SnapshotClient) ActionRemove(resource *Snapshot) (*Snapshot, error) { + + resp := &Snapshot{} + + err := c.rancherClient.doAction(SNAPSHOT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_softlayer_config.go b/vendor/github.com/rancher/go-rancher/client/generated_softlayer_config.go new file mode 100644 index 00000000..500d5a90 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_softlayer_config.go @@ -0,0 +1,95 @@ +package client + +const ( + SOFTLAYER_CONFIG_TYPE = "softlayerConfig" +) + +type SoftlayerConfig struct { + Resource + + ApiEndpoint string `json:"apiEndpoint,omitempty" yaml:"api_endpoint,omitempty"` + + ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"` + + Cpu string `json:"cpu,omitempty" yaml:"cpu,omitempty"` + + DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"` + + Domain string `json:"domain,omitempty" yaml:"domain,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + HourlyBilling bool `json:"hourlyBilling,omitempty" yaml:"hourly_billing,omitempty"` + + Image string `json:"image,omitempty" yaml:"image,omitempty"` + + LocalDisk bool `json:"localDisk,omitempty" yaml:"local_disk,omitempty"` + + Memory string `json:"memory,omitempty" yaml:"memory,omitempty"` + + PrivateNetOnly bool `json:"privateNetOnly,omitempty" yaml:"private_net_only,omitempty"` + + PrivateVlanId string `json:"privateVlanId,omitempty" yaml:"private_vlan_id,omitempty"` + + PublicVlanId string `json:"publicVlanId,omitempty" yaml:"public_vlan_id,omitempty"` + + Region string `json:"region,omitempty" yaml:"region,omitempty"` + + User string `json:"user,omitempty" yaml:"user,omitempty"` +} + +type SoftlayerConfigCollection struct { + Collection + Data []SoftlayerConfig `json:"data,omitempty"` +} + +type SoftlayerConfigClient struct { + rancherClient *RancherClient +} + +type SoftlayerConfigOperations interface { + List(opts *ListOpts) (*SoftlayerConfigCollection, error) + Create(opts *SoftlayerConfig) (*SoftlayerConfig, error) + Update(existing *SoftlayerConfig, updates interface{}) (*SoftlayerConfig, error) + ById(id string) (*SoftlayerConfig, error) + Delete(container *SoftlayerConfig) error +} + +func newSoftlayerConfigClient(rancherClient *RancherClient) *SoftlayerConfigClient { + return &SoftlayerConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *SoftlayerConfigClient) Create(container *SoftlayerConfig) (*SoftlayerConfig, error) { + resp := &SoftlayerConfig{} + err := c.rancherClient.doCreate(SOFTLAYER_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *SoftlayerConfigClient) Update(existing *SoftlayerConfig, updates interface{}) (*SoftlayerConfig, error) { + resp := &SoftlayerConfig{} + err := c.rancherClient.doUpdate(SOFTLAYER_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SoftlayerConfigClient) List(opts *ListOpts) (*SoftlayerConfigCollection, error) { + resp := &SoftlayerConfigCollection{} + err := c.rancherClient.doList(SOFTLAYER_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *SoftlayerConfigClient) ById(id string) (*SoftlayerConfig, error) { + resp := &SoftlayerConfig{} + err := c.rancherClient.doById(SOFTLAYER_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SoftlayerConfigClient) Delete(container *SoftlayerConfig) error { + return c.rancherClient.doResourceDelete(SOFTLAYER_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_state_transition.go b/vendor/github.com/rancher/go-rancher/client/generated_state_transition.go new file mode 100644 index 00000000..d763903f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_state_transition.go @@ -0,0 +1,65 @@ +package client + +const ( + STATE_TRANSITION_TYPE = "stateTransition" +) + +type StateTransition struct { + Resource +} + +type StateTransitionCollection struct { + Collection + Data []StateTransition `json:"data,omitempty"` +} + +type StateTransitionClient struct { + rancherClient *RancherClient +} + +type StateTransitionOperations interface { + List(opts *ListOpts) (*StateTransitionCollection, error) + Create(opts *StateTransition) (*StateTransition, error) + Update(existing *StateTransition, updates interface{}) (*StateTransition, error) + ById(id string) (*StateTransition, error) + Delete(container *StateTransition) error +} + +func newStateTransitionClient(rancherClient *RancherClient) *StateTransitionClient { + return &StateTransitionClient{ + rancherClient: rancherClient, + } +} + +func (c *StateTransitionClient) Create(container *StateTransition) (*StateTransition, error) { + resp := &StateTransition{} + err := c.rancherClient.doCreate(STATE_TRANSITION_TYPE, container, resp) + return resp, err +} + +func (c *StateTransitionClient) Update(existing *StateTransition, updates interface{}) (*StateTransition, error) { + resp := &StateTransition{} + err := c.rancherClient.doUpdate(STATE_TRANSITION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *StateTransitionClient) List(opts *ListOpts) (*StateTransitionCollection, error) { + resp := &StateTransitionCollection{} + err := c.rancherClient.doList(STATE_TRANSITION_TYPE, opts, resp) + return resp, err +} + +func (c *StateTransitionClient) ById(id string) (*StateTransition, error) { + resp := &StateTransition{} + err := c.rancherClient.doById(STATE_TRANSITION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *StateTransitionClient) Delete(container *StateTransition) error { + return c.rancherClient.doResourceDelete(STATE_TRANSITION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_stats_access.go b/vendor/github.com/rancher/go-rancher/client/generated_stats_access.go new file mode 100644 index 00000000..1ec4d45b --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_stats_access.go @@ -0,0 +1,69 @@ +package client + +const ( + STATS_ACCESS_TYPE = "statsAccess" +) + +type StatsAccess struct { + Resource + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Url string `json:"url,omitempty" yaml:"url,omitempty"` +} + +type StatsAccessCollection struct { + Collection + Data []StatsAccess `json:"data,omitempty"` +} + +type StatsAccessClient struct { + rancherClient *RancherClient +} + +type StatsAccessOperations interface { + List(opts *ListOpts) (*StatsAccessCollection, error) + Create(opts *StatsAccess) (*StatsAccess, error) + Update(existing *StatsAccess, updates interface{}) (*StatsAccess, error) + ById(id string) (*StatsAccess, error) + Delete(container *StatsAccess) error +} + +func newStatsAccessClient(rancherClient *RancherClient) *StatsAccessClient { + return &StatsAccessClient{ + rancherClient: rancherClient, + } +} + +func (c *StatsAccessClient) Create(container *StatsAccess) (*StatsAccess, error) { + resp := &StatsAccess{} + err := c.rancherClient.doCreate(STATS_ACCESS_TYPE, container, resp) + return resp, err +} + +func (c *StatsAccessClient) Update(existing *StatsAccess, updates interface{}) (*StatsAccess, error) { + resp := &StatsAccess{} + err := c.rancherClient.doUpdate(STATS_ACCESS_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *StatsAccessClient) List(opts *ListOpts) (*StatsAccessCollection, error) { + resp := &StatsAccessCollection{} + err := c.rancherClient.doList(STATS_ACCESS_TYPE, opts, resp) + return resp, err +} + +func (c *StatsAccessClient) ById(id string) (*StatsAccess, error) { + resp := &StatsAccess{} + err := c.rancherClient.doById(STATS_ACCESS_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *StatsAccessClient) Delete(container *StatsAccess) error { + return c.rancherClient.doResourceDelete(STATS_ACCESS_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_storage_pool.go b/vendor/github.com/rancher/go-rancher/client/generated_storage_pool.go new file mode 100644 index 00000000..8941662a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_storage_pool.go @@ -0,0 +1,172 @@ +package client + +const ( + STORAGE_POOL_TYPE = "storagePool" +) + +type StoragePool struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + DriverName string `json:"driverName,omitempty" yaml:"driver_name,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type StoragePoolCollection struct { + Collection + Data []StoragePool `json:"data,omitempty"` +} + +type StoragePoolClient struct { + rancherClient *RancherClient +} + +type StoragePoolOperations interface { + List(opts *ListOpts) (*StoragePoolCollection, error) + Create(opts *StoragePool) (*StoragePool, error) + Update(existing *StoragePool, updates interface{}) (*StoragePool, error) + ById(id string) (*StoragePool, error) + Delete(container *StoragePool) error + + ActionActivate(*StoragePool) (*StoragePool, error) + + ActionCreate(*StoragePool) (*StoragePool, error) + + ActionDeactivate(*StoragePool) (*StoragePool, error) + + ActionPurge(*StoragePool) (*StoragePool, error) + + ActionRemove(*StoragePool) (*StoragePool, error) + + ActionRestore(*StoragePool) (*StoragePool, error) + + ActionUpdate(*StoragePool) (*StoragePool, error) +} + +func newStoragePoolClient(rancherClient *RancherClient) *StoragePoolClient { + return &StoragePoolClient{ + rancherClient: rancherClient, + } +} + +func (c *StoragePoolClient) Create(container *StoragePool) (*StoragePool, error) { + resp := &StoragePool{} + err := c.rancherClient.doCreate(STORAGE_POOL_TYPE, container, resp) + return resp, err +} + +func (c *StoragePoolClient) Update(existing *StoragePool, updates interface{}) (*StoragePool, error) { + resp := &StoragePool{} + err := c.rancherClient.doUpdate(STORAGE_POOL_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *StoragePoolClient) List(opts *ListOpts) (*StoragePoolCollection, error) { + resp := &StoragePoolCollection{} + err := c.rancherClient.doList(STORAGE_POOL_TYPE, opts, resp) + return resp, err +} + +func (c *StoragePoolClient) ById(id string) (*StoragePool, error) { + resp := &StoragePool{} + err := c.rancherClient.doById(STORAGE_POOL_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *StoragePoolClient) Delete(container *StoragePool) error { + return c.rancherClient.doResourceDelete(STORAGE_POOL_TYPE, &container.Resource) +} + +func (c *StoragePoolClient) ActionActivate(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *StoragePoolClient) ActionCreate(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *StoragePoolClient) ActionDeactivate(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *StoragePoolClient) ActionPurge(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *StoragePoolClient) ActionRemove(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *StoragePoolClient) ActionRestore(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *StoragePoolClient) ActionUpdate(resource *StoragePool) (*StoragePool, error) { + + resp := &StoragePool{} + + err := c.rancherClient.doAction(STORAGE_POOL_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_subscribe.go b/vendor/github.com/rancher/go-rancher/client/generated_subscribe.go new file mode 100644 index 00000000..b8c6aa07 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_subscribe.go @@ -0,0 +1,69 @@ +package client + +const ( + SUBSCRIBE_TYPE = "subscribe" +) + +type Subscribe struct { + Resource + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + EventNames []string `json:"eventNames,omitempty" yaml:"event_names,omitempty"` +} + +type SubscribeCollection struct { + Collection + Data []Subscribe `json:"data,omitempty"` +} + +type SubscribeClient struct { + rancherClient *RancherClient +} + +type SubscribeOperations interface { + List(opts *ListOpts) (*SubscribeCollection, error) + Create(opts *Subscribe) (*Subscribe, error) + Update(existing *Subscribe, updates interface{}) (*Subscribe, error) + ById(id string) (*Subscribe, error) + Delete(container *Subscribe) error +} + +func newSubscribeClient(rancherClient *RancherClient) *SubscribeClient { + return &SubscribeClient{ + rancherClient: rancherClient, + } +} + +func (c *SubscribeClient) Create(container *Subscribe) (*Subscribe, error) { + resp := &Subscribe{} + err := c.rancherClient.doCreate(SUBSCRIBE_TYPE, container, resp) + return resp, err +} + +func (c *SubscribeClient) Update(existing *Subscribe, updates interface{}) (*Subscribe, error) { + resp := &Subscribe{} + err := c.rancherClient.doUpdate(SUBSCRIBE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *SubscribeClient) List(opts *ListOpts) (*SubscribeCollection, error) { + resp := &SubscribeCollection{} + err := c.rancherClient.doList(SUBSCRIBE_TYPE, opts, resp) + return resp, err +} + +func (c *SubscribeClient) ById(id string) (*Subscribe, error) { + resp := &Subscribe{} + err := c.rancherClient.doById(SUBSCRIBE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *SubscribeClient) Delete(container *Subscribe) error { + return c.rancherClient.doResourceDelete(SUBSCRIBE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_task.go b/vendor/github.com/rancher/go-rancher/client/generated_task.go new file mode 100644 index 00000000..13730c4e --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_task.go @@ -0,0 +1,78 @@ +package client + +const ( + TASK_TYPE = "task" +) + +type Task struct { + Resource + + Name string `json:"name,omitempty" yaml:"name,omitempty"` +} + +type TaskCollection struct { + Collection + Data []Task `json:"data,omitempty"` +} + +type TaskClient struct { + rancherClient *RancherClient +} + +type TaskOperations interface { + List(opts *ListOpts) (*TaskCollection, error) + Create(opts *Task) (*Task, error) + Update(existing *Task, updates interface{}) (*Task, error) + ById(id string) (*Task, error) + Delete(container *Task) error + + ActionExecute(*Task) (*Task, error) +} + +func newTaskClient(rancherClient *RancherClient) *TaskClient { + return &TaskClient{ + rancherClient: rancherClient, + } +} + +func (c *TaskClient) Create(container *Task) (*Task, error) { + resp := &Task{} + err := c.rancherClient.doCreate(TASK_TYPE, container, resp) + return resp, err +} + +func (c *TaskClient) Update(existing *Task, updates interface{}) (*Task, error) { + resp := &Task{} + err := c.rancherClient.doUpdate(TASK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *TaskClient) List(opts *ListOpts) (*TaskCollection, error) { + resp := &TaskCollection{} + err := c.rancherClient.doList(TASK_TYPE, opts, resp) + return resp, err +} + +func (c *TaskClient) ById(id string) (*Task, error) { + resp := &Task{} + err := c.rancherClient.doById(TASK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *TaskClient) Delete(container *Task) error { + return c.rancherClient.doResourceDelete(TASK_TYPE, &container.Resource) +} + +func (c *TaskClient) ActionExecute(resource *Task) (*Task, error) { + + resp := &Task{} + + err := c.rancherClient.doAction(TASK_TYPE, "execute", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_task_instance.go b/vendor/github.com/rancher/go-rancher/client/generated_task_instance.go new file mode 100644 index 00000000..52739b11 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_task_instance.go @@ -0,0 +1,77 @@ +package client + +const ( + TASK_INSTANCE_TYPE = "taskInstance" +) + +type TaskInstance struct { + Resource + + EndTime string `json:"endTime,omitempty" yaml:"end_time,omitempty"` + + Exception string `json:"exception,omitempty" yaml:"exception,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + ServerId string `json:"serverId,omitempty" yaml:"server_id,omitempty"` + + StartTime string `json:"startTime,omitempty" yaml:"start_time,omitempty"` + + TaskId string `json:"taskId,omitempty" yaml:"task_id,omitempty"` +} + +type TaskInstanceCollection struct { + Collection + Data []TaskInstance `json:"data,omitempty"` +} + +type TaskInstanceClient struct { + rancherClient *RancherClient +} + +type TaskInstanceOperations interface { + List(opts *ListOpts) (*TaskInstanceCollection, error) + Create(opts *TaskInstance) (*TaskInstance, error) + Update(existing *TaskInstance, updates interface{}) (*TaskInstance, error) + ById(id string) (*TaskInstance, error) + Delete(container *TaskInstance) error +} + +func newTaskInstanceClient(rancherClient *RancherClient) *TaskInstanceClient { + return &TaskInstanceClient{ + rancherClient: rancherClient, + } +} + +func (c *TaskInstanceClient) Create(container *TaskInstance) (*TaskInstance, error) { + resp := &TaskInstance{} + err := c.rancherClient.doCreate(TASK_INSTANCE_TYPE, container, resp) + return resp, err +} + +func (c *TaskInstanceClient) Update(existing *TaskInstance, updates interface{}) (*TaskInstance, error) { + resp := &TaskInstance{} + err := c.rancherClient.doUpdate(TASK_INSTANCE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *TaskInstanceClient) List(opts *ListOpts) (*TaskInstanceCollection, error) { + resp := &TaskInstanceCollection{} + err := c.rancherClient.doList(TASK_INSTANCE_TYPE, opts, resp) + return resp, err +} + +func (c *TaskInstanceClient) ById(id string) (*TaskInstance, error) { + resp := &TaskInstance{} + err := c.rancherClient.doById(TASK_INSTANCE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *TaskInstanceClient) Delete(container *TaskInstance) error { + return c.rancherClient.doResourceDelete(TASK_INSTANCE_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_to_service_upgrade_strategy.go b/vendor/github.com/rancher/go-rancher/client/generated_to_service_upgrade_strategy.go new file mode 100644 index 00000000..3abdc456 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_to_service_upgrade_strategy.go @@ -0,0 +1,75 @@ +package client + +const ( + TO_SERVICE_UPGRADE_STRATEGY_TYPE = "toServiceUpgradeStrategy" +) + +type ToServiceUpgradeStrategy struct { + Resource + + BatchSize int64 `json:"batchSize,omitempty" yaml:"batch_size,omitempty"` + + FinalScale int64 `json:"finalScale,omitempty" yaml:"final_scale,omitempty"` + + IntervalMillis int64 `json:"intervalMillis,omitempty" yaml:"interval_millis,omitempty"` + + ToServiceId string `json:"toServiceId,omitempty" yaml:"to_service_id,omitempty"` + + UpdateLinks bool `json:"updateLinks,omitempty" yaml:"update_links,omitempty"` +} + +type ToServiceUpgradeStrategyCollection struct { + Collection + Data []ToServiceUpgradeStrategy `json:"data,omitempty"` +} + +type ToServiceUpgradeStrategyClient struct { + rancherClient *RancherClient +} + +type ToServiceUpgradeStrategyOperations interface { + List(opts *ListOpts) (*ToServiceUpgradeStrategyCollection, error) + Create(opts *ToServiceUpgradeStrategy) (*ToServiceUpgradeStrategy, error) + Update(existing *ToServiceUpgradeStrategy, updates interface{}) (*ToServiceUpgradeStrategy, error) + ById(id string) (*ToServiceUpgradeStrategy, error) + Delete(container *ToServiceUpgradeStrategy) error +} + +func newToServiceUpgradeStrategyClient(rancherClient *RancherClient) *ToServiceUpgradeStrategyClient { + return &ToServiceUpgradeStrategyClient{ + rancherClient: rancherClient, + } +} + +func (c *ToServiceUpgradeStrategyClient) Create(container *ToServiceUpgradeStrategy) (*ToServiceUpgradeStrategy, error) { + resp := &ToServiceUpgradeStrategy{} + err := c.rancherClient.doCreate(TO_SERVICE_UPGRADE_STRATEGY_TYPE, container, resp) + return resp, err +} + +func (c *ToServiceUpgradeStrategyClient) Update(existing *ToServiceUpgradeStrategy, updates interface{}) (*ToServiceUpgradeStrategy, error) { + resp := &ToServiceUpgradeStrategy{} + err := c.rancherClient.doUpdate(TO_SERVICE_UPGRADE_STRATEGY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ToServiceUpgradeStrategyClient) List(opts *ListOpts) (*ToServiceUpgradeStrategyCollection, error) { + resp := &ToServiceUpgradeStrategyCollection{} + err := c.rancherClient.doList(TO_SERVICE_UPGRADE_STRATEGY_TYPE, opts, resp) + return resp, err +} + +func (c *ToServiceUpgradeStrategyClient) ById(id string) (*ToServiceUpgradeStrategy, error) { + resp := &ToServiceUpgradeStrategy{} + err := c.rancherClient.doById(TO_SERVICE_UPGRADE_STRATEGY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ToServiceUpgradeStrategyClient) Delete(container *ToServiceUpgradeStrategy) error { + return c.rancherClient.doResourceDelete(TO_SERVICE_UPGRADE_STRATEGY_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_type_documentation.go b/vendor/github.com/rancher/go-rancher/client/generated_type_documentation.go new file mode 100644 index 00000000..dc1d5ef8 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_type_documentation.go @@ -0,0 +1,69 @@ +package client + +const ( + TYPE_DOCUMENTATION_TYPE = "typeDocumentation" +) + +type TypeDocumentation struct { + Resource + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + ResourceFields map[string]interface{} `json:"resourceFields,omitempty" yaml:"resource_fields,omitempty"` +} + +type TypeDocumentationCollection struct { + Collection + Data []TypeDocumentation `json:"data,omitempty"` +} + +type TypeDocumentationClient struct { + rancherClient *RancherClient +} + +type TypeDocumentationOperations interface { + List(opts *ListOpts) (*TypeDocumentationCollection, error) + Create(opts *TypeDocumentation) (*TypeDocumentation, error) + Update(existing *TypeDocumentation, updates interface{}) (*TypeDocumentation, error) + ById(id string) (*TypeDocumentation, error) + Delete(container *TypeDocumentation) error +} + +func newTypeDocumentationClient(rancherClient *RancherClient) *TypeDocumentationClient { + return &TypeDocumentationClient{ + rancherClient: rancherClient, + } +} + +func (c *TypeDocumentationClient) Create(container *TypeDocumentation) (*TypeDocumentation, error) { + resp := &TypeDocumentation{} + err := c.rancherClient.doCreate(TYPE_DOCUMENTATION_TYPE, container, resp) + return resp, err +} + +func (c *TypeDocumentationClient) Update(existing *TypeDocumentation, updates interface{}) (*TypeDocumentation, error) { + resp := &TypeDocumentation{} + err := c.rancherClient.doUpdate(TYPE_DOCUMENTATION_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *TypeDocumentationClient) List(opts *ListOpts) (*TypeDocumentationCollection, error) { + resp := &TypeDocumentationCollection{} + err := c.rancherClient.doList(TYPE_DOCUMENTATION_TYPE, opts, resp) + return resp, err +} + +func (c *TypeDocumentationClient) ById(id string) (*TypeDocumentation, error) { + resp := &TypeDocumentation{} + err := c.rancherClient.doById(TYPE_DOCUMENTATION_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *TypeDocumentationClient) Delete(container *TypeDocumentation) error { + return c.rancherClient.doResourceDelete(TYPE_DOCUMENTATION_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_ubiquity_config.go b/vendor/github.com/rancher/go-rancher/client/generated_ubiquity_config.go new file mode 100644 index 00000000..63f91d68 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_ubiquity_config.go @@ -0,0 +1,77 @@ +package client + +const ( + UBIQUITY_CONFIG_TYPE = "ubiquityConfig" +) + +type UbiquityConfig struct { + Resource + + ApiToken string `json:"apiToken,omitempty" yaml:"api_token,omitempty"` + + ApiUsername string `json:"apiUsername,omitempty" yaml:"api_username,omitempty"` + + ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"` + + FlavorId string `json:"flavorId,omitempty" yaml:"flavor_id,omitempty"` + + ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"` + + ZoneId string `json:"zoneId,omitempty" yaml:"zone_id,omitempty"` +} + +type UbiquityConfigCollection struct { + Collection + Data []UbiquityConfig `json:"data,omitempty"` +} + +type UbiquityConfigClient struct { + rancherClient *RancherClient +} + +type UbiquityConfigOperations interface { + List(opts *ListOpts) (*UbiquityConfigCollection, error) + Create(opts *UbiquityConfig) (*UbiquityConfig, error) + Update(existing *UbiquityConfig, updates interface{}) (*UbiquityConfig, error) + ById(id string) (*UbiquityConfig, error) + Delete(container *UbiquityConfig) error +} + +func newUbiquityConfigClient(rancherClient *RancherClient) *UbiquityConfigClient { + return &UbiquityConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *UbiquityConfigClient) Create(container *UbiquityConfig) (*UbiquityConfig, error) { + resp := &UbiquityConfig{} + err := c.rancherClient.doCreate(UBIQUITY_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *UbiquityConfigClient) Update(existing *UbiquityConfig, updates interface{}) (*UbiquityConfig, error) { + resp := &UbiquityConfig{} + err := c.rancherClient.doUpdate(UBIQUITY_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *UbiquityConfigClient) List(opts *ListOpts) (*UbiquityConfigCollection, error) { + resp := &UbiquityConfigCollection{} + err := c.rancherClient.doList(UBIQUITY_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *UbiquityConfigClient) ById(id string) (*UbiquityConfig, error) { + resp := &UbiquityConfig{} + err := c.rancherClient.doById(UBIQUITY_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *UbiquityConfigClient) Delete(container *UbiquityConfig) error { + return c.rancherClient.doResourceDelete(UBIQUITY_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_user_preference.go b/vendor/github.com/rancher/go-rancher/client/generated_user_preference.go new file mode 100644 index 00000000..5d2203b6 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_user_preference.go @@ -0,0 +1,165 @@ +package client + +const ( + USER_PREFERENCE_TYPE = "userPreference" +) + +type UserPreference struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Value string `json:"value,omitempty" yaml:"value,omitempty"` +} + +type UserPreferenceCollection struct { + Collection + Data []UserPreference `json:"data,omitempty"` +} + +type UserPreferenceClient struct { + rancherClient *RancherClient +} + +type UserPreferenceOperations interface { + List(opts *ListOpts) (*UserPreferenceCollection, error) + Create(opts *UserPreference) (*UserPreference, error) + Update(existing *UserPreference, updates interface{}) (*UserPreference, error) + ById(id string) (*UserPreference, error) + Delete(container *UserPreference) error + + ActionActivate(*UserPreference) (*UserPreference, error) + + ActionCreate(*UserPreference) (*UserPreference, error) + + ActionDeactivate(*UserPreference) (*UserPreference, error) + + ActionPurge(*UserPreference) (*UserPreference, error) + + ActionRemove(*UserPreference) (*UserPreference, error) + + ActionRestore(*UserPreference) (*UserPreference, error) + + ActionUpdate(*UserPreference) (*UserPreference, error) +} + +func newUserPreferenceClient(rancherClient *RancherClient) *UserPreferenceClient { + return &UserPreferenceClient{ + rancherClient: rancherClient, + } +} + +func (c *UserPreferenceClient) Create(container *UserPreference) (*UserPreference, error) { + resp := &UserPreference{} + err := c.rancherClient.doCreate(USER_PREFERENCE_TYPE, container, resp) + return resp, err +} + +func (c *UserPreferenceClient) Update(existing *UserPreference, updates interface{}) (*UserPreference, error) { + resp := &UserPreference{} + err := c.rancherClient.doUpdate(USER_PREFERENCE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *UserPreferenceClient) List(opts *ListOpts) (*UserPreferenceCollection, error) { + resp := &UserPreferenceCollection{} + err := c.rancherClient.doList(USER_PREFERENCE_TYPE, opts, resp) + return resp, err +} + +func (c *UserPreferenceClient) ById(id string) (*UserPreference, error) { + resp := &UserPreference{} + err := c.rancherClient.doById(USER_PREFERENCE_TYPE, id, resp) + return resp, err +} + +func (c *UserPreferenceClient) Delete(container *UserPreference) error { + return c.rancherClient.doResourceDelete(USER_PREFERENCE_TYPE, &container.Resource) +} + +func (c *UserPreferenceClient) ActionActivate(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *UserPreferenceClient) ActionCreate(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *UserPreferenceClient) ActionDeactivate(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *UserPreferenceClient) ActionPurge(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *UserPreferenceClient) ActionRemove(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *UserPreferenceClient) ActionRestore(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *UserPreferenceClient) ActionUpdate(resource *UserPreference) (*UserPreference, error) { + + resp := &UserPreference{} + + err := c.rancherClient.doAction(USER_PREFERENCE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_virtual_machine.go b/vendor/github.com/rancher/go-rancher/client/generated_virtual_machine.go new file mode 100644 index 00000000..db75cc79 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_virtual_machine.go @@ -0,0 +1,375 @@ +package client + +const ( + VIRTUAL_MACHINE_TYPE = "virtualMachine" +) + +type VirtualMachine struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` + + AllocationState string `json:"allocationState,omitempty" yaml:"allocation_state,omitempty"` + + Command []string `json:"command,omitempty" yaml:"command,omitempty"` + + Count int64 `json:"count,omitempty" yaml:"count,omitempty"` + + CpuSet string `json:"cpuSet,omitempty" yaml:"cpu_set,omitempty"` + + CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"` + + CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Disks []interface{} `json:"disks,omitempty" yaml:"disks,omitempty"` + + Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"` + + DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"` + + DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"` + + Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"` + + FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"` + + HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` + + ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` + + InstanceLinks map[string]interface{} `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"` + + LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"` + + Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"` + + MemoryMb int64 `json:"memoryMb,omitempty" yaml:"memory_mb,omitempty"` + + MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"` + + NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"` + + NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"` + + Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"` + + PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"` + + RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"` + + RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty" yaml:"restart_policy,omitempty"` + + SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"` + + StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"` + + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + SystemContainer string `json:"systemContainer,omitempty" yaml:"system_container,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vcpu int64 `json:"vcpu,omitempty" yaml:"vcpu,omitempty"` + + Version string `json:"version,omitempty" yaml:"version,omitempty"` + + VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"` +} + +type VirtualMachineCollection struct { + Collection + Data []VirtualMachine `json:"data,omitempty"` +} + +type VirtualMachineClient struct { + rancherClient *RancherClient +} + +type VirtualMachineOperations interface { + List(opts *ListOpts) (*VirtualMachineCollection, error) + Create(opts *VirtualMachine) (*VirtualMachine, error) + Update(existing *VirtualMachine, updates interface{}) (*VirtualMachine, error) + ById(id string) (*VirtualMachine, error) + Delete(container *VirtualMachine) error + + ActionAllocate(*VirtualMachine) (*Instance, error) + + ActionConsole(*VirtualMachine, *InstanceConsoleInput) (*InstanceConsole, error) + + ActionCreate(*VirtualMachine) (*Instance, error) + + ActionDeallocate(*VirtualMachine) (*Instance, error) + + ActionExecute(*VirtualMachine, *ContainerExec) (*HostAccess, error) + + ActionLogs(*VirtualMachine, *ContainerLogs) (*HostAccess, error) + + ActionMigrate(*VirtualMachine) (*Instance, error) + + ActionPurge(*VirtualMachine) (*Instance, error) + + ActionRemove(*VirtualMachine) (*Instance, error) + + ActionRestart(*VirtualMachine) (*Instance, error) + + ActionRestore(*VirtualMachine) (*Instance, error) + + ActionSetlabels(*VirtualMachine, *SetLabelsInput) (*Container, error) + + ActionStart(*VirtualMachine) (*Instance, error) + + ActionStop(*VirtualMachine, *InstanceStop) (*Instance, error) + + ActionUpdate(*VirtualMachine) (*Instance, error) + + ActionUpdatehealthy(*VirtualMachine) (*Instance, error) + + ActionUpdatereinitializing(*VirtualMachine) (*Instance, error) + + ActionUpdateunhealthy(*VirtualMachine) (*Instance, error) +} + +func newVirtualMachineClient(rancherClient *RancherClient) *VirtualMachineClient { + return &VirtualMachineClient{ + rancherClient: rancherClient, + } +} + +func (c *VirtualMachineClient) Create(container *VirtualMachine) (*VirtualMachine, error) { + resp := &VirtualMachine{} + err := c.rancherClient.doCreate(VIRTUAL_MACHINE_TYPE, container, resp) + return resp, err +} + +func (c *VirtualMachineClient) Update(existing *VirtualMachine, updates interface{}) (*VirtualMachine, error) { + resp := &VirtualMachine{} + err := c.rancherClient.doUpdate(VIRTUAL_MACHINE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *VirtualMachineClient) List(opts *ListOpts) (*VirtualMachineCollection, error) { + resp := &VirtualMachineCollection{} + err := c.rancherClient.doList(VIRTUAL_MACHINE_TYPE, opts, resp) + return resp, err +} + +func (c *VirtualMachineClient) ById(id string) (*VirtualMachine, error) { + resp := &VirtualMachine{} + err := c.rancherClient.doById(VIRTUAL_MACHINE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *VirtualMachineClient) Delete(container *VirtualMachine) error { + return c.rancherClient.doResourceDelete(VIRTUAL_MACHINE_TYPE, &container.Resource) +} + +func (c *VirtualMachineClient) ActionAllocate(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "allocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionConsole(resource *VirtualMachine, input *InstanceConsoleInput) (*InstanceConsole, error) { + + resp := &InstanceConsole{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "console", &resource.Resource, input, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionCreate(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionDeallocate(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "deallocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionExecute(resource *VirtualMachine, input *ContainerExec) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "execute", &resource.Resource, input, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionLogs(resource *VirtualMachine, input *ContainerLogs) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "logs", &resource.Resource, input, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionMigrate(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "migrate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionPurge(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionRemove(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionRestart(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "restart", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionRestore(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionSetlabels(resource *VirtualMachine, input *SetLabelsInput) (*Container, error) { + + resp := &Container{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "setlabels", &resource.Resource, input, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionStart(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "start", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionStop(resource *VirtualMachine, input *InstanceStop) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "stop", &resource.Resource, input, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionUpdate(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionUpdatehealthy(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "updatehealthy", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionUpdatereinitializing(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "updatereinitializing", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VirtualMachineClient) ActionUpdateunhealthy(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "updateunhealthy", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_virtual_machine_disk.go b/vendor/github.com/rancher/go-rancher/client/generated_virtual_machine_disk.go new file mode 100644 index 00000000..b5ef2c50 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_virtual_machine_disk.go @@ -0,0 +1,75 @@ +package client + +const ( + VIRTUAL_MACHINE_DISK_TYPE = "virtualMachineDisk" +) + +type VirtualMachineDisk struct { + Resource + + Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + Opts map[string]interface{} `json:"opts,omitempty" yaml:"opts,omitempty"` + + Root bool `json:"root,omitempty" yaml:"root,omitempty"` + + Size string `json:"size,omitempty" yaml:"size,omitempty"` +} + +type VirtualMachineDiskCollection struct { + Collection + Data []VirtualMachineDisk `json:"data,omitempty"` +} + +type VirtualMachineDiskClient struct { + rancherClient *RancherClient +} + +type VirtualMachineDiskOperations interface { + List(opts *ListOpts) (*VirtualMachineDiskCollection, error) + Create(opts *VirtualMachineDisk) (*VirtualMachineDisk, error) + Update(existing *VirtualMachineDisk, updates interface{}) (*VirtualMachineDisk, error) + ById(id string) (*VirtualMachineDisk, error) + Delete(container *VirtualMachineDisk) error +} + +func newVirtualMachineDiskClient(rancherClient *RancherClient) *VirtualMachineDiskClient { + return &VirtualMachineDiskClient{ + rancherClient: rancherClient, + } +} + +func (c *VirtualMachineDiskClient) Create(container *VirtualMachineDisk) (*VirtualMachineDisk, error) { + resp := &VirtualMachineDisk{} + err := c.rancherClient.doCreate(VIRTUAL_MACHINE_DISK_TYPE, container, resp) + return resp, err +} + +func (c *VirtualMachineDiskClient) Update(existing *VirtualMachineDisk, updates interface{}) (*VirtualMachineDisk, error) { + resp := &VirtualMachineDisk{} + err := c.rancherClient.doUpdate(VIRTUAL_MACHINE_DISK_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *VirtualMachineDiskClient) List(opts *ListOpts) (*VirtualMachineDiskCollection, error) { + resp := &VirtualMachineDiskCollection{} + err := c.rancherClient.doList(VIRTUAL_MACHINE_DISK_TYPE, opts, resp) + return resp, err +} + +func (c *VirtualMachineDiskClient) ById(id string) (*VirtualMachineDisk, error) { + resp := &VirtualMachineDisk{} + err := c.rancherClient.doById(VIRTUAL_MACHINE_DISK_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *VirtualMachineDiskClient) Delete(container *VirtualMachineDisk) error { + return c.rancherClient.doResourceDelete(VIRTUAL_MACHINE_DISK_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_virtualbox_config.go b/vendor/github.com/rancher/go-rancher/client/generated_virtualbox_config.go new file mode 100644 index 00000000..0a9e3835 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_virtualbox_config.go @@ -0,0 +1,79 @@ +package client + +const ( + VIRTUALBOX_CONFIG_TYPE = "virtualboxConfig" +) + +type VirtualboxConfig struct { + Resource + + Boot2dockerUrl string `json:"boot2dockerUrl,omitempty" yaml:"boot2docker_url,omitempty"` + + CpuCount string `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"` + + DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"` + + HostonlyCidr string `json:"hostonlyCidr,omitempty" yaml:"hostonly_cidr,omitempty"` + + ImportBoot2dockerVm string `json:"importBoot2dockerVm,omitempty" yaml:"import_boot2docker_vm,omitempty"` + + Memory string `json:"memory,omitempty" yaml:"memory,omitempty"` + + NoShare bool `json:"noShare,omitempty" yaml:"no_share,omitempty"` +} + +type VirtualboxConfigCollection struct { + Collection + Data []VirtualboxConfig `json:"data,omitempty"` +} + +type VirtualboxConfigClient struct { + rancherClient *RancherClient +} + +type VirtualboxConfigOperations interface { + List(opts *ListOpts) (*VirtualboxConfigCollection, error) + Create(opts *VirtualboxConfig) (*VirtualboxConfig, error) + Update(existing *VirtualboxConfig, updates interface{}) (*VirtualboxConfig, error) + ById(id string) (*VirtualboxConfig, error) + Delete(container *VirtualboxConfig) error +} + +func newVirtualboxConfigClient(rancherClient *RancherClient) *VirtualboxConfigClient { + return &VirtualboxConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *VirtualboxConfigClient) Create(container *VirtualboxConfig) (*VirtualboxConfig, error) { + resp := &VirtualboxConfig{} + err := c.rancherClient.doCreate(VIRTUALBOX_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *VirtualboxConfigClient) Update(existing *VirtualboxConfig, updates interface{}) (*VirtualboxConfig, error) { + resp := &VirtualboxConfig{} + err := c.rancherClient.doUpdate(VIRTUALBOX_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *VirtualboxConfigClient) List(opts *ListOpts) (*VirtualboxConfigCollection, error) { + resp := &VirtualboxConfigCollection{} + err := c.rancherClient.doList(VIRTUALBOX_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *VirtualboxConfigClient) ById(id string) (*VirtualboxConfig, error) { + resp := &VirtualboxConfig{} + err := c.rancherClient.doById(VIRTUALBOX_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *VirtualboxConfigClient) Delete(container *VirtualboxConfig) error { + return c.rancherClient.doResourceDelete(VIRTUALBOX_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_vmwarevcloudair_config.go b/vendor/github.com/rancher/go-rancher/client/generated_vmwarevcloudair_config.go new file mode 100644 index 00000000..12f962f4 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_vmwarevcloudair_config.go @@ -0,0 +1,93 @@ +package client + +const ( + VMWAREVCLOUDAIR_CONFIG_TYPE = "vmwarevcloudairConfig" +) + +type VmwarevcloudairConfig struct { + Resource + + Catalog string `json:"catalog,omitempty" yaml:"catalog,omitempty"` + + Catalogitem string `json:"catalogitem,omitempty" yaml:"catalogitem,omitempty"` + + Computeid string `json:"computeid,omitempty" yaml:"computeid,omitempty"` + + CpuCount string `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"` + + DockerPort string `json:"dockerPort,omitempty" yaml:"docker_port,omitempty"` + + Edgegateway string `json:"edgegateway,omitempty" yaml:"edgegateway,omitempty"` + + MemorySize string `json:"memorySize,omitempty" yaml:"memory_size,omitempty"` + + Orgvdcnetwork string `json:"orgvdcnetwork,omitempty" yaml:"orgvdcnetwork,omitempty"` + + Password string `json:"password,omitempty" yaml:"password,omitempty"` + + Provision bool `json:"provision,omitempty" yaml:"provision,omitempty"` + + Publicip string `json:"publicip,omitempty" yaml:"publicip,omitempty"` + + SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"` + + Username string `json:"username,omitempty" yaml:"username,omitempty"` + + Vdcid string `json:"vdcid,omitempty" yaml:"vdcid,omitempty"` +} + +type VmwarevcloudairConfigCollection struct { + Collection + Data []VmwarevcloudairConfig `json:"data,omitempty"` +} + +type VmwarevcloudairConfigClient struct { + rancherClient *RancherClient +} + +type VmwarevcloudairConfigOperations interface { + List(opts *ListOpts) (*VmwarevcloudairConfigCollection, error) + Create(opts *VmwarevcloudairConfig) (*VmwarevcloudairConfig, error) + Update(existing *VmwarevcloudairConfig, updates interface{}) (*VmwarevcloudairConfig, error) + ById(id string) (*VmwarevcloudairConfig, error) + Delete(container *VmwarevcloudairConfig) error +} + +func newVmwarevcloudairConfigClient(rancherClient *RancherClient) *VmwarevcloudairConfigClient { + return &VmwarevcloudairConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *VmwarevcloudairConfigClient) Create(container *VmwarevcloudairConfig) (*VmwarevcloudairConfig, error) { + resp := &VmwarevcloudairConfig{} + err := c.rancherClient.doCreate(VMWAREVCLOUDAIR_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *VmwarevcloudairConfigClient) Update(existing *VmwarevcloudairConfig, updates interface{}) (*VmwarevcloudairConfig, error) { + resp := &VmwarevcloudairConfig{} + err := c.rancherClient.doUpdate(VMWAREVCLOUDAIR_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *VmwarevcloudairConfigClient) List(opts *ListOpts) (*VmwarevcloudairConfigCollection, error) { + resp := &VmwarevcloudairConfigCollection{} + err := c.rancherClient.doList(VMWAREVCLOUDAIR_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *VmwarevcloudairConfigClient) ById(id string) (*VmwarevcloudairConfig, error) { + resp := &VmwarevcloudairConfig{} + err := c.rancherClient.doById(VMWAREVCLOUDAIR_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *VmwarevcloudairConfigClient) Delete(container *VmwarevcloudairConfig) error { + return c.rancherClient.doResourceDelete(VMWAREVCLOUDAIR_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_vmwarevsphere_config.go b/vendor/github.com/rancher/go-rancher/client/generated_vmwarevsphere_config.go new file mode 100644 index 00000000..f6cb9d21 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_vmwarevsphere_config.go @@ -0,0 +1,89 @@ +package client + +const ( + VMWAREVSPHERE_CONFIG_TYPE = "vmwarevsphereConfig" +) + +type VmwarevsphereConfig struct { + Resource + + Boot2dockerUrl string `json:"boot2dockerUrl,omitempty" yaml:"boot2docker_url,omitempty"` + + ComputeIp string `json:"computeIp,omitempty" yaml:"compute_ip,omitempty"` + + CpuCount string `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"` + + Datacenter string `json:"datacenter,omitempty" yaml:"datacenter,omitempty"` + + Datastore string `json:"datastore,omitempty" yaml:"datastore,omitempty"` + + DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"` + + MemorySize string `json:"memorySize,omitempty" yaml:"memory_size,omitempty"` + + Network string `json:"network,omitempty" yaml:"network,omitempty"` + + Password string `json:"password,omitempty" yaml:"password,omitempty"` + + Pool string `json:"pool,omitempty" yaml:"pool,omitempty"` + + Username string `json:"username,omitempty" yaml:"username,omitempty"` + + Vcenter string `json:"vcenter,omitempty" yaml:"vcenter,omitempty"` +} + +type VmwarevsphereConfigCollection struct { + Collection + Data []VmwarevsphereConfig `json:"data,omitempty"` +} + +type VmwarevsphereConfigClient struct { + rancherClient *RancherClient +} + +type VmwarevsphereConfigOperations interface { + List(opts *ListOpts) (*VmwarevsphereConfigCollection, error) + Create(opts *VmwarevsphereConfig) (*VmwarevsphereConfig, error) + Update(existing *VmwarevsphereConfig, updates interface{}) (*VmwarevsphereConfig, error) + ById(id string) (*VmwarevsphereConfig, error) + Delete(container *VmwarevsphereConfig) error +} + +func newVmwarevsphereConfigClient(rancherClient *RancherClient) *VmwarevsphereConfigClient { + return &VmwarevsphereConfigClient{ + rancherClient: rancherClient, + } +} + +func (c *VmwarevsphereConfigClient) Create(container *VmwarevsphereConfig) (*VmwarevsphereConfig, error) { + resp := &VmwarevsphereConfig{} + err := c.rancherClient.doCreate(VMWAREVSPHERE_CONFIG_TYPE, container, resp) + return resp, err +} + +func (c *VmwarevsphereConfigClient) Update(existing *VmwarevsphereConfig, updates interface{}) (*VmwarevsphereConfig, error) { + resp := &VmwarevsphereConfig{} + err := c.rancherClient.doUpdate(VMWAREVSPHERE_CONFIG_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *VmwarevsphereConfigClient) List(opts *ListOpts) (*VmwarevsphereConfigCollection, error) { + resp := &VmwarevsphereConfigCollection{} + err := c.rancherClient.doList(VMWAREVSPHERE_CONFIG_TYPE, opts, resp) + return resp, err +} + +func (c *VmwarevsphereConfigClient) ById(id string) (*VmwarevsphereConfig, error) { + resp := &VmwarevsphereConfig{} + err := c.rancherClient.doById(VMWAREVSPHERE_CONFIG_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *VmwarevsphereConfigClient) Delete(container *VmwarevsphereConfig) error { + return c.rancherClient.doResourceDelete(VMWAREVSPHERE_CONFIG_TYPE, &container.Resource) +} diff --git a/vendor/github.com/rancher/go-rancher/client/generated_volume.go b/vendor/github.com/rancher/go-rancher/client/generated_volume.go new file mode 100644 index 00000000..b610d529 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/generated_volume.go @@ -0,0 +1,204 @@ +package client + +const ( + VOLUME_TYPE = "volume" +) + +type Volume struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` + + DriverOpts map[string]interface{} `json:"driverOpts,omitempty" yaml:"driver_opts,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"` + + InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"` + + IsHostPath bool `json:"isHostPath,omitempty" yaml:"is_host_path,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type VolumeCollection struct { + Collection + Data []Volume `json:"data,omitempty"` +} + +type VolumeClient struct { + rancherClient *RancherClient +} + +type VolumeOperations interface { + List(opts *ListOpts) (*VolumeCollection, error) + Create(opts *Volume) (*Volume, error) + Update(existing *Volume, updates interface{}) (*Volume, error) + ById(id string) (*Volume, error) + Delete(container *Volume) error + + ActionActivate(*Volume) (*Volume, error) + + ActionAllocate(*Volume) (*Volume, error) + + ActionCreate(*Volume) (*Volume, error) + + ActionDeactivate(*Volume) (*Volume, error) + + ActionDeallocate(*Volume) (*Volume, error) + + ActionPurge(*Volume) (*Volume, error) + + ActionRemove(*Volume) (*Volume, error) + + ActionRestore(*Volume) (*Volume, error) + + ActionUpdate(*Volume) (*Volume, error) +} + +func newVolumeClient(rancherClient *RancherClient) *VolumeClient { + return &VolumeClient{ + rancherClient: rancherClient, + } +} + +func (c *VolumeClient) Create(container *Volume) (*Volume, error) { + resp := &Volume{} + err := c.rancherClient.doCreate(VOLUME_TYPE, container, resp) + return resp, err +} + +func (c *VolumeClient) Update(existing *Volume, updates interface{}) (*Volume, error) { + resp := &Volume{} + err := c.rancherClient.doUpdate(VOLUME_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *VolumeClient) List(opts *ListOpts) (*VolumeCollection, error) { + resp := &VolumeCollection{} + err := c.rancherClient.doList(VOLUME_TYPE, opts, resp) + return resp, err +} + +func (c *VolumeClient) ById(id string) (*Volume, error) { + resp := &Volume{} + err := c.rancherClient.doById(VOLUME_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *VolumeClient) Delete(container *Volume) error { + return c.rancherClient.doResourceDelete(VOLUME_TYPE, &container.Resource) +} + +func (c *VolumeClient) ActionActivate(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionAllocate(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "allocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionCreate(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionDeactivate(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionDeallocate(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "deallocate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionPurge(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "purge", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionRemove(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionRestore(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "restore", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *VolumeClient) ActionUpdate(resource *Volume) (*Volume, error) { + + resp := &Volume{} + + err := c.rancherClient.doAction(VOLUME_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} diff --git a/vendor/github.com/rancher/go-rancher/client/schemas.go b/vendor/github.com/rancher/go-rancher/client/schemas.go new file mode 100644 index 00000000..e5fd2f54 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/schemas.go @@ -0,0 +1,129 @@ +package client + +import ( + "reflect" + "strings" +) + +type Schemas struct { + Collection + Data []Schema `json:"data,omitempty"` + schemasByName map[string]*Schema +} + +func (s *Schema) CheckField(name string) (Field, bool) { + for fieldName := range s.ResourceFields { + if fieldName == name { + v, ok := s.ResourceFields[fieldName] + return v, ok + } + } + return Field{}, false +} + +func (s *Schema) Field(name string) Field { + f, _ := s.CheckField(name) + return f +} + +func (s *Schemas) CheckSchema(name string) (Schema, bool) { + for i := range s.Data { + if s.Data[i].Id == name { + return s.Data[i], true + } + } + return Schema{}, false +} + +func (s *Schemas) Schema(name string) Schema { + r, _ := s.CheckSchema(name) + return r +} + +func typeToFields(t reflect.Type) map[string]Field { + result := map[string]Field{} + + for i := 0; i < t.NumField(); i++ { + schemaField := Field{} + + typeField := t.Field(i) + if typeField.Anonymous && typeField.Type.Kind() == reflect.Struct { + parentFields := typeToFields(typeField.Type) + for k, v := range result { + parentFields[k] = v + } + result = parentFields + continue + } else if typeField.Anonymous { + continue + } + + fieldString := strings.ToLower(typeField.Type.Kind().String()) + + switch { + case strings.HasPrefix(fieldString, "int") || strings.HasPrefix(fieldString, "uint"): + schemaField.Type = "int" + case fieldString == "bool": + schemaField.Type = fieldString + case fieldString == "float32" || fieldString == "float64": + schemaField.Type = "float" + case fieldString == "string": + schemaField.Type = "string" + case fieldString == "map": + // HACK + schemaField.Type = "map[string]" + case fieldString == "slice": + // HACK + schemaField.Type = "array[string]" + } + + name := strings.Split(typeField.Tag.Get("json"), ",")[0] + if name == "" && len(typeField.Name) > 1 { + name = strings.ToLower(typeField.Name[0:1]) + typeField.Name[1:] + } else if name == "" { + name = typeField.Name + } + + if schemaField.Type != "" { + result[name] = schemaField + } + } + + return result +} + +func (s *Schemas) AddType(schemaName string, obj interface{}) *Schema { + t := reflect.TypeOf(obj) + schema := Schema{ + Resource: Resource{ + Id: schemaName, + Type: "schema", + Links: map[string]string{}, + }, + PluralName: guessPluralName(schemaName), + ResourceFields: typeToFields(t), + CollectionMethods: []string{"GET"}, + ResourceMethods: []string{"GET"}, + } + + if s.Data == nil { + s.Data = []Schema{} + } + + s.Data = append(s.Data, schema) + + return &s.Data[len(s.Data)-1] +} + +func guessPluralName(name string) string { + if name == "" { + return "" + } + + if strings.HasSuffix(name, "s") || + strings.HasSuffix(name, "ch") || + strings.HasSuffix(name, "x") { + return name + "es" + } + return name + "s" +} diff --git a/vendor/github.com/rancher/go-rancher/client/types.go b/vendor/github.com/rancher/go-rancher/client/types.go new file mode 100644 index 00000000..310fceba --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/client/types.go @@ -0,0 +1,97 @@ +package client + +type Collection struct { + Type string `json:"type,omitempty"` + ResourceType string `json:"resourceType,omitempty"` + Links map[string]string `json:"links,omitempty"` + CreateTypes map[string]string `json:"createTypes,omitempty"` + Actions map[string]string `json:"actions,omitempty"` + SortLinks map[string]string `json:"sortLinks,omitempty"` + Pagination *Pagination `json:"pagination,omitempty"` + Sort *Sort `json:"sort,omitempty"` + Filters map[string][]Condition `json:"filters,omitempty"` +} + +type GenericCollection struct { + Collection + Data []interface{} `json:"data,omitempty"` +} + +type Sort struct { + Name string `json:"name,omitempty"` + Order string `json:"order,omitempty"` + Reverse string `json:"reverse,omitempty"` +} + +type Condition struct { + Modifier string `json:"modifier,omitempty"` + Value interface{} `json:"value,omitempty"` +} + +type Pagination struct { + Marker string `json:"marker,omitempty"` + First string `json:"first,omitempty"` + Previous string `json:"previous,omitempty"` + Next string `json:"next,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Total *int64 `json:"total,omitempty"` + Partial bool `json:"partial,omitempty"` +} + +type Resource struct { + Id string `json:"id,omitempty"` + Type string `json:"type,omitempty"` + Links map[string]string `json:"links"` + Actions map[string]string `json:"actions"` +} + +type Schema struct { + Resource + PluralName string `json:"pluralName,omitempty"` + ResourceMethods []string `json:"resourceMethods,omitempty"` + ResourceFields map[string]Field `json:"resourceFields,omitempty"` + ResourceActions map[string]Action `json:"resourceActions,omitempty"` + CollectionMethods []string `json:"collectionMethods,omitempty"` + CollectionFields map[string]Field `json:"collectionFields,omitempty"` + CollectionActions map[string]Action `json:"collectionActions,omitempty"` + CollectionFilters map[string]Filter `json:"collectionFilters,omitempty"` + IncludeableLinks []string `json:"includeableLinks,omitempty"` +} + +type Field struct { + Type string `json:"type,omitempty"` + Default interface{} `json:"default,omitempty"` + Unique bool `json:"unique,omitempty"` + Nullable bool `json:"nullable,omitempty"` + Create bool `json:"create,omitempty"` + Required bool `json:"required,omitempty"` + Update bool `json:"update,omitempty"` + MinLength *int64 `json:"minLength,omitempty"` + MaxLength *int64 `json:"maxLength,omitempty"` + Min *int64 `json:"min,omitempty"` + Max *int64 `json:"max,omitempty"` + Options []string `json:"options,omitempty"` + ValidChars string `json:"validChars,omitempty"` + InvalidChars string `json:"invalidChars,omitempty"` +} + +type Action struct { + Input string `json:"input,omitempty"` + Output string `json:"output,omitempty"` +} + +type Filter struct { + Modifiers []string `json:"modifiers,omitempty"` +} + +type ListOpts struct { + Filters map[string]interface{} +} + +type ServerApiError struct { + Resource + Status int `json:"status"` + Code string `json:"code"` + Message string `json:"message"` + Detail string `json:"detail"` +} diff --git a/vendor/github.com/rancher/go-rancher/main.go b/vendor/github.com/rancher/go-rancher/main.go new file mode 100644 index 00000000..e8274c8a --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/main.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + _ "github.com/rancher/go-rancher/client" +) + +func main() { + fmt.Println("I have nothing to do...") +} diff --git a/vendor/github.com/rancher/go-rancher/schemas.json b/vendor/github.com/rancher/go-rancher/schemas.json new file mode 100644 index 00000000..40e810e4 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher/schemas.json @@ -0,0 +1,25862 @@ +{ + "type": "collection", + "resourceType": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas" + }, + "createTypes": {}, + "actions": {}, + "data": [ + { + "id": "schema", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/schema", + "collection": "http://localhost:8080/v1/schemas" + }, + "actions": {}, + "pluralName": "schemas", + "resourceFields": { + "collectionActions": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "collectionFields": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "collectionFilters": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "collectionMethods": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "includeableLinks": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "pluralName": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "resourceActions": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "resourceFields": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "resourceMethods": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "subscribe", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/subscribe", + "collection": "http://localhost:8080/v1/subscribe" + }, + "actions": {}, + "pluralName": "subscribe", + "resourceFields": { + "agentId": { + "type": "reference[agent]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "eventNames": { + "type": "array[string]", + "validChars": "*._0-9a-zA-Z;=", + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": 1, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "eventNames": { + "modifiers": [ + "eq" + ] + } + }, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "publish", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/publish" + }, + "actions": {}, + "pluralName": "publish", + "resourceFields": { + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "id": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "previousIds": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "publisher": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "resourceId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "resourceType": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "time": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioning": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningInternalMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "restartPolicy", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/restartpolicy" + }, + "actions": {}, + "pluralName": "restartPolicys", + "resourceFields": { + "maximumRetryCount": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "loadBalancerHealthCheck", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerhealthcheck" + }, + "actions": {}, + "pluralName": "loadBalancerHealthChecks", + "resourceFields": { + "healthyThreshold": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "interval": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "requestLine": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "responseTimeout": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "unhealthyThreshold": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "loadBalancerCookieStickinessPolicy", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancercookiestickinesspolicy" + }, + "actions": {}, + "pluralName": "loadBalancerCookieStickinessPolicys", + "resourceFields": { + "cookie": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "domain": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "indirect": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "mode": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "rewrite", + "insert", + "prefix" + ], + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "nocache": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "postonly": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "loadBalancerAppCookieStickinessPolicy", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerappcookiestickinesspolicy" + }, + "actions": {}, + "pluralName": "loadBalancerAppCookieStickinessPolicys", + "resourceFields": { + "cookie": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "maxLength": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "mode": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "path_parameters", + "query_string" + ], + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "prefix": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "requestLearn": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "timeout": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "globalLoadBalancerPolicy", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/globalloadbalancerpolicy" + }, + "actions": {}, + "pluralName": "globalLoadBalancerPolicys", + "resourceFields": { + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "globalLoadBalancerHealthCheck", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/globalloadbalancerhealthcheck" + }, + "actions": {}, + "pluralName": "globalLoadBalancerHealthChecks", + "resourceFields": { + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "externalHandlerProcessConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/externalhandlerprocessconfig" + }, + "actions": {}, + "pluralName": "externalHandlerProcessConfigs", + "resourceFields": { + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "onError": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "composeConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/composeconfig" + }, + "actions": {}, + "pluralName": "composeConfigs", + "resourceFields": { + "dockerComposeConfig": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "rancherComposeConfig": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [] + }, + { + "id": "addLoadBalancerInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addloadbalancerinput" + }, + "actions": {}, + "pluralName": "addLoadBalancerInputs", + "resourceFields": { + "loadBalancerId": { + "type": "reference[loadBalancer]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "weight": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "addRemoveClusterHostInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addremoveclusterhostinput" + }, + "actions": {}, + "pluralName": "addRemoveClusterHostInputs", + "resourceFields": { + "hostId": { + "type": "reference[host]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "addRemoveLoadBalancerHostInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addremoveloadbalancerhostinput" + }, + "actions": {}, + "pluralName": "addRemoveLoadBalancerHostInputs", + "resourceFields": { + "hostId": { + "type": "reference[host]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "addRemoveLoadBalancerListenerInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addremoveloadbalancerlistenerinput" + }, + "actions": {}, + "pluralName": "addRemoveLoadBalancerListenerInputs", + "resourceFields": { + "loadBalancerListenerId": { + "type": "reference[loadBalancerListener]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "addRemoveLoadBalancerTargetInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addremoveloadbalancertargetinput" + }, + "actions": {}, + "pluralName": "addRemoveLoadBalancerTargetInputs", + "resourceFields": { + "instanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "ipAddress": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "addRemoveServiceLinkInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addremoveservicelinkinput" + }, + "actions": {}, + "pluralName": "addRemoveServiceLinkInputs", + "resourceFields": { + "serviceId": { + "type": "reference[service]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "addLabelInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/addlabelinput" + }, + "actions": {}, + "pluralName": "addLabelInputs", + "resourceFields": { + "key": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "value": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "removeLabelInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/removelabelinput" + }, + "actions": {}, + "pluralName": "removeLabelInputs", + "resourceFields": { + "label": { + "type": "reference[label]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "apiKey", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/apikey", + "collection": "http://localhost:8080/v1/apikeys" + }, + "actions": {}, + "pluralName": "apiKeys", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "publicValue": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 4096, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "secretValue": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 4096, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "publicValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "registryId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "secretValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "images", + "account", + "instances" + ], + "resourceActions": { + "update": { + "input": null, + "output": "credential" + }, + "activate": { + "input": null, + "output": "credential" + }, + "remove": { + "input": null, + "output": "credential" + }, + "restore": { + "input": null, + "output": "credential" + }, + "deactivate": { + "input": null, + "output": "credential" + }, + "create": { + "input": null, + "output": "credential" + }, + "purge": { + "input": null, + "output": "credential" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "cluster", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/cluster", + "collection": "http://localhost:8080/v1/clusters" + }, + "actions": {}, + "pluralName": "clusters", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "agentId": { + "type": "reference[agent]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "apiProxy": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "computeTotal": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "info": { + "type": "json", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "physicalHostId": { + "type": "reference[physicalHost]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "discoverySpec": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "port": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "computeFree": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "computeTotal": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "isPublic": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "physicalHostId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uri": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "ipaddresses", + "storagepools", + "clusters", + "physicalhost", + "labels", + "hosts", + "containerevents", + "account", + "loadbalancerhostmaps", + "instances", + "agent", + "loadbalancers" + ], + "resourceActions": { + "update": { + "input": null, + "output": "host" + }, + "activate": { + "input": null, + "output": "host" + }, + "remove": { + "input": null, + "output": "host" + }, + "restore": { + "input": null, + "output": "host" + }, + "removelabel": { + "input": "removeLabelInput", + "output": "host" + }, + "addlabel": { + "input": "addLabelInput", + "output": "host" + }, + "deactivate": { + "input": null, + "output": "host" + }, + "create": { + "input": null, + "output": "host" + }, + "purge": { + "input": null, + "output": "host" + }, + "addhost": { + "input": "addRemoveClusterHostInput", + "output": "cluster" + }, + "removehost": { + "input": "addRemoveClusterHostInput", + "output": "cluster" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "composeConfigInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/composeconfiginput" + }, + "actions": {}, + "pluralName": "composeConfigInputs", + "resourceFields": { + "serviceIds": { + "type": "array[reference[service]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "container", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/container", + "collection": "http://localhost:8080/v1/containers" + }, + "actions": {}, + "pluralName": "containers", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "agentId": { + "type": "reference[agent]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "allocationState": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "count": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "externalId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "firstRunning": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "hostname": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": 1, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "imageUuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "nativeContainer": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "networkIds": { + "type": "array[reference[network]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "ports": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "primaryIpAddress": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "registryCredentialId": { + "type": "reference[registryCredential]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "requestedHostId": { + "type": "reference[host]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "startOnCreate": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": true + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "creating", + "migrating", + "purged", + "purging", + "removed", + "removing", + "requested", + "restarting", + "restoring", + "running", + "starting", + "stopped", + "stopping", + "updating-running", + "updating-stopped" + ], + "default": null + }, + "systemContainer": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "NetworkAgent", + "LoadBalancerAgent" + ], + "default": null + }, + "token": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "environment": { + "type": "map[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "command": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "directory": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": 1, + "maxLength": null, + "options": null, + "default": null + }, + "user": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": 1, + "maxLength": null, + "options": null, + "default": null + }, + "publishAllPorts": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": false + }, + "privileged": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": false + }, + "capAdd": { + "type": "array[enum]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "ALL", + "AUDIT_CONTROL", + "AUDIT_WRITE", + "BLOCK_SUSPEND", + "CHOWN", + "DAC_OVERRIDE", + "DAC_READ_SEARCH", + "FOWNER", + "FSETID", + "IPC_LOCK", + "IPC_OWNER", + "KILL", + "LEASE", + "LINUX_IMMUTABLE", + "MAC_ADMIN", + "MAC_OVERRIDE", + "MKNOD", + "NET_ADMIN", + "NET_BIND_SERVICE", + "NET_BROADCAST", + "NET_RAW", + "SETFCAP", + "SETGID", + "SETPCAP", + "SETUID", + "SYSLOG", + "SYS_ADMIN", + "SYS_BOOT", + "SYS_CHROOT", + "SYS_MODULE", + "SYS_NICE", + "SYS_PACCT", + "SYS_PTRACE", + "SYS_RAWIO", + "SYS_RESOURCE", + "SYS_TIME", + "SYS_TTY_CONFIG", + "WAKE_ALARM" + ], + "default": null + }, + "capDrop": { + "type": "array[enum]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "ALL", + "AUDIT_CONTROL", + "AUDIT_WRITE", + "BLOCK_SUSPEND", + "CHOWN", + "DAC_OVERRIDE", + "DAC_READ_SEARCH", + "FOWNER", + "FSETID", + "IPC_LOCK", + "IPC_OWNER", + "KILL", + "LEASE", + "LINUX_IMMUTABLE", + "MAC_ADMIN", + "MAC_OVERRIDE", + "MKNOD", + "NET_ADMIN", + "NET_BIND_SERVICE", + "NET_BROADCAST", + "NET_RAW", + "SETFCAP", + "SETGID", + "SETPCAP", + "SETUID", + "SYSLOG", + "SYS_ADMIN", + "SYS_BOOT", + "SYS_CHROOT", + "SYS_MODULE", + "SYS_NICE", + "SYS_PACCT", + "SYS_PTRACE", + "SYS_RAWIO", + "SYS_RESOURCE", + "SYS_TIME", + "SYS_TTY_CONFIG", + "WAKE_ALARM" + ], + "default": null + }, + "dns": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "dnsSearch": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "instanceLinks": { + "type": "map[reference[instance]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "domainName": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "memorySwap": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "memory": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "cpuSet": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "cpuShares": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "stdinOpen": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": false + }, + "tty": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": false + }, + "entryPoint": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "lxcConf": { + "type": "map[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "restartPolicy": { + "type": "restartPolicy", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "devices": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "labels": { + "type": "map[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "dataVolumes": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "dataVolumesFrom": { + "type": "array[reference[container]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "allocationState": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "compute": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "domain": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "firstRunning": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "hostname": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "imageId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "instanceTriggeredStop": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "memoryMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "nativeContainer": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "offeringId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "registryCredentialId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "systemContainer": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "token": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "userdata": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "zoneId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "services", + "instancelinks", + "loadbalancertargets", + "volumes", + "targetinstancelinks", + "agent", + "registrycredential", + "instancelabels", + "ports", + "mounts", + "hosts", + "account", + "credentials" + ], + "resourceActions": { + "update": { + "input": null, + "output": "instance" + }, + "stop": { + "input": "instanceStop", + "output": "instance" + }, + "console": { + "input": "instanceConsoleInput", + "output": "instanceConsole" + }, + "restart": { + "input": null, + "output": "instance" + }, + "remove": { + "input": null, + "output": "instance" + }, + "start": { + "input": null, + "output": "instance" + }, + "restore": { + "input": null, + "output": "instance" + }, + "migrate": { + "input": null, + "output": "instance" + }, + "deallocate": { + "input": null, + "output": "instance" + }, + "allocate": { + "input": null, + "output": "instance" + }, + "create": { + "input": null, + "output": "instance" + }, + "purge": { + "input": null, + "output": "instance" + }, + "logs": { + "input": "containerLogs", + "output": "hostAccess" + }, + "addlabel": { + "input": "addLabelInput", + "output": "container" + }, + "removelabel": { + "input": "removeLabelInput", + "output": "container" + }, + "execute": { + "input": "containerExec", + "output": "hostAccess" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "instanceConsole", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/instanceconsole" + }, + "actions": {}, + "pluralName": "instanceConsoles", + "resourceFields": { + "url": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "password": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [] + }, + { + "id": "instanceConsoleInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/instanceconsoleinput" + }, + "actions": {}, + "pluralName": "instanceConsoleInputs", + "resourceFields": {}, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [] + }, + { + "id": "instanceStop", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/instancestop" + }, + "actions": {}, + "pluralName": "instanceStops", + "resourceFields": { + "remove": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "timeout": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "deallocateFromHost": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "ipAddressAssociateInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/ipaddressassociateinput" + }, + "actions": {}, + "pluralName": "ipAddressAssociateInputs", + "resourceFields": { + "ipAddressId": { + "type": "reference[ipAddress]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "project", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/project", + "collection": "http://localhost:8080/v1/projects" + }, + "actions": {}, + "pluralName": "projects", + "resourceFields": { + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "members": { + "type": "array[projectMember]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalIdType": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "networks", + "services", + "storagepools", + "agents", + "globalloadbalancers", + "labels", + "loadbalancertargets", + "environments", + "instancelinks", + "containerevents", + "loadbalancerhostmaps", + "volumes", + "instances", + "loadbalancers", + "loadbalancerconfiglistenermaps", + "ports", + "ipaddresses", + "mounts", + "loadbalancerlisteners", + "loadbalancerconfigs", + "projectmembers", + "physicalhosts", + "hosts", + "images", + "credentials", + "snapshots", + "certificates" + ], + "resourceActions": { + "update": { + "input": null, + "output": "account" + }, + "activate": { + "input": null, + "output": "account" + }, + "remove": { + "input": null, + "output": "account" + }, + "restore": { + "input": null, + "output": "account" + }, + "deactivate": { + "input": null, + "output": "account" + }, + "create": { + "input": null, + "output": "account" + }, + "purge": { + "input": null, + "output": "account" + }, + "setmembers": { + "input": "setProjectMembersInput", + "output": "setProjectMembersInput" + }, + "delete": { + "input": null, + "output": null + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "registry", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/registry", + "collection": "http://localhost:8080/v1/registries" + }, + "actions": {}, + "pluralName": "registries", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "serverAddress": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "external": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "physicalTotalSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "virtualTotalSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "zoneId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "hosts", + "images", + "account", + "credentials", + "volumes", + "snapshots" + ], + "resourceActions": { + "update": { + "input": null, + "output": "storagePool" + }, + "activate": { + "input": null, + "output": "storagePool" + }, + "remove": { + "input": null, + "output": "storagePool" + }, + "restore": { + "input": null, + "output": "storagePool" + }, + "deactivate": { + "input": null, + "output": "storagePool" + }, + "create": { + "input": null, + "output": "storagePool" + }, + "purge": { + "input": null, + "output": "storagePool" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "registryCredential", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/registrycredential", + "collection": "http://localhost:8080/v1/registrycredentials" + }, + "actions": {}, + "pluralName": "registryCredentials", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "publicValue": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 4096, + "options": null, + "default": null + }, + "registryId": { + "type": "reference[registry]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "secretValue": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 4096, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "email": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "publicValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "registryId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "secretValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "images", + "account", + "registry", + "instances" + ], + "resourceActions": { + "update": { + "input": null, + "output": "credential" + }, + "activate": { + "input": null, + "output": "credential" + }, + "remove": { + "input": null, + "output": "credential" + }, + "restore": { + "input": null, + "output": "credential" + }, + "deactivate": { + "input": null, + "output": "credential" + }, + "create": { + "input": null, + "output": "credential" + }, + "purge": { + "input": null, + "output": "credential" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "removeLoadBalancerInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/removeloadbalancerinput" + }, + "actions": {}, + "pluralName": "removeLoadBalancerInputs", + "resourceFields": { + "loadBalancerId": { + "type": "reference[loadBalancer]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "setLoadBalancerHostsInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/setloadbalancerhostsinput" + }, + "actions": {}, + "pluralName": "setLoadBalancerHostsInputs", + "resourceFields": { + "hostIds": { + "type": "array[reference[host]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "setLoadBalancerListenersInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/setloadbalancerlistenersinput" + }, + "actions": {}, + "pluralName": "setLoadBalancerListenersInputs", + "resourceFields": { + "loadBalancerListenerIds": { + "type": "array[reference[loadBalancerListener]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "setLoadBalancerTargetsInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/setloadbalancertargetsinput" + }, + "actions": {}, + "pluralName": "setLoadBalancerTargetsInputs", + "resourceFields": { + "instanceIds": { + "type": "array[reference[instance]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "ipAddresses": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "setProjectMembersInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/setprojectmembersinput" + }, + "actions": {}, + "pluralName": "setProjectMembersInputs", + "resourceFields": { + "members": { + "type": "array[projectMember]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "setServiceLinksInput", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/setservicelinksinput" + }, + "actions": {}, + "pluralName": "setServiceLinksInputs", + "resourceFields": { + "serviceIds": { + "type": "array[reference[service]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "loadBalancerService", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerservice", + "collection": "http://localhost:8080/v1/loadbalancerservices" + }, + "actions": {}, + "pluralName": "loadBalancerServices", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "dataVolumesFromService": { + "type": "array[reference[service]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "environmentId": { + "type": "reference[environment]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "launchConfig": { + "type": "container", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": "[a-zA-Z0-9]-", + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "scale": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": 1 + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "registering", + "removed", + "removing", + "requested", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "loadBalancerConfig": { + "type": "loadBalancerConfig", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "environmentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancerlisteners", + "environment", + "loadbalancerconfigs", + "consumedservices", + "account", + "instances", + "consumedbyservices", + "loadbalancers" + ], + "resourceActions": { + "update": { + "input": null, + "output": "service" + }, + "activate": { + "input": null, + "output": "service" + }, + "remove": { + "input": null, + "output": "service" + }, + "setservicelinks": { + "input": "setServiceLinksInput", + "output": "service" + }, + "removeservicelink": { + "input": "addRemoveServiceLinkInput", + "output": "service" + }, + "addservicelink": { + "input": "addRemoveServiceLinkInput", + "output": "service" + }, + "deactivate": { + "input": null, + "output": "service" + }, + "create": { + "input": null, + "output": "service" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "account", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/account", + "collection": "http://localhost:8080/v1/accounts" + }, + "actions": {}, + "pluralName": "accounts", + "resourceFields": { + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "externalId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "externalIdType": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalIdType": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "networks", + "services", + "storagepools", + "agents", + "globalloadbalancers", + "labels", + "loadbalancertargets", + "environments", + "instancelinks", + "containerevents", + "loadbalancerhostmaps", + "volumes", + "instances", + "loadbalancers", + "loadbalancerconfiglistenermaps", + "ports", + "ipaddresses", + "mounts", + "loadbalancerlisteners", + "loadbalancerconfigs", + "projectmembers", + "physicalhosts", + "hosts", + "images", + "credentials", + "snapshots", + "certificates" + ], + "resourceActions": { + "update": { + "input": null, + "output": "account" + }, + "activate": { + "input": null, + "output": "account" + }, + "remove": { + "input": null, + "output": "account" + }, + "restore": { + "input": null, + "output": "account" + }, + "deactivate": { + "input": null, + "output": "account" + }, + "create": { + "input": null, + "output": "account" + }, + "purge": { + "input": null, + "output": "account" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "agent", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/agent", + "collection": "http://localhost:8080/v1/agents" + }, + "actions": {}, + "pluralName": "agents", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "managedConfig": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": true + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "reconnecting", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uri": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": true, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentGroupId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "managedConfig": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uri": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "zoneId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "storagepools", + "configitemstatuses", + "physicalhosts", + "hosts", + "account", + "instances" + ], + "resourceActions": { + "update": { + "input": null, + "output": "agent" + }, + "activate": { + "input": null, + "output": "agent" + }, + "remove": { + "input": null, + "output": "agent" + }, + "reconnect": { + "input": null, + "output": "agent" + }, + "restore": { + "input": null, + "output": "agent" + }, + "deactivate": { + "input": null, + "output": "agent" + }, + "create": { + "input": null, + "output": "agent" + }, + "purge": { + "input": null, + "output": "agent" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "certificate", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/certificate", + "collection": "http://localhost:8080/v1/certificates" + }, + "actions": {}, + "pluralName": "certificates", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "cert": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "certChain": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "key": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "cert": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "certChain": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "key": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "account" + ], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "configItem", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/configitem", + "collection": "http://localhost:8080/v1/configitems" + }, + "actions": {}, + "pluralName": "configItems", + "resourceFields": { + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "sourceVersion": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + } + }, + "collectionFilters": { + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "sourceVersion": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "configItemStatus", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/configitemstatus", + "collection": "http://localhost:8080/v1/configitemstatuses" + }, + "actions": {}, + "pluralName": "configItemStatuses", + "resourceFields": { + "agentId": { + "type": "reference[agent]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "appliedUpdated": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "appliedVersion": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "requestedUpdated": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "requestedVersion": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "sourceVersion": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + } + }, + "collectionFilters": { + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "appliedUpdated": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "appliedVersion": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "requestedUpdated": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "requestedVersion": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "sourceVersion": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "agent" + ], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "containerEvent", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/containerevent", + "collection": "http://localhost:8080/v1/containerevents" + }, + "actions": {}, + "pluralName": "containerEvents", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "externalFrom": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "externalId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "externalStatus": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "externalTimestamp": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "hostId": { + "type": "reference[host]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "reportedHostUuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "created", + "creating", + "removed", + "removing", + "requested" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "dockerInspect": { + "type": "json", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "externalFrom": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalStatus": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalTimestamp": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "hostId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "reportedHostUuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "host", + "account" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "containerEvent" + }, + "create": { + "input": null, + "output": "containerEvent" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "credential", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/credential", + "collection": "http://localhost:8080/v1/credentials" + }, + "actions": {}, + "pluralName": "credentials", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "publicValue": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 4096, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "secretValue": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 4096, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "publicValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "registryId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "secretValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "images", + "account", + "instances" + ], + "resourceActions": { + "update": { + "input": null, + "output": "credential" + }, + "activate": { + "input": null, + "output": "credential" + }, + "remove": { + "input": null, + "output": "credential" + }, + "restore": { + "input": null, + "output": "credential" + }, + "deactivate": { + "input": null, + "output": "credential" + }, + "create": { + "input": null, + "output": "credential" + }, + "purge": { + "input": null, + "output": "credential" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "databasechangelog", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/databasechangelog", + "collection": "http://localhost:8080/v1/databasechangelogs" + }, + "actions": {}, + "pluralName": "databasechangelogs", + "resourceFields": { + "author": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "comments": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "dateexecuted": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "exectype": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 10, + "options": null, + "default": null + }, + "filename": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "liquibase": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 20, + "options": null, + "default": null + }, + "md5sum": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 35, + "options": null, + "default": null + }, + "orderexecuted": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "tag": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + } + }, + "collectionFilters": { + "author": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "comments": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "dateexecuted": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "exectype": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "filename": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "liquibase": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "md5sum": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "orderexecuted": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "tag": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "DELETE" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "databasechangeloglock", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/databasechangeloglock", + "collection": "http://localhost:8080/v1/databasechangeloglocks" + }, + "actions": {}, + "pluralName": "databasechangeloglocks", + "resourceFields": { + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "locked": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "lockedby": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "lockgranted": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + } + }, + "collectionFilters": { + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "locked": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "lockedby": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "lockgranted": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + } + }, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "DELETE" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "environment", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/environment", + "collection": "http://localhost:8080/v1/environments" + }, + "actions": {}, + "pluralName": "environments", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": "[a-zA-Z0-9-]", + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested", + "updating-active" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "services", + "account" + ], + "resourceActions": { + "update": { + "input": null, + "output": "environment" + }, + "remove": { + "input": null, + "output": "environment" + }, + "activateservices": { + "input": null, + "output": null + }, + "deactivateservices": { + "input": null, + "output": null + }, + "create": { + "input": null, + "output": "environment" + }, + "exportconfig": { + "input": "composeConfigInput", + "output": "composeConfig" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "externalHandler", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/externalhandler", + "collection": "http://localhost:8080/v1/externalhandlers" + }, + "actions": {}, + "pluralName": "externalHandlers", + "resourceFields": { + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "priority": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "processConfigs": { + "type": "array[externalHandlerProcessConfig]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "retries": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": 1, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "timeoutMillis": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": 1000, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "priority": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "externalhandlerexternalhandlerprocessmaps", + "externalhandlerprocesses" + ], + "resourceActions": { + "update": { + "input": null, + "output": "externalHandler" + }, + "activate": { + "input": null, + "output": "externalHandler" + }, + "remove": { + "input": null, + "output": "externalHandler" + }, + "restore": { + "input": null, + "output": "externalHandler" + }, + "deactivate": { + "input": null, + "output": "externalHandler" + }, + "create": { + "input": null, + "output": "externalHandler" + }, + "purge": { + "input": null, + "output": "externalHandler" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "externalHandlerExternalHandlerProcessMap", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/externalhandlerexternalhandlerprocessmap", + "collection": "http://localhost:8080/v1/externalhandlerexternalhandlerprocessmaps" + }, + "actions": {}, + "pluralName": "externalHandlerExternalHandlerProcessMaps", + "resourceFields": { + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "externalHandlerId": { + "type": "reference[externalHandler]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "externalHandlerProcessId": { + "type": "reference[externalHandlerProcess]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "onError": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalHandlerId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "externalHandlerProcessId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "onError": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "externalhandler", + "externalhandlerprocess" + ], + "resourceActions": { + "update": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + }, + "activate": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + }, + "remove": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + }, + "restore": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + }, + "deactivate": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + }, + "create": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + }, + "purge": { + "input": null, + "output": "externalHandlerExternalHandlerProcessMap" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "externalHandlerProcess", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/externalhandlerprocess", + "collection": "http://localhost:8080/v1/externalhandlerprocesses" + }, + "actions": {}, + "pluralName": "externalHandlerProcesses", + "resourceFields": { + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "externalhandlerexternalhandlerprocessmaps", + "externalhandlers" + ], + "resourceActions": { + "update": { + "input": null, + "output": "externalHandlerProcess" + }, + "activate": { + "input": null, + "output": "externalHandlerProcess" + }, + "remove": { + "input": null, + "output": "externalHandlerProcess" + }, + "restore": { + "input": null, + "output": "externalHandlerProcess" + }, + "deactivate": { + "input": null, + "output": "externalHandlerProcess" + }, + "create": { + "input": null, + "output": "externalHandlerProcess" + }, + "purge": { + "input": null, + "output": "externalHandlerProcess" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "globalLoadBalancer", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/globalloadbalancer", + "collection": "http://localhost:8080/v1/globalloadbalancers" + }, + "actions": {}, + "pluralName": "globalLoadBalancers", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested", + "updating-active" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "globalLoadBalancerHealthCheck": { + "type": "array[globalLoadBalancerHealthCheck]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "globalLoadBalancerPolicy": { + "type": "array[globalLoadBalancerPolicy]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "account", + "loadbalancers" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "globalLoadBalancer" + }, + "addloadbalancer": { + "input": "addLoadBalancerInput", + "output": "globalLoadBalancer" + }, + "removeloadbalancer": { + "input": "removeLoadBalancerInput", + "output": "globalLoadBalancer" + }, + "create": { + "input": null, + "output": "globalLoadBalancer" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "host", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/host", + "collection": "http://localhost:8080/v1/hosts" + }, + "actions": {}, + "pluralName": "hosts", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "agentId": { + "type": "reference[agent]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "computeTotal": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "physicalHostId": { + "type": "reference[physicalHost]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "info": { + "type": "json", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "apiProxy": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "computeFree": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "computeTotal": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "isPublic": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "physicalHostId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uri": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "ipaddresses", + "storagepools", + "clusters", + "physicalhost", + "labels", + "hosts", + "containerevents", + "account", + "loadbalancerhostmaps", + "instances", + "agent", + "loadbalancers" + ], + "resourceActions": { + "update": { + "input": null, + "output": "host" + }, + "activate": { + "input": null, + "output": "host" + }, + "remove": { + "input": null, + "output": "host" + }, + "restore": { + "input": null, + "output": "host" + }, + "removelabel": { + "input": "removeLabelInput", + "output": "host" + }, + "addlabel": { + "input": "addLabelInput", + "output": "host" + }, + "deactivate": { + "input": null, + "output": "host" + }, + "create": { + "input": null, + "output": "host" + }, + "purge": { + "input": null, + "output": "host" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "image", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/image", + "collection": "http://localhost:8080/v1/images" + }, + "actions": {}, + "pluralName": "images", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "checksum": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "format": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "instanceKind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "isPublic": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "physicalSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "registryCredentialId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "url": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "virtualSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "storagepools", + "account", + "volumes", + "instances" + ], + "resourceActions": { + "update": { + "input": null, + "output": "image" + }, + "activate": { + "input": null, + "output": "image" + }, + "remove": { + "input": null, + "output": "image" + }, + "restore": { + "input": null, + "output": "image" + }, + "deactivate": { + "input": null, + "output": "image" + }, + "create": { + "input": null, + "output": "image" + }, + "purge": { + "input": null, + "output": "image" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "instance", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/instance", + "collection": "http://localhost:8080/v1/instances" + }, + "actions": {}, + "pluralName": "instances", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "externalId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "creating", + "migrating", + "purged", + "purging", + "removed", + "removing", + "requested", + "restarting", + "restoring", + "running", + "starting", + "stopped", + "stopping", + "updating-running", + "updating-stopped" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "allocationState": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "compute": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "domain": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "firstRunning": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "hostname": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "imageId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "instanceTriggeredStop": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "memoryMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "nativeContainer": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "offeringId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "registryCredentialId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "systemContainer": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "token": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "userdata": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "zoneId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "instancelabels", + "services", + "ports", + "mounts", + "loadbalancertargets", + "instancelinks", + "hosts", + "account", + "credentials", + "volumes", + "targetinstancelinks" + ], + "resourceActions": { + "update": { + "input": null, + "output": "instance" + }, + "stop": { + "input": "instanceStop", + "output": "instance" + }, + "console": { + "input": "instanceConsoleInput", + "output": "instanceConsole" + }, + "restart": { + "input": null, + "output": "instance" + }, + "remove": { + "input": null, + "output": "instance" + }, + "start": { + "input": null, + "output": "instance" + }, + "restore": { + "input": null, + "output": "instance" + }, + "migrate": { + "input": null, + "output": "instance" + }, + "deallocate": { + "input": null, + "output": "instance" + }, + "allocate": { + "input": null, + "output": "instance" + }, + "create": { + "input": null, + "output": "instance" + }, + "purge": { + "input": null, + "output": "instance" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "instanceLink", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/instancelink", + "collection": "http://localhost:8080/v1/instancelinks" + }, + "actions": {}, + "pluralName": "instanceLinks", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "instanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "linkName": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "targetInstanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "ports": { + "type": "array[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "instanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "linkName": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "targetInstanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "targetinstance", + "account", + "instance" + ], + "resourceActions": { + "update": { + "input": null, + "output": "instanceLink" + }, + "activate": { + "input": null, + "output": "instanceLink" + }, + "remove": { + "input": null, + "output": "instanceLink" + }, + "restore": { + "input": null, + "output": "instanceLink" + }, + "deactivate": { + "input": null, + "output": "instanceLink" + }, + "create": { + "input": null, + "output": "instanceLink" + }, + "purge": { + "input": null, + "output": "instanceLink" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "ipAddress", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/ipaddress", + "collection": "http://localhost:8080/v1/ipaddresses" + }, + "actions": {}, + "pluralName": "ipAddresses", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "address": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "networkId": { + "type": "reference[network]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "associated", + "associating", + "deactivating", + "disassociating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "address": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "hostname": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "ipPoolId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "isPublic": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "networkId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "role": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "subnetId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "privateports", + "publicports", + "hosts", + "account", + "network" + ], + "resourceActions": { + "update": { + "input": null, + "output": "ipAddress" + }, + "activate": { + "input": null, + "output": "ipAddress" + }, + "remove": { + "input": null, + "output": "ipAddress" + }, + "disassociate": { + "input": null, + "output": "ipAddress" + }, + "restore": { + "input": null, + "output": "ipAddress" + }, + "deactivate": { + "input": null, + "output": "ipAddress" + }, + "create": { + "input": null, + "output": "ipAddress" + }, + "purge": { + "input": null, + "output": "ipAddress" + }, + "associate": { + "input": "ipAddressAssociateInput", + "output": "ipPool" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "label", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/label", + "collection": "http://localhost:8080/v1/labels" + }, + "actions": {}, + "pluralName": "labels", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "key": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "created", + "creating", + "removed", + "removing", + "requested" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "value": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "key": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "type": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "value": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "hosts", + "account", + "instances" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "label" + }, + "create": { + "input": null, + "output": "label" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "loadBalancer", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancer", + "collection": "http://localhost:8080/v1/loadbalancers" + }, + "actions": {}, + "pluralName": "loadBalancers", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "globalLoadBalancerId": { + "type": "reference[globalLoadBalancer]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "loadBalancerConfigId": { + "type": "reference[loadBalancerConfig]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "serviceId": { + "type": "reference[service]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested", + "updating-active" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "weight": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "globalLoadBalancerId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "loadBalancerConfigId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "serviceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "weight": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancerconfig", + "service", + "loadbalancertargets", + "hosts", + "globalloadbalancer", + "account", + "loadbalancerhostmaps" + ], + "resourceActions": { + "update": { + "input": null, + "output": "loadBalancer" + }, + "sethosts": { + "input": "setLoadBalancerHostsInput", + "output": "loadBalancer" + }, + "addtarget": { + "input": "addRemoveLoadBalancerTargetInput", + "output": "loadBalancer" + }, + "removehost": { + "input": "addRemoveLoadBalancerHostInput", + "output": "loadBalancer" + }, + "remove": { + "input": null, + "output": "loadBalancer" + }, + "addhost": { + "input": "addRemoveLoadBalancerHostInput", + "output": "loadBalancer" + }, + "create": { + "input": null, + "output": "loadBalancer" + }, + "removetarget": { + "input": "addRemoveLoadBalancerTargetInput", + "output": "loadBalancer" + }, + "settargets": { + "input": "setLoadBalancerTargetsInput", + "output": "loadBalancer" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "loadBalancerConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerconfig", + "collection": "http://localhost:8080/v1/loadbalancerconfigs" + }, + "actions": {}, + "pluralName": "loadBalancerConfigs", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "serviceId": { + "type": "reference[service]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested", + "updating-active" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "healthCheck": { + "type": "loadBalancerHealthCheck", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "appCookieStickinessPolicy": { + "type": "loadBalancerAppCookieStickinessPolicy", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "lbCookieStickinessPolicy": { + "type": "loadBalancerCookieStickinessPolicy", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "serviceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancerconfiglistenermaps", + "loadbalancerlisteners", + "service", + "account", + "loadbalancers" + ], + "resourceActions": { + "removelistener": { + "input": "addRemoveLoadBalancerListenerInput", + "output": "loadBalancerConfig" + }, + "update": { + "input": null, + "output": "loadBalancerConfig" + }, + "remove": { + "input": null, + "output": "loadBalancerConfig" + }, + "setlisteners": { + "input": "setLoadBalancerListenersInput", + "output": "loadBalancerConfig" + }, + "addlistener": { + "input": "addRemoveLoadBalancerListenerInput", + "output": "loadBalancerConfig" + }, + "create": { + "input": null, + "output": "loadBalancerConfig" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "loadBalancerConfigListenerMap", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerconfiglistenermap", + "collection": "http://localhost:8080/v1/loadbalancerconfiglistenermaps" + }, + "actions": {}, + "pluralName": "loadBalancerConfigListenerMaps", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "loadBalancerConfigId": { + "type": "reference[loadBalancerConfig]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "loadBalancerListenerId": { + "type": "reference[loadBalancerListener]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "loadBalancerConfigId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "loadBalancerListenerId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancerlistener", + "loadbalancerconfig", + "account" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "loadBalancerConfigListenerMap" + }, + "create": { + "input": null, + "output": "loadBalancerConfigListenerMap" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "loadBalancerHostMap", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerhostmap", + "collection": "http://localhost:8080/v1/loadbalancerhostmaps" + }, + "actions": {}, + "pluralName": "loadBalancerHostMaps", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "hostId": { + "type": "reference[host]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "loadBalancerId": { + "type": "reference[loadBalancer]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "hostId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "loadBalancerId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "host", + "loadbalancer", + "account" + ], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "loadBalancerListener", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancerlistener", + "collection": "http://localhost:8080/v1/loadbalancerlisteners" + }, + "actions": {}, + "pluralName": "loadBalancerListeners", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "serviceId": { + "type": "reference[service]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "sourcePort": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": 1, + "max": 65535, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "sourceProtocol": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": [ + "tcp", + "http" + ], + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested" + ], + "default": null + }, + "targetPort": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": 1, + "max": 65535, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "targetProtocol": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": [ + "tcp", + "http" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "algorithm": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "roundrobin", + "leastconn", + "source" + ], + "default": "roundrobin" + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "serviceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "sourcePort": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "sourceProtocol": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "targetPort": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "targetProtocol": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancerconfiglistenermaps", + "loadbalancerconfigs", + "service", + "account" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "loadBalancerListener" + }, + "create": { + "input": null, + "output": "loadBalancerListener" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "loadBalancerTarget", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/loadbalancertarget", + "collection": "http://localhost:8080/v1/loadbalancertargets" + }, + "actions": {}, + "pluralName": "loadBalancerTargets", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "instanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "ipAddress": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "loadBalancerId": { + "type": "reference[loadBalancer]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "removed", + "removing", + "requested" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "instanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "ipAddress": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "loadBalancerId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancer", + "account", + "instance" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "loadBalancerTarget" + }, + "create": { + "input": null, + "output": "loadBalancerTarget" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "mount", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/mount", + "collection": "http://localhost:8080/v1/mounts" + }, + "actions": {}, + "pluralName": "mounts", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "instanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "path": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 512, + "options": null, + "default": null + }, + "permissions": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "volumeId": { + "type": "reference[volume]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "instanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "path": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "permissions": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "volumeId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "volume", + "account", + "instance" + ], + "resourceActions": { + "update": { + "input": null, + "output": "mount" + }, + "activate": { + "input": null, + "output": "mount" + }, + "remove": { + "input": null, + "output": "mount" + }, + "restore": { + "input": null, + "output": "mount" + }, + "deactivate": { + "input": null, + "output": "mount" + }, + "create": { + "input": null, + "output": "mount" + }, + "purge": { + "input": null, + "output": "mount" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "network", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/network", + "collection": "http://localhost:8080/v1/networks" + }, + "actions": {}, + "pluralName": "networks", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "domain": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "isPublic": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "ipaddresses", + "account" + ], + "resourceActions": { + "update": { + "input": null, + "output": "network" + }, + "activate": { + "input": null, + "output": "network" + }, + "remove": { + "input": null, + "output": "network" + }, + "restore": { + "input": null, + "output": "network" + }, + "deactivate": { + "input": null, + "output": "network" + }, + "create": { + "input": null, + "output": "network" + }, + "purge": { + "input": null, + "output": "network" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "physicalHost", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/physicalhost", + "collection": "http://localhost:8080/v1/physicalhosts" + }, + "actions": {}, + "pluralName": "physicalHosts", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "active", + "bootstrapping", + "created", + "creating", + "error", + "erroring", + "removed", + "removing", + "requested", + "updating" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "hosts", + "account" + ], + "resourceActions": { + "update": { + "input": null, + "output": "physicalHost" + }, + "bootstrap": { + "input": null, + "output": "physicalHost" + }, + "remove": { + "input": null, + "output": "physicalHost" + }, + "error": { + "input": null, + "output": "physicalHost" + }, + "create": { + "input": null, + "output": "physicalHost" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "port", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/port", + "collection": "http://localhost:8080/v1/ports" + }, + "actions": {}, + "pluralName": "ports", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "instanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "privateIpAddressId": { + "type": "reference[ipAddress]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "privatePort": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "protocol": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "publicIpAddressId": { + "type": "reference[ipAddress]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "publicPort": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "instanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "privateIpAddressId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "privatePort": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "protocol": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "publicIpAddressId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "publicPort": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "privateipaddress", + "publicipaddress", + "account", + "instance" + ], + "resourceActions": { + "update": { + "input": null, + "output": "port" + }, + "activate": { + "input": null, + "output": "port" + }, + "remove": { + "input": null, + "output": "port" + }, + "restore": { + "input": null, + "output": "port" + }, + "deactivate": { + "input": null, + "output": "port" + }, + "create": { + "input": null, + "output": "port" + }, + "purge": { + "input": null, + "output": "port" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "processExecution", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/processexecution", + "collection": "http://localhost:8080/v1/processexecutions" + }, + "actions": {}, + "pluralName": "processExecutions", + "resourceFields": { + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "log": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 16777215, + "options": null, + "default": null + }, + "processInstanceId": { + "type": "reference[processInstance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + } + }, + "collectionFilters": { + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "processInstanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "processinstance" + ], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "processInstance", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/processinstance", + "collection": "http://localhost:8080/v1/processinstances" + }, + "actions": {}, + "pluralName": "processInstances", + "resourceFields": { + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "endTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "exitReason": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "phase": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "priority": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "processName": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "resourceId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "resourceType": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "result": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "runningProcessServerId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "startProcessServerId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "startTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + } + }, + "collectionFilters": { + "endTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "exitReason": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "phase": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "priority": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "processName": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "resourceId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "resourceType": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "result": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "runningProcessServerId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "startProcessServerId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "startTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "processexecutions" + ], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "projectMember", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/projectmember", + "collection": "http://localhost:8080/v1/projectmembers" + }, + "actions": {}, + "pluralName": "projectMembers", + "resourceFields": { + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "externalId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "externalIdType": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": [ + "github_user", + "github_org", + "github_team", + "rancher_id" + ], + "default": "rancher_id" + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "projectId": { + "type": "reference[project]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "role": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": [ + "member", + "owner" + ], + "default": "member" + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalIdType": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "projectId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "role": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "project" + ], + "resourceActions": { + "update": { + "input": null, + "output": "projectMember" + }, + "activate": { + "input": null, + "output": "projectMember" + }, + "remove": { + "input": null, + "output": "projectMember" + }, + "restore": { + "input": null, + "output": "projectMember" + }, + "deactivate": { + "input": null, + "output": "projectMember" + }, + "create": { + "input": null, + "output": "projectMember" + }, + "purge": { + "input": null, + "output": "projectMember" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "service", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/service", + "collection": "http://localhost:8080/v1/services" + }, + "actions": {}, + "pluralName": "services", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "environmentId": { + "type": "reference[environment]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": "[a-zA-Z0-9]-", + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "registering", + "removed", + "removing", + "requested", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "scale": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": 1 + }, + "dataVolumesFromService": { + "type": "array[reference[service]]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "launchConfig": { + "type": "container", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "environmentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "loadbalancerlisteners", + "environment", + "loadbalancerconfigs", + "consumedservices", + "account", + "instances", + "consumedbyservices", + "loadbalancers" + ], + "resourceActions": { + "update": { + "input": null, + "output": "service" + }, + "activate": { + "input": null, + "output": "service" + }, + "remove": { + "input": null, + "output": "service" + }, + "setservicelinks": { + "input": "setServiceLinksInput", + "output": "service" + }, + "removeservicelink": { + "input": "addRemoveServiceLinkInput", + "output": "service" + }, + "addservicelink": { + "input": "addRemoveServiceLinkInput", + "output": "service" + }, + "deactivate": { + "input": null, + "output": "service" + }, + "create": { + "input": null, + "output": "service" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "setting", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/setting", + "collection": "http://localhost:8080/v1/settings" + }, + "actions": {}, + "pluralName": "settings", + "resourceFields": { + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "value": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + } + }, + "collectionFilters": { + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "value": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "snapshot", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/snapshot", + "collection": "http://localhost:8080/v1/snapshots" + }, + "actions": {}, + "pluralName": "snapshots", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "backed-up", + "backing-up", + "created", + "creating", + "removed", + "removing", + "requested" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "volumeId": { + "type": "reference[volume]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "managedVolumeUUID": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "volumeId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "storagepools", + "volume", + "account" + ], + "resourceActions": { + "remove": { + "input": null, + "output": "snapshot" + }, + "create": { + "input": null, + "output": "snapshot" + }, + "backup": { + "input": null, + "output": "snapshot" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "storagePool", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/storagepool", + "collection": "http://localhost:8080/v1/storagepools" + }, + "actions": {}, + "pluralName": "storagePools", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "external": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "physicalTotalSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "virtualTotalSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "zoneId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "hosts", + "images", + "account", + "credentials", + "volumes", + "snapshots" + ], + "resourceActions": { + "update": { + "input": null, + "output": "storagePool" + }, + "activate": { + "input": null, + "output": "storagePool" + }, + "remove": { + "input": null, + "output": "storagePool" + }, + "restore": { + "input": null, + "output": "storagePool" + }, + "deactivate": { + "input": null, + "output": "storagePool" + }, + "create": { + "input": null, + "output": "storagePool" + }, + "purge": { + "input": null, + "output": "storagePool" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "task", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/task", + "collection": "http://localhost:8080/v1/tasks" + }, + "actions": {}, + "pluralName": "tasks", + "resourceFields": { + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + } + }, + "collectionFilters": { + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "taskinstances" + ], + "resourceActions": { + "execute": { + "input": null, + "output": "task" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "taskInstance", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/taskinstance", + "collection": "http://localhost:8080/v1/taskinstances" + }, + "actions": {}, + "pluralName": "taskInstances", + "resourceFields": { + "endTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "exception": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "serverId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "startTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "taskId": { + "type": "reference[task]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + } + }, + "collectionFilters": { + "endTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "exception": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "serverId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "startTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "taskId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "task" + ], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "volume", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/volume", + "collection": "http://localhost:8080/v1/volumes" + }, + "actions": {}, + "pluralName": "volumes", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "imageId": { + "type": "reference[image]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "instanceId": { + "type": "reference[instance]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "uri": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 512, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "isHostPath": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": false + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "allocationState": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "attachedState": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "deviceNumber": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "format": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "imageId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "instanceId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "offeringId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "physicalSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uri": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "virtualSizeMb": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "zoneId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "mounts", + "storagepools", + "image", + "account", + "snapshots", + "instance" + ], + "resourceActions": { + "update": { + "input": null, + "output": "volume" + }, + "activate": { + "input": null, + "output": "volume" + }, + "remove": { + "input": null, + "output": "volume" + }, + "restore": { + "input": null, + "output": "volume" + }, + "deallocate": { + "input": null, + "output": "volume" + }, + "allocate": { + "input": null, + "output": "volume" + }, + "deactivate": { + "input": null, + "output": "volume" + }, + "create": { + "input": null, + "output": "volume" + }, + "purge": { + "input": null, + "output": "volume" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "DELETE" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "typeDocumentation", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/typedocumentation", + "collection": "http://localhost:8080/v1/typedocumentations" + }, + "actions": {}, + "pluralName": "typeDocumentations", + "resourceFields": { + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "id": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "containerExec", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/containerexec", + "collection": "http://localhost:8080/v1/containerexecs" + }, + "actions": {}, + "pluralName": "containerExecs", + "resourceFields": { + "attachStdin": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": true + }, + "attachStdout": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": true + }, + "command": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "tty": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": true + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "containerLogs", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/containerlogs" + }, + "actions": {}, + "pluralName": "containerLogses", + "resourceFields": { + "follow": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": true + }, + "lines": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": 0, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": 100 + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "hostAccess", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/hostaccess", + "collection": "http://localhost:8080/v1/hostaccesses" + }, + "actions": {}, + "pluralName": "hostAccesses", + "resourceFields": { + "token": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "url": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "activeSetting", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/activesetting" + }, + "actions": {}, + "pluralName": "activeSettings", + "resourceFields": { + "activeValue": { + "type": "json", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "id": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "inDb": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "source": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "value": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [] + }, + { + "id": "extensionImplementation", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/extensionimplementation" + }, + "actions": {}, + "pluralName": "extensionImplementations", + "resourceFields": { + "className": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "properties": { + "type": "map[string]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [] + }, + { + "id": "extensionPoint", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/extensionpoint", + "collection": "http://localhost:8080/v1/extensionpoints" + }, + "actions": {}, + "pluralName": "extensionPoints", + "resourceFields": { + "excludeSetting": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "implementations": { + "type": "array[extensionImplementation]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "includeSetting": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "listSetting": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "processDefinition", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/processdefinition", + "collection": "http://localhost:8080/v1/processdefinitions" + }, + "actions": {}, + "pluralName": "processDefinitions", + "resourceFields": { + "extensionBased": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "id": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "postProcessListeners": { + "type": "extensionPoint", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "preProcessListeners": { + "type": "extensionPoint", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "processHandlers": { + "type": "extensionPoint", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "resourceType": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "stateTransitions": { + "type": "array[stateTransition]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "resourceDefinition", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/resourcedefinition", + "collection": "http://localhost:8080/v1/resourcedefinitions" + }, + "actions": {}, + "pluralName": "resourceDefinitions", + "resourceFields": { + "id": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "stateTransition", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/statetransition" + }, + "actions": {}, + "pluralName": "stateTransitions", + "resourceFields": {}, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [] + }, + { + "id": "githubconfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/githubconfig", + "collection": "http://localhost:8080/v1/githubconfigs" + }, + "actions": {}, + "pluralName": "githubconfigs", + "resourceFields": { + "accessMode": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "restricted", + "unrestricted" + ], + "default": "unrestricted" + }, + "allowedOrganizations": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "allowedUsers": { + "type": "array[string]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "clientId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "clientSecret": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "enabled": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "statsAccess", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/statsaccess", + "collection": "http://localhost:8080/v1/statsaccesses" + }, + "actions": {}, + "pluralName": "statsAccesses", + "resourceFields": { + "token": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "url": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET" + ] + }, + { + "id": "virtualboxConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/virtualboxconfig" + }, + "actions": {}, + "pluralName": "virtualboxConfigs", + "resourceFields": { + "memory": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "diskSize": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "boot2dockerUrl": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "digitaloceanConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/digitaloceanconfig" + }, + "actions": {}, + "pluralName": "digitaloceanConfigs", + "resourceFields": { + "image": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "region": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "size": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "accessToken": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "ipv6": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "privateNetworking": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "backups": { + "type": "boolean", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "amazonec2Config", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/amazonec2config" + }, + "actions": {}, + "pluralName": "amazonec2Configs", + "resourceFields": { + "accessKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "secretKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "vpcId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "sessionToken": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "ami": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "region": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "zone": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "subnetId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "securityGroup": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "instanceType": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "rootSize": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "iamInstanceProfile": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "rackspaceConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/rackspaceconfig" + }, + "actions": {}, + "pluralName": "rackspaceConfigs", + "resourceFields": { + "username": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "apiKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "region": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "endpointType": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "imageId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "flavorId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "sshUser": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "sshPort": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "dockerInstall": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "packetConfig", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/packetconfig" + }, + "actions": {}, + "pluralName": "packetConfigs", + "resourceFields": { + "apiKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "projectId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "os": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "facilityCode": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "plan": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "billingCycle": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": {}, + "includeableLinks": [], + "resourceActions": {}, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "POST" + ] + }, + { + "id": "machine", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/machine", + "collection": "http://localhost:8080/v1/machines" + }, + "actions": {}, + "pluralName": "machines", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "externalId": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": false, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": 1, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "active", + "bootstrapping", + "created", + "creating", + "error", + "erroring", + "removed", + "removing", + "requested", + "updating" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "authCertificateAuthority": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "authKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "driver": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "extractedConfig": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "virtualboxConfig": { + "type": "virtualboxConfig", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "digitaloceanConfig": { + "type": "digitaloceanConfig", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "amazonec2Config": { + "type": "amazonec2Config", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "rackspaceConfig": { + "type": "rackspaceConfig", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "packetConfig": { + "type": "packetConfig", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "agentId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "externalId": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "hosts", + "account" + ], + "resourceActions": { + "update": { + "input": null, + "output": "physicalHost" + }, + "bootstrap": { + "input": null, + "output": "physicalHost" + }, + "remove": { + "input": null, + "output": "physicalHost" + }, + "error": { + "input": null, + "output": "physicalHost" + }, + "create": { + "input": null, + "output": "physicalHost" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET", + "PUT", + "DELETE" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "register", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/register", + "collection": "http://localhost:8080/v1/register" + }, + "actions": {}, + "pluralName": "register", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "key": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": true, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "accessKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "secretKey": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "key": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "token": { + "modifiers": [ + "eq" + ] + } + }, + "includeableLinks": [ + "account" + ], + "resourceActions": { + "update": { + "input": null, + "output": "genericObject" + }, + "activate": { + "input": null, + "output": "genericObject" + }, + "remove": { + "input": null, + "output": "genericObject" + }, + "restore": { + "input": null, + "output": "genericObject" + }, + "deactivate": { + "input": null, + "output": "genericObject" + }, + "create": { + "input": null, + "output": "genericObject" + }, + "purge": { + "input": null, + "output": "genericObject" + }, + "stop": { + "input": "instanceStop", + "output": "instance" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET", + "POST" + ] + }, + { + "id": "registrationToken", + "type": "schema", + "links": { + "self": "http://localhost:8080/v1/schemas/registrationtoken", + "collection": "http://localhost:8080/v1/registrationtokens" + }, + "actions": {}, + "pluralName": "registrationTokens", + "resourceFields": { + "accountId": { + "type": "reference[account]", + "validChars": null, + "invalidChars": null, + "create": true, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "created": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "data": { + "type": "map[json]", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 65535, + "options": null, + "default": null + }, + "description": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 1024, + "options": null, + "default": null + }, + "id": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "kind": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "name": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": true, + "update": true, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removeTime": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "removed": { + "type": "date", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 255, + "options": null, + "default": null + }, + "state": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": [ + "activating", + "active", + "deactivating", + "inactive", + "purged", + "purging", + "registering", + "removed", + "removing", + "requested", + "restoring", + "updating-active", + "updating-inactive" + ], + "default": null + }, + "transitioning": { + "type": "enum", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": [ + "yes", + "no", + "error" + ], + "default": null + }, + "transitioningMessage": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "transitioningProgress": { + "type": "int", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "uuid": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": true, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": 128, + "options": null, + "default": null + }, + "command": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "image": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "token": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + }, + "registrationUrl": { + "type": "string", + "validChars": null, + "invalidChars": null, + "create": false, + "update": false, + "nullable": false, + "unique": false, + "required": false, + "min": null, + "max": null, + "minLength": null, + "maxLength": null, + "options": null, + "default": null + } + }, + "collectionFilters": { + "accountId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "created": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "description": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "id": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "kind": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "name": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "publicValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "registryId": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "removeTime": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "removed": { + "modifiers": [ + "eq", + "ne", + "lt", + "lte", + "gt", + "gte", + "null", + "notnull" + ] + }, + "secretValue": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + }, + "state": { + "modifiers": [ + "eq", + "ne", + "null", + "notnull" + ] + }, + "uuid": { + "modifiers": [ + "eq", + "ne", + "prefix", + "like", + "notlike", + "null", + "notnull" + ] + } + }, + "includeableLinks": [ + "images", + "account", + "instances" + ], + "resourceActions": { + "update": { + "input": null, + "output": "credential" + }, + "activate": { + "input": null, + "output": "credential" + }, + "remove": { + "input": null, + "output": "credential" + }, + "restore": { + "input": null, + "output": "credential" + }, + "deactivate": { + "input": null, + "output": "credential" + }, + "create": { + "input": null, + "output": "credential" + }, + "purge": { + "input": null, + "output": "credential" + } + }, + "collectionActions": {}, + "collectionFields": {}, + "resourceMethods": [ + "GET" + ], + "collectionMethods": [ + "GET", + "POST" + ] + } + ], + "sortLinks": {}, + "pagination": null, + "sort": null, + "filters": {}, + "createDefaults": {} +} diff --git a/vendor/gopkg.in/check.v1/.gitignore b/vendor/gopkg.in/check.v1/.gitignore new file mode 100644 index 00000000..191a5360 --- /dev/null +++ b/vendor/gopkg.in/check.v1/.gitignore @@ -0,0 +1,4 @@ +_* +*.swp +*.[568] +[568].out diff --git a/vendor/gopkg.in/check.v1/LICENSE b/vendor/gopkg.in/check.v1/LICENSE new file mode 100644 index 00000000..545cf2d3 --- /dev/null +++ b/vendor/gopkg.in/check.v1/LICENSE @@ -0,0 +1,25 @@ +Gocheck - A rich testing framework 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/vendor/gopkg.in/check.v1/README.md b/vendor/gopkg.in/check.v1/README.md new file mode 100644 index 00000000..0ca9e572 --- /dev/null +++ b/vendor/gopkg.in/check.v1/README.md @@ -0,0 +1,20 @@ +Instructions +============ + +Install the package with: + + go get gopkg.in/check.v1 + +Import it with: + + import "gopkg.in/check.v1" + +and use _check_ as the package name inside the code. + +For more details, visit the project page: + +* http://labix.org/gocheck + +and the API documentation: + +* https://gopkg.in/check.v1 diff --git a/vendor/gopkg.in/check.v1/TODO b/vendor/gopkg.in/check.v1/TODO new file mode 100644 index 00000000..33498270 --- /dev/null +++ b/vendor/gopkg.in/check.v1/TODO @@ -0,0 +1,2 @@ +- Assert(slice, Contains, item) +- Parallel test support diff --git a/vendor/gopkg.in/check.v1/benchmark.go b/vendor/gopkg.in/check.v1/benchmark.go new file mode 100644 index 00000000..46ea9dc6 --- /dev/null +++ b/vendor/gopkg.in/check.v1/benchmark.go @@ -0,0 +1,187 @@ +// 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. + +package check + +import ( + "fmt" + "runtime" + "time" +) + +var memStats runtime.MemStats + +// testingB is a type passed to Benchmark functions to manage benchmark +// timing and to specify the number of iterations to run. +type timer struct { + start time.Time // Time test or benchmark started + duration time.Duration + N int + bytes int64 + timerOn bool + benchTime time.Duration + // The initial states of memStats.Mallocs and memStats.TotalAlloc. + startAllocs uint64 + startBytes uint64 + // The net total of this test after being run. + netAllocs uint64 + netBytes uint64 +} + +// StartTimer starts timing a test. This function is called automatically +// before a benchmark starts, but it can also used to resume timing after +// a call to StopTimer. +func (c *C) StartTimer() { + if !c.timerOn { + c.start = time.Now() + c.timerOn = true + + runtime.ReadMemStats(&memStats) + c.startAllocs = memStats.Mallocs + c.startBytes = memStats.TotalAlloc + } +} + +// StopTimer stops timing a test. This can be used to pause the timer +// while performing complex initialization that you don't +// want to measure. +func (c *C) StopTimer() { + if c.timerOn { + c.duration += time.Now().Sub(c.start) + c.timerOn = false + runtime.ReadMemStats(&memStats) + c.netAllocs += memStats.Mallocs - c.startAllocs + c.netBytes += memStats.TotalAlloc - c.startBytes + } +} + +// ResetTimer sets the elapsed benchmark time to zero. +// It does not affect whether the timer is running. +func (c *C) ResetTimer() { + if c.timerOn { + c.start = time.Now() + runtime.ReadMemStats(&memStats) + c.startAllocs = memStats.Mallocs + c.startBytes = memStats.TotalAlloc + } + c.duration = 0 + c.netAllocs = 0 + c.netBytes = 0 +} + +// SetBytes informs the number of bytes that the benchmark processes +// on each iteration. If this is called in a benchmark it will also +// report MB/s. +func (c *C) SetBytes(n int64) { + c.bytes = n +} + +func (c *C) nsPerOp() int64 { + if c.N <= 0 { + return 0 + } + return c.duration.Nanoseconds() / int64(c.N) +} + +func (c *C) mbPerSec() float64 { + if c.bytes <= 0 || c.duration <= 0 || c.N <= 0 { + return 0 + } + return (float64(c.bytes) * float64(c.N) / 1e6) / c.duration.Seconds() +} + +func (c *C) timerString() string { + if c.N <= 0 { + return fmt.Sprintf("%3.3fs", float64(c.duration.Nanoseconds())/1e9) + } + mbs := c.mbPerSec() + mb := "" + if mbs != 0 { + mb = fmt.Sprintf("\t%7.2f MB/s", mbs) + } + nsop := c.nsPerOp() + ns := fmt.Sprintf("%10d ns/op", nsop) + if c.N > 0 && nsop < 100 { + // The format specifiers here make sure that + // the ones digits line up for all three possible formats. + if nsop < 10 { + ns = fmt.Sprintf("%13.2f ns/op", float64(c.duration.Nanoseconds())/float64(c.N)) + } else { + ns = fmt.Sprintf("%12.1f ns/op", float64(c.duration.Nanoseconds())/float64(c.N)) + } + } + memStats := "" + if c.benchMem { + allocedBytes := fmt.Sprintf("%8d B/op", int64(c.netBytes)/int64(c.N)) + allocs := fmt.Sprintf("%8d allocs/op", int64(c.netAllocs)/int64(c.N)) + memStats = fmt.Sprintf("\t%s\t%s", allocedBytes, allocs) + } + return fmt.Sprintf("%8d\t%s%s%s", c.N, ns, mb, memStats) +} + +func min(x, y int) int { + if x > y { + return y + } + return x +} + +func max(x, y int) int { + if x < y { + return y + } + return x +} + +// roundDown10 rounds a number down to the nearest power of 10. +func roundDown10(n int) int { + var tens = 0 + // tens = floor(log_10(n)) + for n > 10 { + n = n / 10 + tens++ + } + // result = 10^tens + result := 1 + for i := 0; i < tens; i++ { + result *= 10 + } + return result +} + +// roundUp rounds x up to a number of the form [1eX, 2eX, 5eX]. +func roundUp(n int) int { + base := roundDown10(n) + if n < (2 * base) { + return 2 * base + } + if n < (5 * base) { + return 5 * base + } + return 10 * base +} diff --git a/vendor/gopkg.in/check.v1/benchmark_test.go b/vendor/gopkg.in/check.v1/benchmark_test.go new file mode 100644 index 00000000..4dd827c1 --- /dev/null +++ b/vendor/gopkg.in/check.v1/benchmark_test.go @@ -0,0 +1,91 @@ +// These tests verify the test running logic. + +package check_test + +import ( + "time" + . "gopkg.in/check.v1" +) + +var benchmarkS = Suite(&BenchmarkS{}) + +type BenchmarkS struct{} + +func (s *BenchmarkS) TestCountSuite(c *C) { + suitesRun += 1 +} + +func (s *BenchmarkS) TestBasicTestTiming(c *C) { + helper := FixtureHelper{sleepOn: "Test1", sleep: 1000000 * time.Nanosecond} + output := String{} + runConf := RunConf{Output: &output, Verbose: true} + Run(&helper, &runConf) + + expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t0\\.001s\n" + + "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t0\\.000s\n" + c.Assert(output.value, Matches, expected) +} + +func (s *BenchmarkS) TestStreamTestTiming(c *C) { + helper := FixtureHelper{sleepOn: "SetUpSuite", sleep: 1000000 * time.Nanosecond} + output := String{} + runConf := RunConf{Output: &output, Stream: true} + Run(&helper, &runConf) + + expected := "(?s).*\nPASS: check_test\\.go:[0-9]+: FixtureHelper\\.SetUpSuite\t *0\\.001s\n.*" + c.Assert(output.value, Matches, expected) +} + +func (s *BenchmarkS) TestBenchmark(c *C) { + helper := FixtureHelper{sleep: 100000} + output := String{} + runConf := RunConf{ + Output: &output, + Benchmark: true, + BenchmarkTime: 10000000, + Filter: "Benchmark1", + } + Run(&helper, &runConf) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Benchmark1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "SetUpTest") + c.Check(helper.calls[5], Equals, "Benchmark1") + c.Check(helper.calls[6], Equals, "TearDownTest") + // ... and more. + + expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n" + c.Assert(output.value, Matches, expected) +} + +func (s *BenchmarkS) TestBenchmarkBytes(c *C) { + helper := FixtureHelper{sleep: 100000} + output := String{} + runConf := RunConf{ + Output: &output, + Benchmark: true, + BenchmarkTime: 10000000, + Filter: "Benchmark2", + } + Run(&helper, &runConf) + + expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n" + c.Assert(output.value, Matches, expected) +} + +func (s *BenchmarkS) TestBenchmarkMem(c *C) { + helper := FixtureHelper{sleep: 100000} + output := String{} + runConf := RunConf{ + Output: &output, + Benchmark: true, + BenchmarkMem: true, + BenchmarkTime: 10000000, + Filter: "Benchmark3", + } + Run(&helper, &runConf) + + expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark3\t *100\t *[12][0-9]{5} ns/op\t *[0-9]+ B/op\t *[1-9] allocs/op\n" + c.Assert(output.value, Matches, expected) +} diff --git a/vendor/gopkg.in/check.v1/bootstrap_test.go b/vendor/gopkg.in/check.v1/bootstrap_test.go new file mode 100644 index 00000000..e55f327c --- /dev/null +++ b/vendor/gopkg.in/check.v1/bootstrap_test.go @@ -0,0 +1,82 @@ +// These initial tests are for bootstrapping. They verify that we can +// basically use the testing infrastructure itself to check if the test +// system is working. +// +// These tests use will break down the test runner badly in case of +// errors because if they simply fail, we can't be sure the developer +// will ever see anything (because failing means the failing system +// somehow isn't working! :-) +// +// Do not assume *any* internal functionality works as expected besides +// what's actually tested here. + +package check_test + +import ( + "fmt" + "gopkg.in/check.v1" + "strings" +) + +type BootstrapS struct{} + +var boostrapS = check.Suite(&BootstrapS{}) + +func (s *BootstrapS) TestCountSuite(c *check.C) { + suitesRun += 1 +} + +func (s *BootstrapS) TestFailedAndFail(c *check.C) { + if c.Failed() { + critical("c.Failed() must be false first!") + } + c.Fail() + if !c.Failed() { + critical("c.Fail() didn't put the test in a failed state!") + } + c.Succeed() +} + +func (s *BootstrapS) TestFailedAndSucceed(c *check.C) { + c.Fail() + c.Succeed() + if c.Failed() { + critical("c.Succeed() didn't put the test back in a non-failed state") + } +} + +func (s *BootstrapS) TestLogAndGetTestLog(c *check.C) { + c.Log("Hello there!") + log := c.GetTestLog() + if log != "Hello there!\n" { + critical(fmt.Sprintf("Log() or GetTestLog() is not working! Got: %#v", log)) + } +} + +func (s *BootstrapS) TestLogfAndGetTestLog(c *check.C) { + c.Logf("Hello %v", "there!") + log := c.GetTestLog() + if log != "Hello there!\n" { + critical(fmt.Sprintf("Logf() or GetTestLog() is not working! Got: %#v", log)) + } +} + +func (s *BootstrapS) TestRunShowsErrors(c *check.C) { + output := String{} + check.Run(&FailHelper{}, &check.RunConf{Output: &output}) + if strings.Index(output.value, "Expected failure!") == -1 { + critical(fmt.Sprintf("RunWithWriter() output did not contain the "+ + "expected failure! Got: %#v", + output.value)) + } +} + +func (s *BootstrapS) TestRunDoesntShowSuccesses(c *check.C) { + output := String{} + check.Run(&SuccessHelper{}, &check.RunConf{Output: &output}) + if strings.Index(output.value, "Expected success!") != -1 { + critical(fmt.Sprintf("RunWithWriter() output contained a successful "+ + "test! Got: %#v", + output.value)) + } +} diff --git a/vendor/gopkg.in/check.v1/check.go b/vendor/gopkg.in/check.v1/check.go new file mode 100644 index 00000000..82c26fa7 --- /dev/null +++ b/vendor/gopkg.in/check.v1/check.go @@ -0,0 +1,873 @@ +// Package check is a rich testing extension for Go's testing package. +// +// For details about the project, see: +// +// http://labix.org/gocheck +// +package check + +import ( + "bytes" + "errors" + "fmt" + "io" + "math/rand" + "os" + "path" + "path/filepath" + "reflect" + "regexp" + "runtime" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" +) + +// ----------------------------------------------------------------------- +// Internal type which deals with suite method calling. + +const ( + fixtureKd = iota + testKd +) + +type funcKind int + +const ( + succeededSt = iota + failedSt + skippedSt + panickedSt + fixturePanickedSt + missedSt +) + +type funcStatus uint32 + +// A method value can't reach its own Method structure. +type methodType struct { + reflect.Value + Info reflect.Method +} + +func newMethod(receiver reflect.Value, i int) *methodType { + return &methodType{receiver.Method(i), receiver.Type().Method(i)} +} + +func (method *methodType) PC() uintptr { + return method.Info.Func.Pointer() +} + +func (method *methodType) suiteName() string { + t := method.Info.Type.In(0) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + return t.Name() +} + +func (method *methodType) String() string { + return method.suiteName() + "." + method.Info.Name +} + +func (method *methodType) matches(re *regexp.Regexp) bool { + return (re.MatchString(method.Info.Name) || + re.MatchString(method.suiteName()) || + re.MatchString(method.String())) +} + +type C struct { + method *methodType + kind funcKind + testName string + _status funcStatus + logb *logger + logw io.Writer + done chan *C + reason string + mustFail bool + tempDir *tempDir + benchMem bool + startTime time.Time + timer +} + +func (c *C) status() funcStatus { + return funcStatus(atomic.LoadUint32((*uint32)(&c._status))) +} + +func (c *C) setStatus(s funcStatus) { + atomic.StoreUint32((*uint32)(&c._status), uint32(s)) +} + +func (c *C) stopNow() { + runtime.Goexit() +} + +// logger is a concurrency safe byte.Buffer +type logger struct { + sync.Mutex + writer bytes.Buffer +} + +func (l *logger) Write(buf []byte) (int, error) { + l.Lock() + defer l.Unlock() + return l.writer.Write(buf) +} + +func (l *logger) WriteTo(w io.Writer) (int64, error) { + l.Lock() + defer l.Unlock() + return l.writer.WriteTo(w) +} + +func (l *logger) String() string { + l.Lock() + defer l.Unlock() + return l.writer.String() +} + +// ----------------------------------------------------------------------- +// Handling of temporary files and directories. + +type tempDir struct { + sync.Mutex + path string + counter int +} + +func (td *tempDir) newPath() string { + td.Lock() + defer td.Unlock() + if td.path == "" { + var err error + for i := 0; i != 100; i++ { + path := fmt.Sprintf("%s%ccheck-%d", os.TempDir(), os.PathSeparator, rand.Int()) + if err = os.Mkdir(path, 0700); err == nil { + td.path = path + break + } + } + if td.path == "" { + panic("Couldn't create temporary directory: " + err.Error()) + } + } + result := filepath.Join(td.path, strconv.Itoa(td.counter)) + td.counter += 1 + return result +} + +func (td *tempDir) removeAll() { + td.Lock() + defer td.Unlock() + if td.path != "" { + err := os.RemoveAll(td.path) + if err != nil { + fmt.Fprintf(os.Stderr, "WARNING: Error cleaning up temporaries: "+err.Error()) + } + } +} + +// Create a new temporary directory which is automatically removed after +// the suite finishes running. +func (c *C) MkDir() string { + path := c.tempDir.newPath() + if err := os.Mkdir(path, 0700); err != nil { + panic(fmt.Sprintf("Couldn't create temporary directory %s: %s", path, err.Error())) + } + return path +} + +// ----------------------------------------------------------------------- +// Low-level logging functions. + +func (c *C) log(args ...interface{}) { + c.writeLog([]byte(fmt.Sprint(args...) + "\n")) +} + +func (c *C) logf(format string, args ...interface{}) { + c.writeLog([]byte(fmt.Sprintf(format+"\n", args...))) +} + +func (c *C) logNewLine() { + c.writeLog([]byte{'\n'}) +} + +func (c *C) writeLog(buf []byte) { + c.logb.Write(buf) + if c.logw != nil { + c.logw.Write(buf) + } +} + +func hasStringOrError(x interface{}) (ok bool) { + _, ok = x.(fmt.Stringer) + if ok { + return + } + _, ok = x.(error) + return +} + +func (c *C) logValue(label string, value interface{}) { + if label == "" { + if hasStringOrError(value) { + c.logf("... %#v (%q)", value, value) + } else { + c.logf("... %#v", value) + } + } else if value == nil { + c.logf("... %s = nil", label) + } else { + if hasStringOrError(value) { + fv := fmt.Sprintf("%#v", value) + qv := fmt.Sprintf("%q", value) + if fv != qv { + c.logf("... %s %s = %s (%s)", label, reflect.TypeOf(value), fv, qv) + return + } + } + if s, ok := value.(string); ok && isMultiLine(s) { + c.logf(`... %s %s = "" +`, label, reflect.TypeOf(value)) + c.logMultiLine(s) + } else { + c.logf("... %s %s = %#v", label, reflect.TypeOf(value), value) + } + } +} + +func (c *C) logMultiLine(s string) { + b := make([]byte, 0, len(s)*2) + i := 0 + n := len(s) + for i < n { + j := i + 1 + for j < n && s[j-1] != '\n' { + j++ + } + b = append(b, "... "...) + b = strconv.AppendQuote(b, s[i:j]) + if j < n { + b = append(b, " +"...) + } + b = append(b, '\n') + i = j + } + c.writeLog(b) +} + +func isMultiLine(s string) bool { + for i := 0; i+1 < len(s); i++ { + if s[i] == '\n' { + return true + } + } + return false +} + +func (c *C) logString(issue string) { + c.log("... ", issue) +} + +func (c *C) logCaller(skip int) { + // This is a bit heavier than it ought to be. + skip += 1 // Our own frame. + pc, callerFile, callerLine, ok := runtime.Caller(skip) + if !ok { + return + } + var testFile string + var testLine int + testFunc := runtime.FuncForPC(c.method.PC()) + if runtime.FuncForPC(pc) != testFunc { + for { + skip += 1 + if pc, file, line, ok := runtime.Caller(skip); ok { + // Note that the test line may be different on + // distinct calls for the same test. Showing + // the "internal" line is helpful when debugging. + if runtime.FuncForPC(pc) == testFunc { + testFile, testLine = file, line + break + } + } else { + break + } + } + } + if testFile != "" && (testFile != callerFile || testLine != callerLine) { + c.logCode(testFile, testLine) + } + c.logCode(callerFile, callerLine) +} + +func (c *C) logCode(path string, line int) { + c.logf("%s:%d:", nicePath(path), line) + code, err := printLine(path, line) + if code == "" { + code = "..." // XXX Open the file and take the raw line. + if err != nil { + code += err.Error() + } + } + c.log(indent(code, " ")) +} + +var valueGo = filepath.Join("reflect", "value.go") +var asmGo = filepath.Join("runtime", "asm_") + +func (c *C) logPanic(skip int, value interface{}) { + skip++ // Our own frame. + initialSkip := skip + for ; ; skip++ { + if pc, file, line, ok := runtime.Caller(skip); ok { + if skip == initialSkip { + c.logf("... Panic: %s (PC=0x%X)\n", value, pc) + } + name := niceFuncName(pc) + path := nicePath(file) + if strings.Contains(path, "/gopkg.in/check.v") { + continue + } + if name == "Value.call" && strings.HasSuffix(path, valueGo) { + continue + } + if (name == "call16" || name == "call32") && strings.Contains(path, asmGo) { + continue + } + c.logf("%s:%d\n in %s", nicePath(file), line, name) + } else { + break + } + } +} + +func (c *C) logSoftPanic(issue string) { + c.log("... Panic: ", issue) +} + +func (c *C) logArgPanic(method *methodType, expectedType string) { + c.logf("... Panic: %s argument should be %s", + niceFuncName(method.PC()), expectedType) +} + +// ----------------------------------------------------------------------- +// Some simple formatting helpers. + +var initWD, initWDErr = os.Getwd() + +func init() { + if initWDErr == nil { + initWD = strings.Replace(initWD, "\\", "/", -1) + "/" + } +} + +func nicePath(path string) string { + if initWDErr == nil { + if strings.HasPrefix(path, initWD) { + return path[len(initWD):] + } + } + return path +} + +func niceFuncPath(pc uintptr) string { + function := runtime.FuncForPC(pc) + if function != nil { + filename, line := function.FileLine(pc) + return fmt.Sprintf("%s:%d", nicePath(filename), line) + } + return "" +} + +func niceFuncName(pc uintptr) string { + function := runtime.FuncForPC(pc) + if function != nil { + name := path.Base(function.Name()) + if i := strings.Index(name, "."); i > 0 { + name = name[i+1:] + } + if strings.HasPrefix(name, "(*") { + if i := strings.Index(name, ")"); i > 0 { + name = name[2:i] + name[i+1:] + } + } + if i := strings.LastIndex(name, ".*"); i != -1 { + name = name[:i] + "." + name[i+2:] + } + if i := strings.LastIndex(name, "·"); i != -1 { + name = name[:i] + "." + name[i+2:] + } + return name + } + return "" +} + +// ----------------------------------------------------------------------- +// Result tracker to aggregate call results. + +type Result struct { + Succeeded int + Failed int + Skipped int + Panicked int + FixturePanicked int + ExpectedFailures int + Missed int // Not even tried to run, related to a panic in the fixture. + RunError error // Houston, we've got a problem. + WorkDir string // If KeepWorkDir is true +} + +type resultTracker struct { + result Result + _lastWasProblem bool + _waiting int + _missed int + _expectChan chan *C + _doneChan chan *C + _stopChan chan bool +} + +func newResultTracker() *resultTracker { + return &resultTracker{_expectChan: make(chan *C), // Synchronous + _doneChan: make(chan *C, 32), // Asynchronous + _stopChan: make(chan bool)} // Synchronous +} + +func (tracker *resultTracker) start() { + go tracker._loopRoutine() +} + +func (tracker *resultTracker) waitAndStop() { + <-tracker._stopChan +} + +func (tracker *resultTracker) expectCall(c *C) { + tracker._expectChan <- c +} + +func (tracker *resultTracker) callDone(c *C) { + tracker._doneChan <- c +} + +func (tracker *resultTracker) _loopRoutine() { + for { + var c *C + if tracker._waiting > 0 { + // Calls still running. Can't stop. + select { + // XXX Reindent this (not now to make diff clear) + case c = <-tracker._expectChan: + tracker._waiting += 1 + case c = <-tracker._doneChan: + tracker._waiting -= 1 + switch c.status() { + case succeededSt: + if c.kind == testKd { + if c.mustFail { + tracker.result.ExpectedFailures++ + } else { + tracker.result.Succeeded++ + } + } + case failedSt: + tracker.result.Failed++ + case panickedSt: + if c.kind == fixtureKd { + tracker.result.FixturePanicked++ + } else { + tracker.result.Panicked++ + } + case fixturePanickedSt: + // Track it as missed, since the panic + // was on the fixture, not on the test. + tracker.result.Missed++ + case missedSt: + tracker.result.Missed++ + case skippedSt: + if c.kind == testKd { + tracker.result.Skipped++ + } + } + } + } else { + // No calls. Can stop, but no done calls here. + select { + case tracker._stopChan <- true: + return + case c = <-tracker._expectChan: + tracker._waiting += 1 + case c = <-tracker._doneChan: + panic("Tracker got an unexpected done call.") + } + } + } +} + +// ----------------------------------------------------------------------- +// The underlying suite runner. + +type suiteRunner struct { + suite interface{} + setUpSuite, tearDownSuite *methodType + setUpTest, tearDownTest *methodType + tests []*methodType + tracker *resultTracker + tempDir *tempDir + keepDir bool + output *outputWriter + reportedProblemLast bool + benchTime time.Duration + benchMem bool +} + +type RunConf struct { + Output io.Writer + Stream bool + Verbose bool + Filter string + Benchmark bool + BenchmarkTime time.Duration // Defaults to 1 second + BenchmarkMem bool + KeepWorkDir bool +} + +// Create a new suiteRunner able to run all methods in the given suite. +func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner { + var conf RunConf + if runConf != nil { + conf = *runConf + } + if conf.Output == nil { + conf.Output = os.Stdout + } + if conf.Benchmark { + conf.Verbose = true + } + + suiteType := reflect.TypeOf(suite) + suiteNumMethods := suiteType.NumMethod() + suiteValue := reflect.ValueOf(suite) + + runner := &suiteRunner{ + suite: suite, + output: newOutputWriter(conf.Output, conf.Stream, conf.Verbose), + tracker: newResultTracker(), + benchTime: conf.BenchmarkTime, + benchMem: conf.BenchmarkMem, + tempDir: &tempDir{}, + keepDir: conf.KeepWorkDir, + tests: make([]*methodType, 0, suiteNumMethods), + } + if runner.benchTime == 0 { + runner.benchTime = 1 * time.Second + } + + var filterRegexp *regexp.Regexp + if conf.Filter != "" { + if regexp, err := regexp.Compile(conf.Filter); err != nil { + msg := "Bad filter expression: " + err.Error() + runner.tracker.result.RunError = errors.New(msg) + return runner + } else { + filterRegexp = regexp + } + } + + for i := 0; i != suiteNumMethods; i++ { + method := newMethod(suiteValue, i) + switch method.Info.Name { + case "SetUpSuite": + runner.setUpSuite = method + case "TearDownSuite": + runner.tearDownSuite = method + case "SetUpTest": + runner.setUpTest = method + case "TearDownTest": + runner.tearDownTest = method + default: + prefix := "Test" + if conf.Benchmark { + prefix = "Benchmark" + } + if !strings.HasPrefix(method.Info.Name, prefix) { + continue + } + if filterRegexp == nil || method.matches(filterRegexp) { + runner.tests = append(runner.tests, method) + } + } + } + return runner +} + +// Run all methods in the given suite. +func (runner *suiteRunner) run() *Result { + if runner.tracker.result.RunError == nil && len(runner.tests) > 0 { + runner.tracker.start() + if runner.checkFixtureArgs() { + c := runner.runFixture(runner.setUpSuite, "", nil) + if c == nil || c.status() == succeededSt { + for i := 0; i != len(runner.tests); i++ { + c := runner.runTest(runner.tests[i]) + if c.status() == fixturePanickedSt { + runner.skipTests(missedSt, runner.tests[i+1:]) + break + } + } + } else if c != nil && c.status() == skippedSt { + runner.skipTests(skippedSt, runner.tests) + } else { + runner.skipTests(missedSt, runner.tests) + } + runner.runFixture(runner.tearDownSuite, "", nil) + } else { + runner.skipTests(missedSt, runner.tests) + } + runner.tracker.waitAndStop() + if runner.keepDir { + runner.tracker.result.WorkDir = runner.tempDir.path + } else { + runner.tempDir.removeAll() + } + } + return &runner.tracker.result +} + +// Create a call object with the given suite method, and fork a +// goroutine with the provided dispatcher for running it. +func (runner *suiteRunner) forkCall(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C { + var logw io.Writer + if runner.output.Stream { + logw = runner.output + } + if logb == nil { + logb = new(logger) + } + c := &C{ + method: method, + kind: kind, + testName: testName, + logb: logb, + logw: logw, + tempDir: runner.tempDir, + done: make(chan *C, 1), + timer: timer{benchTime: runner.benchTime}, + startTime: time.Now(), + benchMem: runner.benchMem, + } + runner.tracker.expectCall(c) + go (func() { + runner.reportCallStarted(c) + defer runner.callDone(c) + dispatcher(c) + })() + return c +} + +// Same as forkCall(), but wait for call to finish before returning. +func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C { + c := runner.forkCall(method, kind, testName, logb, dispatcher) + <-c.done + return c +} + +// Handle a finished call. If there were any panics, update the call status +// accordingly. Then, mark the call as done and report to the tracker. +func (runner *suiteRunner) callDone(c *C) { + value := recover() + if value != nil { + switch v := value.(type) { + case *fixturePanic: + if v.status == skippedSt { + c.setStatus(skippedSt) + } else { + c.logSoftPanic("Fixture has panicked (see related PANIC)") + c.setStatus(fixturePanickedSt) + } + default: + c.logPanic(1, value) + c.setStatus(panickedSt) + } + } + if c.mustFail { + switch c.status() { + case failedSt: + c.setStatus(succeededSt) + case succeededSt: + c.setStatus(failedSt) + c.logString("Error: Test succeeded, but was expected to fail") + c.logString("Reason: " + c.reason) + } + } + + runner.reportCallDone(c) + c.done <- c +} + +// Runs a fixture call synchronously. The fixture will still be run in a +// goroutine like all suite methods, but this method will not return +// while the fixture goroutine is not done, because the fixture must be +// run in a desired order. +func (runner *suiteRunner) runFixture(method *methodType, testName string, logb *logger) *C { + if method != nil { + c := runner.runFunc(method, fixtureKd, testName, logb, func(c *C) { + c.ResetTimer() + c.StartTimer() + defer c.StopTimer() + c.method.Call([]reflect.Value{reflect.ValueOf(c)}) + }) + return c + } + return nil +} + +// Run the fixture method with runFixture(), but panic with a fixturePanic{} +// in case the fixture method panics. This makes it easier to track the +// fixture panic together with other call panics within forkTest(). +func (runner *suiteRunner) runFixtureWithPanic(method *methodType, testName string, logb *logger, skipped *bool) *C { + if skipped != nil && *skipped { + return nil + } + c := runner.runFixture(method, testName, logb) + if c != nil && c.status() != succeededSt { + if skipped != nil { + *skipped = c.status() == skippedSt + } + panic(&fixturePanic{c.status(), method}) + } + return c +} + +type fixturePanic struct { + status funcStatus + method *methodType +} + +// Run the suite test method, together with the test-specific fixture, +// asynchronously. +func (runner *suiteRunner) forkTest(method *methodType) *C { + testName := method.String() + return runner.forkCall(method, testKd, testName, nil, func(c *C) { + var skipped bool + defer runner.runFixtureWithPanic(runner.tearDownTest, testName, nil, &skipped) + defer c.StopTimer() + benchN := 1 + for { + runner.runFixtureWithPanic(runner.setUpTest, testName, c.logb, &skipped) + mt := c.method.Type() + if mt.NumIn() != 1 || mt.In(0) != reflect.TypeOf(c) { + // Rather than a plain panic, provide a more helpful message when + // the argument type is incorrect. + c.setStatus(panickedSt) + c.logArgPanic(c.method, "*check.C") + return + } + if strings.HasPrefix(c.method.Info.Name, "Test") { + c.ResetTimer() + c.StartTimer() + c.method.Call([]reflect.Value{reflect.ValueOf(c)}) + return + } + if !strings.HasPrefix(c.method.Info.Name, "Benchmark") { + panic("unexpected method prefix: " + c.method.Info.Name) + } + + runtime.GC() + c.N = benchN + c.ResetTimer() + c.StartTimer() + c.method.Call([]reflect.Value{reflect.ValueOf(c)}) + c.StopTimer() + if c.status() != succeededSt || c.duration >= c.benchTime || benchN >= 1e9 { + return + } + perOpN := int(1e9) + if c.nsPerOp() != 0 { + perOpN = int(c.benchTime.Nanoseconds() / c.nsPerOp()) + } + + // Logic taken from the stock testing package: + // - Run more iterations than we think we'll need for a second (1.5x). + // - Don't grow too fast in case we had timing errors previously. + // - Be sure to run at least one more than last time. + benchN = max(min(perOpN+perOpN/2, 100*benchN), benchN+1) + benchN = roundUp(benchN) + + skipped = true // Don't run the deferred one if this panics. + runner.runFixtureWithPanic(runner.tearDownTest, testName, nil, nil) + skipped = false + } + }) +} + +// Same as forkTest(), but wait for the test to finish before returning. +func (runner *suiteRunner) runTest(method *methodType) *C { + c := runner.forkTest(method) + <-c.done + return c +} + +// Helper to mark tests as skipped or missed. A bit heavy for what +// it does, but it enables homogeneous handling of tracking, including +// nice verbose output. +func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) { + for _, method := range methods { + runner.runFunc(method, testKd, "", nil, func(c *C) { + c.setStatus(status) + }) + } +} + +// Verify if the fixture arguments are *check.C. In case of errors, +// log the error as a panic in the fixture method call, and return false. +func (runner *suiteRunner) checkFixtureArgs() bool { + succeeded := true + argType := reflect.TypeOf(&C{}) + for _, method := range []*methodType{runner.setUpSuite, runner.tearDownSuite, runner.setUpTest, runner.tearDownTest} { + if method != nil { + mt := method.Type() + if mt.NumIn() != 1 || mt.In(0) != argType { + succeeded = false + runner.runFunc(method, fixtureKd, "", nil, func(c *C) { + c.logArgPanic(method, "*check.C") + c.setStatus(panickedSt) + }) + } + } + } + return succeeded +} + +func (runner *suiteRunner) reportCallStarted(c *C) { + runner.output.WriteCallStarted("START", c) +} + +func (runner *suiteRunner) reportCallDone(c *C) { + runner.tracker.callDone(c) + switch c.status() { + case succeededSt: + if c.mustFail { + runner.output.WriteCallSuccess("FAIL EXPECTED", c) + } else { + runner.output.WriteCallSuccess("PASS", c) + } + case skippedSt: + runner.output.WriteCallSuccess("SKIP", c) + case failedSt: + runner.output.WriteCallProblem("FAIL", c) + case panickedSt: + runner.output.WriteCallProblem("PANIC", c) + case fixturePanickedSt: + // That's a testKd call reporting that its fixture + // has panicked. The fixture call which caused the + // panic itself was tracked above. We'll report to + // aid debugging. + runner.output.WriteCallProblem("PANIC", c) + case missedSt: + runner.output.WriteCallSuccess("MISS", c) + } +} diff --git a/vendor/gopkg.in/check.v1/check_test.go b/vendor/gopkg.in/check.v1/check_test.go new file mode 100644 index 00000000..871b3252 --- /dev/null +++ b/vendor/gopkg.in/check.v1/check_test.go @@ -0,0 +1,207 @@ +// This file contains just a few generic helpers which are used by the +// other test files. + +package check_test + +import ( + "flag" + "fmt" + "os" + "regexp" + "runtime" + "testing" + "time" + + "gopkg.in/check.v1" +) + +// We count the number of suites run at least to get a vague hint that the +// test suite is behaving as it should. Otherwise a bug introduced at the +// very core of the system could go unperceived. +const suitesRunExpected = 8 + +var suitesRun int = 0 + +func Test(t *testing.T) { + check.TestingT(t) + if suitesRun != suitesRunExpected && flag.Lookup("check.f").Value.String() == "" { + critical(fmt.Sprintf("Expected %d suites to run rather than %d", + suitesRunExpected, suitesRun)) + } +} + +// ----------------------------------------------------------------------- +// Helper functions. + +// Break down badly. This is used in test cases which can't yet assume +// that the fundamental bits are working. +func critical(error string) { + fmt.Fprintln(os.Stderr, "CRITICAL: "+error) + os.Exit(1) +} + +// Return the file line where it's called. +func getMyLine() int { + if _, _, line, ok := runtime.Caller(1); ok { + return line + } + return -1 +} + +// ----------------------------------------------------------------------- +// Helper type implementing a basic io.Writer for testing output. + +// Type implementing the io.Writer interface for analyzing output. +type String struct { + value string +} + +// The only function required by the io.Writer interface. Will append +// written data to the String.value string. +func (s *String) Write(p []byte) (n int, err error) { + s.value += string(p) + return len(p), nil +} + +// Trivial wrapper to test errors happening on a different file +// than the test itself. +func checkEqualWrapper(c *check.C, obtained, expected interface{}) (result bool, line int) { + return c.Check(obtained, check.Equals, expected), getMyLine() +} + +// ----------------------------------------------------------------------- +// Helper suite for testing basic fail behavior. + +type FailHelper struct { + testLine int +} + +func (s *FailHelper) TestLogAndFail(c *check.C) { + s.testLine = getMyLine() - 1 + c.Log("Expected failure!") + c.Fail() +} + +// ----------------------------------------------------------------------- +// Helper suite for testing basic success behavior. + +type SuccessHelper struct{} + +func (s *SuccessHelper) TestLogAndSucceed(c *check.C) { + c.Log("Expected success!") +} + +// ----------------------------------------------------------------------- +// Helper suite for testing ordering and behavior of fixture. + +type FixtureHelper struct { + calls []string + panicOn string + skip bool + skipOnN int + sleepOn string + sleep time.Duration + bytes int64 +} + +func (s *FixtureHelper) trace(name string, c *check.C) { + s.calls = append(s.calls, name) + if name == s.panicOn { + panic(name) + } + if s.sleep > 0 && s.sleepOn == name { + time.Sleep(s.sleep) + } + if s.skip && s.skipOnN == len(s.calls)-1 { + c.Skip("skipOnN == n") + } +} + +func (s *FixtureHelper) SetUpSuite(c *check.C) { + s.trace("SetUpSuite", c) +} + +func (s *FixtureHelper) TearDownSuite(c *check.C) { + s.trace("TearDownSuite", c) +} + +func (s *FixtureHelper) SetUpTest(c *check.C) { + s.trace("SetUpTest", c) +} + +func (s *FixtureHelper) TearDownTest(c *check.C) { + s.trace("TearDownTest", c) +} + +func (s *FixtureHelper) Test1(c *check.C) { + s.trace("Test1", c) +} + +func (s *FixtureHelper) Test2(c *check.C) { + s.trace("Test2", c) +} + +func (s *FixtureHelper) Benchmark1(c *check.C) { + s.trace("Benchmark1", c) + for i := 0; i < c.N; i++ { + time.Sleep(s.sleep) + } +} + +func (s *FixtureHelper) Benchmark2(c *check.C) { + s.trace("Benchmark2", c) + c.SetBytes(1024) + for i := 0; i < c.N; i++ { + time.Sleep(s.sleep) + } +} + +func (s *FixtureHelper) Benchmark3(c *check.C) { + var x []int64 + s.trace("Benchmark3", c) + for i := 0; i < c.N; i++ { + time.Sleep(s.sleep) + x = make([]int64, 5) + _ = x + } +} + +// ----------------------------------------------------------------------- +// Helper which checks the state of the test and ensures that it matches +// the given expectations. Depends on c.Errorf() working, so shouldn't +// be used to test this one function. + +type expectedState struct { + name string + result interface{} + failed bool + log string +} + +// Verify the state of the test. Note that since this also verifies if +// the test is supposed to be in a failed state, no other checks should +// be done in addition to what is being tested. +func checkState(c *check.C, result interface{}, expected *expectedState) { + failed := c.Failed() + c.Succeed() + log := c.GetTestLog() + matched, matchError := regexp.MatchString("^"+expected.log+"$", log) + if matchError != nil { + c.Errorf("Error in matching expression used in testing %s", + expected.name) + } else if !matched { + c.Errorf("%s logged:\n----------\n%s----------\n\nExpected:\n----------\n%s\n----------", + expected.name, log, expected.log) + } + if result != expected.result { + c.Errorf("%s returned %#v rather than %#v", + expected.name, result, expected.result) + } + if failed != expected.failed { + if failed { + c.Errorf("%s has failed when it shouldn't", expected.name) + } else { + c.Errorf("%s has not failed when it should", expected.name) + } + } +} diff --git a/vendor/gopkg.in/check.v1/checkers.go b/vendor/gopkg.in/check.v1/checkers.go new file mode 100644 index 00000000..bac33872 --- /dev/null +++ b/vendor/gopkg.in/check.v1/checkers.go @@ -0,0 +1,458 @@ +package check + +import ( + "fmt" + "reflect" + "regexp" +) + +// ----------------------------------------------------------------------- +// CommentInterface and Commentf helper, to attach extra information to checks. + +type comment struct { + format string + args []interface{} +} + +// Commentf returns an infomational value to use with Assert or Check calls. +// If the checker test fails, the provided arguments will be passed to +// fmt.Sprintf, and will be presented next to the logged failure. +// +// For example: +// +// c.Assert(v, Equals, 42, Commentf("Iteration #%d failed.", i)) +// +// Note that if the comment is constant, a better option is to +// simply use a normal comment right above or next to the line, as +// it will also get printed with any errors: +// +// c.Assert(l, Equals, 8192) // Ensure buffer size is correct (bug #123) +// +func Commentf(format string, args ...interface{}) CommentInterface { + return &comment{format, args} +} + +// CommentInterface must be implemented by types that attach extra +// information to failed checks. See the Commentf function for details. +type CommentInterface interface { + CheckCommentString() string +} + +func (c *comment) CheckCommentString() string { + return fmt.Sprintf(c.format, c.args...) +} + +// ----------------------------------------------------------------------- +// The Checker interface. + +// The Checker interface must be provided by checkers used with +// the Assert and Check verification methods. +type Checker interface { + Info() *CheckerInfo + Check(params []interface{}, names []string) (result bool, error string) +} + +// See the Checker interface. +type CheckerInfo struct { + Name string + Params []string +} + +func (info *CheckerInfo) Info() *CheckerInfo { + return info +} + +// ----------------------------------------------------------------------- +// Not checker logic inverter. + +// The Not checker inverts the logic of the provided checker. The +// resulting checker will succeed where the original one failed, and +// vice-versa. +// +// For example: +// +// c.Assert(a, Not(Equals), b) +// +func Not(checker Checker) Checker { + return ¬Checker{checker} +} + +type notChecker struct { + sub Checker +} + +func (checker *notChecker) Info() *CheckerInfo { + info := *checker.sub.Info() + info.Name = "Not(" + info.Name + ")" + return &info +} + +func (checker *notChecker) Check(params []interface{}, names []string) (result bool, error string) { + result, error = checker.sub.Check(params, names) + result = !result + return +} + +// ----------------------------------------------------------------------- +// IsNil checker. + +type isNilChecker struct { + *CheckerInfo +} + +// The IsNil checker tests whether the obtained value is nil. +// +// For example: +// +// c.Assert(err, IsNil) +// +var IsNil Checker = &isNilChecker{ + &CheckerInfo{Name: "IsNil", Params: []string{"value"}}, +} + +func (checker *isNilChecker) Check(params []interface{}, names []string) (result bool, error string) { + return isNil(params[0]), "" +} + +func isNil(obtained interface{}) (result bool) { + if obtained == nil { + result = true + } else { + switch v := reflect.ValueOf(obtained); v.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + } + } + return +} + +// ----------------------------------------------------------------------- +// NotNil checker. Alias for Not(IsNil), since it's so common. + +type notNilChecker struct { + *CheckerInfo +} + +// The NotNil checker verifies that the obtained value is not nil. +// +// For example: +// +// c.Assert(iface, NotNil) +// +// This is an alias for Not(IsNil), made available since it's a +// fairly common check. +// +var NotNil Checker = ¬NilChecker{ + &CheckerInfo{Name: "NotNil", Params: []string{"value"}}, +} + +func (checker *notNilChecker) Check(params []interface{}, names []string) (result bool, error string) { + return !isNil(params[0]), "" +} + +// ----------------------------------------------------------------------- +// Equals checker. + +type equalsChecker struct { + *CheckerInfo +} + +// The Equals checker verifies that the obtained value is equal to +// the expected value, according to usual Go semantics for ==. +// +// For example: +// +// c.Assert(value, Equals, 42) +// +var Equals Checker = &equalsChecker{ + &CheckerInfo{Name: "Equals", Params: []string{"obtained", "expected"}}, +} + +func (checker *equalsChecker) Check(params []interface{}, names []string) (result bool, error string) { + defer func() { + if v := recover(); v != nil { + result = false + error = fmt.Sprint(v) + } + }() + return params[0] == params[1], "" +} + +// ----------------------------------------------------------------------- +// DeepEquals checker. + +type deepEqualsChecker struct { + *CheckerInfo +} + +// The DeepEquals checker verifies that the obtained value is deep-equal to +// the expected value. The check will work correctly even when facing +// slices, interfaces, and values of different types (which always fail +// the test). +// +// For example: +// +// c.Assert(value, DeepEquals, 42) +// c.Assert(array, DeepEquals, []string{"hi", "there"}) +// +var DeepEquals Checker = &deepEqualsChecker{ + &CheckerInfo{Name: "DeepEquals", Params: []string{"obtained", "expected"}}, +} + +func (checker *deepEqualsChecker) Check(params []interface{}, names []string) (result bool, error string) { + return reflect.DeepEqual(params[0], params[1]), "" +} + +// ----------------------------------------------------------------------- +// HasLen checker. + +type hasLenChecker struct { + *CheckerInfo +} + +// The HasLen checker verifies that the obtained value has the +// provided length. In many cases this is superior to using Equals +// in conjuction with the len function because in case the check +// fails the value itself will be printed, instead of its length, +// providing more details for figuring the problem. +// +// For example: +// +// c.Assert(list, HasLen, 5) +// +var HasLen Checker = &hasLenChecker{ + &CheckerInfo{Name: "HasLen", Params: []string{"obtained", "n"}}, +} + +func (checker *hasLenChecker) Check(params []interface{}, names []string) (result bool, error string) { + n, ok := params[1].(int) + if !ok { + return false, "n must be an int" + } + value := reflect.ValueOf(params[0]) + switch value.Kind() { + case reflect.Map, reflect.Array, reflect.Slice, reflect.Chan, reflect.String: + default: + return false, "obtained value type has no length" + } + return value.Len() == n, "" +} + +// ----------------------------------------------------------------------- +// ErrorMatches checker. + +type errorMatchesChecker struct { + *CheckerInfo +} + +// The ErrorMatches checker verifies that the error value +// is non nil and matches the regular expression provided. +// +// For example: +// +// c.Assert(err, ErrorMatches, "perm.*denied") +// +var ErrorMatches Checker = errorMatchesChecker{ + &CheckerInfo{Name: "ErrorMatches", Params: []string{"value", "regex"}}, +} + +func (checker errorMatchesChecker) Check(params []interface{}, names []string) (result bool, errStr string) { + if params[0] == nil { + return false, "Error value is nil" + } + err, ok := params[0].(error) + if !ok { + return false, "Value is not an error" + } + params[0] = err.Error() + names[0] = "error" + return matches(params[0], params[1]) +} + +// ----------------------------------------------------------------------- +// Matches checker. + +type matchesChecker struct { + *CheckerInfo +} + +// The Matches checker verifies that the string provided as the obtained +// value (or the string resulting from obtained.String()) matches the +// regular expression provided. +// +// For example: +// +// c.Assert(err, Matches, "perm.*denied") +// +var Matches Checker = &matchesChecker{ + &CheckerInfo{Name: "Matches", Params: []string{"value", "regex"}}, +} + +func (checker *matchesChecker) Check(params []interface{}, names []string) (result bool, error string) { + return matches(params[0], params[1]) +} + +func matches(value, regex interface{}) (result bool, error string) { + reStr, ok := regex.(string) + if !ok { + return false, "Regex must be a string" + } + valueStr, valueIsStr := value.(string) + if !valueIsStr { + if valueWithStr, valueHasStr := value.(fmt.Stringer); valueHasStr { + valueStr, valueIsStr = valueWithStr.String(), true + } + } + if valueIsStr { + matches, err := regexp.MatchString("^"+reStr+"$", valueStr) + if err != nil { + return false, "Can't compile regex: " + err.Error() + } + return matches, "" + } + return false, "Obtained value is not a string and has no .String()" +} + +// ----------------------------------------------------------------------- +// Panics checker. + +type panicsChecker struct { + *CheckerInfo +} + +// The Panics checker verifies that calling the provided zero-argument +// function will cause a panic which is deep-equal to the provided value. +// +// For example: +// +// c.Assert(func() { f(1, 2) }, Panics, &SomeErrorType{"BOOM"}). +// +// +var Panics Checker = &panicsChecker{ + &CheckerInfo{Name: "Panics", Params: []string{"function", "expected"}}, +} + +func (checker *panicsChecker) Check(params []interface{}, names []string) (result bool, error string) { + f := reflect.ValueOf(params[0]) + if f.Kind() != reflect.Func || f.Type().NumIn() != 0 { + return false, "Function must take zero arguments" + } + defer func() { + // If the function has not panicked, then don't do the check. + if error != "" { + return + } + params[0] = recover() + names[0] = "panic" + result = reflect.DeepEqual(params[0], params[1]) + }() + f.Call(nil) + return false, "Function has not panicked" +} + +type panicMatchesChecker struct { + *CheckerInfo +} + +// The PanicMatches checker verifies that calling the provided zero-argument +// function will cause a panic with an error value matching +// the regular expression provided. +// +// For example: +// +// c.Assert(func() { f(1, 2) }, PanicMatches, `open.*: no such file or directory`). +// +// +var PanicMatches Checker = &panicMatchesChecker{ + &CheckerInfo{Name: "PanicMatches", Params: []string{"function", "expected"}}, +} + +func (checker *panicMatchesChecker) Check(params []interface{}, names []string) (result bool, errmsg string) { + f := reflect.ValueOf(params[0]) + if f.Kind() != reflect.Func || f.Type().NumIn() != 0 { + return false, "Function must take zero arguments" + } + defer func() { + // If the function has not panicked, then don't do the check. + if errmsg != "" { + return + } + obtained := recover() + names[0] = "panic" + if e, ok := obtained.(error); ok { + params[0] = e.Error() + } else if _, ok := obtained.(string); ok { + params[0] = obtained + } else { + errmsg = "Panic value is not a string or an error" + return + } + result, errmsg = matches(params[0], params[1]) + }() + f.Call(nil) + return false, "Function has not panicked" +} + +// ----------------------------------------------------------------------- +// FitsTypeOf checker. + +type fitsTypeChecker struct { + *CheckerInfo +} + +// The FitsTypeOf checker verifies that the obtained value is +// assignable to a variable with the same type as the provided +// sample value. +// +// For example: +// +// c.Assert(value, FitsTypeOf, int64(0)) +// c.Assert(value, FitsTypeOf, os.Error(nil)) +// +var FitsTypeOf Checker = &fitsTypeChecker{ + &CheckerInfo{Name: "FitsTypeOf", Params: []string{"obtained", "sample"}}, +} + +func (checker *fitsTypeChecker) Check(params []interface{}, names []string) (result bool, error string) { + obtained := reflect.ValueOf(params[0]) + sample := reflect.ValueOf(params[1]) + if !obtained.IsValid() { + return false, "" + } + if !sample.IsValid() { + return false, "Invalid sample value" + } + return obtained.Type().AssignableTo(sample.Type()), "" +} + +// ----------------------------------------------------------------------- +// Implements checker. + +type implementsChecker struct { + *CheckerInfo +} + +// The Implements checker verifies that the obtained value +// implements the interface specified via a pointer to an interface +// variable. +// +// For example: +// +// var e os.Error +// c.Assert(err, Implements, &e) +// +var Implements Checker = &implementsChecker{ + &CheckerInfo{Name: "Implements", Params: []string{"obtained", "ifaceptr"}}, +} + +func (checker *implementsChecker) Check(params []interface{}, names []string) (result bool, error string) { + obtained := reflect.ValueOf(params[0]) + ifaceptr := reflect.ValueOf(params[1]) + if !obtained.IsValid() { + return false, "" + } + if !ifaceptr.IsValid() || ifaceptr.Kind() != reflect.Ptr || ifaceptr.Elem().Kind() != reflect.Interface { + return false, "ifaceptr should be a pointer to an interface variable" + } + return obtained.Type().Implements(ifaceptr.Elem().Type()), "" +} diff --git a/vendor/gopkg.in/check.v1/checkers_test.go b/vendor/gopkg.in/check.v1/checkers_test.go new file mode 100644 index 00000000..5c697474 --- /dev/null +++ b/vendor/gopkg.in/check.v1/checkers_test.go @@ -0,0 +1,272 @@ +package check_test + +import ( + "errors" + "gopkg.in/check.v1" + "reflect" + "runtime" +) + +type CheckersS struct{} + +var _ = check.Suite(&CheckersS{}) + +func testInfo(c *check.C, checker check.Checker, name string, paramNames []string) { + info := checker.Info() + if info.Name != name { + c.Fatalf("Got name %s, expected %s", info.Name, name) + } + if !reflect.DeepEqual(info.Params, paramNames) { + c.Fatalf("Got param names %#v, expected %#v", info.Params, paramNames) + } +} + +func testCheck(c *check.C, checker check.Checker, result bool, error string, params ...interface{}) ([]interface{}, []string) { + info := checker.Info() + if len(params) != len(info.Params) { + c.Fatalf("unexpected param count in test; expected %d got %d", len(info.Params), len(params)) + } + names := append([]string{}, info.Params...) + result_, error_ := checker.Check(params, names) + if result_ != result || error_ != error { + c.Fatalf("%s.Check(%#v) returned (%#v, %#v) rather than (%#v, %#v)", + info.Name, params, result_, error_, result, error) + } + return params, names +} + +func (s *CheckersS) TestComment(c *check.C) { + bug := check.Commentf("a %d bc", 42) + comment := bug.CheckCommentString() + if comment != "a 42 bc" { + c.Fatalf("Commentf returned %#v", comment) + } +} + +func (s *CheckersS) TestIsNil(c *check.C) { + testInfo(c, check.IsNil, "IsNil", []string{"value"}) + + testCheck(c, check.IsNil, true, "", nil) + testCheck(c, check.IsNil, false, "", "a") + + testCheck(c, check.IsNil, true, "", (chan int)(nil)) + testCheck(c, check.IsNil, false, "", make(chan int)) + testCheck(c, check.IsNil, true, "", (error)(nil)) + testCheck(c, check.IsNil, false, "", errors.New("")) + testCheck(c, check.IsNil, true, "", ([]int)(nil)) + testCheck(c, check.IsNil, false, "", make([]int, 1)) + testCheck(c, check.IsNil, false, "", int(0)) +} + +func (s *CheckersS) TestNotNil(c *check.C) { + testInfo(c, check.NotNil, "NotNil", []string{"value"}) + + testCheck(c, check.NotNil, false, "", nil) + testCheck(c, check.NotNil, true, "", "a") + + testCheck(c, check.NotNil, false, "", (chan int)(nil)) + testCheck(c, check.NotNil, true, "", make(chan int)) + testCheck(c, check.NotNil, false, "", (error)(nil)) + testCheck(c, check.NotNil, true, "", errors.New("")) + testCheck(c, check.NotNil, false, "", ([]int)(nil)) + testCheck(c, check.NotNil, true, "", make([]int, 1)) +} + +func (s *CheckersS) TestNot(c *check.C) { + testInfo(c, check.Not(check.IsNil), "Not(IsNil)", []string{"value"}) + + testCheck(c, check.Not(check.IsNil), false, "", nil) + testCheck(c, check.Not(check.IsNil), true, "", "a") +} + +type simpleStruct struct { + i int +} + +func (s *CheckersS) TestEquals(c *check.C) { + testInfo(c, check.Equals, "Equals", []string{"obtained", "expected"}) + + // The simplest. + testCheck(c, check.Equals, true, "", 42, 42) + testCheck(c, check.Equals, false, "", 42, 43) + + // Different native types. + testCheck(c, check.Equals, false, "", int32(42), int64(42)) + + // With nil. + testCheck(c, check.Equals, false, "", 42, nil) + + // Slices + testCheck(c, check.Equals, false, "runtime error: comparing uncomparable type []uint8", []byte{1, 2}, []byte{1, 2}) + + // Struct values + testCheck(c, check.Equals, true, "", simpleStruct{1}, simpleStruct{1}) + testCheck(c, check.Equals, false, "", simpleStruct{1}, simpleStruct{2}) + + // Struct pointers + testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{1}) + testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{2}) +} + +func (s *CheckersS) TestDeepEquals(c *check.C) { + testInfo(c, check.DeepEquals, "DeepEquals", []string{"obtained", "expected"}) + + // The simplest. + testCheck(c, check.DeepEquals, true, "", 42, 42) + testCheck(c, check.DeepEquals, false, "", 42, 43) + + // Different native types. + testCheck(c, check.DeepEquals, false, "", int32(42), int64(42)) + + // With nil. + testCheck(c, check.DeepEquals, false, "", 42, nil) + + // Slices + testCheck(c, check.DeepEquals, true, "", []byte{1, 2}, []byte{1, 2}) + testCheck(c, check.DeepEquals, false, "", []byte{1, 2}, []byte{1, 3}) + + // Struct values + testCheck(c, check.DeepEquals, true, "", simpleStruct{1}, simpleStruct{1}) + testCheck(c, check.DeepEquals, false, "", simpleStruct{1}, simpleStruct{2}) + + // Struct pointers + testCheck(c, check.DeepEquals, true, "", &simpleStruct{1}, &simpleStruct{1}) + testCheck(c, check.DeepEquals, false, "", &simpleStruct{1}, &simpleStruct{2}) +} + +func (s *CheckersS) TestHasLen(c *check.C) { + testInfo(c, check.HasLen, "HasLen", []string{"obtained", "n"}) + + testCheck(c, check.HasLen, true, "", "abcd", 4) + testCheck(c, check.HasLen, true, "", []int{1, 2}, 2) + testCheck(c, check.HasLen, false, "", []int{1, 2}, 3) + + testCheck(c, check.HasLen, false, "n must be an int", []int{1, 2}, "2") + testCheck(c, check.HasLen, false, "obtained value type has no length", nil, 2) +} + +func (s *CheckersS) TestErrorMatches(c *check.C) { + testInfo(c, check.ErrorMatches, "ErrorMatches", []string{"value", "regex"}) + + testCheck(c, check.ErrorMatches, false, "Error value is nil", nil, "some error") + testCheck(c, check.ErrorMatches, false, "Value is not an error", 1, "some error") + testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "some error") + testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "so.*or") + + // Verify params mutation + params, names := testCheck(c, check.ErrorMatches, false, "", errors.New("some error"), "other error") + c.Assert(params[0], check.Equals, "some error") + c.Assert(names[0], check.Equals, "error") +} + +func (s *CheckersS) TestMatches(c *check.C) { + testInfo(c, check.Matches, "Matches", []string{"value", "regex"}) + + // Simple matching + testCheck(c, check.Matches, true, "", "abc", "abc") + testCheck(c, check.Matches, true, "", "abc", "a.c") + + // Must match fully + testCheck(c, check.Matches, false, "", "abc", "ab") + testCheck(c, check.Matches, false, "", "abc", "bc") + + // String()-enabled values accepted + testCheck(c, check.Matches, true, "", reflect.ValueOf("abc"), "a.c") + testCheck(c, check.Matches, false, "", reflect.ValueOf("abc"), "a.d") + + // Some error conditions. + testCheck(c, check.Matches, false, "Obtained value is not a string and has no .String()", 1, "a.c") + testCheck(c, check.Matches, false, "Can't compile regex: error parsing regexp: missing closing ]: `[c$`", "abc", "a[c") +} + +func (s *CheckersS) TestPanics(c *check.C) { + testInfo(c, check.Panics, "Panics", []string{"function", "expected"}) + + // Some errors. + testCheck(c, check.Panics, false, "Function has not panicked", func() bool { return false }, "BOOM") + testCheck(c, check.Panics, false, "Function must take zero arguments", 1, "BOOM") + + // Plain strings. + testCheck(c, check.Panics, true, "", func() { panic("BOOM") }, "BOOM") + testCheck(c, check.Panics, false, "", func() { panic("KABOOM") }, "BOOM") + testCheck(c, check.Panics, true, "", func() bool { panic("BOOM") }, "BOOM") + + // Error values. + testCheck(c, check.Panics, true, "", func() { panic(errors.New("BOOM")) }, errors.New("BOOM")) + testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM")) + + type deep struct{ i int } + // Deep value + testCheck(c, check.Panics, true, "", func() { panic(&deep{99}) }, &deep{99}) + + // Verify params/names mutation + params, names := testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM")) + c.Assert(params[0], check.ErrorMatches, "KABOOM") + c.Assert(names[0], check.Equals, "panic") + + // Verify a nil panic + testCheck(c, check.Panics, true, "", func() { panic(nil) }, nil) + testCheck(c, check.Panics, false, "", func() { panic(nil) }, "NOPE") +} + +func (s *CheckersS) TestPanicMatches(c *check.C) { + testInfo(c, check.PanicMatches, "PanicMatches", []string{"function", "expected"}) + + // Error matching. + testCheck(c, check.PanicMatches, true, "", func() { panic(errors.New("BOOM")) }, "BO.M") + testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BO.M") + + // Some errors. + testCheck(c, check.PanicMatches, false, "Function has not panicked", func() bool { return false }, "BOOM") + testCheck(c, check.PanicMatches, false, "Function must take zero arguments", 1, "BOOM") + + // Plain strings. + testCheck(c, check.PanicMatches, true, "", func() { panic("BOOM") }, "BO.M") + testCheck(c, check.PanicMatches, false, "", func() { panic("KABOOM") }, "BOOM") + testCheck(c, check.PanicMatches, true, "", func() bool { panic("BOOM") }, "BO.M") + + // Verify params/names mutation + params, names := testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BOOM") + c.Assert(params[0], check.Equals, "KABOOM") + c.Assert(names[0], check.Equals, "panic") + + // Verify a nil panic + testCheck(c, check.PanicMatches, false, "Panic value is not a string or an error", func() { panic(nil) }, "") +} + +func (s *CheckersS) TestFitsTypeOf(c *check.C) { + testInfo(c, check.FitsTypeOf, "FitsTypeOf", []string{"obtained", "sample"}) + + // Basic types + testCheck(c, check.FitsTypeOf, true, "", 1, 0) + testCheck(c, check.FitsTypeOf, false, "", 1, int64(0)) + + // Aliases + testCheck(c, check.FitsTypeOf, false, "", 1, errors.New("")) + testCheck(c, check.FitsTypeOf, false, "", "error", errors.New("")) + testCheck(c, check.FitsTypeOf, true, "", errors.New("error"), errors.New("")) + + // Structures + testCheck(c, check.FitsTypeOf, false, "", 1, simpleStruct{}) + testCheck(c, check.FitsTypeOf, false, "", simpleStruct{42}, &simpleStruct{}) + testCheck(c, check.FitsTypeOf, true, "", simpleStruct{42}, simpleStruct{}) + testCheck(c, check.FitsTypeOf, true, "", &simpleStruct{42}, &simpleStruct{}) + + // Some bad values + testCheck(c, check.FitsTypeOf, false, "Invalid sample value", 1, interface{}(nil)) + testCheck(c, check.FitsTypeOf, false, "", interface{}(nil), 0) +} + +func (s *CheckersS) TestImplements(c *check.C) { + testInfo(c, check.Implements, "Implements", []string{"obtained", "ifaceptr"}) + + var e error + var re runtime.Error + testCheck(c, check.Implements, true, "", errors.New(""), &e) + testCheck(c, check.Implements, false, "", errors.New(""), &re) + + // Some bad values + testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, errors.New("")) + testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, interface{}(nil)) + testCheck(c, check.Implements, false, "", interface{}(nil), &e) +} diff --git a/vendor/gopkg.in/check.v1/export_test.go b/vendor/gopkg.in/check.v1/export_test.go new file mode 100644 index 00000000..abb89a2d --- /dev/null +++ b/vendor/gopkg.in/check.v1/export_test.go @@ -0,0 +1,19 @@ +package check + +import "io" + +func PrintLine(filename string, line int) (string, error) { + return printLine(filename, line) +} + +func Indent(s, with string) string { + return indent(s, with) +} + +func NewOutputWriter(writer io.Writer, stream, verbose bool) *outputWriter { + return newOutputWriter(writer, stream, verbose) +} + +func (c *C) FakeSkip(reason string) { + c.reason = reason +} diff --git a/vendor/gopkg.in/check.v1/fixture_test.go b/vendor/gopkg.in/check.v1/fixture_test.go new file mode 100644 index 00000000..2bff9e16 --- /dev/null +++ b/vendor/gopkg.in/check.v1/fixture_test.go @@ -0,0 +1,484 @@ +// Tests for the behavior of the test fixture system. + +package check_test + +import ( + . "gopkg.in/check.v1" +) + +// ----------------------------------------------------------------------- +// Fixture test suite. + +type FixtureS struct{} + +var fixtureS = Suite(&FixtureS{}) + +func (s *FixtureS) TestCountSuite(c *C) { + suitesRun += 1 +} + +// ----------------------------------------------------------------------- +// Basic fixture ordering verification. + +func (s *FixtureS) TestOrder(c *C) { + helper := FixtureHelper{} + Run(&helper, nil) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "SetUpTest") + c.Check(helper.calls[5], Equals, "Test2") + c.Check(helper.calls[6], Equals, "TearDownTest") + c.Check(helper.calls[7], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 8) +} + +// ----------------------------------------------------------------------- +// Check the behavior when panics occur within tests and fixtures. + +func (s *FixtureS) TestPanicOnTest(c *C) { + helper := FixtureHelper{panicOn: "Test1"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "SetUpTest") + c.Check(helper.calls[5], Equals, "Test2") + c.Check(helper.calls[6], Equals, "TearDownTest") + c.Check(helper.calls[7], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 8) + + expected := "^\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: FixtureHelper.Test1\n\n" + + "\\.\\.\\. Panic: Test1 \\(PC=[xA-F0-9]+\\)\n\n" + + ".+:[0-9]+\n" + + " in (go)?panic\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.trace\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.Test1\n" + + "(.|\n)*$" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnSetUpTest(c *C) { + helper := FixtureHelper{panicOn: "SetUpTest"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "TearDownTest") + c.Check(helper.calls[3], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 4) + + expected := "^\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: " + + "FixtureHelper\\.SetUpTest\n\n" + + "\\.\\.\\. Panic: SetUpTest \\(PC=[xA-F0-9]+\\)\n\n" + + ".+:[0-9]+\n" + + " in (go)?panic\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.trace\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.SetUpTest\n" + + "(.|\n)*" + + "\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: " + + "FixtureHelper\\.Test1\n\n" + + "\\.\\.\\. Panic: Fixture has panicked " + + "\\(see related PANIC\\)\n$" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnTearDownTest(c *C) { + helper := FixtureHelper{panicOn: "TearDownTest"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 5) + + expected := "^\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: " + + "FixtureHelper.TearDownTest\n\n" + + "\\.\\.\\. Panic: TearDownTest \\(PC=[xA-F0-9]+\\)\n\n" + + ".+:[0-9]+\n" + + " in (go)?panic\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.trace\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.TearDownTest\n" + + "(.|\n)*" + + "\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: " + + "FixtureHelper\\.Test1\n\n" + + "\\.\\.\\. Panic: Fixture has panicked " + + "\\(see related PANIC\\)\n$" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnSetUpSuite(c *C) { + helper := FixtureHelper{panicOn: "SetUpSuite"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 2) + + expected := "^\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: " + + "FixtureHelper.SetUpSuite\n\n" + + "\\.\\.\\. Panic: SetUpSuite \\(PC=[xA-F0-9]+\\)\n\n" + + ".+:[0-9]+\n" + + " in (go)?panic\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.trace\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.SetUpSuite\n" + + "(.|\n)*$" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnTearDownSuite(c *C) { + helper := FixtureHelper{panicOn: "TearDownSuite"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "SetUpTest") + c.Check(helper.calls[5], Equals, "Test2") + c.Check(helper.calls[6], Equals, "TearDownTest") + c.Check(helper.calls[7], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 8) + + expected := "^\n-+\n" + + "PANIC: check_test\\.go:[0-9]+: " + + "FixtureHelper.TearDownSuite\n\n" + + "\\.\\.\\. Panic: TearDownSuite \\(PC=[xA-F0-9]+\\)\n\n" + + ".+:[0-9]+\n" + + " in (go)?panic\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.trace\n" + + ".*check_test.go:[0-9]+\n" + + " in FixtureHelper.TearDownSuite\n" + + "(.|\n)*$" + + c.Check(output.value, Matches, expected) +} + +// ----------------------------------------------------------------------- +// A wrong argument on a test or fixture will produce a nice error. + +func (s *FixtureS) TestPanicOnWrongTestArg(c *C) { + helper := WrongTestArgHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "TearDownTest") + c.Check(helper.calls[3], Equals, "SetUpTest") + c.Check(helper.calls[4], Equals, "Test2") + c.Check(helper.calls[5], Equals, "TearDownTest") + c.Check(helper.calls[6], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 7) + + expected := "^\n-+\n" + + "PANIC: fixture_test\\.go:[0-9]+: " + + "WrongTestArgHelper\\.Test1\n\n" + + "\\.\\.\\. Panic: WrongTestArgHelper\\.Test1 argument " + + "should be \\*check\\.C\n" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnWrongSetUpTestArg(c *C) { + helper := WrongSetUpTestArgHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(len(helper.calls), Equals, 0) + + expected := + "^\n-+\n" + + "PANIC: fixture_test\\.go:[0-9]+: " + + "WrongSetUpTestArgHelper\\.SetUpTest\n\n" + + "\\.\\.\\. Panic: WrongSetUpTestArgHelper\\.SetUpTest argument " + + "should be \\*check\\.C\n" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnWrongSetUpSuiteArg(c *C) { + helper := WrongSetUpSuiteArgHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(len(helper.calls), Equals, 0) + + expected := + "^\n-+\n" + + "PANIC: fixture_test\\.go:[0-9]+: " + + "WrongSetUpSuiteArgHelper\\.SetUpSuite\n\n" + + "\\.\\.\\. Panic: WrongSetUpSuiteArgHelper\\.SetUpSuite argument " + + "should be \\*check\\.C\n" + + c.Check(output.value, Matches, expected) +} + +// ----------------------------------------------------------------------- +// Nice errors also when tests or fixture have wrong arg count. + +func (s *FixtureS) TestPanicOnWrongTestArgCount(c *C) { + helper := WrongTestArgCountHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "TearDownTest") + c.Check(helper.calls[3], Equals, "SetUpTest") + c.Check(helper.calls[4], Equals, "Test2") + c.Check(helper.calls[5], Equals, "TearDownTest") + c.Check(helper.calls[6], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 7) + + expected := "^\n-+\n" + + "PANIC: fixture_test\\.go:[0-9]+: " + + "WrongTestArgCountHelper\\.Test1\n\n" + + "\\.\\.\\. Panic: WrongTestArgCountHelper\\.Test1 argument " + + "should be \\*check\\.C\n" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnWrongSetUpTestArgCount(c *C) { + helper := WrongSetUpTestArgCountHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(len(helper.calls), Equals, 0) + + expected := + "^\n-+\n" + + "PANIC: fixture_test\\.go:[0-9]+: " + + "WrongSetUpTestArgCountHelper\\.SetUpTest\n\n" + + "\\.\\.\\. Panic: WrongSetUpTestArgCountHelper\\.SetUpTest argument " + + "should be \\*check\\.C\n" + + c.Check(output.value, Matches, expected) +} + +func (s *FixtureS) TestPanicOnWrongSetUpSuiteArgCount(c *C) { + helper := WrongSetUpSuiteArgCountHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(len(helper.calls), Equals, 0) + + expected := + "^\n-+\n" + + "PANIC: fixture_test\\.go:[0-9]+: " + + "WrongSetUpSuiteArgCountHelper\\.SetUpSuite\n\n" + + "\\.\\.\\. Panic: WrongSetUpSuiteArgCountHelper" + + "\\.SetUpSuite argument should be \\*check\\.C\n" + + c.Check(output.value, Matches, expected) +} + +// ----------------------------------------------------------------------- +// Helper test suites with wrong function arguments. + +type WrongTestArgHelper struct { + FixtureHelper +} + +func (s *WrongTestArgHelper) Test1(t int) { +} + +type WrongSetUpTestArgHelper struct { + FixtureHelper +} + +func (s *WrongSetUpTestArgHelper) SetUpTest(t int) { +} + +type WrongSetUpSuiteArgHelper struct { + FixtureHelper +} + +func (s *WrongSetUpSuiteArgHelper) SetUpSuite(t int) { +} + +type WrongTestArgCountHelper struct { + FixtureHelper +} + +func (s *WrongTestArgCountHelper) Test1(c *C, i int) { +} + +type WrongSetUpTestArgCountHelper struct { + FixtureHelper +} + +func (s *WrongSetUpTestArgCountHelper) SetUpTest(c *C, i int) { +} + +type WrongSetUpSuiteArgCountHelper struct { + FixtureHelper +} + +func (s *WrongSetUpSuiteArgCountHelper) SetUpSuite(c *C, i int) { +} + +// ----------------------------------------------------------------------- +// Ensure fixture doesn't run without tests. + +type NoTestsHelper struct { + hasRun bool +} + +func (s *NoTestsHelper) SetUpSuite(c *C) { + s.hasRun = true +} + +func (s *NoTestsHelper) TearDownSuite(c *C) { + s.hasRun = true +} + +func (s *FixtureS) TestFixtureDoesntRunWithoutTests(c *C) { + helper := NoTestsHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Check(helper.hasRun, Equals, false) +} + +// ----------------------------------------------------------------------- +// Verify that checks and assertions work correctly inside the fixture. + +type FixtureCheckHelper struct { + fail string + completed bool +} + +func (s *FixtureCheckHelper) SetUpSuite(c *C) { + switch s.fail { + case "SetUpSuiteAssert": + c.Assert(false, Equals, true) + case "SetUpSuiteCheck": + c.Check(false, Equals, true) + } + s.completed = true +} + +func (s *FixtureCheckHelper) SetUpTest(c *C) { + switch s.fail { + case "SetUpTestAssert": + c.Assert(false, Equals, true) + case "SetUpTestCheck": + c.Check(false, Equals, true) + } + s.completed = true +} + +func (s *FixtureCheckHelper) Test(c *C) { + // Do nothing. +} + +func (s *FixtureS) TestSetUpSuiteCheck(c *C) { + helper := FixtureCheckHelper{fail: "SetUpSuiteCheck"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Assert(output.value, Matches, + "\n---+\n"+ + "FAIL: fixture_test\\.go:[0-9]+: "+ + "FixtureCheckHelper\\.SetUpSuite\n\n"+ + "fixture_test\\.go:[0-9]+:\n"+ + " c\\.Check\\(false, Equals, true\\)\n"+ + "\\.+ obtained bool = false\n"+ + "\\.+ expected bool = true\n\n") + c.Assert(helper.completed, Equals, true) +} + +func (s *FixtureS) TestSetUpSuiteAssert(c *C) { + helper := FixtureCheckHelper{fail: "SetUpSuiteAssert"} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Assert(output.value, Matches, + "\n---+\n"+ + "FAIL: fixture_test\\.go:[0-9]+: "+ + "FixtureCheckHelper\\.SetUpSuite\n\n"+ + "fixture_test\\.go:[0-9]+:\n"+ + " c\\.Assert\\(false, Equals, true\\)\n"+ + "\\.+ obtained bool = false\n"+ + "\\.+ expected bool = true\n\n") + c.Assert(helper.completed, Equals, false) +} + +// ----------------------------------------------------------------------- +// Verify that logging within SetUpTest() persists within the test log itself. + +type FixtureLogHelper struct { + c *C +} + +func (s *FixtureLogHelper) SetUpTest(c *C) { + s.c = c + c.Log("1") +} + +func (s *FixtureLogHelper) Test(c *C) { + c.Log("2") + s.c.Log("3") + c.Log("4") + c.Fail() +} + +func (s *FixtureLogHelper) TearDownTest(c *C) { + s.c.Log("5") +} + +func (s *FixtureS) TestFixtureLogging(c *C) { + helper := FixtureLogHelper{} + output := String{} + Run(&helper, &RunConf{Output: &output}) + c.Assert(output.value, Matches, + "\n---+\n"+ + "FAIL: fixture_test\\.go:[0-9]+: "+ + "FixtureLogHelper\\.Test\n\n"+ + "1\n2\n3\n4\n5\n") +} + +// ----------------------------------------------------------------------- +// Skip() within fixture methods. + +func (s *FixtureS) TestSkipSuite(c *C) { + helper := FixtureHelper{skip: true, skipOnN: 0} + output := String{} + result := Run(&helper, &RunConf{Output: &output}) + c.Assert(output.value, Equals, "") + c.Assert(helper.calls[0], Equals, "SetUpSuite") + c.Assert(helper.calls[1], Equals, "TearDownSuite") + c.Assert(len(helper.calls), Equals, 2) + c.Assert(result.Skipped, Equals, 2) +} + +func (s *FixtureS) TestSkipTest(c *C) { + helper := FixtureHelper{skip: true, skipOnN: 1} + output := String{} + result := Run(&helper, &RunConf{Output: &output}) + c.Assert(helper.calls[0], Equals, "SetUpSuite") + c.Assert(helper.calls[1], Equals, "SetUpTest") + c.Assert(helper.calls[2], Equals, "SetUpTest") + c.Assert(helper.calls[3], Equals, "Test2") + c.Assert(helper.calls[4], Equals, "TearDownTest") + c.Assert(helper.calls[5], Equals, "TearDownSuite") + c.Assert(len(helper.calls), Equals, 6) + c.Assert(result.Skipped, Equals, 1) +} diff --git a/vendor/gopkg.in/check.v1/foundation_test.go b/vendor/gopkg.in/check.v1/foundation_test.go new file mode 100644 index 00000000..8ecf7915 --- /dev/null +++ b/vendor/gopkg.in/check.v1/foundation_test.go @@ -0,0 +1,335 @@ +// These tests check that the foundations of gocheck are working properly. +// They already assume that fundamental failing is working already, though, +// since this was tested in bootstrap_test.go. Even then, some care may +// still have to be taken when using external functions, since they should +// of course not rely on functionality tested here. + +package check_test + +import ( + "fmt" + "gopkg.in/check.v1" + "log" + "os" + "regexp" + "strings" +) + +// ----------------------------------------------------------------------- +// Foundation test suite. + +type FoundationS struct{} + +var foundationS = check.Suite(&FoundationS{}) + +func (s *FoundationS) TestCountSuite(c *check.C) { + suitesRun += 1 +} + +func (s *FoundationS) TestErrorf(c *check.C) { + // Do not use checkState() here. It depends on Errorf() working. + expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+ + " c.Errorf(\"Error %%v!\", \"message\")\n"+ + "... Error: Error message!\n\n", + getMyLine()+1) + c.Errorf("Error %v!", "message") + failed := c.Failed() + c.Succeed() + if log := c.GetTestLog(); log != expectedLog { + c.Logf("Errorf() logged %#v rather than %#v", log, expectedLog) + c.Fail() + } + if !failed { + c.Logf("Errorf() didn't put the test in a failed state") + c.Fail() + } +} + +func (s *FoundationS) TestError(c *check.C) { + expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+ + " c\\.Error\\(\"Error \", \"message!\"\\)\n"+ + "\\.\\.\\. Error: Error message!\n\n", + getMyLine()+1) + c.Error("Error ", "message!") + checkState(c, nil, + &expectedState{ + name: "Error(`Error `, `message!`)", + failed: true, + log: expectedLog, + }) +} + +func (s *FoundationS) TestFailNow(c *check.C) { + defer (func() { + if !c.Failed() { + c.Error("FailNow() didn't fail the test") + } else { + c.Succeed() + if c.GetTestLog() != "" { + c.Error("Something got logged:\n" + c.GetTestLog()) + } + } + })() + + c.FailNow() + c.Log("FailNow() didn't stop the test") +} + +func (s *FoundationS) TestSucceedNow(c *check.C) { + defer (func() { + if c.Failed() { + c.Error("SucceedNow() didn't succeed the test") + } + if c.GetTestLog() != "" { + c.Error("Something got logged:\n" + c.GetTestLog()) + } + })() + + c.Fail() + c.SucceedNow() + c.Log("SucceedNow() didn't stop the test") +} + +func (s *FoundationS) TestFailureHeader(c *check.C) { + output := String{} + failHelper := FailHelper{} + check.Run(&failHelper, &check.RunConf{Output: &output}) + header := fmt.Sprintf(""+ + "\n-----------------------------------"+ + "-----------------------------------\n"+ + "FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n", + failHelper.testLine) + if strings.Index(output.value, header) == -1 { + c.Errorf(""+ + "Failure didn't print a proper header.\n"+ + "... Got:\n%s... Expected something with:\n%s", + output.value, header) + } +} + +func (s *FoundationS) TestFatal(c *check.C) { + var line int + defer (func() { + if !c.Failed() { + c.Error("Fatal() didn't fail the test") + } else { + c.Succeed() + expected := fmt.Sprintf("foundation_test.go:%d:\n"+ + " c.Fatal(\"Die \", \"now!\")\n"+ + "... Error: Die now!\n\n", + line) + if c.GetTestLog() != expected { + c.Error("Incorrect log:", c.GetTestLog()) + } + } + })() + + line = getMyLine() + 1 + c.Fatal("Die ", "now!") + c.Log("Fatal() didn't stop the test") +} + +func (s *FoundationS) TestFatalf(c *check.C) { + var line int + defer (func() { + if !c.Failed() { + c.Error("Fatalf() didn't fail the test") + } else { + c.Succeed() + expected := fmt.Sprintf("foundation_test.go:%d:\n"+ + " c.Fatalf(\"Die %%s!\", \"now\")\n"+ + "... Error: Die now!\n\n", + line) + if c.GetTestLog() != expected { + c.Error("Incorrect log:", c.GetTestLog()) + } + } + })() + + line = getMyLine() + 1 + c.Fatalf("Die %s!", "now") + c.Log("Fatalf() didn't stop the test") +} + +func (s *FoundationS) TestCallerLoggingInsideTest(c *check.C) { + log := fmt.Sprintf(""+ + "foundation_test.go:%d:\n"+ + " result := c.Check\\(10, check.Equals, 20\\)\n"+ + "\\.\\.\\. obtained int = 10\n"+ + "\\.\\.\\. expected int = 20\n\n", + getMyLine()+1) + result := c.Check(10, check.Equals, 20) + checkState(c, result, + &expectedState{ + name: "Check(10, Equals, 20)", + result: false, + failed: true, + log: log, + }) +} + +func (s *FoundationS) TestCallerLoggingInDifferentFile(c *check.C) { + result, line := checkEqualWrapper(c, 10, 20) + testLine := getMyLine() - 1 + log := fmt.Sprintf(""+ + "foundation_test.go:%d:\n"+ + " result, line := checkEqualWrapper\\(c, 10, 20\\)\n"+ + "check_test.go:%d:\n"+ + " return c.Check\\(obtained, check.Equals, expected\\), getMyLine\\(\\)\n"+ + "\\.\\.\\. obtained int = 10\n"+ + "\\.\\.\\. expected int = 20\n\n", + testLine, line) + checkState(c, result, + &expectedState{ + name: "Check(10, Equals, 20)", + result: false, + failed: true, + log: log, + }) +} + +// ----------------------------------------------------------------------- +// ExpectFailure() inverts the logic of failure. + +type ExpectFailureSucceedHelper struct{} + +func (s *ExpectFailureSucceedHelper) TestSucceed(c *check.C) { + c.ExpectFailure("It booms!") + c.Error("Boom!") +} + +type ExpectFailureFailHelper struct{} + +func (s *ExpectFailureFailHelper) TestFail(c *check.C) { + c.ExpectFailure("Bug #XYZ") +} + +func (s *FoundationS) TestExpectFailureFail(c *check.C) { + helper := ExpectFailureFailHelper{} + output := String{} + result := check.Run(&helper, &check.RunConf{Output: &output}) + + expected := "" + + "^\n-+\n" + + "FAIL: foundation_test\\.go:[0-9]+:" + + " ExpectFailureFailHelper\\.TestFail\n\n" + + "\\.\\.\\. Error: Test succeeded, but was expected to fail\n" + + "\\.\\.\\. Reason: Bug #XYZ\n$" + + matched, err := regexp.MatchString(expected, output.value) + if err != nil { + c.Error("Bad expression: ", expected) + } else if !matched { + c.Error("ExpectFailure() didn't log properly:\n", output.value) + } + + c.Assert(result.ExpectedFailures, check.Equals, 0) +} + +func (s *FoundationS) TestExpectFailureSucceed(c *check.C) { + helper := ExpectFailureSucceedHelper{} + output := String{} + result := check.Run(&helper, &check.RunConf{Output: &output}) + + c.Assert(output.value, check.Equals, "") + c.Assert(result.ExpectedFailures, check.Equals, 1) +} + +func (s *FoundationS) TestExpectFailureSucceedVerbose(c *check.C) { + helper := ExpectFailureSucceedHelper{} + output := String{} + result := check.Run(&helper, &check.RunConf{Output: &output, Verbose: true}) + + expected := "" + + "FAIL EXPECTED: foundation_test\\.go:[0-9]+:" + + " ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n" + + matched, err := regexp.MatchString(expected, output.value) + if err != nil { + c.Error("Bad expression: ", expected) + } else if !matched { + c.Error("ExpectFailure() didn't log properly:\n", output.value) + } + + c.Assert(result.ExpectedFailures, check.Equals, 1) +} + +// ----------------------------------------------------------------------- +// Skip() allows stopping a test without positive/negative results. + +type SkipTestHelper struct{} + +func (s *SkipTestHelper) TestFail(c *check.C) { + c.Skip("Wrong platform or whatever") + c.Error("Boom!") +} + +func (s *FoundationS) TestSkip(c *check.C) { + helper := SkipTestHelper{} + output := String{} + check.Run(&helper, &check.RunConf{Output: &output}) + + if output.value != "" { + c.Error("Skip() logged something:\n", output.value) + } +} + +func (s *FoundationS) TestSkipVerbose(c *check.C) { + helper := SkipTestHelper{} + output := String{} + check.Run(&helper, &check.RunConf{Output: &output, Verbose: true}) + + expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" + + " \\(Wrong platform or whatever\\)" + matched, err := regexp.MatchString(expected, output.value) + if err != nil { + c.Error("Bad expression: ", expected) + } else if !matched { + c.Error("Skip() didn't log properly:\n", output.value) + } +} + +// ----------------------------------------------------------------------- +// Check minimum *log.Logger interface provided by *check.C. + +type minLogger interface { + Output(calldepth int, s string) error +} + +func (s *BootstrapS) TestMinLogger(c *check.C) { + var logger minLogger + logger = log.New(os.Stderr, "", 0) + logger = c + logger.Output(0, "Hello there") + expected := `\[LOG\] [0-9]+:[0-9][0-9]\.[0-9][0-9][0-9] +Hello there\n` + output := c.GetTestLog() + c.Assert(output, check.Matches, expected) +} + +// ----------------------------------------------------------------------- +// Ensure that suites with embedded types are working fine, including the +// the workaround for issue 906. + +type EmbeddedInternalS struct { + called bool +} + +type EmbeddedS struct { + EmbeddedInternalS +} + +var embeddedS = check.Suite(&EmbeddedS{}) + +func (s *EmbeddedS) TestCountSuite(c *check.C) { + suitesRun += 1 +} + +func (s *EmbeddedInternalS) TestMethod(c *check.C) { + c.Error("TestMethod() of the embedded type was called!?") +} + +func (s *EmbeddedS) TestMethod(c *check.C) { + // http://code.google.com/p/go/issues/detail?id=906 + c.Check(s.called, check.Equals, false) // Go issue 906 is affecting the runner? + s.called = true +} diff --git a/vendor/gopkg.in/check.v1/helpers.go b/vendor/gopkg.in/check.v1/helpers.go new file mode 100644 index 00000000..58a733b5 --- /dev/null +++ b/vendor/gopkg.in/check.v1/helpers.go @@ -0,0 +1,231 @@ +package check + +import ( + "fmt" + "strings" + "time" +) + +// TestName returns the current test name in the form "SuiteName.TestName" +func (c *C) TestName() string { + return c.testName +} + +// ----------------------------------------------------------------------- +// Basic succeeding/failing logic. + +// Failed returns whether the currently running test has already failed. +func (c *C) Failed() bool { + return c.status() == failedSt +} + +// Fail marks the currently running test as failed. +// +// Something ought to have been previously logged so the developer can tell +// what went wrong. The higher level helper functions will fail the test +// and do the logging properly. +func (c *C) Fail() { + c.setStatus(failedSt) +} + +// FailNow marks the currently running test as failed and stops running it. +// Something ought to have been previously logged so the developer can tell +// what went wrong. The higher level helper functions will fail the test +// and do the logging properly. +func (c *C) FailNow() { + c.Fail() + c.stopNow() +} + +// Succeed marks the currently running test as succeeded, undoing any +// previous failures. +func (c *C) Succeed() { + c.setStatus(succeededSt) +} + +// SucceedNow marks the currently running test as succeeded, undoing any +// previous failures, and stops running the test. +func (c *C) SucceedNow() { + c.Succeed() + c.stopNow() +} + +// ExpectFailure informs that the running test is knowingly broken for +// the provided reason. If the test does not fail, an error will be reported +// to raise attention to this fact. This method is useful to temporarily +// disable tests which cover well known problems until a better time to +// fix the problem is found, without forgetting about the fact that a +// failure still exists. +func (c *C) ExpectFailure(reason string) { + if reason == "" { + panic("Missing reason why the test is expected to fail") + } + c.mustFail = true + c.reason = reason +} + +// Skip skips the running test for the provided reason. If run from within +// SetUpTest, the individual test being set up will be skipped, and if run +// from within SetUpSuite, the whole suite is skipped. +func (c *C) Skip(reason string) { + if reason == "" { + panic("Missing reason why the test is being skipped") + } + c.reason = reason + c.setStatus(skippedSt) + c.stopNow() +} + +// ----------------------------------------------------------------------- +// Basic logging. + +// GetTestLog returns the current test error output. +func (c *C) GetTestLog() string { + return c.logb.String() +} + +// Log logs some information into the test error output. +// The provided arguments are assembled together into a string with fmt.Sprint. +func (c *C) Log(args ...interface{}) { + c.log(args...) +} + +// Log logs some information into the test error output. +// The provided arguments are assembled together into a string with fmt.Sprintf. +func (c *C) Logf(format string, args ...interface{}) { + c.logf(format, args...) +} + +// Output enables *C to be used as a logger in functions that require only +// the minimum interface of *log.Logger. +func (c *C) Output(calldepth int, s string) error { + d := time.Now().Sub(c.startTime) + msec := d / time.Millisecond + sec := d / time.Second + min := d / time.Minute + + c.Logf("[LOG] %d:%02d.%03d %s", min, sec%60, msec%1000, s) + return nil +} + +// Error logs an error into the test error output and marks the test as failed. +// The provided arguments are assembled together into a string with fmt.Sprint. +func (c *C) Error(args ...interface{}) { + c.logCaller(1) + c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...))) + c.logNewLine() + c.Fail() +} + +// Errorf logs an error into the test error output and marks the test as failed. +// The provided arguments are assembled together into a string with fmt.Sprintf. +func (c *C) Errorf(format string, args ...interface{}) { + c.logCaller(1) + c.logString(fmt.Sprintf("Error: "+format, args...)) + c.logNewLine() + c.Fail() +} + +// Fatal logs an error into the test error output, marks the test as failed, and +// stops the test execution. The provided arguments are assembled together into +// a string with fmt.Sprint. +func (c *C) Fatal(args ...interface{}) { + c.logCaller(1) + c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...))) + c.logNewLine() + c.FailNow() +} + +// Fatlaf logs an error into the test error output, marks the test as failed, and +// stops the test execution. The provided arguments are assembled together into +// a string with fmt.Sprintf. +func (c *C) Fatalf(format string, args ...interface{}) { + c.logCaller(1) + c.logString(fmt.Sprint("Error: ", fmt.Sprintf(format, args...))) + c.logNewLine() + c.FailNow() +} + +// ----------------------------------------------------------------------- +// Generic checks and assertions based on checkers. + +// Check verifies if the first value matches the expected value according +// to the provided checker. If they do not match, an error is logged, the +// test is marked as failed, and the test execution continues. +// +// Some checkers may not need the expected argument (e.g. IsNil). +// +// Extra arguments provided to the function are logged next to the reported +// problem when the matching fails. +func (c *C) Check(obtained interface{}, checker Checker, args ...interface{}) bool { + return c.internalCheck("Check", obtained, checker, args...) +} + +// Assert ensures that the first value matches the expected value according +// to the provided checker. If they do not match, an error is logged, the +// test is marked as failed, and the test execution stops. +// +// Some checkers may not need the expected argument (e.g. IsNil). +// +// Extra arguments provided to the function are logged next to the reported +// problem when the matching fails. +func (c *C) Assert(obtained interface{}, checker Checker, args ...interface{}) { + if !c.internalCheck("Assert", obtained, checker, args...) { + c.stopNow() + } +} + +func (c *C) internalCheck(funcName string, obtained interface{}, checker Checker, args ...interface{}) bool { + if checker == nil { + c.logCaller(2) + c.logString(fmt.Sprintf("%s(obtained, nil!?, ...):", funcName)) + c.logString("Oops.. you've provided a nil checker!") + c.logNewLine() + c.Fail() + return false + } + + // If the last argument is a bug info, extract it out. + var comment CommentInterface + if len(args) > 0 { + if c, ok := args[len(args)-1].(CommentInterface); ok { + comment = c + args = args[:len(args)-1] + } + } + + params := append([]interface{}{obtained}, args...) + info := checker.Info() + + if len(params) != len(info.Params) { + names := append([]string{info.Params[0], info.Name}, info.Params[1:]...) + c.logCaller(2) + c.logString(fmt.Sprintf("%s(%s):", funcName, strings.Join(names, ", "))) + c.logString(fmt.Sprintf("Wrong number of parameters for %s: want %d, got %d", info.Name, len(names), len(params)+1)) + c.logNewLine() + c.Fail() + return false + } + + // Copy since it may be mutated by Check. + names := append([]string{}, info.Params...) + + // Do the actual check. + result, error := checker.Check(params, names) + if !result || error != "" { + c.logCaller(2) + for i := 0; i != len(params); i++ { + c.logValue(names[i], params[i]) + } + if comment != nil { + c.logString(comment.CheckCommentString()) + } + if error != "" { + c.logString(error) + } + c.logNewLine() + c.Fail() + return false + } + return true +} diff --git a/vendor/gopkg.in/check.v1/helpers_test.go b/vendor/gopkg.in/check.v1/helpers_test.go new file mode 100644 index 00000000..4baa656b --- /dev/null +++ b/vendor/gopkg.in/check.v1/helpers_test.go @@ -0,0 +1,519 @@ +// These tests verify the inner workings of the helper methods associated +// with check.T. + +package check_test + +import ( + "gopkg.in/check.v1" + "os" + "reflect" + "runtime" + "sync" +) + +var helpersS = check.Suite(&HelpersS{}) + +type HelpersS struct{} + +func (s *HelpersS) TestCountSuite(c *check.C) { + suitesRun += 1 +} + +// ----------------------------------------------------------------------- +// Fake checker and bug info to verify the behavior of Assert() and Check(). + +type MyChecker struct { + info *check.CheckerInfo + params []interface{} + names []string + result bool + error string +} + +func (checker *MyChecker) Info() *check.CheckerInfo { + if checker.info == nil { + return &check.CheckerInfo{Name: "MyChecker", Params: []string{"myobtained", "myexpected"}} + } + return checker.info +} + +func (checker *MyChecker) Check(params []interface{}, names []string) (bool, string) { + rparams := checker.params + rnames := checker.names + checker.params = append([]interface{}{}, params...) + checker.names = append([]string{}, names...) + if rparams != nil { + copy(params, rparams) + } + if rnames != nil { + copy(names, rnames) + } + return checker.result, checker.error +} + +type myCommentType string + +func (c myCommentType) CheckCommentString() string { + return string(c) +} + +func myComment(s string) myCommentType { + return myCommentType(s) +} + +// ----------------------------------------------------------------------- +// Ensure a real checker actually works fine. + +func (s *HelpersS) TestCheckerInterface(c *check.C) { + testHelperSuccess(c, "Check(1, Equals, 1)", true, func() interface{} { + return c.Check(1, check.Equals, 1) + }) +} + +// ----------------------------------------------------------------------- +// Tests for Check(), mostly the same as for Assert() following these. + +func (s *HelpersS) TestCheckSucceedWithExpected(c *check.C) { + checker := &MyChecker{result: true} + testHelperSuccess(c, "Check(1, checker, 2)", true, func() interface{} { + return c.Check(1, checker, 2) + }) + if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) { + c.Fatalf("Bad params for check: %#v", checker.params) + } +} + +func (s *HelpersS) TestCheckSucceedWithoutExpected(c *check.C) { + checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}} + testHelperSuccess(c, "Check(1, checker)", true, func() interface{} { + return c.Check(1, checker) + }) + if !reflect.DeepEqual(checker.params, []interface{}{1}) { + c.Fatalf("Bad params for check: %#v", checker.params) + } +} + +func (s *HelpersS) TestCheckFailWithExpected(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker, 2\\)\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n\n" + testHelperFailure(c, "Check(1, checker, 2)", false, false, log, + func() interface{} { + return c.Check(1, checker, 2) + }) +} + +func (s *HelpersS) TestCheckFailWithExpectedAndComment(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n" + + "\\.+ Hello world!\n\n" + testHelperFailure(c, "Check(1, checker, 2, msg)", false, false, log, + func() interface{} { + return c.Check(1, checker, 2, myComment("Hello world!")) + }) +} + +func (s *HelpersS) TestCheckFailWithExpectedAndStaticComment(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " // Nice leading comment\\.\n" + + " return c\\.Check\\(1, checker, 2\\) // Hello there\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n\n" + testHelperFailure(c, "Check(1, checker, 2, msg)", false, false, log, + func() interface{} { + // Nice leading comment. + return c.Check(1, checker, 2) // Hello there + }) +} + +func (s *HelpersS) TestCheckFailWithoutExpected(c *check.C) { + checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker\\)\n" + + "\\.+ myvalue int = 1\n\n" + testHelperFailure(c, "Check(1, checker)", false, false, log, + func() interface{} { + return c.Check(1, checker) + }) +} + +func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *check.C) { + checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" + + "\\.+ myvalue int = 1\n" + + "\\.+ Hello world!\n\n" + testHelperFailure(c, "Check(1, checker, msg)", false, false, log, + func() interface{} { + return c.Check(1, checker, myComment("Hello world!")) + }) +} + +func (s *HelpersS) TestCheckWithMissingExpected(c *check.C) { + checker := &MyChecker{result: true} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker\\)\n" + + "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" + + "\\.+ Wrong number of parameters for MyChecker: " + + "want 3, got 2\n\n" + testHelperFailure(c, "Check(1, checker, !?)", false, false, log, + func() interface{} { + return c.Check(1, checker) + }) +} + +func (s *HelpersS) TestCheckWithTooManyExpected(c *check.C) { + checker := &MyChecker{result: true} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker, 2, 3\\)\n" + + "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" + + "\\.+ Wrong number of parameters for MyChecker: " + + "want 3, got 4\n\n" + testHelperFailure(c, "Check(1, checker, 2, 3)", false, false, log, + func() interface{} { + return c.Check(1, checker, 2, 3) + }) +} + +func (s *HelpersS) TestCheckWithError(c *check.C) { + checker := &MyChecker{result: false, error: "Some not so cool data provided!"} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker, 2\\)\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n" + + "\\.+ Some not so cool data provided!\n\n" + testHelperFailure(c, "Check(1, checker, 2)", false, false, log, + func() interface{} { + return c.Check(1, checker, 2) + }) +} + +func (s *HelpersS) TestCheckWithNilChecker(c *check.C) { + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, nil\\)\n" + + "\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" + + "\\.+ Oops\\.\\. you've provided a nil checker!\n\n" + testHelperFailure(c, "Check(obtained, nil)", false, false, log, + func() interface{} { + return c.Check(1, nil) + }) +} + +func (s *HelpersS) TestCheckWithParamsAndNamesMutation(c *check.C) { + checker := &MyChecker{result: false, params: []interface{}{3, 4}, names: []string{"newobtained", "newexpected"}} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " return c\\.Check\\(1, checker, 2\\)\n" + + "\\.+ newobtained int = 3\n" + + "\\.+ newexpected int = 4\n\n" + testHelperFailure(c, "Check(1, checker, 2) with mutation", false, false, log, + func() interface{} { + return c.Check(1, checker, 2) + }) +} + +// ----------------------------------------------------------------------- +// Tests for Assert(), mostly the same as for Check() above. + +func (s *HelpersS) TestAssertSucceedWithExpected(c *check.C) { + checker := &MyChecker{result: true} + testHelperSuccess(c, "Assert(1, checker, 2)", nil, func() interface{} { + c.Assert(1, checker, 2) + return nil + }) + if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) { + c.Fatalf("Bad params for check: %#v", checker.params) + } +} + +func (s *HelpersS) TestAssertSucceedWithoutExpected(c *check.C) { + checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}} + testHelperSuccess(c, "Assert(1, checker)", nil, func() interface{} { + c.Assert(1, checker) + return nil + }) + if !reflect.DeepEqual(checker.params, []interface{}{1}) { + c.Fatalf("Bad params for check: %#v", checker.params) + } +} + +func (s *HelpersS) TestAssertFailWithExpected(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, checker, 2\\)\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n\n" + testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log, + func() interface{} { + c.Assert(1, checker, 2) + return nil + }) +} + +func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n" + + "\\.+ Hello world!\n\n" + testHelperFailure(c, "Assert(1, checker, 2, msg)", nil, true, log, + func() interface{} { + c.Assert(1, checker, 2, myComment("Hello world!")) + return nil + }) +} + +func (s *HelpersS) TestAssertFailWithoutExpected(c *check.C) { + checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, checker\\)\n" + + "\\.+ myvalue int = 1\n\n" + testHelperFailure(c, "Assert(1, checker)", nil, true, log, + func() interface{} { + c.Assert(1, checker) + return nil + }) +} + +func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *check.C) { + checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" + + "\\.+ myvalue int = 1\n" + + "\\.+ Hello world!\n\n" + testHelperFailure(c, "Assert(1, checker, msg)", nil, true, log, + func() interface{} { + c.Assert(1, checker, myComment("Hello world!")) + return nil + }) +} + +func (s *HelpersS) TestAssertWithMissingExpected(c *check.C) { + checker := &MyChecker{result: true} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, checker\\)\n" + + "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" + + "\\.+ Wrong number of parameters for MyChecker: " + + "want 3, got 2\n\n" + testHelperFailure(c, "Assert(1, checker, !?)", nil, true, log, + func() interface{} { + c.Assert(1, checker) + return nil + }) +} + +func (s *HelpersS) TestAssertWithError(c *check.C) { + checker := &MyChecker{result: false, error: "Some not so cool data provided!"} + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, checker, 2\\)\n" + + "\\.+ myobtained int = 1\n" + + "\\.+ myexpected int = 2\n" + + "\\.+ Some not so cool data provided!\n\n" + testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log, + func() interface{} { + c.Assert(1, checker, 2) + return nil + }) +} + +func (s *HelpersS) TestAssertWithNilChecker(c *check.C) { + log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + + " c\\.Assert\\(1, nil\\)\n" + + "\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" + + "\\.+ Oops\\.\\. you've provided a nil checker!\n\n" + testHelperFailure(c, "Assert(obtained, nil)", nil, true, log, + func() interface{} { + c.Assert(1, nil) + return nil + }) +} + +// ----------------------------------------------------------------------- +// Ensure that values logged work properly in some interesting cases. + +func (s *HelpersS) TestValueLoggingWithArrays(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + + " return c\\.Check\\(\\[\\]byte{1, 2}, checker, \\[\\]byte{1, 3}\\)\n" + + "\\.+ myobtained \\[\\]uint8 = \\[\\]byte{0x1, 0x2}\n" + + "\\.+ myexpected \\[\\]uint8 = \\[\\]byte{0x1, 0x3}\n\n" + testHelperFailure(c, "Check([]byte{1}, chk, []byte{3})", false, false, log, + func() interface{} { + return c.Check([]byte{1, 2}, checker, []byte{1, 3}) + }) +} + +func (s *HelpersS) TestValueLoggingWithMultiLine(c *check.C) { + checker := &MyChecker{result: false} + log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + + " return c\\.Check\\(\"a\\\\nb\\\\n\", checker, \"a\\\\nb\\\\nc\"\\)\n" + + "\\.+ myobtained string = \"\" \\+\n" + + "\\.+ \"a\\\\n\" \\+\n" + + "\\.+ \"b\\\\n\"\n" + + "\\.+ myexpected string = \"\" \\+\n" + + "\\.+ \"a\\\\n\" \\+\n" + + "\\.+ \"b\\\\n\" \\+\n" + + "\\.+ \"c\"\n\n" + testHelperFailure(c, `Check("a\nb\n", chk, "a\nb\nc")`, false, false, log, + func() interface{} { + return c.Check("a\nb\n", checker, "a\nb\nc") + }) +} + +func (s *HelpersS) TestValueLoggingWithMultiLineException(c *check.C) { + // If the newline is at the end of the string, don't log as multi-line. + checker := &MyChecker{result: false} + log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + + " return c\\.Check\\(\"a b\\\\n\", checker, \"a\\\\nb\"\\)\n" + + "\\.+ myobtained string = \"a b\\\\n\"\n" + + "\\.+ myexpected string = \"\" \\+\n" + + "\\.+ \"a\\\\n\" \\+\n" + + "\\.+ \"b\"\n\n" + testHelperFailure(c, `Check("a b\n", chk, "a\nb")`, false, false, log, + func() interface{} { + return c.Check("a b\n", checker, "a\nb") + }) +} + +// ----------------------------------------------------------------------- +// MakeDir() tests. + +type MkDirHelper struct { + path1 string + path2 string + isDir1 bool + isDir2 bool + isDir3 bool + isDir4 bool +} + +func (s *MkDirHelper) SetUpSuite(c *check.C) { + s.path1 = c.MkDir() + s.isDir1 = isDir(s.path1) +} + +func (s *MkDirHelper) Test(c *check.C) { + s.path2 = c.MkDir() + s.isDir2 = isDir(s.path2) +} + +func (s *MkDirHelper) TearDownSuite(c *check.C) { + s.isDir3 = isDir(s.path1) + s.isDir4 = isDir(s.path2) +} + +func (s *HelpersS) TestMkDir(c *check.C) { + helper := MkDirHelper{} + output := String{} + check.Run(&helper, &check.RunConf{Output: &output}) + c.Assert(output.value, check.Equals, "") + c.Check(helper.isDir1, check.Equals, true) + c.Check(helper.isDir2, check.Equals, true) + c.Check(helper.isDir3, check.Equals, true) + c.Check(helper.isDir4, check.Equals, true) + c.Check(helper.path1, check.Not(check.Equals), + helper.path2) + c.Check(isDir(helper.path1), check.Equals, false) + c.Check(isDir(helper.path2), check.Equals, false) +} + +func isDir(path string) bool { + if stat, err := os.Stat(path); err == nil { + return stat.IsDir() + } + return false +} + +// Concurrent logging should not corrupt the underling buffer. +// Use go test -race to detect the race in this test. +func (s *HelpersS) TestConcurrentLogging(c *check.C) { + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU())) + var start, stop sync.WaitGroup + start.Add(1) + for i, n := 0, runtime.NumCPU()*2; i < n; i++ { + stop.Add(1) + go func(i int) { + start.Wait() + for j := 0; j < 30; j++ { + c.Logf("Worker %d: line %d", i, j) + } + stop.Done() + }(i) + } + start.Done() + stop.Wait() +} + +// ----------------------------------------------------------------------- +// Test the TestName function + +type TestNameHelper struct { + name1 string + name2 string + name3 string + name4 string + name5 string +} + +func (s *TestNameHelper) SetUpSuite(c *check.C) { s.name1 = c.TestName() } +func (s *TestNameHelper) SetUpTest(c *check.C) { s.name2 = c.TestName() } +func (s *TestNameHelper) Test(c *check.C) { s.name3 = c.TestName() } +func (s *TestNameHelper) TearDownTest(c *check.C) { s.name4 = c.TestName() } +func (s *TestNameHelper) TearDownSuite(c *check.C) { s.name5 = c.TestName() } + +func (s *HelpersS) TestTestName(c *check.C) { + helper := TestNameHelper{} + output := String{} + check.Run(&helper, &check.RunConf{Output: &output}) + c.Check(helper.name1, check.Equals, "") + c.Check(helper.name2, check.Equals, "TestNameHelper.Test") + c.Check(helper.name3, check.Equals, "TestNameHelper.Test") + c.Check(helper.name4, check.Equals, "TestNameHelper.Test") + c.Check(helper.name5, check.Equals, "") +} + +// ----------------------------------------------------------------------- +// A couple of helper functions to test helper functions. :-) + +func testHelperSuccess(c *check.C, name string, expectedResult interface{}, closure func() interface{}) { + var result interface{} + defer (func() { + if err := recover(); err != nil { + panic(err) + } + checkState(c, result, + &expectedState{ + name: name, + result: expectedResult, + failed: false, + log: "", + }) + })() + result = closure() +} + +func testHelperFailure(c *check.C, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) { + var result interface{} + defer (func() { + if err := recover(); err != nil { + panic(err) + } + checkState(c, result, + &expectedState{ + name: name, + result: expectedResult, + failed: true, + log: log, + }) + })() + result = closure() + if shouldStop { + c.Logf("%s didn't stop when it should", name) + } +} diff --git a/vendor/gopkg.in/check.v1/printer.go b/vendor/gopkg.in/check.v1/printer.go new file mode 100644 index 00000000..e0f7557b --- /dev/null +++ b/vendor/gopkg.in/check.v1/printer.go @@ -0,0 +1,168 @@ +package check + +import ( + "bytes" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "os" +) + +func indent(s, with string) (r string) { + eol := true + for i := 0; i != len(s); i++ { + c := s[i] + switch { + case eol && c == '\n' || c == '\r': + case c == '\n' || c == '\r': + eol = true + case eol: + eol = false + s = s[:i] + with + s[i:] + i += len(with) + } + } + return s +} + +func printLine(filename string, line int) (string, error) { + fset := token.NewFileSet() + file, err := os.Open(filename) + if err != nil { + return "", err + } + fnode, err := parser.ParseFile(fset, filename, file, parser.ParseComments) + if err != nil { + return "", err + } + config := &printer.Config{Mode: printer.UseSpaces, Tabwidth: 4} + lp := &linePrinter{fset: fset, fnode: fnode, line: line, config: config} + ast.Walk(lp, fnode) + result := lp.output.Bytes() + // Comments leave \n at the end. + n := len(result) + for n > 0 && result[n-1] == '\n' { + n-- + } + return string(result[:n]), nil +} + +type linePrinter struct { + config *printer.Config + fset *token.FileSet + fnode *ast.File + line int + output bytes.Buffer + stmt ast.Stmt +} + +func (lp *linePrinter) emit() bool { + if lp.stmt != nil { + lp.trim(lp.stmt) + lp.printWithComments(lp.stmt) + lp.stmt = nil + return true + } + return false +} + +func (lp *linePrinter) printWithComments(n ast.Node) { + nfirst := lp.fset.Position(n.Pos()).Line + nlast := lp.fset.Position(n.End()).Line + for _, g := range lp.fnode.Comments { + cfirst := lp.fset.Position(g.Pos()).Line + clast := lp.fset.Position(g.End()).Line + if clast == nfirst-1 && lp.fset.Position(n.Pos()).Column == lp.fset.Position(g.Pos()).Column { + for _, c := range g.List { + lp.output.WriteString(c.Text) + lp.output.WriteByte('\n') + } + } + if cfirst >= nfirst && cfirst <= nlast && n.End() <= g.List[0].Slash { + // The printer will not include the comment if it starts past + // the node itself. Trick it into printing by overlapping the + // slash with the end of the statement. + g.List[0].Slash = n.End() - 1 + } + } + node := &printer.CommentedNode{n, lp.fnode.Comments} + lp.config.Fprint(&lp.output, lp.fset, node) +} + +func (lp *linePrinter) Visit(n ast.Node) (w ast.Visitor) { + if n == nil { + if lp.output.Len() == 0 { + lp.emit() + } + return nil + } + first := lp.fset.Position(n.Pos()).Line + last := lp.fset.Position(n.End()).Line + if first <= lp.line && last >= lp.line { + // Print the innermost statement containing the line. + if stmt, ok := n.(ast.Stmt); ok { + if _, ok := n.(*ast.BlockStmt); !ok { + lp.stmt = stmt + } + } + if first == lp.line && lp.emit() { + return nil + } + return lp + } + return nil +} + +func (lp *linePrinter) trim(n ast.Node) bool { + stmt, ok := n.(ast.Stmt) + if !ok { + return true + } + line := lp.fset.Position(n.Pos()).Line + if line != lp.line { + return false + } + switch stmt := stmt.(type) { + case *ast.IfStmt: + stmt.Body = lp.trimBlock(stmt.Body) + case *ast.SwitchStmt: + stmt.Body = lp.trimBlock(stmt.Body) + case *ast.TypeSwitchStmt: + stmt.Body = lp.trimBlock(stmt.Body) + case *ast.CaseClause: + stmt.Body = lp.trimList(stmt.Body) + case *ast.CommClause: + stmt.Body = lp.trimList(stmt.Body) + case *ast.BlockStmt: + stmt.List = lp.trimList(stmt.List) + } + return true +} + +func (lp *linePrinter) trimBlock(stmt *ast.BlockStmt) *ast.BlockStmt { + if !lp.trim(stmt) { + return lp.emptyBlock(stmt) + } + stmt.Rbrace = stmt.Lbrace + return stmt +} + +func (lp *linePrinter) trimList(stmts []ast.Stmt) []ast.Stmt { + for i := 0; i != len(stmts); i++ { + if !lp.trim(stmts[i]) { + stmts[i] = lp.emptyStmt(stmts[i]) + break + } + } + return stmts +} + +func (lp *linePrinter) emptyStmt(n ast.Node) *ast.ExprStmt { + return &ast.ExprStmt{&ast.Ellipsis{n.Pos(), nil}} +} + +func (lp *linePrinter) emptyBlock(n ast.Node) *ast.BlockStmt { + p := n.Pos() + return &ast.BlockStmt{p, []ast.Stmt{lp.emptyStmt(n)}, p} +} diff --git a/vendor/gopkg.in/check.v1/printer_test.go b/vendor/gopkg.in/check.v1/printer_test.go new file mode 100644 index 00000000..538b2d52 --- /dev/null +++ b/vendor/gopkg.in/check.v1/printer_test.go @@ -0,0 +1,104 @@ +package check_test + +import ( + . "gopkg.in/check.v1" +) + +var _ = Suite(&PrinterS{}) + +type PrinterS struct{} + +func (s *PrinterS) TestCountSuite(c *C) { + suitesRun += 1 +} + +var printTestFuncLine int + +func init() { + printTestFuncLine = getMyLine() + 3 +} + +func printTestFunc() { + println(1) // Comment1 + if 2 == 2 { // Comment2 + println(3) // Comment3 + } + switch 5 { + case 6: println(6) // Comment6 + println(7) + } + switch interface{}(9).(type) {// Comment9 + case int: println(10) + println(11) + } + select { + case <-(chan bool)(nil): println(14) + println(15) + default: println(16) + println(17) + } + println(19, + 20) + _ = func() { println(21) + println(22) + } + println(24, func() { + println(25) + }) + // Leading comment + // with multiple lines. + println(29) // Comment29 +} + +var printLineTests = []struct { + line int + output string +}{ + {1, "println(1) // Comment1"}, + {2, "if 2 == 2 { // Comment2\n ...\n}"}, + {3, "println(3) // Comment3"}, + {5, "switch 5 {\n...\n}"}, + {6, "case 6:\n println(6) // Comment6\n ..."}, + {7, "println(7)"}, + {9, "switch interface{}(9).(type) { // Comment9\n...\n}"}, + {10, "case int:\n println(10)\n ..."}, + {14, "case <-(chan bool)(nil):\n println(14)\n ..."}, + {15, "println(15)"}, + {16, "default:\n println(16)\n ..."}, + {17, "println(17)"}, + {19, "println(19,\n 20)"}, + {20, "println(19,\n 20)"}, + {21, "_ = func() {\n println(21)\n println(22)\n}"}, + {22, "println(22)"}, + {24, "println(24, func() {\n println(25)\n})"}, + {25, "println(25)"}, + {26, "println(24, func() {\n println(25)\n})"}, + {29, "// Leading comment\n// with multiple lines.\nprintln(29) // Comment29"}, +} + +func (s *PrinterS) TestPrintLine(c *C) { + for _, test := range printLineTests { + output, err := PrintLine("printer_test.go", printTestFuncLine+test.line) + c.Assert(err, IsNil) + c.Assert(output, Equals, test.output) + } +} + +var indentTests = []struct { + in, out string +}{ + {"", ""}, + {"\n", "\n"}, + {"a", ">>>a"}, + {"a\n", ">>>a\n"}, + {"a\nb", ">>>a\n>>>b"}, + {" ", ">>> "}, +} + +func (s *PrinterS) TestIndent(c *C) { + for _, test := range indentTests { + out := Indent(test.in, ">>>") + c.Assert(out, Equals, test.out) + } + +} diff --git a/vendor/gopkg.in/check.v1/reporter.go b/vendor/gopkg.in/check.v1/reporter.go new file mode 100644 index 00000000..fb04f76f --- /dev/null +++ b/vendor/gopkg.in/check.v1/reporter.go @@ -0,0 +1,88 @@ +package check + +import ( + "fmt" + "io" + "sync" +) + +// ----------------------------------------------------------------------- +// Output writer manages atomic output writing according to settings. + +type outputWriter struct { + m sync.Mutex + writer io.Writer + wroteCallProblemLast bool + Stream bool + Verbose bool +} + +func newOutputWriter(writer io.Writer, stream, verbose bool) *outputWriter { + return &outputWriter{writer: writer, Stream: stream, Verbose: verbose} +} + +func (ow *outputWriter) Write(content []byte) (n int, err error) { + ow.m.Lock() + n, err = ow.writer.Write(content) + ow.m.Unlock() + return +} + +func (ow *outputWriter) WriteCallStarted(label string, c *C) { + if ow.Stream { + header := renderCallHeader(label, c, "", "\n") + ow.m.Lock() + ow.writer.Write([]byte(header)) + ow.m.Unlock() + } +} + +func (ow *outputWriter) WriteCallProblem(label string, c *C) { + var prefix string + if !ow.Stream { + prefix = "\n-----------------------------------" + + "-----------------------------------\n" + } + header := renderCallHeader(label, c, prefix, "\n\n") + ow.m.Lock() + ow.wroteCallProblemLast = true + ow.writer.Write([]byte(header)) + if !ow.Stream { + c.logb.WriteTo(ow.writer) + } + ow.m.Unlock() +} + +func (ow *outputWriter) WriteCallSuccess(label string, c *C) { + if ow.Stream || (ow.Verbose && c.kind == testKd) { + // TODO Use a buffer here. + var suffix string + if c.reason != "" { + suffix = " (" + c.reason + ")" + } + if c.status() == succeededSt { + suffix += "\t" + c.timerString() + } + suffix += "\n" + if ow.Stream { + suffix += "\n" + } + header := renderCallHeader(label, c, "", suffix) + ow.m.Lock() + // Resist temptation of using line as prefix above due to race. + if !ow.Stream && ow.wroteCallProblemLast { + header = "\n-----------------------------------" + + "-----------------------------------\n" + + header + } + ow.wroteCallProblemLast = false + ow.writer.Write([]byte(header)) + ow.m.Unlock() + } +} + +func renderCallHeader(label string, c *C, prefix, suffix string) string { + pc := c.method.PC() + return fmt.Sprintf("%s%s: %s: %s%s", prefix, label, niceFuncPath(pc), + niceFuncName(pc), suffix) +} diff --git a/vendor/gopkg.in/check.v1/reporter_test.go b/vendor/gopkg.in/check.v1/reporter_test.go new file mode 100644 index 00000000..0b7ed762 --- /dev/null +++ b/vendor/gopkg.in/check.v1/reporter_test.go @@ -0,0 +1,159 @@ +package check_test + +import ( + "fmt" + "path/filepath" + "runtime" + + . "gopkg.in/check.v1" +) + +var _ = Suite(&reporterS{}) + +type reporterS struct { + testFile string +} + +func (s *reporterS) SetUpSuite(c *C) { + _, fileName, _, ok := runtime.Caller(0) + c.Assert(ok, Equals, true) + s.testFile = filepath.Base(fileName) +} + +func (s *reporterS) TestWrite(c *C) { + testString := "test string" + output := String{} + + dummyStream := true + dummyVerbose := true + o := NewOutputWriter(&output, dummyStream, dummyVerbose) + + o.Write([]byte(testString)) + c.Assert(output.value, Equals, testString) +} + +func (s *reporterS) TestWriteCallStartedWithStreamFlag(c *C) { + testLabel := "test started label" + stream := true + output := String{} + + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + + o.WriteCallStarted(testLabel, c) + expected := fmt.Sprintf("%s: %s:\\d+: %s\n", testLabel, s.testFile, c.TestName()) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallStartedWithoutStreamFlag(c *C) { + stream := false + output := String{} + + dummyLabel := "dummy" + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + + o.WriteCallStarted(dummyLabel, c) + c.Assert(output.value, Equals, "") +} + +func (s *reporterS) TestWriteCallProblemWithStreamFlag(c *C) { + testLabel := "test problem label" + stream := true + output := String{} + + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + + o.WriteCallProblem(testLabel, c) + expected := fmt.Sprintf("%s: %s:\\d+: %s\n\n", testLabel, s.testFile, c.TestName()) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallProblemWithoutStreamFlag(c *C) { + testLabel := "test problem label" + stream := false + output := String{} + + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + + o.WriteCallProblem(testLabel, c) + expected := fmt.Sprintf(""+ + "\n"+ + "----------------------------------------------------------------------\n"+ + "%s: %s:\\d+: %s\n\n", testLabel, s.testFile, c.TestName()) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallProblemWithoutStreamFlagWithLog(c *C) { + testLabel := "test problem label" + testLog := "test log" + stream := false + output := String{} + + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + + c.Log(testLog) + o.WriteCallProblem(testLabel, c) + expected := fmt.Sprintf(""+ + "\n"+ + "----------------------------------------------------------------------\n"+ + "%s: %s:\\d+: %s\n\n%s\n", testLabel, s.testFile, c.TestName(), testLog) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallSuccessWithStreamFlag(c *C) { + testLabel := "test success label" + stream := true + output := String{} + + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + + o.WriteCallSuccess(testLabel, c) + expected := fmt.Sprintf("%s: %s:\\d+: %s\t\\d\\.\\d+s\n\n", testLabel, s.testFile, c.TestName()) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallSuccessWithStreamFlagAndReason(c *C) { + testLabel := "test success label" + testReason := "test skip reason" + stream := true + output := String{} + + dummyVerbose := true + o := NewOutputWriter(&output, stream, dummyVerbose) + c.FakeSkip(testReason) + + o.WriteCallSuccess(testLabel, c) + expected := fmt.Sprintf("%s: %s:\\d+: %s \\(%s\\)\t\\d\\.\\d+s\n\n", + testLabel, s.testFile, c.TestName(), testReason) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallSuccessWithoutStreamFlagWithVerboseFlag(c *C) { + testLabel := "test success label" + stream := false + verbose := true + output := String{} + + o := NewOutputWriter(&output, stream, verbose) + + o.WriteCallSuccess(testLabel, c) + expected := fmt.Sprintf("%s: %s:\\d+: %s\t\\d\\.\\d+s\n", testLabel, s.testFile, c.TestName()) + c.Assert(output.value, Matches, expected) +} + +func (s *reporterS) TestWriteCallSuccessWithoutStreamFlagWithoutVerboseFlag(c *C) { + testLabel := "test success label" + stream := false + verbose := false + output := String{} + + o := NewOutputWriter(&output, stream, verbose) + + o.WriteCallSuccess(testLabel, c) + c.Assert(output.value, Equals, "") +} diff --git a/vendor/gopkg.in/check.v1/run.go b/vendor/gopkg.in/check.v1/run.go new file mode 100644 index 00000000..da8fd798 --- /dev/null +++ b/vendor/gopkg.in/check.v1/run.go @@ -0,0 +1,175 @@ +package check + +import ( + "bufio" + "flag" + "fmt" + "os" + "testing" + "time" +) + +// ----------------------------------------------------------------------- +// Test suite registry. + +var allSuites []interface{} + +// Suite registers the given value as a test suite to be run. Any methods +// starting with the Test prefix in the given value will be considered as +// a test method. +func Suite(suite interface{}) interface{} { + allSuites = append(allSuites, suite) + return suite +} + +// ----------------------------------------------------------------------- +// Public running interface. + +var ( + oldFilterFlag = flag.String("gocheck.f", "", "Regular expression selecting which tests and/or suites to run") + oldVerboseFlag = flag.Bool("gocheck.v", false, "Verbose mode") + oldStreamFlag = flag.Bool("gocheck.vv", false, "Super verbose mode (disables output caching)") + oldBenchFlag = flag.Bool("gocheck.b", false, "Run benchmarks") + oldBenchTime = flag.Duration("gocheck.btime", 1*time.Second, "approximate run time for each benchmark") + oldListFlag = flag.Bool("gocheck.list", false, "List the names of all tests that will be run") + oldWorkFlag = flag.Bool("gocheck.work", false, "Display and do not remove the test working directory") + + newFilterFlag = flag.String("check.f", "", "Regular expression selecting which tests and/or suites to run") + newVerboseFlag = flag.Bool("check.v", false, "Verbose mode") + newStreamFlag = flag.Bool("check.vv", false, "Super verbose mode (disables output caching)") + newBenchFlag = flag.Bool("check.b", false, "Run benchmarks") + newBenchTime = flag.Duration("check.btime", 1*time.Second, "approximate run time for each benchmark") + newBenchMem = flag.Bool("check.bmem", false, "Report memory benchmarks") + newListFlag = flag.Bool("check.list", false, "List the names of all tests that will be run") + newWorkFlag = flag.Bool("check.work", false, "Display and do not remove the test working directory") +) + +// TestingT runs all test suites registered with the Suite function, +// printing results to stdout, and reporting any failures back to +// the "testing" package. +func TestingT(testingT *testing.T) { + benchTime := *newBenchTime + if benchTime == 1*time.Second { + benchTime = *oldBenchTime + } + conf := &RunConf{ + Filter: *oldFilterFlag + *newFilterFlag, + Verbose: *oldVerboseFlag || *newVerboseFlag, + Stream: *oldStreamFlag || *newStreamFlag, + Benchmark: *oldBenchFlag || *newBenchFlag, + BenchmarkTime: benchTime, + BenchmarkMem: *newBenchMem, + KeepWorkDir: *oldWorkFlag || *newWorkFlag, + } + if *oldListFlag || *newListFlag { + w := bufio.NewWriter(os.Stdout) + for _, name := range ListAll(conf) { + fmt.Fprintln(w, name) + } + w.Flush() + return + } + result := RunAll(conf) + println(result.String()) + if !result.Passed() { + testingT.Fail() + } +} + +// RunAll runs all test suites registered with the Suite function, using the +// provided run configuration. +func RunAll(runConf *RunConf) *Result { + result := Result{} + for _, suite := range allSuites { + result.Add(Run(suite, runConf)) + } + return &result +} + +// Run runs the provided test suite using the provided run configuration. +func Run(suite interface{}, runConf *RunConf) *Result { + runner := newSuiteRunner(suite, runConf) + return runner.run() +} + +// ListAll returns the names of all the test functions registered with the +// Suite function that will be run with the provided run configuration. +func ListAll(runConf *RunConf) []string { + var names []string + for _, suite := range allSuites { + names = append(names, List(suite, runConf)...) + } + return names +} + +// List returns the names of the test functions in the given +// suite that will be run with the provided run configuration. +func List(suite interface{}, runConf *RunConf) []string { + var names []string + runner := newSuiteRunner(suite, runConf) + for _, t := range runner.tests { + names = append(names, t.String()) + } + return names +} + +// ----------------------------------------------------------------------- +// Result methods. + +func (r *Result) Add(other *Result) { + r.Succeeded += other.Succeeded + r.Skipped += other.Skipped + r.Failed += other.Failed + r.Panicked += other.Panicked + r.FixturePanicked += other.FixturePanicked + r.ExpectedFailures += other.ExpectedFailures + r.Missed += other.Missed + if r.WorkDir != "" && other.WorkDir != "" { + r.WorkDir += ":" + other.WorkDir + } else if other.WorkDir != "" { + r.WorkDir = other.WorkDir + } +} + +func (r *Result) Passed() bool { + return (r.Failed == 0 && r.Panicked == 0 && + r.FixturePanicked == 0 && r.Missed == 0 && + r.RunError == nil) +} + +func (r *Result) String() string { + if r.RunError != nil { + return "ERROR: " + r.RunError.Error() + } + + var value string + if r.Failed == 0 && r.Panicked == 0 && r.FixturePanicked == 0 && + r.Missed == 0 { + value = "OK: " + } else { + value = "OOPS: " + } + value += fmt.Sprintf("%d passed", r.Succeeded) + if r.Skipped != 0 { + value += fmt.Sprintf(", %d skipped", r.Skipped) + } + if r.ExpectedFailures != 0 { + value += fmt.Sprintf(", %d expected failures", r.ExpectedFailures) + } + if r.Failed != 0 { + value += fmt.Sprintf(", %d FAILED", r.Failed) + } + if r.Panicked != 0 { + value += fmt.Sprintf(", %d PANICKED", r.Panicked) + } + if r.FixturePanicked != 0 { + value += fmt.Sprintf(", %d FIXTURE-PANICKED", r.FixturePanicked) + } + if r.Missed != 0 { + value += fmt.Sprintf(", %d MISSED", r.Missed) + } + if r.WorkDir != "" { + value += "\nWORK=" + r.WorkDir + } + return value +} diff --git a/vendor/gopkg.in/check.v1/run_test.go b/vendor/gopkg.in/check.v1/run_test.go new file mode 100644 index 00000000..f41fffc3 --- /dev/null +++ b/vendor/gopkg.in/check.v1/run_test.go @@ -0,0 +1,419 @@ +// These tests verify the test running logic. + +package check_test + +import ( + "errors" + . "gopkg.in/check.v1" + "os" + "sync" +) + +var runnerS = Suite(&RunS{}) + +type RunS struct{} + +func (s *RunS) TestCountSuite(c *C) { + suitesRun += 1 +} + +// ----------------------------------------------------------------------- +// Tests ensuring result counting works properly. + +func (s *RunS) TestSuccess(c *C) { + output := String{} + result := Run(&SuccessHelper{}, &RunConf{Output: &output}) + c.Check(result.Succeeded, Equals, 1) + c.Check(result.Failed, Equals, 0) + c.Check(result.Skipped, Equals, 0) + c.Check(result.Panicked, Equals, 0) + c.Check(result.FixturePanicked, Equals, 0) + c.Check(result.Missed, Equals, 0) + c.Check(result.RunError, IsNil) +} + +func (s *RunS) TestFailure(c *C) { + output := String{} + result := Run(&FailHelper{}, &RunConf{Output: &output}) + c.Check(result.Succeeded, Equals, 0) + c.Check(result.Failed, Equals, 1) + c.Check(result.Skipped, Equals, 0) + c.Check(result.Panicked, Equals, 0) + c.Check(result.FixturePanicked, Equals, 0) + c.Check(result.Missed, Equals, 0) + c.Check(result.RunError, IsNil) +} + +func (s *RunS) TestFixture(c *C) { + output := String{} + result := Run(&FixtureHelper{}, &RunConf{Output: &output}) + c.Check(result.Succeeded, Equals, 2) + c.Check(result.Failed, Equals, 0) + c.Check(result.Skipped, Equals, 0) + c.Check(result.Panicked, Equals, 0) + c.Check(result.FixturePanicked, Equals, 0) + c.Check(result.Missed, Equals, 0) + c.Check(result.RunError, IsNil) +} + +func (s *RunS) TestPanicOnTest(c *C) { + output := String{} + helper := &FixtureHelper{panicOn: "Test1"} + result := Run(helper, &RunConf{Output: &output}) + c.Check(result.Succeeded, Equals, 1) + c.Check(result.Failed, Equals, 0) + c.Check(result.Skipped, Equals, 0) + c.Check(result.Panicked, Equals, 1) + c.Check(result.FixturePanicked, Equals, 0) + c.Check(result.Missed, Equals, 0) + c.Check(result.RunError, IsNil) +} + +func (s *RunS) TestPanicOnSetUpTest(c *C) { + output := String{} + helper := &FixtureHelper{panicOn: "SetUpTest"} + result := Run(helper, &RunConf{Output: &output}) + c.Check(result.Succeeded, Equals, 0) + c.Check(result.Failed, Equals, 0) + c.Check(result.Skipped, Equals, 0) + c.Check(result.Panicked, Equals, 0) + c.Check(result.FixturePanicked, Equals, 1) + c.Check(result.Missed, Equals, 2) + c.Check(result.RunError, IsNil) +} + +func (s *RunS) TestPanicOnSetUpSuite(c *C) { + output := String{} + helper := &FixtureHelper{panicOn: "SetUpSuite"} + result := Run(helper, &RunConf{Output: &output}) + c.Check(result.Succeeded, Equals, 0) + c.Check(result.Failed, Equals, 0) + c.Check(result.Skipped, Equals, 0) + c.Check(result.Panicked, Equals, 0) + c.Check(result.FixturePanicked, Equals, 1) + c.Check(result.Missed, Equals, 2) + c.Check(result.RunError, IsNil) +} + +// ----------------------------------------------------------------------- +// Check result aggregation. + +func (s *RunS) TestAdd(c *C) { + result := &Result{ + Succeeded: 1, + Skipped: 2, + Failed: 3, + Panicked: 4, + FixturePanicked: 5, + Missed: 6, + ExpectedFailures: 7, + } + result.Add(&Result{ + Succeeded: 10, + Skipped: 20, + Failed: 30, + Panicked: 40, + FixturePanicked: 50, + Missed: 60, + ExpectedFailures: 70, + }) + c.Check(result.Succeeded, Equals, 11) + c.Check(result.Skipped, Equals, 22) + c.Check(result.Failed, Equals, 33) + c.Check(result.Panicked, Equals, 44) + c.Check(result.FixturePanicked, Equals, 55) + c.Check(result.Missed, Equals, 66) + c.Check(result.ExpectedFailures, Equals, 77) + c.Check(result.RunError, IsNil) +} + +// ----------------------------------------------------------------------- +// Check the Passed() method. + +func (s *RunS) TestPassed(c *C) { + c.Assert((&Result{}).Passed(), Equals, true) + c.Assert((&Result{Succeeded: 1}).Passed(), Equals, true) + c.Assert((&Result{Skipped: 1}).Passed(), Equals, true) + c.Assert((&Result{Failed: 1}).Passed(), Equals, false) + c.Assert((&Result{Panicked: 1}).Passed(), Equals, false) + c.Assert((&Result{FixturePanicked: 1}).Passed(), Equals, false) + c.Assert((&Result{Missed: 1}).Passed(), Equals, false) + c.Assert((&Result{RunError: errors.New("!")}).Passed(), Equals, false) +} + +// ----------------------------------------------------------------------- +// Check that result printing is working correctly. + +func (s *RunS) TestPrintSuccess(c *C) { + result := &Result{Succeeded: 5} + c.Check(result.String(), Equals, "OK: 5 passed") +} + +func (s *RunS) TestPrintFailure(c *C) { + result := &Result{Failed: 5} + c.Check(result.String(), Equals, "OOPS: 0 passed, 5 FAILED") +} + +func (s *RunS) TestPrintSkipped(c *C) { + result := &Result{Skipped: 5} + c.Check(result.String(), Equals, "OK: 0 passed, 5 skipped") +} + +func (s *RunS) TestPrintExpectedFailures(c *C) { + result := &Result{ExpectedFailures: 5} + c.Check(result.String(), Equals, "OK: 0 passed, 5 expected failures") +} + +func (s *RunS) TestPrintPanicked(c *C) { + result := &Result{Panicked: 5} + c.Check(result.String(), Equals, "OOPS: 0 passed, 5 PANICKED") +} + +func (s *RunS) TestPrintFixturePanicked(c *C) { + result := &Result{FixturePanicked: 5} + c.Check(result.String(), Equals, "OOPS: 0 passed, 5 FIXTURE-PANICKED") +} + +func (s *RunS) TestPrintMissed(c *C) { + result := &Result{Missed: 5} + c.Check(result.String(), Equals, "OOPS: 0 passed, 5 MISSED") +} + +func (s *RunS) TestPrintAll(c *C) { + result := &Result{Succeeded: 1, Skipped: 2, ExpectedFailures: 3, + Panicked: 4, FixturePanicked: 5, Missed: 6} + c.Check(result.String(), Equals, + "OOPS: 1 passed, 2 skipped, 3 expected failures, 4 PANICKED, "+ + "5 FIXTURE-PANICKED, 6 MISSED") +} + +func (s *RunS) TestPrintRunError(c *C) { + result := &Result{Succeeded: 1, Failed: 1, + RunError: errors.New("Kaboom!")} + c.Check(result.String(), Equals, "ERROR: Kaboom!") +} + +// ----------------------------------------------------------------------- +// Verify that the method pattern flag works correctly. + +func (s *RunS) TestFilterTestName(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: "Test[91]"} + Run(&helper, &runConf) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 5) +} + +func (s *RunS) TestFilterTestNameWithAll(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: ".*"} + Run(&helper, &runConf) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "SetUpTest") + c.Check(helper.calls[5], Equals, "Test2") + c.Check(helper.calls[6], Equals, "TearDownTest") + c.Check(helper.calls[7], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 8) +} + +func (s *RunS) TestFilterSuiteName(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: "FixtureHelper"} + Run(&helper, &runConf) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test1") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "SetUpTest") + c.Check(helper.calls[5], Equals, "Test2") + c.Check(helper.calls[6], Equals, "TearDownTest") + c.Check(helper.calls[7], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 8) +} + +func (s *RunS) TestFilterSuiteNameAndTestName(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: "FixtureHelper\\.Test2"} + Run(&helper, &runConf) + c.Check(helper.calls[0], Equals, "SetUpSuite") + c.Check(helper.calls[1], Equals, "SetUpTest") + c.Check(helper.calls[2], Equals, "Test2") + c.Check(helper.calls[3], Equals, "TearDownTest") + c.Check(helper.calls[4], Equals, "TearDownSuite") + c.Check(len(helper.calls), Equals, 5) +} + +func (s *RunS) TestFilterAllOut(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: "NotFound"} + Run(&helper, &runConf) + c.Check(len(helper.calls), Equals, 0) +} + +func (s *RunS) TestRequirePartialMatch(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: "est"} + Run(&helper, &runConf) + c.Check(len(helper.calls), Equals, 8) +} + +func (s *RunS) TestFilterError(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Filter: "]["} + result := Run(&helper, &runConf) + c.Check(result.String(), Equals, + "ERROR: Bad filter expression: error parsing regexp: missing closing ]: `[`") + c.Check(len(helper.calls), Equals, 0) +} + +// ----------------------------------------------------------------------- +// Verify that List works correctly. + +func (s *RunS) TestListFiltered(c *C) { + names := List(&FixtureHelper{}, &RunConf{Filter: "1"}) + c.Assert(names, DeepEquals, []string{ + "FixtureHelper.Test1", + }) +} + +func (s *RunS) TestList(c *C) { + names := List(&FixtureHelper{}, &RunConf{}) + c.Assert(names, DeepEquals, []string{ + "FixtureHelper.Test1", + "FixtureHelper.Test2", + }) +} + +// ----------------------------------------------------------------------- +// Verify that verbose mode prints tests which pass as well. + +func (s *RunS) TestVerboseMode(c *C) { + helper := FixtureHelper{} + output := String{} + runConf := RunConf{Output: &output, Verbose: true} + Run(&helper, &runConf) + + expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t *[.0-9]+s\n" + + "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n" + + c.Assert(output.value, Matches, expected) +} + +func (s *RunS) TestVerboseModeWithFailBeforePass(c *C) { + helper := FixtureHelper{panicOn: "Test1"} + output := String{} + runConf := RunConf{Output: &output, Verbose: true} + Run(&helper, &runConf) + + expected := "(?s).*PANIC.*\n-+\n" + // Should have an extra line. + "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n" + + c.Assert(output.value, Matches, expected) +} + +// ----------------------------------------------------------------------- +// Verify the stream output mode. In this mode there's no output caching. + +type StreamHelper struct { + l2 sync.Mutex + l3 sync.Mutex +} + +func (s *StreamHelper) SetUpSuite(c *C) { + c.Log("0") +} + +func (s *StreamHelper) Test1(c *C) { + c.Log("1") + s.l2.Lock() + s.l3.Lock() + go func() { + s.l2.Lock() // Wait for "2". + c.Log("3") + s.l3.Unlock() + }() +} + +func (s *StreamHelper) Test2(c *C) { + c.Log("2") + s.l2.Unlock() + s.l3.Lock() // Wait for "3". + c.Fail() + c.Log("4") +} + +func (s *RunS) TestStreamMode(c *C) { + helper := &StreamHelper{} + output := String{} + runConf := RunConf{Output: &output, Stream: true} + Run(helper, &runConf) + + expected := "START: run_test\\.go:[0-9]+: StreamHelper\\.SetUpSuite\n0\n" + + "PASS: run_test\\.go:[0-9]+: StreamHelper\\.SetUpSuite\t *[.0-9]+s\n\n" + + "START: run_test\\.go:[0-9]+: StreamHelper\\.Test1\n1\n" + + "PASS: run_test\\.go:[0-9]+: StreamHelper\\.Test1\t *[.0-9]+s\n\n" + + "START: run_test\\.go:[0-9]+: StreamHelper\\.Test2\n2\n3\n4\n" + + "FAIL: run_test\\.go:[0-9]+: StreamHelper\\.Test2\n\n" + + c.Assert(output.value, Matches, expected) +} + +type StreamMissHelper struct{} + +func (s *StreamMissHelper) SetUpSuite(c *C) { + c.Log("0") + c.Fail() +} + +func (s *StreamMissHelper) Test1(c *C) { + c.Log("1") +} + +func (s *RunS) TestStreamModeWithMiss(c *C) { + helper := &StreamMissHelper{} + output := String{} + runConf := RunConf{Output: &output, Stream: true} + Run(helper, &runConf) + + expected := "START: run_test\\.go:[0-9]+: StreamMissHelper\\.SetUpSuite\n0\n" + + "FAIL: run_test\\.go:[0-9]+: StreamMissHelper\\.SetUpSuite\n\n" + + "START: run_test\\.go:[0-9]+: StreamMissHelper\\.Test1\n" + + "MISS: run_test\\.go:[0-9]+: StreamMissHelper\\.Test1\n\n" + + c.Assert(output.value, Matches, expected) +} + +// ----------------------------------------------------------------------- +// Verify that that the keep work dir request indeed does so. + +type WorkDirSuite struct {} + +func (s *WorkDirSuite) Test(c *C) { + c.MkDir() +} + +func (s *RunS) TestKeepWorkDir(c *C) { + output := String{} + runConf := RunConf{Output: &output, Verbose: true, KeepWorkDir: true} + result := Run(&WorkDirSuite{}, &runConf) + + c.Assert(result.String(), Matches, ".*\nWORK=" + result.WorkDir) + + stat, err := os.Stat(result.WorkDir) + c.Assert(err, IsNil) + c.Assert(stat.IsDir(), Equals, true) +} From edeffb22e9231062e14f7b124a49d23d0ea614e7 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 18 Apr 2016 20:32:00 -0700 Subject: [PATCH 003/357] TCMU go bindings --- frontend/tcmu/cfunc.go | 156 +++++++++++++++++++++++ frontend/tcmu/main.go | 277 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 433 insertions(+) create mode 100644 frontend/tcmu/cfunc.go create mode 100644 frontend/tcmu/main.go diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go new file mode 100644 index 00000000..348696cf --- /dev/null +++ b/frontend/tcmu/cfunc.go @@ -0,0 +1,156 @@ +package main + +/* +#include +#include +#include +#include +#include + +#include "libtcmu.h" + + +void errp(const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vfprintf(stderr, fmt, va); + va_end(va); +} + +int sh_open_cgo(struct tcmu_device *dev) { + return shOpen(dev); +} + +void sh_close_cgo(struct tcmu_device *dev) { + shClose(dev); +} + +static struct tcmulib_handler sh_handler = { + .name = "Shorthorn TCMU handler", + .subtype = "file", + .cfg_desc = "dev_config=file/", + .added = sh_open_cgo, + .removed = sh_close_cgo, +}; + +struct tcmulib_context *tcmu_init() { + return tcmulib_initialize(&sh_handler, 1, errp); +} + +bool tcmu_poll_master_fd(struct tcmulib_context *cxt) { + int ret; + struct pollfd pfd; + + pfd.fd = tcmulib_get_master_fd(cxt); + pfd.events = POLLIN; + pfd.revents = 0; + + ret = poll(&pfd, 1, -1); + if (ret < 0) { + errp("poll error out with %d", ret); + exit(1); + } + + if (pfd.revents) { + tcmulib_master_fd_ready(cxt); + return true; + } + return false; +} + +int tcmu_wait_for_next_command(struct tcmu_device *dev) { + struct pollfd pfd; + + pfd.fd = tcmu_get_dev_fd(dev); + pfd.events = POLLIN; + pfd.revents = 0; + + poll(&pfd, 1, -1); + + if (pfd.revents != 0 && pfd.revents != POLLIN ) { + errp("poll received unexpected revent: 0x%x\n", pfd.revents); + return -1; + } + return 0; +} + +uint8_t tcmucmd_get_cdb_at(struct tcmulib_cmd *cmd, int index) { + return cmd->cdb[index]; +} + +void *allocate_buffer(int length) { + return calloc(1, length); +} + +*/ +import "C" + +import ( + "unsafe" +) + +type ( + TcmuCommand *C.struct_tcmulib_cmd + TcmuDevice *C.struct_tcmu_device + + Cbuffer *C.void +) + +func CmdGetScsiCmd(cmd TcmuCommand) byte { + return byte(C.tcmucmd_get_cdb_at(cmd, 0)) +} + +func CmdMemcpyIntoIovec(cmd TcmuCommand, buf []byte, length int) int { + if len(buf) != length { + log.Errorln("read buffer length %v is not %v: ", len(buf), length) + return 0 + } + return int(C.tcmu_memcpy_into_iovec(cmd.iovec, cmd.iov_cnt, unsafe.Pointer(&buf[0]), C.size_t(length))) +} + +func CmdMemcpyFromIovec(cmd TcmuCommand, buf []byte, length int) int { + if len(buf) != length { + log.Errorln("write buffer length %v is not %v: ", len(buf), length) + return 0 + } + return int(C.tcmu_memcpy_from_iovec(unsafe.Pointer(&buf[0]), C.size_t(length), cmd.iovec, cmd.iov_cnt)) +} + +func CmdSetMediumError(cmd TcmuCommand) int { + return int(C.tcmu_set_sense_data(&cmd.sense_buf[0], C.MEDIUM_ERROR, C.ASC_READ_ERROR, nil)) +} + +func CmdGetLba(cmd TcmuCommand) int64 { + return int64(C.tcmu_get_lba(cmd.cdb)) +} + +func CmdGetXferLength(cmd TcmuCommand) int { + return int(C.tcmu_get_xfer_length(cmd.cdb)) +} + +func CmdEmulateInquiry(cmd TcmuCommand, dev TcmuDevice) int { + return int(C.tcmu_emulate_inquiry(dev, cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) +} + +func CmdEmulateTestUnitReady(cmd TcmuCommand) int { + return int(C.tcmu_emulate_test_unit_ready(cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) +} + +func CmdEmulateModeSense(cmd TcmuCommand) int { + return int(C.tcmu_emulate_mode_sense(cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) +} + +func CmdEmulateModeSelect(cmd TcmuCommand) int { + return int(C.tcmu_emulate_mode_select(cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) +} + +func CmdEmulateServiceActionIn(cmd TcmuCommand, numLbas int64, blockSize int) int { + if C.tcmucmd_get_cdb_at(cmd, 1) == C.READ_CAPACITY_16 { + return int(C.tcmu_emulate_read_capacity_16(C.uint64_t(numLbas), + C.uint32_t(blockSize), + cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) + } + return C.TCMU_NOT_HANDLED +} diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go new file mode 100644 index 00000000..fe54db56 --- /dev/null +++ b/frontend/tcmu/main.go @@ -0,0 +1,277 @@ +package main + +/* +#cgo LDFLAGS: -L ./libs -ltcmu +#cgo CFLAGS: -I ./includes + +#include +#include +#include +#include "libtcmu.h" + +extern struct tcmulib_context *tcmu_init(); +extern bool tcmu_poll_master_fd(struct tcmulib_context *cxt); +extern int tcmu_wait_for_next_command(struct tcmu_device *dev); +extern void *allocate_buffer(int length); + +*/ +import "C" +import "unsafe" + +import ( + "net" + "os/signal" + "sync" + "syscall" + + "github.com/Sirupsen/logrus" + + "github.com/yasker/longhorn/block" + "github.com/yasker/longhorn/rpc" + + "flag" + "os" + "runtime/pprof" +) + +var ( + ready bool = false + + log = logrus.WithFields(logrus.Fields{"pkg": "main"}) + + address = "localhost:5000" + + cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") + workers = 128 + + sigs chan os.Signal + done chan bool +) + +type TcmuState struct { + volume string + client *rpc.Client + conn *net.TCPConn + lbas int64 + blockSize int + mutex *sync.Mutex + dev TcmuDevice +} + +//export shOpen +func shOpen(dev TcmuDevice) int { + var ( + err error + ) + + state := &TcmuState{ + mutex: &sync.Mutex{}, + } + blockSizeStr := C.CString("hw_block_size") + defer C.free(unsafe.Pointer(blockSizeStr)) + blockSize := int(C.tcmu_get_attribute(dev, blockSizeStr)) + if blockSize == -1 { + log.Errorln("Cannot find valid hw_block_size") + return -C.EINVAL + } + state.blockSize = blockSize + + size := int64(C.tcmu_get_device_size(dev)) + if size == -1 { + log.Errorln("Cannot find valid disk size") + return -C.EINVAL + } + state.lbas = size / int64(state.blockSize) + + cfgString := C.GoString(C.tcmu_get_dev_cfgstring(dev)) + if cfgString == "" { + log.Errorln("Cannot find configuration string") + return -C.EINVAL + } + //id := strings.TrimPrefix(cfgString, "file/") + //TODO check volume name here + + addr, err := net.ResolveTCPAddr("tcp4", address) + if err != nil { + log.Fatalf("failed to resolve ", address, err) + } + state.conn, err = net.DialTCP("tcp", nil, addr) + if err != nil { + log.Fatalf("Cannot connect to replica, %v", err) + } + + state.client = rpc.NewClient(state.conn, 5, workers) + state.dev = dev + + go state.HandleRequest() + + log.Debugln("Device added") + + ready = true + return 0 +} + +func (s *TcmuState) HandleRequest() { + defer s.conn.Close() + + cmds := make(chan TcmuCommand, workers) + wg := sync.WaitGroup{} + wg.Add(workers) + for i := 0; i < workers; i++ { + go func() { + defer wg.Done() + s.processCommands(cmds) + }() + } + + for true { + C.tcmulib_processing_start(s.dev) + cmd := C.tcmulib_get_next_command(s.dev) + for cmd != nil { + cmds <- cmd + cmd = C.tcmulib_get_next_command(s.dev) + } + ret := C.tcmu_wait_for_next_command(s.dev) + if ret != 0 { + log.Errorln("Fail to wait for next command", ret) + break + } + } +} + +func (s *TcmuState) handleReadCommand(dev TcmuDevice, cmd TcmuCommand) int { + offset := CmdGetLba(cmd) * int64(s.blockSize) + length := CmdGetXferLength(cmd) * s.blockSize + + resp, err := s.client.Call(&rpc.Request{ + Header: &block.Request{ + Type: rpc.MSG_TYPE_READ_REQUEST, + Offset: offset, + Length: int64(length), + }}) + if err != nil { + log.Errorln("read failed: ", err.Error()) + return CmdSetMediumError(cmd) + } + + copied := CmdMemcpyIntoIovec(cmd, resp.Data, length) + if copied != length { + log.Errorln("read failed: unable to complete buffer copy ") + return CmdSetMediumError(cmd) + } + return C.SAM_STAT_GOOD +} + +func (s *TcmuState) handleWriteCommand(dev TcmuDevice, cmd TcmuCommand) int { + offset := CmdGetLba(cmd) * int64(s.blockSize) + length := CmdGetXferLength(cmd) * s.blockSize + + buf := make([]byte, length) + if buf == nil { + log.Errorln("read failed: fail to allocate buffer") + return CmdSetMediumError(cmd) + } + copied := CmdMemcpyFromIovec(cmd, buf, length) + if copied != length { + log.Errorln("write failed: unable to complete buffer copy ") + return CmdSetMediumError(cmd) + } + + if _, err := s.client.Call(&rpc.Request{ + Header: &block.Request{ + Type: rpc.MSG_TYPE_WRITE_REQUEST, + Offset: offset, + Length: int64(length), + }, + Data: buf}); err != nil { + log.Errorln("write failed: ", err.Error()) + return CmdSetMediumError(cmd) + } + + return C.SAM_STAT_GOOD +} + +func (s *TcmuState) processCommands(cmds chan TcmuCommand) { + for cmd := range cmds { + s.processCommand(cmd) + } +} + +func (s *TcmuState) processCommand(cmd TcmuCommand) { + ret := s.handleCommand(cmd) + + s.mutex.Lock() + defer s.mutex.Unlock() + + C.tcmulib_command_complete(s.dev, cmd, C.int(ret)) + C.tcmulib_processing_complete(s.dev) +} + +func (s *TcmuState) handleCommand(cmd TcmuCommand) int { + scsiCmd := CmdGetScsiCmd(cmd) + switch scsiCmd { + case C.INQUIRY: + return CmdEmulateInquiry(cmd, s.dev) + case C.TEST_UNIT_READY: + return CmdEmulateTestUnitReady(cmd) + case C.SERVICE_ACTION_IN_16: + return CmdEmulateServiceActionIn(cmd, s.lbas, s.blockSize) + case C.MODE_SENSE, C.MODE_SENSE_10: + return CmdEmulateModeSense(cmd) + case C.MODE_SELECT, C.MODE_SELECT_10: + return CmdEmulateModeSelect(cmd) + case C.READ_6, C.READ_10, C.READ_12, C.READ_16: + return s.handleReadCommand(s.dev, cmd) + case C.WRITE_6, C.WRITE_10, C.WRITE_12, C.WRITE_16: + return s.handleWriteCommand(s.dev, cmd) + default: + log.Errorf("unknown command 0x%x\n", scsiCmd) + } + return C.TCMU_NOT_HANDLED +} + +//export shClose +func shClose(dev TcmuDevice) { + log.Debugln("Device removed") +} + +func handleSignal() { + sig := <-sigs + log.Infoln("Shutting down process, due to received signal ", sig) + pprof.StopCPUProfile() + done <- true +} + +func main() { + logrus.SetLevel(logrus.DebugLevel) + + flag.Parse() + if *cpuprofile != "" { + log.Debug("Output cpuprofile to %v", *cpuprofile) + f, err := os.Create(*cpuprofile) + if err != nil { + log.Fatal(err) + } + pprof.StartCPUProfile(f) + } + + sigs = make(chan os.Signal, 1) + done = make(chan bool, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + + go handleSignal() + + cxt := C.tcmu_init() + if cxt == nil { + panic("cxt is nil") + } + + for !ready { + result := C.tcmu_poll_master_fd(cxt) + log.Debugln("Poll master fd one more time, last result ", result) + } + + log.Infoln("Waiting for process") + <-done + log.Infoln("Shutdown complete") +} From 6195d9072dfe716f9b6c277564e995752957d918 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 18 Apr 2016 20:33:15 -0700 Subject: [PATCH 004/357] Minor changes to adapt TCMU to frontend API --- frontend/tcmu/cfunc.go | 34 ++--- frontend/tcmu/frontend.go | 289 ++++++++++++++++++++++++++++++++++++++ frontend/tcmu/main.go | 189 +++++++------------------ 3 files changed, 359 insertions(+), 153 deletions(-) create mode 100644 frontend/tcmu/frontend.go diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index 348696cf..9185ff4f 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -1,4 +1,4 @@ -package main +package tcmu /* #include @@ -6,8 +6,8 @@ package main #include #include #include - -#include "libtcmu.h" +#include +#include void errp(const char *fmt, ...) @@ -69,7 +69,7 @@ int tcmu_wait_for_next_command(struct tcmu_device *dev) { poll(&pfd, 1, -1); - if (pfd.revents != 0 && pfd.revents != POLLIN ) { + if (pfd.revents != POLLIN) { errp("poll received unexpected revent: 0x%x\n", pfd.revents); return -1; } @@ -92,17 +92,17 @@ import ( ) type ( - TcmuCommand *C.struct_tcmulib_cmd - TcmuDevice *C.struct_tcmu_device + Command *C.struct_tcmulib_cmd + Device *C.struct_tcmu_device Cbuffer *C.void ) -func CmdGetScsiCmd(cmd TcmuCommand) byte { +func CmdGetScsiCmd(cmd Command) byte { return byte(C.tcmucmd_get_cdb_at(cmd, 0)) } -func CmdMemcpyIntoIovec(cmd TcmuCommand, buf []byte, length int) int { +func CmdMemcpyIntoIovec(cmd Command, buf []byte, length int) int { if len(buf) != length { log.Errorln("read buffer length %v is not %v: ", len(buf), length) return 0 @@ -110,7 +110,7 @@ func CmdMemcpyIntoIovec(cmd TcmuCommand, buf []byte, length int) int { return int(C.tcmu_memcpy_into_iovec(cmd.iovec, cmd.iov_cnt, unsafe.Pointer(&buf[0]), C.size_t(length))) } -func CmdMemcpyFromIovec(cmd TcmuCommand, buf []byte, length int) int { +func CmdMemcpyFromIovec(cmd Command, buf []byte, length int) int { if len(buf) != length { log.Errorln("write buffer length %v is not %v: ", len(buf), length) return 0 @@ -118,35 +118,35 @@ func CmdMemcpyFromIovec(cmd TcmuCommand, buf []byte, length int) int { return int(C.tcmu_memcpy_from_iovec(unsafe.Pointer(&buf[0]), C.size_t(length), cmd.iovec, cmd.iov_cnt)) } -func CmdSetMediumError(cmd TcmuCommand) int { +func CmdSetMediumError(cmd Command) int { return int(C.tcmu_set_sense_data(&cmd.sense_buf[0], C.MEDIUM_ERROR, C.ASC_READ_ERROR, nil)) } -func CmdGetLba(cmd TcmuCommand) int64 { +func CmdGetLba(cmd Command) int64 { return int64(C.tcmu_get_lba(cmd.cdb)) } -func CmdGetXferLength(cmd TcmuCommand) int { +func CmdGetXferLength(cmd Command) int { return int(C.tcmu_get_xfer_length(cmd.cdb)) } -func CmdEmulateInquiry(cmd TcmuCommand, dev TcmuDevice) int { +func CmdEmulateInquiry(cmd Command, dev Device) int { return int(C.tcmu_emulate_inquiry(dev, cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) } -func CmdEmulateTestUnitReady(cmd TcmuCommand) int { +func CmdEmulateTestUnitReady(cmd Command) int { return int(C.tcmu_emulate_test_unit_ready(cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) } -func CmdEmulateModeSense(cmd TcmuCommand) int { +func CmdEmulateModeSense(cmd Command) int { return int(C.tcmu_emulate_mode_sense(cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) } -func CmdEmulateModeSelect(cmd TcmuCommand) int { +func CmdEmulateModeSelect(cmd Command) int { return int(C.tcmu_emulate_mode_select(cmd.cdb, cmd.iovec, cmd.iov_cnt, &cmd.sense_buf[0])) } -func CmdEmulateServiceActionIn(cmd TcmuCommand, numLbas int64, blockSize int) int { +func CmdEmulateServiceActionIn(cmd Command, numLbas int64, blockSize int) int { if C.tcmucmd_get_cdb_at(cmd, 1) == C.READ_CAPACITY_16 { return int(C.tcmu_emulate_read_capacity_16(C.uint64_t(numLbas), C.uint32_t(blockSize), diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go new file mode 100644 index 00000000..d6f1efa8 --- /dev/null +++ b/frontend/tcmu/frontend.go @@ -0,0 +1,289 @@ +package tcmu + +import ( + "crypto/md5" + "encoding/hex" + "fmt" + "io/ioutil" + "os" + "path" + "path/filepath" + "strconv" + "strings" + "syscall" + "time" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" +) + +const ( + devPath = "/dev/longhorn/" + configDir = "/sys/kernel/config/target/core/user_42" + scsiDir = "/sys/kernel/config/target/loopback" + wwnPrefix = "naa.6001405" + teardownRetryWait = 1 + teardownAttempts = 2 +) + +func New() types.Frontend { + return &Tcmu{} +} + +type Tcmu struct { + volume string +} + +func (t *Tcmu) Activate(name string, size int64, rw types.ReaderWriterAt) error { + t.volume = name + + t.Shutdown() + + if err := PreEnableTcmu(name, size); err != nil { + return err + } + + if err := start(rw); err != nil { + return err + } + + return PostEnableTcmu(name, size) +} + +func (t *Tcmu) Shutdown() error { + return TeardownTcmu(t.volume) +} + +func PreEnableTcmu(volume string, size int64) error { + err := writeLines(path.Join(configDir, volume, "control"), []string{ + fmt.Sprintf("dev_size=%d", size), + fmt.Sprintf("dev_config=%s", GetDevConfig(volume)), + "hw_block_size=4096", + "async=1", + }) + if err != nil { + return err + } + + return writeLines(path.Join(configDir, volume, "enable"), []string{ + "1", + }) +} + +func PostEnableTcmu(volume string, size int64) error { + prefix, nexusWnn := getScsiPrefixAndWnn(volume) + + err := writeLines(path.Join(prefix, "nexus"), []string{ + nexusWnn, + }) + if err != nil { + return err + } + + lunPath := getLunPath(prefix) + logrus.Infof("Creating directory: %s", lunPath) + if err := os.MkdirAll(lunPath, 0755); err != nil && !os.IsExist(err) { + return err + } + + logrus.Infof("Linking: %s => %s", path.Join(lunPath, volume), path.Join(configDir, volume)) + if err := os.Symlink(path.Join(configDir, volume), path.Join(lunPath, volume)); err != nil { + return err + } + + return createDevice(volume) +} + +func createDevice(volume string) error { + os.MkdirAll(devPath, 0700) + + dev := devPath + volume + + if _, err := os.Stat(dev); err == nil { + return fmt.Errorf("Device %s already exists, can not create", dev) + } + + tgt, _ := getScsiPrefixAndWnn(volume) + + address, err := ioutil.ReadFile(path.Join(tgt, "address")) + if err != nil { + return err + } + + found := false + matches := []string{} + path := fmt.Sprintf("/sys/bus/scsi/devices/%s*/block/*/dev", strings.TrimSpace(string(address))) + for i := 0; i < 30; i++ { + var err error + matches, err = filepath.Glob(path) + if len(matches) > 0 && err == nil { + found = true + break + } + + logrus.Infof("Waiting for %s", path) + time.Sleep(1 * time.Second) + } + + if !found { + return fmt.Errorf("Failed to find %s", path) + } + + if len(matches) == 0 { + return fmt.Errorf("Failed to find %s", path) + } + + if len(matches) > 1 { + return fmt.Errorf("Too many matches for %s, found %d", path, len(matches)) + } + + majorMinor, err := ioutil.ReadFile(matches[0]) + if err != nil { + return err + } + + parts := strings.Split(strings.TrimSpace(string(majorMinor)), ":") + if len(parts) != 2 { + return fmt.Errorf("Invalid major:minor string %s", string(majorMinor)) + } + + major, err := strconv.Atoi(parts[0]) + if err != nil { + return err + } + minor, err := strconv.Atoi(parts[1]) + if err != nil { + return err + } + + logrus.Infof("Creating device %s %d:%d", dev, major, minor) + return mknod(dev, major, minor) +} + +func mknod(device string, major, minor int) error { + var fileMode os.FileMode = 0600 + fileMode |= syscall.S_IFBLK + dev := int((major << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)) + + return syscall.Mknod(device, uint32(fileMode), dev) +} + +func GetDevConfig(volume string) string { + return fmt.Sprintf("file//root/%s", volume) +} + +func getScsiPrefixAndWnn(volume string) (string, string) { + suffix := genSuffix(volume) + loopbackWnn := wwnPrefix + "r0" + suffix + nexusWnn := wwnPrefix + "r1" + suffix + return path.Join(scsiDir, loopbackWnn, "tpgt_1"), nexusWnn +} + +func getLunPath(prefix string) string { + return path.Join(prefix, "lun", "lun_0") +} + +func TeardownTcmu(volume string) error { + var err error + for i := 1; i <= teardownAttempts; i++ { + logrus.Info("Starting TCMU teardown.") + err := teardown(volume) + if err == nil { + logrus.Info("TCMU teardown successful.") + break + } else if i < teardownAttempts { + logrus.Infof("Error occurred during TCMU teardown. Attempting again after %v second sleep. Error: %v", teardownRetryWait, err) + time.Sleep(time.Second * teardownRetryWait) + } + } + return err +} + +func teardown(volume string) error { + dev := devPath + volume + tpgtPath, _ := getScsiPrefixAndWnn(volume) + lunPath := getLunPath(tpgtPath) + + /* + We're removing: + /sys/kernel/config/target/loopback/naa./tpgt_1/lun/lun_0/ + /sys/kernel/config/target/loopback/naa./tpgt_1/lun/lun_0 + /sys/kernel/config/target/loopback/naa./tpgt_1 + /sys/kernel/config/target/loopback/naa. + /sys/kernel/config/target/core/user_42/ + */ + pathsToRemove := []string{ + path.Join(lunPath, volume), + lunPath, + tpgtPath, + path.Dir(tpgtPath), + path.Join(configDir, volume), + } + + for _, p := range pathsToRemove { + err := remove(p) + if err != nil { + return err + } + } + + // Should be cleaned up automatically, but if it isn't remove it + if _, err := os.Stat(dev); err == nil { + err := remove(dev) + if err != nil { + return err + } + } + + return nil +} + +func removeAsync(path string, done chan<- error) { + logrus.Infof("Removing: %s", path) + if err := os.Remove(path); err != nil && !os.IsNotExist(err) { + logrus.Errorf("Unable to remove: %v", path) + done <- err + } + logrus.Debugf("Removed: %s", path) + done <- nil +} + +func remove(path string) error { + done := make(chan error) + go removeAsync(path, done) + select { + case err := <-done: + return err + case <-time.After(30 * time.Second): + return fmt.Errorf("Timeout trying to delete %s.", path) + } +} + +func writeLines(target string, lines []string) error { + dir := path.Dir(target) + if stat, err := os.Stat(dir); os.IsNotExist(err) { + logrus.Infof("Creating directory: %s", dir) + if err := os.MkdirAll(dir, 0755); err != nil { + return err + } + } else if !stat.IsDir() { + return fmt.Errorf("%s is not a directory", dir) + } + + for _, line := range lines { + content := []byte(line + "\n") + logrus.Infof("Setting %s: %s", target, line) + if err := ioutil.WriteFile(target, content, 0755); err != nil { + logrus.Errorf("Failed to write %s to %s: %v", line, target, err) + return err + } + } + + return nil +} + +func genSuffix(volume string) string { + digest := md5.New() + digest.Write([]byte(volume)) + return hex.EncodeToString(digest.Sum([]byte{}))[:8] +} diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index fe54db56..815d58c8 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -1,13 +1,13 @@ -package main +package tcmu /* -#cgo LDFLAGS: -L ./libs -ltcmu -#cgo CFLAGS: -I ./includes +#cgo LDFLAGS: -ltcmu -lnl-3 -lnl-genl-3 -lm #include #include #include -#include "libtcmu.h" +#include +#include extern struct tcmulib_context *tcmu_init(); extern bool tcmu_poll_master_fd(struct tcmulib_context *cxt); @@ -16,56 +16,37 @@ extern void *allocate_buffer(int length); */ import "C" -import "unsafe" - import ( - "net" - "os/signal" + "errors" "sync" - "syscall" + "unsafe" "github.com/Sirupsen/logrus" - - "github.com/yasker/longhorn/block" - "github.com/yasker/longhorn/rpc" - - "flag" - "os" - "runtime/pprof" + "github.com/rancher/longhorn/types" ) var ( - ready bool = false + ready = false log = logrus.WithFields(logrus.Fields{"pkg": "main"}) - address = "localhost:5000" - - cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") - workers = 128 - - sigs chan os.Signal - done chan bool + // this is super dirty + backend types.ReaderWriterAt ) -type TcmuState struct { +type State struct { + sync.Mutex + volume string - client *rpc.Client - conn *net.TCPConn lbas int64 blockSize int - mutex *sync.Mutex - dev TcmuDevice + backend types.ReaderWriterAt } //export shOpen -func shOpen(dev TcmuDevice) int { - var ( - err error - ) - - state := &TcmuState{ - mutex: &sync.Mutex{}, +func shOpen(dev Device) int { + state := &State{ + backend: backend, } blockSizeStr := C.CString("hw_block_size") defer C.free(unsafe.Pointer(blockSizeStr)) @@ -91,47 +72,21 @@ func shOpen(dev TcmuDevice) int { //id := strings.TrimPrefix(cfgString, "file/") //TODO check volume name here - addr, err := net.ResolveTCPAddr("tcp4", address) - if err != nil { - log.Fatalf("failed to resolve ", address, err) - } - state.conn, err = net.DialTCP("tcp", nil, addr) - if err != nil { - log.Fatalf("Cannot connect to replica, %v", err) - } - - state.client = rpc.NewClient(state.conn, 5, workers) - state.dev = dev - - go state.HandleRequest() + go state.HandleRequest(dev) log.Debugln("Device added") - - ready = true return 0 } -func (s *TcmuState) HandleRequest() { - defer s.conn.Close() - - cmds := make(chan TcmuCommand, workers) - wg := sync.WaitGroup{} - wg.Add(workers) - for i := 0; i < workers; i++ { - go func() { - defer wg.Done() - s.processCommands(cmds) - }() - } - +func (s *State) HandleRequest(dev Device) { for true { - C.tcmulib_processing_start(s.dev) - cmd := C.tcmulib_get_next_command(s.dev) + C.tcmulib_processing_start(dev) + cmd := C.tcmulib_get_next_command(dev) for cmd != nil { - cmds <- cmd - cmd = C.tcmulib_get_next_command(s.dev) + go s.processCommand(dev, cmd) + cmd = C.tcmulib_get_next_command(dev) } - ret := C.tcmu_wait_for_next_command(s.dev) + ret := C.tcmu_wait_for_next_command(dev) if ret != 0 { log.Errorln("Fail to wait for next command", ret) break @@ -139,22 +94,18 @@ func (s *TcmuState) HandleRequest() { } } -func (s *TcmuState) handleReadCommand(dev TcmuDevice, cmd TcmuCommand) int { +func (s *State) handleReadCommand(dev Device, cmd Command) int { offset := CmdGetLba(cmd) * int64(s.blockSize) length := CmdGetXferLength(cmd) * s.blockSize - resp, err := s.client.Call(&rpc.Request{ - Header: &block.Request{ - Type: rpc.MSG_TYPE_READ_REQUEST, - Offset: offset, - Length: int64(length), - }}) + buf := make([]byte, length) + _, err := s.backend.ReadAt(buf, offset) if err != nil { log.Errorln("read failed: ", err.Error()) return CmdSetMediumError(cmd) } - copied := CmdMemcpyIntoIovec(cmd, resp.Data, length) + copied := CmdMemcpyIntoIovec(cmd, buf, length) if copied != length { log.Errorln("read failed: unable to complete buffer copy ") return CmdSetMediumError(cmd) @@ -162,11 +113,11 @@ func (s *TcmuState) handleReadCommand(dev TcmuDevice, cmd TcmuCommand) int { return C.SAM_STAT_GOOD } -func (s *TcmuState) handleWriteCommand(dev TcmuDevice, cmd TcmuCommand) int { +func (s *State) handleWriteCommand(dev Device, cmd Command) int { offset := CmdGetLba(cmd) * int64(s.blockSize) length := CmdGetXferLength(cmd) * s.blockSize - buf := make([]byte, length) + buf := make([]byte, length, length) if buf == nil { log.Errorln("read failed: fail to allocate buffer") return CmdSetMediumError(cmd) @@ -177,13 +128,7 @@ func (s *TcmuState) handleWriteCommand(dev TcmuDevice, cmd TcmuCommand) int { return CmdSetMediumError(cmd) } - if _, err := s.client.Call(&rpc.Request{ - Header: &block.Request{ - Type: rpc.MSG_TYPE_WRITE_REQUEST, - Offset: offset, - Length: int64(length), - }, - Data: buf}); err != nil { + if _, err := s.backend.WriteAt(buf, offset); err != nil { log.Errorln("write failed: ", err.Error()) return CmdSetMediumError(cmd) } @@ -191,27 +136,21 @@ func (s *TcmuState) handleWriteCommand(dev TcmuDevice, cmd TcmuCommand) int { return C.SAM_STAT_GOOD } -func (s *TcmuState) processCommands(cmds chan TcmuCommand) { - for cmd := range cmds { - s.processCommand(cmd) - } -} - -func (s *TcmuState) processCommand(cmd TcmuCommand) { - ret := s.handleCommand(cmd) +func (s *State) processCommand(dev Device, cmd Command) { + ret := s.handleCommand(dev, cmd) - s.mutex.Lock() - defer s.mutex.Unlock() + s.Lock() + defer s.Unlock() - C.tcmulib_command_complete(s.dev, cmd, C.int(ret)) - C.tcmulib_processing_complete(s.dev) + C.tcmulib_command_complete(dev, cmd, C.int(ret)) + C.tcmulib_processing_complete(dev) } -func (s *TcmuState) handleCommand(cmd TcmuCommand) int { +func (s *State) handleCommand(dev Device, cmd Command) int { scsiCmd := CmdGetScsiCmd(cmd) switch scsiCmd { case C.INQUIRY: - return CmdEmulateInquiry(cmd, s.dev) + return CmdEmulateInquiry(cmd, dev) case C.TEST_UNIT_READY: return CmdEmulateTestUnitReady(cmd) case C.SERVICE_ACTION_IN_16: @@ -221,9 +160,9 @@ func (s *TcmuState) handleCommand(cmd TcmuCommand) int { case C.MODE_SELECT, C.MODE_SELECT_10: return CmdEmulateModeSelect(cmd) case C.READ_6, C.READ_10, C.READ_12, C.READ_16: - return s.handleReadCommand(s.dev, cmd) + return s.handleReadCommand(dev, cmd) case C.WRITE_6, C.WRITE_10, C.WRITE_12, C.WRITE_16: - return s.handleWriteCommand(s.dev, cmd) + return s.handleWriteCommand(dev, cmd) default: log.Errorf("unknown command 0x%x\n", scsiCmd) } @@ -231,47 +170,25 @@ func (s *TcmuState) handleCommand(cmd TcmuCommand) int { } //export shClose -func shClose(dev TcmuDevice) { +func shClose(dev Device) { log.Debugln("Device removed") } -func handleSignal() { - sig := <-sigs - log.Infoln("Shutting down process, due to received signal ", sig) - pprof.StopCPUProfile() - done <- true -} - -func main() { - logrus.SetLevel(logrus.DebugLevel) - - flag.Parse() - if *cpuprofile != "" { - log.Debug("Output cpuprofile to %v", *cpuprofile) - f, err := os.Create(*cpuprofile) - if err != nil { - log.Fatal(err) - } - pprof.StartCPUProfile(f) - } - - sigs = make(chan os.Signal, 1) - done = make(chan bool, 1) - signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - - go handleSignal() +func start(rw types.ReaderWriterAt) error { + // this is super dirty + backend = rw cxt := C.tcmu_init() if cxt == nil { - panic("cxt is nil") + return errors.New("TCMU ctx is nil") } - for !ready { - result := C.tcmu_poll_master_fd(cxt) - log.Debugln("Poll master fd one more time, last result ", result) - } + go func() { + for !ready { + result := C.tcmu_poll_master_fd(cxt) + log.Debugln("Poll master fd one more time, last result ", result) + } + }() - log.Infoln("Waiting for process") - <-done - log.Infoln("Shutdown complete") + return nil } From dea27d92f2876ef211c7cfce617650d4ff1bc146 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 18 Apr 2016 22:54:16 -0700 Subject: [PATCH 005/357] Fix memory issue --- rpc/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/rpc/client.go b/rpc/client.go index ba845236..4dba54b9 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -93,6 +93,7 @@ func (c *Client) handleRequest(req *Message) { func (c *Client) handleResponse(resp *Message) { if req, ok := c.messages[resp.Seq]; ok { + delete(c.messages, resp.Seq) // can probably optimize away this copy if len(resp.Data) > 0 { copy(req.Data, resp.Data) From 62e2412945076fdf6451042b65af7a2ee396a90e Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 18 Apr 2016 22:54:44 -0700 Subject: [PATCH 006/357] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80b278e2..a2aa577d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A microservice that does micro things. ## Running ./bin/longhorn replica --size 10g /opt/volume - ./bin/longhorn controller --frontend tcmu vol-name --replica tcp://localhost:9052 + ./bin/longhorn controller --frontend tcmu --replica tcp://localhost:9502 vol-name That will create the device `/dev/longhorn/vol-name` From 2d413cee156940a6b8697015ff99c43c6a342052 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 19 Apr 2016 14:36:05 -0700 Subject: [PATCH 007/357] Don't show `unknown scsi commands` as error --- frontend/tcmu/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index 815d58c8..64904c37 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -164,7 +164,7 @@ func (s *State) handleCommand(dev Device, cmd Command) int { case C.WRITE_6, C.WRITE_10, C.WRITE_12, C.WRITE_16: return s.handleWriteCommand(dev, cmd) default: - log.Errorf("unknown command 0x%x\n", scsiCmd) + log.Debugf("Ignore unknown SCSI command 0x%x\n", scsiCmd) } return C.TCMU_NOT_HANDLED } From f70c6014c5899ea5aa46786a852c69cb945e6478 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 19 Apr 2016 11:47:54 -0700 Subject: [PATCH 008/357] Add controller client --- client/controller_client.go | 108 ++++++++++++++++++++++++++++++++++++ controller/rest/model.go | 19 +++++++ controller/rest/replica.go | 5 ++ 3 files changed, 132 insertions(+) create mode 100644 client/controller_client.go diff --git a/client/controller_client.go b/client/controller_client.go new file mode 100644 index 00000000..9bbb5391 --- /dev/null +++ b/client/controller_client.go @@ -0,0 +1,108 @@ +package client + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/controller/rest" +) + +type ControllerClient struct { + controller string +} + +func NewControllerClient(controller string) *ControllerClient { + if !strings.HasSuffix(controller, "/v1") { + controller += "/v1" + } + return &ControllerClient{ + controller: controller, + } +} + +func (c *ControllerClient) Start(replicas ...string) error { + volume, err := c.GetVolume() + if err != nil { + return err + } + + return c.post(volume.Actions["start"], rest.StartInput{ + Replicas: replicas, + }, nil) +} + +func (c *ControllerClient) ListReplicas() ([]rest.Replica, error) { + var resp rest.ReplicaCollection + err := c.get("/replicas", &resp) + return resp.Data, err +} + +func (c *ControllerClient) CreateReplica(address string) (*rest.Replica, error) { + var resp rest.Replica + err := c.post("/replicas", &rest.Replica{ + Address: address, + }, &resp) + return &resp, err +} + +func (c *ControllerClient) GetVolume() (*rest.Volume, error) { + var volumes rest.VolumeCollection + + err := c.get("/volumes", &volumes) + if err != nil { + return nil, err + } + + if len(volumes.Data) == 0 { + return nil, errors.New("No volume found") + } + + return &volumes.Data[0], nil +} + +func (c *ControllerClient) post(path string, req, resp interface{}) error { + b, err := json.Marshal(req) + if err != nil { + return err + } + + bodyType := "application/json" + url := path + if !strings.HasPrefix(url, "http") { + url = c.controller + path + } + + logrus.Debugf("POST %s", url) + httpResp, err := http.Post(url, bodyType, bytes.NewBuffer(b)) + if err != nil { + return err + } + defer httpResp.Body.Close() + + if httpResp.StatusCode >= 300 { + content, _ := ioutil.ReadAll(httpResp.Body) + return fmt.Errorf("Bad response: %d %s: %s", httpResp.StatusCode, httpResp.Status, content) + } + + if resp == nil { + return nil + } + + return json.NewDecoder(httpResp.Body).Decode(resp) +} + +func (c *ControllerClient) get(path string, obj interface{}) error { + resp, err := http.Get(c.controller + path) + if err != nil { + return err + } + defer resp.Body.Close() + + return json.NewDecoder(resp.Body).Decode(obj) +} diff --git a/controller/rest/model.go b/controller/rest/model.go index 65d35ab4..1f2a495f 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -21,6 +21,16 @@ type Volume struct { ReplicaCount int `json:"replicaCount"` } +type VolumeCollection struct { + client.Collection + Data []Volume `json:"data"` +} + +type ReplicaCollection struct { + client.Collection + Data []Replica `json:"data"` +} + type StartInput struct { client.Resource Replicas []string `json:"replicas"` @@ -71,11 +81,20 @@ func NewSchema() *client.Schemas { schemas.AddType("error", client.ServerApiError{}) schemas.AddType("apiVersion", client.Resource{}) schemas.AddType("schema", client.Schema{}) + schemas.AddType("startInput", StartInput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} replica.ResourceMethods = []string{"GET", "PUT"} + f := replica.ResourceFields["address"] + f.Create = true + replica.ResourceFields["address"] = f + + f = replica.ResourceFields["mode"] + f.Update = true + replica.ResourceFields["mode"] = f + volumes := schemas.AddType("volume", Volume{}) volumes.ResourceActions = map[string]client.Action{ "start": client.Action{ diff --git a/controller/rest/replica.go b/controller/rest/replica.go index d9abb6bb..5d4663d6 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -16,6 +16,11 @@ func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { resp.Data = append(resp.Data, NewReplica(r.Address, r.Mode)) } + resp.ResourceType = "replica" + resp.CreateTypes = map[string]string{ + "replica": apiContext.UrlBuilder.Collection("replica"), + } + apiContext.Write(&resp) return nil } From 780fe5e664793a3f819a11e027b019a1c2de9437 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 19 Apr 2016 19:58:01 -0700 Subject: [PATCH 009/357] Add replica/rebuild --- Dockerfile.dapper | 18 ++- README.md | 28 ++++- app/add_replica.go | 44 +++++++ app/replica.go | 4 + app/sync_agent.go | 67 +++++++++++ backend/file/file.go | 3 +- client/controller_client.go | 24 +++- client/replica_client.go | 163 +++++++++++++++++++++++++ integration/core/test_cli.py | 146 ++++++++++++++++++++++ main.go | 2 + replica/rest/model.go | 2 +- scripts/integration-test | 21 +++- scripts/test | 4 + sync/agent/model.go | 40 ++++++ sync/agent/process.go | 169 ++++++++++++++++++++++++++ sync/agent/router.go | 37 ++++++ sync/sync.go | 227 +++++++++++++++++++++++++++++++++++ 17 files changed, 987 insertions(+), 12 deletions(-) create mode 100644 app/add_replica.go create mode 100644 app/sync_agent.go create mode 100644 client/replica_client.go create mode 100644 integration/core/test_cli.py create mode 100644 sync/agent/model.go create mode 100644 sync/agent/process.go create mode 100644 sync/agent/router.go create mode 100644 sync/sync.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 2c109319..40eede7d 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -14,20 +14,21 @@ WORKDIR ${DAPPER_SOURCE} # Install packages RUN apt-get update && \ apt-get install -y \ + cmake \ curl \ git \ - python-tox \ - cmake \ - pkg-config \ libglib2.0-dev \ libkmod-dev \ libnl-genl-3-dev \ - linux-libc-dev + linux-libc-dev \ + pkg-config \ + psmisc \ + python-tox # Install Go 1.6 RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz RUN echo '6d894da8b4ad3f7f6c295db0d73ccc3646bce630e1c43e662a0120681d47e988 go.tar.gz' | sha256sum -c && \ - tar xvzf go.tar.gz -C /usr/local && \ + tar xzf go.tar.gz -C /usr/local && \ rm go.tar.gz RUN mkdir -p /go ENV PATH $PATH:/usr/local/go/bin @@ -53,5 +54,12 @@ RUN cd /usr/src/tcmu-runner && \ cp scsi_defs.h /usr/local/include && \ cp libtcmu_static.a /usr/local/lib/libtcmu.a +# Install ssync +RUN go get -d github.com/kp6/alphorn/ssync && \ + cd $GOPATH/src/github.com/kp6/alphorn && \ + git clone https://github.com/kp6/alphorn.git && \ + cd ssync && \ + go build -o /usr/local/bin/ssync + ENTRYPOINT ["./scripts/entry"] CMD ["build"] diff --git a/README.md b/README.md index a2aa577d..40b0b6e6 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,40 @@ A microservice that does micro things. `make` - ## Running +You need to be running RancherOS v0.4.4 (all kernel patches are not yet fully upstreamed). +Also ensure that TCMU is enabled: + + modprobe target_core_user + mount -t configfs none /sys/kernel/config + +Then run + ./bin/longhorn replica --size 10g /opt/volume ./bin/longhorn controller --frontend tcmu --replica tcp://localhost:9502 vol-name That will create the device `/dev/longhorn/vol-name` +## Add Replica/Rebuild + +To add a live replica needs the sync agent to be running. The replica runs by default on port +9502 and 9053. 9502 is the HTTP control port and 9503 is the data path. The sync agent must run +on the next port, which is 9503 by default. You must run the sync agent for each running replica and +in the same folder as the replica. For example: + + ./bin/longhorn replica --size 10g /opt/volume & + cd /opt/volume + $OLDPWD/bin/longhorn sync-agent & + +You also need to install `ssync` to your $PATH. The code for that is available at https://github.com/kp6/alphorn/tree/master/ssync + +To perform the actual add replica/rebuild run the below command + + ./bin/longhorn add-replica tcp://123.123.123.123:9502 + +If that program exist with exit code 0, then it worked. + ## License Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) diff --git a/app/add_replica.go b/app/add_replica.go new file mode 100644 index 00000000..c211493d --- /dev/null +++ b/app/add_replica.go @@ -0,0 +1,44 @@ +package app + +import ( + "errors" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/rancher/longhorn/sync" +) + +func AddReplicaCmd() cli.Command { + return cli.Command{ + Name: "add-replica", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "url", + Value: "http://localhost:9501", + }, + cli.BoolFlag{ + Name: "debug", + }, + }, + Action: func(c *cli.Context) { + if err := addReplica(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func addReplica(c *cli.Context) error { + if c.NArg() == 0 { + return errors.New("replica address is required") + } + replica := c.Args()[0] + + url := c.String("url") + if c.Bool("debug") { + logrus.SetLevel(logrus.DebugLevel) + } + + task := sync.NewTask(url) + return task.AddReplica(replica) +} diff --git a/app/replica.go b/app/replica.go index 1e22eec5..b863deaf 100644 --- a/app/replica.go +++ b/app/replica.go @@ -45,6 +45,10 @@ func startReplica(c *cli.Context) error { return errors.New("directory name is required") } + if c.Bool("debug") { + logrus.SetLevel(logrus.DebugLevel) + } + dir := c.Args()[0] s := replica.NewServer(dir, 4096) diff --git a/app/sync_agent.go b/app/sync_agent.go new file mode 100644 index 00000000..96f2eaaa --- /dev/null +++ b/app/sync_agent.go @@ -0,0 +1,67 @@ +package app + +import ( + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/rancher/longhorn/sync/agent" +) + +func SyncAgentCmd() cli.Command { + return cli.Command{ + Name: "sync-agent", + UsageText: "longhorn controller DIRECTORY SIZE", + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "debug", + }, + cli.StringFlag{ + Name: "listen", + Value: "localhost:9504", + }, + cli.StringFlag{ + Name: "listen-port-range", + Value: "9700-9800", + }, + }, + Action: func(c *cli.Context) { + if err := startSyncAgent(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func startSyncAgent(c *cli.Context) error { + if c.Bool("debug") { + logrus.SetLevel(logrus.DebugLevel) + } + + listen := c.String("listen") + portRange := c.String("listen-port-range") + + parts := strings.Split(portRange, "-") + if len(parts) != 2 { + return fmt.Errorf("Invalid format for range: %s", portRange) + } + + start, err := strconv.Atoi(strings.TrimSpace(parts[0])) + if err != nil { + return err + } + + end, err := strconv.Atoi(strings.TrimSpace(parts[1])) + if err != nil { + return err + } + + server := agent.NewServer(start, end) + router := agent.NewRouter(server) + logrus.Infof("Listening on %s", listen) + + return http.ListenAndServe(listen, router) +} diff --git a/backend/file/file.go b/backend/file/file.go index 1e6e35e0..fe5dbb2f 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -2,7 +2,6 @@ package file import ( "os" - "syscall" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" @@ -38,7 +37,7 @@ func (f *Wrapper) Size() (int64, error) { func (ff *Factory) Create(address string) (types.Backend, error) { logrus.Infof("Creating file: %s", address) - file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE|syscall.O_DIRECT, 0600) + file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE, 0600) if err != nil { logrus.Infof("Failed to create file %s: %v", address, err) return nil, err diff --git a/client/controller_client.go b/client/controller_client.go index 9bbb5391..107987a1 100644 --- a/client/controller_client.go +++ b/client/controller_client.go @@ -51,6 +51,12 @@ func (c *ControllerClient) CreateReplica(address string) (*rest.Replica, error) return &resp, err } +func (c *ControllerClient) UpdateReplica(replica rest.Replica) (rest.Replica, error) { + var resp rest.Replica + err := c.put(replica.Links["self"], &replica, &resp) + return resp, err +} + func (c *ControllerClient) GetVolume() (*rest.Volume, error) { var volumes rest.VolumeCollection @@ -67,6 +73,14 @@ func (c *ControllerClient) GetVolume() (*rest.Volume, error) { } func (c *ControllerClient) post(path string, req, resp interface{}) error { + return c.do("POST", path, req, resp) +} + +func (c *ControllerClient) put(path string, req, resp interface{}) error { + return c.do("PUT", path, req, resp) +} + +func (c *ControllerClient) do(method, path string, req, resp interface{}) error { b, err := json.Marshal(req) if err != nil { return err @@ -78,8 +92,14 @@ func (c *ControllerClient) post(path string, req, resp interface{}) error { url = c.controller + path } - logrus.Debugf("POST %s", url) - httpResp, err := http.Post(url, bodyType, bytes.NewBuffer(b)) + logrus.Debugf("%s %s", method, url) + httpReq, err := http.NewRequest(method, url, bytes.NewBuffer(b)) + if err != nil { + return err + } + httpReq.Header.Set("Content-Type", bodyType) + + httpResp, err := http.DefaultClient.Do(httpReq) if err != nil { return err } diff --git a/client/replica_client.go b/client/replica_client.go new file mode 100644 index 00000000..6526d6c0 --- /dev/null +++ b/client/replica_client.go @@ -0,0 +1,163 @@ +package client + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/replica/rest" + "github.com/rancher/longhorn/sync/agent" +) + +type ReplicaClient struct { + address string + syncAgent string + host string +} + +func NewReplicaClient(address string) (*ReplicaClient, error) { + if strings.HasPrefix(address, "tcp://") { + address = address[6:] + } + + if !strings.HasPrefix(address, "http") { + address = "http://" + address + } + + if !strings.HasSuffix(address, "/v1") { + address += "/v1" + } + + u, err := url.Parse(address) + if err != nil { + return nil, err + } + + parts := strings.Split(u.Host, ":") + if len(parts) < 2 { + return nil, fmt.Errorf("Invalid address %s, must have a port in it", address) + } + + port, err := strconv.Atoi(parts[1]) + if err != nil { + return nil, err + } + + syncAgent := strings.Replace(address, fmt.Sprintf(":%d", port), fmt.Sprintf(":%d", port+2), -1) + + return &ReplicaClient{ + host: parts[0], + address: address, + syncAgent: syncAgent, + }, nil +} + +func (c *ReplicaClient) GetReplica() (rest.Replica, error) { + var replica rest.Replica + + err := c.get(c.address+"/replicas/1", &replica) + return replica, err +} + +func (c *ReplicaClient) ReloadReplica() (rest.Replica, error) { + var replica rest.Replica + + err := c.post(c.address+"/replicas/1?action=reload", map[string]string{}, &replica) + return replica, err +} + +func (c *ReplicaClient) LaunchReceiver() (string, int, error) { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{}, &running) + if err != nil { + return "", 0, err + } + + return c.host, running.Port, nil +} + +func (c *ReplicaClient) SendFile(from, to, host string, port int) error { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + Host: host, + SrcFile: from, + DestFile: to, + Port: port, + }, &running) + if err != nil { + return err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return nil + default: + return fmt.Errorf("ExitCode: %d", running.ExitCode) + } + } +} + +func (c *ReplicaClient) get(url string, obj interface{}) error { + if !strings.HasPrefix(url, "http") { + url = c.address + url + } + + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + + return json.NewDecoder(resp.Body).Decode(obj) +} + +func (c *ReplicaClient) post(path string, req, resp interface{}) error { + b, err := json.Marshal(req) + if err != nil { + return err + } + + bodyType := "application/json" + url := path + if !strings.HasPrefix(url, "http") { + url = c.address + path + } + + logrus.Debugf("POST %s", url) + httpResp, err := http.Post(url, bodyType, bytes.NewBuffer(b)) + if err != nil { + return err + } + defer httpResp.Body.Close() + + if httpResp.StatusCode >= 300 { + content, _ := ioutil.ReadAll(httpResp.Body) + return fmt.Errorf("Bad response: %d %s: %s", httpResp.StatusCode, httpResp.Status, content) + } + + if resp == nil { + return nil + } + + return json.NewDecoder(httpResp.Body).Decode(resp) +} diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py new file mode 100644 index 00000000..3e4cad9b --- /dev/null +++ b/integration/core/test_cli.py @@ -0,0 +1,146 @@ +import time +import random +from os import path +import subprocess + +import pytest +import cattle + + +REPLICA = 'tcp://localhost:9502' +REPLICA2 = 'tcp://localhost:9505' + + +@pytest.fixture +def controller_client(request): + url = 'http://localhost:9501/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup_controller(c)) + c = cleanup_controller(c) + assert c.list_volume()[0].replicaCount == 0 + return c + + +def cleanup_controller(client): + for r in client.list_replica(): + client.delete(r) + return client + + +@pytest.fixture +def replica_client(request): + url = 'http://localhost:9502/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup_replica(c)) + return cleanup_replica(c) + + +@pytest.fixture +def replica_client2(request): + url = 'http://localhost:9505/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup_replica(c)) + return cleanup_replica(c) + + +def cleanup_replica(client): + for r in client.list_replica(): + if 'close' in r: + client.delete(r) + else: + client.delete(r.open(size=str(1024*1024))) + return client + + +@pytest.fixture +def random_str(): + return 'random-{0}-{1}'.format(random_num(), int(time.time())) + + +def random_num(): + return random.randint(0, 1000000) + + +def _file(f): + return path.join(_base(), '../../{}'.format(f)) + + +def _base(): + return path.dirname(__file__) + + +@pytest.fixture(scope='session') +def bin(): + c = _file('bin/longhorn') + assert path.exists(c) + return c + + +def open_replica(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + assert r.state == 'closed' + assert r.size == '' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + r = r.open(size=str(1024*4096)) + + assert r.state == 'open' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + return r + + +def test_replica_add_start(bin, controller_client, replica_client): + open_replica(replica_client) + + cmd = [bin, 'add-replica', '--debug', REPLICA] + subprocess.check_call(cmd) + + volume = controller_client.list_volume()[0] + assert volume.replicaCount == 1 + + +def test_replica_add_rebuild(bin, controller_client, replica_client, + replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + r = replica_client.list_replica()[0] + r = r.snapshot() + r = r.snapshot() + + l = replica_client2.list_replica()[0] + + assert r.chain == ['volume-head-002.img', + 'volume-snap-001.img', + 'volume-snap-000.img'] + + assert l.chain != ['volume-head-002.img', + 'volume-snap-001.img', + 'volume-snap-000.img'] + + cmd = [bin, 'add-replica', '--debug', REPLICA] + subprocess.check_call(cmd) + + volume = controller_client.list_volume()[0] + assert volume.replicaCount == 1 + + cmd = [bin, 'add-replica', '--debug', REPLICA2] + subprocess.check_call(cmd) + + volume = controller_client.list_volume()[0] + assert volume.replicaCount == 2 + + replicas = controller_client.list_replica() + assert len(replicas) == 2 + + for r in replicas: + assert r.mode == 'RW' diff --git a/main.go b/main.go index cc3c3f74..b006133f 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,8 @@ func main() { a.Commands = []cli.Command{ app.ControllerCmd(), app.ReplicaCmd(), + app.AddReplicaCmd(), + app.SyncAgentCmd(), } a.Run(os.Args) diff --git a/replica/rest/model.go b/replica/rest/model.go index 649dd945..0ce12476 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -15,7 +15,7 @@ const ( type Replica struct { client.Resource - Dirty bool `json:"dirtry"` + Dirty bool `json:"dirty"` Head string `json:"head"` Parent string `json:"parent"` Size string `json:"size"` diff --git a/scripts/integration-test b/scripts/integration-test index 9465d054..38709b65 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -1,12 +1,31 @@ #!/bin/bash set -e +killall longhorn ssync || true + temp=$(mktemp -d) -trap "rm -rf $temp" EXIT +temp2=$(mktemp -d) +trap "rm -rf $temp $temp2" EXIT cd $(dirname $0)/.. + +if [ ! -x ./bin/longhorn ]; then + ./scripts/build +fi + ./bin/longhorn controller --enable-backend file test-volume & ./bin/longhorn replica $temp & +./bin/longhorn replica --listen localhost:9505 $temp2 & +( + mkdir -p $temp + cd $temp + $OLDPWD/bin/longhorn sync-agent --listen localhost:9504 --listen-port-range 5000-5500 & +) +( + mkdir -p $temp2 + cd $temp2 + $OLDPWD/bin/longhorn sync-agent --listen localhost:9507 --listen-port-range 5501-6000 & +) cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; tox diff --git a/scripts/test b/scripts/test index 4a6795b8..d7f05fe1 100755 --- a/scripts/test +++ b/scripts/test @@ -5,6 +5,10 @@ cd $(dirname $0)/.. echo Running tests +if [ ! -x ./bin/longhorn ]; then + ./scripts/build +fi + PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" go test -race -cover -tags=test ${PACKAGES} diff --git a/sync/agent/model.go b/sync/agent/model.go new file mode 100644 index 00000000..c298be31 --- /dev/null +++ b/sync/agent/model.go @@ -0,0 +1,40 @@ +package agent + +import ( + "time" + + "github.com/rancher/go-rancher/client" +) + +type Process struct { + client.Resource + SrcFile string `json:"srcFile"` + DestFile string `json:"destfile"` + Host string `json:"host"` + Port int `json:"port"` + ExitCode int `json:"exitCode"` + Created time.Time `json:"created"` +} + +type ProcessCollection struct { + client.Collection + Data []Process `json:"data"` +} + +func NewSchema() *client.Schemas { + schemas := &client.Schemas{} + + schemas.AddType("error", client.ServerApiError{}) + schemas.AddType("apiVersion", client.Resource{}) + schemas.AddType("schema", client.Schema{}) + process := schemas.AddType("process", Process{}) + process.CollectionMethods = []string{"GET", "POST"} + + for _, name := range []string{"file", "host", "port"} { + f := process.ResourceFields[name] + f.Create = true + process.ResourceFields[name] = f + } + + return schemas +} diff --git a/sync/agent/process.go b/sync/agent/process.go new file mode 100644 index 00000000..b79066b5 --- /dev/null +++ b/sync/agent/process.go @@ -0,0 +1,169 @@ +package agent + +import ( + "errors" + "net/http" + "os" + "os/exec" + "strconv" + "sync" + "syscall" + + "github.com/Sirupsen/logrus" + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +type Server struct { + sync.Mutex + + processCounter int + currentPort int + startPort, endPort int + nextProcess int + processes map[string]*Process + processesByPort map[int]*Process +} + +func NewServer(start, end int) *Server { + return &Server{ + currentPort: start, + startPort: start, + endPort: end, + processes: map[string]*Process{}, + processesByPort: map[int]*Process{}, + } +} + +func (s *Server) ListProcesses(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + resp := ProcessCollection{ + Collection: client.Collection{ + ResourceType: "process", + }, + } + + s.Lock() + for _, p := range s.processes { + resp.Data = append(resp.Data, *p) + } + s.Unlock() + + apiContext.Write(&resp) + return nil +} + +func (s *Server) GetProcess(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + s.Lock() + p, ok := s.processes[id] + s.Unlock() + + if ok { + apiContext.Write(&p) + } else { + rw.WriteHeader(http.StatusNotFound) + } + + return nil +} + +func (s *Server) CreateProcess(rw http.ResponseWriter, req *http.Request) error { + var p Process + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&p); err != nil { + return err + } + + s.Lock() + + if p.SrcFile == "" { + var err error + p.Port, err = s.nextPort() + if err != nil { + s.Unlock() + return err + } + } + + s.processCounter++ + id := strconv.Itoa(s.processCounter) + p.Id = id + p.Type = "process" + s.processes[p.Id] = &p + s.processesByPort[p.Port] = &p + + s.Unlock() + + p.ExitCode = -2 + go s.launch(&p) + + apiContext.Write(&p) + return nil +} + +func (s *Server) launch(p *Process) error { + args := []string{} + if p.Host != "" { + args = append(args, "-host", p.Host) + } + if p.Port != 0 { + args = append(args, "-port", strconv.Itoa(p.Port)) + } + if p.SrcFile == "" { + args = append(args, "-daemon") + } else { + args = append(args, p.SrcFile) + if p.DestFile != "" { + args = append(args, p.DestFile) + } + } + + cmd := exec.Command("ssync", args...) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Start() + + logrus.Infof("Running %s %v", "ssync", args) + err := cmd.Wait() + if err != nil { + logrus.Infof("Error running %s %v: %v", "ssync", args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "ssync", args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v", "ssync", args) + return nil +} + +func (s *Server) nextPort() (int, error) { + // Must be called with s.Lock() obtained + for i := 0; i < (s.endPort - s.startPort + 1); i++ { + port := s.currentPort + s.currentPort++ + if s.currentPort > s.endPort { + s.currentPort = s.startPort + } + + if _, ok := s.processesByPort[port]; ok { + continue + } + + return port, nil + } + + return 0, errors.New("Out of ports") +} diff --git a/sync/agent/router.go b/sync/agent/router.go new file mode 100644 index 00000000..f8b80cb4 --- /dev/null +++ b/sync/agent/router.go @@ -0,0 +1,37 @@ +package agent + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { + return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if err := t(rw, req); err != nil { + apiContext := api.GetApiContext(req) + apiContext.WriteErr(err) + } + })) +} + +func NewRouter(s *Server) *mux.Router { + schemas := NewSchema() + router := mux.NewRouter().StrictSlash(true) + f := HandleError + + // API framework routes + router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) + router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) + router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) + router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + + // Process + router.Methods("GET").Path("/v1/processes").Handler(f(schemas, s.ListProcesses)) + router.Methods("GET").Path("/v1/processes/{id}").Handler(f(schemas, s.GetProcess)) + router.Methods("POST").Path("/v1/processes").Handler(f(schemas, s.CreateProcess)) + + return router +} diff --git a/sync/sync.go b/sync/sync.go new file mode 100644 index 00000000..5f7ad7bd --- /dev/null +++ b/sync/sync.go @@ -0,0 +1,227 @@ +package sync + +import ( + "fmt" + "reflect" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/client" + "github.com/rancher/longhorn/controller/rest" +) + +type Task struct { + client *client.ControllerClient +} + +func NewTask(controller string) *Task { + return &Task{ + client: client.NewControllerClient(controller), + } +} + +func (t *Task) AddReplica(replica string) error { + volume, err := t.client.GetVolume() + if err != nil { + return err + } + + if volume.ReplicaCount == 0 { + return t.client.Start(replica) + } + + logrus.Infof("Adding replica %s in WO mode", replica) + _, err = t.client.CreateReplica(replica) + if err != nil { + return err + } + + fromClient, toClient, err := t.getTransferClients(replica) + if err != nil { + return err + } + + if err := t.syncFiles(fromClient, toClient); err != nil { + return err + } + + if err := t.reloadAndCheck(fromClient, toClient); err != nil { + return err + } + + return t.setRw(replica) +} + +func (t *Task) setRw(replica string) error { + to, err := t.getToReplica(replica) + if err != nil { + return err + } + + to.Mode = "RW" + + to, err = t.client.UpdateReplica(to) + if err != nil { + return err + } + + if to.Mode != "RW" { + return fmt.Errorf("Failed to set replica to RW, in mode %s", to.Mode) + } + + return nil +} + +func (t *Task) reloadAndCheck(fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { + from, err := fromClient.GetReplica() + if err != nil { + return err + } + + to, err := toClient.ReloadReplica() + if err != nil { + return err + } + + fromChain := from.Chain[1:] + toChain := to.Chain[1:] + + if reflect.DeepEqual(fromChain, toChain) { + return fmt.Errorf("Chains are not equal: %v != %v", fromChain, toChain) + } + + return nil +} + +func (t *Task) syncFiles(fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { + from, err := fromClient.GetReplica() + if err != nil { + return err + } + + to, err := fromClient.GetReplica() + if err != nil { + return err + } + + fromHead := "" + toHead := "" + + for _, i := range from.Chain { + if strings.Contains(i, "volume-head") { + if fromHead != "" { + return fmt.Errorf("More than one head volume found in the from replica %s, %s", fromHead, i) + } + fromHead = i + continue + } + + if err := t.syncFile(i, "", fromClient, toClient); err != nil { + return err + } + + if err := t.syncFile(i+".meta", "", fromClient, toClient); err != nil { + return err + } + } + + for _, i := range to.Chain { + if strings.Contains(i, "volume-head") { + if toHead != "" { + return fmt.Errorf("More than one head volume found in the to replica %s, %s", toHead, i) + } + toHead = i + continue + } + } + + if fromHead == "" || toHead == "" { + return fmt.Errorf("Failed to find both source and destination head volumes, %s, %s", fromHead, toHead) + } + + if err := t.syncFile(fromHead+".meta", toHead+".meta", fromClient, toClient); err != nil { + return err + } + + return nil +} + +func (t *Task) syncFile(from, to string, fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { + host, port, err := toClient.LaunchReceiver() + if err != nil { + return err + } + + if to == "" { + to = from + } + + logrus.Infof("Synchronizing %s to %s@%s:%d", from, to, host, port) + err = fromClient.SendFile(from, to, host, port) + if err != nil { + logrus.Infof("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err) + } else { + logrus.Infof("Done synchronizing %s to %s@%s:%d", from, to, host, port) + } + + return err +} + +func (t *Task) getTransferClients(address string) (*client.ReplicaClient, *client.ReplicaClient, error) { + from, err := t.getFromReplica() + if err != nil { + return nil, nil, err + } + logrus.Infof("Using replica %s as the source for rebuild ", from.Address) + + fromClient, err := client.NewReplicaClient(from.Address) + if err != nil { + return nil, nil, err + } + + to, err := t.getToReplica(address) + if err != nil { + return nil, nil, err + } + logrus.Infof("Using replica %s as the target for rebuild ", to.Address) + + toClient, err := client.NewReplicaClient(to.Address) + if err != nil { + return nil, nil, err + } + + return fromClient, toClient, nil +} + +func (t *Task) getFromReplica() (rest.Replica, error) { + replicas, err := t.client.ListReplicas() + if err != nil { + return rest.Replica{}, err + } + + for _, r := range replicas { + if r.Mode == "RW" { + return r, nil + } + } + + return rest.Replica{}, fmt.Errorf("Failed to find good replica to copy from") +} + +func (t *Task) getToReplica(address string) (rest.Replica, error) { + replicas, err := t.client.ListReplicas() + if err != nil { + return rest.Replica{}, err + } + + for _, r := range replicas { + if r.Address == address { + if r.Mode != "WO" { + return rest.Replica{}, fmt.Errorf("Replica %s is not in mode WO got: %s", address, r.Mode) + } + return r, nil + } + } + + return rest.Replica{}, fmt.Errorf("Failed to find target replica to copy to") +} From 73204e964c0c9a5e17f58135c500206aea2cca2c Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 20 Apr 2016 21:31:21 -0700 Subject: [PATCH 010/357] Add error handling, cli ls/rm/add --- README.md | 27 ++++---- app/add_replica.go | 3 +- app/controller.go | 5 ++ app/ls_replica.go | 70 +++++++++++++++++++ app/replica.go | 31 ++++++++- app/rm_replica.go | 44 ++++++++++++ app/shutdown.go | 32 +++++++++ app/sync_agent.go | 2 +- backend/remote/remote.go | 4 +- client/controller_client.go | 27 ++++++++ controller/control.go | 47 +++++++++++-- controller/multi_writer_at.go | 15 ++++- controller/replicator.go | 123 +++++++++++++++++++++++++++++----- main.go | 4 +- replica/replica.go | 15 +++-- rpc/client.go | 41 ++++++++++-- rpc/server.go | 4 +- rpc/types.go | 9 +-- rpc/wire.go | 6 ++ scripts/integration-test | 10 --- sync/sync.go | 4 +- util/util.go | 8 ++- 22 files changed, 456 insertions(+), 75 deletions(-) create mode 100644 app/ls_replica.go create mode 100644 app/rm_replica.go create mode 100644 app/shutdown.go diff --git a/README.md b/README.md index 40b0b6e6..2403f020 100644 --- a/README.md +++ b/README.md @@ -18,28 +18,29 @@ Also ensure that TCMU is enabled: Then run ./bin/longhorn replica --size 10g /opt/volume - ./bin/longhorn controller --frontend tcmu --replica tcp://localhost:9502 vol-name + ./bin/longhorn replica --size 10g --listen localhost:9505 /opt/volume2 + ./bin/longhorn controller --frontend tcmu --replica tcp://localhost:9502 --replica tcp://localhost:9505 vol-name That will create the device `/dev/longhorn/vol-name` -## Add Replica/Rebuild +## Ports -To add a live replica needs the sync agent to be running. The replica runs by default on port -9502 and 9053. 9502 is the HTTP control port and 9503 is the data path. The sync agent must run -on the next port, which is 9503 by default. You must run the sync agent for each running replica and -in the same folder as the replica. For example: +Each replica uses three consequetive ports. By default they are 9502, 9503, and 9504. They are used for +controll channel, data channel, and sync communication respectively. - ./bin/longhorn replica --size 10g /opt/volume & - cd /opt/volume - $OLDPWD/bin/longhorn sync-agent & +## CLI -You also need to install `ssync` to your $PATH. The code for that is available at https://github.com/kp6/alphorn/tree/master/ssync +List replicas -To perform the actual add replica/rebuild run the below command + longhorn ls - ./bin/longhorn add-replica tcp://123.123.123.123:9502 +Remove replica -If that program exist with exit code 0, then it worked. + longhorn rm tcp://localhost:9502 + +Add replica + + longhorn add tcp://localhost:9502 ## License Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) diff --git a/app/add_replica.go b/app/add_replica.go index c211493d..33895e06 100644 --- a/app/add_replica.go +++ b/app/add_replica.go @@ -10,7 +10,8 @@ import ( func AddReplicaCmd() cli.Command { return cli.Command{ - Name: "add-replica", + Name: "add-replica", + ShortName: "add", Flags: []cli.Flag{ cli.StringFlag{ Name: "url", diff --git a/app/controller.go b/app/controller.go index a97f7a00..422aa235 100644 --- a/app/controller.go +++ b/app/controller.go @@ -104,5 +104,10 @@ func startController(c *cli.Context) error { } logrus.Infof("Listening on %s", listen) + + addShutdown(func() { + control.Shutdown() + }) + return http.ListenAndServe(listen, router) } diff --git a/app/ls_replica.go b/app/ls_replica.go new file mode 100644 index 00000000..5268cb3c --- /dev/null +++ b/app/ls_replica.go @@ -0,0 +1,70 @@ +package app + +import ( + "fmt" + "os" + "text/tabwriter" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/rancher/longhorn/client" +) + +func LsReplicaCmd() cli.Command { + return cli.Command{ + Name: "ls-replica", + ShortName: "ls", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "url", + Value: "http://localhost:9501", + }, + cli.BoolFlag{ + Name: "debug", + }, + }, + Action: func(c *cli.Context) { + if err := lsReplica(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func getCli(c *cli.Context) *client.ControllerClient { + url := c.String("url") + return client.NewControllerClient(url) + +} + +func lsReplica(c *cli.Context) error { + controllerClient := getCli(c) + + reps, err := controllerClient.ListReplicas() + if err != nil { + return err + } + + tw := tabwriter.NewWriter(os.Stdout, 0, 20, 1, ' ', 0) + for _, r := range reps { + chain := interface{}("") + repClient, err := client.NewReplicaClient(r.Address) + if err != nil { + chain = err.Error() + } + + if chain == "" { + r, err := repClient.GetReplica() + if err == nil { + chain = r.Chain + } else { + chain = err.Error() + } + } + + fmt.Fprintf(tw, "%s\t%s\t%v\n", r.Address, r.Mode, chain) + } + tw.Flush() + + return nil +} diff --git a/app/replica.go b/app/replica.go index b863deaf..7dd77a4a 100644 --- a/app/replica.go +++ b/app/replica.go @@ -4,6 +4,9 @@ import ( "errors" "net/http" "os" + "os/exec" + "path/filepath" + "syscall" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" @@ -24,6 +27,9 @@ func ReplicaCmd() cli.Command { Name: "listen", Value: "localhost:9502", }, + cli.BoolTFlag{ + Name: "sync-agent", + }, cli.BoolFlag{ Name: "debug", }, @@ -65,7 +71,7 @@ func startReplica(c *cli.Context) error { } } - controlAddress, dataAddress, err := util.ParseAddresses(address) + controlAddress, dataAddress, syncAddress, err := util.ParseAddresses(address) if err != nil { return err } @@ -86,5 +92,28 @@ func startReplica(c *cli.Context) error { resp <- rpcServer.ListenAndServe() }() + if c.Bool("sync-agent") { + exe, err := exec.LookPath(os.Args[0]) + if err != nil { + return err + } + + exe, err = filepath.Abs(exe) + if err != nil { + return err + } + + go func() { + cmd := exec.Command(exe, "sync-agent", "--listen", syncAddress) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Dir = dir + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + resp <- cmd.Run() + }() + } + return <-resp } diff --git a/app/rm_replica.go b/app/rm_replica.go new file mode 100644 index 00000000..5de4cebd --- /dev/null +++ b/app/rm_replica.go @@ -0,0 +1,44 @@ +package app + +import ( + "errors" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" +) + +func RmReplicaCmd() cli.Command { + return cli.Command{ + Name: "rm-replica", + ShortName: "rm", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "url", + Value: "http://localhost:9501", + }, + cli.BoolFlag{ + Name: "debug", + }, + }, + Action: func(c *cli.Context) { + if err := rmReplica(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func rmReplica(c *cli.Context) error { + if c.NArg() == 0 { + return errors.New("replica address is required") + } + replica := c.Args()[0] + + if c.Bool("debug") { + logrus.SetLevel(logrus.DebugLevel) + } + + controllerClient := getCli(c) + _, err := controllerClient.DeleteReplica(replica) + return err +} diff --git a/app/shutdown.go b/app/shutdown.go new file mode 100644 index 00000000..364d3766 --- /dev/null +++ b/app/shutdown.go @@ -0,0 +1,32 @@ +package app + +import ( + "os" + "os/signal" + "syscall" +) + +var ( + hooks = []func(){} +) + +func addShutdown(f func()) { + if len(hooks) == 0 { + registerShutdown() + } + + hooks = append(hooks, f) +} + +func registerShutdown() { + c := make(chan os.Signal, 1024) + signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) + go func() { + for range c { + for _, hook := range hooks { + hook() + } + os.Exit(1) + } + }() +} diff --git a/app/sync_agent.go b/app/sync_agent.go index 96f2eaaa..66696b0b 100644 --- a/app/sync_agent.go +++ b/app/sync_agent.go @@ -61,7 +61,7 @@ func startSyncAgent(c *cli.Context) error { server := agent.NewServer(start, end) router := agent.NewRouter(server) - logrus.Infof("Listening on %s", listen) + logrus.Infof("Listening on sync %s", listen) return http.ListenAndServe(listen, router) } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index bb28a21e..a263ff46 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -93,9 +93,9 @@ func (r *Remote) info() (rest.Replica, error) { } func (rf *Factory) Create(address string) (types.Backend, error) { - logrus.Infof("Conneting to remote: %s", address) + logrus.Infof("Connecting to remote: %s", address) - controlAddress, dataAddress, err := util.ParseAddresses(address) + controlAddress, dataAddress, _, err := util.ParseAddresses(address) if err != nil { return nil, err } diff --git a/client/controller_client.go b/client/controller_client.go index 107987a1..36e8765d 100644 --- a/client/controller_client.go +++ b/client/controller_client.go @@ -51,6 +51,33 @@ func (c *ControllerClient) CreateReplica(address string) (*rest.Replica, error) return &resp, err } +func (c *ControllerClient) DeleteReplica(address string) (*rest.Replica, error) { + reps, err := c.ListReplicas() + if err != nil { + return nil, err + } + + for _, rep := range reps { + if rep.Address == address { + httpReq, err := http.NewRequest("DELETE", rep.Links["self"], nil) + if err != nil { + return nil, err + } + httpResp, err := http.DefaultClient.Do(httpReq) + if err != nil { + return nil, err + } + if httpResp.StatusCode >= 300 { + content, _ := ioutil.ReadAll(httpResp.Body) + return nil, fmt.Errorf("Bad response: %d %s: %s", httpResp.StatusCode, httpResp.Status, content) + } + return &rep, nil + } + } + + return nil, nil +} + func (c *ControllerClient) UpdateReplica(replica rest.Replica) (rest.Replica, error) { var resp rest.Replica err := c.put(replica.Links["self"], &replica, &resp) diff --git a/controller/control.go b/controller/control.go index e4ea01d2..6770a35f 100644 --- a/controller/control.go +++ b/controller/control.go @@ -33,6 +33,13 @@ func (c *Controller) AddReplica(address string) error { } func (c *Controller) addReplica(address string, snapshot bool) error { + c.Lock() + if c.hasReplica(address) { + c.Unlock() + return nil + } + c.Unlock() + newBackend, err := c.factory.Create(address) if err != nil { return err @@ -53,7 +60,6 @@ func (c *Controller) Snapshot() error { func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { if c.hasReplica(address) { - newBackend.Close() return nil } @@ -62,6 +68,10 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, newBackend.Close() return err } + if err := newBackend.Snapshot(); err != nil { + newBackend.Close() + return err + } } c.replicas = append(c.replicas, types.Replica{ @@ -112,7 +122,7 @@ func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { defer c.Unlock() case types.RW: c.RLock() - c.RUnlock() + defer c.RUnlock() default: return fmt.Errorf("Can not set to mode %s", mode) } @@ -182,12 +192,37 @@ func (c *Controller) Start(addresses ...string) error { return nil } -func (c *Controller) WriteAt(b []byte, off int64) (n int, err error) { - return c.backend.WriteAt(b, off) +func (c *Controller) WriteAt(b []byte, off int64) (int, error) { + c.RLock() + n, err := c.backend.WriteAt(b, off) + c.RUnlock() + if err != nil { + return n, c.handleError(err) + } + return n, err +} + +func (c *Controller) ReadAt(b []byte, off int64) (int, error) { + c.RLock() + n, err := c.backend.ReadAt(b, off) + c.RUnlock() + if err != nil { + return n, c.handleError(err) + } + return n, err } -func (c *Controller) ReadAt(b []byte, off int64) (n int, err error) { - return c.backend.ReadAt(b, off) +func (c *Controller) handleError(err error) error { + if bErr, ok := err.(*BackendError); ok { + if len(bErr.Errors) > 0 { + c.Lock() + for address := range bErr.Errors { + c.setReplicaModeNoLock(address, types.ERR) + } + c.Unlock() + } + } + return err } func (c *Controller) reset() { diff --git a/controller/multi_writer_at.go b/controller/multi_writer_at.go index ec0182a7..e980ae68 100644 --- a/controller/multi_writer_at.go +++ b/controller/multi_writer_at.go @@ -2,6 +2,7 @@ package controller import ( "io" + "strings" "sync" ) @@ -10,18 +11,26 @@ type MultiWriterAt struct { } type MultiWriterError struct { - Index int Writers []io.WriterAt Errors []error } func (m *MultiWriterError) Error() string { + errors := []string{} for _, err := range m.Errors { if err != nil { - return err.Error() + errors = append(errors, err.Error()) } } - return "Unknown" + + switch len(errors) { + case 0: + return "Unknown" + case 1: + return errors[0] + default: + return strings.Join(errors, "; ") + } } func (m *MultiWriterAt) WriteAt(p []byte, off int64) (n int, err error) { diff --git a/controller/replicator.go b/controller/replicator.go index bc963006..93496c5d 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -1,19 +1,50 @@ package controller import ( + "errors" + "fmt" "io" + "strings" "sync" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" ) +var ( + ErrNoBackend = errors.New("No backend available") +) + type replicator struct { - io.WriterAt + backendsAvailable bool + backends map[string]backendWrapper + writerIndex map[int]string + readerIndex map[int]string + readers []io.ReaderAt + writer io.WriterAt + next int +} - backends map[string]backendWrapper - readers []io.ReaderAt - readerLength int +type BackendError struct { + Errors map[string]error +} + +func (b *BackendError) Error() string { + errors := []string{} + for address, err := range b.Errors { + if err != nil { + errors = append(errors, fmt.Sprintf("%s: %s", address, err.Error())) + } + } + + switch len(errors) { + case 0: + return "Unknown" + case 1: + return errors[0] + default: + return strings.Join(errors, "; ") + } } func (r *replicator) AddBackend(address string, backend types.Backend) { @@ -48,24 +79,76 @@ func (r *replicator) RemoveBackend(address string) { r.buildReadWriters() } -func (r *replicator) ReadAt(buf []byte, off int64) (n int, err error) { - // Use a poor random algorithm by always selecting 0 :) - return r.readers[0].ReadAt(buf, off) +func (r *replicator) ReadAt(buf []byte, off int64) (int, error) { + if !r.backendsAvailable { + return 0, ErrNoBackend + } + + index := r.next + r.next++ + if index >= len(r.readers) { + r.next = 0 + index = 0 + } + n, err := r.readers[index].ReadAt(buf, off) + if err != nil { + return n, &BackendError{ + Errors: map[string]error{ + r.readerIndex[index]: err, + }, + } + } + return n, err +} + +func (r *replicator) WriteAt(p []byte, off int64) (int, error) { + if !r.backendsAvailable { + return 0, ErrNoBackend + } + + n, err := r.writer.WriteAt(p, off) + if err != nil { + errors := map[string]error{ + r.writerIndex[0]: err, + } + if mErr, ok := err.(*MultiWriterError); ok { + errors = map[string]error{} + for index, err := range mErr.Errors { + if err != nil { + errors[r.writerIndex[index]] = err + } + } + } + return n, &BackendError{Errors: errors} + } + return n, err } func (r *replicator) buildReadWriters() { + r.reset(false) + readers := []io.ReaderAt{} - writers := make([]io.WriterAt, 0, len(r.backends)) - for _, b := range r.backends { - writers = append(writers, b.backend) - readers = append(readers, b.backend) + writers := []io.WriterAt{} + + for address, b := range r.backends { + if b.mode != types.ERR { + r.writerIndex[len(writers)] = address + writers = append(writers, b.backend) + } + if b.mode == types.RW { + r.readerIndex[len(readers)] = address + readers = append(readers, b.backend) + } } - r.WriterAt = &MultiWriterAt{ + r.writer = &MultiWriterAt{ writers: writers, } r.readers = readers - r.readerLength = len(readers) + + if len(r.readers) > 0 { + r.backendsAvailable = true + } } func (r *replicator) SetMode(address string, mode types.Mode) { @@ -107,14 +190,20 @@ func (r *replicator) Close() error { } } - r.reset() + r.reset(true) return lastErr } -func (r *replicator) reset() { - r.WriterAt = nil - r.backends = nil +func (r *replicator) reset(full bool) { + r.backendsAvailable = false + r.writer = nil + r.writerIndex = map[int]string{} + r.readerIndex = map[int]string{} + + if full { + r.backends = nil + } } type backendWrapper struct { diff --git a/main.go b/main.go index b006133f..38feee89 100644 --- a/main.go +++ b/main.go @@ -24,8 +24,10 @@ func main() { a.Commands = []cli.Command{ app.ControllerCmd(), app.ReplicaCmd(), - app.AddReplicaCmd(), app.SyncAgentCmd(), + app.AddReplicaCmd(), + app.LsReplicaCmd(), + app.RmReplicaCmd(), } a.Run(os.Args) diff --git a/replica/replica.go b/replica/replica.go index fb772aa9..fd16fe6f 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -86,7 +86,7 @@ func New(size, sectorSize int64, dir string) (*Replica, error) { r.info.Parent = r.diskData[r.info.Head].Parent - return r, nil + return r, r.writeVolumeMetaData(true) } func (r *Replica) Reload() (*Replica, error) { @@ -169,15 +169,19 @@ func (r *Replica) Chain() ([]string, error) { return result, nil } +func (r *Replica) writeVolumeMetaData(dirty bool) error { + info := r.info + info.Dirty = dirty + return r.encodeToFile(&info, volumeMetaData) +} + func (r *Replica) close(writeMeta bool) error { for _, f := range r.volume.files { f.Close() } if writeMeta { - info := r.info - info.Dirty = false - return r.encodeToFile(&info, volumeMetaData) + return r.writeVolumeMetaData(false) } return nil @@ -295,7 +299,7 @@ func (r *Replica) createDisk() error { info := r.info info.Head = newHeadDisk.name - info.Dirty = false + info.Dirty = true info.Parent = newHeadDisk.Parent info.SectorSize = r.volume.sectorSize @@ -417,6 +421,7 @@ func (r *Replica) Snapshot() error { func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { r.RLock() + r.info.Dirty = true c, err := r.volume.WriteAt(buf, offset) r.RUnlock() return c, err diff --git a/rpc/client.go b/rpc/client.go index 4dba54b9..a72308d8 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -16,6 +16,7 @@ type Client struct { seq uint32 messages map[uint32]*Message wire *Wire + err error } func NewClient(conn net.Conn) *Client { @@ -63,15 +64,17 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { } func (c *Client) Close() { + c.wire.Close() c.end <- struct{}{} - close(c.send) } func (c *Client) loop() { + defer close(c.send) + for { select { case <-c.end: - break + return case req := <-c.requests: c.handleRequest(req) case resp := <-c.responses: @@ -85,14 +88,40 @@ func (c *Client) nextSeq() uint32 { return c.seq } +func (c *Client) replyError(req *Message) { + delete(c.messages, req.Seq) + req.Type = TypeError + req.Data = []byte(c.err.Error()) + req.Done() +} + func (c *Client) handleRequest(req *Message) { + if c.err != nil { + c.replyError(req) + return + } + req.Seq = c.nextSeq() c.messages[req.Seq] = req c.send <- req } func (c *Client) handleResponse(resp *Message) { + if resp.transportErr != nil { + c.err = resp.transportErr + // Terminate all in flight + for _, msg := range c.messages { + c.replyError(msg) + } + return + } + if req, ok := c.messages[resp.Seq]; ok { + if c.err != nil { + c.replyError(req) + return + } + delete(c.messages, resp.Seq) // can probably optimize away this copy if len(resp.Data) > 0 { @@ -107,9 +136,7 @@ func (c *Client) write() { for msg := range c.send { if err := c.wire.Write(msg); err != nil { c.responses <- &Message{ - Seq: msg.Seq, - Type: TypeError, - Data: []byte(err.Error()), + transportErr: err, } } } @@ -120,6 +147,10 @@ func (c *Client) read() { msg, err := c.wire.Read() if err != nil { logrus.Errorf("Error reading from wire: %v", err) + c.responses <- &Message{ + transportErr: err, + } + break } c.responses <- msg } diff --git a/rpc/server.go b/rpc/server.go index 97a9d5fa..5b51d8f3 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -35,7 +35,9 @@ func (s *Server) Handle() error { func (s *Server) read() error { for { msg, err := s.wire.Read() - if err != nil { + if err == io.EOF { + return err + } else if err != nil { logrus.Errorf("Failed to read: %v", err) return err } diff --git a/rpc/types.go b/rpc/types.go index 056bd0a8..b21fbc62 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -17,8 +17,9 @@ const ( type Message struct { sync.WaitGroup - Seq uint32 - Type uint32 - Offset int64 - Data []byte + Seq uint32 + Type uint32 + Offset int64 + Data []byte + transportErr error } diff --git a/rpc/wire.go b/rpc/wire.go index ee738c3e..a37357a3 100644 --- a/rpc/wire.go +++ b/rpc/wire.go @@ -8,12 +8,14 @@ import ( ) type Wire struct { + conn net.Conn writer *bufio.Writer reader io.Reader } func NewWire(conn net.Conn) *Wire { return &Wire{ + conn: conn, writer: bufio.NewWriterSize(conn, writeBufferSize), reader: bufio.NewReaderSize(conn, readBufferSize), } @@ -71,3 +73,7 @@ func (w *Wire) Read() (*Message, error) { return &msg, nil } + +func (w *Wire) Close() error { + return w.conn.Close() +} diff --git a/scripts/integration-test b/scripts/integration-test index 38709b65..e0650adb 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -16,16 +16,6 @@ fi ./bin/longhorn controller --enable-backend file test-volume & ./bin/longhorn replica $temp & ./bin/longhorn replica --listen localhost:9505 $temp2 & -( - mkdir -p $temp - cd $temp - $OLDPWD/bin/longhorn sync-agent --listen localhost:9504 --listen-port-range 5000-5500 & -) -( - mkdir -p $temp2 - cd $temp2 - $OLDPWD/bin/longhorn sync-agent --listen localhost:9507 --listen-port-range 5501-6000 & -) cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; tox diff --git a/sync/sync.go b/sync/sync.go index 5f7ad7bd..5b2573e9 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -86,7 +86,7 @@ func (t *Task) reloadAndCheck(fromClient *client.ReplicaClient, toClient *client fromChain := from.Chain[1:] toChain := to.Chain[1:] - if reflect.DeepEqual(fromChain, toChain) { + if !reflect.DeepEqual(fromChain, toChain) { return fmt.Errorf("Chains are not equal: %v != %v", fromChain, toChain) } @@ -99,7 +99,7 @@ func (t *Task) syncFiles(fromClient *client.ReplicaClient, toClient *client.Repl return err } - to, err := fromClient.GetReplica() + to, err := toClient.GetReplica() if err != nil { return err } diff --git a/util/util.go b/util/util.go index caefa318..05ce55c1 100644 --- a/util/util.go +++ b/util/util.go @@ -10,14 +10,16 @@ var ( parsePattern = regexp.MustCompile(`(.*):(\d+)`) ) -func ParseAddresses(name string) (string, string, error) { +func ParseAddresses(name string) (string, string, string, error) { matches := parsePattern.FindStringSubmatch(name) if matches == nil { - return "", "", fmt.Errorf("Invalid address %s does not match pattern: %v", name, parsePattern) + return "", "", "", fmt.Errorf("Invalid address %s does not match pattern: %v", name, parsePattern) } host := matches[1] port, _ := strconv.Atoi(matches[2]) - return fmt.Sprintf("%s:%d", host, port), fmt.Sprintf("%s:%d", host, port+1), nil + return fmt.Sprintf("%s:%d", host, port), + fmt.Sprintf("%s:%d", host, port+1), + fmt.Sprintf("%s:%d", host, port+2), nil } From 3aec1a6ce1dc04603cfb22ae281cc15f40571337 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 21 Apr 2016 11:20:31 -0700 Subject: [PATCH 011/357] Fix implicat declaration in cgo Fix following warnings frontend/tcmu/cfunc.go: In function 'sh_open_cgo': frontend/tcmu/cfunc.go:23:9: warning: implicit declaration of function 'shOpen' [-Wimplicit-function-declaration] return shOpen(dev); ^ frontend/tcmu/cfunc.go: In function 'sh_close_cgo': frontend/tcmu/cfunc.go:27:2: warning: implicit declaration of function 'shClose' [-Wimplicit-function-declaration] shClose(dev); ^ --- frontend/tcmu/cfunc.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index 9185ff4f..bebc8212 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -19,6 +19,9 @@ void errp(const char *fmt, ...) va_end(va); } +extern int shOpen(struct tcmu_device *dev); +extern void shClose(struct tcmu_device *dev); + int sh_open_cgo(struct tcmu_device *dev) { return shOpen(dev); } From e1a849724dad0af1454960e679075181e92c71dc Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 21 Apr 2016 19:31:53 -0700 Subject: [PATCH 012/357] Delete target link file it is exists so link won't fail --- replica/replica.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/replica/replica.go b/replica/replica.go index fd16fe6f..bf4e5f0a 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -248,7 +248,15 @@ func (r *Replica) linkDisk(oldname, newname string) error { return nil } - if err := os.Link(path.Join(r.dir, oldname), path.Join(r.dir, newname)); err != nil { + dest := path.Join(r.dir, newname) + if _, err := os.Stat(dest); err == nil { + logrus.Infof("Old file %s exists, deleting", dest) + if err := os.Remove(dest); err != nil { + return err + } + } + + if err := os.Link(path.Join(r.dir, oldname), dest); err != nil { return err } From c00e8ee583e8408ef9edcebf67f626682fe5cc15 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 21 Apr 2016 21:10:18 -0700 Subject: [PATCH 013/357] Only allow one WO replica at a time to block concurrent rebuild --- Dockerfile.dapper | 2 +- controller/control.go | 27 +++++++++++++++++++++++---- integration/core/test_controller.py | 12 ++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 40eede7d..7a2fc14a 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -57,7 +57,7 @@ RUN cd /usr/src/tcmu-runner && \ # Install ssync RUN go get -d github.com/kp6/alphorn/ssync && \ cd $GOPATH/src/github.com/kp6/alphorn && \ - git clone https://github.com/kp6/alphorn.git && \ + git checkout c7705144deb2d398820fd248c261d2279b27f45d && \ cd ssync && \ go build -o /usr/local/bin/ssync diff --git a/controller/control.go b/controller/control.go index 6770a35f..070f935d 100644 --- a/controller/control.go +++ b/controller/control.go @@ -32,11 +32,30 @@ func (c *Controller) AddReplica(address string) error { return c.addReplica(address, true) } +func (c *Controller) hasWOReplica() bool { + for _, i := range c.replicas { + if i.Mode == types.WO { + return true + } + } + return false +} + +func (c *Controller) canAdd(address string) (bool, error) { + if c.hasReplica(address) { + return false, nil + } + if c.hasWOReplica() { + return false, fmt.Errorf("Can only have one WO replica at a time") + } + return true, nil +} + func (c *Controller) addReplica(address string, snapshot bool) error { c.Lock() - if c.hasReplica(address) { + if ok, err := c.canAdd(address); !ok { c.Unlock() - return nil + return err } c.Unlock() @@ -59,8 +78,8 @@ func (c *Controller) Snapshot() error { } func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { - if c.hasReplica(address) { - return nil + if ok, err := c.canAdd(address); !ok { + return err } if snapshot { diff --git a/integration/core/test_controller.py b/integration/core/test_controller.py index 56c8859a..c38f8b0d 100644 --- a/integration/core/test_controller.py +++ b/integration/core/test_controller.py @@ -3,6 +3,7 @@ import pytest import cattle +from cattle import ApiError @pytest.fixture @@ -47,6 +48,14 @@ def test_replica_create(client): assert r[0].mode == 'WO' f2 = 'file://' + random_str() + with pytest.raises(ApiError) as e: + client.create_replica(address=f2) + assert e.value.error.status == 500 + assert e.value.error.message == 'Can only have one WO replica at a time' + + r = client.update(r[0], mode='RW') + assert r.mode == 'RW' + replica2 = client.create_replica(address=f2) assert replica2.address == f2 @@ -57,8 +66,11 @@ def test_replica_create(client): def test_replica_delete(client): f = 'file://' + random_str() r1 = client.create_replica(address=f+'1') + client.update(r1, mode='RW') r2 = client.create_replica(address=f+'2') + client.update(r2, mode='RW') r3 = client.create_replica(address=f+'3') + client.update(r3, mode='RW') r = client.list_replica() assert len(r) == 3 From ff14f2abda8ec2ee9831ad7ef85680573f71e2ab Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Wed, 20 Apr 2016 13:39:43 -0700 Subject: [PATCH 014/357] add open to replica client --- client/replica_client.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/replica_client.go b/client/replica_client.go index 6526d6c0..980f144b 100644 --- a/client/replica_client.go +++ b/client/replica_client.go @@ -59,6 +59,17 @@ func NewReplicaClient(address string) (*ReplicaClient, error) { }, nil } +func (c *ReplicaClient) OpenReplica(size string) error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["open"], rest.OpenInput{ + Size: size, + }, nil) +} + func (c *ReplicaClient) GetReplica() (rest.Replica, error) { var replica rest.Replica From 49c870dfbd5ddb21f46587d18cff0e29a7cd67ad Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 23 Apr 2016 21:56:35 -0700 Subject: [PATCH 015/357] Add optional name to replica snapshot API --- integration/core/test_cli.py | 4 +- integration/core/test_replica.py | 16 +- replica/replica.go | 29 +- replica/replica_test.go | 22 +- replica/rest/model.go | 7 + replica/rest/replica.go | 27 +- replica/server.go | 6 +- trash.yml | 2 + vendor/github.com/satori/go.uuid/.travis.yml | 12 + vendor/github.com/satori/go.uuid/LICENSE | 20 + vendor/github.com/satori/go.uuid/README.md | 64 +++ .../satori/go.uuid/benchmarks_test.go | 121 ++++ vendor/github.com/satori/go.uuid/uuid.go | 442 +++++++++++++++ vendor/github.com/satori/go.uuid/uuid_test.go | 520 ++++++++++++++++++ 14 files changed, 1250 insertions(+), 42 deletions(-) create mode 100644 vendor/github.com/satori/go.uuid/.travis.yml create mode 100644 vendor/github.com/satori/go.uuid/LICENSE create mode 100644 vendor/github.com/satori/go.uuid/README.md create mode 100644 vendor/github.com/satori/go.uuid/benchmarks_test.go create mode 100644 vendor/github.com/satori/go.uuid/uuid.go create mode 100644 vendor/github.com/satori/go.uuid/uuid_test.go diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 3e4cad9b..a5d1592e 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -114,8 +114,8 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, open_replica(replica_client2) r = replica_client.list_replica()[0] - r = r.snapshot() - r = r.snapshot() + r = r.snapshot(name='000') + r = r.snapshot(name='001') l = replica_client2.list_replica()[0] diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index a5318406..aa7207e6 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -98,8 +98,8 @@ def test_snapshot(client): assert r.parent == '' assert r.head == 'volume-head-000.img' - r = r.snapshot() - r = r.snapshot() + r = r.snapshot(name='000') + r = r.snapshot(name='001') assert r.state == 'open' assert r.size == str(1024*4096) @@ -116,8 +116,8 @@ def test_remove_disk(client): r = replicas[0] r = r.open(size=str(1024*4096)) - r = r.snapshot() - r = r.snapshot() + r = r.snapshot(name='000') + r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] @@ -136,8 +136,8 @@ def test_remove_last_disk(client): r = replicas[0] r = r.open(size=str(1024*4096)) - r = r.snapshot() - r = r.snapshot() + r = r.snapshot(name='000') + r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] @@ -156,8 +156,8 @@ def test_reload(client): r = replicas[0] r = r.open(size=str(1024*4096)) - r = r.snapshot() - r = r.snapshot() + r = r.snapshot(name='000') + r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] diff --git a/replica/replica.go b/replica/replica.go index bf4e5f0a..1de160db 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -21,11 +21,11 @@ const ( volumeMetaData = "volume.meta" defaultSectorSize = 4096 headName = "volume-head-%03d.img" - diskName = "volume-snap-%03d.img" + diskName = "volume-snap-%s.img" ) var ( - diskPattern = regexp.MustCompile(`volume-snap-(\d)+.img`) + diskPattern = regexp.MustCompile(`volume-head-(\d)+.img`) ) type Replica struct { @@ -78,8 +78,10 @@ func New(size, sectorSize int64, dir string) (*Replica, error) { if err := r.openFiles(); err != nil { return nil, err } + } else if size <= 0 { + return nil, os.ErrNotExist } else { - if err := r.createDisk(); err != nil { + if err := r.createDisk("000"); err != nil { return nil, err } } @@ -224,12 +226,16 @@ func (r *Replica) openFile(name string, flag int) (*os.File, error) { return os.OpenFile(path.Join(r.dir, name), os.O_RDWR|os.O_CREATE|flag, 0666) } -func (r *Replica) createNewHead(parent string) (*os.File, disk, error) { - newHeadName, err := r.nextFile(diskPattern, headName, parent) +func (r *Replica) createNewHead(oldHead, parent string) (*os.File, disk, error) { + newHeadName, err := r.nextFile(diskPattern, headName, oldHead) if err != nil { return nil, disk{}, err } + if _, err := os.Stat(path.Join(r.dir, newHeadName)); err == nil { + return nil, disk{}, fmt.Errorf("%s already exists", newHeadName) + } + f, err := r.openFile(newHeadName, os.O_TRUNC) if err != nil { return nil, disk{}, err @@ -275,19 +281,16 @@ func (r *Replica) rmDisk(name string) error { return lastErr } -func (r *Replica) createDisk() error { +func (r *Replica) createDisk(name string) error { done := false oldHead := r.info.Head - newSnapName, err := r.nextFile(diskPattern, diskName, r.diskData[oldHead].Parent) - if err != nil { - return err - } + newSnapName := fmt.Sprintf(diskName, name) if oldHead == "" { newSnapName = "" } - f, newHeadDisk, err := r.createNewHead(newSnapName) + f, newHeadDisk, err := r.createNewHead(oldHead, newSnapName) if err != nil { return err } @@ -420,11 +423,11 @@ func (r *Replica) Delete() error { return nil } -func (r *Replica) Snapshot() error { +func (r *Replica) Snapshot(name string) error { r.Lock() defer r.Unlock() - return r.createDisk() + return r.createDisk(name) } func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { diff --git a/replica/replica_test.go b/replica/replica_test.go index 0cccce91..ec70c2e9 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -38,10 +38,10 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot() + err = r.Snapshot("000") c.Assert(err, IsNil) - err = r.Snapshot() + err = r.Snapshot("001") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -65,10 +65,10 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot() + err = r.Snapshot("000") c.Assert(err, IsNil) - err = r.Snapshot() + err = r.Snapshot("001") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -102,10 +102,10 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot() + err = r.Snapshot("000") c.Assert(err, IsNil) - err = r.Snapshot() + err = r.Snapshot("001") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -139,10 +139,10 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot() + err = r.Snapshot("000") c.Assert(err, IsNil) - err = r.Snapshot() + err = r.Snapshot("001") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -227,19 +227,19 @@ func (s *TestSuite) TestSnapshotReadWrite(c *C) { count, err := r.WriteAt(buf, 0) c.Assert(err, IsNil) c.Assert(count, Equals, 3*b) - err = r.Snapshot() + err = r.Snapshot("000") c.Assert(err, IsNil) fill(buf[b:2*b], 2) count, err = r.WriteAt(buf[b:2*b], b) c.Assert(count, Equals, b) - err = r.Snapshot() + err = r.Snapshot("001") c.Assert(err, IsNil) fill(buf[:b], 1) count, err = r.WriteAt(buf[:b], 0) c.Assert(count, Equals, b) - err = r.Snapshot() + err = r.Snapshot("002") c.Assert(err, IsNil) readBuf := make([]byte, 3*b) diff --git a/replica/rest/model.go b/replica/rest/model.go index 0ce12476..4a28b949 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -29,6 +29,11 @@ type OpenInput struct { Size string `json:"size"` } +type SnapshotInput struct { + client.Resource + Name string `json:"Name"` +} + type RemoveDiskInput struct { client.Resource Name string `json:"name"` @@ -71,6 +76,7 @@ func NewSchema() *client.Schemas { schemas.AddType("apiVersion", client.Resource{}) schemas.AddType("schema", client.Schema{}) schemas.AddType("openInput", OpenInput{}) + schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("removediskInput", RemoveDiskInput{}) replica := schemas.AddType("replica", Replica{}) @@ -86,6 +92,7 @@ func NewSchema() *client.Schemas { Output: "replica", }, "snapshot": client.Action{ + Input: "snapshotInput", Output: "replica", }, "removedisk": client.Action{ diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 955b8148..1098875b 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -1,12 +1,14 @@ package rest import ( + "io" "net/http" "strconv" "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" + "github.com/satori/go.uuid" ) func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { @@ -46,13 +48,17 @@ func (s *Server) doOp(req *http.Request, err error) error { func (s *Server) OpenReplica(rw http.ResponseWriter, req *http.Request) error { var input OpenInput apiContext := api.GetApiContext(req) - if err := apiContext.Read(&input); err != nil { + if err := apiContext.Read(&input); err != nil && err != io.EOF { return err } - size, err := strconv.ParseInt(input.Size, 10, 0) - if err != nil { - return err + size := int64(0) + if input.Size != "" { + var err error + size, err = strconv.ParseInt(input.Size, 10, 0) + if err != nil { + return err + } } return s.doOp(req, s.s.Open(size)) @@ -69,7 +75,18 @@ func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { } func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) error { - return s.doOp(req, s.s.Snapshot()) + var input SnapshotInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil && err != io.EOF { + return err + } + + name := input.Name + if name == "" { + name = uuid.NewV4().String() + } + + return s.doOp(req, s.s.Snapshot(name)) } func (s *Server) ReloadReplica(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/server.go b/replica/server.go index 57222b05..8931031f 100644 --- a/replica/server.go +++ b/replica/server.go @@ -62,7 +62,7 @@ func (s *Server) Replica() *Replica { return s.r } -func (s *Server) Snapshot() error { +func (s *Server) Snapshot(name string) error { s.Lock() defer s.Unlock() @@ -70,8 +70,8 @@ func (s *Server) Snapshot() error { return nil } - logrus.Infof("Snapshotting volume") - return s.r.Snapshot() + logrus.Infof("Snapshotting [%s] volume", name) + return s.r.Snapshot(name) } func (s *Server) RemoveDiffDisk(name string) error { diff --git a/trash.yml b/trash.yml index 70fd3abd..6d38debb 100644 --- a/trash.yml +++ b/trash.yml @@ -20,3 +20,5 @@ import: version: 5d2041e26a699eaca682e2ea41c8f891e1060444 - package: github.com/codegangsta/cli version: 71f57d300dd6a780ac1856c005c4b518cfd498ec +- package: github.com/satori/go.uuid + version: f9ab0dce87d815821e221626b772e3475a0d2749 diff --git a/vendor/github.com/satori/go.uuid/.travis.yml b/vendor/github.com/satori/go.uuid/.travis.yml new file mode 100644 index 00000000..5e217462 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/.travis.yml @@ -0,0 +1,12 @@ +language: go +go: + - 1.0 + - 1.1 + - 1.2 + - 1.3 + - 1.4 + - 1.5 + - 1.6 +sudo: false +notifications: + email: false diff --git a/vendor/github.com/satori/go.uuid/LICENSE b/vendor/github.com/satori/go.uuid/LICENSE new file mode 100644 index 00000000..488357b8 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/LICENSE @@ -0,0 +1,20 @@ +Copyright (C) 2013-2016 by Maxim Bublis + +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/satori/go.uuid/README.md b/vendor/github.com/satori/go.uuid/README.md new file mode 100644 index 00000000..b6b626b2 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/README.md @@ -0,0 +1,64 @@ +# UUID package for Go language + +[![Build Status](https://travis-ci.org/satori/go.uuid.png?branch=master)](https://travis-ci.org/satori/go.uuid) +[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.png)](http://godoc.org/github.com/satori/go.uuid) + +This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs. + +With 100% test coverage and benchmarks out of box. + +Supported versions: +* Version 1, based on timestamp and MAC address (RFC 4122) +* Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) +* Version 3, based on MD5 hashing (RFC 4122) +* Version 4, based on random numbers (RFC 4122) +* Version 5, based on SHA-1 hashing (RFC 4122) + +## Installation + +Use the `go` command: + + $ go get github.com/satori/go.uuid + +## Requirements + +UUID package requires any stable version of Go Programming Language. + +## Example + +```go +package main + +import ( + "fmt" + "github.com/satori/go.uuid" +) + +func main() { + // Creating UUID Version 4 + u1 := uuid.NewV4() + fmt.Printf("UUIDv4: %s\n", u1) + + // Parsing UUID from string input + u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + if err != nil { + fmt.Printf("Something gone wrong: %s", err) + } + fmt.Printf("Successfully parsed: %s", u2) +} +``` + +## Documentation + +[Documentation](http://godoc.org/github.com/satori/go.uuid) is hosted at GoDoc project. + +## Links +* [RFC 4122](http://tools.ietf.org/html/rfc4122) +* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) + +## Copyright + +Copyright (C) 2013-2016 by Maxim Bublis . + +UUID package released under MIT License. +See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. diff --git a/vendor/github.com/satori/go.uuid/benchmarks_test.go b/vendor/github.com/satori/go.uuid/benchmarks_test.go new file mode 100644 index 00000000..b4e567fc --- /dev/null +++ b/vendor/github.com/satori/go.uuid/benchmarks_test.go @@ -0,0 +1,121 @@ +// Copyright (C) 2013-2015 by Maxim Bublis +// +// 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. + +package uuid + +import ( + "testing" +) + +func BenchmarkFromBytes(b *testing.B) { + bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + for i := 0; i < b.N; i++ { + FromBytes(bytes) + } +} + +func BenchmarkFromString(b *testing.B) { + s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + for i := 0; i < b.N; i++ { + FromString(s) + } +} + +func BenchmarkFromStringUrn(b *testing.B) { + s := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" + for i := 0; i < b.N; i++ { + FromString(s) + } +} + +func BenchmarkFromStringWithBrackets(b *testing.B) { + s := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" + for i := 0; i < b.N; i++ { + FromString(s) + } +} + +func BenchmarkNewV1(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV1() + } +} + +func BenchmarkNewV2(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV2(DomainPerson) + } +} + +func BenchmarkNewV3(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV3(NamespaceDNS, "www.example.com") + } +} + +func BenchmarkNewV4(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV4() + } +} + +func BenchmarkNewV5(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV5(NamespaceDNS, "www.example.com") + } +} + +func BenchmarkMarshalBinary(b *testing.B) { + u := NewV4() + for i := 0; i < b.N; i++ { + u.MarshalBinary() + } +} + +func BenchmarkMarshalText(b *testing.B) { + u := NewV4() + for i := 0; i < b.N; i++ { + u.MarshalText() + } +} + +func BenchmarkUnmarshalBinary(b *testing.B) { + bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + u := UUID{} + for i := 0; i < b.N; i++ { + u.UnmarshalBinary(bytes) + } +} + +func BenchmarkUnmarshalText(b *testing.B) { + bytes := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + u := UUID{} + for i := 0; i < b.N; i++ { + u.UnmarshalText(bytes) + } +} + +func BenchmarkMarshalToString(b *testing.B) { + u := NewV4() + for i := 0; i < b.N; i++ { + u.String() + } +} diff --git a/vendor/github.com/satori/go.uuid/uuid.go b/vendor/github.com/satori/go.uuid/uuid.go new file mode 100644 index 00000000..da6ff712 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/uuid.go @@ -0,0 +1,442 @@ +// Copyright (C) 2013-2015 by Maxim Bublis +// +// 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. + +// Package uuid provides implementation of Universally Unique Identifier (UUID). +// Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and +// version 2 (as specified in DCE 1.1). +package uuid + +import ( + "bytes" + "crypto/md5" + "crypto/rand" + "crypto/sha1" + "database/sql/driver" + "encoding/binary" + "encoding/hex" + "fmt" + "hash" + "net" + "os" + "sync" + "time" +) + +// UUID layout variants. +const ( + VariantNCS = iota + VariantRFC4122 + VariantMicrosoft + VariantFuture +) + +// UUID DCE domains. +const ( + DomainPerson = iota + DomainGroup + DomainOrg +) + +// Difference in 100-nanosecond intervals between +// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970). +const epochStart = 122192928000000000 + +// Used in string method conversion +const dash byte = '-' + +// UUID v1/v2 storage. +var ( + storageMutex sync.Mutex + storageOnce sync.Once + epochFunc = unixTimeFunc + clockSequence uint16 + lastTime uint64 + hardwareAddr [6]byte + posixUID = uint32(os.Getuid()) + posixGID = uint32(os.Getgid()) +) + +// String parse helpers. +var ( + urnPrefix = []byte("urn:uuid:") + byteGroups = []int{8, 4, 4, 4, 12} +) + +func initClockSequence() { + buf := make([]byte, 2) + safeRandom(buf) + clockSequence = binary.BigEndian.Uint16(buf) +} + +func initHardwareAddr() { + interfaces, err := net.Interfaces() + if err == nil { + for _, iface := range interfaces { + if len(iface.HardwareAddr) >= 6 { + copy(hardwareAddr[:], iface.HardwareAddr) + return + } + } + } + + // Initialize hardwareAddr randomly in case + // of real network interfaces absence + safeRandom(hardwareAddr[:]) + + // Set multicast bit as recommended in RFC 4122 + hardwareAddr[0] |= 0x01 +} + +func initStorage() { + initClockSequence() + initHardwareAddr() +} + +func safeRandom(dest []byte) { + if _, err := rand.Read(dest); err != nil { + panic(err) + } +} + +// Returns difference in 100-nanosecond intervals between +// UUID epoch (October 15, 1582) and current time. +// This is default epoch calculation function. +func unixTimeFunc() uint64 { + return epochStart + uint64(time.Now().UnixNano()/100) +} + +// UUID representation compliant with specification +// described in RFC 4122. +type UUID [16]byte + +// The nil UUID is special form of UUID that is specified to have all +// 128 bits set to zero. +var Nil = UUID{} + +// Predefined namespace UUIDs. +var ( + NamespaceDNS, _ = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + NamespaceURL, _ = FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8") + NamespaceOID, _ = FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8") + NamespaceX500, _ = FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8") +) + +// And returns result of binary AND of two UUIDs. +func And(u1 UUID, u2 UUID) UUID { + u := UUID{} + for i := 0; i < 16; i++ { + u[i] = u1[i] & u2[i] + } + return u +} + +// Or returns result of binary OR of two UUIDs. +func Or(u1 UUID, u2 UUID) UUID { + u := UUID{} + for i := 0; i < 16; i++ { + u[i] = u1[i] | u2[i] + } + return u +} + +// Equal returns true if u1 and u2 equals, otherwise returns false. +func Equal(u1 UUID, u2 UUID) bool { + return bytes.Equal(u1[:], u2[:]) +} + +// Version returns algorithm version used to generate UUID. +func (u UUID) Version() uint { + return uint(u[6] >> 4) +} + +// Variant returns UUID layout variant. +func (u UUID) Variant() uint { + switch { + case (u[8] & 0x80) == 0x00: + return VariantNCS + case (u[8]&0xc0)|0x80 == 0x80: + return VariantRFC4122 + case (u[8]&0xe0)|0xc0 == 0xc0: + return VariantMicrosoft + } + return VariantFuture +} + +// Bytes returns bytes slice representation of UUID. +func (u UUID) Bytes() []byte { + return u[:] +} + +// Returns canonical string representation of UUID: +// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. +func (u UUID) String() string { + buf := make([]byte, 36) + + hex.Encode(buf[0:8], u[0:4]) + buf[8] = dash + hex.Encode(buf[9:13], u[4:6]) + buf[13] = dash + hex.Encode(buf[14:18], u[6:8]) + buf[18] = dash + hex.Encode(buf[19:23], u[8:10]) + buf[23] = dash + hex.Encode(buf[24:], u[10:]) + + return string(buf) +} + +// SetVersion sets version bits. +func (u *UUID) SetVersion(v byte) { + u[6] = (u[6] & 0x0f) | (v << 4) +} + +// SetVariant sets variant bits as described in RFC 4122. +func (u *UUID) SetVariant() { + u[8] = (u[8] & 0xbf) | 0x80 +} + +// MarshalText implements the encoding.TextMarshaler interface. +// The encoding is the same as returned by String. +func (u UUID) MarshalText() (text []byte, err error) { + text = []byte(u.String()) + return +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// Following formats are supported: +// "6ba7b810-9dad-11d1-80b4-00c04fd430c8", +// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", +// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" +func (u *UUID) UnmarshalText(text []byte) (err error) { + if len(text) < 32 { + err = fmt.Errorf("uuid: UUID string too short: %s", text) + return + } + + t := text[:] + + if bytes.Equal(t[:9], urnPrefix) { + t = t[9:] + } else if t[0] == '{' { + t = t[1:] + } + + b := u[:] + + for _, byteGroup := range byteGroups { + if t[0] == '-' { + t = t[1:] + } + + if len(t) < byteGroup { + err = fmt.Errorf("uuid: UUID string too short: %s", text) + return + } + + _, err = hex.Decode(b[:byteGroup/2], t[:byteGroup]) + + if err != nil { + return + } + + t = t[byteGroup:] + b = b[byteGroup/2:] + } + + return +} + +// MarshalBinary implements the encoding.BinaryMarshaler interface. +func (u UUID) MarshalBinary() (data []byte, err error) { + data = u.Bytes() + return +} + +// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. +// It will return error if the slice isn't 16 bytes long. +func (u *UUID) UnmarshalBinary(data []byte) (err error) { + if len(data) != 16 { + err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) + return + } + copy(u[:], data) + + return +} + +// Value implements the driver.Valuer interface. +func (u UUID) Value() (driver.Value, error) { + return u.String(), nil +} + +// Scan implements the sql.Scanner interface. +// A 16-byte slice is handled by UnmarshalBinary, while +// a longer byte slice or a string is handled by UnmarshalText. +func (u *UUID) Scan(src interface{}) error { + switch src := src.(type) { + case []byte: + if len(src) == 16 { + return u.UnmarshalBinary(src) + } + return u.UnmarshalText(src) + + case string: + return u.UnmarshalText([]byte(src)) + } + + return fmt.Errorf("uuid: cannot convert %T to UUID", src) +} + +// FromBytes returns UUID converted from raw byte slice input. +// It will return error if the slice isn't 16 bytes long. +func FromBytes(input []byte) (u UUID, err error) { + err = u.UnmarshalBinary(input) + return +} + +// FromBytesOrNil returns UUID converted from raw byte slice input. +// Same behavior as FromBytes, but returns a Nil UUID on error. +func FromBytesOrNil(input []byte) UUID { + uuid, err := FromBytes(input) + if err != nil { + return Nil + } + return uuid +} + +// FromString returns UUID parsed from string input. +// Input is expected in a form accepted by UnmarshalText. +func FromString(input string) (u UUID, err error) { + err = u.UnmarshalText([]byte(input)) + return +} + +// FromStringOrNil returns UUID parsed from string input. +// Same behavior as FromString, but returns a Nil UUID on error. +func FromStringOrNil(input string) UUID { + uuid, err := FromString(input) + if err != nil { + return Nil + } + return uuid +} + +// Returns UUID v1/v2 storage state. +// Returns epoch timestamp, clock sequence, and hardware address. +func getStorage() (uint64, uint16, []byte) { + storageOnce.Do(initStorage) + + storageMutex.Lock() + defer storageMutex.Unlock() + + timeNow := epochFunc() + // Clock changed backwards since last UUID generation. + // Should increase clock sequence. + if timeNow <= lastTime { + clockSequence++ + } + lastTime = timeNow + + return timeNow, clockSequence, hardwareAddr[:] +} + +// NewV1 returns UUID based on current timestamp and MAC address. +func NewV1() UUID { + u := UUID{} + + timeNow, clockSeq, hardwareAddr := getStorage() + + binary.BigEndian.PutUint32(u[0:], uint32(timeNow)) + binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) + binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) + binary.BigEndian.PutUint16(u[8:], clockSeq) + + copy(u[10:], hardwareAddr) + + u.SetVersion(1) + u.SetVariant() + + return u +} + +// NewV2 returns DCE Security UUID based on POSIX UID/GID. +func NewV2(domain byte) UUID { + u := UUID{} + + timeNow, clockSeq, hardwareAddr := getStorage() + + switch domain { + case DomainPerson: + binary.BigEndian.PutUint32(u[0:], posixUID) + case DomainGroup: + binary.BigEndian.PutUint32(u[0:], posixGID) + } + + binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) + binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) + binary.BigEndian.PutUint16(u[8:], clockSeq) + u[9] = domain + + copy(u[10:], hardwareAddr) + + u.SetVersion(2) + u.SetVariant() + + return u +} + +// NewV3 returns UUID based on MD5 hash of namespace UUID and name. +func NewV3(ns UUID, name string) UUID { + u := newFromHash(md5.New(), ns, name) + u.SetVersion(3) + u.SetVariant() + + return u +} + +// NewV4 returns random generated UUID. +func NewV4() UUID { + u := UUID{} + safeRandom(u[:]) + u.SetVersion(4) + u.SetVariant() + + return u +} + +// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name. +func NewV5(ns UUID, name string) UUID { + u := newFromHash(sha1.New(), ns, name) + u.SetVersion(5) + u.SetVariant() + + return u +} + +// Returns UUID based on hashing of namespace UUID and name. +func newFromHash(h hash.Hash, ns UUID, name string) UUID { + u := UUID{} + h.Write(ns[:]) + h.Write([]byte(name)) + copy(u[:], h.Sum(nil)) + + return u +} diff --git a/vendor/github.com/satori/go.uuid/uuid_test.go b/vendor/github.com/satori/go.uuid/uuid_test.go new file mode 100644 index 00000000..aa275345 --- /dev/null +++ b/vendor/github.com/satori/go.uuid/uuid_test.go @@ -0,0 +1,520 @@ +// Copyright (C) 2013, 2015 by Maxim Bublis +// +// 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. + +package uuid + +import ( + "bytes" + "testing" +) + +func TestBytes(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + bytes1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + if !bytes.Equal(u.Bytes(), bytes1) { + t.Errorf("Incorrect bytes representation for UUID: %s", u) + } +} + +func TestString(t *testing.T) { + if NamespaceDNS.String() != "6ba7b810-9dad-11d1-80b4-00c04fd430c8" { + t.Errorf("Incorrect string representation for UUID: %s", NamespaceDNS.String()) + } +} + +func TestEqual(t *testing.T) { + if !Equal(NamespaceDNS, NamespaceDNS) { + t.Errorf("Incorrect comparison of %s and %s", NamespaceDNS, NamespaceDNS) + } + + if Equal(NamespaceDNS, NamespaceURL) { + t.Errorf("Incorrect comparison of %s and %s", NamespaceDNS, NamespaceURL) + } +} + +func TestOr(t *testing.T) { + u1 := UUID{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff} + u2 := UUID{0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00} + + u := UUID{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} + + if !Equal(u, Or(u1, u2)) { + t.Errorf("Incorrect bitwise OR result %s", Or(u1, u2)) + } +} + +func TestAnd(t *testing.T) { + u1 := UUID{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff} + u2 := UUID{0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00} + + u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + if !Equal(u, And(u1, u2)) { + t.Errorf("Incorrect bitwise AND result %s", And(u1, u2)) + } +} + +func TestVersion(t *testing.T) { + u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + if u.Version() != 1 { + t.Errorf("Incorrect version for UUID: %d", u.Version()) + } +} + +func TestSetVersion(t *testing.T) { + u := UUID{} + u.SetVersion(4) + + if u.Version() != 4 { + t.Errorf("Incorrect version for UUID after u.setVersion(4): %d", u.Version()) + } +} + +func TestVariant(t *testing.T) { + u1 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + if u1.Variant() != VariantNCS { + t.Errorf("Incorrect variant for UUID variant %d: %d", VariantNCS, u1.Variant()) + } + + u2 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + if u2.Variant() != VariantRFC4122 { + t.Errorf("Incorrect variant for UUID variant %d: %d", VariantRFC4122, u2.Variant()) + } + + u3 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + if u3.Variant() != VariantMicrosoft { + t.Errorf("Incorrect variant for UUID variant %d: %d", VariantMicrosoft, u3.Variant()) + } + + u4 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + + if u4.Variant() != VariantFuture { + t.Errorf("Incorrect variant for UUID variant %d: %d", VariantFuture, u4.Variant()) + } +} + +func TestSetVariant(t *testing.T) { + u := new(UUID) + u.SetVariant() + + if u.Variant() != VariantRFC4122 { + t.Errorf("Incorrect variant for UUID after u.setVariant(): %d", u.Variant()) + } +} + +func TestFromBytes(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + u1, err := FromBytes(b1) + if err != nil { + t.Errorf("Error parsing UUID from bytes: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + b2 := []byte{} + + _, err = FromBytes(b2) + if err == nil { + t.Errorf("Should return error parsing from empty byte slice, got %s", err) + } +} + +func TestMarshalBinary(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + b2, err := u.MarshalBinary() + if err != nil { + t.Errorf("Error marshaling UUID: %s", err) + } + + if !bytes.Equal(b1, b2) { + t.Errorf("Marshaled UUID should be %s, got %s", b1, b2) + } +} + +func TestUnmarshalBinary(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + u1 := UUID{} + err := u1.UnmarshalBinary(b1) + if err != nil { + t.Errorf("Error unmarshaling UUID: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + b2 := []byte{} + u2 := UUID{} + + err = u2.UnmarshalBinary(b2) + if err == nil { + t.Errorf("Should return error unmarshalling from empty byte slice, got %s", err) + } +} + +func TestFromString(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + s2 := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" + s3 := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" + + _, err := FromString("") + if err == nil { + t.Errorf("Should return error trying to parse empty string, got %s", err) + } + + u1, err := FromString(s1) + if err != nil { + t.Errorf("Error parsing UUID from string: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + u2, err := FromString(s2) + if err != nil { + t.Errorf("Error parsing UUID from string: %s", err) + } + + if !Equal(u, u2) { + t.Errorf("UUIDs should be equal: %s and %s", u, u2) + } + + u3, err := FromString(s3) + if err != nil { + t.Errorf("Error parsing UUID from string: %s", err) + } + + if !Equal(u, u3) { + t.Errorf("UUIDs should be equal: %s and %s", u, u3) + } +} + +func TestFromStringShort(t *testing.T) { + // Invalid 35-character UUID string + s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c" + + for i := len(s1); i >= 0; i-- { + _, err := FromString(s1[:i]) + if err == nil { + t.Errorf("Should return error trying to parse too short string, got %s", err) + } + } +} + +func TestFromStringOrNil(t *testing.T) { + u := FromStringOrNil("") + if u != Nil { + t.Errorf("Should return Nil UUID on parse failure, got %s", u) + } +} + +func TestFromBytesOrNil(t *testing.T) { + b := []byte{} + u := FromBytesOrNil(b) + if u != Nil { + t.Errorf("Should return Nil UUID on parse failure, got %s", u) + } +} + +func TestMarshalText(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + + b2, err := u.MarshalText() + if err != nil { + t.Errorf("Error marshaling UUID: %s", err) + } + + if !bytes.Equal(b1, b2) { + t.Errorf("Marshaled UUID should be %s, got %s", b1, b2) + } +} + +func TestUnmarshalText(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + + u1 := UUID{} + err := u1.UnmarshalText(b1) + if err != nil { + t.Errorf("Error unmarshaling UUID: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + b2 := []byte("") + u2 := UUID{} + + err = u2.UnmarshalText(b2) + if err == nil { + t.Errorf("Should return error trying to unmarshal from empty string") + } +} + +func TestValue(t *testing.T) { + u, err := FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + if err != nil { + t.Errorf("Error parsing UUID from string: %s", err) + } + + val, err := u.Value() + if err != nil { + t.Errorf("Error getting UUID value: %s", err) + } + + if val != u.String() { + t.Errorf("Wrong value returned, should be equal: %s and %s", val, u) + } +} + +func TestScanBinary(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + + u1 := UUID{} + err := u1.Scan(b1) + if err != nil { + t.Errorf("Error unmarshaling UUID: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + b2 := []byte{} + u2 := UUID{} + + err = u2.Scan(b2) + if err == nil { + t.Errorf("Should return error unmarshalling from empty byte slice, got %s", err) + } +} + +func TestScanString(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + + u1 := UUID{} + err := u1.Scan(s1) + if err != nil { + t.Errorf("Error unmarshaling UUID: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + s2 := "" + u2 := UUID{} + + err = u2.Scan(s2) + if err == nil { + t.Errorf("Should return error trying to unmarshal from empty string") + } +} + +func TestScanText(t *testing.T) { + u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + + u1 := UUID{} + err := u1.Scan(b1) + if err != nil { + t.Errorf("Error unmarshaling UUID: %s", err) + } + + if !Equal(u, u1) { + t.Errorf("UUIDs should be equal: %s and %s", u, u1) + } + + b2 := []byte("") + u2 := UUID{} + + err = u2.Scan(b2) + if err == nil { + t.Errorf("Should return error trying to unmarshal from empty string") + } +} + +func TestScanUnsupported(t *testing.T) { + u := UUID{} + + err := u.Scan(true) + if err == nil { + t.Errorf("Should return error trying to unmarshal from bool") + } +} + +func TestNewV1(t *testing.T) { + u := NewV1() + + if u.Version() != 1 { + t.Errorf("UUIDv1 generated with incorrect version: %d", u.Version()) + } + + if u.Variant() != VariantRFC4122 { + t.Errorf("UUIDv1 generated with incorrect variant: %d", u.Variant()) + } + + u1 := NewV1() + u2 := NewV1() + + if Equal(u1, u2) { + t.Errorf("UUIDv1 generated two equal UUIDs: %s and %s", u1, u2) + } + + oldFunc := epochFunc + epochFunc = func() uint64 { return 0 } + + u3 := NewV1() + u4 := NewV1() + + if Equal(u3, u4) { + t.Errorf("UUIDv1 generated two equal UUIDs: %s and %s", u3, u4) + } + + epochFunc = oldFunc +} + +func TestNewV2(t *testing.T) { + u1 := NewV2(DomainPerson) + + if u1.Version() != 2 { + t.Errorf("UUIDv2 generated with incorrect version: %d", u1.Version()) + } + + if u1.Variant() != VariantRFC4122 { + t.Errorf("UUIDv2 generated with incorrect variant: %d", u1.Variant()) + } + + u2 := NewV2(DomainGroup) + + if u2.Version() != 2 { + t.Errorf("UUIDv2 generated with incorrect version: %d", u2.Version()) + } + + if u2.Variant() != VariantRFC4122 { + t.Errorf("UUIDv2 generated with incorrect variant: %d", u2.Variant()) + } +} + +func TestNewV3(t *testing.T) { + u := NewV3(NamespaceDNS, "www.example.com") + + if u.Version() != 3 { + t.Errorf("UUIDv3 generated with incorrect version: %d", u.Version()) + } + + if u.Variant() != VariantRFC4122 { + t.Errorf("UUIDv3 generated with incorrect variant: %d", u.Variant()) + } + + if u.String() != "5df41881-3aed-3515-88a7-2f4a814cf09e" { + t.Errorf("UUIDv3 generated incorrectly: %s", u.String()) + } + + u = NewV3(NamespaceDNS, "python.org") + + if u.String() != "6fa459ea-ee8a-3ca4-894e-db77e160355e" { + t.Errorf("UUIDv3 generated incorrectly: %s", u.String()) + } + + u1 := NewV3(NamespaceDNS, "golang.org") + u2 := NewV3(NamespaceDNS, "golang.org") + if !Equal(u1, u2) { + t.Errorf("UUIDv3 generated different UUIDs for same namespace and name: %s and %s", u1, u2) + } + + u3 := NewV3(NamespaceDNS, "example.com") + if Equal(u1, u3) { + t.Errorf("UUIDv3 generated same UUIDs for different names in same namespace: %s and %s", u1, u2) + } + + u4 := NewV3(NamespaceURL, "golang.org") + if Equal(u1, u4) { + t.Errorf("UUIDv3 generated same UUIDs for sane names in different namespaces: %s and %s", u1, u4) + } +} + +func TestNewV4(t *testing.T) { + u := NewV4() + + if u.Version() != 4 { + t.Errorf("UUIDv4 generated with incorrect version: %d", u.Version()) + } + + if u.Variant() != VariantRFC4122 { + t.Errorf("UUIDv4 generated with incorrect variant: %d", u.Variant()) + } +} + +func TestNewV5(t *testing.T) { + u := NewV5(NamespaceDNS, "www.example.com") + + if u.Version() != 5 { + t.Errorf("UUIDv5 generated with incorrect version: %d", u.Version()) + } + + if u.Variant() != VariantRFC4122 { + t.Errorf("UUIDv5 generated with incorrect variant: %d", u.Variant()) + } + + u = NewV5(NamespaceDNS, "python.org") + + if u.String() != "886313e1-3b8a-5372-9b90-0c9aee199e5d" { + t.Errorf("UUIDv5 generated incorrectly: %s", u.String()) + } + + u1 := NewV5(NamespaceDNS, "golang.org") + u2 := NewV5(NamespaceDNS, "golang.org") + if !Equal(u1, u2) { + t.Errorf("UUIDv5 generated different UUIDs for same namespace and name: %s and %s", u1, u2) + } + + u3 := NewV5(NamespaceDNS, "example.com") + if Equal(u1, u3) { + t.Errorf("UUIDv5 generated same UUIDs for different names in same namespace: %s and %s", u1, u2) + } + + u4 := NewV5(NamespaceURL, "golang.org") + if Equal(u1, u4) { + t.Errorf("UUIDv3 generated same UUIDs for sane names in different namespaces: %s and %s", u1, u4) + } +} From 9708716d41ce01911e52bc2cdb9cb65523e08baf Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 23 Apr 2016 21:58:20 -0700 Subject: [PATCH 016/357] Switch to newer drone format --- .drone.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index b0f0e2eb..9a8850fc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,4 +1,6 @@ -image: rancher/dind:v1.10.0-rancher1 -script: - - wrapdocker - - make ci +build: + image: rancher/dapper:1.10.3 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + commands: + - dapper ci From 35a6e28cc9ffd801289de18381c8d4ff5b0ed444 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 25 Apr 2016 08:42:15 -0700 Subject: [PATCH 017/357] Add snapshot controller API --- backend/file/file.go | 2 +- backend/remote/remote.go | 27 +++++++++++++++++++++------ controller/control.go | 15 +++++++++++---- controller/replicator.go | 10 ++++++++-- controller/rest/model.go | 16 ++++++++++++++-- controller/rest/router.go | 1 + controller/rest/volume.go | 24 ++++++++++++++++++++++++ integration/core/test_cli.py | 28 ++++++++++++++++++++++++++++ types/types.go | 2 +- util/util.go | 6 ++++++ 10 files changed, 115 insertions(+), 16 deletions(-) diff --git a/backend/file/file.go b/backend/file/file.go index fe5dbb2f..4ec437f2 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -23,7 +23,7 @@ func (f *Wrapper) Close() error { return f.File.Close() } -func (f *Wrapper) Snapshot() error { +func (f *Wrapper) Snapshot(name string) error { return nil } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index a263ff46..13fdb170 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -1,8 +1,10 @@ package remote import ( + "bytes" "encoding/json" "fmt" + "io" "net" "net/http" "strconv" @@ -36,20 +38,33 @@ type Remote struct { func (r *Remote) Close() error { logrus.Infof("Closing: %s", r.name) - return r.doAction("close") + return r.doAction("close", "") } -func (r *Remote) Snapshot() error { - logrus.Infof("Snapshot: %s", r.name) - return r.doAction("snapshot") +func (r *Remote) Snapshot(name string) error { + logrus.Infof("Snapshot: %s %s", r.name, name) + return r.doAction("snapshot", name) } -func (r *Remote) doAction(action string) error { - req, err := http.NewRequest("POST", r.replicaURL+"?action="+action, nil) +func (r *Remote) doAction(action, name string) error { + body := io.Reader(nil) + if name != "" { + buffer := &bytes.Buffer{} + if err := json.NewEncoder(buffer).Encode(&map[string]string{"name": name}); err != nil { + return err + } + body = buffer + } + + req, err := http.NewRequest("POST", r.replicaURL+"?action="+action, body) if err != nil { return err } + if name != "" { + req.Header.Add("Content-Type", "application/json") + } + resp, err := r.httpClient.Do(req) if err != nil { return err diff --git a/controller/control.go b/controller/control.go index 070f935d..75469a77 100644 --- a/controller/control.go +++ b/controller/control.go @@ -6,6 +6,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" ) type Controller struct { @@ -70,11 +71,15 @@ func (c *Controller) addReplica(address string, snapshot bool) error { return c.addReplicaNoLock(newBackend, address, snapshot) } -func (c *Controller) Snapshot() error { +func (c *Controller) Snapshot(name string) (string, error) { c.Lock() defer c.Unlock() - return c.backend.Snapshot() + if name == "" { + name = util.UUID() + } + + return name, c.backend.Snapshot(name) } func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { @@ -83,11 +88,13 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, } if snapshot { - if err := c.backend.Snapshot(); err != nil { + uuid := util.UUID() + + if err := c.backend.Snapshot(uuid); err != nil { newBackend.Close() return err } - if err := newBackend.Snapshot(); err != nil { + if err := newBackend.Snapshot(uuid); err != nil { newBackend.Close() return err } diff --git a/controller/replicator.go b/controller/replicator.go index 93496c5d..e99bfc10 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -161,14 +161,20 @@ func (r *replicator) SetMode(address string, mode types.Mode) { r.buildReadWriters() } -func (r *replicator) Snapshot() error { +func (r *replicator) Snapshot(name string) error { + for _, wrapper := range r.backends { + if wrapper.mode == types.ERR { + return errors.New("Can not snapshot while a replica is in ERR") + } + } + var lastErr error wg := sync.WaitGroup{} for _, backend := range r.backends { wg.Add(1) go func(backend types.Backend) { - if err := backend.Snapshot(); err != nil { + if err := backend.Snapshot(name); err != nil { lastErr = err } wg.Done() diff --git a/controller/rest/model.go b/controller/rest/model.go index 1f2a495f..25199077 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -36,6 +36,10 @@ type StartInput struct { Replicas []string `json:"replicas"` } +type SnapshotOutput struct { + client.Resource +} + func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { v := &Volume{ Resource: client.Resource{ @@ -47,8 +51,12 @@ func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { ReplicaCount: replicas, } - v.Actions["start"] = context.UrlBuilder.ActionLink(v.Resource, "start") - v.Actions["shutdown"] = context.UrlBuilder.ActionLink(v.Resource, "shutdown") + if replicas == 0 { + v.Actions["start"] = context.UrlBuilder.ActionLink(v.Resource, "start") + } else { + v.Actions["shutdown"] = context.UrlBuilder.ActionLink(v.Resource, "shutdown") + v.Actions["snapshot"] = context.UrlBuilder.ActionLink(v.Resource, "snapshot") + } return v } @@ -82,6 +90,7 @@ func NewSchema() *client.Schemas { schemas.AddType("apiVersion", client.Resource{}) schemas.AddType("schema", client.Schema{}) schemas.AddType("startInput", StartInput{}) + schemas.AddType("snapshotOutput", SnapshotOutput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} @@ -104,6 +113,9 @@ func NewSchema() *client.Schemas { "shutdown": client.Action{ Output: "volume", }, + "snapshot": client.Action{ + Output: "snapshotOutput", + }, } return schemas diff --git a/controller/rest/router.go b/controller/rest/router.go index 7519c8d1..f51c402b 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -33,6 +33,7 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "start").Handler(f(schemas, s.StartVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "shutdown").Handler(f(schemas, s.ShutdownVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "snapshot").Handler(f(schemas, s.SnapshotVolume)) // Replicas router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) diff --git a/controller/rest/volume.go b/controller/rest/volume.go index 42c6eb59..b8e2b826 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -49,6 +49,30 @@ func (s *Server) ShutdownVolume(rw http.ResponseWriter, req *http.Request) error return s.GetVolume(rw, req) } +func (s *Server) SnapshotVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + name, err := s.c.Snapshot("") + if err != nil { + return err + } + + apiContext.Write(&SnapshotOutput{ + client.Resource{ + Id: name, + Type: "snapshotOutput", + }, + }) + return nil +} + func (s *Server) StartVolume(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) id := mux.Vars(req)["id"] diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index a5d1592e..1075d218 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -144,3 +144,31 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, for r in replicas: assert r.mode == 'RW' + + +def test_snapshot(controller_client, replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + snap = v.snapshot() + assert snap.id != '' + + r1 = replica_client.list_replica()[0] + r2 = replica_client2.list_replica()[0] + + assert r2.chain == [ + 'volume-head-001.img', + 'volume-snap-{}.img'.format(snap.id), + ] + + assert r1.chain == [ + 'volume-head-001.img', + 'volume-snap-{}.img'.format(snap.id), + ] diff --git a/types/types.go b/types/types.go index b9f2efc1..89af9413 100644 --- a/types/types.go +++ b/types/types.go @@ -16,7 +16,7 @@ type ReaderWriterAt interface { type Backend interface { ReaderWriterAt io.Closer - Snapshot() error + Snapshot(name string) error Size() (int64, error) } diff --git a/util/util.go b/util/util.go index 05ce55c1..1f7cfaea 100644 --- a/util/util.go +++ b/util/util.go @@ -4,6 +4,8 @@ import ( "fmt" "regexp" "strconv" + + "github.com/satori/go.uuid" ) var ( @@ -23,3 +25,7 @@ func ParseAddresses(name string) (string, string, string, error) { fmt.Sprintf("%s:%d", host, port+1), fmt.Sprintf("%s:%d", host, port+2), nil } + +func UUID() string { + return uuid.NewV4().String() +} From 916853ba7f6097f75f60c258bcb624d61756fa24 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 25 Apr 2016 09:36:52 -0700 Subject: [PATCH 018/357] Add "snapshot ls" CLI --- app/add_replica.go | 15 +------ app/controller.go | 7 --- app/ls_replica.go | 45 +++++++++---------- app/replica.go | 7 --- app/rm_replica.go | 13 ------ app/snapshot.go | 85 ++++++++++++++++++++++++++++++++++++ app/sync_agent.go | 7 --- integration/core/test_cli.py | 52 ++++++++++++++++------ main.go | 21 ++++++++- util/util.go | 19 ++++++++ 10 files changed, 184 insertions(+), 87 deletions(-) create mode 100644 app/snapshot.go diff --git a/app/add_replica.go b/app/add_replica.go index 33895e06..0accc3fd 100644 --- a/app/add_replica.go +++ b/app/add_replica.go @@ -12,15 +12,6 @@ func AddReplicaCmd() cli.Command { return cli.Command{ Name: "add-replica", ShortName: "add", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "url", - Value: "http://localhost:9501", - }, - cli.BoolFlag{ - Name: "debug", - }, - }, Action: func(c *cli.Context) { if err := addReplica(c); err != nil { logrus.Fatal(err) @@ -35,11 +26,7 @@ func addReplica(c *cli.Context) error { } replica := c.Args()[0] - url := c.String("url") - if c.Bool("debug") { - logrus.SetLevel(logrus.DebugLevel) - } - + url := c.GlobalString("url") task := sync.NewTask(url) return task.AddReplica(replica) } diff --git a/app/controller.go b/app/controller.go index 422aa235..de763ba8 100644 --- a/app/controller.go +++ b/app/controller.go @@ -41,9 +41,6 @@ func ControllerCmd() cli.Command { cli.StringSliceFlag{ Name: "replica", }, - cli.BoolFlag{ - Name: "debug", - }, }, Action: func(c *cli.Context) { if err := startController(c); err != nil { @@ -64,10 +61,6 @@ func startController(c *cli.Context) error { replicas := c.StringSlice("replica") frontendName := c.String("frontend") - if c.Bool("debug") { - logrus.SetLevel(logrus.DebugLevel) - } - factories := map[string]types.BackendFactory{} for _, backend := range backends { switch backend { diff --git a/app/ls_replica.go b/app/ls_replica.go index 5268cb3c..3bd2a483 100644 --- a/app/ls_replica.go +++ b/app/ls_replica.go @@ -14,15 +14,6 @@ func LsReplicaCmd() cli.Command { return cli.Command{ Name: "ls-replica", ShortName: "ls", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "url", - Value: "http://localhost:9501", - }, - cli.BoolFlag{ - Name: "debug", - }, - }, Action: func(c *cli.Context) { if err := lsReplica(c); err != nil { logrus.Fatal(err) @@ -32,7 +23,7 @@ func LsReplicaCmd() cli.Command { } func getCli(c *cli.Context) *client.ControllerClient { - url := c.String("url") + url := c.GlobalString("url") return client.NewControllerClient(url) } @@ -45,26 +36,32 @@ func lsReplica(c *cli.Context) error { return err } + format := "%s\t%s\t%v\n" tw := tabwriter.NewWriter(os.Stdout, 0, 20, 1, ' ', 0) + fmt.Fprintf(tw, format, "ADDRESS", "MODE", "CHAIN") for _, r := range reps { chain := interface{}("") - repClient, err := client.NewReplicaClient(r.Address) - if err != nil { - chain = err.Error() - } - - if chain == "" { - r, err := repClient.GetReplica() - if err == nil { - chain = r.Chain - } else { - chain = err.Error() - } + chainList, err := getChain(r.Address) + if err == nil { + chain = chainList } - - fmt.Fprintf(tw, "%s\t%s\t%v\n", r.Address, r.Mode, chain) + fmt.Fprintf(tw, format, r.Address, r.Mode, chain) } tw.Flush() return nil } + +func getChain(address string) ([]string, error) { + repClient, err := client.NewReplicaClient(address) + if err != nil { + return nil, err + } + + r, err := repClient.GetReplica() + if err != nil { + return nil, err + } + + return r.Chain, err +} diff --git a/app/replica.go b/app/replica.go index 7dd77a4a..d613a4cb 100644 --- a/app/replica.go +++ b/app/replica.go @@ -30,9 +30,6 @@ func ReplicaCmd() cli.Command { cli.BoolTFlag{ Name: "sync-agent", }, - cli.BoolFlag{ - Name: "debug", - }, cli.StringFlag{ Name: "size", Usage: "Volume size in bytes or human readable 42kb, 42mb, 42gb", @@ -51,10 +48,6 @@ func startReplica(c *cli.Context) error { return errors.New("directory name is required") } - if c.Bool("debug") { - logrus.SetLevel(logrus.DebugLevel) - } - dir := c.Args()[0] s := replica.NewServer(dir, 4096) diff --git a/app/rm_replica.go b/app/rm_replica.go index 5de4cebd..010f996b 100644 --- a/app/rm_replica.go +++ b/app/rm_replica.go @@ -11,15 +11,6 @@ func RmReplicaCmd() cli.Command { return cli.Command{ Name: "rm-replica", ShortName: "rm", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "url", - Value: "http://localhost:9501", - }, - cli.BoolFlag{ - Name: "debug", - }, - }, Action: func(c *cli.Context) { if err := rmReplica(c); err != nil { logrus.Fatal(err) @@ -34,10 +25,6 @@ func rmReplica(c *cli.Context) error { } replica := c.Args()[0] - if c.Bool("debug") { - logrus.SetLevel(logrus.DebugLevel) - } - controllerClient := getCli(c) _, err := controllerClient.DeleteReplica(replica) return err diff --git a/app/snapshot.go b/app/snapshot.go new file mode 100644 index 00000000..0def43d7 --- /dev/null +++ b/app/snapshot.go @@ -0,0 +1,85 @@ +package app + +import ( + "fmt" + "os" + "strings" + "text/tabwriter" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/rancher/longhorn/util" +) + +func SnapshotCmd() cli.Command { + return cli.Command{ + Name: "snapshots", + ShortName: "snapshot", + Subcommands: []cli.Command{ + SnapshotLsCmd(), + }, + Action: func(c *cli.Context) { + if err := lsSnapshot(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func SnapshotLsCmd() cli.Command { + return cli.Command{ + Name: "ls", + Action: func(c *cli.Context) { + if err := lsSnapshot(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + +func lsSnapshot(c *cli.Context) error { + cli := getCli(c) + + replicas, err := cli.ListReplicas() + if err != nil { + return err + } + + first := true + snapshots := []string{} + for _, r := range replicas { + if r.Mode == "ERR" { + continue + } + + if first { + first = false + chain, err := getChain(r.Address) + if err != nil { + return err + } + snapshots = chain[1:] + continue + } + + chain, err := getChain(r.Address) + if err != nil { + return err + } + + snapshots = util.Filter(snapshots, func(i string) bool { + return util.Contains(chain, i) + }) + } + + format := "%s\n" + tw := tabwriter.NewWriter(os.Stdout, 0, 20, 1, ' ', 0) + fmt.Fprintf(tw, format, "ID") + for _, s := range snapshots { + s = strings.TrimSuffix(strings.TrimPrefix(s, "volume-snap-"), ".img") + fmt.Fprintf(tw, format, s) + } + tw.Flush() + + return nil +} diff --git a/app/sync_agent.go b/app/sync_agent.go index 66696b0b..a4310d83 100644 --- a/app/sync_agent.go +++ b/app/sync_agent.go @@ -16,9 +16,6 @@ func SyncAgentCmd() cli.Command { Name: "sync-agent", UsageText: "longhorn controller DIRECTORY SIZE", Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "debug", - }, cli.StringFlag{ Name: "listen", Value: "localhost:9504", @@ -37,10 +34,6 @@ func SyncAgentCmd() cli.Command { } func startSyncAgent(c *cli.Context) error { - if c.Bool("debug") { - logrus.SetLevel(logrus.DebugLevel) - } - listen := c.String("listen") portRange := c.String("listen-port-range") diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 1075d218..db0e6854 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -101,7 +101,7 @@ def open_replica(client): def test_replica_add_start(bin, controller_client, replica_client): open_replica(replica_client) - cmd = [bin, 'add-replica', '--debug', REPLICA] + cmd = [bin, '--debug', 'add-replica', REPLICA] subprocess.check_call(cmd) volume = controller_client.list_volume()[0] @@ -127,13 +127,13 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, 'volume-snap-001.img', 'volume-snap-000.img'] - cmd = [bin, 'add-replica', '--debug', REPLICA] + cmd = [bin, '--debug', 'add-replica', REPLICA] subprocess.check_call(cmd) volume = controller_client.list_volume()[0] assert volume.replicaCount == 1 - cmd = [bin, 'add-replica', '--debug', REPLICA2] + cmd = [bin, '--debug', 'add-replica', REPLICA2] subprocess.check_call(cmd) volume = controller_client.list_volume()[0] @@ -146,7 +146,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert r.mode == 'RW' -def test_snapshot(controller_client, replica_client, replica_client2): +def test_snapshot(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) open_replica(replica_client2) @@ -160,15 +160,39 @@ def test_snapshot(controller_client, replica_client, replica_client2): snap = v.snapshot() assert snap.id != '' - r1 = replica_client.list_replica()[0] - r2 = replica_client2.list_replica()[0] + snap2 = v.snapshot() + assert snap2.id != '' - assert r2.chain == [ - 'volume-head-001.img', - 'volume-snap-{}.img'.format(snap.id), - ] + cmd = [bin, '--debug', 'snapshot'] + output = subprocess.check_output(cmd) - assert r1.chain == [ - 'volume-head-001.img', - 'volume-snap-{}.img'.format(snap.id), - ] + assert output == '''ID +{} +{} +'''.format(snap2.id, snap.id) + + +def test_snapshot_ls(bin, controller_client, replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + snap = v.snapshot() + assert snap.id != '' + + snap2 = v.snapshot() + assert snap2.id != '' + + cmd = [bin, '--debug', 'snapshot', 'ls'] + output = subprocess.check_output(cmd) + + assert output == '''ID +{} +{} +'''.format(snap2.id, snap.id) diff --git a/main.go b/main.go index 38feee89..8e554577 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "os" "runtime/pprof" + "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/rancher/longhorn/app" ) @@ -21,6 +22,21 @@ func main() { } a := cli.NewApp() + a.Before = func(c *cli.Context) error { + if c.GlobalBool("debug") { + logrus.SetLevel(logrus.DebugLevel) + } + return nil + } + a.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "url", + Value: "http://localhost:9501", + }, + cli.BoolFlag{ + Name: "debug", + }, + } a.Commands = []cli.Command{ app.ControllerCmd(), app.ReplicaCmd(), @@ -28,7 +44,10 @@ func main() { app.AddReplicaCmd(), app.LsReplicaCmd(), app.RmReplicaCmd(), + app.SnapshotCmd(), } - a.Run(os.Args) + if err := a.Run(os.Args); err != nil { + logrus.Fatal(err) + } } diff --git a/util/util.go b/util/util.go index 1f7cfaea..757fed66 100644 --- a/util/util.go +++ b/util/util.go @@ -29,3 +29,22 @@ func ParseAddresses(name string) (string, string, string, error) { func UUID() string { return uuid.NewV4().String() } + +func Filter(list []string, check func(string) bool) []string { + result := make([]string, 0, len(list)) + for _, i := range list { + if check(i) { + result = append(result, i) + } + } + return result +} + +func Contains(arr []string, val string) bool { + for _, a := range arr { + if a == val { + return true + } + } + return false +} From c3a622e3de94c60f86b38c0145a3f6bd24ce8f00 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 25 Apr 2016 09:43:49 -0700 Subject: [PATCH 019/357] Add "snapshot create" command --- app/snapshot.go | 24 ++++++++++++++++++++++++ client/controller_client.go | 15 +++++++++++++++ integration/core/test_cli.py | 26 ++++++++++++++++++++++++++ replica/rest/replica.go | 4 ++-- 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index 0def43d7..4f625562 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -16,6 +16,7 @@ func SnapshotCmd() cli.Command { Name: "snapshots", ShortName: "snapshot", Subcommands: []cli.Command{ + SnapshotCreateCmd(), SnapshotLsCmd(), }, Action: func(c *cli.Context) { @@ -26,6 +27,17 @@ func SnapshotCmd() cli.Command { } } +func SnapshotCreateCmd() cli.Command { + return cli.Command{ + Name: "create", + Action: func(c *cli.Context) { + if err := createSnapshot(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + func SnapshotLsCmd() cli.Command { return cli.Command{ Name: "ls", @@ -37,6 +49,18 @@ func SnapshotLsCmd() cli.Command { } } +func createSnapshot(c *cli.Context) error { + cli := getCli(c) + + id, err := cli.Snapshot() + if err != nil { + return err + } + + fmt.Println(id) + return nil +} + func lsSnapshot(c *cli.Context) error { cli := getCli(c) diff --git a/client/controller_client.go b/client/controller_client.go index 36e8765d..087a3d3c 100644 --- a/client/controller_client.go +++ b/client/controller_client.go @@ -37,6 +37,21 @@ func (c *ControllerClient) Start(replicas ...string) error { }, nil) } +func (c *ControllerClient) Snapshot() (string, error) { + volume, err := c.GetVolume() + if err != nil { + return "", err + } + + output := &rest.SnapshotOutput{} + err = c.post(volume.Actions["snapshot"], nil, output) + if err != nil { + return "", err + } + + return output.Id, err +} + func (c *ControllerClient) ListReplicas() ([]rest.Replica, error) { var resp rest.ReplicaCollection err := c.get("/replicas", &resp) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index db0e6854..f8d7838f 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -196,3 +196,29 @@ def test_snapshot_ls(bin, controller_client, replica_client, replica_client2): {} {} '''.format(snap2.id, snap.id) + + +def test_snapshot_create(bin, controller_client, replica_client, + replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + cmd = [bin, 'snapshot', 'create'] + output = subprocess.check_output(cmd).strip() + expected = replica_client.list_replica()[0].chain[1] + + assert expected == 'volume-snap-{}.img'.format(output) + + cmd = [bin, '--debug', 'snapshot', 'ls'] + ls_output = subprocess.check_output(cmd) + + assert ls_output == '''ID +{} +'''.format(output) diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 1098875b..d4fe364c 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -8,7 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" - "github.com/satori/go.uuid" + "github.com/rancher/longhorn/util" ) func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { @@ -83,7 +83,7 @@ func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) erro name := input.Name if name == "" { - name = uuid.NewV4().String() + name = util.UUID() } return s.doOp(req, s.s.Snapshot(name)) From f2a228271ad788ce0c925bf37ca74d76acbae81a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 25 Apr 2016 10:29:04 -0700 Subject: [PATCH 020/357] tcmu: Fix poll return 0 This patch will fix `poll received unexpected revent: 0x0` This event is harmless, and shouldn't result in TCMU polling failure. --- frontend/tcmu/cfunc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index bebc8212..a2a85912 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -72,7 +72,7 @@ int tcmu_wait_for_next_command(struct tcmu_device *dev) { poll(&pfd, 1, -1); - if (pfd.revents != POLLIN) { + if (pfd.revents != 0 && pfd.revents != POLLIN) { errp("poll received unexpected revent: 0x%x\n", pfd.revents); return -1; } From 79f23e3550d70a48d42639124c30d3ac9b1fb2f3 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 25 Apr 2016 12:57:13 -0700 Subject: [PATCH 021/357] Fix aufs --- Dockerfile.dapper | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 7a2fc14a..12ae9a9c 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,5 +61,7 @@ RUN go get -d github.com/kp6/alphorn/ssync && \ cd ssync && \ go build -o /usr/local/bin/ssync +VOLUME /tmp +ENV TMPDIR /tmp ENTRYPOINT ["./scripts/entry"] CMD ["build"] From 9fdd86837daa67cac1a513d2c74285cfeca90568 Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 02:24:54 -0700 Subject: [PATCH 022/357] replica: switched to O_DIRECT --- replica/diff_disk.go | 5 +++-- replica/replica.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 162923c4..3fef2bb3 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -5,6 +5,7 @@ import ( "os" "github.com/frostschutz/go-fibmap" + fio "github.com/rancher/sparse-utils/directfio" ) type diffDisk struct { @@ -42,7 +43,7 @@ func (d *diffDisk) WriteAt(buf []byte, offset int64) (int, error) { startSector := offset / d.sectorSize sectors := int64(len(buf)) / d.sectorSize - c, err := d.files[target].WriteAt(buf, offset) + c, err := fio.WriteAt(d.files[target], buf, offset) // Regardless of err mark bytes as written for i := int64(0); i < sectors; i++ { @@ -100,7 +101,7 @@ func (d *diffDisk) read(target byte, buf []byte, offset int64, startSector int64 bufStart := startSector * d.sectorSize bufEnd := sectors * d.sectorSize newBuf := buf[bufStart : bufStart+bufEnd] - return d.files[target].ReadAt(newBuf, offset+bufStart) + return fio.ReadAt(d.files[target], newBuf, offset+bufStart) } func (d *diffDisk) lookup(sector int64) (byte, error) { diff --git a/replica/replica.go b/replica/replica.go index 1de160db..e7b6c0a0 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -13,6 +13,7 @@ import ( "syscall" "github.com/Sirupsen/logrus" + fio "github.com/rancher/sparse-utils/directfio" ) const ( @@ -223,7 +224,7 @@ func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) func (r *Replica) openFile(name string, flag int) (*os.File, error) { // TODO: need to turn on O_DIRECT - return os.OpenFile(path.Join(r.dir, name), os.O_RDWR|os.O_CREATE|flag, 0666) + return os.OpenFile(path.Join(r.dir, name), fio.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) } func (r *Replica) createNewHead(oldHead, parent string) (*os.File, disk, error) { From f05ff5a97046d98766cc9e9edae1d92b6d513325 Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 02:31:05 -0700 Subject: [PATCH 023/357] trash: added reference to directfio --- trash.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trash.yml b/trash.yml index 6d38debb..64b8709e 100644 --- a/trash.yml +++ b/trash.yml @@ -22,3 +22,5 @@ import: version: 71f57d300dd6a780ac1856c005c4b518cfd498ec - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 +- package: github.com/rancher/sparse-utils + version: 337dc0010fc0b05fe34736bca8d988153ca1e61b From 0900faae9039dccffdee0b0caa61d60e04ea5244 Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 11:59:44 -0700 Subject: [PATCH 024/357] replica: got rid of fio reference --- replica/replica.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index e7b6c0a0..3e0e6889 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -13,7 +13,6 @@ import ( "syscall" "github.com/Sirupsen/logrus" - fio "github.com/rancher/sparse-utils/directfio" ) const ( @@ -224,7 +223,7 @@ func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) func (r *Replica) openFile(name string, flag int) (*os.File, error) { // TODO: need to turn on O_DIRECT - return os.OpenFile(path.Join(r.dir, name), fio.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) + return os.OpenFile(path.Join(r.dir, name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) } func (r *Replica) createNewHead(oldHead, parent string) (*os.File, disk, error) { From 4d0c9698ae5df77557decfa07d8581e47638a36c Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 12:00:34 -0700 Subject: [PATCH 025/357] relplica: corrected package reference --- replica/diff_disk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 3fef2bb3..91cfcbe9 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -5,7 +5,7 @@ import ( "os" "github.com/frostschutz/go-fibmap" - fio "github.com/rancher/sparse-utils/directfio" + fio "github.com/rancher/sparse-tools/directfio" ) type diffDisk struct { From 89e9658f156cd5dcf328ab65ea9dea2e2676419b Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Mon, 25 Apr 2016 16:38:41 -0700 Subject: [PATCH 026/357] bump to go-1.6.2 --- Dockerfile.dapper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 12ae9a9c..909da5a0 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -26,8 +26,8 @@ RUN apt-get update && \ python-tox # Install Go 1.6 -RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz -RUN echo '6d894da8b4ad3f7f6c295db0d73ccc3646bce630e1c43e662a0120681d47e988 go.tar.gz' | sha256sum -c && \ +RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz +RUN echo 'e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a go.tar.gz' | sha256sum -c && \ tar xzf go.tar.gz -C /usr/local && \ rm go.tar.gz RUN mkdir -p /go From 611231947e9de0eadfe0463e636a41d2aa13a731 Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 12:53:10 -0700 Subject: [PATCH 027/357] dapper: updated ssync, directfio dependencies --- Dockerfile.dapper | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 12ae9a9c..9ddef0d1 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -54,10 +54,10 @@ RUN cd /usr/src/tcmu-runner && \ cp scsi_defs.h /usr/local/include && \ cp libtcmu_static.a /usr/local/lib/libtcmu.a -# Install ssync -RUN go get -d github.com/kp6/alphorn/ssync && \ - cd $GOPATH/src/github.com/kp6/alphorn && \ - git checkout c7705144deb2d398820fd248c261d2279b27f45d && \ +# Install ssync, etc +RUN go get -d github.com/rancher/sparse-tools/ssync && \ + cd $GOPATH/src/github.com/rancher/sparse-tools && \ + git checkout 84fc96db3ee359d3e5675df414494c09c7d0c0c2 && \ cd ssync && \ go build -o /usr/local/bin/ssync From c25255b1e330c6fad0ffdfe68725805109e65e85 Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 15:05:59 -0700 Subject: [PATCH 028/357] trash: fixed ref to psarse-tools vendor: added sparse-tools --- trash.yml | 4 +- .../rancher/sparse-tools/.gitignore | 29 +++ .../github.com/rancher/sparse-tools/LICENSE | 201 ++++++++++++++++ .../github.com/rancher/sparse-tools/README.md | 2 + .../sparse-tools/directfio/directfio.go | 62 +++++ .../sparse-tools/directfio/directfio_test.go | 227 ++++++++++++++++++ 6 files changed, 523 insertions(+), 2 deletions(-) create mode 100644 vendor/github.com/rancher/sparse-tools/.gitignore create mode 100644 vendor/github.com/rancher/sparse-tools/LICENSE create mode 100644 vendor/github.com/rancher/sparse-tools/README.md create mode 100644 vendor/github.com/rancher/sparse-tools/directfio/directfio.go create mode 100644 vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go diff --git a/trash.yml b/trash.yml index 64b8709e..1f33ce45 100644 --- a/trash.yml +++ b/trash.yml @@ -22,5 +22,5 @@ import: version: 71f57d300dd6a780ac1856c005c4b518cfd498ec - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 -- package: github.com/rancher/sparse-utils - version: 337dc0010fc0b05fe34736bca8d988153ca1e61b +- package: github.com/rancher/sparse-tools + version: 84fc96db3ee359d3e5675df414494c09c7d0c0c2 diff --git a/vendor/github.com/rancher/sparse-tools/.gitignore b/vendor/github.com/rancher/sparse-tools/.gitignore new file mode 100644 index 00000000..96073d7e --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/.gitignore @@ -0,0 +1,29 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so +ssync + +# test data files +*.bar + +# Folders +_obj +_test +.vscode + +# 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/vendor/github.com/rancher/sparse-tools/LICENSE b/vendor/github.com/rancher/sparse-tools/LICENSE new file mode 100644 index 00000000..8dada3ed --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/LICENSE @@ -0,0 +1,201 @@ + 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/rancher/sparse-tools/README.md b/vendor/github.com/rancher/sparse-tools/README.md new file mode 100644 index 00000000..5e8ace3a --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/README.md @@ -0,0 +1,2 @@ +# alphorn +sparse storage slab synchronization, etc. diff --git a/vendor/github.com/rancher/sparse-tools/directfio/directfio.go b/vendor/github.com/rancher/sparse-tools/directfio/directfio.go new file mode 100644 index 00000000..e8172b67 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/directfio/directfio.go @@ -0,0 +1,62 @@ +package directfio + +import ( + "unsafe" + "os" +) + +const ( + // what to align the block buffer to + alignment = 4096 + + // BlockSize sic + BlockSize = alignment +) + +// ReadAt read into unaligned data buffer via direct I/O +func ReadAt(file *os.File, data []byte, offset int64) (int, error) { + if alignmentShift(data) == 0 { + return file.ReadAt(data, offset) + } + buf := AllocateAligned(len(data)) + n, err := file.ReadAt(buf, offset) + copy(data, buf) + return n, err +} + +// WriteAt write from unaligned data buffer via direct I/O +func WriteAt(file *os.File, data []byte, offset int64) (int, error) { + if alignmentShift(data) == 0 { + return file.WriteAt(data, offset) + } + // Write unaligned + buf := AllocateAligned(len(data)) + copy(buf, data) + n, err := file.WriteAt(buf, offset) + return n, err +} + +// AllocateAligned returns []byte of size aligned to alignment +func AllocateAligned(size int) []byte { + block := make([]byte, size+alignment) + shift := alignmentShift(block) + offset := 0 + if shift != 0 { + offset = alignment - shift + } + block = block[offset:size] + shift = alignmentShift(block) + if shift != 0 { + panic("Alignment failure") + } + return block +} + +// alignmentShift returns alignment of the block in memory +func alignmentShift(block []byte) int { + if len(block) == 0 { + return 0 + } + return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(alignment-1)) +} + diff --git a/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go b/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go new file mode 100644 index 00000000..4e7a0c03 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go @@ -0,0 +1,227 @@ +package directfio_test + +import ( + "bytes" + "os" + "testing" + + "log" + "time" + + "io/ioutil" + + fio "github.com/rancher/sparse-tools/directfio" + "syscall" +) + +func tempFileName() string { + // Make a temporary file name + f, err := ioutil.TempFile("", "fio_test") + if err != nil { + log.Fatal("Failed to make temp file", err) + } + defer f.Close() + return f.Name() +} + +func cleanup(path string) { + // Cleanup + err := os.Remove(path) + if err != nil { + log.Fatal("Failed to remove file", path, err) + } +} + +func fillData(data []byte, start int) { + for i := 0; i < len(data); i++ { + data[i] = byte(start + i) + } +} + +func TestDirectFileIO1(t *testing.T) { + blocks := 4 + + // Init data + data1 := fio.AllocateAligned(blocks * fio.BlockSize) + fillData(data1, 0) + + path := tempFileName() + { + // Write + f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0644) + if err != nil { + t.Fatal("Failed to OpenFile for write", err) + } + defer f.Close() + + _, err = f.WriteAt(data1, int64(blocks*fio.BlockSize)) + if err != nil { + t.Fatal("Failed to write", err) + } + } + + data2 := fio.AllocateAligned(blocks * fio.BlockSize) + { + // Read + f, err := os.OpenFile(path, os.O_RDONLY|syscall.O_DIRECT, 0) + if err != nil { + t.Fatal("Failed to OpenFile for read", err) + } + defer f.Close() + + _, err = f.ReadAt(data2, int64(blocks*fio.BlockSize)) + if err != nil { + t.Fatal("Failed to read", err) + } + } + + // Check + if !bytes.Equal(data1, data2) { + t.Fatal("Read not the same as written") + } + + cleanup(path) +} + +func TestDirectFileIO2(t *testing.T) { + blocks := 4 + + // Init data + data1 := make([]byte, blocks*fio.BlockSize) + fillData(data1, 0) + + path := tempFileName() + { + // Write + f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0644) + if err != nil { + t.Fatal("Failed to OpenFile for write", err) + } + defer f.Close() + + _, err = fio.WriteAt(f, data1, int64(blocks*fio.BlockSize)) + if err != nil { + t.Fatal("Failed to write", err) + } + } + + data2 := make([]byte, blocks*fio.BlockSize) + { + // Read + f, err := os.OpenFile(path, os.O_RDONLY|syscall.O_DIRECT, 0) + if err != nil { + t.Fatal("Failed to OpenFile for read", err) + } + defer f.Close() + + _, err = fio.ReadAt(f, data2, int64(blocks*fio.BlockSize)) + if err != nil { + t.Fatal("Failed to read", err) + } + } + + // Check + if !bytes.Equal(data1, data2) { + t.Fatal("Read not the same as written") + } + + cleanup(path) +} + +const fileSize = int64(512) /*MB*/ << 20 + +const FileMode = os.O_WRONLY | syscall.O_DIRECT + +func write(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { + data := fio.AllocateAligned(batchSize) + fillData(data, 0) + + f, err := os.OpenFile(path, FileMode, 0) + if err != nil { + b.Fatal("Failed to OpenFile for write", err) + } + defer f.Close() + + for pos := offset; pos < offset+size; pos += int64(batchSize) { + _, err = f.WriteAt(data, pos) + if err != nil { + b.Fatal("Failed to write", err) + } + } + done <- true +} + +func writeUnaligned(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { + data := make([]byte, batchSize) + fillData(data, 0) + + f, err := os.OpenFile(path, FileMode, 0) + if err != nil { + b.Fatal("Failed to OpenFile for write", err) + } + defer f.Close() + + for pos := offset; pos < offset+size; pos += int64(batchSize) { + _, err = fio.WriteAt(f, data, pos) + if err != nil { + b.Fatal("Failed to write", err) + } + } + done <- true +} + +func writeTest(b *testing.B, path string, writers, batch int, write func(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64)) { + done := make(chan bool, writers) + chunkSize := fileSize / int64(writers) + + start := time.Now().Unix() + ioSize := batch * fio.BlockSize + for i := 0; i < writers; i++ { + go write(b, path, done, ioSize, int64(i)*chunkSize, chunkSize) + } + for i := 0; i < writers; i++ { + <-done + } + stop := time.Now().Unix() + log.Println("writers=", writers, "batch=", batch, "(blocks)", "thruput=", fileSize/(1<<20)/(stop-start), "(MB/s)") +} + +func BenchmarkWrite8(b *testing.B) { + path := tempFileName() + + f, err := os.OpenFile(path, os.O_CREATE|FileMode, 0644) + if err != nil { + b.Fatal("Failed to OpenFile for write", err) + } + defer f.Close() + f.Truncate(fileSize) + + for batch := 32; batch >= 1; batch >>= 1 { + log.Println("") + for writers := 1; writers <= 8; writers <<= 1 { + writeTest(b, path, writers, batch, write) + } + } + + cleanup(path) +} + +func BenchmarkWrite8u(b *testing.B) { + path := tempFileName() + + f, err := os.OpenFile(path, os.O_CREATE|FileMode, 0644) + if err != nil { + b.Fatal("Failed to OpenFile for write", err) + } + defer f.Close() + f.Truncate(fileSize) + + for batch := 32; batch >= 1; batch >>= 1 { + log.Println("") + for writers := 1; writers <= 8; writers <<= 1 { + writeTest(b, path, writers, batch, writeUnaligned) + } + } + + cleanup(path) +} From b55e49fdcdd1832d5c016d984c6732f390b3a4aa Mon Sep 17 00:00:00 2001 From: kirill Date: Mon, 25 Apr 2016 15:55:06 -0700 Subject: [PATCH 029/357] go fmt --- replica/diff_disk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 91cfcbe9..8c73585c 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -5,7 +5,7 @@ import ( "os" "github.com/frostschutz/go-fibmap" - fio "github.com/rancher/sparse-tools/directfio" + fio "github.com/rancher/sparse-tools/directfio" ) type diffDisk struct { From 7441bb44915beb19798e696a14adf00c710cd4fa Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 26 Apr 2016 04:30:54 +0000 Subject: [PATCH 030/357] Working docker image --- package/Dockerfile | 5 +++++ package/launch | 14 ++++++++++++++ scripts/package | 1 + 3 files changed, 20 insertions(+) create mode 100755 package/launch diff --git a/package/Dockerfile b/package/Dockerfile index 26bc7203..cd70b58b 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,3 +1,8 @@ FROM ubuntu:16.04 + +RUN apt-get update && apt-get install kmod + COPY longhorn /usr/bin/ +COPY launch /usr/bin/ +COPY ssync /usr/bin/ CMD ["longhorn"] diff --git a/package/launch b/package/launch new file mode 100755 index 00000000..fb8b8195 --- /dev/null +++ b/package/launch @@ -0,0 +1,14 @@ +#!/bin/bash + +set -x + +if [ "$1" == "controller" ]; then + if [ ! -d /sys/kernel/config ]; then + modprobe target_core_user + fi + + mount --rbind /host/dev /dev + mount -t configfs none /sys/kernel/config +fi + +exec longhorn "$@" diff --git a/scripts/package b/scripts/package index 37b91174..8fd588ac 100755 --- a/scripts/package +++ b/scripts/package @@ -12,6 +12,7 @@ if [ ! -x ../bin/longhorn ]; then ../scripts/build fi +cp /usr/local/bin/ssync . cp ../bin/longhorn . docker build -t ${REPO}/longhorn:${TAG} . From a0cb2da8267ecbaf89dedd35b3d2d523a75f4d9b Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 25 Apr 2016 12:25:09 -0700 Subject: [PATCH 031/357] Scripts to add longhorn-agent to repo --- package/Dockerfile | 2 +- scripts/build-agent | 9 + scripts/ci | 1 + scripts/package | 2 +- trash.yml | 2 + .../rancher/go-rancher-metadata/.gitignore | 1 + .../rancher/go-rancher-metadata/README.md | 40 ++++ .../rancher/go-rancher-metadata/main.go | 31 +++ .../go-rancher-metadata/metadata/change.go | 27 +++ .../go-rancher-metadata/metadata/metadata.go | 194 ++++++++++++++++++ .../go-rancher-metadata/metadata/types.go | 49 +++++ .../go-rancher-metadata/metadata/utils.go | 19 ++ 12 files changed, 375 insertions(+), 2 deletions(-) create mode 100755 scripts/build-agent create mode 100644 vendor/github.com/rancher/go-rancher-metadata/.gitignore create mode 100644 vendor/github.com/rancher/go-rancher-metadata/README.md create mode 100644 vendor/github.com/rancher/go-rancher-metadata/main.go create mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/change.go create mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go create mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/types.go create mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go diff --git a/package/Dockerfile b/package/Dockerfile index 26bc7203..269c1bb6 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,3 +1,3 @@ FROM ubuntu:16.04 -COPY longhorn /usr/bin/ +COPY longhorn longhorn-agent /usr/bin/ CMD ["longhorn"] diff --git a/scripts/build-agent b/scripts/build-agent new file mode 100755 index 00000000..98739864 --- /dev/null +++ b/scripts/build-agent @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source $(dirname $0)/version + +cd $(dirname $0)/.. + +mkdir -p bin +go build -tags tcmu -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn-agent ./agent diff --git a/scripts/ci b/scripts/ci index 502224c5..e86607c8 100755 --- a/scripts/ci +++ b/scripts/ci @@ -4,6 +4,7 @@ set -e cd $(dirname $0) ./build +./build-agent ./test ./validate ./integration-test diff --git a/scripts/package b/scripts/package index 37b91174..91da0a46 100755 --- a/scripts/package +++ b/scripts/package @@ -12,7 +12,7 @@ if [ ! -x ../bin/longhorn ]; then ../scripts/build fi -cp ../bin/longhorn . +cp ../bin/longhorn* . docker build -t ${REPO}/longhorn:${TAG} . echo Built ${REPO}/longhorn:${TAG} diff --git a/trash.yml b/trash.yml index 1f33ce45..31801519 100644 --- a/trash.yml +++ b/trash.yml @@ -24,3 +24,5 @@ import: version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools version: 84fc96db3ee359d3e5675df414494c09c7d0c0c2 +- package: github.com/rancher/go-rancher-metadata + version: 721b783c9983a17ec0d63d5530337610de9519ec diff --git a/vendor/github.com/rancher/go-rancher-metadata/.gitignore b/vendor/github.com/rancher/go-rancher-metadata/.gitignore new file mode 100644 index 00000000..11c2ad0c --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/.gitignore @@ -0,0 +1 @@ +go-rancher-metadata diff --git a/vendor/github.com/rancher/go-rancher-metadata/README.md b/vendor/github.com/rancher/go-rancher-metadata/README.md new file mode 100644 index 00000000..9ac7dede --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/README.md @@ -0,0 +1,40 @@ +# Go bindings for Rancher-metadata + +This library is incomplete, but implements a variety of calls against [rancher-metadata](https://github.com/rancher/rancher-metadata) service + +#Example usage + +```go +package main + +import ( + "time" + + "github.com/Sirupsen/logrus" + "github.com/rancher/go-rancher-metadata/metadata" +) + +const ( + metadataUrl = "http://rancher-metadata/2015-12-19" +) + +func main() { + + m := metadata.NewClient(metadataUrl) + + version := "init" + + for { + newVersion, err := m.GetVersion() + if err != nil { + logrus.Errorf("Error reading metadata version: %v", err) + } else if version == newVersion { + logrus.Debug("No changes in metadata version") + } else { + logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) + version = newVersion + } + time.Sleep(5 * time.Second) + } +} +``` diff --git a/vendor/github.com/rancher/go-rancher-metadata/main.go b/vendor/github.com/rancher/go-rancher-metadata/main.go new file mode 100644 index 00000000..fe3037eb --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "time" + + "github.com/Sirupsen/logrus" + "github.com/rancher/go-rancher-metadata/metadata" +) + +const ( + metadataUrl = "http://rancher-metadata/2015-12-19" +) + +func main() { + m := metadata.NewClient(metadataUrl) + + version := "init" + + for { + newVersion, err := m.GetVersion() + if err != nil { + logrus.Errorf("Error reading metadata version: %v", err) + } else if version == newVersion { + logrus.Debug("No changes in metadata version") + } else { + logrus.Debugf("Metadata version has changed, oldVersion=[%s], newVersion=[%s]", version, newVersion) + version = newVersion + } + time.Sleep(5 * time.Second) + } +} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/change.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/change.go new file mode 100644 index 00000000..80ca02cd --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/metadata/change.go @@ -0,0 +1,27 @@ +package metadata + +import ( + "time" + + "github.com/Sirupsen/logrus" +) + +func (m *Client) OnChange(intervalSeconds int, do func(string)) { + interval := time.Duration(intervalSeconds) + version := "init" + + for { + newVersion, err := m.GetVersion() + if err != nil { + logrus.Errorf("Error reading metadata version: %v", err) + time.Sleep(interval * time.Second) + } else if version == newVersion { + logrus.Debug("No changes in metadata version") + time.Sleep(interval * time.Second) + } else { + logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) + version = newVersion + do(newVersion) + } + } +} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go new file mode 100644 index 00000000..74e8e4d8 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go @@ -0,0 +1,194 @@ +package metadata + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" +) + +type Client struct { + url string +} + +func NewClient(url string) *Client { + return &Client{url} +} + +func NewClientAndWait(url string) (*Client, error) { + client := &Client{url} + + if err := testConnection(client); err != nil { + return nil, err + } + + return client, nil +} + +func (m *Client) SendRequest(path string) ([]byte, error) { + client := &http.Client{} + req, err := http.NewRequest("GET", m.url+path, nil) + req.Header.Add("Accept", "application/json") + resp, err := client.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 200 { + return nil, fmt.Errorf("Error %v accessing %v path", resp.StatusCode, path) + } + + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + return body, nil +} + +func (m *Client) GetVersion() (string, error) { + resp, err := m.SendRequest("/version") + if err != nil { + return "", err + } + return string(resp[:]), nil +} + +func (m *Client) GetSelfContainer() (Container, error) { + resp, err := m.SendRequest("/self/container") + var container Container + if err != nil { + return container, err + } + + if err = json.Unmarshal(resp, &container); err != nil { + return container, err + } + + return container, nil +} + +func (m *Client) GetSelfServiceByName(name string) (Service, error) { + resp, err := m.SendRequest("/self/stack/services/" + name) + var service Service + if err != nil { + return service, err + } + + if err = json.Unmarshal(resp, &service); err != nil { + return service, err + } + + return service, nil +} + +func (m *Client) GetSelfService() (Service, error) { + resp, err := m.SendRequest("/self/service") + var service Service + if err != nil { + return service, err + } + + if err = json.Unmarshal(resp, &service); err != nil { + return service, err + } + + return service, nil +} + +func (m *Client) GetSelfStack() (Stack, error) { + resp, err := m.SendRequest("/self/stack") + var stack Stack + if err != nil { + return stack, err + } + + if err = json.Unmarshal(resp, &stack); err != nil { + return stack, err + } + + return stack, nil +} + +func (m *Client) GetServices() ([]Service, error) { + resp, err := m.SendRequest("/services") + var services []Service + if err != nil { + return services, err + } + + if err = json.Unmarshal(resp, &services); err != nil { + return services, err + } + return services, nil +} + +func (m *Client) GetStacks() ([]Stack, error) { + resp, err := m.SendRequest("/stacks") + var stacks []Stack + if err != nil { + return stacks, err + } + + if err = json.Unmarshal(resp, &stacks); err != nil { + return stacks, err + } + return stacks, nil +} + +func (m *Client) GetContainers() ([]Container, error) { + resp, err := m.SendRequest("/containers") + var containers []Container + if err != nil { + return containers, err + } + + if err = json.Unmarshal(resp, &containers); err != nil { + return containers, err + } + return containers, nil +} + +func (m *Client) GetServiceContainers(serviceName string, stackName string) ([]Container, error) { + var serviceContainers = []Container{} + containers, err := m.GetContainers() + if err != nil { + return serviceContainers, err + } + + for _, container := range containers { + if container.StackName == stackName && container.ServiceName == serviceName { + serviceContainers = append(serviceContainers, container) + } + } + + return serviceContainers, nil +} + +func (m *Client) GetHosts() ([]Host, error) { + resp, err := m.SendRequest("/hosts") + var hosts []Host + if err != nil { + return hosts, err + } + + if err = json.Unmarshal(resp, &hosts); err != nil { + return hosts, err + } + return hosts, nil +} + +func (m *Client) GetHost(UUID string) (Host, error) { + var host Host + hosts, err := m.GetHosts() + if err != nil { + return host, err + } + for _, host := range hosts { + if host.UUID == UUID { + return host, nil + } + } + + return host, fmt.Errorf("could not find host by UUID %v", UUID) +} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/types.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/types.go new file mode 100644 index 00000000..2a1efc48 --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/metadata/types.go @@ -0,0 +1,49 @@ +package metadata + +type Stack struct { + EnvironmentName string `json:"environment_name"` + Name string `json:"name"` + Services []Service `json:"services"` +} + +type Service struct { + Scale int `json:"scale"` + Name string `json:"name"` + StackName string `json:"stack_name"` + Kind string `json:"kind"` + Hostname string `json:"hostname"` + Vip string `json:"vip"` + CreateIndex int `json:"create_index"` + UUID string `json:"uuid"` + ExternalIps []string `json:"external_ips"` + Sidekicks []string `json:"sidekicks"` + Containers []Container `json:"containers"` + Ports []string `json:"ports"` + Labels map[string]string `json:"labels"` + Links map[string]string `json:"links"` + Metadata map[string]interface{} `json:"metadata"` + Token string `json:"token"` +} + +type Container struct { + Name string `json:"name"` + PrimaryIp string `json:"primary_ip"` + Ips []string `json:"ips"` + Ports []string `json:"ports"` + ServiceName string `json:"service_name"` + StackName string `json:"stack_name"` + Labels map[string]string `json:"labels"` + CreateIndex int `json:"create_index"` + HostUUID string `json:"host_uuid"` + UUID string `json:"uuid"` + HealthState string `json:"health_state"` +} + +type Host struct { + Name string `json:"name"` + AgentIP string `json:"agent_ip"` + HostId int `json:"host_id"` + Labels map[string]string `json:"labels"` + UUID string `json:"uuid"` + Hostname string `json:"hostname"` +} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go new file mode 100644 index 00000000..d8048d0f --- /dev/null +++ b/vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go @@ -0,0 +1,19 @@ +package metadata + +import ( + "time" +) + +func testConnection(mdClient *Client) error { + var err error + maxTime := 20 * time.Second + + for i := 1 * time.Second; i < maxTime; i *= time.Duration(2) { + if _, err = mdClient.GetVersion(); err != nil { + time.Sleep(i) + } else { + return nil + } + } + return err +} From de6f99cf8b633a54747cba40ca54e62fe5de503b Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 26 Apr 2016 16:08:22 -0700 Subject: [PATCH 032/357] Add agent code --- Dockerfile.dapper | 11 +- agent/controller/controller.go | 292 +++++++++++++++++++++++++++++++++ agent/main.go | 85 ++++++++++ agent/status/common.go | 26 +++ agent/status/controller.go | 29 ++++ agent/status/replica.go | 94 +++++++++++ scripts/build | 7 + scripts/ci | 1 - 8 files changed, 543 insertions(+), 2 deletions(-) create mode 100644 agent/controller/controller.go create mode 100644 agent/main.go create mode 100644 agent/status/common.go create mode 100644 agent/status/controller.go create mode 100644 agent/status/replica.go create mode 100755 scripts/build diff --git a/Dockerfile.dapper b/Dockerfile.dapper index b42d5103..4951adca 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -55,12 +55,21 @@ RUN cd /usr/src/tcmu-runner && \ cp libtcmu_static.a /usr/local/lib/libtcmu.a # Install ssync, etc -RUN go get -d github.com/rancher/sparse-tools/ssync && \ +RUN GOPATH=/tmp/ssync && go get -d github.com/rancher/sparse-tools/ssync && \ cd $GOPATH/src/github.com/rancher/sparse-tools && \ git checkout 84fc96db3ee359d3e5675df414494c09c7d0c0c2 && \ cd ssync && \ go build -o /usr/local/bin/ssync +# Install longhorn Docker driver +RUN GOPATH=/tmp/docker-longhorn-driver && \ + mkdir -p $GOPATH/src/github.com/rancher && \ + cd $GOPATH/src/github.com/rancher && \ + git clone https://github.com/cjellick/docker-longhorn-driver.git && \ + cd docker-longhorn-driver && \ + git checkout e53e38da80e2a99b87443582d0ebc6d879faa031 && \ + go build -o /usr/local/bin/docker-longhorn-driver + VOLUME /tmp ENV TMPDIR /tmp ENTRYPOINT ["./scripts/entry"] diff --git a/agent/controller/controller.go b/agent/controller/controller.go new file mode 100644 index 00000000..45b678ea --- /dev/null +++ b/agent/controller/controller.go @@ -0,0 +1,292 @@ +package controller + +import ( + "fmt" + "os/exec" + "time" + + "github.com/Sirupsen/logrus" + + "github.com/rancher/go-rancher-metadata/metadata" + lclient "github.com/rancher/longhorn/client" + "github.com/rancher/longhorn/controller/rest" + "io/ioutil" + "net/http" + "os" +) + +const ( + defaultVolumeSize = "10737418240" // 10 gb + MetadataURL = "http://rancher-metadata/2015-12-19" +) + +type replica struct { + client *metadata.Client + host string + port int + healthState string + size string +} + +func ReplicaAddress(host string, port int) string { + return fmt.Sprintf("tcp://%s:%d", host, port) +} + +type Controller struct { + client *lclient.ControllerClient +} + +func New() *Controller { + client := lclient.NewControllerClient("http://localhost:9501") + return &Controller{ + client: client, + } +} + +func (c *Controller) Close() error { + logrus.Infof("Shutting down Longhorn.") + return nil +} + +func (c *Controller) Start() error { + logrus.Infof("Starting Longhorn.") + + volume, err := c.client.GetVolume() + if err != nil { + return fmt.Errorf("Error while getting volume: %v", err) + } + + if volume.ReplicaCount == 0 { + if err = c.getReplicasAndStart(); err != nil { + return err + } + } else { + logrus.Infof("Volume is started with %v replicas.", volume.ReplicaCount) + } + + return c.refresh() +} + +func (c *Controller) getReplicasAndStart() error { + var fromMetadata map[string]replica + var scale int + for { + var err error + if scale, fromMetadata, err = c.replicasFromMetadata(); err != nil { + return err + } else if len(fromMetadata) < scale { + logrus.Infof("Waiting for replicas. Current %v, expected: %v", len(fromMetadata), scale) + time.Sleep(1 * time.Second) + } else { + break + } + } + + startingReplicas := map[string]replica{} + dirtyReplicas := map[string]replica{} + for address, replFromMD := range fromMetadata { + replicaClient, err := lclient.NewReplicaClient(address) + if err != nil { + logrus.Errorf("Error getting client for replica %v. Removing from list of startup replicas. Error: %v", address, err) + continue + } + + replica, err := replicaClient.GetReplica() + if replica.Dirty { + logrus.Infof("Removing dirty replica %v from startup.", address) + dirtyReplicas[address] = replFromMD + } else { + startingReplicas[address] = replFromMD + } + } + + if len(startingReplicas) == 0 && len(dirtyReplicas) > 0 { + // just start with a single dirty replica + for k, v := range dirtyReplicas { + logrus.Infof("Couldn't find any clean replicas. Using dirty replica %v.", k) + startingReplicas[k] = v + break + } + } + + addresses := []string{} + for address, repl := range startingReplicas { + if err := c.ensureOpen(repl); err != nil { + logrus.Errorf("Replica %v is not open. Removing it from startup list. Error while waiting for open: %v", address, err) + continue + } + addresses = append(addresses, address) + } + + if len(addresses) == 0 { + return fmt.Errorf("Couldn't find any valid replicas to start with. Original replica set from metadta: %v", fromMetadata) + } + + logrus.Infof("Starting controller with replicas: %v.", addresses) + if err := c.client.Start(addresses...); err != nil { + return fmt.Errorf("Error starting controller: %v", err) + } + + return nil +} + +func (c *Controller) refresh() error { + for { + if err := c.syncReplicas(); err != nil { + logrus.Errorf("Failed to sync replicas: %v", err) + } + time.Sleep(5 * time.Second) + } +} + +func (c *Controller) syncReplicas() (retErr error) { + logrus.Debugf("Syncing replicas.") + + replicasInController, err := c.client.ListReplicas() + if err != nil { + return fmt.Errorf("Error listing replicas in controller: %v", err) + } + fromController := map[string]rest.Replica{} + for _, r := range replicasInController { + fromController[r.Address] = r + } + + _, fromMetadata, err := c.replicasFromMetadata() + if err != nil { + return fmt.Errorf("Error listing replicas in metadata: %v", err) + } + + // Remove replicas from controller if they aren't in metadata + if len(replicasInController) > 1 { + for address := range fromController { + if _, ok := fromMetadata[address]; !ok { + logrus.Infof("Removing replica %v", address) + if _, err := c.client.DeleteReplica(address); err != nil { + return fmt.Errorf("Error removing replica %v: %v", address, err) + } + return nil // Just remove one replica per cycle + } + } + } + + // Add replicas + for address, r := range fromMetadata { + if _, ok := fromController[address]; !ok { + if err := c.addReplica(r); err != nil { + return fmt.Errorf("Error adding replica %v: %v", address, err) + } + } + } + + return nil +} + +func (c *Controller) addReplica(r replica) error { + logrus.Infof("Adding replica %v", r.host) + err := c.ensureOpen(r) + if err != nil { + return err + } + + cmd := exec.Command("longhorn", "add", ReplicaAddress(r.host, r.port)) + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + + return cmd.Run() +} + +func (c *Controller) ensureOpen(r replica) error { + client, err := lclient.NewReplicaClient(ReplicaAddress(r.host, r.port)) + if err != nil { + return err + } + + replica, err := client.GetReplica() + if err != nil { + return err + } + + if replica.State != "open" { + if err := client.OpenReplica(r.size); err != nil { + return fmt.Errorf("Error opening replica %v: %v", r.host, err) + } + } + + return nil +} + +func backoff(maxDuration time.Duration, timeoutMessage string, f func() (bool, error)) error { + startTime := time.Now() + waitTime := 150 * time.Millisecond + maxWaitTime := 2 * time.Second + for { + if time.Now().Sub(startTime) > maxDuration { + return fmt.Errorf(timeoutMessage) + } + + if done, err := f(); err != nil { + return err + } else if done { + return nil + } + + time.Sleep(waitTime) + + waitTime *= 2 + if waitTime > maxWaitTime { + waitTime = maxWaitTime + } + } +} + +func (c *Controller) replicasFromMetadata() (int, map[string]replica, error) { + client, err := metadata.NewClientAndWait(MetadataURL) + if err != nil { + return 0, nil, err + } + service, err := client.GetSelfServiceByName("replica") + if err != nil { + return 0, nil, err + } + + // Unmarshalling the metadata as json is forcing it to a bad format + resp, err := http.Get(MetadataURL + "/self/service/metadata/longhorn/volume_size") + if err != nil { + return 0, nil, err + } + + size := "" + if resp.StatusCode == 200 { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return 0, nil, err + } + size = string(body) + } + + if size == "" { + size = defaultVolumeSize + } + + containers := map[string]metadata.Container{} + for _, container := range service.Containers { + if c, ok := containers[container.Name]; !ok { + containers[container.Name] = container + } else if container.CreateIndex > c.CreateIndex { + containers[container.Name] = container + } + } + + result := map[string]replica{} + for _, container := range containers { + r := replica{ + healthState: container.HealthState, + host: container.PrimaryIp, + port: 9502, + size: size, + } + result[ReplicaAddress(r.host, r.port)] = r + } + + return service.Scale, result, nil +} diff --git a/agent/main.go b/agent/main.go new file mode 100644 index 00000000..c4f021b2 --- /dev/null +++ b/agent/main.go @@ -0,0 +1,85 @@ +package main + +import ( + "net/http" + "os" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/gorilla/mux" + "github.com/rancher/longhorn/agent/controller" + "github.com/rancher/longhorn/agent/status" +) + +var ( + VERSION = "0.0.0" +) + +func main() { + app := cli.NewApp() + app.Version = VERSION + app.Flags = []cli.Flag{ + cli.BoolFlag{ + Name: "controller", + }, + cli.BoolFlag{ + Name: "replica", + }, + cli.StringFlag{ + Name: "listen, l", + Value: ":8199", + }, + cli.StringFlag{ + Name: "log-level", + Value: "debug", + }, + } + app.Action = func(c *cli.Context) { + if err := runApp(c); err != nil { + logrus.Fatal(err) + } + } + app.Run(os.Args) +} + +func runApp(context *cli.Context) error { + logLevel := context.GlobalString("log-level") + lvl, err := logrus.ParseLevel(logLevel) + if err != nil { + return err + } + logrus.SetLevel(lvl) + + runController := context.GlobalBool("controller") + runReplica := context.GlobalBool("replica") + + if runController { + go runPing(context) + c := controller.New() + defer c.Close() + return c.Start() + } else if runReplica { + return runPing(context) + } + + return nil +} + +func runPing(context *cli.Context) error { + + controller := status.NewControllerStatus() + + replica, err := status.NewReplicaStatus() + if err != nil { + return err + } + + r := mux.NewRouter() + r.Handle("/controller/status", controller) + r.Handle("/replica/status", replica) + http.Handle("/", r) + + listen := context.GlobalString("listen") + logrus.Info("Listening for healthcheck requests on ", listen) + return http.ListenAndServe(listen, nil) +} diff --git a/agent/status/common.go b/agent/status/common.go new file mode 100644 index 00000000..9ca6a70c --- /dev/null +++ b/agent/status/common.go @@ -0,0 +1,26 @@ +package status + +import ( + "net/http" + + "github.com/Sirupsen/logrus" +) + +func writeOK(rw http.ResponseWriter) { + logrus.Debugf("Reporting OK.") + rw.Write([]byte("OK")) +} + +func writeError(rw http.ResponseWriter, err error) { + writeErrorString(rw, err.Error()) +} + +func writeErrorString(rw http.ResponseWriter, msg string) { + if rw != nil { + logrus.Infof("Reporting unhealthy status: %v", msg) + rw.WriteHeader(http.StatusServiceUnavailable) + rw.Write([]byte(msg)) + } else { + logrus.Warn("Not reporting a status. ResponseWriter is null.") + } +} diff --git a/agent/status/controller.go b/agent/status/controller.go new file mode 100644 index 00000000..995ff0bc --- /dev/null +++ b/agent/status/controller.go @@ -0,0 +1,29 @@ +package status + +import ( + "net/http" + + "github.com/rancher/longhorn/client" +) + +type ControllerStatus struct { + controller *client.ControllerClient +} + +func NewControllerStatus() *ControllerStatus { + + controllerClient := client.NewControllerClient("http://localhost:9501/v1") + return &ControllerStatus{ + controller: controllerClient, + } +} + +func (s *ControllerStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + _, err := s.controller.GetVolume() + if err != nil { + writeError(rw, err) + return + } + + writeOK(rw) +} diff --git a/agent/status/replica.go b/agent/status/replica.go new file mode 100644 index 00000000..c64bfa26 --- /dev/null +++ b/agent/status/replica.go @@ -0,0 +1,94 @@ +package status + +import ( + "fmt" + "net/http" + + md "github.com/rancher/go-rancher-metadata/metadata" + "github.com/rancher/longhorn/client" + + "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/agent/controller" +) + +type ReplicaStatus struct { + controller *client.ControllerClient + replica *client.ReplicaClient + metadata *md.Client + address string + controllerLastError string +} + +func NewReplicaStatus() (*ReplicaStatus, error) { + metadata, err := md.NewClientAndWait(controller.MetadataURL) + if err != nil { + return nil, err + } + self, err := metadata.GetSelfContainer() + if err != nil { + return nil, err + } + addr := controller.ReplicaAddress(self.PrimaryIp, 9502) + + controllerClient := client.NewControllerClient("http://controller:9501/v1") + replicaClient, err := client.NewReplicaClient("http://localhost:9502/v1") + if err != nil { + return nil, err + } + + return &ReplicaStatus{ + controller: controllerClient, + replica: replicaClient, + address: addr, + }, nil +} + +func (s *ReplicaStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + // Checking against the replica is easy: just ensure that the API is responding. + _, err := s.replica.GetReplica() + if err != nil { + writeError(rw, err) + return + } + + if ok, msg := s.checkReplicaStatusInController(rw); !ok { + writeErrorString(rw, msg) + return + } + + writeOK(rw) +} + +func (s *ReplicaStatus) checkReplicaStatusInController(rw http.ResponseWriter) (bool, string) { + replicas, err := s.controller.ListReplicas() + if err != nil { + logrus.Warnf("Couldn't get replicas from controller. Reporting cached status.") + return s.reportCacheControllerResponse() + } + for _, replica := range replicas { + if replica.Address == s.address { + if strings.EqualFold(replica.Mode, "err") { + return s.cacheControllerResponse(false, fmt.Sprintf("Replica %v is in error mode.", s.address)) + } + return s.cacheControllerResponse(true, "") + } + } + + return s.cacheControllerResponse(false, fmt.Sprintf("Replica %v is not in the controller's list of replicas. Current list: %v", s.address, replicas)) +} + +func (s *ReplicaStatus) reportCacheControllerResponse() (bool, string) { + healthy := len(s.controllerLastError) == 0 + return healthy, s.controllerLastError +} + +func (s *ReplicaStatus) cacheControllerResponse(ok bool, msg string) (bool, string) { + if ok { + s.controllerLastError = "" + } else { + s.controllerLastError = msg + " (cached response)" + } + return ok, msg +} diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..0347cab2 --- /dev/null +++ b/scripts/build @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +cd $(dirname $0) + +./build-cli +./build-agent diff --git a/scripts/ci b/scripts/ci index e86607c8..502224c5 100755 --- a/scripts/ci +++ b/scripts/ci @@ -4,7 +4,6 @@ set -e cd $(dirname $0) ./build -./build-agent ./test ./validate ./integration-test From 657bc303303737bb57e6275f7a66e881bed8b570 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Wed, 27 Apr 2016 21:44:07 -0700 Subject: [PATCH 033/357] Update docker-longhorn-driver reference --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 4951adca..6c894d45 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -67,7 +67,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/cjellick/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout e53e38da80e2a99b87443582d0ebc6d879faa031 && \ + git checkout ea010af4d207042593bc26de62b09dc3fd251f48 && \ go build -o /usr/local/bin/docker-longhorn-driver VOLUME /tmp From 47b312fa4b14811b3783ae9b7b1b58c5be44c88a Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Fri, 29 Apr 2016 10:25:16 -0700 Subject: [PATCH 034/357] Add share-mnt to driver launch --- package/Dockerfile | 7 +++++-- package/launch-driver | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 package/launch-driver diff --git a/package/Dockerfile b/package/Dockerfile index 918e8c0c..9f1464e2 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,5 +1,8 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install kmod +RUN apt-get update && apt-get install -y kmod curl -COPY longhorn longhorn-agent launch ssync docker-longhorn-driver /usr/bin/ +RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ + chmod u+x share-mnt && mv share-mnt /usr/bin + +COPY longhorn longhorn-agent launch ssync launch-driver docker-longhorn-driver /usr/bin/ CMD ["longhorn"] diff --git a/package/launch-driver b/package/launch-driver new file mode 100755 index 00000000..d96ea421 --- /dev/null +++ b/package/launch-driver @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e -x + +if [ "$1" == "volumedriver" ]; then + /usr/bin/share-mnt /var/lib/rancher/longhorn -- docker-longhorn-driver "$@" +else + docker-longhorn-driver "$@" +fi From c98d59466cf61b5d09e343b8103de8b3c8f3127a Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 1 May 2016 22:39:05 -0700 Subject: [PATCH 035/357] Refactor states --- app/replica.go | 2 +- backend/remote/remote.go | 11 +- client/replica_client.go | 24 +++- integration/core/test_cli.py | 23 ++-- integration/core/test_replica.py | 203 +++++++++++++++++++++++++------ replica/replica.go | 38 ++++-- replica/rest/model.go | 84 +++++++++---- replica/rest/replica.go | 31 +++-- replica/rest/router.go | 33 ++++- replica/server.go | 67 +++++++++- sync/sync.go | 6 +- 11 files changed, 419 insertions(+), 103 deletions(-) diff --git a/app/replica.go b/app/replica.go index d613a4cb..6fcacdcb 100644 --- a/app/replica.go +++ b/app/replica.go @@ -59,7 +59,7 @@ func startReplica(c *cli.Context) error { return err } - if err := s.Open(size); err != nil { + if err := s.Create(size); err != nil { return err } } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 13fdb170..260f6c37 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -41,6 +41,11 @@ func (r *Remote) Close() error { return r.doAction("close", "") } +func (r *Remote) open() error { + logrus.Infof("Opening: %s", r.name) + return r.doAction("open", "") +} + func (r *Remote) Snapshot(name string) error { logrus.Infof("Snapshot: %s %s", r.name, name) return r.doAction("snapshot", name) @@ -128,8 +133,8 @@ func (rf *Factory) Create(address string) (types.Backend, error) { return nil, err } - if replica.State != rest.StateOpen { - return nil, fmt.Errorf("Can not add replica in state: %s", replica.State) + if replica.State != "closed" { + return nil, fmt.Errorf("Replica must be closed, Can not add in state: %s", replica.State) } conn, err := net.Dial("tcp", dataAddress) @@ -139,5 +144,5 @@ func (rf *Factory) Create(address string) (types.Backend, error) { r.ReaderWriterAt = rpc.NewClient(conn) - return r, nil + return r, r.open() } diff --git a/client/replica_client.go b/client/replica_client.go index 980f144b..704e8781 100644 --- a/client/replica_client.go +++ b/client/replica_client.go @@ -59,17 +59,35 @@ func NewReplicaClient(address string) (*ReplicaClient, error) { }, nil } -func (c *ReplicaClient) OpenReplica(size string) error { +func (c *ReplicaClient) Close() error { r, err := c.GetReplica() if err != nil { return err } - return c.post(r.Actions["open"], rest.OpenInput{ - Size: size, + return c.post(r.Actions["close"], nil, nil) +} + +func (c *ReplicaClient) SetRebuilding(rebuilding bool) error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["setrebuilding"], &rest.RebuildingInput{ + Rebuilding: rebuilding, }, nil) } +func (c *ReplicaClient) OpenReplica() error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["open"], nil, nil) +} + func (c *ReplicaClient) GetReplica() (rest.Replica, error) { var replica rest.Replica diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index f8d7838f..6dabc87b 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -44,11 +44,14 @@ def replica_client2(request): def cleanup_replica(client): - for r in client.list_replica(): - if 'close' in r: - client.delete(r) - else: - client.delete(r.open(size=str(1024*1024))) + r = client.list_replica()[0] + if r.state == 'initial': + return client + if 'open' in r: + r = r.open() + client.delete(r) + r = client.reload(r) + assert r.state == 'initial' return client @@ -81,15 +84,15 @@ def open_replica(client): assert len(replicas) == 1 r = replicas[0] - assert r.state == 'closed' - assert r.size == '' + assert r.state == 'initial' + assert r.size == '0' assert r.sectorSize == 0 assert r.parent == '' assert r.head == '' - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) - assert r.state == 'open' + assert r.state == 'closed' assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.parent == '' @@ -114,6 +117,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, open_replica(replica_client2) r = replica_client.list_replica()[0] + r = r.open() r = r.snapshot(name='000') r = r.snapshot(name='001') @@ -127,6 +131,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, 'volume-snap-001.img', 'volume-snap-000.img'] + r = r.close() cmd = [bin, '--debug', 'add-replica', REPLICA] subprocess.check_call(cmd) diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index aa7207e6..cc3d8149 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -14,11 +14,14 @@ def client(request): def cleanup(client): - for r in client.list_replica(): - if 'close' in r: - client.delete(r) - else: - client.delete(r.open(size='4096')) + r = client.list_replica()[0] + if r.state == 'initial': + return client + if 'open' in r: + r = r.open() + client.delete(r) + r = client.reload(r) + assert r.state == 'initial' return client @@ -31,40 +34,69 @@ def random_num(): return random.randint(0, 1000000) -def test_open(client): +def test_create(client): replicas = client.list_replica() assert len(replicas) == 1 r = replicas[0] - assert r.state == 'closed' - assert r.size == '' + assert r.state == 'initial' + assert r.size == '0' assert r.sectorSize == 0 assert r.parent == '' assert r.head == '' - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) - assert r.state == 'open' + assert r.state == 'closed' assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.parent == '' assert r.head == 'volume-head-000.img' -def test_close(client): +def test_open(client): replicas = client.list_replica() assert len(replicas) == 1 r = replicas[0] - assert r.state == 'closed' - assert r.size == '' + assert r.state == 'initial' + assert r.size == '0' assert r.sectorSize == 0 assert r.parent == '' assert r.head == '' - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) + + assert r.state == 'closed' + assert not r.dirty + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + r = r.open() + + assert r.state == 'open' + assert not r.dirty + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + +def test_close(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + r = r.create(size=str(1024*4096)) + r = r.open() assert r.state == 'open' + assert not r.dirty + assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.parent == '' @@ -73,10 +105,12 @@ def test_close(client): r = r.close() assert r.state == 'closed' - assert r.size == '' - assert r.sectorSize == 0 + assert not r.dirty + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 assert r.parent == '' - assert r.head == '' + assert r.head == 'volume-head-000.img' def test_snapshot(client): @@ -84,24 +118,29 @@ def test_snapshot(client): assert len(replicas) == 1 r = replicas[0] - assert r.state == 'closed' - assert r.size == '' - assert r.sectorSize == 0 - assert r.parent == '' - assert r.head == '' - - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) + r = r.open() assert r.state == 'open' + assert not r.dirty + assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.parent == '' assert r.head == 'volume-head-000.img' r = r.snapshot(name='000') + assert r.state == 'dirty' + assert r.dirty + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + r = r.snapshot(name='001') - assert r.state == 'open' + assert r.state == 'dirty' + assert r.dirty + assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.head == 'volume-head-002.img' @@ -115,14 +154,16 @@ def test_remove_disk(client): assert len(replicas) == 1 r = replicas[0] - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) + r = r.open() r = r.snapshot(name='000') r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] r = r.removedisk(name='volume-snap-001.img') - assert r.state == 'open' + assert r.state == 'dirty' + assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.head == 'volume-head-002.img' @@ -135,14 +176,16 @@ def test_remove_last_disk(client): assert len(replicas) == 1 r = replicas[0] - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) + r = r.open() r = r.snapshot(name='000') r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] r = r.removedisk(name='volume-snap-000.img') - assert r.state == 'open' + assert r.state == 'dirty' + assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.head == 'volume-head-002.img' @@ -155,14 +198,15 @@ def test_reload(client): assert len(replicas) == 1 r = replicas[0] - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) + r = r.open() r = r.snapshot(name='000') r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] r = r.removedisk(name='volume-snap-000.img') - assert r.state == 'open' + assert r.state == 'dirty' assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.head == 'volume-head-002.img' @@ -170,6 +214,14 @@ def test_reload(client): assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] r = r.reload() + assert r.state == 'dirty' + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] + assert r.head == 'volume-head-002.img' + assert r.parent == 'volume-snap-001.img' + + r = r.close().open() assert r.state == 'open' assert r.size == str(1024*4096) assert r.sectorSize == 4096 @@ -183,14 +235,10 @@ def test_reload_simple(client): assert len(replicas) == 1 r = replicas[0] - assert r.state == 'closed' - assert r.size == '' - assert r.sectorSize == 0 - assert r.parent == '' - assert r.head == '' - - r = r.open(size=str(1024*4096)) + r = r.create(size=str(1024*4096)) + r = r.open() assert r.state == 'open' + assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 4096 assert r.parent == '' @@ -202,3 +250,82 @@ def test_reload_simple(client): assert r.sectorSize == 4096 assert r.parent == '' assert r.head == 'volume-head-000.img' + + +def test_rebuilding(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + r = r.create(size=str(1024*4096)) + r = r.open() + r = r.snapshot(name='001') + assert r.state == 'dirty' + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] + + r = r.setrebuilding(rebuilding=True) + assert r.state == 'rebuilding' + assert r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] + + r = r.close().open() + assert r.state == 'rebuilding' + assert r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] + + r = r.reload() + assert r.state == 'rebuilding' + assert r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] + + +def test_not_rebuilding(client): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + r = r.create(size=str(1024*4096)) + r = r.open() + r = r.snapshot(name='001') + assert r.state == 'dirty' + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] + + r = r.setrebuilding(rebuilding=True) + assert r.state == 'rebuilding' + assert r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] + + r = r.setrebuilding(rebuilding=False) + assert r.state == 'dirty' + assert not r.rebuilding + assert r.size == str(1024*4096) + assert r.sectorSize == 4096 + assert r.parent == 'volume-snap-001.img' + assert r.head == 'volume-head-001.img' + assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] diff --git a/replica/replica.go b/replica/replica.go index 3e0e6889..06504d25 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -41,6 +41,7 @@ type Info struct { Size int64 Head string Dirty bool + Rebuilding bool Parent string SectorSize int64 } @@ -50,6 +51,12 @@ type disk struct { Parent string } +func ReadInfo(dir string) (Info, error) { + var info Info + err := (&Replica{dir: dir}).unmarshalFile(volumeMetaData, &info) + return info, err +} + func New(size, sectorSize int64, dir string) (*Replica, error) { if size%sectorSize != 0 { return nil, fmt.Errorf("Size %d not a multiple of sector size %d", size, sectorSize) @@ -88,11 +95,25 @@ func New(size, sectorSize int64, dir string) (*Replica, error) { r.info.Parent = r.diskData[r.info.Head].Parent - return r, r.writeVolumeMetaData(true) + return r, r.writeVolumeMetaData(true, r.info.Rebuilding) +} + +func (r *Replica) SetRebuilding(rebuilding bool) error { + err := r.writeVolumeMetaData(true, rebuilding) + if err != nil { + return err + } + r.info.Rebuilding = rebuilding + return nil } func (r *Replica) Reload() (*Replica, error) { - return New(r.info.Size, r.volume.sectorSize, r.dir) + newReplica, err := New(r.info.Size, r.volume.sectorSize, r.dir) + if err != nil { + return nil, err + } + newReplica.info.Dirty = r.info.Dirty + return newReplica, nil } func (r *Replica) findDisk(name string) int { @@ -171,22 +192,19 @@ func (r *Replica) Chain() ([]string, error) { return result, nil } -func (r *Replica) writeVolumeMetaData(dirty bool) error { +func (r *Replica) writeVolumeMetaData(dirty, rebuilding bool) error { info := r.info info.Dirty = dirty + info.Rebuilding = rebuilding return r.encodeToFile(&info, volumeMetaData) } -func (r *Replica) close(writeMeta bool) error { +func (r *Replica) close() error { for _, f := range r.volume.files { f.Close() } - if writeMeta { - return r.writeVolumeMetaData(false) - } - - return nil + return r.writeVolumeMetaData(false, r.info.Rebuilding) } func (r *Replica) encodeToFile(obj interface{}, file string) error { @@ -408,7 +426,7 @@ func (r *Replica) Close() error { r.Lock() defer r.Unlock() - return r.close(true) + return r.close() } func (r *Replica) Delete() error { diff --git a/replica/rest/model.go b/replica/rest/model.go index 4a28b949..216202b3 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -8,14 +8,10 @@ import ( "github.com/rancher/longhorn/replica" ) -const ( - StateOpen = "open" - StateClosed = "closed" -) - type Replica struct { client.Resource Dirty bool `json:"dirty"` + Rebuilding bool `json:"rebuilding"` Head string `json:"head"` Parent string `json:"parent"` Size string `json:"size"` @@ -24,11 +20,16 @@ type Replica struct { Chain []string `json:"chain"` } -type OpenInput struct { +type CreateInput struct { client.Resource Size string `json:"size"` } +type RebuildingInput struct { + client.Resource + Rebuilding bool `json:"rebuilding"` +} + type SnapshotInput struct { client.Resource Name string `json:"Name"` @@ -39,7 +40,7 @@ type RemoveDiskInput struct { Name string `json:"name"` } -func NewReplica(context *api.ApiContext, rep *replica.Replica) *Replica { +func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, rep *replica.Replica) *Replica { r := &Replica{ Resource: client.Resource{ Type: "replica", @@ -48,22 +49,48 @@ func NewReplica(context *api.ApiContext, rep *replica.Replica) *Replica { }, } - if rep == nil { - r.State = StateClosed - r.Actions["open"] = context.UrlBuilder.ActionLink(r.Resource, "open") - } else { - r.State = StateOpen - info := rep.Info() - r.Dirty = info.Dirty - r.Head = info.Head - r.Parent = info.Parent - r.SectorSize = info.SectorSize - r.Size = strconv.FormatInt(info.Size, 10) + r.State = string(state) + + actions := map[string]bool{} + + switch state { + case replica.Initial: + actions["create"] = true + case replica.Open: + actions["close"] = true + actions["setrebuilding"] = true + actions["snapshot"] = true + actions["reload"] = true + actions["removedisk"] = true + case replica.Closed: + actions["open"] = true + actions["removedisk"] = true + case replica.Dirty: + actions["setrebuilding"] = true + actions["close"] = true + actions["snapshot"] = true + actions["reload"] = true + actions["removedisk"] = true + case replica.Rebuilding: + actions["setrebuilding"] = true + actions["close"] = true + actions["reload"] = true + case replica.Error: + } + + for action := range actions { + r.Actions[action] = context.UrlBuilder.ActionLink(r.Resource, action) + } + + r.Dirty = info.Dirty + r.Rebuilding = info.Rebuilding + r.Head = info.Head + r.Parent = info.Parent + r.SectorSize = info.SectorSize + r.Size = strconv.FormatInt(info.Size, 10) + + if rep != nil { r.Chain, _ = rep.Chain() - r.Actions["reload"] = context.UrlBuilder.ActionLink(r.Resource, "reload") - r.Actions["snapshot"] = context.UrlBuilder.ActionLink(r.Resource, "snapshot") - r.Actions["close"] = context.UrlBuilder.ActionLink(r.Resource, "close") - r.Actions["removedisk"] = context.UrlBuilder.ActionLink(r.Resource, "removedisk") } return r @@ -75,17 +102,18 @@ func NewSchema() *client.Schemas { schemas.AddType("error", client.ServerApiError{}) schemas.AddType("apiVersion", client.Resource{}) schemas.AddType("schema", client.Schema{}) - schemas.AddType("openInput", OpenInput{}) + schemas.AddType("createInput", CreateInput{}) + schemas.AddType("rebuildingInput", RebuildingInput{}) schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("removediskInput", RemoveDiskInput{}) replica := schemas.AddType("replica", Replica{}) + replica.ResourceMethods = []string{"GET", "DELETE"} replica.ResourceActions = map[string]client.Action{ "close": client.Action{ Output: "replica", }, "open": client.Action{ - Input: "openInput", Output: "replica", }, "reload": client.Action{ @@ -99,6 +127,14 @@ func NewSchema() *client.Schemas { Input: "removediskInput", Output: "replica", }, + "setrebuilding": client.Action{ + Input: "rebuildingInput", + Output: "replica", + }, + "create": client.Action{ + Input: "createInput", + Output: "replica", + }, } return schemas diff --git a/replica/rest/replica.go b/replica/rest/replica.go index d4fe364c..f94c0631 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -14,19 +14,20 @@ import ( func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) resp := client.GenericCollection{} - resp.Data = append(resp.Data, s.getReplica(apiContext)) + resp.Data = append(resp.Data, s.Replica(apiContext)) apiContext.Write(&resp) return nil } -func (s *Server) getReplica(apiContext *api.ApiContext) *Replica { - return NewReplica(apiContext, s.s.Replica()) +func (s *Server) Replica(apiContext *api.ApiContext) *Replica { + state, info := s.s.Status() + return NewReplica(apiContext, state, info, s.s.Replica()) } func (s *Server) GetReplica(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) - r := s.getReplica(apiContext) + r := s.Replica(apiContext) if mux.Vars(req)["id"] == r.Id { apiContext.Write(r) } else { @@ -41,12 +42,22 @@ func (s *Server) doOp(req *http.Request, err error) error { } apiContext := api.GetApiContext(req) - apiContext.Write(s.getReplica(apiContext)) + apiContext.Write(s.Replica(apiContext)) return nil } -func (s *Server) OpenReplica(rw http.ResponseWriter, req *http.Request) error { - var input OpenInput +func (s *Server) SetRebuilding(rw http.ResponseWriter, req *http.Request) error { + var input RebuildingInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil && err != io.EOF { + return err + } + + return s.doOp(req, s.s.SetRebuilding(input.Rebuilding)) +} + +func (s *Server) Create(rw http.ResponseWriter, req *http.Request) error { + var input CreateInput apiContext := api.GetApiContext(req) if err := apiContext.Read(&input); err != nil && err != io.EOF { return err @@ -61,7 +72,11 @@ func (s *Server) OpenReplica(rw http.ResponseWriter, req *http.Request) error { } } - return s.doOp(req, s.s.Open(size)) + return s.doOp(req, s.s.Create(size)) +} + +func (s *Server) OpenReplica(rw http.ResponseWriter, req *http.Request) error { + return s.doOp(req, s.s.Open()) } func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/rest/router.go b/replica/rest/router.go index cb9bbbe5..2d36728c 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -1,11 +1,24 @@ package rest import ( + "net/http" + "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/longhorn/controller/rest" ) +func checkAction(s *Server, t func(http.ResponseWriter, *http.Request) error) func(http.ResponseWriter, *http.Request) error { + return func(rw http.ResponseWriter, req *http.Request) error { + replica := s.Replica(api.GetApiContext(req)) + if replica.Actions[req.URL.Query().Get("action")] == "" { + rw.WriteHeader(http.StatusNotFound) + return nil + } + return t(rw, req) + } +} + func NewRouter(s *Server) *mux.Router { schemas := NewSchema() router := mux.NewRouter().StrictSlash(true) @@ -20,12 +33,22 @@ func NewRouter(s *Server) *mux.Router { // Replicas router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) - router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "reload").Handler(f(schemas, s.ReloadReplica)) - router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "snapshot").Handler(f(schemas, s.SnapshotReplica)) - router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "open").Handler(f(schemas, s.OpenReplica)) - router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "close").Handler(f(schemas, s.CloseReplica)) - router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "removedisk").Handler(f(schemas, s.RemoveDisk)) router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) + // Actions + actions := map[string]func(http.ResponseWriter, *http.Request) error{ + "reload": s.ReloadReplica, + "snapshot": s.SnapshotReplica, + "open": s.OpenReplica, + "close": s.CloseReplica, + "removedisk": s.RemoveDisk, + "setrebuilding": s.SetRebuilding, + "create": s.Create, + } + + for name, action := range actions { + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", name).Handler(f(schemas, checkAction(s, action))) + } + return router } diff --git a/replica/server.go b/replica/server.go index 8931031f..0afff2d1 100644 --- a/replica/server.go +++ b/replica/server.go @@ -2,11 +2,23 @@ package replica import ( "fmt" + "os" "sync" "github.com/Sirupsen/logrus" ) +const ( + Initial = State("initial") + Open = State("open") + Closed = State("closed") + Dirty = State("dirty") + Rebuilding = State("rebuilding") + Error = State("error") +) + +type State string + type Server struct { sync.RWMutex r *Replica @@ -21,7 +33,25 @@ func NewServer(dir string, sectorSize int64) *Server { } } -func (s *Server) Open(size int64) error { +func (s *Server) Create(size int64) error { + s.Lock() + defer s.Unlock() + + state, _ := s.Status() + if state != Initial { + return nil + } + + logrus.Infof("Creating volume %s, size %d/%d", s.dir, size, s.sectorSize) + r, err := New(size, s.sectorSize, s.dir) + if err != nil { + return err + } + + return r.Close() +} + +func (s *Server) Open() error { s.Lock() defer s.Unlock() @@ -29,6 +59,9 @@ func (s *Server) Open(size int64) error { return fmt.Errorf("Replica is already open") } + _, info := s.Status() + size := info.Size + logrus.Infof("Opening volume %s, size %d/%d", s.dir, size, s.sectorSize) r, err := New(size, s.sectorSize, s.dir) if err != nil { @@ -58,6 +91,38 @@ func (s *Server) Reload() error { return nil } +func (s *Server) Status() (State, Info) { + if s.r == nil { + info, err := ReadInfo(s.dir) + if os.IsNotExist(err) { + return Initial, Info{} + } else if err != nil { + return Error, Info{} + } + return Closed, info + } + info := s.r.Info() + switch { + case info.Rebuilding: + return Rebuilding, info + case info.Dirty: + return Dirty, info + default: + return Open, info + } +} + +func (s *Server) SetRebuilding(rebuilding bool) error { + state, _ := s.Status() + // Must be Open/Dirty to set true or must be Rebuilding to set false + if (rebuilding && state != Open && state != Dirty) || + (!rebuilding && state != Rebuilding) { + return fmt.Errorf("Can not set rebuilding=%v from state %s", rebuilding, state) + } + + return s.r.SetRebuilding(rebuilding) +} + func (s *Server) Replica() *Replica { return s.r } diff --git a/sync/sync.go b/sync/sync.go index 5b2573e9..ef9f7d74 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -90,7 +90,7 @@ func (t *Task) reloadAndCheck(fromClient *client.ReplicaClient, toClient *client return fmt.Errorf("Chains are not equal: %v != %v", fromChain, toChain) } - return nil + return toClient.SetRebuilding(false) } func (t *Task) syncFiles(fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { @@ -99,6 +99,10 @@ func (t *Task) syncFiles(fromClient *client.ReplicaClient, toClient *client.Repl return err } + if err := toClient.SetRebuilding(true); err != nil { + return err + } + to, err := toClient.GetReplica() if err != nil { return err From 9b249acbc66120d6a0e7f8af0433da5d629a1b58 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 3 May 2016 07:10:17 -0700 Subject: [PATCH 036/357] implement logic for new replica states/actions --- Dockerfile.dapper | 2 +- agent/controller/controller.go | 248 +++++++++++++++++++++------------ client/replica_client.go | 11 ++ 3 files changed, 171 insertions(+), 90 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 6c894d45..ef1739da 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -67,7 +67,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/cjellick/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout ea010af4d207042593bc26de62b09dc3fd251f48 && \ + git checkout 553bfea741326737cc88b9fa99a0b147de2e5830 && \ go build -o /usr/local/bin/docker-longhorn-driver VOLUME /tmp diff --git a/agent/controller/controller.go b/agent/controller/controller.go index 45b678ea..5ba6da28 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -2,17 +2,18 @@ package controller import ( "fmt" + "io/ioutil" + "net/http" + "os" "os/exec" "time" "github.com/Sirupsen/logrus" "github.com/rancher/go-rancher-metadata/metadata" + lclient "github.com/rancher/longhorn/client" "github.com/rancher/longhorn/controller/rest" - "io/ioutil" - "net/http" - "os" ) const ( @@ -21,7 +22,7 @@ const ( ) type replica struct { - client *metadata.Client + client *lclient.ReplicaClient host string port int healthState string @@ -68,66 +69,161 @@ func (c *Controller) Start() error { } func (c *Controller) getReplicasAndStart() error { - var fromMetadata map[string]replica + var replicaMetadata map[string]*replica var scale int for { var err error - if scale, fromMetadata, err = c.replicasFromMetadata(); err != nil { + if scale, replicaMetadata, err = c.replicaMetadataAndClient(); err != nil { return err - } else if len(fromMetadata) < scale { - logrus.Infof("Waiting for replicas. Current %v, expected: %v", len(fromMetadata), scale) + } else if len(replicaMetadata) < scale { + logrus.Infof("Waiting for replicas. Current %v, expected: %v", len(replicaMetadata), scale) time.Sleep(1 * time.Second) } else { break } } - startingReplicas := map[string]replica{} - dirtyReplicas := map[string]replica{} - for address, replFromMD := range fromMetadata { - replicaClient, err := lclient.NewReplicaClient(address) + initializingReplicas := map[string]*replica{} + closedCleanReplicas := map[string]*replica{} + closedDirtyReplicas := map[string]*replica{} + openCleanReplicas := map[string]*replica{} + openDirtyReplicas := map[string]*replica{} + rebuildingClosedReplicas := map[string]*replica{} + rebuildingOpenReplicas := map[string]*replica{} + otherReplicas := map[string]*replica{} + + for address, replicaMd := range replicaMetadata { + replica, err := replicaMd.client.GetReplica() if err != nil { - logrus.Errorf("Error getting client for replica %v. Removing from list of startup replicas. Error: %v", address, err) + logrus.Errorf("Error getting replica %v. Removing from list of start replcias. Error: %v", address, err) continue } - replica, err := replicaClient.GetReplica() - if replica.Dirty { - logrus.Infof("Removing dirty replica %v from startup.", address) - dirtyReplicas[address] = replFromMD + if replica.State == "initial" { + initializingReplicas[address] = replicaMd + + } else if replica.Rebuilding && replica.State == "closed" { + rebuildingClosedReplicas[address] = replicaMd + + } else if replica.Rebuilding { + rebuildingOpenReplicas[address] = replicaMd + + } else if replica.State == "closed" && replica.Dirty { + closedDirtyReplicas[address] = replicaMd + + } else if replica.State == "closed" { + closedCleanReplicas[address] = replicaMd + + } else if replica.State == "open" { + openCleanReplicas[address] = replicaMd + + } else if replica.State == "dirty" { + openDirtyReplicas[address] = replicaMd + } else { - startingReplicas[address] = replFromMD + otherReplicas[address] = replicaMd + } } + logrus.Infof("Initializing replicas: %v", initializingReplicas) + logrus.Infof("Closed and clean replicas: %v", closedCleanReplicas) + logrus.Infof("Closed and dirty replicas: %v", closedDirtyReplicas) + logrus.Infof("Open and dirty replicas: %v", openDirtyReplicas) + logrus.Infof("Open and clean replicas: %v", openCleanReplicas) + logrus.Infof("Rebuilding and closed replicas: %v", rebuildingClosedReplicas) + logrus.Infof("Rebuilding and open replicas: %v", rebuildingOpenReplicas) + logrus.Infof("Other replicas (likely in error state)L %v", otherReplicas) + + // Closed and clean. Start with all replicas. + attemptedStart, err := c.startWithAll(closedCleanReplicas, false) + if attemptedStart { + return err + } - if len(startingReplicas) == 0 && len(dirtyReplicas) > 0 { - // just start with a single dirty replica - for k, v := range dirtyReplicas { - logrus.Infof("Couldn't find any clean replicas. Using dirty replica %v.", k) - startingReplicas[k] = v - break - } + // Closed and dirty. Start with one. + attemptedStart, err = c.startWithOne(closedDirtyReplicas, false) + if attemptedStart { + return err } + // Open and dirty. Close and start with one. + attemptedStart, err = c.startWithOne(openDirtyReplicas, true) + if attemptedStart { + return err + } + + // Open and clean. Close and start with one (because they could become dirty before we close). + attemptedStart, err = c.startWithOne(openCleanReplicas, true) + if attemptedStart { + return err + } + + // Rebuilding and closed. Start with one. + attemptedStart, err = c.startWithOne(rebuildingClosedReplicas, false) + if attemptedStart { + return err + } + + // Rebuilding and open. Close and start with one. + attemptedStart, err = c.startWithOne(rebuildingOpenReplicas, true) + if attemptedStart { + return err + } + + // Initial. Start with all + attemptedStart, err = c.startWithAll(initializingReplicas, true) + if attemptedStart { + return err + } + + return fmt.Errorf("Couldn't find any valid replicas to start with. Original replicas from metadata: %v", replicaMetadata) +} + +func (c *Controller) startWithAll(replicas map[string]*replica, create bool) (bool, error) { addresses := []string{} - for address, repl := range startingReplicas { - if err := c.ensureOpen(repl); err != nil { - logrus.Errorf("Replica %v is not open. Removing it from startup list. Error while waiting for open: %v", address, err) - continue + for address, replica := range replicas { + if create { + logrus.Infof("Create replica %v", address) + if err := replica.client.Create(replica.size); err != nil { + logrus.Errorf("Error creating replica %v: %v. It won't be used to start controller.", address, err) + continue + } } addresses = append(addresses, address) } - - if len(addresses) == 0 { - return fmt.Errorf("Couldn't find any valid replicas to start with. Original replica set from metadta: %v", fromMetadata) + if len(addresses) > 0 { + logrus.Infof("Starting controller with replicas: %v.", addresses) + return true, c.client.Start(addresses...) } + return false, nil +} - logrus.Infof("Starting controller with replicas: %v.", addresses) - if err := c.client.Start(addresses...); err != nil { - return fmt.Errorf("Error starting controller: %v", err) +// Start the controller with a single replica from the provided map. If the map is bigger than one, will try with each replica. +// Return bool indicates if the controller attempted to start. +func (c *Controller) startWithOne(replicas map[string]*replica, close bool) (bool, error) { + returnErrors := []error{} + for addr, replica := range replicas { + if close { + logrus.Infof("Closing replica %v", addr) + if err := replica.client.Close(); err != nil { + logrus.Errorf("Error closing replica %v: %v. It won't be used to start controller.", addr, err) + continue + } + } + + logrus.Infof("Starting controller with replica: %v.", addr) + if err := c.client.Start(addr); err != nil { + returnErrors = append(returnErrors, fmt.Errorf("%v: %v", addr, err)) + } else { + return true, nil + } } - return nil + var err error + if len(returnErrors) > 0 { + err = fmt.Errorf("Enountered %v errors trying to start controller. Errors: %v", len(returnErrors), returnErrors) + } + return err != nil, err } func (c *Controller) refresh() error { @@ -151,7 +247,7 @@ func (c *Controller) syncReplicas() (retErr error) { fromController[r.Address] = r } - _, fromMetadata, err := c.replicasFromMetadata() + _, fromMetadata, err := c.replicaMetadataAndClient() if err != nil { return fmt.Errorf("Error listing replicas in metadata: %v", err) } @@ -181,11 +277,22 @@ func (c *Controller) syncReplicas() (retErr error) { return nil } -func (c *Controller) addReplica(r replica) error { - logrus.Infof("Adding replica %v", r.host) - err := c.ensureOpen(r) +func (c *Controller) addReplica(r *replica) error { + replica, err := r.client.GetReplica() if err != nil { - return err + return fmt.Errorf("Error getting replica %v before adding: %v", r.host, err) + } + + if replica.State == "initial" { + err := r.client.Create(r.size) + if err != nil { + return fmt.Errorf("Error opening replica %v before adding: %v", r.host, err) + } + } else if _, ok := replica.Actions["close"]; ok { + err := r.client.Close() + if err != nil { + return fmt.Errorf("Error closing replica %v before adding: %v", r.host, err) + } } cmd := exec.Command("longhorn", "add", ReplicaAddress(r.host, r.port)) @@ -195,51 +302,7 @@ func (c *Controller) addReplica(r replica) error { return cmd.Run() } -func (c *Controller) ensureOpen(r replica) error { - client, err := lclient.NewReplicaClient(ReplicaAddress(r.host, r.port)) - if err != nil { - return err - } - - replica, err := client.GetReplica() - if err != nil { - return err - } - - if replica.State != "open" { - if err := client.OpenReplica(r.size); err != nil { - return fmt.Errorf("Error opening replica %v: %v", r.host, err) - } - } - - return nil -} - -func backoff(maxDuration time.Duration, timeoutMessage string, f func() (bool, error)) error { - startTime := time.Now() - waitTime := 150 * time.Millisecond - maxWaitTime := 2 * time.Second - for { - if time.Now().Sub(startTime) > maxDuration { - return fmt.Errorf(timeoutMessage) - } - - if done, err := f(); err != nil { - return err - } else if done { - return nil - } - - time.Sleep(waitTime) - - waitTime *= 2 - if waitTime > maxWaitTime { - waitTime = maxWaitTime - } - } -} - -func (c *Controller) replicasFromMetadata() (int, map[string]replica, error) { +func (c *Controller) replicaMetadataAndClient() (int, map[string]*replica, error) { client, err := metadata.NewClientAndWait(MetadataURL) if err != nil { return 0, nil, err @@ -277,15 +340,22 @@ func (c *Controller) replicasFromMetadata() (int, map[string]replica, error) { } } - result := map[string]replica{} + result := map[string]*replica{} for _, container := range containers { - r := replica{ + r := &replica{ healthState: container.HealthState, host: container.PrimaryIp, port: 9502, size: size, } - result[ReplicaAddress(r.host, r.port)] = r + + address := ReplicaAddress(r.host, r.port) + replicaClient, err := lclient.NewReplicaClient(address) + if err != nil { + return 0, nil, fmt.Errorf("Error getting client for replica %v: %v", address, err) + } + r.client = replicaClient + result[address] = r } return service.Scale, result, nil diff --git a/client/replica_client.go b/client/replica_client.go index 704e8781..d1009588 100644 --- a/client/replica_client.go +++ b/client/replica_client.go @@ -59,6 +59,17 @@ func NewReplicaClient(address string) (*ReplicaClient, error) { }, nil } +func (c *ReplicaClient) Create(size string) error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["create"], rest.CreateInput{ + Size: size, + }, nil) +} + func (c *ReplicaClient) Close() error { r, err := c.GetReplica() if err != nil { From 8959aeb6f2033bd7e8cd728d7854ffa105919efd Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 4 May 2016 09:52:25 -0700 Subject: [PATCH 037/357] Do not return error to caller if we still have a good replica --- controller/control.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/controller/control.go b/controller/control.go index 75469a77..77c2535f 100644 --- a/controller/control.go +++ b/controller/control.go @@ -240,13 +240,20 @@ func (c *Controller) ReadAt(b []byte, off int64) (int, error) { func (c *Controller) handleError(err error) error { if bErr, ok := err.(*BackendError); ok { + c.Lock() if len(bErr.Errors) > 0 { - c.Lock() for address := range bErr.Errors { c.setReplicaModeNoLock(address, types.ERR) } - c.Unlock() + // if we still have a good replica, do not return error + for _, r := range c.replicas { + if r.Mode == types.RW { + err = nil + break + } + } } + c.Unlock() } return err } From 4d9c5515eaafaa6855af244eb24c5dfcd50c4e99 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Wed, 4 May 2016 14:46:52 -0700 Subject: [PATCH 038/357] Replica healthcheck fixes - In replcia healthcheck: if a replica is not listed in the controller API, consider it healthy. - Add logic to retry replicas that errored out - Pull in new docker-longhorn-driver that tweaks the replica healthcheck configuration --- Dockerfile.dapper | 2 +- agent/controller/controller.go | 150 +++++++++++++++++++++++++++++---- agent/status/common.go | 1 - agent/status/replica.go | 7 +- 4 files changed, 137 insertions(+), 23 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ef1739da..6e3e3ee6 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -67,7 +67,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/cjellick/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout 553bfea741326737cc88b9fa99a0b147de2e5830 && \ + git checkout e861cbf7058bbcdf1c0600469710dc07afeeeeb2 && \ go build -o /usr/local/bin/docker-longhorn-driver VOLUME /tmp diff --git a/agent/controller/controller.go b/agent/controller/controller.go index 5ba6da28..73ab1e63 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -19,6 +19,7 @@ import ( const ( defaultVolumeSize = "10737418240" // 10 gb MetadataURL = "http://rancher-metadata/2015-12-19" + errorRetryMax = 1 ) type replica struct { @@ -34,13 +35,15 @@ func ReplicaAddress(host string, port int) string { } type Controller struct { - client *lclient.ControllerClient + client *lclient.ControllerClient + errorRetries map[string]int } func New() *Controller { client := lclient.NewControllerClient("http://localhost:9501") return &Controller{ - client: client, + client: client, + errorRetries: map[string]int{}, } } @@ -238,36 +241,132 @@ func (c *Controller) refresh() error { func (c *Controller) syncReplicas() (retErr error) { logrus.Debugf("Syncing replicas.") + // Remove replicas from controller if they aren't in metadata + _, fromMetadata, err := c.replicaMetadataAndClient() + if err != nil { + return fmt.Errorf("Error listing replicas in metadata: %v", err) + } + if err := c.removeReplicasNotInMetadata(fromMetadata); err != nil { + return err + } + + // Retry replicas in error state + if err := c.retryErroredReplicas(); err != nil { + return err + } + + // Add new replicas + return c.addReplicasInMetadata() +} + +func (c *Controller) removeReplicasNotInMetadata(fromMetadata map[string]*replica) error { replicasInController, err := c.client.ListReplicas() if err != nil { - return fmt.Errorf("Error listing replicas in controller: %v", err) + return fmt.Errorf("Error listing replicas in controller during remove: %v", err) } fromController := map[string]rest.Replica{} for _, r := range replicasInController { fromController[r.Address] = r } - _, fromMetadata, err := c.replicaMetadataAndClient() - if err != nil { - return fmt.Errorf("Error listing replicas in metadata: %v", err) - } - - // Remove replicas from controller if they aren't in metadata - if len(replicasInController) > 1 { + if len(fromController) > 1 { for address := range fromController { if _, ok := fromMetadata[address]; !ok { - logrus.Infof("Removing replica %v", address) + logrus.Infof("Replica %v not in metadata. Removing it.", address) if _, err := c.client.DeleteReplica(address); err != nil { return fmt.Errorf("Error removing replica %v: %v", address, err) } - return nil // Just remove one replica per cycle + return c.removeReplicasNotInMetadata(fromMetadata) } } } - // Add replicas + return nil +} + +func (c *Controller) retryErroredReplicas() error { + _, fromMetadata, err := c.replicaMetadataAndClient() + if err != nil { + return fmt.Errorf("Error listing replicas in metadata during retry: %v", err) + } + + replicasInController, err := c.client.ListReplicas() + if err != nil { + return fmt.Errorf("Error listing replicas in controller during retry: %v", err) + } + + for _, r := range replicasInController { + if r.Mode != "ERR" { + continue + } + + if retryCount, ok := c.errorRetries[r.Address]; ok && retryCount >= errorRetryMax { + logrus.Infof("Reached max retry count for replica %v. Ignoring it so that replica helthcheck failure destroys it.", r.Address) + } else { + logrus.Infof("Retrying errored replica %v", r.Address) + c.errorRetries[r.Address] = retryCount + 1 + replicaMD, ok := fromMetadata[r.Address] + if !ok { + logrus.Warnf("Cannot find errored replica %v in metadata. Won't attempt to re-add it.", r.Actions) + } else if err := c.removeAndAdd(r, replicaMD); err != nil { + return fmt.Errorf("Error performing remove and add for replica %v: %v", r.Address, err) + } else { + // remove and add was successful + delete(c.errorRetries, r.Address) + } + } + } + + // Cleanup error retires map + for address := range c.errorRetries { + if _, ok := fromMetadata[address]; !ok { + delete(c.errorRetries, address) + } + } + + return nil +} + +func (c *Controller) removeAndAdd(replica rest.Replica, replicaMD *replica) error { + logrus.Infof("Removing errored replica %v for re-add.", replica.Address) + if _, err := c.client.DeleteReplica(replica.Address); err != nil { + return fmt.Errorf("Error removing errored replica %v: %v.", replica.Address, err) + } + + freshReplica, err := replicaMD.client.GetReplica() + if err != nil { + return fmt.Errorf("Error getting replica %v during removeAndAdd: %v.", replica.Address, err) + } + + if _, ok := freshReplica.Actions["close"]; ok { + err := replicaMD.client.Close() + if err != nil { + return fmt.Errorf("Error closing replica %v before adding: %v.", replica.Address, err) + } + } + + return c.addReplica(replicaMD) +} + +func (c *Controller) addReplicasInMetadata() error { + _, fromMetadata, err := c.replicaMetadataAndClient() + if err != nil { + return fmt.Errorf("Error listing replicas in metadata during add: %v", err) + } + + replicasInController, err := c.client.ListReplicas() + if err != nil { + return fmt.Errorf("Error listing replicas in controller during add: %v", err) + } + + fromController := map[string]rest.Replica{} + for _, r := range replicasInController { + fromController[r.Address] = r + } + for address, r := range fromMetadata { if _, ok := fromController[address]; !ok { + logrus.Infof("Adding replica %v because it isn't in controller.", address) if err := c.addReplica(r); err != nil { return fmt.Errorf("Error adding replica %v: %v", address, err) } @@ -283,7 +382,7 @@ func (c *Controller) addReplica(r *replica) error { return fmt.Errorf("Error getting replica %v before adding: %v", r.host, err) } - if replica.State == "initial" { + if _, ok := replica.Actions["create"]; ok { err := r.client.Create(r.size) if err != nil { return fmt.Errorf("Error opening replica %v before adding: %v", r.host, err) @@ -295,11 +394,30 @@ func (c *Controller) addReplica(r *replica) error { } } - cmd := exec.Command("longhorn", "add", ReplicaAddress(r.host, r.port)) + address := ReplicaAddress(r.host, r.port) + logrus.Infof("Calling longhorn add cli for replica %v.", address) + cmd := exec.Command("longhorn", "add", address) cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout - return cmd.Run() + if err := cmd.Run(); err != nil { + logrus.Warnf("longhorn add cli returned error %v while adding replica %v. Attempting to clean up.", err, address) + replicas, err2 := c.client.ListReplicas() + if err2 != nil { + logrus.Errorf("Error listing replicas while trying to clean up after failed add for replica %v", address) + } else { + for _, replica := range replicas { + if replica.Address == address && replica.Mode != "RW" { + logrus.Infof("Removing replica %v after having failed to add it. Add failure: %v", address, err) + if _, err := c.client.DeleteReplica(address); err != nil { + logrus.Errorf("Error while deleting replica as part of cleanup: %v", err) + } + } + } + } + return fmt.Errorf("Error executing add command %v: %v", cmd, err) + } + return nil } func (c *Controller) replicaMetadataAndClient() (int, map[string]*replica, error) { diff --git a/agent/status/common.go b/agent/status/common.go index 9ca6a70c..f6d1d35f 100644 --- a/agent/status/common.go +++ b/agent/status/common.go @@ -7,7 +7,6 @@ import ( ) func writeOK(rw http.ResponseWriter) { - logrus.Debugf("Reporting OK.") rw.Write([]byte("OK")) } diff --git a/agent/status/replica.go b/agent/status/replica.go index c64bfa26..a94c2754 100644 --- a/agent/status/replica.go +++ b/agent/status/replica.go @@ -7,8 +7,6 @@ import ( md "github.com/rancher/go-rancher-metadata/metadata" "github.com/rancher/longhorn/client" - "strings" - "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/agent/controller" ) @@ -69,14 +67,13 @@ func (s *ReplicaStatus) checkReplicaStatusInController(rw http.ResponseWriter) ( } for _, replica := range replicas { if replica.Address == s.address { - if strings.EqualFold(replica.Mode, "err") { + if replica.Mode == "ERR" { return s.cacheControllerResponse(false, fmt.Sprintf("Replica %v is in error mode.", s.address)) } - return s.cacheControllerResponse(true, "") } } - return s.cacheControllerResponse(false, fmt.Sprintf("Replica %v is not in the controller's list of replicas. Current list: %v", s.address, replicas)) + return s.cacheControllerResponse(true, "") } func (s *ReplicaStatus) reportCacheControllerResponse() (bool, string) { From c7dd2bc1e283e0e85dec02c43b90f81bb1f5d618 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Thu, 5 May 2016 18:29:15 -0700 Subject: [PATCH 039/357] Add logic to reset rebuilding flag on replica --- integration/core/test_cli.py | 34 ++++++++++++++++++++++++++++++++++ sync/sync.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 6dabc87b..35066114 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -151,6 +151,40 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert r.mode == 'RW' +def test_replica_add_after_rebuild_failed(bin, controller_client, + replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + r = replica_client.list_replica()[0] + r = r.open() + r = r.snapshot(name='000') + r.close() + + cmd = [bin, '--debug', 'add-replica', REPLICA] + subprocess.check_call(cmd) + + volume = controller_client.list_volume()[0] + assert volume.replicaCount == 1 + + l = replica_client2.list_replica()[0] + l = l.open() + l = l.setrebuilding(rebuilding=True) + l.close() + + cmd = [bin, '--debug', 'add-replica', REPLICA2] + subprocess.check_call(cmd) + + volume = controller_client.list_volume()[0] + assert volume.replicaCount == 2 + + replicas = controller_client.list_replica() + assert len(replicas) == 2 + + for r in replicas: + assert r.mode == 'RW' + + def test_snapshot(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) open_replica(replica_client2) diff --git a/sync/sync.go b/sync/sync.go index ef9f7d74..490c5a32 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -30,6 +30,10 @@ func (t *Task) AddReplica(replica string) error { return t.client.Start(replica) } + if err := t.checkAndResetFailedRebuild(replica); err != nil { + return err + } + logrus.Infof("Adding replica %s in WO mode", replica) _, err = t.client.CreateReplica(replica) if err != nil { @@ -52,6 +56,32 @@ func (t *Task) AddReplica(replica string) error { return t.setRw(replica) } +func (t *Task) checkAndResetFailedRebuild(address string) error { + client, err := client.NewReplicaClient(address) + if err != nil { + return err + } + + replica, err := client.GetReplica() + if err != nil { + return err + } + + if replica.State == "closed" && replica.Rebuilding { + if err := client.OpenReplica(); err != nil { + return err + } + + if err := client.SetRebuilding(false); err != nil { + return err + } + + return client.Close() + } + + return nil +} + func (t *Task) setRw(replica string) error { to, err := t.getToReplica(replica) if err != nil { From 4de05b27923d5c12b45b48c9232313f22f4b6d58 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 2 May 2016 10:52:35 -0700 Subject: [PATCH 040/357] Add snapshot rm command --- app/snapshot.go | 30 ++++++++++++ client/replica_client.go | 57 ++++++++++++++++++++-- integration/core/test_cli.py | 29 +++++++++++ replica/diff_disk.go | 5 +- scripts/integration-test | 4 +- sync/agent/model.go | 13 ++--- sync/agent/process.go | 39 +++++++++++++++ sync/sync.go | 94 ++++++++++++++++++++++++++++++++++++ 8 files changed, 257 insertions(+), 14 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index 4f625562..936efd29 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -8,6 +8,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/rancher/longhorn/sync" "github.com/rancher/longhorn/util" ) @@ -18,6 +19,7 @@ func SnapshotCmd() cli.Command { Subcommands: []cli.Command{ SnapshotCreateCmd(), SnapshotLsCmd(), + SnapshotRmCmd(), }, Action: func(c *cli.Context) { if err := lsSnapshot(c); err != nil { @@ -38,6 +40,17 @@ func SnapshotCreateCmd() cli.Command { } } +func SnapshotRmCmd() cli.Command { + return cli.Command{ + Name: "rm", + Action: func(c *cli.Context) { + if err := rmSnapshot(c); err != nil { + logrus.Fatal(err) + } + }, + } +} + func SnapshotLsCmd() cli.Command { return cli.Command{ Name: "ls", @@ -61,6 +74,23 @@ func createSnapshot(c *cli.Context) error { return nil } +func rmSnapshot(c *cli.Context) error { + var lastErr error + url := c.GlobalString("url") + task := sync.NewTask(url) + + for _, name := range c.Args() { + if err := task.DeleteSnapshot(name); err == nil { + fmt.Printf("deleted %s\n", name) + } else { + lastErr = err + fmt.Fprintf(os.Stderr, "Failed to delete %s: %v", name, err) + } + } + + return lastErr +} + func lsSnapshot(c *cli.Context) error { cli := getCli(c) diff --git a/client/replica_client.go b/client/replica_client.go index d1009588..be241b94 100644 --- a/client/replica_client.go +++ b/client/replica_client.go @@ -90,6 +90,17 @@ func (c *ReplicaClient) SetRebuilding(rebuilding bool) error { }, nil) } +func (c *ReplicaClient) RemoveDisk(disk string) error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["removedisk"], &rest.RemoveDiskInput{ + Name: disk, + }, nil) +} + func (c *ReplicaClient) OpenReplica() error { r, err := c.GetReplica() if err != nil { @@ -115,7 +126,9 @@ func (c *ReplicaClient) ReloadReplica() (rest.Replica, error) { func (c *ReplicaClient) LaunchReceiver() (string, int, error) { var running agent.Process - err := c.post(c.syncAgent+"/processes", &agent.Process{}, &running) + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "sync", + }, &running) if err != nil { return "", 0, err } @@ -123,13 +136,47 @@ func (c *ReplicaClient) LaunchReceiver() (string, int, error) { return c.host, running.Port, nil } +func (c *ReplicaClient) Coalesce(from, to string) error { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "fold", + SrcFile: from, + DestFile: to, + }, &running) + if err != nil { + return err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return nil + default: + return fmt.Errorf("ExitCode: %d", running.ExitCode) + } + } +} + func (c *ReplicaClient) SendFile(from, to, host string, port int) error { var running agent.Process err := c.post(c.syncAgent+"/processes", &agent.Process{ - Host: host, - SrcFile: from, - DestFile: to, - Port: port, + ProcessType: "sync", + Host: host, + SrcFile: from, + DestFile: to, + Port: port, }, &running) if err != nil { return err diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 35066114..3e1e0b9d 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -261,3 +261,32 @@ def test_snapshot_create(bin, controller_client, replica_client, assert ls_output == '''ID {} '''.format(output) + + +def test_snapshot_rm(bin, controller_client, replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + cmd = [bin, 'snapshot', 'create'] + subprocess.check_call(cmd) + output = subprocess.check_output(cmd).strip() + + chain = replica_client.list_replica()[0].chain + assert len(chain) == 3 + assert chain[0] == 'volume-head-002.img' + assert chain[1] == 'volume-snap-{}.img'.format(output) + + cmd = [bin, 'snapshot', 'rm', output] + subprocess.check_call(cmd) + + new_chain = replica_client.list_replica()[0].chain + assert len(new_chain) == 2 + assert chain[0] == new_chain[0] + assert chain[2] == new_chain[1] diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 8c73585c..37e0e539 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -24,8 +24,9 @@ func (d *diffDisk) RemoveIndex(index int) error { } for i := 0; i < len(d.location); i++ { - if d.location[i] >= byte(index) { - d.location[i] = d.location[i] - 1 + if d.location[i] == byte(index) { + // set back to unknown + d.location[i] = 0 } } diff --git a/scripts/integration-test b/scripts/integration-test index e0650adb..81540040 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -18,4 +18,6 @@ fi ./bin/longhorn replica --listen localhost:9505 $temp2 & cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; -tox +if [ -z "$NO_TEST" ]; then + tox "$@" +fi diff --git a/sync/agent/model.go b/sync/agent/model.go index c298be31..565a9c91 100644 --- a/sync/agent/model.go +++ b/sync/agent/model.go @@ -8,12 +8,13 @@ import ( type Process struct { client.Resource - SrcFile string `json:"srcFile"` - DestFile string `json:"destfile"` - Host string `json:"host"` - Port int `json:"port"` - ExitCode int `json:"exitCode"` - Created time.Time `json:"created"` + ProcessType string `json:"processType"` + SrcFile string `json:"srcFile"` + DestFile string `json:"destfile"` + Host string `json:"host"` + Port int `json:"port"` + ExitCode int `json:"exitCode"` + Created time.Time `json:"created"` } type ProcessCollection struct { diff --git a/sync/agent/process.go b/sync/agent/process.go index b79066b5..5b5f179d 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -2,6 +2,7 @@ package agent import ( "errors" + "fmt" "net/http" "os" "os/exec" @@ -106,6 +107,44 @@ func (s *Server) CreateProcess(rw http.ResponseWriter, req *http.Request) error } func (s *Server) launch(p *Process) error { + switch p.ProcessType { + case "sync": + return s.launchSync(p) + case "fold": + return s.launchFold(p) + } + return fmt.Errorf("Unknown process type %s", p.ProcessType) +} + +func (s *Server) launchFold(p *Process) error { + cmd := exec.Command("sfold", p.SrcFile, p.DestFile) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Start() + + logrus.Infof("Running %s %v", cmd.Path, cmd.Args) + err := cmd.Wait() + if err != nil { + logrus.Infof("Error running %s %v: %v", "sfold", cmd.Args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "sfold", cmd.Args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v", "sfold", cmd.Args) + return nil +} + +func (s *Server) launchSync(p *Process) error { args := []string{} if p.Host != "" { args = append(args, "-host", p.Host) diff --git a/sync/sync.go b/sync/sync.go index 490c5a32..eb2cfcf7 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -20,6 +20,100 @@ func NewTask(controller string) *Task { } } +func (t *Task) DeleteSnapshot(snapshot string) error { + replicas, err := t.client.ListReplicas() + if err != nil { + return err + } + + for _, replica := range replicas { + if err := t.coalesceSnapshot(&replica, snapshot); err != nil { + return err + } + } + + for _, replica := range replicas { + if err := t.rmDisk(&replica, snapshot); err != nil { + return err + } + } + + return nil +} + +func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string) error { + repClient, err := client.NewReplicaClient(replicaInController.Address) + if err != nil { + return err + } + + replica, err := repClient.GetReplica() + if err != nil { + return err + } + + disk, _ := getNameAndIndex(replica.Chain, snapshot) + return repClient.RemoveDisk(disk) +} + +func getNameAndIndex(chain []string, snapshot string) (string, int) { + index := find(chain, snapshot) + if index < 0 { + snapshot = fmt.Sprintf("volume-snap-%s.img", snapshot) + index = find(chain, snapshot) + } + + if index < 0 { + return "", index + } + + return snapshot, index +} + +func (t *Task) coalesceSnapshot(replicaInController *rest.Replica, snapshot string) error { + if replicaInController.Mode != "RW" { + return fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := client.NewReplicaClient(replicaInController.Address) + if err != nil { + return err + } + + replica, err := repClient.GetReplica() + if err != nil { + return err + } + + _, index := getNameAndIndex(replica.Chain, snapshot) + + switch { + case index < 0: + return fmt.Errorf("Snapshot %s not found on replica %s", snapshot, replicaInController.Address) + case index == 0: + return fmt.Errorf("Can not remove the head disk in the chain") + case index >= len(replica.Chain): + return fmt.Errorf("Can not remove the last disk in the chain") + } + + logrus.Infof("Coalescing %s on %s", snapshot, replicaInController.Address) + err = repClient.Coalesce(replica.Chain[index], replica.Chain[index+1]) + if err != nil { + logrus.Errorf("Failed to coalesce %s on %s: %v", snapshot, replicaInController.Address, err) + return err + } + return nil +} + +func find(list []string, item string) int { + for i, val := range list { + if val == item { + return i + } + } + return -1 +} + func (t *Task) AddReplica(replica string) error { volume, err := t.client.GetVolume() if err != nil { From 56ef4b61a4678bb86cb41636500799c6372fb0b8 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 7 May 2016 22:33:49 -0700 Subject: [PATCH 041/357] Include ssync and sfold in longhorn CLI --- Dockerfile.dapper | 7 - main.go | 12 + package/Dockerfile | 2 +- scripts/package | 2 +- sync/agent/process.go | 28 +- trash.yml | 5 +- vendor/github.com/docker/docker/.dockerignore | 3 + vendor/github.com/docker/docker/.gitignore | 27 + vendor/github.com/docker/docker/.mailmap | 237 ++ vendor/github.com/docker/docker/AUTHORS | 1460 ++++++++++ vendor/github.com/docker/docker/CHANGELOG.md | 2415 +++++++++++++++++ .../github.com/docker/docker/CONTRIBUTING.md | 436 +++ vendor/github.com/docker/docker/Dockerfile | 276 ++ .../docker/docker/Dockerfile.aarch64 | 209 ++ .../github.com/docker/docker/Dockerfile.armhf | 227 ++ .../github.com/docker/docker/Dockerfile.gccgo | 102 + .../docker/docker/Dockerfile.ppc64le | 227 ++ .../github.com/docker/docker/Dockerfile.s390x | 206 ++ .../docker/docker/Dockerfile.simple | 56 + .../docker/docker/Dockerfile.windows | 101 + vendor/github.com/docker/docker/LICENSE | 191 ++ vendor/github.com/docker/docker/MAINTAINERS | 255 ++ vendor/github.com/docker/docker/Makefile | 106 + vendor/github.com/docker/docker/NOTICE | 19 + vendor/github.com/docker/docker/README.md | 301 ++ vendor/github.com/docker/docker/ROADMAP.md | 140 + vendor/github.com/docker/docker/VENDORING.md | 45 + vendor/github.com/docker/docker/VERSION | 1 + vendor/github.com/docker/docker/pkg/README.md | 11 + .../docker/docker/pkg/reexec/README.md | 5 + .../docker/pkg/reexec/command_freebsd.go | 23 + .../docker/docker/pkg/reexec/command_linux.go | 28 + .../docker/pkg/reexec/command_unsupported.go | 12 + .../docker/pkg/reexec/command_windows.go | 23 + .../docker/docker/pkg/reexec/reexec.go | 47 + .../rancher/sparse-tools/.dockerignore | 4 + .../rancher/sparse-tools/.drone.yml | 6 + .../rancher/sparse-tools/.gitignore | 36 +- .../rancher/sparse-tools/Dockerfile.dapper | 16 + .../github.com/rancher/sparse-tools/Makefile | 23 + .../github.com/rancher/sparse-tools/README.md | 4 + .../rancher/sparse-tools/cli/sfold/main.go | 58 + .../rancher/sparse-tools/cli/ssync/main.go | 85 + .../sparse-tools/directfio/directfio.go | 43 +- .../sparse-tools/directfio/directfio_test.go | 133 +- .../rancher/sparse-tools/log/log.go | 99 + .../rancher/sparse-tools/sparse/client.go | 486 ++++ .../sparse-tools/sparse/client_test.go | 587 ++++ .../rancher/sparse-tools/sparse/file.go | 141 + .../rancher/sparse-tools/sparse/layout.go | 271 ++ .../sparse-tools/sparse/layout_test.go | 192 ++ .../rancher/sparse-tools/sparse/server.go | 396 +++ .../rancher/sparse-tools/sparse/sfold.go | 109 + .../rancher/sparse-tools/sparse/sfold_test.go | 149 + .../rancher/sparse-tools/sparse/ssync_test.go | 327 +++ .../sparse-tools/sparse/testutil_test.go | 133 + .../github.com/rancher/sparse-tools/trash.yml | 4 + 57 files changed, 10451 insertions(+), 96 deletions(-) create mode 100644 vendor/github.com/docker/docker/.dockerignore create mode 100644 vendor/github.com/docker/docker/.gitignore create mode 100644 vendor/github.com/docker/docker/.mailmap create mode 100644 vendor/github.com/docker/docker/AUTHORS create mode 100644 vendor/github.com/docker/docker/CHANGELOG.md create mode 100644 vendor/github.com/docker/docker/CONTRIBUTING.md create mode 100644 vendor/github.com/docker/docker/Dockerfile create mode 100644 vendor/github.com/docker/docker/Dockerfile.aarch64 create mode 100644 vendor/github.com/docker/docker/Dockerfile.armhf create mode 100644 vendor/github.com/docker/docker/Dockerfile.gccgo create mode 100644 vendor/github.com/docker/docker/Dockerfile.ppc64le create mode 100644 vendor/github.com/docker/docker/Dockerfile.s390x create mode 100644 vendor/github.com/docker/docker/Dockerfile.simple create mode 100755 vendor/github.com/docker/docker/Dockerfile.windows create mode 100644 vendor/github.com/docker/docker/LICENSE create mode 100644 vendor/github.com/docker/docker/MAINTAINERS create mode 100644 vendor/github.com/docker/docker/Makefile create mode 100644 vendor/github.com/docker/docker/NOTICE create mode 100644 vendor/github.com/docker/docker/README.md create mode 100644 vendor/github.com/docker/docker/ROADMAP.md create mode 100644 vendor/github.com/docker/docker/VENDORING.md create mode 100644 vendor/github.com/docker/docker/VERSION create mode 100644 vendor/github.com/docker/docker/pkg/README.md create mode 100644 vendor/github.com/docker/docker/pkg/reexec/README.md create mode 100644 vendor/github.com/docker/docker/pkg/reexec/command_freebsd.go create mode 100644 vendor/github.com/docker/docker/pkg/reexec/command_linux.go create mode 100644 vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go create mode 100644 vendor/github.com/docker/docker/pkg/reexec/command_windows.go create mode 100644 vendor/github.com/docker/docker/pkg/reexec/reexec.go create mode 100644 vendor/github.com/rancher/sparse-tools/.dockerignore create mode 100644 vendor/github.com/rancher/sparse-tools/.drone.yml create mode 100644 vendor/github.com/rancher/sparse-tools/Dockerfile.dapper create mode 100644 vendor/github.com/rancher/sparse-tools/Makefile create mode 100644 vendor/github.com/rancher/sparse-tools/cli/sfold/main.go create mode 100644 vendor/github.com/rancher/sparse-tools/cli/ssync/main.go create mode 100644 vendor/github.com/rancher/sparse-tools/log/log.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/client.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/client_test.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/file.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/layout.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/layout_test.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/server.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/sfold.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go create mode 100644 vendor/github.com/rancher/sparse-tools/trash.yml diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 6e3e3ee6..cf3577f9 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -54,13 +54,6 @@ RUN cd /usr/src/tcmu-runner && \ cp scsi_defs.h /usr/local/include && \ cp libtcmu_static.a /usr/local/lib/libtcmu.a -# Install ssync, etc -RUN GOPATH=/tmp/ssync && go get -d github.com/rancher/sparse-tools/ssync && \ - cd $GOPATH/src/github.com/rancher/sparse-tools && \ - git checkout 84fc96db3ee359d3e5675df414494c09c7d0c0c2 && \ - cd ssync && \ - go build -o /usr/local/bin/ssync - # Install longhorn Docker driver RUN GOPATH=/tmp/docker-longhorn-driver && \ mkdir -p $GOPATH/src/github.com/rancher && \ diff --git a/main.go b/main.go index 8e554577..d6c844ff 100644 --- a/main.go +++ b/main.go @@ -7,10 +7,22 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/docker/docker/pkg/reexec" "github.com/rancher/longhorn/app" + "github.com/rancher/sparse-tools/cli/sfold" + "github.com/rancher/sparse-tools/cli/ssync" ) func main() { + reexec.Register("ssync", ssync.Main) + reexec.Register("sfold", sfold.Main) + + if !reexec.Init() { + longhornCli() + } +} + +func longhornCli() { pprofFile := os.Getenv("PPROFILE") if pprofFile != "" { f, err := os.Create(pprofFile) diff --git a/package/Dockerfile b/package/Dockerfile index 9f1464e2..37b48b9a 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -4,5 +4,5 @@ RUN apt-get update && apt-get install -y kmod curl RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin -COPY longhorn longhorn-agent launch ssync launch-driver docker-longhorn-driver /usr/bin/ +COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver /usr/bin/ CMD ["longhorn"] diff --git a/scripts/package b/scripts/package index c87be8d1..f4b1f94c 100755 --- a/scripts/package +++ b/scripts/package @@ -13,7 +13,7 @@ if [ ! -x ../bin/longhorn ]; then fi cp ../bin/longhorn* . -cp /usr/local/bin/{docker-longhorn-driver,ssync} . +cp /usr/local/bin/docker-longhorn-driver . docker build -t ${REPO}/longhorn:${TAG} . echo Built ${REPO}/longhorn:${TAG} diff --git a/sync/agent/process.go b/sync/agent/process.go index 5b5f179d..97734c89 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -11,6 +11,7 @@ import ( "syscall" "github.com/Sirupsen/logrus" + "github.com/docker/docker/pkg/reexec" "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" @@ -100,7 +101,11 @@ func (s *Server) CreateProcess(rw http.ResponseWriter, req *http.Request) error s.Unlock() p.ExitCode = -2 - go s.launch(&p) + go func() { + if err := s.launch(&p); err != nil { + logrus.Errorf("Failed to launch %#v: %v", p, err) + } + }() apiContext.Write(&p) return nil @@ -117,13 +122,15 @@ func (s *Server) launch(p *Process) error { } func (s *Server) launchFold(p *Process) error { - cmd := exec.Command("sfold", p.SrcFile, p.DestFile) + cmd := reexec.Command("sfold", p.SrcFile, p.DestFile) cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - cmd.Start() + if err := cmd.Start(); err != nil { + return err + } logrus.Infof("Running %s %v", cmd.Path, cmd.Args) err := cmd.Wait() @@ -144,8 +151,15 @@ func (s *Server) launchFold(p *Process) error { return nil } +func binName() (string, error) { + if _, err := os.Stat(os.Args[0]); err == nil { + return os.Args[0], nil + } + return exec.LookPath(os.Args[0]) +} + func (s *Server) launchSync(p *Process) error { - args := []string{} + args := []string{"ssync"} if p.Host != "" { args = append(args, "-host", p.Host) } @@ -161,13 +175,15 @@ func (s *Server) launchSync(p *Process) error { } } - cmd := exec.Command("ssync", args...) + cmd := reexec.Command(args...) cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - cmd.Start() + if err := cmd.Start(); err != nil { + return err + } logrus.Infof("Running %s %v", "ssync", args) err := cmd.Wait() diff --git a/trash.yml b/trash.yml index 31801519..7db7acb3 100644 --- a/trash.yml +++ b/trash.yml @@ -18,11 +18,14 @@ import: version: 5ed452cd07a408bc6c96d10766a963c0d7585518 - package: github.com/docker/go-units version: 5d2041e26a699eaca682e2ea41c8f891e1060444 +- package: github.com/docker/docker + version: v1.11.1 - package: github.com/codegangsta/cli version: 71f57d300dd6a780ac1856c005c4b518cfd498ec - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 84fc96db3ee359d3e5675df414494c09c7d0c0c2 + version: 8ab53cdb89eb75f6ab104e44145303b04139689c + repo: https://github.com/ibuildthecloud/sparse-tools.git - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec diff --git a/vendor/github.com/docker/docker/.dockerignore b/vendor/github.com/docker/docker/.dockerignore new file mode 100644 index 00000000..9bd2c021 --- /dev/null +++ b/vendor/github.com/docker/docker/.dockerignore @@ -0,0 +1,3 @@ +bundles +.gopath +vendor/pkg diff --git a/vendor/github.com/docker/docker/.gitignore b/vendor/github.com/docker/docker/.gitignore new file mode 100644 index 00000000..9ea55ed0 --- /dev/null +++ b/vendor/github.com/docker/docker/.gitignore @@ -0,0 +1,27 @@ +# Docker project generated files to ignore +# if you want to ignore files created by your editor/tools, +# please consider a global .gitignore https://help.github.com/articles/ignoring-files +*.exe +*.exe~ +*.orig +*.test +.*.swp +.DS_Store +.gopath/ +autogen/ +bundles/ +docker/docker +dockerversion/version_autogen.go +docs/AWS_S3_BUCKET +docs/GITCOMMIT +docs/GIT_BRANCH +docs/VERSION +docs/_build +docs/_static +docs/_templates +docs/changed-files +# generated by man/md2man-all.sh +man/man1 +man/man5 +man/man8 +vendor/pkg/ diff --git a/vendor/github.com/docker/docker/.mailmap b/vendor/github.com/docker/docker/.mailmap new file mode 100644 index 00000000..685f8e6b --- /dev/null +++ b/vendor/github.com/docker/docker/.mailmap @@ -0,0 +1,237 @@ +# Generate AUTHORS: hack/generate-authors.sh + +# Tip for finding duplicates (besides scanning the output of AUTHORS for name +# duplicates that aren't also email duplicates): scan the output of: +# git log --format='%aE - %aN' | sort -uf +# +# For explanation on this file format: man git-shortlog + +Patrick Stapleton +Shishir Mahajan +Erwin van der Koogh +Ahmed Kamal +Tejesh Mehta +Cristian Staretu +Cristian Staretu +Cristian Staretu +Marcus Linke +Aleksandrs Fadins +Christopher Latham +Hu Keping +Wayne Chang +Chen Chao +Daehyeok Mun + + + + + + +Guillaume J. Charmes + + + + + +Thatcher Peskens +Thatcher Peskens +Thatcher Peskens dhrp +Jérôme Petazzoni jpetazzo +Jérôme Petazzoni +Joffrey F +Joffrey F +Joffrey F +Tim Terhorst +Andy Smith + + + + + + + + + +Walter Stanish + +Roberto Hashioka +Konstantin Pelykh +David Sissitka +Nolan Darilek + +Benoit Chesneau +Jordan Arentsen +Daniel Garcia +Miguel Angel Fernández +Bhiraj Butala +Faiz Khan +Victor Lyuboslavsky +Jean-Baptiste Barth +Matthew Mueller + +Shih-Yuan Lee +Daniel Mizyrycki root +Jean-Baptiste Dalido + + + + + + + + + + + + + + +Sven Dowideit +Sven Dowideit +Sven Dowideit +Sven Dowideit <¨SvenDowideit@home.org.au¨> +Sven Dowideit +Sven Dowideit + +Alexander Morozov +Alexander Morozov + +O.S. Tezer + +Roberto G. Hashioka + + + + + +Sridhar Ratnakumar +Sridhar Ratnakumar +Liang-Chi Hsieh +Aleksa Sarai +Aleksa Sarai +Aleksa Sarai +Will Weaver +Timothy Hobbs +Nathan LeClaire +Nathan LeClaire + + + + +Matthew Heon + + + + +Francisco Carriedo + + + + +Brian Goff + + + +Hollie Teal + + + +Jessica Frazelle +Jessica Frazelle +Jessica Frazelle +Jessica Frazelle +Jessica Frazelle + + + + +Thomas LEVEIL Thomas LÉVEIL + + +Antonio Murdaca +Antonio Murdaca +Antonio Murdaca +Antonio Murdaca +Antonio Murdaca +Darren Shepherd +Deshi Xiao +Deshi Xiao +Doug Davis +Jacob Atzen +Jeff Nickoloff +John Howard (VM) +John Howard (VM) +John Howard (VM) +Madhu Venugopal +Mary Anthony +Mary Anthony moxiegirl +Mary Anthony +mattyw +resouer +AJ Bowen soulshake +AJ Bowen soulshake +Tibor Vass +Tibor Vass +Vincent Bernat +Yestin Sun +bin liu +John Howard (VM) jhowardmsft +Ankush Agarwal +Tangi COLIN tangicolin +Allen Sun +Adrien Gallouët + +Anuj Bahuguna +Anusha Ragunathan +Avi Miller +Brent Salisbury +Chander G +Chun Chen +Ying Li +Daehyeok Mun + +Daniel, Dao Quang Minh +Daniel Nephin +Dave Tucker +Doug Tangren +Frederick F. Kautz IV +Ben Golub +Harold Cooper +hsinko <21551195@zju.edu.cn> +Josh Hawn +Justin Cormack + + +Kamil Domański +Lei Jitang + +Linus Heckemann + +Lynda O'Leary + +Marianna Tessel +Michael Huettermann +Moysés Borges + +Nigel Poulton +Qiang Huang + +Boaz Shuster +Shuwei Hao + +Soshi Katsuta + +Stefan Berger + +Stephen Day + +Toli Kuznets +Tristan Carel + +Vincent Demeester + +Vishnu Kannan +xlgao-zju xlgao +yuchangchun y00277921 + + diff --git a/vendor/github.com/docker/docker/AUTHORS b/vendor/github.com/docker/docker/AUTHORS new file mode 100644 index 00000000..bfb128ca --- /dev/null +++ b/vendor/github.com/docker/docker/AUTHORS @@ -0,0 +1,1460 @@ +# This file lists all individuals having contributed content to the repository. +# For how it is generated, see `hack/generate-authors.sh`. + +Aanand Prasad +Aaron Davidson +Aaron Feng +Aaron Huslage +Aaron Lehmann +Aaron Welch +Abel Muiño +Abhijeet Kasurde +Abhinav Ajgaonkar +Abhishek Chanda +Abin Shahab +Adam Miller +Adam Singer +Aditi Rajagopal +Aditya +Adria Casas +Adrian Mouat +Adrian Oprea +Adrien Folie +Adrien Gallouët +Ahmed Kamal +Ahmet Alp Balkan +Aidan Feldman +Aidan Hobson Sayers +AJ Bowen +Ajey Charantimath +ajneu +Akihiro Suda +Al Tobey +alambike +Alan Thompson +Albert Callarisa +Albert Zhang +Aleksa Sarai +Aleksandrs Fadins +Alena Prokharchyk +Alessandro Boch +Alessio Biancalana +Alex Chan +Alex Crawford +Alex Gaynor +Alex Samorukov +Alex Warhawk +Alexander Artemenko +Alexander Boyd +Alexander Larsson +Alexander Morozov +Alexander Shopov +Alexandre Beslic +Alexandre González +Alexandru Sfirlogea +Alexey Guskov +Alexey Kotlyarov +Alexey Shamrin +Alexis THOMAS +Allen Madsen +Allen Sun +almoehi +Alvin Richards +amangoel +Amen Belayneh +Amit Bakshi +Amit Krishnan +Amy Lindburg +Anand Patil +AnandkumarPatel +Anatoly Borodin +Anchal Agrawal +Anders Janmyr +Andre Dublin <81dublin@gmail.com> +Andre Granovsky +Andrea Luzzardi +Andrea Turli +Andreas Köhler +Andreas Savvides +Andreas Tiefenthaler +Andrew C. Bodine +Andrew Clay Shafer +Andrew Duckworth +Andrew France +Andrew Gerrand +Andrew Guenther +Andrew Kuklewicz +Andrew Macgregor +Andrew Macpherson +Andrew Martin +Andrew Munsell +Andrew Weiss +Andrew Williams +Andrews Medina +Andrey Petrov +Andrey Stolbovsky +André Martins +andy +Andy Chambers +andy diller +Andy Goldstein +Andy Kipp +Andy Rothfusz +Andy Smith +Andy Wilson +Anes Hasicic +Anil Belur +Ankush Agarwal +Anonmily +Anthon van der Neut +Anthony Baire +Anthony Bishopric +Anthony Dahanne +Anton Löfgren +Anton Nikitin +Anton Polonskiy +Anton Tiurin +Antonio Murdaca +Antony Messerli +Anuj Bahuguna +Anusha Ragunathan +apocas +ArikaChen +Arnaud Porterie +Arthur Barr +Arthur Gautier +Artur Meyster +Arun Gupta +Asbjørn Enge +averagehuman +Avi Das +Avi Miller +ayoshitake +Azat Khuyiyakhmetov +Bardia Keyoumarsi +Barnaby Gray +Barry Allard +Bartłomiej Piotrowski +Bastiaan Bakker +bdevloed +Ben Firshman +Ben Golub +Ben Hall +Ben Sargent +Ben Severson +Ben Toews +Ben Wiklund +Benjamin Atkin +Benoit Chesneau +Bernerd Schaefer +Bert Goethals +Bharath Thiruveedula +Bhiraj Butala +Bill W +bin liu +Blake Geno +Boaz Shuster +bobby abbott +boucher +Bouke Haarsma +Boyd Hemphill +Bradley Cicenas +Bradley Wright +Brandon Liu +Brandon Philips +Brandon Rhodes +Brendan Dixon +Brent Salisbury +Brett Kochendorfer +Brian (bex) Exelbierd +Brian Bland +Brian DeHamer +Brian Dorsey +Brian Flad +Brian Goff +Brian McCallister +Brian Olsen +Brian Shumate +Brian Torres-Gil +Brice Jaglin +Briehan Lombaard +Bruno Bigras +Bruno Binet +Bruno Gazzera +Bruno Renié +Bryan Bess +Bryan Boreham +Bryan Matsuo +Bryan Murphy +buddhamagnet +Burke Libbey +Byung Kang +Caleb Spare +Calen Pennington +Cameron Boehmer +Cameron Spear +Campbell Allen +Candid Dauth +Carl Henrik Lunde +Carl X. Su +Carlos Sanchez +Carol Fager-Higgins +Cary +Casey Bisson +Cedric Davies +Cezar Sa Espinola +Chad Swenson +Chance Zibolski +Chander G +Charles Chan +Charles Hooper +Charles Lindsay +Charles Merriam +Charles Sarrazin +Charlie Lewis +Chase Bolt +ChaYoung You +Chen Chao +Chen Hanxiao +cheney90 +Chewey +Chia-liang Kao +chli +Cholerae Hu +Chris Alfonso +Chris Armstrong +Chris Dituri +Chris Fordham +Chris Khoo +Chris McKinnel +Chris Seto +Chris Snow +Chris St. Pierre +Chris Stivers +Chris Swan +Chris Wahl +Chris Weyl +chrismckinnel +Christian Berendt +Christian Böhme +Christian Rotzoll +Christian Simon +Christian Stefanescu +ChristoperBiscardi +Christophe Mehay +Christophe Troestler +Christopher Currie +Christopher Jones +Christopher Latham +Christopher Rigor +Christy Perez +Chun Chen +Ciro S. Costa +Clayton Coleman +Clinton Kitson +Coenraad Loubser +Colin Dunklau +Colin Rice +Colin Walters +Collin Guarino +Colm Hally +companycy +Cory Forsyth +cressie176 +Cristian Staretu +cristiano balducci +Cruceru Calin-Cristian +Cyril F +Daan van Berkel +Daehyeok Mun +Dafydd Crosby +dalanlan +Damien Nozay +Damjan Georgievski +Dan Anolik +Dan Buch +Dan Cotora +Dan Griffin +Dan Hirsch +Dan Keder +Dan Levy +Dan McPherson +Dan Stine +Dan Walsh +Dan Williams +Daniel Antlinger +Daniel Exner +Daniel Farrell +Daniel Garcia +Daniel Gasienica +Daniel Hiltgen +Daniel Menet +Daniel Mizyrycki +Daniel Nephin +Daniel Norberg +Daniel Nordberg +Daniel Robinson +Daniel S +Daniel Von Fange +Daniel YC Lin +Daniel Zhang +Daniel, Dao Quang Minh +Danny Berger +Danny Yates +Darren Coxall +Darren Shepherd +Darren Stahl +Dave Barboza +Dave Henderson +Dave Tucker +David Anderson +David Calavera +David Corking +David Cramer +David Currie +David Davis +David Gageot +David Gebler +David Lawrence +David Mackey +David Mat +David Mcanulty +David Pelaez +David R. Jenni +David Röthlisberger +David Sheets +David Sissitka +David Xia +David Young +Davide Ceretti +Dawn Chen +dcylabs +decadent +Deng Guangxing +Deni Bertovic +Denis Gladkikh +Denis Ollier +Dennis Docter +Derek +Derek +Derek Ch +Derek McGowan +Deric Crago +Deshi Xiao +devmeyster +Devvyn Murphy +Dharmit Shah +Dieter Reuter +Dima Stopel +Dimitri John Ledkov +Dinesh Subhraveti +Diogo Monica +DiuDiugirl +Djibril Koné +dkumor +Dmitry Demeshchuk +Dmitry Gusev +Dmitry V. Krivenok +Dmitry Vorobev +Dolph Mathews +Dominik Finkbeiner +Dominik Honnef +Don Kirkby +Don Kjer +Don Spaulding +Donald Huang +Dong Chen +Donovan Jones +Doug Davis +Doug MacEachern +Doug Tangren +Dr Nic Williams +dragon788 +Dražen Lučanin +Dustin Sallings +Ed Costello +Edmund Wagner +Eiichi Tsukata +Eike Herzbach +Eivind Uggedal +Elan Ruusamäe +Elias Probst +Elijah Zupancic +eluck +Elvir Kuric +Emil Hernvall +Emily Maier +Emily Rose +Emir Ozer +Enguerran +Eohyung Lee +Eric Hanchrow +Eric Lee +Eric Myhre +Eric Paris +Eric Rafaloff +Eric Rosenberg +Eric Sage +Eric Windisch +Eric-Olivier Lamey +Erik Bray +Erik Dubbelboer +Erik Hollensbe +Erik Inge Bolsø +Erik Kristensen +Erik Weathers +Erno Hopearuoho +Erwin van der Koogh +Euan +Eugene Yakubovich +eugenkrizo +evalle +Evan Allrich +Evan Carmi +Evan Hazlett +Evan Krall +Evan Phoenix +Evan Wies +Evgeny Vereshchagin +Ewa Czechowska +Eystein Måløy Stenberg +ezbercih +Fabiano Rosas +Fabio Falci +Fabio Rehm +Fabrizio Regini +Faiz Khan +falmp +Fangyuan Gao <21551127@zju.edu.cn> +Fareed Dudhia +Fathi Boudra +Federico Gimenez +Felix Geisendörfer +Felix Hupfeld +Felix Rabe +Felix Schindler +Ferenc Szabo +Fernando +Fero Volar +Filipe Brandenburger +Filipe Oliveira +fl0yd +Flavio Castelli +FLGMwt +Florian Klein +Florian Maier +Florian Weingarten +Florin Asavoaie +Francesc Campoy +Francisco Carriedo +Francisco Souza +Frank Groeneveld +Frank Herrmann +Frank Macreery +Frank Rosquin +Fred Lifton +Frederick F. Kautz IV +Frederik Loeffert +Frederik Nordahl Jul Sabroe +Freek Kalter +Félix Baylac-Jacqué +Félix Cantournet +Gabe Rosenhouse +Gabor Nagy +Gabriel Monroy +GabrielNicolasAvellaneda +Galen Sampson +Gareth Rushgrove +Garrett Barboza +Gaurav +gautam, prasanna +GennadySpb +Geoffrey Bachelet +George MacRorie +George Xie +Georgi Hristozov +Gereon Frey +German DZ +Gert van Valkenhoef +Gianluca Borello +Gildas Cuisinier +gissehel +Giuseppe Mazzotta +Gleb Fotengauer-Malinovskiy +Gleb M Borisov +Glyn Normington +GoBella +Goffert van Gool +Gosuke Miyashita +Gou Rao +Govinda Fichtner +Grant Reaber +Graydon Hoare +Greg Fausak +Greg Thornton +grossws +grunny +gs11 +Guilhem Lettron +Guilherme Salgado +Guillaume Dufour +Guillaume J. Charmes +guoxiuyan +Gurjeet Singh +Guruprasad +gwx296173 +Günter Zöchbauer +Hans Kristian Flaatten +Hans Rødtang +Hao Zhang <21521210@zju.edu.cn> +Harald Albers +Harley Laue +Harold Cooper +Harry Zhang +He Simei +heartlock <21521209@zju.edu.cn> +Hector Castro +Henning Sprang +Hobofan +Hollie Teal +Hong Xu +hsinko <21551195@zju.edu.cn> +Hu Keping +Hu Tao +Huanzhong Zhang +Huayi Zhang +Hugo Duncan +Hugo Marisco <0x6875676f@gmail.com> +Hunter Blanks +huqun +Huu Nguyen +hyeongkyu.lee +hyp3rdino +Ian Babrou +Ian Bishop +Ian Bull +Ian Calvert +Ian Lee +Ian Main +Ian Truslove +Iavael +Icaro Seara +Igor Dolzhikov +Ilkka Laukkanen +Ilya Dmitrichenko +Ilya Gusev +ILYA Khlopotov +imre Fitos +inglesp +Ingo Gottwald +Isaac Dupree +Isabel Jimenez +Isao Jonas +Ivan Babrou +Ivan Fraixedes +J Bruni +J. Nunn +Jack Danger Canty +Jacob Atzen +Jacob Edelman +Jake Champlin +Jake Moshenko +jakedt +James Allen +James Carey +James Carr +James DeFelice +James Harrison Fisher +James Kyburz +James Kyle +James Lal +James Mills +James Nugent +James Turnbull +Jamie Hannaford +Jamshid Afshar +Jan Keromnes +Jan Koprowski +Jan Pazdziora +Jan Toebes +Jan-Gerd Tenberge +Jan-Jaap Driessen +Jana Radhakrishnan +Januar Wayong +Jared Biel +Jaroslaw Zabiello +jaseg +Jasmine Hegman +Jason Divock +Jason Giedymin +Jason Green +Jason Hall +Jason Heiss +Jason Livesay +Jason McVetta +Jason Plum +Jason Shepherd +Jason Smith +Jason Sommer +Jason Stangroome +jaxgeller +Jay +Jay +Jay Kamat +Jean-Baptiste Barth +Jean-Baptiste Dalido +Jean-Paul Calderone +Jean-Tiare Le Bigot +Jeff Anderson +Jeff Johnston +Jeff Lindsay +Jeff Mickey +Jeff Minard +Jeff Nickoloff +Jeff Welch +Jeffrey Bolle +Jeffrey Morgan +Jeffrey van Gogh +Jenny Gebske +Jeremy Grosser +Jeremy Price +Jeremy Qian +Jeremy Unruh +Jeroen Jacobs +Jesse Dearing +Jesse Dubay +Jessica Frazelle +Jezeniel Zapanta +jgeiger +Jian Zhang +jianbosun +Jilles Oldenbeuving +Jim Alateras +Jim Perrin +Jimmy Cuadra +Jimmy Puckett +jimmyxian +Jinsoo Park +Jiri Popelka +Jiří Župka +jjy +jmzwcn +Joe Beda +Joe Doliner +Joe Ferguson +Joe Gordon +Joe Shaw +Joe Van Dyk +Joel Friedly +Joel Handwell +Joel Hansson +Joel Wurtz +Joey Geiger +Joey Gibson +Joffrey F +Johan Euphrosine +Johan Rydberg +Johannes 'fish' Ziemke +John Costa +John Feminella +John Gardiner Myers +John Gossman +John Howard (VM) +John OBrien III +John Starks +John Tims +John Warwick +John Willis +Jon Wedaman +Jonas Pfenniger +Jonathan A. Sternberg +Jonathan Boulle +Jonathan Camp +Jonathan Dowland +Jonathan Lebon +Jonathan McCrohan +Jonathan Mueller +Jonathan Pares +Jonathan Rudenberg +Joost Cassee +Jordan +Jordan Arentsen +Jordan Sissel +Jose Diaz-Gonzalez +Joseph Anthony Pasquale Holsten +Joseph Hager +Joseph Kern +Josh +Josh Hawn +Josh Poimboeuf +Josiah Kiehl +José Tomás Albornoz +JP +jrabbit +Julian Taylor +Julien Barbier +Julien Bisconti +Julien Bordellier +Julien Dubois +Julien Pervillé +Jun-Ru Chang +Jussi Nummelin +Justas Brazauskas +Justin Cormack +Justin Force +Justin Plock +Justin Simonelis +Jyrki Puttonen +Jérôme Petazzoni +Jörg Thalheim +Kai Blin +Kai Qiang Wu(Kennan) +Kamil Domański +Kanstantsin Shautsou +Karan Lyons +Kareem Khazem +kargakis +Karl Grzeszczak +Karol Duleba +Katie McLaughlin +Kato Kazuyoshi +Katrina Owen +Kawsar Saiyeed +kayrus +Keli Hu +Ken Cochrane +Ken ICHIKAWA +Kenfe-Mickael Laventure +Kenjiro Nakayama +Kent Johnson +Kevin "qwazerty" Houdebert +Kevin Clark +Kevin J. Lynagh +Kevin Menard +Kevin P. Kucharczyk +Kevin Shi +Kevin Wallace +Kevin Yap +Keyvan Fatehi +kies +Kim BKC Carlbacker +Kim Eik +Kimbro Staken +Kir Kolyshkin +Kiran Gangadharan +Kirill SIbirev +knappe +Kohei Tsuruta +Koichi Shiraishi +Konrad Kleine +Konstantin Pelykh +Krasimir Georgiev +Kristian Haugene +Kristina Zabunova +krrg +Kun Zhang +Kunal Kushwaha +Kyle Conroy +kyu +Lachlan Coote +Lai Jiangshan +Lajos Papp +Lakshan Perera +Lalatendu Mohanty +lalyos +Lance Chen +Lance Kinley +Lars Kellogg-Stedman +Lars R. Damerow +Laszlo Meszaros +Laurent Erignoux +Laurie Voss +Leandro Siqueira +Lee, Meng-Han +leeplay +Lei Jitang +Len Weincier +Lennie +Leszek Kowalski +Levi Blackstone +Levi Gross +Lewis Marshall +Lewis Peckover +Liana Lo +Liang Mingqiang +Liang-Chi Hsieh +liaoqingwei +limsy +Linus Heckemann +Liran Tal +Liron Levin +Liu Bo +Liu Hua +LIZAO LI +Lloyd Dewolf +Lokesh Mandvekar +longliqiang88 <394564827@qq.com> +Lorenz Leutgeb +Lorenzo Fontana +Louis Opter +Luca Marturana +Luca Orlandi +Luca-Bogdan Grigorescu +Lucas Chan +Luis Martínez de Bartolomé Izquierdo +Lukas Waslowski +lukaspustina +lukemarsden +Lynda O'Leary +Lénaïc Huard +Ma Shimiao +Mabin +Madhav Puri +Madhu Venugopal +Mageee <21521230.zju.edu.cn> +Mahesh Tiyyagura +malnick +Malte Janduda +manchoz +Manfred Touron +Manfred Zabarauskas +Manuel Meurer +Manuel Woelker +mapk0y +Marc Abramowitz +Marc Kuo +Marc Tamsky +Marcelo Salazar +Marco Hennings +Marcus Farkas +Marcus Linke +Marcus Ramberg +Marek Goldmann +Marian Marinov +Marianna Tessel +Mario Loriedo +Marius Gundersen +Marius Sturm +Marius Voila +Mark Allen +Mark McGranaghan +Mark McKinstry +Mark West +Marko Mikulicic +Marko Tibold +Markus Fix +Martijn Dwars +Martijn van Oosterhout +Martin Honermeyer +Martin Kelly +Martin Mosegaard Amdisen +Martin Redmond +Mary Anthony +Masahito Zembutsu +Mason Malone +Mateusz Sulima +Mathias Monnerville +Mathieu Le Marec - Pasquet +Matt Apperson +Matt Bachmann +Matt Bentley +Matt Haggard +Matt McCormick +Matt Moore +Matt Robenolt +Matthew Heon +Matthew Mayer +Matthew Mueller +Matthew Riley +Matthias Klumpp +Matthias Kühnle +Matthias Rampke +Matthieu Hauglustaine +mattymo +mattyw +Mauricio Garavaglia +mauriyouth +Max Shytikov +Maxim Ivanov +Maxim Kulkin +Maxim Treskin +Maxime Petazzoni +Meaglith Ma +meejah +Megan Kostick +Mehul Kar +Mengdi Gao +Mert Yazıcıoğlu +Micah Zoltu +Michael A. Smith +Michael Bridgen +Michael Brown +Michael Chiang +Michael Crosby +Michael Currie +Michael Gorsuch +Michael Grauer +Michael Hudson-Doyle +Michael Huettermann +Michael Käufl +Michael Neale +Michael Prokop +Michael Scharf +Michael Stapelberg +Michael Steinert +Michael Thies +Michael West +Michal Fojtik +Michal Gebauer +Michal Jemala +Michal Minar +Michaël Pailloncy +Michał Czeraszkiewicz +Michiel@unhosted +Miguel Angel Fernández +Miguel Morales +Mihai Borobocea +Mihuleacc Sergiu +Mike Brown +Mike Chelen +Mike Danese +Mike Dillon +Mike Dougherty +Mike Gaffney +Mike Goelzer +Mike Leone +Mike MacCana +Mike Naberezny +Mike Snitzer +Mikhail Sobolev +Miloslav Trmač +mingqing +Mingzhen Feng +Mitch Capper +mlarcher +Mohammad Banikazemi +Mohammed Aaqib Ansari +Mohit Soni +Morgan Bauer +Morgante Pell +Morgy93 +Morten Siebuhr +Morton Fox +Moysés Borges +mqliang +Mrunal Patel +msabansal +mschurenko +Mustafa Akın +Muthukumar R +Médi-Rémi Hashim +Nakul Pathak +Nalin Dahyabhai +Nan Monnand Deng +Naoki Orii +Natalie Parker +Nate Brennand +Nate Eagleson +Nate Jones +Nathan Hsieh +Nathan Kleyn +Nathan LeClaire +Nathan McCauley +Nathan Williams +Neal McBurnett +Nelson Chen +Nghia Tran +Niall O'Higgins +Nicholas E. Rabenau +Nick Irvine +Nick Parker +Nick Payne +Nick Stenning +Nick Stinemates +Nicolas Borboën +Nicolas De loof +Nicolas Dudebout +Nicolas Goy +Nicolas Kaiser +Nicolás Hock Isaza +Nigel Poulton +NikolaMandic +nikolas +Nishant Totla +NIWA Hideyuki +noducks +Nolan Darilek +nponeccop +Nuutti Kotivuori +nzwsch +O.S. Tezer +OddBloke +odk- +Oguz Bilgic +Oh Jinkyun +Ohad Schneider +Ole Reifschneider +Oliver Neal +Olivier Gambier +Olle Jonsson +Oriol Francès +Otto Kekäläinen +oyld +ozlerhakan +paetling +pandrew +panticz +Paolo G. Giarrusso +Pascal Borreli +Pascal Hartig +Patrick Devine +Patrick Hemmer +Patrick Stapleton +pattichen +Paul +paul +Paul Annesley +Paul Bellamy +Paul Bowsher +Paul Hammond +Paul Jimenez +Paul Lietar +Paul Liljenberg +Paul Morie +Paul Nasrat +Paul Weaver +Pavel Lobashov +Pavel Pospisil +Pavel Sutyrin +Pavel Tikhomirov +Pavlos Ratis +Peeyush Gupta +Peggy Li +Pei Su +Penghan Wang +perhapszzy@sina.com +Peter Bourgon +Peter Braden +Peter Choi +Peter Dave Hello +Peter Edge +Peter Ericson +Peter Esbensen +Peter Malmgren +Peter Salvatore +Peter Volpe +Peter Waller +Phil +Phil Estes +Phil Spitler +Philip Monroe +Philipp Wahala +Philipp Weissensteiner +Phillip Alexander +pidster +Piergiuliano Bossi +Pierre +Pierre Carrier +Pierre Wacrenier +Pierre-Alain RIVIERE +Piotr Bogdan +pixelistik +Porjo +Poul Kjeldager Sørensen +Pradeep Chhetri +Prasanna Gautam +Prayag Verma +Przemek Hejman +pysqz +qg <1373319223@qq.com> +qhuang +Qiang Huang +qq690388648 <690388648@qq.com> +Quentin Brossard +Quentin Perez +Quentin Tayssier +r0n22 +Rafal Jeczalik +Rafe Colton +Raghavendra K T +Raghuram Devarakonda +Rajat Pandit +Rajdeep Dua +Ralle +Ralph Bean +Ramkumar Ramachandra +Ramon van Alteren +Ray Tsang +ReadmeCritic +Recursive Madman +Regan McCooey +Remi Rampin +Renato Riccieri Santos Zannon +resouer +rgstephens +Rhys Hiltner +Rich Seymour +Richard +Richard Burnison +Richard Harvey +Richard Metzler +Richard Scothern +Richo Healey +Rick Bradley +Rick van de Loo +Rick Wieman +Rik Nijessen +Riku Voipio +Riley Guerin +Riyaz Faizullabhoy +Rob Vesse +Robert Bachmann +Robert Bittle +Robert Obryk +Robert Stern +Robert Wallis +Roberto G. Hashioka +Robin Naundorf +Robin Schneider +Robin Speekenbrink +robpc +Rodrigo Vaz +Roel Van Nyen +Roger Peppe +Rohit Jnagal +Rohit Kadam +Roland Huß +Roland Moriz +Roma Sokolov +Roman Strashkin +Ron Smits +root +root +root +Rory Hunter +Rory McCune +Ross Boucher +Rovanion Luckey +Rozhnov Alexandr +rsmoorthy +Rudolph Gottesheim +Rui Lopes +Ryan Anderson +Ryan Aslett +Ryan Belgrave +Ryan Detzel +Ryan Fowler +Ryan McLaughlin +Ryan O'Donnell +Ryan Seto +Ryan Thomas +Ryan Trauntvein +Ryan Wallner +RyanDeng +Rémy Greinhofer +s. rannou +s00318865 +Sabin Basyal +Sachin Joshi +Sagar Hani +Sally O'Malley +Sam Abed +Sam Alba +Sam Bailey +Sam J Sharpe +Sam Neirinck +Sam Reis +Sam Rijs +Sambuddha Basu +Sami Wagiaalla +Samuel Andaya +Samuel Dion-Girardeau +Samuel Karp +Samuel PHAN +Sankar சங்கர் +Sanket Saurav +Santhosh Manohar +sapphiredev +Satnam Singh +satoru +Satoshi Amemiya +scaleoutsean +Scott Bessler +Scott Collier +Scott Johnston +Scott Stamp +Scott Walls +sdreyesg +Sean Cronin +Sean OMeara +Sean P. Kane +Sebastiaan van Steenis +Sebastiaan van Stijn +Senthil Kumar Selvaraj +SeongJae Park +Seongyeol Lim +Sergey Alekseev +Sergey Evstifeev +Sevki Hasirci +Shane Canon +Shane da Silva +shaunol +Shawn Landden +Shawn Siefkas +Shekhar Gulati +Sheng Yang +Shih-Yuan Lee +Shijiang Wei +Shishir Mahajan +shuai-z +Shuwei Hao +Sian Lerk Lau +sidharthamani +Silas Sewell +Simei He +Simon Eskildsen +Simon Leinen +Simon Taranto +Sindhu S +Sjoerd Langkemper +Solganik Alexander +Solomon Hykes +Song Gao +Soshi Katsuta +Soulou +Spencer Brown +Spencer Smith +Sridatta Thatipamala +Sridhar Ratnakumar +Srini Brahmaroutu +Srini Brahmaroutu +Steeve Morin +Stefan Berger +Stefan J. Wernli +Stefan Praszalowicz +Stefan Scherer +Stefan Staudenmeyer +Stefan Weil +Stephen Crosby +Stephen Day +Stephen Rust +Steve Durrheimer +Steve Francia +Steve Koch +Steven Burgess +Steven Iveson +Steven Merrill +Steven Richards +Steven Taylor +Sujith Haridasan +Suryakumar Sudar +Sven Dowideit +Swapnil Daingade +Sylvain Baubeau +Sylvain Bellemare +Sébastien +Sébastien Luttringer +Sébastien Stormacq +TAGOMORI Satoshi +tang0th +Tangi COLIN +Tatsuki Sugiura +Tatsushi Inagaki +Taylor Jones +tbonza +Ted M. Young +Tehmasp Chaudhri +Tejesh Mehta +terryding77 <550147740@qq.com> +tgic +Thatcher Peskens +theadactyl +Thell 'Bo' Fowler +Thermionix +Thijs Terlouw +Thomas Bikeev +Thomas Frössman +Thomas Gazagnaire +Thomas Hansen +Thomas LEVEIL +Thomas Orozco +Thomas Schroeter +Thomas Sjögren +Thomas Swift +Thomas Texier +Tianon Gravi +Tibor Vass +Tiffany Low +Tim Bosse +Tim Dettrick +Tim Hockin +Tim Ruffles +Tim Smith +Tim Terhorst +Tim Wang +Tim Waugh +Tim Wraight +Timothy Hobbs +tjwebb123 +tobe +Tobias Bieniek +Tobias Bradtke +Tobias Gesellchen +Tobias Klauser +Tobias Schmidt +Tobias Schwab +Todd Crane +Todd Lunter +Todd Whiteman +Toli Kuznets +Tom Barlow +Tom Denham +Tom Fotherby +Tom Howe +Tom Hulihan +Tom Maaswinkel +Tom X. Tobin +Tomas Tomecek +Tomasz Kopczynski +Tomasz Lipinski +Tomasz Nurkiewicz +Tommaso Visconti +Tomáš Hrčka +Tonis Tiigi +Tonny Xu +Tony Daws +Tony Miller +toogley +Torstein Husebø +tpng +tracylihui <793912329@qq.com> +Travis Cline +Travis Thieman +Trent Ogren +Trevor +Trevor Pounds +trishnaguha +Tristan Carel +Troy Denton +Tyler Brock +Tzu-Jung Lee +Tõnis Tiigi +Ulysse Carion +unknown +vagrant +Vaidas Jablonskis +Veres Lajos +vgeta +Victor Coisne +Victor Costan +Victor I. Wood +Victor Lyuboslavsky +Victor Marmol +Victor Palma +Victor Vieux +Victoria Bialas +Vijaya Kumar K +Viktor Stanchev +Viktor Vojnovski +VinayRaghavanKS +Vincent Batts +Vincent Bernat +Vincent Bernat +Vincent Demeester +Vincent Giersch +Vincent Mayers +Vincent Woo +Vinod Kulkarni +Vishal Doshi +Vishnu Kannan +Vitor Monteiro +Vivek Agarwal +Vivek Dasgupta +Vivek Goyal +Vladimir Bulyga +Vladimir Kirillov +Vladimir Rutsky +Vladimir Varankin +VladimirAus +Vojtech Vitek (V-Teq) +waitingkuo +Walter Leibbrandt +Walter Stanish +WANG Chao +Ward Vandewege +WarheadsSE +Wayne Chang +Wei-Ting Kuo +weiyan +Weiyang Zhu +Wen Cheng Ma +Wenxuan Zhao +Wenyu You <21551128@zju.edu.cn> +Wes Morgan +Will Dietz +Will Rouesnel +Will Weaver +willhf +William Delanoue +William Henry +William Hubbs +William Riancho +William Thurston +WiseTrem +wlan0 +Wolfgang Powisch +wonderflow +xamyzhao +XiaoBing Jiang +Xiaoxu Chen +xiekeyang +Xinzi Zhou +Xiuming Chen +xlgao-zju +xuzhaokui +Yahya +YAMADA Tsuyoshi +Yan Feng +Yang Bai +yangshukui +Yasunori Mahata +Yestin Sun +Yi EungJun +Yibai Zhang +Yihang Ho +Ying Li +Yohei Ueda +Yong Tang +Yongzhi Pan +Youcef YEKHLEF +Yuan Sun +yuchangchun +yuchengxia +Yurii Rashkovskii +yuzou +Zac Dover +Zach Borboa +Zachary Jaffee +Zain Memon +Zaiste! +Zane DeGraffenried +Zefan Li +Zen Lin(Zhinan Lin) +Zhang Kun +Zhang Wei +Zhang Wentao +Zhenan Ye <21551168@zju.edu.cn> +Zhu Guihua +Zhuoyun Wei +Zilin Du +zimbatm +Ziming Dong +ZJUshuaizhou <21551191@zju.edu.cn> +zmarouf +Zoltan Tombol +zqh +Zuhayr Elahi +Álex González +Álvaro Lázaro +Átila Camurça Alves +尹吉峰 diff --git a/vendor/github.com/docker/docker/CHANGELOG.md b/vendor/github.com/docker/docker/CHANGELOG.md new file mode 100644 index 00000000..49068a40 --- /dev/null +++ b/vendor/github.com/docker/docker/CHANGELOG.md @@ -0,0 +1,2415 @@ +# Changelog + +Items starting with `DEPRECATE` are important deprecation notices. For more +information on the list of deprecated flags and APIs please have a look at +https://docs.docker.com/engine/deprecated/ where target removal dates can also +be found. + +## 1.11.1 (2016-04-26) + +### Distribution + +- Fix schema2 manifest media type to be of type `application/vnd.docker.container.image.v1+json` ([#21949](https://github.com/docker/docker/pull/21949)) + +### Documentation + ++ Add missing API documentation for changes introduced with 1.11.0 ([#22048](https://github.com/docker/docker/pull/22048)) + +### Builder + +* Append label passed to `docker build` as arguments as an implicit `LABEL` command at the end of the processed `Dockerfile` ([#22184](https://github.com/docker/docker/pull/22184)) + +### Networking + +- Fix a panic that would occur when forwarding DNS query ([#22261](https://github.com/docker/docker/pull/22261)) +- Fix an issue where OS threads could end up within an incorrect network namespace when using user defined networks ([#22261](https://github.com/docker/docker/pull/22261)) + +### Runtime + +- Fix a bug preventing labels configuration to be reloaded via the config file ([#22299](https://github.com/docker/docker/pull/22299)) +- Fix a regression where container mounting `/var/run` would prevent other containers from being removed ([#22256](https://github.com/docker/docker/pull/22256)) +- Fix an issue where it would be impossible to update both `memory-swap` and `memory` value together ([#22255](https://github.com/docker/docker/pull/22255)) +- Fix a regression from 1.11.0 where the `/auth` endpoint would not initialize `serveraddress` if it is not provided ([#22254](https://github.com/docker/docker/pull/22254)) +- Add missing cleanup of container temporary files when cancelling a schedule restart ([#22237](https://github.com/docker/docker/pull/22237)) +- Removed scary error message when no restart policy is specified ([#21993](https://github.com/docker/docker/pull/21993)) +- Fix a panic that would occur when the plugins were activated via the json spec ([#22191](https://github.com/docker/docker/pull/22191)) +- Fix restart backoff logic to correctly reset delay if container ran for at least 10secs ([#22125](https://github.com/docker/docker/pull/22125)) +- Remove error message when a container restart get cancelled ([#22123](https://github.com/docker/docker/pull/22123)) +- Fix an issue where `docker` would not correcly clean up after `docker exec` ([#22121](https://github.com/docker/docker/pull/22121)) +- Fix a panic that could occur when servicing concurrent `docker stats` commands ([#22120](https://github.com/docker/docker/pull/22120))` +- Revert deprecation of non-existing host directories auto-creation ([#22065](https://github.com/docker/docker/pull/22065)) +- Hide misleading rpc error on daemon shutdown ([#22058](https://github.com/docker/docker/pull/22058)) + +## 1.11.0 (2016-04-13) + +**IMPORTANT**: With Docker 1.11, a Linux docker installation is now made of 4 binaries (`docker`, [`docker-containerd`](https://github.com/docker/containerd), [`docker-containerd-shim`](https://github.com/docker/containerd) and [`docker-runc`](https://github.com/opencontainers/runc)). If you have scripts relying on docker being a single static binaries, please make sure to update them. Interaction with the daemon stay the same otherwise, the usage of the other binaries should be transparent. A Windows docker installation remains a single binary, `docker.exe`. + +### Builder + +- Fix a bug where Docker would not used the correct uid/gid when processing the `WORKDIR` command ([#21033](https://github.com/docker/docker/pull/21033)) +- Fix a bug where copy operations with userns would not use the proper uid/gid ([#20782](https://github.com/docker/docker/pull/20782), [#21162](https://github.com/docker/docker/pull/21162)) + +### Client + +* Usage of the `:` separator for security option has been deprecated. `=` should be used instead ([#21232](https://github.com/docker/docker/pull/21232)) ++ The client user agent is now passed to the registry on `pull`, `build`, `push`, `login` and `search` operations ([#21306](https://github.com/docker/docker/pull/21306), [#21373](https://github.com/docker/docker/pull/21373)) +* Allow setting the Domainname and Hostname separately through the API ([#20200](https://github.com/docker/docker/pull/20200)) +* Docker info will now warn users if it can not detect the kernel version or the operating system ([#21128](https://github.com/docker/docker/pull/21128)) +- Fix an issue where `docker stats --no-stream` output could be all 0s ([#20803](https://github.com/docker/docker/pull/20803)) +- Fix a bug where some newly started container would not appear in a running `docker stats` command ([#20792](https://github.com/docker/docker/pull/20792)) +* Post processing is no longer enabled for linux-cgo terminals ([#20587](https://github.com/docker/docker/pull/20587)) +- Values to `--hostname` are now refused if they do not comply with [RFC1123](https://tools.ietf.org/html/rfc1123) ([#20566](https://github.com/docker/docker/pull/20566)) ++ Docker learned how to use a SOCKS proxy ([#20366](https://github.com/docker/docker/pull/20366), [#18373](https://github.com/docker/docker/pull/18373)) ++ Docker now supports external credential stores ([#20107](https://github.com/docker/docker/pull/20107)) +* `docker ps` now supports displaying the list of volumes mounted inside a container ([#20017](https://github.com/docker/docker/pull/20017)) +* `docker info` now also report Docker's root directory location ([#19986](https://github.com/docker/docker/pull/19986)) +- Docker now prohibits login in with an empty username (spaces are trimmed) ([#19806](https://github.com/docker/docker/pull/19806)) +* Docker events attributes are now sorted by key ([#19761](https://github.com/docker/docker/pull/19761)) +* `docker ps` no longer show exported port for stopped containers ([#19483](https://github.com/docker/docker/pull/19483)) +- Docker now cleans after itself if a save/export command fails ([#17849](https://github.com/docker/docker/pull/17849)) +* Docker load learned how to display a progress bar ([#17329](https://github.com/docker/docker/pull/17329), [#120078](https://github.com/docker/docker/pull/20078)) + +### Distribution + +- Fix a panic that occurred when pulling an images with 0 layers ([#21222](https://github.com/docker/docker/pull/21222)) +- Fix a panic that could occur on error while pushing to a registry with a misconfigured token service ([#21212](https://github.com/docker/docker/pull/21212)) ++ All first-level delegation roles are now signed when doing a trusted push ([#21046](https://github.com/docker/docker/pull/21046)) ++ OAuth support for registries was added ([#20970](https://github.com/docker/docker/pull/20970)) +* `docker login` now handles token using the implementation found in [docker/distribution](https://github.com/docker/distribution) ([#20832](https://github.com/docker/docker/pull/20832)) +* `docker login` will no longer prompt for an email ([#20565](https://github.com/docker/docker/pull/20565)) +* Docker will now fallback to registry V1 if no basic auth credentials are available ([#20241](https://github.com/docker/docker/pull/20241)) +* Docker will now try to resume layer download where it left off after a network error/timeout ([#19840](https://github.com/docker/docker/pull/19840)) +- Fix generated manifest mediaType when pushing cross-repository ([#19509](https://github.com/docker/docker/pull/19509)) +- Fix docker requesting additional push credentials when pulling an image if Content Trust is enabled ([#20382](https://github.com/docker/docker/pull/20382)) + +### Logging + +- Fix a race in the journald log driver ([#21311](https://github.com/docker/docker/pull/21311)) +* Docker syslog driver now uses the RFC-5424 format when emitting logs ([#20121](https://github.com/docker/docker/pull/20121)) +* Docker GELF log driver now allows to specify the compression algorithm and level via the `gelf-compression-type` and `gelf-compression-level` options ([#19831](https://github.com/docker/docker/pull/19831)) +* Docker daemon learned to output uncolorized logs via the `--raw-logs` options ([#19794](https://github.com/docker/docker/pull/19794)) ++ Docker, on Windows platform, now includes an ETW (Event Tracing in Windows) logging driver named `etwlogs` ([#19689](https://github.com/docker/docker/pull/19689)) +* Journald log driver learned how to handle tags ([#19564](https://github.com/docker/docker/pull/19564)) ++ The fluentd log driver learned the following options: `fluentd-address`, `fluentd-buffer-limit`, `fluentd-retry-wait`, `fluentd-max-retries` and `fluentd-async-connect` ([#19439](https://github.com/docker/docker/pull/19439)) ++ Docker learned to send log to Google Cloud via the new `gcplogs` logging driver. ([#18766](https://github.com/docker/docker/pull/18766)) + + +### Misc + ++ When saving linked images together with `docker save` a subsequent `docker load` will correctly restore their parent/child relationship ([#21385](https://github.com/docker/docker/pull/c)) ++ Support for building the Docker cli for OpenBSD was added ([#21325](https://github.com/docker/docker/pull/21325)) ++ Labels can now be applied at network, volume and image creation ([#21270](https://github.com/docker/docker/pull/21270)) +* The `dockremap` is now created as a system user ([#21266](https://github.com/docker/docker/pull/21266)) +- Fix a few response body leaks ([#21258](https://github.com/docker/docker/pull/21258)) +- Docker, when run as a service with systemd, will now properly manage its processes cgroups ([#20633](https://github.com/docker/docker/pull/20633)) +* Docker info now reports the value of cgroup KernelMemory or emits a warning if it is not supported ([#20863](https://github.com/docker/docker/pull/20863)) +* Docker info now also reports the cgroup driver in use ([#20388](https://github.com/docker/docker/pull/20388)) +* Docker completion is now available on PowerShell ([#19894](https://github.com/docker/docker/pull/19894)) +* `dockerinit` is no more ([#19490](https://github.com/docker/docker/pull/19490),[#19851](https://github.com/docker/docker/pull/19851)) ++ Support for building Docker on arm64 was added ([#19013](https://github.com/docker/docker/pull/19013)) ++ Experimental support for building docker.exe in a native Windows Docker installation ([#18348](https://github.com/docker/docker/pull/18348)) + +### Networking + +- Fix panic if a node is forcibly removed from the cluster ([#21671](https://github.com/docker/docker/pull/21671)) +- Fix "error creating vxlan interface" when starting a container in a Swarm cluster ([#21671](https://github.com/docker/docker/pull/21671)) +* `docker network inspect` will now report all endpoints whether they have an active container or not ([#21160](https://github.com/docker/docker/pull/21160)) ++ Experimental support for the MacVlan and IPVlan network drivers have been added ([#21122](https://github.com/docker/docker/pull/21122)) +* Output of `docker network ls` is now sorted by network name ([#20383](https://github.com/docker/docker/pull/20383)) +- Fix a bug where Docker would allow a network to be created with the reserved `default` name ([#19431](https://github.com/docker/docker/pull/19431)) +* `docker network inspect` returns whether a network is internal or not ([#19357](https://github.com/docker/docker/pull/19357)) ++ Control IPv6 via explicit option when creating a network (`docker network create --ipv6`). This shows up as a new `EnableIPv6` field in `docker network inspect` ([#17513](https://github.com/docker/docker/pull/17513)) +* Support for AAAA Records (aka IPv6 Service Discovery) in embedded DNS Server ([#21396](https://github.com/docker/docker/pull/21396)) +- Fix to not forward docker domain IPv6 queries to external servers ([#21396](https://github.com/docker/docker/pull/21396)) +* Multiple A/AAAA records from embedded DNS Server for DNS Round robin ([#21019](https://github.com/docker/docker/pull/21019)) +- Fix endpoint count inconsistency after an ungraceful dameon restart ([#21261](https://github.com/docker/docker/pull/21261)) +- Move the ownership of exposed ports and port-mapping options from Endpoint to Sandbox ([#21019](https://github.com/docker/docker/pull/21019)) +- Fixed a bug which prevents docker reload when host is configured with ipv6.disable=1 ([#21019](https://github.com/docker/docker/pull/21019)) +- Added inbuilt nil IPAM driver ([#21019](https://github.com/docker/docker/pull/21019)) +- Fixed bug in iptables.Exists() logic [#21019](https://github.com/docker/docker/pull/21019) +- Fixed a Veth interface leak when using overlay network ([#21019](https://github.com/docker/docker/pull/21019)) +- Fixed a bug which prevents docker reload after a network delete during shutdown ([#20214](https://github.com/docker/docker/pull/20214)) +- Make sure iptables chains are recreated on firewalld reload ([#20419](https://github.com/docker/docker/pull/20419)) +- Allow to pass global datastore during config reload ([#20419](https://github.com/docker/docker/pull/20419)) +- For anonymous containers use the alias name for IP to name mapping, ie:DNS PTR record ([#21019](https://github.com/docker/docker/pull/21019)) +- Fix a panic when deleting an entry from /etc/hosts file ([#21019](https://github.com/docker/docker/pull/21019)) +- Source the forwarded DNS queries from the container net namespace ([#21019](https://github.com/docker/docker/pull/21019)) +- Fix to retain the network internal mode config for bridge networks on daemon reload ([#21780] (https://github.com/docker/docker/pull/21780)) +- Fix to retain IPAM driver option configs on daemon reload ([#21914] (https://github.com/docker/docker/pull/21914)) + +### Plugins + +- Fix a file descriptor leak that would occur every time plugins were enumerated ([#20686](https://github.com/docker/docker/pull/20686)) +- Fix an issue where Authz plugin would corrupt the payload body when faced with a large amount of data ([#20602](https://github.com/docker/docker/pull/20602)) + +### Runtime + +- Fix a panic that could occur when cleanup after a container started with invalid parameters ([#21716](https://github.com/docker/docker/pull/21716)) +- Fix a race with event timers stopping early ([#21692](https://github.com/docker/docker/pull/21692)) +- Fix race conditions in the layer store, potentially corrupting the map and crashing the process ([#21677](https://github.com/docker/docker/pull/21677)) +- Un-deprecate auto-creation of host directories for mounts. This feature was marked deprecated in ([#21666](https://github.com/docker/docker/pull/21666)) + Docker 1.9, but was decided to be too much of an backward-incompatible change, so it was decided to keep the feature. ++ It is now possible for containers to share the NET and IPC namespaces when `userns` is enabled ([#21383](https://github.com/docker/docker/pull/21383)) ++ `docker inspect ` will now expose the rootfs layers ([#21370](https://github.com/docker/docker/pull/21370)) ++ Docker Windows gained a minimal `top` implementation ([#21354](https://github.com/docker/docker/pull/21354)) +* Docker learned to report the faulty exe when a container cannot be started due to its condition ([#21345](https://github.com/docker/docker/pull/21345)) +* Docker with device mapper will now refuse to run if `udev sync` is not available ([#21097](https://github.com/docker/docker/pull/21097)) +- Fix a bug where Docker would not validate the config file upon configuration reload ([#21089](https://github.com/docker/docker/pull/21089)) +- Fix a hang that would happen on attach if initial start was to fail ([#21048](https://github.com/docker/docker/pull/21048)) +- Fix an issue where registry service options in the daemon configuration file were not properly taken into account ([#21045](https://github.com/docker/docker/pull/21045)) +- Fix a race between the exec and resize operations ([#21022](https://github.com/docker/docker/pull/21022)) +- Fix an issue where nanoseconds were not correctly taken in account when filtering Docker events ([#21013](https://github.com/docker/docker/pull/21013)) +- Fix the handling of Docker command when passed a 64 bytes id ([#21002](https://github.com/docker/docker/pull/21002)) +* Docker will now return a `204` (i.e http.StatusNoContent) code when it successfully deleted a network ([#20977](https://github.com/docker/docker/pull/20977)) +- Fix a bug where the daemon would wait indefinitely in case the process it was about to killed had already exited on its own ([#20967](https://github.com/docker/docker/pull/20967) +* The devmapper driver learned the `dm.min_free_space` option. If the mapped device free space reaches the passed value, new device creation will be prohibited. ([#20786](https://github.com/docker/docker/pull/20786)) ++ Docker can now prevent processes in container to gain new privileges via the `--security-opt=no-new-privileges` flag ([#20727](https://github.com/docker/docker/pull/20727)) +- Starting a container with the `--device` option will now correctly resolves symlinks ([#20684](https://github.com/docker/docker/pull/20684)) ++ Docker now relies on [`containerd`](https://github.com/docker/containerd) and [`runc`](https://github.com/opencontainers/runc) to spawn containers. ([#20662](https://github.com/docker/docker/pull/20662)) +- Fix docker configuration reloading to only alter value present in the given config file ([#20604](https://github.com/docker/docker/pull/20604)) ++ Docker now allows setting a container hostname via the `--hostname` flag when `--net=host` ([#20177](https://github.com/docker/docker/pull/20177)) ++ Docker now allows executing privileged container while running with `--userns-remap` if both `--privileged` and the new `--userns=host` flag are specified ([#20111](https://github.com/docker/docker/pull/20111)) +- Fix Docker not cleaning up correctly old containers upon restarting after a crash ([#19679](https://github.com/docker/docker/pull/19679)) +* Docker will now error out if it doesn't recognize a configuration key within the config file ([#19517](https://github.com/docker/docker/pull/19517)) +- Fix container loading, on daemon startup, when they depends on a plugin running within a container ([#19500](https://github.com/docker/docker/pull/19500)) +* `docker update` learned how to change a container restart policy ([#19116](https://github.com/docker/docker/pull/19116)) +* `docker inspect` now also returns a new `State` field containing the container state in a human readable way (i.e. one of `created`, `restarting`, `running`, `paused`, `exited` or `dead`)([#18966](https://github.com/docker/docker/pull/18966)) ++ Docker learned to limit the number of active pids (i.e. processes) within the container via the `pids-limit` flags. NOTE: This requires `CGROUP_PIDS=y` to be in the kernel configuration. ([#18697](https://github.com/docker/docker/pull/18697)) +- `docker load` now has a `--quiet` option to suppress the load output ([#20078](https://github.com/docker/docker/pull/20078)) +- Fix a bug in neighbor discovery for IPv6 peers ([#20842](https://github.com/docker/docker/pull/20842)) +- Fix a panic during cleanup if a container was started with invalid options ([#21802](https://github.com/docker/docker/pull/21802)) +- Fix a situation where a container cannot be stopped if the terminal is closed ([#21840](https://github.com/docker/docker/pull/21840)) + +### Security + +* Object with the `pcp_pmcd_t` selinux type were given management access to `/var/lib/docker(/.*)?` ([#21370](https://github.com/docker/docker/pull/21370)) +* `restart_syscall`, `copy_file_range`, `mlock2` joined the list of allowed calls in the default seccomp profile ([#21117](https://github.com/docker/docker/pull/21117), [#21262](https://github.com/docker/docker/pull/21262)) +* `send`, `recv` and `x32` were added to the list of allowed syscalls and arch in the default seccomp profile ([#19432](https://github.com/docker/docker/pull/19432)) +* Docker Content Trust now requests the server to perform snapshot signing ([#21046](https://github.com/docker/docker/pull/21046)) +* Support for using YubiKeys for Content Trust signing has been moved out of experimental ([#21591](https://github.com/docker/docker/pull/21591)) + +### Volumes + +* Output of `docker volume ls` is now sorted by volume name ([#20389](https://github.com/docker/docker/pull/20389)) +* Local volumes can now accepts options similar to the unix `mount` tool ([#20262](https://github.com/docker/docker/pull/20262)) +- Fix an issue where one letter directory name could not be used as source for volumes ([#21106](https://github.com/docker/docker/pull/21106)) ++ `docker run -v` now accepts a new flag `nocopy`. This tell the runtime not to copy the container path content into the volume (which is the default behavior) ([#21223](https://github.com/docker/docker/pull/21223)) + +## 1.10.3 (2016-03-10) + +### Runtime + +- Fix Docker client exiting with an "Unrecognized input header" error [#20706](https://github.com/docker/docker/pull/20706) +- Fix Docker exiting if Exec is started with both `AttachStdin` and `Detach` [#20647](https://github.com/docker/docker/pull/20647) + +### Distribution + +- Fix a crash when pushing multiple images sharing the same layers to the same repository in parallel [#20831](https://github.com/docker/docker/pull/20831) +- Fix a panic when pushing images to a registry which uses a misconfigured token service [#21030](https://github.com/docker/docker/pull/21030) + +### Plugin system + +- Fix issue preventing volume plugins to start when SELinux is enabled [#20834](https://github.com/docker/docker/pull/20834) +- Prevent Docker from exiting if a volume plugin returns a null response for Get requests [#20682](https://github.com/docker/docker/pull/20682) +- Fix plugin system leaking file descriptors if a plugin has an error [#20680](https://github.com/docker/docker/pull/20680) + +### Security + +- Fix linux32 emulation to fail during docker build [#20672](https://github.com/docker/docker/pull/20672) + It was due to the `personality` syscall being blocked by the default seccomp profile. +- Fix Oracle XE 10g failing to start in a container [#20981](https://github.com/docker/docker/pull/20981) + It was due to the `ipc` syscall being blocked by the default seccomp profile. +- Fix user namespaces not working on Linux From Scratch [#20685](https://github.com/docker/docker/pull/20685) +- Fix issue preventing daemon to start if userns is enabled and the `subuid` or `subgid` files contain comments [#20725](https://github.com/docker/docker/pull/20725) + +## 1.10.2 (2016-02-22) + +### Runtime + +- Prevent systemd from deleting containers' cgroups when its configuration is reloaded [#20518](https://github.com/docker/docker/pull/20518) +- Fix SELinux issues by disregarding `--read-only` when mounting `/dev/mqueue` [#20333](https://github.com/docker/docker/pull/20333) +- Fix chown permissions used during `docker cp` when userns is used [#20446](https://github.com/docker/docker/pull/20446) +- Fix configuration loading issue with all booleans defaulting to `true` [#20471](https://github.com/docker/docker/pull/20471) +- Fix occasional panic with `docker logs -f` [#20522](https://github.com/docker/docker/pull/20522) + +### Distribution + +- Keep layer reference if deletion failed to avoid a badly inconsistent state [#20513](https://github.com/docker/docker/pull/20513) +- Handle gracefully a corner case when canceling migration [#20372](https://github.com/docker/docker/pull/20372) +- Fix docker import on compressed data [#20367](https://github.com/docker/docker/pull/20367) +- Fix tar-split files corruption during migration that later cause docker push and docker save to fail [#20458](https://github.com/docker/docker/pull/20458) + +### Networking + +- Fix daemon crash if embedded DNS is sent garbage [#20510](https://github.com/docker/docker/pull/20510) + +### Volumes + +- Fix issue with multiple volume references with same name [#20381](https://github.com/docker/docker/pull/20381) + +### Security + +- Fix potential cache corruption and delegation conflict issues [#20523](https://github.com/docker/docker/pull/20523) + +## 1.10.1 (2016-02-11) + +### Runtime + +* Do not stop daemon on migration hard failure [#20156](https://github.com/docker/docker/pull/20156) +- Fix various issues with migration to content-addressable images [#20058](https://github.com/docker/docker/pull/20058) +- Fix ZFS permission bug with user namespaces [#20045](https://github.com/docker/docker/pull/20045) +- Do not leak /dev/mqueue from the host to all containers, keep it container-specific [#19876](https://github.com/docker/docker/pull/19876) [#20133](https://github.com/docker/docker/pull/20133) +- Fix `docker ps --filter before=...` to not show stopped containers without providing `-a` flag [#20135](https://github.com/docker/docker/pull/20135) + +### Security + +- Fix issue preventing docker events to work properly with authorization plugin [#20002](https://github.com/docker/docker/pull/20002) + +### Distribution + +* Add additional verifications and prevent from uploading invalid data to registries [#20164](https://github.com/docker/docker/pull/20164) +- Fix regression preventing uppercase characters in image reference hostname [#20175](https://github.com/docker/docker/pull/20175) + +### Networking + +- Fix embedded DNS for user-defined networks in the presence of firewalld [#20060](https://github.com/docker/docker/pull/20060) +- Fix issue where removing a network during shutdown left Docker inoperable [#20181](https://github.com/docker/docker/issues/20181) [#20235](https://github.com/docker/docker/issues/20235) +- Embedded DNS is now able to return compressed results [#20181](https://github.com/docker/docker/issues/20181) +- Fix port-mapping issue with `userland-proxy=false` [#20181](https://github.com/docker/docker/issues/20181) + +### Logging + +- Fix bug where tcp+tls protocol would be rejected [#20109](https://github.com/docker/docker/pull/20109) + +### Volumes + +- Fix issue whereby older volume drivers would not receive volume options [#19983](https://github.com/docker/docker/pull/19983) + +### Misc + +- Remove TasksMax from Docker systemd service [#20167](https://github.com/docker/docker/pull/20167) + +## 1.10.0 (2016-02-04) + +**IMPORTANT**: Docker 1.10 uses a new content-addressable storage for images and layers. +A migration is performed the first time docker is run, and can take a significant amount of time depending on the number of images present. +Refer to this page on the wiki for more information: https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration +We also released a cool migration utility that enables you to perform the migration before updating to reduce downtime. +Engine 1.10 migrator can be found on Docker Hub: https://hub.docker.com/r/docker/v1.10-migrator/ + +### Runtime + ++ New `docker update` command that allows updating resource constraints on running containers [#15078](https://github.com/docker/docker/pull/15078) ++ Add `--tmpfs` flag to `docker run` to create a tmpfs mount in a container [#13587](https://github.com/docker/docker/pull/13587) ++ Add `--format` flag to `docker images` command [#17692](https://github.com/docker/docker/pull/17692) ++ Allow to set daemon configuration in a file and hot-reload it with the `SIGHUP` signal [#18587](https://github.com/docker/docker/pull/18587) ++ Updated docker events to include more meta-data and event types [#18888](https://github.com/docker/docker/pull/18888) + This change is backward compatible in the API, but not on the CLI. ++ Add `--blkio-weight-device` flag to `docker run` [#13959](https://github.com/docker/docker/pull/13959) ++ Add `--device-read-bps` and `--device-write-bps` flags to `docker run` [#14466](https://github.com/docker/docker/pull/14466) ++ Add `--device-read-iops` and `--device-write-iops` flags to `docker run` [#15879](https://github.com/docker/docker/pull/15879) ++ Add `--oom-score-adj` flag to `docker run` [#16277](https://github.com/docker/docker/pull/16277) ++ Add `--detach-keys` flag to `attach`, `run`, `start` and `exec` commands to override the default key sequence that detaches from a container [#15666](https://github.com/docker/docker/pull/15666) ++ Add `--shm-size` flag to `run`, `create` and `build` to set the size of `/dev/shm` [#16168](https://github.com/docker/docker/pull/16168) ++ Show the number of running, stopped, and paused containers in `docker info` [#19249](https://github.com/docker/docker/pull/19249) ++ Show the `OSType` and `Architecture` in `docker info` [#17478](https://github.com/docker/docker/pull/17478) ++ Add `--cgroup-parent` flag on `daemon` to set cgroup parent for all containers [#19062](https://github.com/docker/docker/pull/19062) ++ Add `-L` flag to docker cp to follow symlinks [#16613](https://github.com/docker/docker/pull/16613) ++ New `status=dead` filter for `docker ps` [#17908](https://github.com/docker/docker/pull/17908) +* Change `docker run` exit codes to distinguish between runtime and application errors [#14012](https://github.com/docker/docker/pull/14012) +* Enhance `docker events --since` and `--until` to support nanoseconds and timezones [#17495](https://github.com/docker/docker/pull/17495) +* Add `--all`/`-a` flag to `stats` to include both running and stopped containers [#16742](https://github.com/docker/docker/pull/16742) +* Change the default cgroup-driver to `cgroupfs` [#17704](https://github.com/docker/docker/pull/17704) +* Emit a "tag" event when tagging an image with `build -t` [#17115](https://github.com/docker/docker/pull/17115) +* Best effort for linked containers' start order when starting the daemon [#18208](https://github.com/docker/docker/pull/18208) +* Add ability to add multiple tags on `build` [#15780](https://github.com/docker/docker/pull/15780) +* Permit `OPTIONS` request against any url, thus fixing issue with CORS [#19569](https://github.com/docker/docker/pull/19569) +- Fix the `--quiet` flag on `docker build` to actually be quiet [#17428](https://github.com/docker/docker/pull/17428) +- Fix `docker images --filter dangling=false` to now show all non-dangling images [#19326](https://github.com/docker/docker/pull/19326) +- Fix race condition causing autorestart turning off on restart [#17629](https://github.com/docker/docker/pull/17629) +- Recognize GPFS filesystems [#19216](https://github.com/docker/docker/pull/19216) +- Fix obscure bug preventing to start containers [#19751](https://github.com/docker/docker/pull/19751) +- Forbid `exec` during container restart [#19722](https://github.com/docker/docker/pull/19722) +- devicemapper: Increasing `--storage-opt dm.basesize` will now increase the base device size on daemon restart [#19123](https://github.com/docker/docker/pull/19123) + +### Security + ++ Add `--userns-remap` flag to `daemon` to support user namespaces (previously in experimental) [#19187](https://github.com/docker/docker/pull/19187) ++ Add support for custom seccomp profiles in `--security-opt` [#17989](https://github.com/docker/docker/pull/17989) ++ Add default seccomp profile [#18780](https://github.com/docker/docker/pull/18780) ++ Add `--authorization-plugin` flag to `daemon` to customize ACLs [#15365](https://github.com/docker/docker/pull/15365) ++ Docker Content Trust now supports the ability to read and write user delegations [#18887](https://github.com/docker/docker/pull/18887) + This is an optional, opt-in feature that requires the explicit use of the Notary command-line utility in order to be enabled. + Enabling delegation support in a specific repository will break the ability of Docker 1.9 and 1.8 to pull from that repository, if content trust is enabled. +* Allow SELinux to run in a container when using the BTRFS storage driver [#16452](https://github.com/docker/docker/pull/16452) + +### Distribution + +* Use content-addressable storage for images and layers [#17924](https://github.com/docker/docker/pull/17924) + Note that a migration is performed the first time docker is run; it can take a significant amount of time depending on the number of images and containers present. + Images no longer depend on the parent chain but contain a list of layer references. + `docker load`/`docker save` tarballs now also contain content-addressable image configurations. + For more information: https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration +* Add support for the new [manifest format ("schema2")](https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md) [#18785](https://github.com/docker/docker/pull/18785) +* Lots of improvements for push and pull: performance++, retries on failed downloads, cancelling on client disconnect [#18353](https://github.com/docker/docker/pull/18353), [#18418](https://github.com/docker/docker/pull/18418), [#19109](https://github.com/docker/docker/pull/19109), [#18353](https://github.com/docker/docker/pull/18353) +* Limit v1 protocol fallbacks [#18590](https://github.com/docker/docker/pull/18590) +- Fix issue where docker could hang indefinitely waiting for a nonexistent process to pull an image [#19743](https://github.com/docker/docker/pull/19743) + +### Networking + ++ Use DNS-based discovery instead of `/etc/hosts` [#19198](https://github.com/docker/docker/pull/19198) ++ Support for network-scoped alias using `--net-alias` on `run` and `--alias` on `network connect` [#19242](https://github.com/docker/docker/pull/19242) ++ Add `--ip` and `--ip6` on `run` and `network connect` to support custom IP addresses for a container in a network [#19001](https://github.com/docker/docker/pull/19001) ++ Add `--ipam-opt` to `network create` for passing custom IPAM options [#17316](https://github.com/docker/docker/pull/17316) ++ Add `--internal` flag to `network create` to restrict external access to and from the network [#19276](https://github.com/docker/docker/pull/19276) ++ Add `kv.path` option to `--cluster-store-opt` [#19167](https://github.com/docker/docker/pull/19167) ++ Add `discovery.heartbeat` and `discovery.ttl` options to `--cluster-store-opt` to configure discovery TTL and heartbeat timer [#18204](https://github.com/docker/docker/pull/18204) ++ Add `--format` flag to `network inspect` [#17481](https://github.com/docker/docker/pull/17481) ++ Add `--link` to `network connect` to provide a container-local alias [#19229](https://github.com/docker/docker/pull/19229) ++ Support for Capability exchange with remote IPAM plugins [#18775](https://github.com/docker/docker/pull/18775) ++ Add `--force` to `network disconnect` to force container to be disconnected from network [#19317](https://github.com/docker/docker/pull/19317) +* Support for multi-host networking using built-in overlay driver for all engine supported kernels: 3.10+ [#18775](https://github.com/docker/docker/pull/18775) +* `--link` is now supported on `docker run` for containers in user-defined network [#19229](https://github.com/docker/docker/pull/19229) +* Enhance `docker network rm` to allow removing multiple networks [#17489](https://github.com/docker/docker/pull/17489) +* Include container names in `network inspect` [#17615](https://github.com/docker/docker/pull/17615) +* Include auto-generated subnets for user-defined networks in `network inspect` [#17316](https://github.com/docker/docker/pull/17316) +* Add `--filter` flag to `network ls` to hide predefined networks [#17782](https://github.com/docker/docker/pull/17782) +* Add support for network connect/disconnect to stopped containers [#18906](https://github.com/docker/docker/pull/18906) +* Add network ID to container inspect [#19323](https://github.com/docker/docker/pull/19323) +- Fix MTU issue where Docker would not start with two or more default routes [#18108](https://github.com/docker/docker/pull/18108) +- Fix duplicate IP address for containers [#18106](https://github.com/docker/docker/pull/18106) +- Fix issue preventing sometimes docker from creating the bridge network [#19338](https://github.com/docker/docker/pull/19338) +- Do not substitute 127.0.0.1 name server when using `--net=host` [#19573](https://github.com/docker/docker/pull/19573) + +### Logging + ++ New logging driver for Splunk [#16488](https://github.com/docker/docker/pull/16488) ++ Add support for syslog over TCP+TLS [#18998](https://github.com/docker/docker/pull/18998) +* Enhance `docker logs --since` and `--until` to support nanoseconds and time [#17495](https://github.com/docker/docker/pull/17495) +* Enhance AWS logs to auto-detect region [#16640](https://github.com/docker/docker/pull/16640) + +### Volumes + ++ Add support to set the mount propagation mode for a volume [#17034](https://github.com/docker/docker/pull/17034) +* Add `ls` and `inspect` endpoints to volume plugin API [#16534](https://github.com/docker/docker/pull/16534) + Existing plugins need to make use of these new APIs to satisfy users' expectation + For that, please use the new MIME type `application/vnd.docker.plugins.v1.2+json` [#19549](https://github.com/docker/docker/pull/19549) +- Fix data not being copied to named volumes [#19175](https://github.com/docker/docker/pull/19175) +- Fix issues preventing volume drivers from being containerized [#19500](https://github.com/docker/docker/pull/19500) +- Fix `docker volumes ls --dangling=false` to now show all non-dangling volumes [#19671](https://github.com/docker/docker/pull/19671) +- Do not remove named volumes on container removal [#19568](https://github.com/docker/docker/pull/19568) +- Allow external volume drivers to host anonymous volumes [#19190](https://github.com/docker/docker/pull/19190) + +### Builder + ++ Add support for `**` in `.dockerignore` to wildcard multiple levels of directories [#17090](https://github.com/docker/docker/pull/17090) +- Fix handling of UTF-8 characters in Dockerfiles [#17055](https://github.com/docker/docker/pull/17055) +- Fix permissions problem when reading from STDIN [#19283](https://github.com/docker/docker/pull/19283) + +### Client + ++ Add support for overriding the API version to use via an `DOCKER_API_VERSION` environment-variable [#15964](https://github.com/docker/docker/pull/15964) +- Fix a bug preventing Windows clients to log in to Docker Hub [#19891](https://github.com/docker/docker/pull/19891) + +### Misc + +* systemd: Set TasksMax in addition to LimitNPROC in systemd service file [#19391](https://github.com/docker/docker/pull/19391) + +### Deprecations + +* Remove LXC support. The LXC driver was deprecated in Docker 1.8, and has now been removed [#17700](https://github.com/docker/docker/pull/17700) +* Remove `--exec-driver` daemon flag, because it is no longer in use [#17700](https://github.com/docker/docker/pull/17700) +* Remove old deprecated single-dashed long CLI flags (such as `-rm`; use `--rm` instead) [#17724](https://github.com/docker/docker/pull/17724) +* Deprecate HostConfig at API container start [#17799](https://github.com/docker/docker/pull/17799) +* Deprecate docker packages for newly EOL'd Linux distributions: Fedora 21 and Ubuntu 15.04 (Vivid) [#18794](https://github.com/docker/docker/pull/18794), [#18809](https://github.com/docker/docker/pull/18809) +* Deprecate `-f` flag for docker tag [#18350](https://github.com/docker/docker/pull/18350) + +## 1.9.1 (2015-11-21) + +### Runtime + +- Do not prevent daemon from booting if images could not be restored (#17695) +- Force IPC mount to unmount on daemon shutdown/init (#17539) +- Turn IPC unmount errors into warnings (#17554) +- Fix `docker stats` performance regression (#17638) +- Clarify cryptic error message upon `docker logs` if `--log-driver=none` (#17767) +- Fix seldom panics (#17639, #17634, #17703) +- Fix opq whiteouts problems for files with dot prefix (#17819) +- devicemapper: try defaulting to xfs instead of ext4 for performance reasons (#17903, #17918) +- devicemapper: fix displayed fs in docker info (#17974) +- selinux: only relabel if user requested so with the `z` option (#17450, #17834) +- Do not make network calls when normalizing names (#18014) + +### Client + +- Fix `docker login` on windows (#17738) +- Fix bug with `docker inspect` output when not connected to daemon (#17715) +- Fix `docker inspect -f {{.HostConfig.Dns}} somecontainer` (#17680) + +### Builder + +- Fix regression with symlink behavior in ADD/COPY (#17710) + +### Networking + +- Allow passing a network ID as an argument for `--net` (#17558) +- Fix connect to host and prevent disconnect from host for `host` network (#17476) +- Fix `--fixed-cidr` issue when gateway ip falls in ip-range and ip-range is + not the first block in the network (#17853) +- Restore deterministic `IPv6` generation from `MAC` address on default `bridge` network (#17890) +- Allow port-mapping only for endpoints created on docker run (#17858) +- Fixed an endpoint delete issue with a possible stale sbox (#18102) + +### Distribution + +- Correct parent chain in v2 push when v1Compatibility files on the disk are inconsistent (#18047) + +## 1.9.0 (2015-11-03) + +### Runtime + ++ `docker stats` now returns block IO metrics (#15005) ++ `docker stats` now details network stats per interface (#15786) ++ Add `ancestor=` filter to `docker ps --filter` flag to filter +containers based on their ancestor images (#14570) ++ Add `label=` filter to `docker ps --filter` to filter containers +based on label (#16530) ++ Add `--kernel-memory` flag to `docker run` (#14006) ++ Add `--message` flag to `docker import` allowing to specify an optional +message (#15711) ++ Add `--privileged` flag to `docker exec` (#14113) ++ Add `--stop-signal` flag to `docker run` allowing to replace the container +process stopping signal (#15307) ++ Add a new `unless-stopped` restart policy (#15348) ++ Inspecting an image now returns tags (#13185) ++ Add container size information to `docker inspect` (#15796) ++ Add `RepoTags` and `RepoDigests` field to `/images/{name:.*}/json` (#17275) +- Remove the deprecated `/container/ps` endpoint from the API (#15972) +- Send and document correct HTTP codes for `/exec//start` (#16250) +- Share shm and mqueue between containers sharing IPC namespace (#15862) +- Event stream now shows OOM status when `--oom-kill-disable` is set (#16235) +- Ensure special network files (/etc/hosts etc.) are read-only if bind-mounted +with `ro` option (#14965) +- Improve `rmi` performance (#16890) +- Do not update /etc/hosts for the default bridge network, except for links (#17325) +- Fix conflict with duplicate container names (#17389) +- Fix an issue with incorrect template execution in `docker inspect` (#17284) +- DEPRECATE `-c` short flag variant for `--cpu-shares` in docker run (#16271) + +### Client + ++ Allow `docker import` to import from local files (#11907) + +### Builder + ++ Add a `STOPSIGNAL` Dockerfile instruction allowing to set a different +stop-signal for the container process (#15307) ++ Add an `ARG` Dockerfile instruction and a `--build-arg` flag to `docker build` +that allows to add build-time environment variables (#15182) +- Improve cache miss performance (#16890) + +### Storage + +- devicemapper: Implement deferred deletion capability (#16381) + +## Networking + ++ `docker network` exits experimental and is part of standard release (#16645) ++ New network top-level concept, with associated subcommands and API (#16645) + WARNING: the API is different from the experimental API ++ Support for multiple isolated/micro-segmented networks (#16645) ++ Built-in multihost networking using VXLAN based overlay driver (#14071) ++ Support for third-party network plugins (#13424) ++ Ability to dynamically connect containers to multiple networks (#16645) ++ Support for user-defined IP address management via pluggable IPAM drivers (#16910) ++ Add daemon flags `--cluster-store` and `--cluster-advertise` for built-in nodes discovery (#16229) ++ Add `--cluster-store-opt` for setting up TLS settings (#16644) ++ Add `--dns-opt` to the daemon (#16031) +- DEPRECATE following container `NetworkSettings` fields in API v1.21: `EndpointID`, `Gateway`, + `GlobalIPv6Address`, `GlobalIPv6PrefixLen`, `IPAddress`, `IPPrefixLen`, `IPv6Gateway` and `MacAddress`. + Those are now specific to the `bridge` network. Use `NetworkSettings.Networks` to inspect + the networking settings of a container per network. + +### Volumes + ++ New top-level `volume` subcommand and API (#14242) +- Move API volume driver settings to host-specific config (#15798) +- Print an error message if volume name is not unique (#16009) +- Ensure volumes created from Dockerfiles always use the local volume driver +(#15507) +- DEPRECATE auto-creating missing host paths for bind mounts (#16349) + +### Logging + ++ Add `awslogs` logging driver for Amazon CloudWatch (#15495) ++ Add generic `tag` log option to allow customizing container/image +information passed to driver (e.g. show container names) (#15384) +- Implement the `docker logs` endpoint for the journald driver (#13707) +- DEPRECATE driver-specific log tags (e.g. `syslog-tag`, etc.) (#15384) + +### Distribution + ++ `docker search` now works with partial names (#16509) +- Push optimization: avoid buffering to file (#15493) +- The daemon will display progress for images that were already being pulled +by another client (#15489) +- Only permissions required for the current action being performed are requested (#) ++ Renaming trust keys (and respective environment variables) from `offline` to +`root` and `tagging` to `repository` (#16894) +- DEPRECATE trust key environment variables +`DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE` and +`DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE` (#16894) + +### Security + ++ Add SELinux profiles to the rpm package (#15832) +- Fix various issues with AppArmor profiles provided in the deb package +(#14609) +- Add AppArmor policy that prevents writing to /proc (#15571) + +## 1.8.3 (2015-10-12) + +### Distribution + +- Fix layer IDs lead to local graph poisoning (CVE-2014-8178) +- Fix manifest validation and parsing logic errors allow pull-by-digest validation bypass (CVE-2014-8179) ++ Add `--disable-legacy-registry` to prevent a daemon from using a v1 registry + +## 1.8.2 (2015-09-10) + +### Distribution + +- Fixes rare edge case of handling GNU LongLink and LongName entries. +- Fix ^C on docker pull. +- Fix docker pull issues on client disconnection. +- Fix issue that caused the daemon to panic when loggers weren't configured properly. +- Fix goroutine leak pulling images from registry V2. + +### Runtime + +- Fix a bug mounting cgroups for docker daemons running inside docker containers. +- Initialize log configuration properly. + +### Client: + +- Handle `-q` flag in `docker ps` properly when there is a default format. + +### Networking + +- Fix several corner cases with netlink. + +### Contrib + +- Fix several issues with bash completion. + +## 1.8.1 (2015-08-12) + +### Distribution + +* Fix a bug where pushing multiple tags would result in invalid images + +## 1.8.0 (2015-08-11) + +### Distribution + ++ Trusted pull, push and build, disabled by default +* Make tar layers deterministic between registries +* Don't allow deleting the image of running containers +* Check if a tag name to load is a valid digest +* Allow one character repository names +* Add a more accurate error description for invalid tag name +* Make build cache ignore mtime + +### Cli + ++ Add support for DOCKER_CONFIG/--config to specify config file dir ++ Add --type flag for docker inspect command ++ Add formatting options to `docker ps` with `--format` ++ Replace `docker -d` with new subcommand `docker daemon` +* Zsh completion updates and improvements +* Add some missing events to bash completion +* Support daemon urls with base paths in `docker -H` +* Validate status= filter to docker ps +* Display when a container is in --net=host in docker ps +* Extend docker inspect to export image metadata related to graph driver +* Restore --default-gateway{,-v6} daemon options +* Add missing unpublished ports in docker ps +* Allow duration strings in `docker events` as --since/--until +* Expose more mounts information in `docker inspect` + +### Runtime + ++ Add new Fluentd logging driver ++ Allow `docker import` to load from local files ++ Add logging driver for GELF via UDP ++ Allow to copy files from host to containers with `docker cp` ++ Promote volume drivers from experimental to master ++ Add rollover options to json-file log driver, and --log-driver-opts flag ++ Add memory swappiness tuning options +* Remove cgroup read-only flag when privileged +* Make /proc, /sys, & /dev readonly for readonly containers +* Add cgroup bind mount by default +* Overlay: Export metadata for container and image in `docker inspect` +* Devicemapper: external device activation +* Devicemapper: Compare uuid of base device on startup +* Remove RC4 from the list of registry cipher suites +* Add syslog-facility option +* LXC execdriver compatibility with recent LXC versions +* Mark LXC execriver as deprecated (to be removed with the migration to runc) + +### Plugins + +* Separate plugin sockets and specs locations +* Allow TLS connections to plugins + +### Bug fixes + +- Add missing 'Names' field to /containers/json API output +- Make `docker rmi` of dangling images safe while pulling +- Devicemapper: Change default basesize to 100G +- Go Scheduler issue with sync.Mutex and gcc +- Fix issue where Search API endpoint would panic due to empty AuthConfig +- Set image canonical names correctly +- Check dockerinit only if lxc driver is used +- Fix ulimit usage of nproc +- Always attach STDIN if -i,--interactive is specified +- Show error messages when saving container state fails +- Fixed incorrect assumption on --bridge=none treated as disable network +- Check for invalid port specifications in host configuration +- Fix endpoint leave failure for --net=host mode +- Fix goroutine leak in the stats API if the container is not running +- Check for apparmor file before reading it +- Fix DOCKER_TLS_VERIFY being ignored +- Set umask to the default on startup +- Correct the message of pause and unpause a non-running container +- Adjust disallowed CpuShares in container creation +- ZFS: correctly apply selinux context +- Display empty string instead of when IP opt is nil +- `docker kill` returns error when container is not running +- Fix COPY/ADD quoted/json form +- Fix goroutine leak on logs -f with no output +- Remove panic in nat package on invalid hostport +- Fix container linking in Fedora 22 +- Fix error caused using default gateways outside of the allocated range +- Format times in inspect command with a template as RFC3339Nano +- Make registry client to accept 2xx and 3xx http status responses as successful +- Fix race issue that caused the daemon to crash with certain layer downloads failed in a specific order. +- Fix error when the docker ps format was not valid. +- Remove redundant ip forward check. +- Fix issue trying to push images to repository mirrors. +- Fix error cleaning up network entrypoints when there is an initialization issue. + +## 1.7.1 (2015-07-14) + +#### Runtime + +- Fix default user spawning exec process with `docker exec` +- Make `--bridge=none` not to configure the network bridge +- Publish networking stats properly +- Fix implicit devicemapper selection with static binaries +- Fix socket connections that hung intermittently +- Fix bridge interface creation on CentOS/RHEL 6.6 +- Fix local dns lookups added to resolv.conf +- Fix copy command mounting volumes +- Fix read/write privileges in volumes mounted with --volumes-from + +#### Remote API + +- Fix unmarshalling of Command and Entrypoint +- Set limit for minimum client version supported +- Validate port specification +- Return proper errors when attach/reattach fail + +#### Distribution + +- Fix pulling private images +- Fix fallback between registry V2 and V1 + +## 1.7.0 (2015-06-16) + +#### Runtime ++ Experimental feature: support for out-of-process volume plugins +* The userland proxy can be disabled in favor of hairpin NAT using the daemon’s `--userland-proxy=false` flag +* The `exec` command supports the `-u|--user` flag to specify the new process owner ++ Default gateway for containers can be specified daemon-wide using the `--default-gateway` and `--default-gateway-v6` flags ++ The CPU CFS (Completely Fair Scheduler) quota can be set in `docker run` using `--cpu-quota` ++ Container block IO can be controlled in `docker run` using`--blkio-weight` ++ ZFS support ++ The `docker logs` command supports a `--since` argument ++ UTS namespace can be shared with the host with `docker run --uts=host` + +#### Quality +* Networking stack was entirely rewritten as part of the libnetwork effort +* Engine internals refactoring +* Volumes code was entirely rewritten to support the plugins effort ++ Sending SIGUSR1 to a daemon will dump all goroutines stacks without exiting + +#### Build ++ Support ${variable:-value} and ${variable:+value} syntax for environment variables ++ Support resource management flags `--cgroup-parent`, `--cpu-period`, `--cpu-quota`, `--cpuset-cpus`, `--cpuset-mems` ++ git context changes with branches and directories +* The .dockerignore file support exclusion rules + +#### Distribution ++ Client support for v2 mirroring support for the official registry + +#### Bugfixes +* Firewalld is now supported and will automatically be used when available +* mounting --device recursively + +## 1.6.2 (2015-05-13) + +#### Runtime +- Revert change prohibiting mounting into /sys + +## 1.6.1 (2015-05-07) + +#### Security +- Fix read/write /proc paths (CVE-2015-3630) +- Prohibit VOLUME /proc and VOLUME / (CVE-2015-3631) +- Fix opening of file-descriptor 1 (CVE-2015-3627) +- Fix symlink traversal on container respawn allowing local privilege escalation (CVE-2015-3629) +- Prohibit mount of /sys + +#### Runtime +- Update AppArmor policy to not allow mounts + +## 1.6.0 (2015-04-07) + +#### Builder ++ Building images from an image ID ++ Build containers with resource constraints, ie `docker build --cpu-shares=100 --memory=1024m...` ++ `commit --change` to apply specified Dockerfile instructions while committing the image ++ `import --change` to apply specified Dockerfile instructions while importing the image ++ Builds no longer continue in the background when canceled with CTRL-C + +#### Client ++ Windows Support + +#### Runtime ++ Container and image Labels ++ `--cgroup-parent` for specifying a parent cgroup to place container cgroup within ++ Logging drivers, `json-file`, `syslog`, or `none` ++ Pulling images by ID ++ `--ulimit` to set the ulimit on a container ++ `--default-ulimit` option on the daemon which applies to all created containers (and overwritten by `--ulimit` on run) + +## 1.5.0 (2015-02-10) + +#### Builder ++ Dockerfile to use for a given `docker build` can be specified with the `-f` flag +* Dockerfile and .dockerignore files can be themselves excluded as part of the .dockerignore file, thus preventing modifications to these files invalidating ADD or COPY instructions cache +* ADD and COPY instructions accept relative paths +* Dockerfile `FROM scratch` instruction is now interpreted as a no-base specifier +* Improve performance when exposing a large number of ports + +#### Hack ++ Allow client-side only integration tests for Windows +* Include docker-py integration tests against Docker daemon as part of our test suites + +#### Packaging ++ Support for the new version of the registry HTTP API +* Speed up `docker push` for images with a majority of already existing layers +- Fixed contacting a private registry through a proxy + +#### Remote API ++ A new endpoint will stream live container resource metrics and can be accessed with the `docker stats` command ++ Containers can be renamed using the new `rename` endpoint and the associated `docker rename` command +* Container `inspect` endpoint show the ID of `exec` commands running in this container +* Container `inspect` endpoint show the number of times Docker auto-restarted the container +* New types of event can be streamed by the `events` endpoint: ‘OOM’ (container died with out of memory), ‘exec_create’, and ‘exec_start' +- Fixed returned string fields which hold numeric characters incorrectly omitting surrounding double quotes + +#### Runtime ++ Docker daemon has full IPv6 support ++ The `docker run` command can take the `--pid=host` flag to use the host PID namespace, which makes it possible for example to debug host processes using containerized debugging tools ++ The `docker run` command can take the `--read-only` flag to make the container’s root filesystem mounted as readonly, which can be used in combination with volumes to force a container’s processes to only write to locations that will be persisted ++ Container total memory usage can be limited for `docker run` using the `--memory-swap` flag +* Major stability improvements for devicemapper storage driver +* Better integration with host system: containers will reflect changes to the host's `/etc/resolv.conf` file when restarted +* Better integration with host system: per-container iptable rules are moved to the DOCKER chain +- Fixed container exiting on out of memory to return an invalid exit code + +#### Other +* The HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables are properly taken into account by the client when connecting to the Docker daemon + +## 1.4.1 (2014-12-15) + +#### Runtime +- Fix issue with volumes-from and bind mounts not being honored after create + +## 1.4.0 (2014-12-11) + +#### Notable Features since 1.3.0 ++ Set key=value labels to the daemon (displayed in `docker info`), applied with + new `-label` daemon flag ++ Add support for `ENV` in Dockerfile of the form: + `ENV name=value name2=value2...` ++ New Overlayfs Storage Driver ++ `docker info` now returns an `ID` and `Name` field ++ Filter events by event name, container, or image ++ `docker cp` now supports copying from container volumes +- Fixed `docker tag`, so it honors `--force` when overriding a tag for existing + image. + +## 1.3.3 (2014-12-11) + +#### Security +- Fix path traversal vulnerability in processing of absolute symbolic links (CVE-2014-9356) +- Fix decompression of xz image archives, preventing privilege escalation (CVE-2014-9357) +- Validate image IDs (CVE-2014-9358) + +#### Runtime +- Fix an issue when image archives are being read slowly + +#### Client +- Fix a regression related to stdin redirection +- Fix a regression with `docker cp` when destination is the current directory + +## 1.3.2 (2014-11-20) + +#### Security +- Fix tar breakout vulnerability +* Extractions are now sandboxed chroot +- Security options are no longer committed to images + +#### Runtime +- Fix deadlock in `docker ps -f exited=1` +- Fix a bug when `--volumes-from` references a container that failed to start + +#### Registry ++ `--insecure-registry` now accepts CIDR notation such as 10.1.0.0/16 +* Private registries whose IPs fall in the 127.0.0.0/8 range do no need the `--insecure-registry` flag +- Skip the experimental registry v2 API when mirroring is enabled + +## 1.3.1 (2014-10-28) + +#### Security +* Prevent fallback to SSL protocols < TLS 1.0 for client, daemon and registry ++ Secure HTTPS connection to registries with certificate verification and without HTTP fallback unless `--insecure-registry` is specified + +#### Runtime +- Fix issue where volumes would not be shared + +#### Client +- Fix issue with `--iptables=false` not automatically setting `--ip-masq=false` +- Fix docker run output to non-TTY stdout + +#### Builder +- Fix escaping `$` for environment variables +- Fix issue with lowercase `onbuild` Dockerfile instruction +- Restrict environment variable expansion to `ENV`, `ADD`, `COPY`, `WORKDIR`, `EXPOSE`, `VOLUME` and `USER` + +## 1.3.0 (2014-10-14) + +#### Notable features since 1.2.0 ++ Docker `exec` allows you to run additional processes inside existing containers ++ Docker `create` gives you the ability to create a container via the CLI without executing a process ++ `--security-opts` options to allow user to customize container labels and apparmor profiles ++ Docker `ps` filters +- Wildcard support to COPY/ADD ++ Move production URLs to get.docker.com from get.docker.io ++ Allocate IP address on the bridge inside a valid CIDR ++ Use drone.io for PR and CI testing ++ Ability to setup an official registry mirror ++ Ability to save multiple images with docker `save` + +## 1.2.0 (2014-08-20) + +#### Runtime ++ Make /etc/hosts /etc/resolv.conf and /etc/hostname editable at runtime ++ Auto-restart containers using policies ++ Use /var/lib/docker/tmp for large temporary files ++ `--cap-add` and `--cap-drop` to tweak what linux capability you want ++ `--device` to use devices in containers + +#### Client ++ `docker search` on private registries ++ Add `exited` filter to `docker ps --filter` +* `docker rm -f` now kills instead of stop ++ Support for IPv6 addresses in `--dns` flag + +#### Proxy ++ Proxy instances in separate processes +* Small bug fix on UDP proxy + +## 1.1.2 (2014-07-23) + +#### Runtime ++ Fix port allocation for existing containers ++ Fix containers restart on daemon restart + +#### Packaging ++ Fix /etc/init.d/docker issue on Debian + +## 1.1.1 (2014-07-09) + +#### Builder +* Fix issue with ADD + +## 1.1.0 (2014-07-03) + +#### Notable features since 1.0.1 ++ Add `.dockerignore` support ++ Pause containers during `docker commit` ++ Add `--tail` to `docker logs` + +#### Builder ++ Allow a tar file as context for `docker build` +* Fix issue with white-spaces and multi-lines in `Dockerfiles` + +#### Runtime +* Overall performance improvements +* Allow `/` as source of `docker run -v` +* Fix port allocation +* Fix bug in `docker save` +* Add links information to `docker inspect` + +#### Client +* Improve command line parsing for `docker commit` + +#### Remote API +* Improve status code for the `start` and `stop` endpoints + +## 1.0.1 (2014-06-19) + +#### Notable features since 1.0.0 +* Enhance security for the LXC driver + +#### Builder +* Fix `ONBUILD` instruction passed to grandchildren + +#### Runtime +* Fix events subscription +* Fix /etc/hostname file with host networking +* Allow `-h` and `--net=none` +* Fix issue with hotplug devices in `--privileged` + +#### Client +* Fix artifacts with events +* Fix a panic with empty flags +* Fix `docker cp` on Mac OS X + +#### Miscellaneous +* Fix compilation on Mac OS X +* Fix several races + +## 1.0.0 (2014-06-09) + +#### Notable features since 0.12.0 +* Production support + +## 0.12.0 (2014-06-05) + +#### Notable features since 0.11.0 +* 40+ various improvements to stability, performance and usability +* New `COPY` Dockerfile instruction to allow copying a local file from the context into the container without ever extracting if the file is a tar file +* Inherit file permissions from the host on `ADD` +* New `pause` and `unpause` commands to allow pausing and unpausing of containers using cgroup freezer +* The `images` command has a `-f`/`--filter` option to filter the list of images +* Add `--force-rm` to clean up after a failed build +* Standardize JSON keys in Remote API to CamelCase +* Pull from a docker run now assumes `latest` tag if not specified +* Enhance security on Linux capabilities and device nodes + +## 0.11.1 (2014-05-07) + +#### Registry +- Fix push and pull to private registry + +## 0.11.0 (2014-05-07) + +#### Notable features since 0.10.0 + +* SELinux support for mount and process labels +* Linked containers can be accessed by hostname +* Use the net `--net` flag to allow advanced network configuration such as host networking so that containers can use the host's network interfaces +* Add a ping endpoint to the Remote API to do healthchecks of your docker daemon +* Logs can now be returned with an optional timestamp +* Docker now works with registries that support SHA-512 +* Multiple registry endpoints are supported to allow registry mirrors + +## 0.10.0 (2014-04-08) + +#### Builder +- Fix printing multiple messages on a single line. Fixes broken output during builds. +- Follow symlinks inside container's root for ADD build instructions. +- Fix EXPOSE caching. + +#### Documentation +- Add the new options of `docker ps` to the documentation. +- Add the options of `docker restart` to the documentation. +- Update daemon docs and help messages for --iptables and --ip-forward. +- Updated apt-cacher-ng docs example. +- Remove duplicate description of --mtu from docs. +- Add missing -t and -v for `docker images` to the docs. +- Add fixes to the cli docs. +- Update libcontainer docs. +- Update images in docs to remove references to AUFS and LXC. +- Update the nodejs_web_app in the docs to use the new epel RPM address. +- Fix external link on security of containers. +- Update remote API docs. +- Add image size to history docs. +- Be explicit about binding to all interfaces in redis example. +- Document DisableNetwork flag in the 1.10 remote api. +- Document that `--lxc-conf` is lxc only. +- Add chef usage documentation. +- Add example for an image with multiple for `docker load`. +- Explain what `docker run -a` does in the docs. + +#### Contrib +- Add variable for DOCKER_LOGFILE to sysvinit and use append instead of overwrite in opening the logfile. +- Fix init script cgroup mounting workarounds to be more similar to cgroupfs-mount and thus work properly. +- Remove inotifywait hack from the upstart host-integration example because it's not necessary any more. +- Add check-config script to contrib. +- Fix fish shell completion. + +#### Hack +* Clean up "go test" output from "make test" to be much more readable/scannable. +* Exclude more "definitely not unit tested Go source code" directories from hack/make/test. ++ Generate md5 and sha256 hashes when building, and upload them via hack/release.sh. +- Include contributed completions in Ubuntu PPA. ++ Add cli integration tests. +* Add tweaks to the hack scripts to make them simpler. + +#### Remote API ++ Add TLS auth support for API. +* Move git clone from daemon to client. +- Fix content-type detection in docker cp. +* Split API into 2 go packages. + +#### Runtime +* Support hairpin NAT without going through Docker server. +- devicemapper: succeed immediately when removing non-existing devices. +- devicemapper: improve handling of devicemapper devices (add per device lock, increase sleep time and unlock while sleeping). +- devicemapper: increase timeout in waitClose to 10 seconds. +- devicemapper: ensure we shut down thin pool cleanly. +- devicemapper: pass info, rather than hash to activateDeviceIfNeeded, deactivateDevice, setInitialized, deleteDevice. +- devicemapper: avoid AB-BA deadlock. +- devicemapper: make shutdown better/faster. +- improve alpha sorting in mflag. +- Remove manual http cookie management because the cookiejar is being used. +- Use BSD raw mode on Darwin. Fixes nano, tmux and others. +- Add FreeBSD support for the client. +- Merge auth package into registry. +- Add deprecation warning for -t on `docker pull`. +- Remove goroutine leak on error. +- Update parseLxcInfo to comply with new lxc1.0 format. +- Fix attach exit on darwin. +- Improve deprecation message. +- Retry to retrieve the layer metadata up to 5 times for `docker pull`. +- Only unshare the mount namespace for execin. +- Merge existing config when committing. +- Disable daemon startup timeout. +- Fix issue #4681: add loopback interface when networking is disabled. +- Add failing test case for issue #4681. +- Send SIGTERM to child, instead of SIGKILL. +- Show the driver and the kernel version in `docker info` even when not in debug mode. +- Always symlink /dev/ptmx for libcontainer. This fixes console related problems. +- Fix issue caused by the absence of /etc/apparmor.d. +- Don't leave empty cidFile behind when failing to create the container. +- Mount cgroups automatically if they're not mounted already. +- Use mock for search tests. +- Update to double-dash everywhere. +- Move .dockerenv parsing to lxc driver. +- Move all bind-mounts in the container inside the namespace. +- Don't use separate bind mount for container. +- Always symlink /dev/ptmx for libcontainer. +- Don't kill by pid for other drivers. +- Add initial logging to libcontainer. +* Sort by port in `docker ps`. +- Move networking drivers into runtime top level package. ++ Add --no-prune to `docker rmi`. ++ Add time since exit in `docker ps`. +- graphdriver: add build tags. +- Prevent allocation of previously allocated ports & prevent improve port allocation. +* Add support for --since/--before in `docker ps`. +- Clean up container stop. ++ Add support for configurable dns search domains. +- Add support for relative WORKDIR instructions. +- Add --output flag for docker save. +- Remove duplication of DNS entries in config merging. +- Add cpuset.cpus to cgroups and native driver options. +- Remove docker-ci. +- Promote btrfs. btrfs is no longer considered experimental. +- Add --input flag to `docker load`. +- Return error when existing bridge doesn't match IP address. +- Strip comments before parsing line continuations to avoid interpreting instructions as comments. +- Fix TestOnlyLoopbackExistsWhenUsingDisableNetworkOption to ignore "DOWN" interfaces. +- Add systemd implementation of cgroups and make containers show up as systemd units. +- Fix commit and import when no repository is specified. +- Remount /var/lib/docker as --private to fix scaling issue. +- Use the environment's proxy when pinging the remote registry. +- Reduce error level from harmless errors. +* Allow --volumes-from to be individual files. +- Fix expanding buffer in StdCopy. +- Set error regardless of attach or stdin. This fixes #3364. +- Add support for --env-file to load environment variables from files. +- Symlink /etc/mtab and /proc/mounts. +- Allow pushing a single tag. +- Shut down containers cleanly at shutdown and wait forever for the containers to shut down. This makes container shutdown on daemon shutdown work properly via SIGTERM. +- Don't throw error when starting an already running container. +- Fix dynamic port allocation limit. +- remove setupDev from libcontainer. +- Add API version to `docker version`. +- Return correct exit code when receiving signal and make SIGQUIT quit without cleanup. +- Fix --volumes-from mount failure. +- Allow non-privileged containers to create device nodes. +- Skip login tests because of external dependency on a hosted service. +- Deprecate `docker images --tree` and `docker images --viz`. +- Deprecate `docker insert`. +- Include base abstraction for apparmor. This fixes some apparmor related problems on Ubuntu 14.04. +- Add specific error message when hitting 401 over HTTP on push. +- Fix absolute volume check. +- Remove volumes-from from the config. +- Move DNS options to hostconfig. +- Update the apparmor profile for libcontainer. +- Add deprecation notice for `docker commit -run`. + +## 0.9.1 (2014-03-24) + +#### Builder +- Fix printing multiple messages on a single line. Fixes broken output during builds. + +#### Documentation +- Fix external link on security of containers. + +#### Contrib +- Fix init script cgroup mounting workarounds to be more similar to cgroupfs-mount and thus work properly. +- Add variable for DOCKER_LOGFILE to sysvinit and use append instead of overwrite in opening the logfile. + +#### Hack +- Generate md5 and sha256 hashes when building, and upload them via hack/release.sh. + +#### Remote API +- Fix content-type detection in `docker cp`. + +#### Runtime +- Use BSD raw mode on Darwin. Fixes nano, tmux and others. +- Only unshare the mount namespace for execin. +- Retry to retrieve the layer metadata up to 5 times for `docker pull`. +- Merge existing config when committing. +- Fix panic in monitor. +- Disable daemon startup timeout. +- Fix issue #4681: add loopback interface when networking is disabled. +- Add failing test case for issue #4681. +- Send SIGTERM to child, instead of SIGKILL. +- Show the driver and the kernel version in `docker info` even when not in debug mode. +- Always symlink /dev/ptmx for libcontainer. This fixes console related problems. +- Fix issue caused by the absence of /etc/apparmor.d. +- Don't leave empty cidFile behind when failing to create the container. +- Improve deprecation message. +- Fix attach exit on darwin. +- devicemapper: improve handling of devicemapper devices (add per device lock, increase sleep time, unlock while sleeping). +- devicemapper: succeed immediately when removing non-existing devices. +- devicemapper: increase timeout in waitClose to 10 seconds. +- Remove goroutine leak on error. +- Update parseLxcInfo to comply with new lxc1.0 format. + +## 0.9.0 (2014-03-10) + +#### Builder +- Avoid extra mount/unmount during build. This fixes mount/unmount related errors during build. +- Add error to docker build --rm. This adds missing error handling. +- Forbid chained onbuild, `onbuild from` and `onbuild maintainer` triggers. +- Make `--rm` the default for `docker build`. + +#### Documentation +- Download the docker client binary for Mac over https. +- Update the titles of the install instructions & descriptions. +* Add instructions for upgrading boot2docker. +* Add port forwarding example in OS X install docs. +- Attempt to disentangle repository and registry. +- Update docs to explain more about `docker ps`. +- Update sshd example to use a Dockerfile. +- Rework some examples, including the Python examples. +- Update docs to include instructions for a container's lifecycle. +- Update docs documentation to discuss the docs branch. +- Don't skip cert check for an example & use HTTPS. +- Bring back the memory and swap accounting section which was lost when the kernel page was removed. +- Explain DNS warnings and how to fix them on systems running and using a local nameserver. + +#### Contrib +- Add Tanglu support for mkimage-debootstrap. +- Add SteamOS support for mkimage-debootstrap. + +#### Hack +- Get package coverage when running integration tests. +- Remove the Vagrantfile. This is being replaced with boot2docker. +- Fix tests on systems where aufs isn't available. +- Update packaging instructions and remove the dependency on lxc. + +#### Remote API +* Move code specific to the API to the api package. +- Fix header content type for the API. Makes all endpoints use proper content type. +- Fix registry auth & remove ping calls from CmdPush and CmdPull. +- Add newlines to the JSON stream functions. + +#### Runtime +* Do not ping the registry from the CLI. All requests to registries flow through the daemon. +- Check for nil information return in the lxc driver. This fixes panics with older lxc versions. +- Devicemapper: cleanups and fix for unmount. Fixes two problems which were causing unmount to fail intermittently. +- Devicemapper: remove directory when removing device. Directories don't get left behind when removing the device. +* Devicemapper: enable skip_block_zeroing. Improves performance by not zeroing blocks. +- Devicemapper: fix shutdown warnings. Fixes shutdown warnings concerning pool device removal. +- Ensure docker cp stream is closed properly. Fixes problems with files not being copied by `docker cp`. +- Stop making `tcp://` default to `127.0.0.1:4243` and remove the default port for tcp. +- Fix `--run` in `docker commit`. This makes `docker commit --run` work again. +- Fix custom bridge related options. This makes custom bridges work again. ++ Mount-bind the PTY as container console. This allows tmux/screen to run. ++ Add the pure Go libcontainer library to make it possible to run containers using only features of the Linux kernel. ++ Add native exec driver which uses libcontainer and make it the default exec driver. +- Add support for handling extended attributes in archives. +* Set the container MTU to be the same as the host MTU. ++ Add simple sha256 checksums for layers to speed up `docker push`. +* Improve kernel version parsing. +* Allow flag grouping (`docker run -it`). +- Remove chroot exec driver. +- Fix divide by zero to fix panic. +- Rewrite `docker rmi`. +- Fix docker info with lxc 1.0.0. +- Fix fedora tty with apparmor. +* Don't always append env vars, replace defaults with vars from config. +* Fix a goroutine leak. +* Switch to Go 1.2.1. +- Fix unique constraint error checks. +* Handle symlinks for Docker's data directory and for TMPDIR. +- Add deprecation warnings for flags (-flag is deprecated in favor of --flag) +- Add apparmor profile for the native execution driver. +* Move system specific code from archive to pkg/system. +- Fix duplicate signal for `docker run -i -t` (issue #3336). +- Return correct process pid for lxc. +- Add a -G option to specify the group which unix sockets belong to. ++ Add `-f` flag to `docker rm` to force removal of running containers. ++ Kill ghost containers and restart all ghost containers when the docker daemon restarts. ++ Add `DOCKER_RAMDISK` environment variable to make Docker work when the root is on a ramdisk. + +## 0.8.1 (2014-02-18) + +#### Builder + +- Avoid extra mount/unmount during build. This removes an unneeded mount/unmount operation which was causing problems with devicemapper +- Fix regression with ADD of tar files. This stops Docker from decompressing tarballs added via ADD from the local file system +- Add error to `docker build --rm`. This adds a missing error check to ensure failures to remove containers are detected and reported + +#### Documentation + +* Update issue filing instructions +* Warn against the use of symlinks for Docker's storage folder +* Replace the Firefox example with an IceWeasel example +* Rewrite the PostgresSQL example using a Dockerfile and add more details to it +* Improve the OS X documentation + +#### Remote API + +- Fix broken images API for version less than 1.7 +- Use the right encoding for all API endpoints which return JSON +- Move remote api client to api/ +- Queue calls to the API using generic socket wait + +#### Runtime + +- Fix the use of custom settings for bridges and custom bridges +- Refactor the devicemapper code to avoid many mount/unmount race conditions and failures +- Remove two panics which could make Docker crash in some situations +- Don't ping registry from the CLI client +- Enable skip_block_zeroing for devicemapper. This stops devicemapper from always zeroing entire blocks +- Fix --run in `docker commit`. This makes docker commit store `--run` in the image configuration +- Remove directory when removing devicemapper device. This cleans up leftover mount directories +- Drop NET_ADMIN capability for non-privileged containers. Unprivileged containers can't change their network configuration +- Ensure `docker cp` stream is closed properly +- Avoid extra mount/unmount during container registration. This removes an unneeded mount/unmount operation which was causing problems with devicemapper +- Stop allowing tcp:// as a default tcp bin address which binds to 127.0.0.1:4243 and remove the default port ++ Mount-bind the PTY as container console. This allows tmux and screen to run in a container +- Clean up archive closing. This fixes and improves archive handling +- Fix engine tests on systems where temp directories are symlinked +- Add test methods for save and load +- Avoid temporarily unmounting the container when restarting it. This fixes a race for devicemapper during restart +- Support submodules when building from a GitHub repository +- Quote volume path to allow spaces +- Fix remote tar ADD behavior. This fixes a regression which was causing Docker to extract tarballs + +## 0.8.0 (2014-02-04) + +#### Notable features since 0.7.0 + +* Images and containers can be removed much faster +* Building an image from source with docker build is now much faster +* The Docker daemon starts and stops much faster +* The memory footprint of many common operations has been reduced, by streaming files instead of buffering them in memory, fixing memory leaks, and fixing various suboptimal memory allocations +* Several race conditions were fixed, making Docker more stable under very high concurrency load. This makes Docker more stable and less likely to crash and reduces the memory footprint of many common operations +* All packaging operations are now built on the Go language’s standard tar implementation, which is bundled with Docker itself. This makes packaging more portable across host distributions, and solves several issues caused by quirks and incompatibilities between different distributions of tar +* Docker can now create, remove and modify larger numbers of containers and images graciously thanks to more aggressive releasing of system resources. For example the storage driver API now allows Docker to do reference counting on mounts created by the drivers +With the ongoing changes to the networking and execution subsystems of docker testing these areas have been a focus of the refactoring. By moving these subsystems into separate packages we can test, analyze, and monitor coverage and quality of these packages +* Many components have been separated into smaller sub-packages, each with a dedicated test suite. As a result the code is better-tested, more readable and easier to change + +* The ADD instruction now supports caching, which avoids unnecessarily re-uploading the same source content again and again when it hasn’t changed +* The new ONBUILD instruction adds to your image a “trigger” instruction to be executed at a later time, when the image is used as the base for another build +* Docker now ships with an experimental storage driver which uses the BTRFS filesystem for copy-on-write +* Docker is officially supported on Mac OS X +* The Docker daemon supports systemd socket activation + +## 0.7.6 (2014-01-14) + +#### Builder + +* Do not follow symlink outside of build context + +#### Runtime + +- Remount bind mounts when ro is specified +* Use https for fetching docker version + +#### Other + +* Inline the test.docker.io fingerprint +* Add ca-certificates to packaging documentation + +## 0.7.5 (2014-01-09) + +#### Builder + +* Disable compression for build. More space usage but a much faster upload +- Fix ADD caching for certain paths +- Do not compress archive from git build + +#### Documentation + +- Fix error in GROUP add example +* Make sure the GPG fingerprint is inline in the documentation +* Give more specific advice on setting up signing of commits for DCO + +#### Runtime + +- Fix misspelled container names +- Do not add hostname when networking is disabled +* Return most recent image from the cache by date +- Return all errors from docker wait +* Add Content-Type Header "application/json" to GET /version and /info responses + +#### Other + +* Update DCO to version 1.1 ++ Update Makefile to use "docker:GIT_BRANCH" as the generated image name +* Update Travis to check for new 1.1 DCO version + +## 0.7.4 (2014-01-07) + +#### Builder + +- Fix ADD caching issue with . prefixed path +- Fix docker build on devicemapper by reverting sparse file tar option +- Fix issue with file caching and prevent wrong cache hit +* Use same error handling while unmarshalling CMD and ENTRYPOINT + +#### Documentation + +* Simplify and streamline Amazon Quickstart +* Install instructions use unprefixed Fedora image +* Update instructions for mtu flag for Docker on GCE ++ Add Ubuntu Saucy to installation +- Fix for wrong version warning on master instead of latest + +#### Runtime + +- Only get the image's rootfs when we need to calculate the image size +- Correctly handle unmapping UDP ports +* Make CopyFileWithTar use a pipe instead of a buffer to save memory on docker build +- Fix login message to say pull instead of push +- Fix "docker load" help by removing "SOURCE" prompt and mentioning STDIN +* Make blank -H option default to the same as no -H was sent +* Extract cgroups utilities to own submodule + +#### Other + ++ Add Travis CI configuration to validate DCO and gofmt requirements ++ Add Developer Certificate of Origin Text +* Upgrade VBox Guest Additions +* Check standalone header when pinging a registry server + +## 0.7.3 (2014-01-02) + +#### Builder + ++ Update ADD to use the image cache, based on a hash of the added content +* Add error message for empty Dockerfile + +#### Documentation + +- Fix outdated link to the "Introduction" on www.docker.io ++ Update the docs to get wider when the screen does +- Add information about needing to install LXC when using raw binaries +* Update Fedora documentation to disentangle the docker and docker.io conflict +* Add a note about using the new `-mtu` flag in several GCE zones ++ Add FrugalWare installation instructions ++ Add a more complete example of `docker run` +- Fix API documentation for creating and starting Privileged containers +- Add missing "name" parameter documentation on "/containers/create" +* Add a mention of `lxc-checkconfig` as a way to check for some of the necessary kernel configuration +- Update the 1.8 API documentation with some additions that were added to the docs for 1.7 + +#### Hack + +- Add missing libdevmapper dependency to the packagers documentation +* Update minimum Go requirement to a hard line at Go 1.2+ +* Many minor improvements to the Vagrantfile ++ Add ability to customize dockerinit search locations when compiling (to be used very sparingly only by packagers of platforms who require a nonstandard location) ++ Add coverprofile generation reporting +- Add `-a` to our Go build flags, removing the need for recompiling the stdlib manually +* Update Dockerfile to be more canonical and have less spurious warnings during build +- Fix some miscellaneous `docker pull` progress bar display issues +* Migrate more miscellaneous packages under the "pkg" folder +* Update TextMate highlighting to automatically be enabled for files named "Dockerfile" +* Reorganize syntax highlighting files under a common "contrib/syntax" directory +* Update install.sh script (https://get.docker.io/) to not fail if busybox fails to download or run at the end of the Ubuntu/Debian installation +* Add support for container names in bash completion + +#### Packaging + ++ Add an official Docker client binary for Darwin (Mac OS X) +* Remove empty "Vendor" string and added "License" on deb package ++ Add a stubbed version of "/etc/default/docker" in the deb package + +#### Runtime + +* Update layer application to extract tars in place, avoiding file churn while handling whiteouts +- Fix permissiveness of mtime comparisons in tar handling (since GNU tar and Go tar do not yet support sub-second mtime precision) +* Reimplement `docker top` in pure Go to work more consistently, and even inside Docker-in-Docker (thus removing the shell injection vulnerability present in some versions of `lxc-ps`) ++ Update `-H unix://` to work similarly to `-H tcp://` by inserting the default values for missing portions +- Fix more edge cases regarding dockerinit and deleted or replaced docker or dockerinit files +* Update container name validation to include '.' +- Fix use of a symlink or non-absolute path as the argument to `-g` to work as expected +* Update to handle external mounts outside of LXC, fixing many small mounting quirks and making future execution backends and other features simpler +* Update to use proper box-drawing characters everywhere in `docker images -tree` +* Move MTU setting from LXC configuration to directly use netlink +* Add `-S` option to external tar invocation for more efficient spare file handling ++ Add arch/os info to User-Agent string, especially for registry requests ++ Add `-mtu` option to Docker daemon for configuring MTU +- Fix `docker build` to exit with a non-zero exit code on error ++ Add `DOCKER_HOST` environment variable to configure the client `-H` flag without specifying it manually for every invocation + +## 0.7.2 (2013-12-16) + +#### Runtime + ++ Validate container names on creation with standard regex +* Increase maximum image depth to 127 from 42 +* Continue to move api endpoints to the job api ++ Add -bip flag to allow specification of dynamic bridge IP via CIDR +- Allow bridge creation when ipv6 is not enabled on certain systems +* Set hostname and IP address from within dockerinit +* Drop capabilities from within dockerinit +- Fix volumes on host when symlink is present the image +- Prevent deletion of image if ANY container is depending on it even if the container is not running +* Update docker push to use new progress display +* Use os.Lstat to allow mounting unix sockets when inspecting volumes +- Adjust handling of inactive user login +- Add missing defines in devicemapper for older kernels +- Allow untag operations with no container validation +- Add auth config to docker build + +#### Documentation + +* Add more information about Docker logging ++ Add RHEL documentation +* Add a direct example for changing the CMD that is run in a container +* Update Arch installation documentation ++ Add section on Trusted Builds ++ Add Network documentation page + +#### Other + ++ Add new cover bundle for providing code coverage reporting +* Separate integration tests in bundles +* Make Tianon the hack maintainer +* Update mkimage-debootstrap with more tweaks for keeping images small +* Use https to get the install script +* Remove vendored dotcloud/tar now that Go 1.2 has been released + +## 0.7.1 (2013-12-05) + +#### Documentation + ++ Add @SvenDowideit as documentation maintainer ++ Add links example ++ Add documentation regarding ambassador pattern ++ Add Google Cloud Platform docs ++ Add dockerfile best practices +* Update doc for RHEL +* Update doc for registry +* Update Postgres examples +* Update doc for Ubuntu install +* Improve remote api doc + +#### Runtime + ++ Add hostconfig to docker inspect ++ Implement `docker log -f` to stream logs ++ Add env variable to disable kernel version warning ++ Add -format to `docker inspect` ++ Support bind-mount for files +- Fix bridge creation on RHEL +- Fix image size calculation +- Make sure iptables are called even if the bridge already exists +- Fix issue with stderr only attach +- Remove init layer when destroying a container +- Fix same port binding on different interfaces +- `docker build` now returns the correct exit code +- Fix `docker port` to display correct port +- `docker build` now check that the dockerfile exists client side +- `docker attach` now returns the correct exit code +- Remove the name entry when the container does not exist + +#### Registry + +* Improve progress bars, add ETA for downloads +* Simultaneous pulls now waits for the first to finish instead of failing +- Tag only the top-layer image when pushing to registry +- Fix issue with offline image transfer +- Fix issue preventing using ':' in password for registry + +#### Other + ++ Add pprof handler for debug ++ Create a Makefile +* Use stdlib tar that now includes fix +* Improve make.sh test script +* Handle SIGQUIT on the daemon +* Disable verbose during tests +* Upgrade to go1.2 for official build +* Improve unit tests +* The test suite now runs all tests even if one fails +* Refactor C in Go (Devmapper) +- Fix OS X compilation + +## 0.7.0 (2013-11-25) + +#### Notable features since 0.6.0 + +* Storage drivers: choose from aufs, device-mapper, or vfs. +* Standard Linux support: docker now runs on unmodified Linux kernels and all major distributions. +* Links: compose complex software stacks by connecting containers to each other. +* Container naming: organize your containers by giving them memorable names. +* Advanced port redirects: specify port redirects per interface, or keep sensitive ports private. +* Offline transfer: push and pull images to the filesystem without losing information. +* Quality: numerous bugfixes and small usability improvements. Significant increase in test coverage. + +## 0.6.7 (2013-11-21) + +#### Runtime + +* Improve stability, fixes some race conditions +* Skip the volumes mounted when deleting the volumes of container. +* Fix layer size computation: handle hard links correctly +* Use the work Path for docker cp CONTAINER:PATH +* Fix tmp dir never cleanup +* Speedup docker ps +* More informative error message on name collisions +* Fix nameserver regex +* Always return long id's +* Fix container restart race condition +* Keep published ports on docker stop;docker start +* Fix container networking on Fedora +* Correctly express "any address" to iptables +* Fix network setup when reconnecting to ghost container +* Prevent deletion if image is used by a running container +* Lock around read operations in graph + +#### RemoteAPI + +* Return full ID on docker rmi + +#### Client + ++ Add -tree option to images ++ Offline image transfer +* Exit with status 2 on usage error and display usage on stderr +* Do not forward SIGCHLD to container +* Use string timestamp for docker events -since + +#### Other + +* Update to go 1.2rc5 ++ Add /etc/default/docker support to upstart + +## 0.6.6 (2013-11-06) + +#### Runtime + +* Ensure container name on register +* Fix regression in /etc/hosts ++ Add lock around write operations in graph +* Check if port is valid +* Fix restart runtime error with ghost container networking ++ Add some more colors and animals to increase the pool of generated names +* Fix issues in docker inspect ++ Escape apparmor confinement ++ Set environment variables using a file. +* Prevent docker insert to erase something ++ Prevent DNS server conflicts in CreateBridgeIface ++ Validate bind mounts on the server side ++ Use parent image config in docker build +* Fix regression in /etc/hosts + +#### Client + ++ Add -P flag to publish all exposed ports ++ Add -notrunc and -q flags to docker history +* Fix docker commit, tag and import usage ++ Add stars, trusted builds and library flags in docker search +* Fix docker logs with tty + +#### RemoteAPI + +* Make /events API send headers immediately +* Do not split last column docker top ++ Add size to history + +#### Other + ++ Contrib: Desktop integration. Firefox usecase. ++ Dockerfile: bump to go1.2rc3 + +## 0.6.5 (2013-10-29) + +#### Runtime + ++ Containers can now be named ++ Containers can now be linked together for service discovery ++ 'run -a', 'start -a' and 'attach' can forward signals to the container for better integration with process supervisors ++ Automatically start crashed containers after a reboot ++ Expose IP, port, and proto as separate environment vars for container links +* Allow ports to be published to specific ips +* Prohibit inter-container communication by default +- Ignore ErrClosedPipe for stdin in Container.Attach +- Remove unused field kernelVersion +* Fix issue when mounting subdirectories of /mnt in container +- Fix untag during removal of images +* Check return value of syscall.Chdir when changing working directory inside dockerinit + +#### Client + +- Only pass stdin to hijack when needed to avoid closed pipe errors +* Use less reflection in command-line method invocation +- Monitor the tty size after starting the container, not prior +- Remove useless os.Exit() calls after log.Fatal + +#### Hack + ++ Add initial init scripts library and a safer Ubuntu packaging script that works for Debian +* Add -p option to invoke debootstrap with http_proxy +- Update install.sh with $sh_c to get sudo/su for modprobe +* Update all the mkimage scripts to use --numeric-owner as a tar argument +* Update hack/release.sh process to automatically invoke hack/make.sh and bail on build and test issues + +#### Other + +* Documentation: Fix the flags for nc in example +* Testing: Remove warnings and prevent mount issues +- Testing: Change logic for tty resize to avoid warning in tests +- Builder: Fix race condition in docker build with verbose output +- Registry: Fix content-type for PushImageJSONIndex method +* Contrib: Improve helper tools to generate debian and Arch linux server images + +## 0.6.4 (2013-10-16) + +#### Runtime + +- Add cleanup of container when Start() fails +* Add better comments to utils/stdcopy.go +* Add utils.Errorf for error logging ++ Add -rm to docker run for removing a container on exit +- Remove error messages which are not actually errors +- Fix `docker rm` with volumes +- Fix some error cases where a HTTP body might not be closed +- Fix panic with wrong dockercfg file +- Fix the attach behavior with -i +* Record termination time in state. +- Use empty string so TempDir uses the OS's temp dir automatically +- Make sure to close the network allocators ++ Autorestart containers by default +* Bump vendor kr/pty to commit 3b1f6487b `(syscall.O_NOCTTY)` +* lxc: Allow set_file_cap capability in container +- Move run -rm to the cli only +* Split stdout stderr +* Always create a new session for the container + +#### Testing + +- Add aggregated docker-ci email report +- Add cleanup to remove leftover containers +* Add nightly release to docker-ci +* Add more tests around auth.ResolveAuthConfig +- Remove a few errors in tests +- Catch errClosing error when TCP and UDP proxies are terminated +* Only run certain tests with TESTFLAGS='-run TestName' make.sh +* Prevent docker-ci to test closing PRs +* Replace panic by log.Fatal in tests +- Increase TestRunDetach timeout + +#### Documentation + +* Add initial draft of the Docker infrastructure doc +* Add devenvironment link to CONTRIBUTING.md +* Add `apt-get install curl` to Ubuntu docs +* Add explanation for export restrictions +* Add .dockercfg doc +* Remove Gentoo install notes about #1422 workaround +* Fix help text for -v option +* Fix Ping endpoint documentation +- Fix parameter names in docs for ADD command +- Fix ironic typo in changelog +* Various command fixes in postgres example +* Document how to edit and release docs +- Minor updates to `postgresql_service.rst` +* Clarify LGTM process to contributors +- Corrected error in the package name +* Document what `vagrant up` is actually doing ++ improve doc search results +* Cleanup whitespace in API 1.5 docs +* use angle brackets in MAINTAINER example email +* Update archlinux.rst ++ Changes to a new style for the docs. Includes version switcher. +* Formatting, add information about multiline json +* Improve registry and index REST API documentation +- Replace deprecated upgrading reference to docker-latest.tgz, which hasn't been updated since 0.5.3 +* Update Gentoo installation documentation now that we're in the portage tree proper +* Cleanup and reorganize docs and tooling for contributors and maintainers +- Minor spelling correction of protocoll -> protocol + +#### Contrib + +* Add vim syntax highlighting for Dockerfiles from @honza +* Add mkimage-arch.sh +* Reorganize contributed completion scripts to add zsh completion + +#### Hack + +* Add vagrant user to the docker group +* Add proper bash completion for "docker push" +* Add xz utils as a runtime dep +* Add cleanup/refactor portion of #2010 for hack and Dockerfile updates ++ Add contrib/mkimage-centos.sh back (from #1621), and associated documentation link +* Add several of the small make.sh fixes from #1920, and make the output more consistent and contributor-friendly ++ Add @tianon to hack/MAINTAINERS +* Improve network performance for VirtualBox +* Revamp install.sh to be usable by more people, and to use official install methods whenever possible (apt repo, portage tree, etc.) +- Fix contrib/mkimage-debian.sh apt caching prevention ++ Add Dockerfile.tmLanguage to contrib +* Configured FPM to make /etc/init/docker.conf a config file +* Enable SSH Agent forwarding in Vagrant VM +* Several small tweaks/fixes for contrib/mkimage-debian.sh + +#### Other + +- Builder: Abort build if mergeConfig returns an error and fix duplicate error message +- Packaging: Remove deprecated packaging directory +- Registry: Use correct auth config when logging in. +- Registry: Fix the error message so it is the same as the regex + +## 0.6.3 (2013-09-23) + +#### Packaging + +* Add 'docker' group on install for ubuntu package +* Update tar vendor dependency +* Download apt key over HTTPS + +#### Runtime + +- Only copy and change permissions on non-bindmount volumes +* Allow multiple volumes-from +- Fix HTTP imports from STDIN + +#### Documentation + +* Update section on extracting the docker binary after build +* Update development environment docs for new build process +* Remove 'base' image from documentation + +#### Other + +- Client: Fix detach issue +- Registry: Update regular expression to match index + +## 0.6.2 (2013-09-17) + +#### Runtime + ++ Add domainname support ++ Implement image filtering with path.Match +* Remove unnecessary warnings +* Remove os/user dependency +* Only mount the hostname file when the config exists +* Handle signals within the `docker login` command +- UID and GID are now also applied to volumes +- `docker start` set error code upon error +- `docker run` set the same error code as the process started + +#### Builder + ++ Add -rm option in order to remove intermediate containers +* Allow multiline for the RUN instruction + +#### Registry + +* Implement login with private registry +- Fix push issues + +#### Other + ++ Hack: Vendor all dependencies +* Remote API: Bump to v1.5 +* Packaging: Break down hack/make.sh into small scripts, one per 'bundle': test, binary, ubuntu etc. +* Documentation: General improvements + +## 0.6.1 (2013-08-23) + +#### Registry + +* Pass "meta" headers in API calls to the registry + +#### Packaging + +- Use correct upstart script with new build tool +- Use libffi-dev, don`t build it from sources +- Remove duplicate mercurial install command + +## 0.6.0 (2013-08-22) + +#### Runtime + ++ Add lxc-conf flag to allow custom lxc options ++ Add an option to set the working directory +* Add Image name to LogEvent tests ++ Add -privileged flag and relevant tests, docs, and examples +* Add websocket support to /container//attach/ws +* Add warning when net.ipv4.ip_forwarding = 0 +* Add hostname to environment +* Add last stable version in `docker version` +- Fix race conditions in parallel pull +- Fix Graph ByParent() to generate list of child images per parent image. +- Fix typo: fmt.Sprint -> fmt.Sprintf +- Fix small \n error un docker build +* Fix to "Inject dockerinit at /.dockerinit" +* Fix #910. print user name to docker info output +* Use Go 1.1.2 for dockerbuilder +* Use ranged for loop on channels +- Use utils.ParseRepositoryTag instead of strings.Split(name, ":") in server.ImageDelete +- Improve CMD, ENTRYPOINT, and attach docs. +- Improve connect message with socket error +- Load authConfig only when needed and fix useless WARNING +- Show tag used when image is missing +* Apply volumes-from before creating volumes +- Make docker run handle SIGINT/SIGTERM +- Prevent crash when .dockercfg not readable +- Install script should be fetched over https, not http. +* API, issue 1471: Use groups for socket permissions +- Correctly detect IPv4 forwarding +* Mount /dev/shm as a tmpfs +- Switch from http to https for get.docker.io +* Let userland proxy handle container-bound traffic +* Update the Docker CLI to specify a value for the "Host" header. +- Change network range to avoid conflict with EC2 DNS +- Reduce connect and read timeout when pinging the registry +* Parallel pull +- Handle ip route showing mask-less IP addresses +* Allow ENTRYPOINT without CMD +- Always consider localhost as a domain name when parsing the FQN repos name +* Refactor checksum + +#### Documentation + +* Add MongoDB image example +* Add instructions for creating and using the docker group +* Add sudo to examples and installation to documentation +* Add ufw doc +* Add a reference to ps -a +* Add information about Docker`s high level tools over LXC. +* Fix typo in docs for docker run -dns +* Fix a typo in the ubuntu installation guide +* Fix to docs regarding adding docker groups +* Update default -H docs +* Update readme with dependencies for building +* Update amazon.rst to explain that Vagrant is not necessary for running Docker on ec2 +* PostgreSQL service example in documentation +* Suggest installing linux-headers by default. +* Change the twitter handle +* Clarify Amazon EC2 installation +* 'Base' image is deprecated and should no longer be referenced in the docs. +* Move note about officially supported kernel +- Solved the logo being squished in Safari + +#### Builder + ++ Add USER instruction do Dockerfile ++ Add workdir support for the Buildfile +* Add no cache for docker build +- Fix docker build and docker events output +- Only count known instructions as build steps +- Make sure ENV instruction within build perform a commit each time +- Forbid certain paths within docker build ADD +- Repository name (and optionally a tag) in build usage +- Make sure ADD will create everything in 0755 + +#### Remote API + +* Sort Images by most recent creation date. +* Reworking opaque requests in registry module +* Add image name in /events +* Use mime pkg to parse Content-Type +* 650 http utils and user agent field + +#### Hack + ++ Bash Completion: Limit commands to containers of a relevant state +* Add docker dependencies coverage testing into docker-ci + +#### Packaging + ++ Docker-brew 0.5.2 support and memory footprint reduction +* Add new docker dependencies into docker-ci +- Revert "docker.upstart: avoid spawning a `sh` process" ++ Docker-brew and Docker standard library ++ Release docker with docker +* Fix the upstart script generated by get.docker.io +* Enabled the docs to generate manpages. +* Revert Bind daemon to 0.0.0.0 in Vagrant. + +#### Register + +* Improve auth push +* Registry unit tests + mock registry + +#### Tests + +* Improve TestKillDifferentUser to prevent timeout on buildbot +- Fix typo in TestBindMounts (runContainer called without image) +* Improve TestGetContainersTop so it does not rely on sleep +* Relax the lo interface test to allow iface index != 1 +* Add registry functional test to docker-ci +* Add some tests in server and utils + +#### Other + +* Contrib: bash completion script +* Client: Add docker cp command and copy api endpoint to copy container files/folders to the host +* Don`t read from stdout when only attached to stdin + +## 0.5.3 (2013-08-13) + +#### Runtime + +* Use docker group for socket permissions +- Spawn shell within upstart script +- Handle ip route showing mask-less IP addresses +- Add hostname to environment + +#### Builder + +- Make sure ENV instruction within build perform a commit each time + +## 0.5.2 (2013-08-08) + +* Builder: Forbid certain paths within docker build ADD +- Runtime: Change network range to avoid conflict with EC2 DNS +* API: Change daemon to listen on unix socket by default + +## 0.5.1 (2013-07-30) + +#### Runtime + ++ Add `ps` args to `docker top` ++ Add support for container ID files (pidfile like) ++ Add container=lxc in default env ++ Support networkless containers with `docker run -n` and `docker -d -b=none` +* Stdout/stderr logs are now stored in the same file as JSON +* Allocate a /16 IP range by default, with fallback to /24. Try 12 ranges instead of 3. +* Change .dockercfg format to json and support multiple auth remote +- Do not override volumes from config +- Fix issue with EXPOSE override + +#### API + ++ Docker client now sets useragent (RFC 2616) ++ Add /events endpoint + +#### Builder + ++ ADD command now understands URLs ++ CmdAdd and CmdEnv now respect Dockerfile-set ENV variables +- Create directories with 755 instead of 700 within ADD instruction + +#### Hack + +* Simplify unit tests with helpers +* Improve docker.upstart event +* Add coverage testing into docker-ci + +## 0.5.0 (2013-07-17) + +#### Runtime + ++ List all processes running inside a container with 'docker top' ++ Host directories can be mounted as volumes with 'docker run -v' ++ Containers can expose public UDP ports (eg, '-p 123/udp') ++ Optionally specify an exact public port (eg. '-p 80:4500') +* 'docker login' supports additional options +- Don't save a container`s hostname when committing an image. + +#### Registry + ++ New image naming scheme inspired by Go packaging convention allows arbitrary combinations of registries +- Fix issues when uploading images to a private registry + +#### Builder + ++ ENTRYPOINT instruction sets a default binary entry point to a container ++ VOLUME instruction marks a part of the container as persistent data +* 'docker build' displays the full output of a build by default + +## 0.4.8 (2013-07-01) + ++ Builder: New build operation ENTRYPOINT adds an executable entry point to the container. - Runtime: Fix a bug which caused 'docker run -d' to no longer print the container ID. +- Tests: Fix issues in the test suite + +## 0.4.7 (2013-06-28) + +#### Remote API + +* The progress bar updates faster when downloading and uploading large files +- Fix a bug in the optional unix socket transport + +#### Runtime + +* Improve detection of kernel version ++ Host directories can be mounted as volumes with 'docker run -b' +- fix an issue when only attaching to stdin +* Use 'tar --numeric-owner' to avoid uid mismatch across multiple hosts + +#### Hack + +* Improve test suite and dev environment +* Remove dependency on unit tests on 'os/user' + +#### Other + +* Registry: easier push/pull to a custom registry ++ Documentation: add terminology section + +## 0.4.6 (2013-06-22) + +- Runtime: fix a bug which caused creation of empty images (and volumes) to crash. + +## 0.4.5 (2013-06-21) + ++ Builder: 'docker build git://URL' fetches and builds a remote git repository +* Runtime: 'docker ps -s' optionally prints container size +* Tests: improved and simplified +- Runtime: fix a regression introduced in 0.4.3 which caused the logs command to fail. +- Builder: fix a regression when using ADD with single regular file. + +## 0.4.4 (2013-06-19) + +- Builder: fix a regression introduced in 0.4.3 which caused builds to fail on new clients. + +## 0.4.3 (2013-06-19) + +#### Builder + ++ ADD of a local file will detect tar archives and unpack them +* ADD improvements: use tar for copy + automatically unpack local archives +* ADD uses tar/untar for copies instead of calling 'cp -ar' +* Fix the behavior of ADD to be (mostly) reverse-compatible, predictable and well-documented. +- Fix a bug which caused builds to fail if ADD was the first command +* Nicer output for 'docker build' + +#### Runtime + +* Remove bsdtar dependency +* Add unix socket and multiple -H support +* Prevent rm of running containers +* Use go1.1 cookiejar +- Fix issue detaching from running TTY container +- Forbid parallel push/pull for a single image/repo. Fixes #311 +- Fix race condition within Run command when attaching. + +#### Client + +* HumanReadable ProgressBar sizes in pull +* Fix docker version`s git commit output + +#### API + +* Send all tags on History API call +* Add tag lookup to history command. Fixes #882 + +#### Documentation + +- Fix missing command in irc bouncer example + +## 0.4.2 (2013-06-17) + +- Packaging: Bumped version to work around an Ubuntu bug + +## 0.4.1 (2013-06-17) + +#### Remote Api + ++ Add flag to enable cross domain requests ++ Add images and containers sizes in docker ps and docker images + +#### Runtime + ++ Configure dns configuration host-wide with 'docker -d -dns' ++ Detect faulty DNS configuration and replace it with a public default ++ Allow docker run : ++ You can now specify public port (ex: -p 80:4500) +* Improve image removal to garbage-collect unreferenced parents + +#### Client + +* Allow multiple params in inspect +* Print the container id before the hijack in `docker run` + +#### Registry + +* Add regexp check on repo`s name +* Move auth to the client +- Remove login check on pull + +#### Other + +* Vagrantfile: Add the rest api port to vagrantfile`s port_forward +* Upgrade to Go 1.1 +- Builder: don`t ignore last line in Dockerfile when it doesn`t end with \n + +## 0.4.0 (2013-06-03) + +#### Builder + ++ Introducing Builder ++ 'docker build' builds a container, layer by layer, from a source repository containing a Dockerfile + +#### Remote API + ++ Introducing Remote API ++ control Docker programmatically using a simple HTTP/json API + +#### Runtime + +* Various reliability and usability improvements + +## 0.3.4 (2013-05-30) + +#### Builder + ++ 'docker build' builds a container, layer by layer, from a source repository containing a Dockerfile ++ 'docker build -t FOO' applies the tag FOO to the newly built container. + +#### Runtime + ++ Interactive TTYs correctly handle window resize +* Fix how configuration is merged between layers + +#### Remote API + ++ Split stdout and stderr on 'docker run' ++ Optionally listen on a different IP and port (use at your own risk) + +#### Documentation + +* Improve install instructions. + +## 0.3.3 (2013-05-23) + +- Registry: Fix push regression +- Various bugfixes + +## 0.3.2 (2013-05-09) + +#### Registry + +* Improve the checksum process +* Use the size to have a good progress bar while pushing +* Use the actual archive if it exists in order to speed up the push +- Fix error 400 on push + +#### Runtime + +* Store the actual archive on commit + +## 0.3.1 (2013-05-08) + +#### Builder + ++ Implement the autorun capability within docker builder ++ Add caching to docker builder ++ Add support for docker builder with native API as top level command ++ Implement ENV within docker builder +- Check the command existence prior create and add Unit tests for the case +* use any whitespaces instead of tabs + +#### Runtime + ++ Add go version to debug infos +* Kernel version - don`t show the dash if flavor is empty + +#### Registry + ++ Add docker search top level command in order to search a repository +- Fix pull for official images with specific tag +- Fix issue when login in with a different user and trying to push +* Improve checksum - async calculation + +#### Images + ++ Output graph of images to dot (graphviz) +- Fix ByParent function + +#### Documentation + ++ New introduction and high-level overview ++ Add the documentation for docker builder +- CSS fix for docker documentation to make REST API docs look better. +- Fix CouchDB example page header mistake +- Fix README formatting +* Update www.docker.io website. + +#### Other + ++ Website: new high-level overview +- Makefile: Swap "go get" for "go get -d", especially to compile on go1.1rc +* Packaging: packaging ubuntu; issue #510: Use goland-stable PPA package to build docker + +## 0.3.0 (2013-05-06) + +#### Runtime + +- Fix the command existence check +- strings.Split may return an empty string on no match +- Fix an index out of range crash if cgroup memory is not + +#### Documentation + +* Various improvements ++ New example: sharing data between 2 couchdb databases + +#### Other + +* Vagrant: Use only one deb line in /etc/apt ++ Registry: Implement the new registry + +## 0.2.2 (2013-05-03) + ++ Support for data volumes ('docker run -v=PATH') ++ Share data volumes between containers ('docker run -volumes-from') ++ Improve documentation +* Upgrade to Go 1.0.3 +* Various upgrades to the dev environment for contributors + +## 0.2.1 (2013-05-01) + ++ 'docker commit -run' bundles a layer with default runtime options: command, ports etc. +* Improve install process on Vagrant ++ New Dockerfile operation: "maintainer" ++ New Dockerfile operation: "expose" ++ New Dockerfile operation: "cmd" ++ Contrib script to build a Debian base layer ++ 'docker -d -r': restart crashed containers at daemon startup +* Runtime: improve test coverage + +## 0.2.0 (2013-04-23) + +- Runtime: ghost containers can be killed and waited for +* Documentation: update install instructions +- Packaging: fix Vagrantfile +- Development: automate releasing binaries and ubuntu packages ++ Add a changelog +- Various bugfixes + +## 0.1.8 (2013-04-22) + +- Dynamically detect cgroup capabilities +- Issue stability warning on kernels <3.8 +- 'docker push' buffers on disk instead of memory +- Fix 'docker diff' for removed files +- Fix 'docker stop' for ghost containers +- Fix handling of pidfile +- Various bugfixes and stability improvements + +## 0.1.7 (2013-04-18) + +- Container ports are available on localhost +- 'docker ps' shows allocated TCP ports +- Contributors can run 'make hack' to start a continuous integration VM +- Streamline ubuntu packaging & uploading +- Various bugfixes and stability improvements + +## 0.1.6 (2013-04-17) + +- Record the author an image with 'docker commit -author' + +## 0.1.5 (2013-04-17) + +- Disable standalone mode +- Use a custom DNS resolver with 'docker -d -dns' +- Detect ghost containers +- Improve diagnosis of missing system capabilities +- Allow disabling memory limits at compile time +- Add debian packaging +- Documentation: installing on Arch Linux +- Documentation: running Redis on docker +- Fix lxc 0.9 compatibility +- Automatically load aufs module +- Various bugfixes and stability improvements + +## 0.1.4 (2013-04-09) + +- Full support for TTY emulation +- Detach from a TTY session with the escape sequence `C-p C-q` +- Various bugfixes and stability improvements +- Minor UI improvements +- Automatically create our own bridge interface 'docker0' + +## 0.1.3 (2013-04-04) + +- Choose TCP frontend port with '-p :PORT' +- Layer format is versioned +- Major reliability improvements to the process manager +- Various bugfixes and stability improvements + +## 0.1.2 (2013-04-03) + +- Set container hostname with 'docker run -h' +- Selective attach at run with 'docker run -a [stdin[,stdout[,stderr]]]' +- Various bugfixes and stability improvements +- UI polish +- Progress bar on push/pull +- Use XZ compression by default +- Make IP allocator lazy + +## 0.1.1 (2013-03-31) + +- Display shorthand IDs for convenience +- Stabilize process management +- Layers can include a commit message +- Simplified 'docker attach' +- Fix support for re-attaching +- Various bugfixes and stability improvements +- Auto-download at run +- Auto-login on push +- Beefed up documentation + +## 0.1.0 (2013-03-23) + +Initial public release + +- Implement registry in order to push/pull images +- TCP port allocation +- Fix termcaps on Linux +- Add documentation +- Add Vagrant support with Vagrantfile +- Add unit tests +- Add repository/tags to ease image management +- Improve the layer implementation diff --git a/vendor/github.com/docker/docker/CONTRIBUTING.md b/vendor/github.com/docker/docker/CONTRIBUTING.md new file mode 100644 index 00000000..6b875d69 --- /dev/null +++ b/vendor/github.com/docker/docker/CONTRIBUTING.md @@ -0,0 +1,436 @@ +# Contributing to Docker + +Want to hack on Docker? Awesome! We have a contributor's guide that explains +[setting up a Docker development environment and the contribution +process](https://docs.docker.com/opensource/project/who-written-for/). + +![Contributors guide](docs/static_files/contributors.png) + +This page contains information about reporting issues as well as some tips and +guidelines useful to experienced open source contributors. Finally, make sure +you read our [community guidelines](#docker-community-guidelines) before you +start participating. + +## Topics + +* [Reporting Security Issues](#reporting-security-issues) +* [Design and Cleanup Proposals](#design-and-cleanup-proposals) +* [Reporting Issues](#reporting-other-issues) +* [Quick Contribution Tips and Guidelines](#quick-contribution-tips-and-guidelines) +* [Community Guidelines](#docker-community-guidelines) + +## Reporting security issues + +The Docker maintainers take security seriously. If you discover a security +issue, please bring it to their attention right away! + +Please **DO NOT** file a public issue, instead send your report privately to +[security@docker.com](mailto:security@docker.com). + +Security reports are greatly appreciated and we will publicly thank you for it. +We also like to send gifts—if you're into Docker schwag, make sure to let +us know. We currently do not offer a paid security bounty program, but are not +ruling it out in the future. + + +## Reporting other issues + +A great way to contribute to the project is to send a detailed report when you +encounter an issue. We always appreciate a well-written, thorough bug report, +and will thank you for it! + +Check that [our issue database](https://github.com/docker/docker/issues) +doesn't already include that problem or suggestion before submitting an issue. +If you find a match, you can use the "subscribe" button to get notified on +updates. Do *not* leave random "+1" or "I have this too" comments, as they +only clutter the discussion, and don't help resolving it. However, if you +have ways to reproduce the issue or have additional information that may help +resolving the issue, please leave a comment. + +When reporting issues, always include: + +* The output of `docker version`. +* The output of `docker info`. + +Also include the steps required to reproduce the problem if possible and +applicable. This information will help us review and fix your issue faster. +When sending lengthy log-files, consider posting them as a gist (https://gist.github.com). +Don't forget to remove sensitive data from your logfiles before posting (you can +replace those parts with "REDACTED"). + +**Issue Report Template**: + +``` +Description of problem: + + +`docker version`: + + +`docker info`: + + +`uname -a`: + + +Environment details (AWS, VirtualBox, physical, etc.): + + +How reproducible: + + +Steps to Reproduce: +1. +2. +3. + + +Actual Results: + + +Expected Results: + + +Additional info: + + + +``` + + +##Quick contribution tips and guidelines + +This section gives the experienced contributor some tips and guidelines. + +###Pull requests are always welcome + +Not sure if that typo is worth a pull request? Found a bug and know how to fix +it? Do it! We will appreciate it. Any significant improvement should be +documented as [a GitHub issue](https://github.com/docker/docker/issues) before +anybody starts working on it. + +We are always thrilled to receive pull requests. We do our best to process them +quickly. If your pull request is not accepted on the first try, +don't get discouraged! Our contributor's guide explains [the review process we +use for simple changes](https://docs.docker.com/opensource/workflow/make-a-contribution/). + +### Design and cleanup proposals + +You can propose new designs for existing Docker features. You can also design +entirely new features. We really appreciate contributors who want to refactor or +otherwise cleanup our project. For information on making these types of +contributions, see [the advanced contribution +section](https://docs.docker.com/opensource/workflow/advanced-contributing/) in +the contributors guide. + +We try hard to keep Docker lean and focused. Docker can't do everything for +everybody. This means that we might decide against incorporating a new feature. +However, there might be a way to implement that feature *on top of* Docker. + +### Talking to other Docker users and contributors + + + + + + + + + + + + + + + + + + + + +
Internet Relay Chat (IRC) +

+ IRC a direct line to our most knowledgeable Docker users; we have + both the #docker and #docker-dev group on + irc.freenode.net. + IRC is a rich chat protocol but it can overwhelm new users. You can search + our chat archives. +

+ Read our IRC quickstart guide for an easy way to get started. +
Google Groups + There are two groups. + Docker-user + is for people using Docker containers. + The docker-dev + group is for contributors and other people contributing to the Docker + project. + You can join them without an google account by sending an email to e.g. "docker-user+subscribe@googlegroups.com". + After receiving the join-request message, you can simply reply to that to confirm the subscribtion. +
Twitter + You can follow Docker's Twitter feed + to get updates on our products. You can also tweet us questions or just + share blogs or stories. +
Stack Overflow + Stack Overflow has over 17000 Docker questions listed. We regularly + monitor Docker questions + and so do many other knowledgeable Docker users. +
+ + +### Conventions + +Fork the repository and make changes on your fork in a feature branch: + +- If it's a bug fix branch, name it XXXX-something where XXXX is the number of + the issue. +- If it's a feature branch, create an enhancement issue to announce + your intentions, and name it XXXX-something where XXXX is the number of the + issue. + +Submit unit tests for your changes. Go has a great test framework built in; use +it! Take a look at existing tests for inspiration. [Run the full test +suite](https://docs.docker.com/opensource/project/test-and-docs/) on your branch before +submitting a pull request. + +Update the documentation when creating or modifying features. Test your +documentation changes for clarity, concision, and correctness, as well as a +clean documentation build. See our contributors guide for [our style +guide](https://docs.docker.com/opensource/doc-style) and instructions on [building +the documentation](https://docs.docker.com/opensource/project/test-and-docs/#build-and-test-the-documentation). + +Write clean code. Universally formatted code promotes ease of writing, reading, +and maintenance. Always run `gofmt -s -w file.go` on each changed file before +committing your changes. Most editors have plug-ins that do this automatically. + +Pull request descriptions should be as clear as possible and include a reference +to all the issues that they address. + +Commit messages must start with a capitalized and short summary (max. 50 chars) +written in the imperative, followed by an optional, more detailed explanatory +text which is separated from the summary by an empty line. + +Code review comments may be added to your pull request. Discuss, then make the +suggested modifications and push additional commits to your feature branch. Post +a comment after pushing. New commits show up in the pull request automatically, +but the reviewers are notified only when you comment. + +Pull requests must be cleanly rebased on top of master without multiple branches +mixed into the PR. + +**Git tip**: If your PR no longer merges cleanly, use `rebase master` in your +feature branch to update your pull request rather than `merge master`. + +Before you make a pull request, squash your commits into logical units of work +using `git rebase -i` and `git push -f`. A logical unit of work is a consistent +set of patches that should be reviewed together: for example, upgrading the +version of a vendored dependency and taking advantage of its now available new +feature constitute two separate units of work. Implementing a new function and +calling it in another file constitute a single logical unit of work. The very +high majority of submissions should have a single commit, so if in doubt: squash +down to one. + +After every commit, [make sure the test suite passes] +(https://docs.docker.com/opensource/project/test-and-docs/). Include documentation +changes in the same pull request so that a revert would remove all traces of +the feature or fix. + +Include an issue reference like `Closes #XXXX` or `Fixes #XXXX` in commits that +close an issue. Including references automatically closes the issue on a merge. + +Please do not add yourself to the `AUTHORS` file, as it is regenerated regularly +from the Git history. + +Please see the [Coding Style](#coding-style) for further guidelines. + +### Merge approval + +Docker maintainers use LGTM (Looks Good To Me) in comments on the code review to +indicate acceptance. + +A change requires LGTMs from an absolute majority of the maintainers of each +component affected. For example, if a change affects `docs/` and `registry/`, it +needs an absolute majority from the maintainers of `docs/` AND, separately, an +absolute majority of the maintainers of `registry/`. + +For more details, see the [MAINTAINERS](MAINTAINERS) page. + +### Sign your work + +The sign-off is a simple line at the end of the explanation for the patch. Your +signature certifies that you wrote the patch or otherwise have the right to pass +it on as an open-source patch. The rules are pretty simple: if you can certify +the below (from [developercertificate.org](http://developercertificate.org/)): + +``` +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +660 York Street, Suite 102, +San Francisco, CA 94110 USA + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. +``` + +Then you just add a line to every git commit message: + + Signed-off-by: Joe Smith + +Use your real name (sorry, no pseudonyms or anonymous contributions.) + +If you set your `user.name` and `user.email` git configs, you can sign your +commit automatically with `git commit -s`. + +Note that the old-style `Docker-DCO-1.1-Signed-off-by: ...` format is still +accepted, so there is no need to update outstanding pull requests to the new +format right away, but please do adjust your processes for future contributions. + +### How can I become a maintainer? + +The procedures for adding new maintainers are explained in the +global [MAINTAINERS](https://github.com/docker/opensource/blob/master/MAINTAINERS) +file in the [https://github.com/docker/opensource/](https://github.com/docker/opensource/) +repository. + +Don't forget: being a maintainer is a time investment. Make sure you +will have time to make yourself available. You don't have to be a +maintainer to make a difference on the project! + +## Docker community guidelines + +We want to keep the Docker community awesome, growing and collaborative. We need +your help to keep it that way. To help with this we've come up with some general +guidelines for the community as a whole: + +* Be nice: Be courteous, respectful and polite to fellow community members: + no regional, racial, gender, or other abuse will be tolerated. We like + nice people way better than mean ones! + +* Encourage diversity and participation: Make everyone in our community feel + welcome, regardless of their background and the extent of their + contributions, and do everything possible to encourage participation in + our community. + +* Keep it legal: Basically, don't get us in trouble. Share only content that + you own, do not share private or sensitive information, and don't break + the law. + +* Stay on topic: Make sure that you are posting to the correct channel and + avoid off-topic discussions. Remember when you update an issue or respond + to an email you are potentially sending to a large number of people. Please + consider this before you update. Also remember that nobody likes spam. + +* Don't send email to the maintainers: There's no need to send email to the + maintainers to ask them to investigate an issue or to take a look at a + pull request. Instead of sending an email, GitHub mentions should be + used to ping maintainers to review a pull request, a proposal or an + issue. + +### Guideline violations — 3 strikes method + +The point of this section is not to find opportunities to punish people, but we +do need a fair way to deal with people who are making our community suck. + +1. First occurrence: We'll give you a friendly, but public reminder that the + behavior is inappropriate according to our guidelines. + +2. Second occurrence: We will send you a private message with a warning that + any additional violations will result in removal from the community. + +3. Third occurrence: Depending on the violation, we may need to delete or ban + your account. + +**Notes:** + +* Obvious spammers are banned on first occurrence. If we don't do this, we'll + have spam all over the place. + +* Violations are forgiven after 6 months of good behavior, and we won't hold a + grudge. + +* People who commit minor infractions will get some education, rather than + hammering them in the 3 strikes process. + +* The rules apply equally to everyone in the community, no matter how much + you've contributed. + +* Extreme violations of a threatening, abusive, destructive or illegal nature + will be addressed immediately and are not subject to 3 strikes or forgiveness. + +* Contact abuse@docker.com to report abuse or appeal violations. In the case of + appeals, we know that mistakes happen, and we'll work with you to come up with a + fair solution if there has been a misunderstanding. + +## Coding Style + +Unless explicitly stated, we follow all coding guidelines from the Go +community. While some of these standards may seem arbitrary, they somehow seem +to result in a solid, consistent codebase. + +It is possible that the code base does not currently comply with these +guidelines. We are not looking for a massive PR that fixes this, since that +goes against the spirit of the guidelines. All new contributions should make a +best effort to clean up and make the code base better than they left it. +Obviously, apply your best judgement. Remember, the goal here is to make the +code base easier for humans to navigate and understand. Always keep that in +mind when nudging others to comply. + +The rules: + +1. All code should be formatted with `gofmt -s`. +2. All code should pass the default levels of + [`golint`](https://github.com/golang/lint). +3. All code should follow the guidelines covered in [Effective + Go](http://golang.org/doc/effective_go.html) and [Go Code Review + Comments](https://github.com/golang/go/wiki/CodeReviewComments). +4. Comment the code. Tell us the why, the history and the context. +5. Document _all_ declarations and methods, even private ones. Declare + expectations, caveats and anything else that may be important. If a type + gets exported, having the comments already there will ensure it's ready. +6. Variable name length should be proportional to it's context and no longer. + `noCommaALongVariableNameLikeThisIsNotMoreClearWhenASimpleCommentWouldDo`. + In practice, short methods will have short variable names and globals will + have longer names. +7. No underscores in package names. If you need a compound name, step back, + and re-examine why you need a compound name. If you still think you need a + compound name, lose the underscore. +8. No utils or helpers packages. If a function is not general enough to + warrant it's own package, it has not been written generally enough to be a + part of a util package. Just leave it unexported and well-documented. +9. All tests should run with `go test` and outside tooling should not be + required. No, we don't need another unit testing framework. Assertion + packages are acceptable if they provide _real_ incremental value. +10. Even though we call these "rules" above, they are actually just + guidelines. Since you've read all the rules, you now know that. + +If you are having trouble getting into the mood of idiomatic Go, we recommend +reading through [Effective Go](http://golang.org/doc/effective_go.html). The +[Go Blog](http://blog.golang.org/) is also a great resource. Drinking the +kool-aid is a lot easier than going thirsty. diff --git a/vendor/github.com/docker/docker/Dockerfile b/vendor/github.com/docker/docker/Dockerfile new file mode 100644 index 00000000..119bbdc3 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile @@ -0,0 +1,276 @@ +# This file describes the standard way to build Docker, using docker +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. +# docker build -t docker . +# +# # Mount your source in an interactive container for quick testing: +# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash +# +# # Run the test suite: +# docker run --privileged docker hack/make.sh test +# +# # Publish a release: +# docker run --privileged \ +# -e AWS_S3_BUCKET=baz \ +# -e AWS_ACCESS_KEY=foo \ +# -e AWS_SECRET_KEY=bar \ +# -e GPG_PASSPHRASE=gloubiboulga \ +# docker hack/release.sh +# +# Note: AppArmor used to mess with privileged mode, but this is no longer +# the case. Therefore, you don't have to disable it anymore. +# + +FROM debian:jessie + +# add zfs ppa +RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys E871F18B51E0147C77796AC81196BA81F6B0FC61 \ + || apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys E871F18B51E0147C77796AC81196BA81F6B0FC61 +RUN echo deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main > /etc/apt/sources.list.d/zfs.list + +# add llvm repo +RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421 \ + || apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421 +RUN echo deb http://llvm.org/apt/jessie/ llvm-toolchain-jessie-3.8 main > /etc/apt/sources.list.d/llvm.list + +# allow replacing httpredir mirror +ARG APT_MIRROR=httpredir.debian.org +RUN sed -i s/httpredir.debian.org/$APT_MIRROR/g /etc/apt/sources.list + +# Packaged dependencies +RUN apt-get update && apt-get install -y \ + apparmor \ + apt-utils \ + aufs-tools \ + automake \ + bash-completion \ + bsdmainutils \ + btrfs-tools \ + build-essential \ + clang-3.8 \ + createrepo \ + curl \ + dpkg-sig \ + gcc-mingw-w64 \ + git \ + iptables \ + jq \ + libapparmor-dev \ + libcap-dev \ + libltdl-dev \ + libsqlite3-dev \ + libsystemd-journal-dev \ + libtool \ + mercurial \ + net-tools \ + pkg-config \ + python-dev \ + python-mock \ + python-pip \ + python-websocket \ + ubuntu-zfs \ + xfsprogs \ + libzfs-dev \ + tar \ + zip \ + --no-install-recommends \ + && pip install awscli==1.10.15 \ + && ln -snf /usr/bin/clang-3.8 /usr/local/bin/clang \ + && ln -snf /usr/bin/clang++-3.8 /usr/local/bin/clang++ + +# Get lvm2 source for compiling statically +ENV LVM2_VERSION 2.02.103 +RUN mkdir -p /usr/local/lvm2 \ + && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ + | tar -xzC /usr/local/lvm2 --strip-components=1 +# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags + +# Compile and install lvm2 +RUN cd /usr/local/lvm2 \ + && ./configure \ + --build="$(gcc -print-multiarch)" \ + --enable-static_link \ + && make device-mapper \ + && make install_device-mapper +# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + +# Configure the container for OSX cross compilation +ENV OSX_SDK MacOSX10.11.sdk +ENV OSX_CROSS_COMMIT 8aa9b71a394905e6c5f4b59e2b97b87a004658a4 +RUN set -x \ + && export OSXCROSS_PATH="/osxcross" \ + && git clone https://github.com/tpoechtrager/osxcross.git $OSXCROSS_PATH \ + && ( cd $OSXCROSS_PATH && git checkout -q $OSX_CROSS_COMMIT) \ + && curl -sSL https://s3.dockerproject.org/darwin/v2/${OSX_SDK}.tar.xz -o "${OSXCROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" \ + && UNATTENDED=yes OSX_VERSION_MIN=10.6 ${OSXCROSS_PATH}/build.sh +ENV PATH /osxcross/target/bin:$PATH + +# install seccomp: the version shipped in trusty is too old +ENV SECCOMP_VERSION 2.3.0 +RUN set -x \ + && export SECCOMP_PATH="$(mktemp -d)" \ + && curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" \ + | tar -xzC "$SECCOMP_PATH" --strip-components=1 \ + && ( \ + cd "$SECCOMP_PATH" \ + && ./configure --prefix=/usr/local \ + && make \ + && make install \ + && ldconfig \ + ) \ + && rm -rf "$SECCOMP_PATH" + +# Install Go +# IMPORTANT: If the version of Go is updated, the Windows to Linux CI machines +# will need updating, to avoid errors. Ping #docker-maintainers on IRC +# with a heads-up. +ENV GO_VERSION 1.5.4 +RUN curl -fsSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" \ + | tar -xzC /usr/local +ENV PATH /go/bin:/usr/local/go/bin:$PATH +ENV GOPATH /go:/go/src/github.com/docker/docker/vendor + +# Compile Go for cross compilation +ENV DOCKER_CROSSPLATFORMS \ + linux/386 linux/arm \ + darwin/amd64 \ + freebsd/amd64 freebsd/386 freebsd/arm \ + windows/amd64 windows/386 + +# This has been commented out and kept as reference because we don't support compiling with older Go anymore. +# ENV GOFMT_VERSION 1.3.3 +# RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt + +ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 +# Grab Go's cover tool for dead-simple code coverage testing +# Grab Go's vet tool for examining go code to find suspicious constructs +# and help prevent errors that the compiler might not catch +RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ + && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) \ + && go install -v golang.org/x/tools/cmd/cover \ + && go install -v golang.org/x/tools/cmd/vet +# Grab Go's lint tool +ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 +RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ + && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ + && go install -v github.com/golang/lint/golint + +# Install two versions of the registry. The first is an older version that +# only supports schema1 manifests. The second is a newer version that supports +# both. This allows integration-cli tests to cover push/pull with both schema1 +# and schema2 manifests. +ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd +ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry \ + && rm -rf "$GOPATH" + +# Install notary server +ENV NOTARY_VERSION docker-v1.11-3 +RUN set -x \ + && export GO15VENDOREXPERIMENT=1 \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \ + && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary \ + && rm -rf "$GOPATH" + +# Get the "docker-py" source so we can run their integration tests +ENV DOCKER_PY_COMMIT e2878cbcc3a7eef99917adc1be252800b0e41ece +RUN git clone https://github.com/docker/docker-py.git /docker-py \ + && cd /docker-py \ + && git checkout -q $DOCKER_PY_COMMIT \ + && pip install -r test-requirements.txt + +# Set user.email so crosbymichael's in-container merge commits go smoothly +RUN git config --global user.email 'docker-dummy@example.com' + +# Add an unprivileged user to be used for tests which need it +RUN groupadd -r docker +RUN useradd --create-home --gid docker unprivilegeduser + +VOLUME /var/lib/docker +WORKDIR /go/src/github.com/docker/docker +ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux + +# Let us use a .bashrc file +RUN ln -sfv $PWD/.bashrc ~/.bashrc + +# Register Docker's bash completion. +RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker + +# Get useful and necessary Hub images so we can "docker load" locally instead of pulling +COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/ +RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ + buildpack-deps:jessie@sha256:25785f89240fbcdd8a74bdaf30dd5599a9523882c6dfc567f2e9ef7cf6f79db6 \ + busybox:latest@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0 \ + debian:jessie@sha256:f968f10b4b523737e253a97eac59b0d1420b5c19b69928d35801a6373ffe330e \ + hello-world:latest@sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 +# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is) + +# Download man page generator +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b v1.0.4 https://github.com/cpuguy83/go-md2man.git "$GOPATH/src/github.com/cpuguy83/go-md2man" \ + && git clone --depth 1 -b v1.4 https://github.com/russross/blackfriday.git "$GOPATH/src/github.com/russross/blackfriday" \ + && go get -v -d github.com/cpuguy83/go-md2man \ + && go build -v -o /usr/local/bin/go-md2man github.com/cpuguy83/go-md2man \ + && rm -rf "$GOPATH" + +# Download toml validator +ENV TOMLV_COMMIT 9baf8a8a9f2ed20a8e54160840c492f937eeaf9a +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" \ + && (cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT") \ + && go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ + && rm -rf "$GOPATH" + +# Build/install the tool for embedding resources in Windows binaries +ENV RSRC_COMMIT ba14da1f827188454a4591717fff29999010887f +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ + && (cd "$GOPATH/src/github.com/akavel/rsrc" && git checkout -q "$RSRC_COMMIT") \ + && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ + && rm -rf "$GOPATH" + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="seccomp apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +# Wrap all commands in the "docker-in-docker" script to allow nested containers +ENTRYPOINT ["hack/dind"] + +# Upload docker source +COPY . /go/src/github.com/docker/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.aarch64 b/vendor/github.com/docker/docker/Dockerfile.aarch64 new file mode 100644 index 00000000..ec59c7eb --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.aarch64 @@ -0,0 +1,209 @@ +# This file describes the standard way to build Docker on aarch64, using docker +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. +# docker build -t docker -f Dockerfile.aarch64 . +# +# # Mount your source in an interactive container for quick testing: +# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash +# +# # Run the test suite: +# docker run --privileged docker hack/make.sh test +# +# Note: AppArmor used to mess with privileged mode, but this is no longer +# the case. Therefore, you don't have to disable it anymore. +# + +FROM aarch64/ubuntu:wily + +# Packaged dependencies +RUN apt-get update && apt-get install -y \ + apparmor \ + aufs-tools \ + automake \ + bash-completion \ + btrfs-tools \ + build-essential \ + createrepo \ + curl \ + dpkg-sig \ + g++ \ + gcc \ + git \ + iptables \ + jq \ + libapparmor-dev \ + libc6-dev \ + libcap-dev \ + libsqlite3-dev \ + libsystemd-dev \ + mercurial \ + net-tools \ + parallel \ + pkg-config \ + python-dev \ + python-mock \ + python-pip \ + python-websocket \ + gccgo \ + --no-install-recommends + +# Install armhf loader to use armv6 binaries on armv8 +RUN dpkg --add-architecture armhf \ + && apt-get update \ + && apt-get install -y libc6:armhf + +# Get lvm2 source for compiling statically +ENV LVM2_VERSION 2.02.103 +RUN mkdir -p /usr/local/lvm2 \ + && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ + | tar -xzC /usr/local/lvm2 --strip-components=1 +# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags + +# fix platform enablement in lvm2 to support aarch64 properly +RUN set -e \ + && for f in config.guess config.sub; do \ + curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ + done +# "arch.c:78:2: error: #error the arch code needs to know about your machine type" + +# Compile and install lvm2 +RUN cd /usr/local/lvm2 \ + && ./configure \ + --build="$(gcc -print-multiarch)" \ + --enable-static_link \ + && make device-mapper \ + && make install_device-mapper +# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + +# install seccomp: the version shipped in trusty is too old +ENV SECCOMP_VERSION 2.3.0 +RUN set -x \ + && export SECCOMP_PATH="$(mktemp -d)" \ + && curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" \ + | tar -xzC "$SECCOMP_PATH" --strip-components=1 \ + && ( \ + cd "$SECCOMP_PATH" \ + && ./configure --prefix=/usr/local \ + && make \ + && make install \ + && ldconfig \ + ) \ + && rm -rf "$SECCOMP_PATH" + +# Install Go +# We don't have official binary tarballs for ARM64, eigher for Go or bootstrap, +# so we use the official armv6 released binaries as a GOROOT_BOOTSTRAP, and +# build Go from source code. +ENV GO_VERSION 1.5.4 +RUN mkdir /usr/src/go && curl -fsSL https://storage.googleapis.com/golang/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/src/go -xz --strip-components=1 \ + && cd /usr/src/go/src \ + && GOOS=linux GOARCH=arm64 GOROOT_BOOTSTRAP="$(go env GOROOT)" ./make.bash + +ENV PATH /usr/src/go/bin:$PATH +ENV GOPATH /go:/go/src/github.com/docker/docker/vendor + +# Only install one version of the registry, because old version which support +# schema1 manifests is not working on ARM64, we should skip integration-cli +# tests for schema1 manifests on ARM64. +ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \ + && rm -rf "$GOPATH" + +# Install notary server +ENV NOTARY_VERSION docker-v1.11-3 +RUN set -x \ + && export GO15VENDOREXPERIMENT=1 \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \ + && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary \ + && rm -rf "$GOPATH" + +# Get the "docker-py" source so we can run their integration tests +ENV DOCKER_PY_COMMIT e2878cbcc3a7eef99917adc1be252800b0e41ece +RUN git clone https://github.com/docker/docker-py.git /docker-py \ + && cd /docker-py \ + && git checkout -q $DOCKER_PY_COMMIT \ + && pip install -r test-requirements.txt + +# Set user.email so crosbymichael's in-container merge commits go smoothly +RUN git config --global user.email 'docker-dummy@example.com' + +# Add an unprivileged user to be used for tests which need it +RUN groupadd -r docker +RUN useradd --create-home --gid docker unprivilegeduser + +VOLUME /var/lib/docker +WORKDIR /go/src/github.com/docker/docker +ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux + +# Let us use a .bashrc file +RUN ln -sfv $PWD/.bashrc ~/.bashrc + +# Register Docker's bash completion. +RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker + +# Get useful and necessary Hub images so we can "docker load" locally instead of pulling +COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/ +RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ + aarch64/buildpack-deps:jessie@sha256:6aa1d6910791b7ac78265fd0798e5abd6cb3f27ae992f6f960f6c303ec9535f2 \ + aarch64/busybox:latest@sha256:b23a6a37cf269dff6e46d2473b6e227afa42b037e6d23435f1d2bc40fc8c2828 \ + aarch64/debian:jessie@sha256:4be74a41a7c70ebe887b634b11ffe516cf4fcd56864a54941e56bb49883c3170 \ + aarch64/hello-world:latest@sha256:65a4a158587b307bb02db4de41b836addb0c35175bdc801367b1ac1ddeb9afda +# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is) + +# Download man page generator +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b v1.0.4 https://github.com/cpuguy83/go-md2man.git "$GOPATH/src/github.com/cpuguy83/go-md2man" \ + && git clone --depth 1 -b v1.4 https://github.com/russross/blackfriday.git "$GOPATH/src/github.com/russross/blackfriday" \ + && go get -v -d github.com/cpuguy83/go-md2man \ + && go build -v -o /usr/local/bin/go-md2man github.com/cpuguy83/go-md2man \ + && rm -rf "$GOPATH" + +# Download toml validator +ENV TOMLV_COMMIT 9baf8a8a9f2ed20a8e54160840c492f937eeaf9a +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" \ + && (cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT") \ + && go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ + && rm -rf "$GOPATH" + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="seccomp apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +# Wrap all commands in the "docker-in-docker" script to allow nested containers +ENTRYPOINT ["hack/dind"] + +# Upload docker source +COPY . /go/src/github.com/docker/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.armhf b/vendor/github.com/docker/docker/Dockerfile.armhf new file mode 100644 index 00000000..5fd48805 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.armhf @@ -0,0 +1,227 @@ +# This file describes the standard way to build Docker on ARMv7, using docker +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. +# docker build -t docker -f Dockerfile.armhf . +# +# # Mount your source in an interactive container for quick testing: +# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash +# +# # Run the test suite: +# docker run --privileged docker hack/make.sh test +# +# Note: AppArmor used to mess with privileged mode, but this is no longer +# the case. Therefore, you don't have to disable it anymore. +# + +FROM armhf/debian:jessie + +# Packaged dependencies +RUN apt-get update && apt-get install -y \ + apparmor \ + aufs-tools \ + automake \ + bash-completion \ + btrfs-tools \ + build-essential \ + createrepo \ + curl \ + dpkg-sig \ + git \ + iptables \ + jq \ + net-tools \ + libapparmor-dev \ + libcap-dev \ + libltdl-dev \ + libsqlite3-dev \ + libsystemd-journal-dev \ + libtool \ + mercurial \ + pkg-config \ + python-dev \ + python-mock \ + python-pip \ + python-websocket \ + xfsprogs \ + tar \ + --no-install-recommends + +# Get lvm2 source for compiling statically +ENV LVM2_VERSION 2.02.103 +RUN mkdir -p /usr/local/lvm2 \ + && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ + | tar -xzC /usr/local/lvm2 --strip-components=1 +# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags + +# Compile and install lvm2 +RUN cd /usr/local/lvm2 \ + && ./configure \ + --build="$(gcc -print-multiarch)" \ + --enable-static_link \ + && make device-mapper \ + && make install_device-mapper +# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + +# Install Go +# TODO Update to 1.5.4 once available, or build from source, as these builds +# are marked "end of life", see http://dave.cheney.net/unofficial-arm-tarballs +ENV GO_VERSION 1.5.3 +RUN curl -fsSL "http://dave.cheney.net/paste/go${GO_VERSION}.linux-arm.tar.gz" \ + | tar -xzC /usr/local +ENV PATH /go/bin:/usr/local/go/bin:$PATH +ENV GOPATH /go:/go/src/github.com/docker/docker/vendor + +# we're building for armhf, which is ARMv7, so let's be explicit about that +ENV GOARCH arm +ENV GOARM 7 + +# This has been commented out and kept as reference because we don't support compiling with older Go anymore. +# ENV GOFMT_VERSION 1.3.3 +# RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt + +ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 +# Grab Go's cover tool for dead-simple code coverage testing +# Grab Go's vet tool for examining go code to find suspicious constructs +# and help prevent errors that the compiler might not catch +RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ + && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) \ + && go install -v golang.org/x/tools/cmd/cover \ + && go install -v golang.org/x/tools/cmd/vet +# Grab Go's lint tool +ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 +RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ + && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ + && go install -v github.com/golang/lint/golint + +# install seccomp: the version shipped in trusty is too old +ENV SECCOMP_VERSION 2.3.0 +RUN set -x \ + && export SECCOMP_PATH="$(mktemp -d)" \ + && curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" \ + | tar -xzC "$SECCOMP_PATH" --strip-components=1 \ + && ( \ + cd "$SECCOMP_PATH" \ + && ./configure --prefix=/usr/local \ + && make \ + && make install \ + && ldconfig \ + ) \ + && rm -rf "$SECCOMP_PATH" + +# Install two versions of the registry. The first is an older version that +# only supports schema1 manifests. The second is a newer version that supports +# both. This allows integration-cli tests to cover push/pull with both schema1 +# and schema2 manifests. +ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd +ENV REGISTRY_COMMIT cb08de17d74bef86ce6c5abe8b240e282f5750be +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry \ + && rm -rf "$GOPATH" + +# Install notary server +ENV NOTARY_VERSION docker-v1.11-3 +RUN set -x \ + && export GO15VENDOREXPERIMENT=1 \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \ + && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary \ + && rm -rf "$GOPATH" + +# Get the "docker-py" source so we can run their integration tests +ENV DOCKER_PY_COMMIT e2878cbcc3a7eef99917adc1be252800b0e41ece +RUN git clone https://github.com/docker/docker-py.git /docker-py \ + && cd /docker-py \ + && git checkout -q $DOCKER_PY_COMMIT \ + && pip install -r test-requirements.txt + +# Set user.email so crosbymichael's in-container merge commits go smoothly +RUN git config --global user.email 'docker-dummy@example.com' + +# Add an unprivileged user to be used for tests which need it +RUN groupadd -r docker +RUN useradd --create-home --gid docker unprivilegeduser + +VOLUME /var/lib/docker +WORKDIR /go/src/github.com/docker/docker +ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux + +# Let us use a .bashrc file +RUN ln -sfv $PWD/.bashrc ~/.bashrc + +# Register Docker's bash completion. +RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker + +# Get useful and necessary Hub images so we can "docker load" locally instead of pulling +COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/ +RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ + armhf/buildpack-deps:jessie@sha256:ca6cce8e5bf5c952129889b5cc15cd6aa8d995d77e55e3749bbaadae50e476cb \ + armhf/busybox:latest@sha256:d98a7343ac750ffe387e3d514f8521ba69846c216778919b01414b8617cfb3d4 \ + armhf/debian:jessie@sha256:4a2187483f04a84f9830910fe3581d69b3c985cc045d9f01d8e2f3795b28107b \ + armhf/hello-world:latest@sha256:161dcecea0225975b2ad5f768058212c1e0d39e8211098666ffa1ac74cfb7791 +# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is) + +# Download man page generator +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b v1.0.4 https://github.com/cpuguy83/go-md2man.git "$GOPATH/src/github.com/cpuguy83/go-md2man" \ + && git clone --depth 1 -b v1.4 https://github.com/russross/blackfriday.git "$GOPATH/src/github.com/russross/blackfriday" \ + && go get -v -d github.com/cpuguy83/go-md2man \ + && go build -v -o /usr/local/bin/go-md2man github.com/cpuguy83/go-md2man \ + && rm -rf "$GOPATH" + +# Download toml validator +ENV TOMLV_COMMIT 9baf8a8a9f2ed20a8e54160840c492f937eeaf9a +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" \ + && (cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT") \ + && go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ + && rm -rf "$GOPATH" + +# Build/install the tool for embedding resources in Windows binaries +ENV RSRC_VERSION v2 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b "$RSRC_VERSION" https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ + && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ + && rm -rf "$GOPATH" + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="seccomp apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +ENTRYPOINT ["hack/dind"] + +# Upload docker source +COPY . /go/src/github.com/docker/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.gccgo b/vendor/github.com/docker/docker/Dockerfile.gccgo new file mode 100644 index 00000000..1156a973 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.gccgo @@ -0,0 +1,102 @@ +# This file describes the standard way to build Docker, using docker +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. +# docker build -t docker -f Dockerfile.gccgo . +# + +FROM gcc:5.3 + +# Packaged dependencies +RUN apt-get update && apt-get install -y \ + apparmor \ + aufs-tools \ + btrfs-tools \ + build-essential \ + curl \ + git \ + iptables \ + jq \ + net-tools \ + libapparmor-dev \ + libcap-dev \ + libsqlite3-dev \ + mercurial \ + net-tools \ + parallel \ + python-dev \ + python-mock \ + python-pip \ + python-websocket \ + --no-install-recommends + +# Get lvm2 source for compiling statically +RUN git clone -b v2_02_103 https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2 +# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags + +# Compile and install lvm2 +RUN cd /usr/local/lvm2 \ + && ./configure --enable-static_link \ + && make device-mapper \ + && make install_device-mapper +# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + +# install seccomp: the version shipped in jessie is too old +ENV SECCOMP_VERSION v2.3.0 +RUN set -x \ + && export SECCOMP_PATH=$(mktemp -d) \ + && git clone https://github.com/seccomp/libseccomp.git "$SECCOMP_PATH" \ + && ( \ + cd "$SECCOMP_PATH" \ + && git checkout "$SECCOMP_VERSION" \ + && ./autogen.sh \ + && ./configure --prefix=/usr \ + && make \ + && make install \ + ) \ + && rm -rf "$SECCOMP_PATH" + +ENV GOPATH /go:/go/src/github.com/docker/docker/vendor + +# Get the "docker-py" source so we can run their integration tests +ENV DOCKER_PY_COMMIT e2878cbcc3a7eef99917adc1be252800b0e41ece +RUN git clone https://github.com/docker/docker-py.git /docker-py \ + && cd /docker-py \ + && git checkout -q $DOCKER_PY_COMMIT + +# Add an unprivileged user to be used for tests which need it +RUN groupadd -r docker +RUN useradd --create-home --gid docker unprivilegeduser + +VOLUME /var/lib/docker +WORKDIR /go/src/github.com/docker/docker +ENV DOCKER_BUILDTAGS apparmor seccomp selinux + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="seccomp apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +# Wrap all commands in the "docker-in-docker" script to allow nested containers +ENTRYPOINT ["hack/dind"] + +# Upload docker source +COPY . /go/src/github.com/docker/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.ppc64le b/vendor/github.com/docker/docker/Dockerfile.ppc64le new file mode 100644 index 00000000..2b7411e7 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.ppc64le @@ -0,0 +1,227 @@ +# This file describes the standard way to build Docker on ppc64le, using docker +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. +# docker build -t docker -f Dockerfile.ppc64le . +# +# # Mount your source in an interactive container for quick testing: +# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash +# +# # Run the test suite: +# docker run --privileged docker hack/make.sh test +# +# Note: AppArmor used to mess with privileged mode, but this is no longer +# the case. Therefore, you don't have to disable it anymore. +# + +FROM ppc64le/gcc:5.3 + +# Packaged dependencies +RUN apt-get update && apt-get install -y \ + apparmor \ + aufs-tools \ + automake \ + bash-completion \ + btrfs-tools \ + build-essential \ + createrepo \ + curl \ + dpkg-sig \ + git \ + iptables \ + jq \ + net-tools \ + libapparmor-dev \ + libcap-dev \ + libltdl-dev \ + libsqlite3-dev \ + libsystemd-journal-dev \ + libtool \ + mercurial \ + pkg-config \ + python-dev \ + python-mock \ + python-pip \ + python-websocket \ + xfsprogs \ + tar \ + --no-install-recommends + +# Get lvm2 source for compiling statically +ENV LVM2_VERSION 2.02.103 +RUN mkdir -p /usr/local/lvm2 \ + && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ + | tar -xzC /usr/local/lvm2 --strip-components=1 +# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags + +# fix platform enablement in lvm2 to support ppc64le properly +RUN set -e \ + && for f in config.guess config.sub; do \ + curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ + done +# "arch.c:78:2: error: #error the arch code needs to know about your machine type" + +# Compile and install lvm2 +RUN cd /usr/local/lvm2 \ + && ./configure \ + --build="$(gcc -print-multiarch)" \ + --enable-static_link \ + && make device-mapper \ + && make install_device-mapper +# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + +# TODO install Go, using gccgo as GOROOT_BOOTSTRAP (Go 1.5+ supports ppc64le properly) +# possibly a ppc64le/golang image? + +## BUILD GOLANG +ENV GO_VERSION 1.5.4 +ENV GO_DOWNLOAD_URL https://golang.org/dl/go${GO_VERSION}.src.tar.gz +ENV GO_DOWNLOAD_SHA256 002acabce7ddc140d0d55891f9d4fcfbdd806b9332fb8b110c91bc91afb0bc93 +ENV GOROOT_BOOTSTRAP /usr/local + +RUN curl -fsSL "$GO_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GO_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ + && tar -C /usr/src -xzf golang.tar.gz \ + && rm golang.tar.gz \ + && cd /usr/src/go/src && ./make.bash 2>&1 + +ENV GOROOT_BOOTSTRAP /usr/src/ + +ENV PATH /usr/src/go/bin/:/go/bin:$PATH +ENV GOPATH /go:/go/src/github.com/docker/docker/vendor + +# This has been commented out and kept as reference because we don't support compiling with older Go anymore. +# ENV GOFMT_VERSION 1.3.3 +# RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt + +ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3 +# Grab Go's cover tool for dead-simple code coverage testing +# Grab Go's vet tool for examining go code to find suspicious constructs +# and help prevent errors that the compiler might not catch +RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ + && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) \ + && go install -v golang.org/x/tools/cmd/cover \ + && go install -v golang.org/x/tools/cmd/vet +# Grab Go's lint tool +ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456 +RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ + && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ + && go install -v github.com/golang/lint/golint + +# Install two versions of the registry. The first is an older version that +# only supports schema1 manifests. The second is a newer version that supports +# both. This allows integration-cli tests to cover push/pull with both schema1 +# and schema2 manifests. +ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd +ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry \ + && rm -rf "$GOPATH" + +# Install notary and notary-server +ENV NOTARY_VERSION docker-v1.11-3 +RUN set -x \ + && export GO15VENDOREXPERIMENT=1 \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \ + && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary \ + && rm -rf "$GOPATH" + +# Get the "docker-py" source so we can run their integration tests +ENV DOCKER_PY_COMMIT e2878cbcc3a7eef99917adc1be252800b0e41ece +RUN git clone https://github.com/docker/docker-py.git /docker-py \ + && cd /docker-py \ + && git checkout -q $DOCKER_PY_COMMIT \ + && pip install -r test-requirements.txt + +# Set user.email so crosbymichael's in-container merge commits go smoothly +RUN git config --global user.email 'docker-dummy@example.com' + +# Add an unprivileged user to be used for tests which need it +RUN groupadd -r docker +RUN useradd --create-home --gid docker unprivilegeduser + +VOLUME /var/lib/docker +WORKDIR /go/src/github.com/docker/docker +ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux + +# Let us use a .bashrc file +RUN ln -sfv $PWD/.bashrc ~/.bashrc + +# Register Docker's bash completion. +RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker + +# Get useful and necessary Hub images so we can "docker load" locally instead of pulling +COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/ +RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ + ppc64le/buildpack-deps:jessie@sha256:902bfe4ef1389f94d143d64516dd50a2de75bca2e66d4a44b1d73f63ddf05dda \ + ppc64le/busybox:latest@sha256:38bb82085248d5a3c24bd7a5dc146f2f2c191e189da0441f1c2ca560e3fc6f1b \ + ppc64le/debian:jessie@sha256:412845f51b6ab662afba71bc7a716e20fdb9b84f185d180d4c7504f8a75c4f91 \ + ppc64le/hello-world:latest@sha256:186a40a9a02ca26df0b6c8acdfb8ac2f3ae6678996a838f977e57fac9d963974 +# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is) + +# Download man page generator +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b v1.0.4 https://github.com/cpuguy83/go-md2man.git "$GOPATH/src/github.com/cpuguy83/go-md2man" \ + && git clone --depth 1 -b v1.4 https://github.com/russross/blackfriday.git "$GOPATH/src/github.com/russross/blackfriday" \ + && go get -v -d github.com/cpuguy83/go-md2man \ + && go build -v -o /usr/local/bin/go-md2man github.com/cpuguy83/go-md2man \ + && rm -rf "$GOPATH" + +# Download toml validator +ENV TOMLV_COMMIT 9baf8a8a9f2ed20a8e54160840c492f937eeaf9a +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" \ + && (cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT") \ + && go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ + && rm -rf "$GOPATH" + +# Build/install the tool for embedding resources in Windows binaries +ENV RSRC_VERSION v2 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b "$RSRC_VERSION" https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ + && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ + && rm -rf "$GOPATH" + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +# Wrap all commands in the "docker-in-docker" script to allow nested containers +ENTRYPOINT ["hack/dind"] + +# Upload docker source +COPY . /go/src/github.com/docker/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.s390x b/vendor/github.com/docker/docker/Dockerfile.s390x new file mode 100644 index 00000000..00b551e0 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.s390x @@ -0,0 +1,206 @@ +# This file describes the standard way to build Docker on s390x, using docker +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. +# docker build -t docker -f Dockerfile.s390x . +# +# # Mount your source in an interactive container for quick testing: +# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash +# +# # Run the test suite: +# docker run --privileged docker hack/make.sh test +# +# Note: AppArmor used to mess with privileged mode, but this is no longer +# the case. Therefore, you don't have to disable it anymore. +# + +FROM s390x/gcc:5.3 + +# Packaged dependencies +RUN apt-get update && apt-get install -y \ + apparmor \ + aufs-tools \ + automake \ + bash-completion \ + btrfs-tools \ + build-essential \ + createrepo \ + curl \ + dpkg-sig \ + git \ + iptables \ + jq \ + net-tools \ + libapparmor-dev \ + libcap-dev \ + libltdl-dev \ + libsqlite3-dev \ + libsystemd-journal-dev \ + libtool \ + mercurial \ + pkg-config \ + python-dev \ + python-mock \ + python-pip \ + python-websocket \ + xfsprogs \ + tar \ + --no-install-recommends + +# Get lvm2 source for compiling statically +ENV LVM2_VERSION 2.02.103 +RUN mkdir -p /usr/local/lvm2 \ + && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ + | tar -xzC /usr/local/lvm2 --strip-components=1 +# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags + +# fix platform enablement in lvm2 to support s390x properly +RUN set -e \ + && for f in config.guess config.sub; do \ + curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ + done +# "arch.c:78:2: error: #error the arch code needs to know about your machine type" + +# Compile and install lvm2 +RUN cd /usr/local/lvm2 \ + && ./configure \ + --build="$(gcc -print-multiarch)" \ + --enable-static_link \ + && make device-mapper \ + && make install_device-mapper +# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + +# Note: Go comes from the base image (gccgo, specifically) +# We can't compile Go proper because s390x isn't an officially supported architecture yet. + +ENV PATH /go/bin:$PATH +ENV GOPATH /go:/go/src/github.com/docker/docker/vendor + +# This has been commented out and kept as reference because we don't support compiling with older Go anymore. +# ENV GOFMT_VERSION 1.3.3 +# RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt + +# TODO update this sha when we upgrade to Go 1.5+ +ENV GO_TOOLS_COMMIT 069d2f3bcb68257b627205f0486d6cc69a231ff9 +# Grab Go's cover tool for dead-simple code coverage testing +# Grab Go's vet tool for examining go code to find suspicious constructs +# and help prevent errors that the compiler might not catch +RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \ + && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT) \ + && go install -v golang.org/x/tools/cmd/cover \ + && go install -v golang.org/x/tools/cmd/vet +# Grab Go's lint tool +ENV GO_LINT_COMMIT f42f5c1c440621302702cb0741e9d2ca547ae80f +RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \ + && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ + && go install -v github.com/golang/lint/golint + + +# Install registry +ENV REGISTRY_COMMIT ec87e9b6971d831f0eff752ddb54fb64693e51cd +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ + && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ + && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ + go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \ + && rm -rf "$GOPATH" + +# Install notary server +ENV NOTARY_VERSION docker-v1.11-3 +RUN set -x \ + && export GO15VENDOREXPERIMENT=1 \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \ + && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \ + && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \ + go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \ + && rm -rf "$GOPATH" + +# Get the "docker-py" source so we can run their integration tests +ENV DOCKER_PY_COMMIT e2878cbcc3a7eef99917adc1be252800b0e41ece +RUN git clone https://github.com/docker/docker-py.git /docker-py \ + && cd /docker-py \ + && git checkout -q $DOCKER_PY_COMMIT \ + && pip install -r test-requirements.txt + +# Set user.email so crosbymichael's in-container merge commits go smoothly +RUN git config --global user.email 'docker-dummy@example.com' + +# Add an unprivileged user to be used for tests which need it +RUN groupadd -r docker +RUN useradd --create-home --gid docker unprivilegeduser + +VOLUME /var/lib/docker +WORKDIR /go/src/github.com/docker/docker +ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux + +# Let us use a .bashrc file +RUN ln -sfv $PWD/.bashrc ~/.bashrc + +# Register Docker's bash completion. +RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker + +# Get useful and necessary Hub images so we can "docker load" locally instead of pulling +COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/ +RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \ + s390x/buildpack-deps:jessie@sha256:4d1381224acaca6c4bfe3604de3af6972083a8558a99672cb6989c7541780099 \ + s390x/busybox:latest@sha256:dd61522c983884a66ed72d60301925889028c6d2d5e0220a8fe1d9b4c6a4f01b \ + s390x/debian:jessie@sha256:b74c863400909eff3c5e196cac9bfd1f6333ce47aae6a38398d87d5875da170a \ + s390x/hello-world:latest@sha256:780d80b3a7677c3788c0d5cd9168281320c8d4a6d9183892d8ee5cdd610f5699 +# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is) + +# Download man page generator +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b v1.0.4 https://github.com/cpuguy83/go-md2man.git "$GOPATH/src/github.com/cpuguy83/go-md2man" \ + && git clone --depth 1 -b v1.4 https://github.com/russross/blackfriday.git "$GOPATH/src/github.com/russross/blackfriday" \ + && go get -v -d github.com/cpuguy83/go-md2man \ + && go build -v -o /usr/local/bin/go-md2man github.com/cpuguy83/go-md2man \ + && rm -rf "$GOPATH" + +# Download toml validator +ENV TOMLV_COMMIT 9baf8a8a9f2ed20a8e54160840c492f937eeaf9a +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" \ + && (cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT") \ + && go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ + && rm -rf "$GOPATH" + +# Build/install the tool for embedding resources in Windows binaries +ENV RSRC_VERSION v2 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone --depth 1 -b "$RSRC_VERSION" https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ + && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ + && rm -rf "$GOPATH" + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="seccomp apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +# Wrap all commands in the "docker-in-docker" script to allow nested containers +ENTRYPOINT ["hack/dind"] + +# Upload docker source +COPY . /go/src/github.com/docker/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.simple b/vendor/github.com/docker/docker/Dockerfile.simple new file mode 100644 index 00000000..aabadada --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.simple @@ -0,0 +1,56 @@ +# docker build -t docker:simple -f Dockerfile.simple . +# docker run --rm docker:simple hack/make.sh dynbinary +# docker run --rm --privileged docker:simple hack/dind hack/make.sh test-unit +# docker run --rm --privileged -v /var/lib/docker docker:simple hack/dind hack/make.sh dynbinary test-integration-cli + +# This represents the bare minimum required to build and test Docker. + +FROM debian:jessie + +# compile and runtime deps +# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#build-dependencies +# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + btrfs-tools \ + curl \ + gcc \ + git \ + golang \ + libdevmapper-dev \ + libsqlite3-dev \ + \ + ca-certificates \ + e2fsprogs \ + iptables \ + procps \ + xfsprogs \ + xz-utils \ + \ + aufs-tools \ + && rm -rf /var/lib/apt/lists/* + +# Install runc +ENV RUNC_COMMIT baf6536d6259209c3edfa2b22237af82942d3dfa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc" \ + && cd "$GOPATH/src/github.com/opencontainers/runc" \ + && git checkout -q "$RUNC_COMMIT" \ + && make static BUILDTAGS="seccomp apparmor selinux" \ + && cp runc /usr/local/bin/docker-runc + +# Install containerd +ENV CONTAINERD_COMMIT v0.2.1 +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone git://github.com/docker/containerd.git "$GOPATH/src/github.com/docker/containerd" \ + && cd "$GOPATH/src/github.com/docker/containerd" \ + && git checkout -q "$CONTAINERD_COMMIT" \ + && make static \ + && cp bin/containerd /usr/local/bin/docker-containerd \ + && cp bin/containerd-shim /usr/local/bin/docker-containerd-shim \ + && cp bin/ctr /usr/local/bin/docker-containerd-ctr + +ENV AUTO_GOPATH 1 +WORKDIR /usr/src/docker +COPY . /usr/src/docker diff --git a/vendor/github.com/docker/docker/Dockerfile.windows b/vendor/github.com/docker/docker/Dockerfile.windows new file mode 100755 index 00000000..d288ab62 --- /dev/null +++ b/vendor/github.com/docker/docker/Dockerfile.windows @@ -0,0 +1,101 @@ +# This file describes the standard way to build Docker, using a docker container on Windows +# Server 2016 +# +# Usage: +# +# # Assemble the full dev environment. This is slow the first time. Run this from +# # a directory containing the sources you are validating. For example from +# # c:\go\src\github.com\docker\docker +# +# docker build -t docker -f Dockerfile.windows . +# +# +# # Build docker in a container. Run the following from a Windows cmd command prommpt, +# # replacing c:\built with the directory you want the binaries to be placed on the +# # host system. +# +# docker run --rm -v "c:\built:c:\target" docker sh -c 'cd /c/go/src/github.com/docker/docker; hack/make.sh binary; ec=$?; if [ $ec -eq 0 ]; then robocopy /c/go/src/github.com/docker/docker/bundles/$(cat VERSION)/binary /c/target/binary; fi; exit $ec' +# +# Important notes: +# --------------- +# +# 'Start-Sleep' is a deliberate workaround for a current problem on containers in Windows +# Server 2016. It ensures that the network is up and available for when the command is +# network related. This bug is being tracked internally at Microsoft and exists in TP4. +# Generally sleep 1 or 2 is probably enough, but making it 5 to make the build file +# as bullet proof as possible. This isn't a big deal as this only runs the first time. +# +# The cygwin posix utilities from GIT aren't usable interactively as at January 2016. This +# is because they require a console window which isn't present in a container in Windows. +# See the example at the top of this file. Do NOT use -it in that docker run!!! +# +# Don't try to use a volume for passing the source through. The cygwin posix utilities will +# balk at reparse points. Again, see the example at the top of this file on how use a volume +# to get the built binary out of the container. +# +# The steps are minimised dramatically to improve performance (TP4 is slow on commit) + +FROM windowsservercore + +# Environment variable notes: +# - GO_VERSION must consistent with 'Dockerfile' used by Linux'. +# - FROM_DOCKERFILE is used for detection of building within a container. +ENV GO_VERSION=1.5.4 \ + GIT_LOCATION=https://github.com/git-for-windows/git/releases/download/v2.7.2.windows.1/Git-2.7.2-64-bit.exe \ + RSRC_COMMIT=ba14da1f827188454a4591717fff29999010887f \ + GOPATH=C:/go;C:/go/src/github.com/docker/docker/vendor \ + FROM_DOCKERFILE=1 + +WORKDIR c:/ + +# Everything downloaded/installed in one go (better performance, esp on TP4) +RUN \ + setx /M Path "c:\git\cmd;c:\git\bin;c:\git\usr\bin;%Path%;c:\gcc\bin;c:\go\bin" && \ + setx GOROOT "c:\go" && \ + powershell -command \ + $ErrorActionPreference = 'Stop'; \ + Start-Sleep -Seconds 5; \ + Function Download-File([string] $source, [string] $target) { \ + $wc = New-Object net.webclient; $wc.Downloadfile($source, $target) \ + } \ + \ + Write-Host INFO: Downloading git...; \ + Download-File %GIT_LOCATION% gitsetup.exe; \ + \ + Write-Host INFO: Downloading go...; \ + Download-File https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.msi go.msi; \ + \ + Write-Host INFO: Downloading compiler 1 of 3...; \ + Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/gcc.zip gcc.zip; \ + \ + Write-Host INFO: Downloading compiler 2 of 3...; \ + Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/runtime.zip runtime.zip; \ + \ + Write-Host INFO: Downloading compiler 3 of 3...; \ + Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/binutils.zip binutils.zip; \ + \ + Write-Host INFO: Installing git...; \ + Start-Process gitsetup.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=c:\git\' -Wait; \ + \ + Write-Host INFO: Installing go..."; \ + Start-Process msiexec -ArgumentList '-i go.msi -quiet' -Wait; \ + \ + Write-Host INFO: Unzipping compiler...; \ + c:\git\usr\bin\unzip.exe -q -o gcc.zip -d /c/gcc; \ + c:\git\usr\bin\unzip.exe -q -o runtime.zip -d /c/gcc; \ + c:\git\usr\bin\unzip.exe -q -o binutils.zip -d /c/gcc"; \ + \ + Write-Host INFO: Removing interim files; \ + Remove-Item *.zip; \ + Remove-Item go.msi; \ + Remove-Item gitsetup.exe; \ + \ + Write-Host INFO: Cloning and installing RSRC; \ + c:\git\bin\git.exe clone https://github.com/akavel/rsrc.git c:\go\src\github.com\akavel\rsrc; \ + cd \go\src\github.com\akavel\rsrc; c:\git\bin\git.exe checkout -q %RSRC_COMMIT%; c:\go\bin\go.exe install -v; \ + \ + Write-Host INFO: Completed + +# Prepare for building +COPY . /go/src/github.com/docker/docker + diff --git a/vendor/github.com/docker/docker/LICENSE b/vendor/github.com/docker/docker/LICENSE new file mode 100644 index 00000000..8f3fee62 --- /dev/null +++ b/vendor/github.com/docker/docker/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + https://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 + + Copyright 2013-2016 Docker, 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 + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT 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/docker/MAINTAINERS b/vendor/github.com/docker/docker/MAINTAINERS new file mode 100644 index 00000000..802e288a --- /dev/null +++ b/vendor/github.com/docker/docker/MAINTAINERS @@ -0,0 +1,255 @@ +# Docker maintainers file +# +# This file describes who runs the docker/docker project and how. +# This is a living document - if you see something out of date or missing, speak up! +# +# It is structured to be consumable by both humans and programs. +# To extract its contents programmatically, use any TOML-compliant +# parser. +# +# This file is compiled into the MAINTAINERS file in docker/opensource. +# +[Org] + + [Org."Core maintainers"] + + # The Core maintainers are the ghostbusters of the project: when there's a problem others + # can't solve, they show up and fix it with bizarre devices and weaponry. + # They have final say on technical implementation and coding style. + # They are ultimately responsible for quality in all its forms: usability polish, + # bugfixes, performance, stability, etc. When ownership can cleanly be passed to + # a subsystem, they are responsible for doing so and holding the + # subsystem maintainers accountable. If ownership is unclear, they are the de facto owners. + + # For each release (including minor releases), a "release captain" is assigned from the + # pool of core maintainers. Rotation is encouraged across all maintainers, to ensure + # the release process is clear and up-to-date. + + people = [ + "aaronlehmann", + "calavera", + "coolljt0725", + "cpuguy83", + "crosbymichael", + "duglin", + "estesp", + "icecrime", + "jhowardmsft", + "jfrazelle", + "lk4d4", + "mhbauer", + "runcom", + "tianon", + "tibor", + "tonistiigi", + "unclejack", + "vbatts", + "vdemeester" + ] + + [Org."Docs maintainers"] + + # TODO Describe the docs maintainers role. + + people = [ + "jamtur01", + "moxiegirl", + "sven", + "thajeztah" + ] + + [Org.Curators] + + # The curators help ensure that incoming issues and pull requests are properly triaged and + # that our various contribution and reviewing processes are respected. With their knowledge of + # the repository activity, they can also guide contributors to relevant material or + # discussions. + # + # They are neither code nor docs reviewers, so they are never expected to merge. They can + # however: + # - close an issue or pull request when it's an exact duplicate + # - close an issue or pull request when it's inappropriate or off-topic + + people = [ + "programmerq", + "thajeztah" + ] + + [Org.Alumni] + + # This list contains maintainers that are no longer active on the project. + # It is thanks to these people that the project has become what it is today. + # Thank you! + + people = [ + # As a maintainer, Erik was responsible for the "builder", and + # started the first designs for the new networking model in + # Docker. Erik is now working on all kinds of plugins for Docker + # (https://github.com/contiv) and various open source projects + # in his own repository https://github.com/erikh. You may + # still stumble into him in our issue tracker, or on IRC. + "erikh", + + # Victor is one of the earliest contributors to Docker, having worked on the + # project when it was still "dotCloud" in April 2013. He's been responsible + # for multiple releases (https://github.com/docker/docker/pulls?q=is%3Apr+bump+in%3Atitle+author%3Avieux), + # and up until today (2015), our number 2 contributor. Although he's no longer + # a maintainer for the Docker "Engine", he's still actively involved in other + # Docker projects, and most likely can be found in the Docker Swarm repository, + # for which he's a core maintainer. + "vieux", + + # Vishnu became a maintainer to help out on the daemon codebase and + # libcontainer integration. He's currently involved in the + # Open Containers Initiative, working on the specifications, + # besides his work on cAdvisor and Kubernetes for Google. + "vishh" + ] + +[people] + +# A reference list of all people associated with the project. +# All other sections should refer to people by their canonical key +# in the people section. + + # ADD YOURSELF HERE IN ALPHABETICAL ORDER + + [people.aaronlehmann] + Name = "Aaron Lehmann" + Email = "aaron.lehmann@docker.com" + GitHub = "aaronlehmann" + + [people.calavera] + Name = "David Calavera" + Email = "david.calavera@gmail.com" + GitHub = "calavera" + + [people.coolljt0725] + Name = "Lei Jitang" + Email = "leijitang@huawei.com" + GitHub = "coolljt0725" + + [people.cpuguy83] + Name = "Brian Goff" + Email = "cpuguy83@gmail.com" + Github = "cpuguy83" + + [people.crosbymichael] + Name = "Michael Crosby" + Email = "crosbymichael@gmail.com" + GitHub = "crosbymichael" + + [people.duglin] + Name = "Doug Davis" + Email = "dug@us.ibm.com" + GitHub = "duglin" + + [people.erikh] + Name = "Erik Hollensbe" + Email = "erik@docker.com" + GitHub = "erikh" + + [people.estesp] + Name = "Phil Estes" + Email = "estesp@linux.vnet.ibm.com" + GitHub = "estesp" + + [people.icecrime] + Name = "Arnaud Porterie" + Email = "arnaud@docker.com" + GitHub = "icecrime" + + [people.jamtur01] + Name = "James Turnbull" + Email = "james@lovedthanlost.net" + GitHub = "jamtur01" + + [people.jhowardmsft] + Name = "John Howard" + Email = "jhoward@microsoft.com" + GitHub = "jhowardmsft" + + [people.jfrazelle] + Name = "Jessie Frazelle" + Email = "jess@linux.com" + GitHub = "jfrazelle" + + [people.lk4d4] + Name = "Alexander Morozov" + Email = "lk4d4@docker.com" + GitHub = "lk4d4" + + [people.mhbauer] + Name = "Morgan Bauer" + Email = "mbauer@us.ibm.com" + GitHub = "mhbauer" + + [people.moxiegirl] + Name = "Mary Anthony" + Email = "mary.anthony@docker.com" + GitHub = "moxiegirl" + + [people.programmerq] + Name = "Jeff Anderson" + Email = "jeff@docker.com" + GitHub = "programmerq" + + [people.runcom] + Name = "Antonio Murdaca" + Email = "runcom@redhat.com" + GitHub = "runcom" + + [people.shykes] + Name = "Solomon Hykes" + Email = "solomon@docker.com" + GitHub = "shykes" + + [people.sven] + Name = "Sven Dowideit" + Email = "SvenDowideit@home.org.au" + GitHub = "SvenDowideit" + + [people.thajeztah] + Name = "Sebastiaan van Stijn" + Email = "github@gone.nl" + GitHub = "thaJeztah" + + [people.tianon] + Name = "Tianon Gravi" + Email = "admwiggin@gmail.com" + GitHub = "tianon" + + [people.tibor] + Name = "Tibor Vass" + Email = "tibor@docker.com" + GitHub = "tiborvass" + + [people.tonistiigi] + Name = "Tõnis Tiigi" + Email = "tonis@docker.com" + GitHub = "tonistiigi" + + [people.unclejack] + Name = "Cristian Staretu" + Email = "cristian.staretu@gmail.com" + GitHub = "unclejack" + + [people.vbatts] + Name = "Vincent Batts" + Email = "vbatts@redhat.com" + GitHub = "vbatts" + + [people.vdemeester] + Name = "Vincent Demeester" + Email = "vincent@sbr.pm" + GitHub = "vdemeester" + + [people.vieux] + Name = "Victor Vieux" + Email = "vieux@docker.com" + GitHub = "vieux" + + [people.vishh] + Name = "Vishnu Kannan" + Email = "vishnuk@google.com" + GitHub = "vishh" diff --git a/vendor/github.com/docker/docker/Makefile b/vendor/github.com/docker/docker/Makefile new file mode 100644 index 00000000..e0ba358c --- /dev/null +++ b/vendor/github.com/docker/docker/Makefile @@ -0,0 +1,106 @@ +.PHONY: all binary build cross default docs docs-build docs-shell shell test test-docker-py test-integration-cli test-unit validate + +# get OS/Arch of docker engine +DOCKER_OSARCH := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKER_ENGINE_OSARCH:-$$DOCKER_CLIENT_OSARCH}') +DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKERFILE}') + +# env vars passed through directly to Docker's build scripts +# to allow things like `make DOCKER_CLIENTONLY=1 binary` easily +# `docs/sources/contributing/devenvironment.md ` and `project/PACKAGERS.md` have some limited documentation of some of these +DOCKER_ENVS := \ + -e BUILDFLAGS \ + -e KEEPBUNDLE \ + -e DOCKER_BUILD_GOGC \ + -e DOCKER_BUILD_PKGS \ + -e DOCKER_CLIENTONLY \ + -e DOCKER_DEBUG \ + -e DOCKER_EXPERIMENTAL \ + -e DOCKER_GRAPHDRIVER \ + -e DOCKER_INCREMENTAL_BINARY \ + -e DOCKER_REMAP_ROOT \ + -e DOCKER_STORAGE_OPTS \ + -e DOCKER_USERLANDPROXY \ + -e TESTDIRS \ + -e TESTFLAGS \ + -e TIMEOUT +# note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds + +# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test` +# (default to no bind mount if DOCKER_HOST is set) +# note: BINDDIR is supported for backwards-compatibility here +BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles)) +DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)") + +# This allows the test suite to be able to run without worrying about the underlying fs used by the container running the daemon (e.g. aufs-on-aufs), so long as the host running the container is running a supported fs. +# The volume will be cleaned up when the container is removed due to `--rm`. +# Note that `BIND_DIR` will already be set to `bundles` if `DOCKER_HOST` is not set (see above BIND_DIR line), in such case this will do nothing since `DOCKER_MOUNT` will already be set. +DOCKER_MOUNT := $(if $(DOCKER_MOUNT),$(DOCKER_MOUNT),-v "/go/src/github.com/docker/docker/bundles") + +GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) +DOCKER_IMAGE := docker-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH)) +DOCKER_DOCS_IMAGE := docker-docs$(if $(GIT_BRANCH),:$(GIT_BRANCH)) + +DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) + +# if this session isn't interactive, then we don't want to allocate a +# TTY, which would fail, but if it is interactive, we do want to attach +# so that the user can send e.g. ^C through. +INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0) +ifeq ($(INTERACTIVE), 1) + DOCKER_FLAGS += -t +endif + +DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" + +default: binary + +all: build + $(DOCKER_RUN_DOCKER) hack/make.sh + +binary: build + $(DOCKER_RUN_DOCKER) hack/make.sh binary + +build: bundles + docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . + +bundles: + mkdir bundles + +cross: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross + +win: build + $(DOCKER_RUN_DOCKER) hack/make.sh win + +tgz: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross tgz + +deb: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build-deb + +docs: + $(MAKE) -C docs docs + +gccgo: build + $(DOCKER_RUN_DOCKER) hack/make.sh gccgo + +rpm: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build-rpm + +shell: build + $(DOCKER_RUN_DOCKER) bash + +test: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary cross test-unit test-integration-cli test-docker-py + +test-docker-py: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-docker-py + +test-integration-cli: build + $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration-cli + +test-unit: build + $(DOCKER_RUN_DOCKER) hack/make.sh test-unit + +validate: build + $(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-default-seccomp validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor diff --git a/vendor/github.com/docker/docker/NOTICE b/vendor/github.com/docker/docker/NOTICE new file mode 100644 index 00000000..8a37c1c7 --- /dev/null +++ b/vendor/github.com/docker/docker/NOTICE @@ -0,0 +1,19 @@ +Docker +Copyright 2012-2016 Docker, Inc. + +This product includes software developed at Docker, Inc. (https://www.docker.com). + +This product contains software (https://github.com/kr/pty) developed +by Keith Rarick, licensed under the MIT License. + +The following is courtesy of our legal counsel: + + +Use and transfer of Docker may be subject to certain restrictions by the +United States and other governments. +It is your responsibility to ensure that your use and/or transfer does not +violate applicable laws. + +For more information, please see https://www.bis.doc.gov + +See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. diff --git a/vendor/github.com/docker/docker/README.md b/vendor/github.com/docker/docker/README.md new file mode 100644 index 00000000..aa9cc0ea --- /dev/null +++ b/vendor/github.com/docker/docker/README.md @@ -0,0 +1,301 @@ +Docker: the container engine [![Release](https://img.shields.io/github/release/docker/docker.svg)](https://github.com/docker/docker/releases/latest) +============================ + +Docker is an open source project to pack, ship and run any application +as a lightweight container. + +Docker containers are both *hardware-agnostic* and *platform-agnostic*. +This means they can run anywhere, from your laptop to the largest +cloud compute instance and everything in between - and they don't require +you to use a particular language, framework or packaging system. That +makes them great building blocks for deploying and scaling web apps, +databases, and backend services without depending on a particular stack +or provider. + +Docker began as an open-source implementation of the deployment engine which +powers [dotCloud](https://www.dotcloud.com), a popular Platform-as-a-Service. +It benefits directly from the experience accumulated over several years +of large-scale operation and support of hundreds of thousands of +applications and databases. + +![](docs/static_files/docker-logo-compressed.png "Docker") + +## Security Disclosure + +Security is very important to us. If you have any issue regarding security, +please disclose the information responsibly by sending an email to +security@docker.com and not by creating a github issue. + +## Better than VMs + +A common method for distributing applications and sandboxing their +execution is to use virtual machines, or VMs. Typical VM formats are +VMware's vmdk, Oracle VirtualBox's vdi, and Amazon EC2's ami. In theory +these formats should allow every developer to automatically package +their application into a "machine" for easy distribution and deployment. +In practice, that almost never happens, for a few reasons: + + * *Size*: VMs are very large which makes them impractical to store + and transfer. + * *Performance*: running VMs consumes significant CPU and memory, + which makes them impractical in many scenarios, for example local + development of multi-tier applications, and large-scale deployment + of cpu and memory-intensive applications on large numbers of + machines. + * *Portability*: competing VM environments don't play well with each + other. Although conversion tools do exist, they are limited and + add even more overhead. + * *Hardware-centric*: VMs were designed with machine operators in + mind, not software developers. As a result, they offer very + limited tooling for what developers need most: building, testing + and running their software. For example, VMs offer no facilities + for application versioning, monitoring, configuration, logging or + service discovery. + +By contrast, Docker relies on a different sandboxing method known as +*containerization*. Unlike traditional virtualization, containerization +takes place at the kernel level. Most modern operating system kernels +now support the primitives necessary for containerization, including +Linux with [openvz](https://openvz.org), +[vserver](http://linux-vserver.org) and more recently +[lxc](https://linuxcontainers.org/), Solaris with +[zones](https://docs.oracle.com/cd/E26502_01/html/E29024/preface-1.html#scrolltoc), +and FreeBSD with +[Jails](https://www.freebsd.org/doc/handbook/jails.html). + +Docker builds on top of these low-level primitives to offer developers a +portable format and runtime environment that solves all four problems. +Docker containers are small (and their transfer can be optimized with +layers), they have basically zero memory and cpu overhead, they are +completely portable, and are designed from the ground up with an +application-centric design. + +Perhaps best of all, because Docker operates at the OS level, it can still be +run inside a VM! + +## Plays well with others + +Docker does not require you to buy into a particular programming +language, framework, packaging system, or configuration language. + +Is your application a Unix process? Does it use files, tcp connections, +environment variables, standard Unix streams and command-line arguments +as inputs and outputs? Then Docker can run it. + +Can your application's build be expressed as a sequence of such +commands? Then Docker can build it. + +## Escape dependency hell + +A common problem for developers is the difficulty of managing all +their application's dependencies in a simple and automated way. + +This is usually difficult for several reasons: + + * *Cross-platform dependencies*. Modern applications often depend on + a combination of system libraries and binaries, language-specific + packages, framework-specific modules, internal components + developed for another project, etc. These dependencies live in + different "worlds" and require different tools - these tools + typically don't work well with each other, requiring awkward + custom integrations. + + * *Conflicting dependencies*. Different applications may depend on + different versions of the same dependency. Packaging tools handle + these situations with various degrees of ease - but they all + handle them in different and incompatible ways, which again forces + the developer to do extra work. + + * *Custom dependencies*. A developer may need to prepare a custom + version of their application's dependency. Some packaging systems + can handle custom versions of a dependency, others can't - and all + of them handle it differently. + + +Docker solves the problem of dependency hell by giving the developer a simple +way to express *all* their application's dependencies in one place, while +streamlining the process of assembling them. If this makes you think of +[XKCD 927](https://xkcd.com/927/), don't worry. Docker doesn't +*replace* your favorite packaging systems. It simply orchestrates +their use in a simple and repeatable way. How does it do that? With +layers. + +Docker defines a build as running a sequence of Unix commands, one +after the other, in the same container. Build commands modify the +contents of the container (usually by installing new files on the +filesystem), the next command modifies it some more, etc. Since each +build command inherits the result of the previous commands, the +*order* in which the commands are executed expresses *dependencies*. + +Here's a typical Docker build process: + +```bash +FROM ubuntu:12.04 +RUN apt-get update && apt-get install -y python python-pip curl +RUN curl -sSL https://github.com/shykes/helloflask/archive/master.tar.gz | tar -xzv +RUN cd helloflask-master && pip install -r requirements.txt +``` + +Note that Docker doesn't care *how* dependencies are built - as long +as they can be built by running a Unix command in a container. + + +Getting started +=============== + +Docker can be installed either on your computer for building applications or +on servers for running them. To get started, [check out the installation +instructions in the +documentation](https://docs.docker.com/engine/installation/). + +We also offer an [interactive tutorial](https://www.docker.com/tryit/) +for quickly learning the basics of using Docker. + +Usage examples +============== + +Docker can be used to run short-lived commands, long-running daemons +(app servers, databases, etc.), interactive shell sessions, etc. + +You can find a [list of real-world +examples](https://docs.docker.com/engine/examples/) in the +documentation. + +Under the hood +-------------- + +Under the hood, Docker is built on the following components: + +* The + [cgroups](https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt) + and + [namespaces](http://man7.org/linux/man-pages/man7/namespaces.7.html) + capabilities of the Linux kernel +* The [Go](https://golang.org) programming language +* The [Docker Image Specification](https://github.com/docker/docker/blob/master/image/spec/v1.md) +* The [Libcontainer Specification](https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md) + +Contributing to Docker [![GoDoc](https://godoc.org/github.com/docker/docker?status.svg)](https://godoc.org/github.com/docker/docker) +====================== + +| **Master** (Linux) | **Experimental** (linux) | **Windows** | **FreeBSD** | +|------------------|----------------------|---------|---------| +| [![Jenkins Build Status](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master/badge/icon)](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master/) | [![Jenkins Build Status](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master%20%28experimental%29/badge/icon)](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master%20%28experimental%29/) | [![Build Status](http://jenkins.dockerproject.org/job/Docker%20Master%20(windows)/badge/icon)](http://jenkins.dockerproject.org/job/Docker%20Master%20(windows)/) | [![Build Status](http://jenkins.dockerproject.org/job/Docker%20Master%20(freebsd)/badge/icon)](http://jenkins.dockerproject.org/job/Docker%20Master%20(freebsd)/) | + +Want to hack on Docker? Awesome! We have [instructions to help you get +started contributing code or documentation](https://docs.docker.com/opensource/project/who-written-for/). + +These instructions are probably not perfect, please let us know if anything +feels wrong or incomplete. Better yet, submit a PR and improve them yourself. + +Getting the development builds +============================== + +Want to run Docker from a master build? You can download +master builds at [master.dockerproject.org](https://master.dockerproject.org). +They are updated with each commit merged into the master branch. + +Don't know how to use that super cool new feature in the master build? Check +out the master docs at +[docs.master.dockerproject.org](http://docs.master.dockerproject.org). + +How the project is run +====================== + +Docker is a very, very active project. If you want to learn more about how it is run, +or want to get more involved, the best place to start is [the project directory](https://github.com/docker/docker/tree/master/project). + +We are always open to suggestions on process improvements, and are always looking for more maintainers. + +### Talking to other Docker users and contributors + + + + + + + + + + + + + + + + + + + + +
Internet Relay Chat (IRC) +

+ IRC is a direct line to our most knowledgeable Docker users; we have + both the #docker and #docker-dev group on + irc.freenode.net. + IRC is a rich chat protocol but it can overwhelm new users. You can search + our chat archives. +

+ Read our IRC quickstart guide for an easy way to get started. +
Google Groups + There are two groups. + Docker-user + is for people using Docker containers. + The docker-dev + group is for contributors and other people contributing to the Docker + project. + You can join them without an google account by sending an email to e.g. "docker-user+subscribe@googlegroups.com". + After receiving the join-request message, you can simply reply to that to confirm the subscribtion. +
Twitter + You can follow Docker's Twitter feed + to get updates on our products. You can also tweet us questions or just + share blogs or stories. +
Stack Overflow + Stack Overflow has over 7000 Docker questions listed. We regularly + monitor Docker questions + and so do many other knowledgeable Docker users. +
+ +### Legal + +*Brought to you courtesy of our legal counsel. For more context, +please see the [NOTICE](https://github.com/docker/docker/blob/master/NOTICE) document in this repo.* + +Use and transfer of Docker may be subject to certain restrictions by the +United States and other governments. + +It is your responsibility to ensure that your use and/or transfer does not +violate applicable laws. + +For more information, please see https://www.bis.doc.gov + + +Licensing +========= +Docker is licensed under the Apache License, Version 2.0. See +[LICENSE](https://github.com/docker/docker/blob/master/LICENSE) for the full +license text. + +Other Docker Related Projects +============================= +There are a number of projects under development that are based on Docker's +core technology. These projects expand the tooling built around the +Docker platform to broaden its application and utility. + +* [Docker Registry](https://github.com/docker/distribution): Registry +server for Docker (hosting/delivery of repositories and images) +* [Docker Machine](https://github.com/docker/machine): Machine management +for a container-centric world +* [Docker Swarm](https://github.com/docker/swarm): A Docker-native clustering +system +* [Docker Compose](https://github.com/docker/compose) (formerly Fig): +Define and run multi-container apps +* [Kitematic](https://github.com/docker/kitematic): The easiest way to use +Docker on Mac and Windows + +If you know of another project underway that should be listed here, please help +us keep this list up-to-date by submitting a PR. + +Awesome-Docker +============== +You can find more projects, tools and articles related to Docker on the [awesome-docker list](https://github.com/veggiemonk/awesome-docker). Add your project there. diff --git a/vendor/github.com/docker/docker/ROADMAP.md b/vendor/github.com/docker/docker/ROADMAP.md new file mode 100644 index 00000000..514fdb74 --- /dev/null +++ b/vendor/github.com/docker/docker/ROADMAP.md @@ -0,0 +1,140 @@ +Docker Engine Roadmap +===================== + +### How should I use this document? + +This document provides description of items that the project decided to prioritize. This should +serve as a reference point for Docker contributors to understand where the project is going, and +help determine if a contribution could be conflicting with some longer terms plans. + +The fact that a feature isn't listed here doesn't mean that a patch for it will automatically be +refused (except for those mentioned as "frozen features" below)! We are always happy to receive +patches for new cool features we haven't thought about, or didn't judge priority. Please however +understand that such patches might take longer for us to review. + +### How can I help? + +Short term objectives are listed in the [wiki](https://github.com/docker/docker/wiki) and described +in [Issues](https://github.com/docker/docker/issues?q=is%3Aopen+is%3Aissue+label%3Aroadmap). Our +goal is to split down the workload in such way that anybody can jump in and help. Please comment on +issues if you want to take it to avoid duplicating effort! Similarly, if a maintainer is already +assigned on an issue you'd like to participate in, pinging him on IRC or GitHub to offer your help is +the best way to go. + +### How can I add something to the roadmap? + +The roadmap process is new to the Docker Engine: we are only beginning to structure and document the +project objectives. Our immediate goal is to be more transparent, and work with our community to +focus our efforts on fewer prioritized topics. + +We hope to offer in the near future a process allowing anyone to propose a topic to the roadmap, but +we are not quite there yet. For the time being, the BDFL remains the keeper of the roadmap, and we +won't be accepting pull requests adding or removing items from this file. + +# 1. Features and refactoring + +## 1.1 Runtime improvements + +We recently introduced [`runC`](https://runc.io) as a standalone low-level tool for container +execution. The initial goal was to integrate runC as a replacement in the Engine for the traditional +default libcontainer `execdriver`, but the Engine internals were not ready for this. + +As runC continued evolving, and the OCI specification along with it, we created +[`containerd`](https://containerd.tools/), a daemon to control and monitor multiple `runC`. This is +the new target for Engine integration, as it can entirely replace the whole `execdriver` +architecture, and container monitoring along with it. + +Docker Engine will rely on a long-running `containerd` companion daemon for all container execution +related operations. This could open the door in the future for Engine restarts without interrupting +running containers. + +## 1.2 Plugins improvements + +Docker Engine 1.7.0 introduced plugin support, initially for the use cases of volumes and networks +extensions. The plugin infrastructure was kept minimal as we were collecting use cases and real +world feedback before optimizing for any particular workflow. + +In the future, we'd like plugins to become first class citizens, and encourage an ecosystem of +plugins. This implies in particular making it trivially easy to distribute plugins as containers +through any Registry instance, as well as solving the commonly heard pain points of plugins needing +to be treated as somewhat special (being active at all time, started before any other user +containers, and not as easily dismissed). + +## 1.3 Internal decoupling + +A lot of work has been done in trying to decouple the Docker Engine's internals. In particular, the +API implementation has been refactored and ongoing work is happening to move the code to a separate +repository ([`docker/engine-api`](https://github.com/docker/engine-api)), and the Builder side of +the daemon is now [fully independent](https://github.com/docker/docker/tree/master/builder) while +still residing in the same repository. + +We are exploring ways to go further with that decoupling, capitalizing on the work introduced by the +runtime renovation and plugins improvement efforts. Indeed, the combination of `containerd` support +with the concept of "special" containers opens the door for bootstrapping more Engine internals +using the same facilities. + +## 1.4 Cluster capable Engine + +The community has been pushing for a more cluster capable Docker Engine, and a huge effort was spent +adding features such as multihost networking, and node discovery down at the Engine level. Yet, the +Engine is currently incapable of taking scheduling decisions alone, and continues relying on Swarm +for that. + +We plan to complete this effort and make Engine fully cluster capable. Multiple instances of the +Docker Engine being already capable of discovering each other and establish overlay networking for +their container to communicate, the next step is for a given Engine to gain ability to dispatch work +to another node in the cluster. This will be introduced in a backward compatible way, such that a +`docker run` invocation on a particular node remains fully deterministic. + +# 2 Frozen features + +## 2.1 Docker exec + +We won't accept patches expanding the surface of `docker exec`, which we intend to keep as a +*debugging* feature, as well as being strongly dependent on the Runtime ingredient effort. + +## 2.2 Dockerfile syntax + +The Dockerfile syntax as we know it is simple, and has proven successful in supporting all our +[official images](https://github.com/docker-library/official-images). Although this is *not* a +definitive move, we temporarily won't accept more patches to the Dockerfile syntax for several +reasons: + + - Long term impact of syntax changes is a sensitive matter that require an amount of attention the + volume of Engine codebase and activity today doesn't allow us to provide. + - Allowing the Builder to be implemented as a separate utility consuming the Engine's API will + open the door for many possibilities, such as offering alternate syntaxes or DSL for existing + languages without cluttering the Engine's codebase. + - A standalone Builder will also offer the opportunity for a better dedicated group of maintainers + to own the Dockerfile syntax and decide collectively on the direction to give it. + - Our experience with official images tend to show that no new instruction or syntax expansion is + *strictly* necessary for the majority of use cases, and although we are aware many things are + still lacking for many, we cannot make it a priority yet for the above reasons. + +Again, this is not about saying that the Dockerfile syntax is done, it's about making choices about +what we want to do first! + +## 2.3 Remote Registry Operations + +A large amount of work is ongoing in the area of image distribution and provenance. This includes +moving to the V2 Registry API and heavily refactoring the code that powers these features. The +desired result is more secure, reliable and easier to use image distribution. + +Part of the problem with this part of the code base is the lack of a stable and flexible interface. +If new features are added that access the registry without solidifying these interfaces, achieving +feature parity will continue to be elusive. While we get a handle on this situation, we are imposing +a moratorium on new code that accesses the Registry API in commands that don't already make remote +calls. + +Currently, only the following commands cause interaction with a remote registry: + + - push + - pull + - run + - build + - search + - login + +In the interest of stabilizing the registry access model during this ongoing work, we are not +accepting additions to other commands that will cause remote interaction with the Registry API. This +moratorium will lift when the goals of the distribution project have been met. diff --git a/vendor/github.com/docker/docker/VENDORING.md b/vendor/github.com/docker/docker/VENDORING.md new file mode 100644 index 00000000..c6bb5086 --- /dev/null +++ b/vendor/github.com/docker/docker/VENDORING.md @@ -0,0 +1,45 @@ +# Vendoring policies + +This document outlines recommended Vendoring policies for Docker repositories. +(Example, libnetwork is a Docker repo and logrus is not.) + +## Vendoring using tags + +Commit ID based vendoring provides little/no information about the updates +vendored. To fix this, vendors will now require that repositories use annotated +tags along with commit ids to snapshot commits. Annotated tags by themselves +are not sufficient, since the same tag can be force updated to reference +different commits. + +Each tag should: +- Follow Semantic Versioning rules (refer to section on "Semantic Versioning") +- Have a corresponding entry in the change tracking document. + +Each repo should: +- Have a change tracking document between tags/releases. Ex: CHANGELOG.md, +github releases file. + +The goal here is for consuming repos to be able to use the tag version and +changelog updates to determine whether the vendoring will cause any breaking or +backward incompatible changes. This also means that repos can specify having +dependency on a package of a specific version or greater up to the next major +release, without encountering breaking changes. + +## Semantic Versioning +Annotated version tags should follow Schema Versioning policies. +According to http://semver.org: + +"Given a version number MAJOR.MINOR.PATCH, increment the: + MAJOR version when you make incompatible API changes, + MINOR version when you add functionality in a backwards-compatible manner, and + PATCH version when you make backwards-compatible bug fixes. +Additional labels for pre-release and build metadata are available as extensions +to the MAJOR.MINOR.PATCH format." + +## Vendoring cadence +In order to avoid huge vendoring changes, it is recommended to have a regular +cadence for vendoring updates. eg. monthly. + +## Pre-merge vendoring tests +All related repos will be vendored into docker/docker. +CI on docker/docker should catch any breaking changes involving multiple repos. diff --git a/vendor/github.com/docker/docker/VERSION b/vendor/github.com/docker/docker/VERSION new file mode 100644 index 00000000..720c7384 --- /dev/null +++ b/vendor/github.com/docker/docker/VERSION @@ -0,0 +1 @@ +1.11.1 diff --git a/vendor/github.com/docker/docker/pkg/README.md b/vendor/github.com/docker/docker/pkg/README.md new file mode 100644 index 00000000..c4b78a8a --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/README.md @@ -0,0 +1,11 @@ +pkg/ is a collection of utility packages used by the Docker project without being specific to its internals. + +Utility packages are kept separate from the docker core codebase to keep it as small and concise as possible. +If some utilities grow larger and their APIs stabilize, they may be moved to their own repository under the +Docker organization, to facilitate re-use by other projects. However that is not the priority. + +The directory `pkg` is named after the same directory in the camlistore project. Since Brad is a core +Go maintainer, we thought it made sense to copy his methods for organizing Go code :) Thanks Brad! + +Because utility packages are small and neatly separated from the rest of the codebase, they are a good +place to start for aspiring maintainers and contributors. Get in touch if you want to help maintain them! diff --git a/vendor/github.com/docker/docker/pkg/reexec/README.md b/vendor/github.com/docker/docker/pkg/reexec/README.md new file mode 100644 index 00000000..45592ce8 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/reexec/README.md @@ -0,0 +1,5 @@ +## reexec + +The `reexec` package facilitates the busybox style reexec of the docker binary that we require because +of the forking limitations of using Go. Handlers can be registered with a name and the argv 0 of +the exec of the binary will be used to find and execute custom init paths. diff --git a/vendor/github.com/docker/docker/pkg/reexec/command_freebsd.go b/vendor/github.com/docker/docker/pkg/reexec/command_freebsd.go new file mode 100644 index 00000000..c7f797a5 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/reexec/command_freebsd.go @@ -0,0 +1,23 @@ +// +build freebsd + +package reexec + +import ( + "os/exec" +) + +// Self returns the path to the current process's binary. +// Uses os.Args[0]. +func Self() string { + return naiveSelf() +} + +// Command returns *exec.Cmd which have Path as current binary. +// For example if current binary is "docker" at "/usr/bin/", then cmd.Path will +// be set to "/usr/bin/docker". +func Command(args ...string) *exec.Cmd { + return &exec.Cmd{ + Path: Self(), + Args: args, + } +} diff --git a/vendor/github.com/docker/docker/pkg/reexec/command_linux.go b/vendor/github.com/docker/docker/pkg/reexec/command_linux.go new file mode 100644 index 00000000..3c3a73a9 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/reexec/command_linux.go @@ -0,0 +1,28 @@ +// +build linux + +package reexec + +import ( + "os/exec" + "syscall" +) + +// Self returns the path to the current process's binary. +// Returns "/proc/self/exe". +func Self() string { + return "/proc/self/exe" +} + +// Command returns *exec.Cmd which have Path as current binary. Also it setting +// SysProcAttr.Pdeathsig to SIGTERM. +// This will use the in-memory version (/proc/self/exe) of the current binary, +// it is thus safe to delete or replace the on-disk binary (os.Args[0]). +func Command(args ...string) *exec.Cmd { + return &exec.Cmd{ + Path: Self(), + Args: args, + SysProcAttr: &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGTERM, + }, + } +} diff --git a/vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go b/vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go new file mode 100644 index 00000000..ad4ea38e --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go @@ -0,0 +1,12 @@ +// +build !linux,!windows,!freebsd + +package reexec + +import ( + "os/exec" +) + +// Command is unsupported on operating systems apart from Linux and Windows. +func Command(args ...string) *exec.Cmd { + return nil +} diff --git a/vendor/github.com/docker/docker/pkg/reexec/command_windows.go b/vendor/github.com/docker/docker/pkg/reexec/command_windows.go new file mode 100644 index 00000000..8d65e0ae --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/reexec/command_windows.go @@ -0,0 +1,23 @@ +// +build windows + +package reexec + +import ( + "os/exec" +) + +// Self returns the path to the current process's binary. +// Uses os.Args[0]. +func Self() string { + return naiveSelf() +} + +// Command returns *exec.Cmd which have Path as current binary. +// For example if current binary is "docker.exe" at "C:\", then cmd.Path will +// be set to "C:\docker.exe". +func Command(args ...string) *exec.Cmd { + return &exec.Cmd{ + Path: Self(), + Args: args, + } +} diff --git a/vendor/github.com/docker/docker/pkg/reexec/reexec.go b/vendor/github.com/docker/docker/pkg/reexec/reexec.go new file mode 100644 index 00000000..ceb98d25 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/reexec/reexec.go @@ -0,0 +1,47 @@ +package reexec + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" +) + +var registeredInitializers = make(map[string]func()) + +// Register adds an initialization func under the specified name +func Register(name string, initializer func()) { + if _, exists := registeredInitializers[name]; exists { + panic(fmt.Sprintf("reexec func already registred under name %q", name)) + } + + registeredInitializers[name] = initializer +} + +// Init is called as the first part of the exec process and returns true if an +// initialization function was called. +func Init() bool { + initializer, exists := registeredInitializers[os.Args[0]] + if exists { + initializer() + + return true + } + return false +} + +func naiveSelf() string { + name := os.Args[0] + if filepath.Base(name) == name { + if lp, err := exec.LookPath(name); err == nil { + return lp + } + } + // handle conversion of relative paths to absolute + if absName, err := filepath.Abs(name); err == nil { + return absName + } + // if we couldn't get absolute name, return original + // (NOTE: Go only errors on Abs() if os.Getwd fails) + return name +} diff --git a/vendor/github.com/rancher/sparse-tools/.dockerignore b/vendor/github.com/rancher/sparse-tools/.dockerignore new file mode 100644 index 00000000..6e43c2a9 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/.dockerignore @@ -0,0 +1,4 @@ +./bin +./.dapper +./dist +./.trash-cache diff --git a/vendor/github.com/rancher/sparse-tools/.drone.yml b/vendor/github.com/rancher/sparse-tools/.drone.yml new file mode 100644 index 00000000..9a8850fc --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/.drone.yml @@ -0,0 +1,6 @@ +build: + image: rancher/dapper:1.10.3 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + commands: + - dapper ci diff --git a/vendor/github.com/rancher/sparse-tools/.gitignore b/vendor/github.com/rancher/sparse-tools/.gitignore index 96073d7e..91335dfc 100644 --- a/vendor/github.com/rancher/sparse-tools/.gitignore +++ b/vendor/github.com/rancher/sparse-tools/.gitignore @@ -1,29 +1,13 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so -ssync +/.dapper +/bin +*.swp +/.trash-cache -# test data files -*.bar - -# Folders -_obj -_test .vscode +#delve invocation binaries +debug +debug.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 +#go build binaries +ssync/ssync +sfold/sfold diff --git a/vendor/github.com/rancher/sparse-tools/Dockerfile.dapper b/vendor/github.com/rancher/sparse-tools/Dockerfile.dapper new file mode 100644 index 00000000..90da5ad5 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/Dockerfile.dapper @@ -0,0 +1,16 @@ +FROM golang:1.6 +RUN go get github.com/rancher/trash +RUN go get github.com/golang/lint/golint +RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ + chmod +x /usr/bin/docker +ENV PATH /go/bin:$PATH +ENV DAPPER_SOURCE /go/src/github.com/rancher/sparse-tools +ENV DAPPER_OUTPUT bin +ENV DAPPER_DOCKER_SOCKET true +ENV DAPPER_ENV TAG REPO +ENV GO15VENDOREXPERIMENT 1 +ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache +WORKDIR ${DAPPER_SOURCE} +ENTRYPOINT ["./scripts/entry"] +VOLUME /tmp +CMD ["ci"] diff --git a/vendor/github.com/rancher/sparse-tools/Makefile b/vendor/github.com/rancher/sparse-tools/Makefile new file mode 100644 index 00000000..d7d72a16 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/Makefile @@ -0,0 +1,23 @@ +TARGETS := $(shell ls scripts) + +.dapper: + @echo Downloading dapper + @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp + @@chmod +x .dapper.tmp + @./.dapper.tmp -v + @mv .dapper.tmp .dapper + +$(TARGETS): .dapper + ./.dapper $@ + +trash: .dapper + ./.dapper -m bind trash + +trash-keep: .dapper + ./.dapper -m bind trash -k + +deps: trash + +.DEFAULT_GOAL := ci + +.PHONY: $(TARGETS) diff --git a/vendor/github.com/rancher/sparse-tools/README.md b/vendor/github.com/rancher/sparse-tools/README.md index 5e8ace3a..b23dc001 100644 --- a/vendor/github.com/rancher/sparse-tools/README.md +++ b/vendor/github.com/rancher/sparse-tools/README.md @@ -1,2 +1,6 @@ # alphorn sparse storage slab synchronization, etc. + +## Building + +Run `make` diff --git a/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go b/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go new file mode 100644 index 00000000..9f695f2f --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go @@ -0,0 +1,58 @@ +package sfold + +import ( + "flag" + "fmt" + "os" + + "github.com/rancher/sparse-tools/log" + "github.com/rancher/sparse-tools/sparse" +) + +func Main() { + defaultNonVerboseLogLevel := log.LevelWarn // set if -verbose is false + // Command line parsing + verbose := flag.Bool("verbose", false, "verbose mode") + flag.Usage = func() { + const usage = "fold " + const examples = ` +Examples: + fold child.snapshot parent.snapshot` + fmt.Fprintf(os.Stderr, "\nUsage of %s:\n", os.Args[0]) + fmt.Fprintln(os.Stderr, usage) + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, examples) + } + flag.Parse() + + args := flag.Args() + if len(args) < 1 { + cmdError("missing file paths") + } + if len(args) < 2 { + cmdError("missing destination file path") + } + if len(args) > 2 { + cmdError("too many arguments") + } + + srcPath := args[0] + dstPath := args[1] + if *verbose { + fmt.Fprintf(os.Stderr, "Folding %s to %s...\n", srcPath, dstPath) + } else { + log.LevelPush(defaultNonVerboseLogLevel) + defer log.LevelPop() + } + + err := sparse.FoldFile(srcPath, dstPath) + if err != nil { + os.Exit(1) + } +} + +func cmdError(msg string) { + fmt.Fprintln(os.Stderr, "Error:", msg) + flag.Usage() + os.Exit(2) +} diff --git a/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go b/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go new file mode 100644 index 00000000..5e75441a --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go @@ -0,0 +1,85 @@ +package ssync + +import ( + "flag" + "fmt" + "os" + + "github.com/rancher/sparse-tools/log" + "github.com/rancher/sparse-tools/sparse" +) + +func Main() { + defaultVerboseLogLevel := log.LevelInfo // set if -verbose + defaultNonVerboseLogLevel := log.LevelWarn // set if -verbose=false + // Command line parsing + verbose := flag.Bool("verbose", false, "verbose mode") + daemon := flag.Bool("daemon", false, "daemon mode (run on remote host)") + port := flag.Int("port", 5000, "optional daemon port") + timeout := flag.Int("timeout", 60, "optional daemon/client timeout (seconds)") + host := flag.String("host", "", "remote host of (requires running daemon)") + flag.Usage = func() { + const usage = "sync []" + const examples = ` +Examples: + sync -daemon + sync -host remote.net file.data` + fmt.Fprintf(os.Stderr, "\nUsage of %s:\n", os.Args[0]) + fmt.Fprintln(os.Stderr, usage) + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, examples) + } + flag.Parse() + + args := flag.Args() + if *daemon { + // Daemon mode + endpoint := sparse.TCPEndPoint{Host: "" /*bind to all*/, Port: int16(*port)} + if *verbose { + log.LevelPush(defaultVerboseLogLevel) + defer log.LevelPop() + fmt.Fprintln(os.Stderr, "Listening on", endpoint, "...") + } else { + log.LevelPush(defaultNonVerboseLogLevel) + defer log.LevelPop() + } + + sparse.Server(endpoint, *timeout) + } else { + // "local to remote"" file sync mode + if len(args) < 1 { + cmdError("missing file path") + } + srcPath := args[0] + dstPath := srcPath + if len(args) == 2 { + dstPath = args[1] + } else if len(args) > 2 { + cmdError("too many arguments") + } + + endpoint := sparse.TCPEndPoint{Host: *host, Port: int16(*port)} + if *verbose { + log.LevelPush(defaultVerboseLogLevel) + defer log.LevelPop() + fmt.Fprintf(os.Stderr, "Syncing %s to %s@%s:%d...\n", srcPath, dstPath, endpoint.Host, endpoint.Port) + } else { + log.LevelPush(defaultNonVerboseLogLevel) + defer log.LevelPop() + } + + _, err := sparse.SyncFile(srcPath, endpoint, dstPath, *timeout) + if err != nil { + log.Info("ssync: error:", err, "exit code 1") + os.Exit(1) + } + log.Info("ssync: exit code 0") + } +} + +func cmdError(msg string) { + fmt.Fprintln(os.Stderr, "Error:", msg) + flag.Usage() + log.Info("ssync: exit code 2") + os.Exit(2) +} diff --git a/vendor/github.com/rancher/sparse-tools/directfio/directfio.go b/vendor/github.com/rancher/sparse-tools/directfio/directfio.go index e8172b67..d01d6175 100644 --- a/vendor/github.com/rancher/sparse-tools/directfio/directfio.go +++ b/vendor/github.com/rancher/sparse-tools/directfio/directfio.go @@ -1,8 +1,9 @@ package directfio import ( - "unsafe" "os" + "syscall" + "unsafe" ) const ( @@ -13,27 +14,36 @@ const ( BlockSize = alignment ) +// OpenFile open file for direct i/o (syscall.O_DIRECT) +// Use AllocateAligned to avoid extra data fuffer copy +func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { + + return os.OpenFile(name, syscall.O_DIRECT|flag, perm) +} + // ReadAt read into unaligned data buffer via direct I/O +// Use AllocateAligned to avoid extra data fuffer copy func ReadAt(file *os.File, data []byte, offset int64) (int, error) { - if alignmentShift(data) == 0 { - return file.ReadAt(data, offset) - } - buf := AllocateAligned(len(data)) - n, err := file.ReadAt(buf, offset) - copy(data, buf) - return n, err + if alignmentShift(data) == 0 { + return file.ReadAt(data, offset) + } + buf := AllocateAligned(len(data)) + n, err := file.ReadAt(buf, offset) + copy(data, buf) + return n, err } // WriteAt write from unaligned data buffer via direct I/O +// Use AllocateAligned to avoid extra data fuffer copy func WriteAt(file *os.File, data []byte, offset int64) (int, error) { - if alignmentShift(data) == 0 { - return file.WriteAt(data, offset) - } - // Write unaligned - buf := AllocateAligned(len(data)) - copy(buf, data) - n, err := file.WriteAt(buf, offset) - return n, err + if alignmentShift(data) == 0 { + return file.WriteAt(data, offset) + } + // Write unaligned + buf := AllocateAligned(len(data)) + copy(buf, data) + n, err := file.WriteAt(buf, offset) + return n, err } // AllocateAligned returns []byte of size aligned to alignment @@ -59,4 +69,3 @@ func alignmentShift(block []byte) int { } return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(alignment-1)) } - diff --git a/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go b/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go index 4e7a0c03..2ec0c0e6 100644 --- a/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go +++ b/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go @@ -10,13 +10,26 @@ import ( "io/ioutil" - fio "github.com/rancher/sparse-tools/directfio" "syscall" + + fio "github.com/rancher/sparse-tools/directfio" ) -func tempFileName() string { - // Make a temporary file name - f, err := ioutil.TempFile("", "fio_test") +func tempFilePath() string { + // Make a temporary file path + f, err := ioutil.TempFile("", "fio-test") + if err != nil { + log.Fatal("Failed to make temp file", err) + } + defer f.Close() + return f.Name() +} + +// tempBigFileName is for files that are substantial in isze (for benchmark and stress tests) +// created in current directory +func tempBigFilePath() string { + // Make a temporary file path in current dir + f, err := ioutil.TempFile(".", "fio-test") if err != nil { log.Fatal("Failed to make temp file", err) } @@ -45,7 +58,8 @@ func TestDirectFileIO1(t *testing.T) { data1 := fio.AllocateAligned(blocks * fio.BlockSize) fillData(data1, 0) - path := tempFileName() + path := tempFilePath() + defer cleanup(path) { // Write f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0644) @@ -79,8 +93,6 @@ func TestDirectFileIO1(t *testing.T) { if !bytes.Equal(data1, data2) { t.Fatal("Read not the same as written") } - - cleanup(path) } func TestDirectFileIO2(t *testing.T) { @@ -90,10 +102,11 @@ func TestDirectFileIO2(t *testing.T) { data1 := make([]byte, blocks*fio.BlockSize) fillData(data1, 0) - path := tempFileName() + path := tempFilePath() + defer cleanup(path) { // Write - f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0644) + f, err := fio.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0644) if err != nil { t.Fatal("Failed to OpenFile for write", err) } @@ -108,7 +121,7 @@ func TestDirectFileIO2(t *testing.T) { data2 := make([]byte, blocks*fio.BlockSize) { // Read - f, err := os.OpenFile(path, os.O_RDONLY|syscall.O_DIRECT, 0) + f, err := fio.OpenFile(path, os.O_RDONLY, 0) if err != nil { t.Fatal("Failed to OpenFile for read", err) } @@ -124,19 +137,17 @@ func TestDirectFileIO2(t *testing.T) { if !bytes.Equal(data1, data2) { t.Fatal("Read not the same as written") } - - cleanup(path) } -const fileSize = int64(512) /*MB*/ << 20 +const fileSize = int64(1) /*GB*/ << 30 -const FileMode = os.O_WRONLY | syscall.O_DIRECT +const FileMode = os.O_RDWR func write(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { data := fio.AllocateAligned(batchSize) fillData(data, 0) - f, err := os.OpenFile(path, FileMode, 0) + f, err := os.OpenFile(path, syscall.O_DIRECT|FileMode, 0) if err != nil { b.Fatal("Failed to OpenFile for write", err) } @@ -151,11 +162,29 @@ func write(b *testing.B, path string, done chan<- bool, batchSize int, offset, s done <- true } +func read(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { + data := fio.AllocateAligned(batchSize) + + f, err := os.OpenFile(path, syscall.O_DIRECT|FileMode, 0) + if err != nil { + b.Fatal("Failed to OpenFile for read", err) + } + defer f.Close() + + for pos := offset; pos < offset+size; pos += int64(batchSize) { + _, err = f.ReadAt(data, pos) + if err != nil { + b.Fatal("Failed to read", err) + } + } + done <- true +} + func writeUnaligned(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { data := make([]byte, batchSize) fillData(data, 0) - f, err := os.OpenFile(path, FileMode, 0) + f, err := fio.OpenFile(path, FileMode, 0) if err != nil { b.Fatal("Failed to OpenFile for write", err) } @@ -170,58 +199,88 @@ func writeUnaligned(b *testing.B, path string, done chan<- bool, batchSize int, done <- true } -func writeTest(b *testing.B, path string, writers, batch int, write func(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64)) { - done := make(chan bool, writers) - chunkSize := fileSize / int64(writers) +func readUnaligned(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { + data := make([]byte, batchSize) - start := time.Now().Unix() + f, err := fio.OpenFile(path, FileMode, 0) + if err != nil { + b.Fatal("Failed to OpenFile for read", err) + } + defer f.Close() + + for pos := offset; pos < offset+size; pos += int64(batchSize) { + _, err = fio.ReadAt(f, data, pos) + if err != nil { + b.Fatal("Failed to read", err) + } + } + done <- true +} + +func ioTest(title string, b *testing.B, path string, threads, batch int, io func(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64)) { + done := make(chan bool, threads) + chunkSize := fileSize / int64(threads) + + start := time.Now().UnixNano() ioSize := batch * fio.BlockSize - for i := 0; i < writers; i++ { - go write(b, path, done, ioSize, int64(i)*chunkSize, chunkSize) + for i := 0; i < threads; i++ { + go io(b, path, done, ioSize, int64(i)*chunkSize, chunkSize) } - for i := 0; i < writers; i++ { + for i := 0; i < threads; i++ { <-done } - stop := time.Now().Unix() - log.Println("writers=", writers, "batch=", batch, "(blocks)", "thruput=", fileSize/(1<<20)/(stop-start), "(MB/s)") + stop := time.Now().UnixNano() + if len(title) > 0 { + log.Println(title, ":", threads, "(threads) batch=", batch, "(blocks)", "thruput=", 1000000*fileSize/(1<<20)/((stop-start)/1000), "(MB/s)") + } } -func BenchmarkWrite8(b *testing.B) { - path := tempFileName() +func BenchmarkIO8(b *testing.B) { + path := tempBigFilePath() + defer cleanup(path) f, err := os.OpenFile(path, os.O_CREATE|FileMode, 0644) if err != nil { b.Fatal("Failed to OpenFile for write", err) } defer f.Close() + f.Truncate(fileSize) + log.Println("") + ioTest("pilot write", b, path, 8, 32, write) for batch := 32; batch >= 1; batch >>= 1 { log.Println("") - for writers := 1; writers <= 8; writers <<= 1 { - writeTest(b, path, writers, batch, write) + for threads := 1; threads <= 8; threads <<= 1 { + ioTest("write", b, path, threads, batch, write) + } + for threads := 1; threads <= 8; threads <<= 1 { + ioTest(" read", b, path, threads, batch, read) } } - - cleanup(path) + } -func BenchmarkWrite8u(b *testing.B) { - path := tempFileName() +func BenchmarkIO8u(b *testing.B) { + path := tempBigFilePath() + defer cleanup(path) f, err := os.OpenFile(path, os.O_CREATE|FileMode, 0644) if err != nil { b.Fatal("Failed to OpenFile for write", err) } defer f.Close() f.Truncate(fileSize) + log.Println("") + ioTest("pilot write", b, path, 8, 32, writeUnaligned) for batch := 32; batch >= 1; batch >>= 1 { log.Println("") - for writers := 1; writers <= 8; writers <<= 1 { - writeTest(b, path, writers, batch, writeUnaligned) + for threads := 1; threads <= 8; threads <<= 1 { + ioTest("unaligned write", b, path, threads, batch, writeUnaligned) + } + for threads := 1; threads <= 8; threads <<= 1 { + ioTest(" unaligned read", b, path, threads, batch, readUnaligned) } } - - cleanup(path) } diff --git a/vendor/github.com/rancher/sparse-tools/log/log.go b/vendor/github.com/rancher/sparse-tools/log/log.go new file mode 100644 index 00000000..4294889e --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/log/log.go @@ -0,0 +1,99 @@ +package log + +import ( + syslog "log" + "sync" +) + +// Level of logging +type Level int + +// Levels +const ( + LevelTrace Level = 1 + iota + LevelDebug + LevelInfo + LevelWarn + LevelError + LevelFatal +) + +// crude global log level control: +// log everything at this level and above +var logMutex sync.RWMutex +var logLevel = LevelDebug +var logLevelStack []Level + +// LevelPush push current level down the stack and set +func LevelPush(level Level) { + logMutex.Lock() + defer logMutex.Unlock() + + logLevelStack = append(logLevelStack, level) + logLevel = level +} + +// LevelPop pop current level from the stack +func LevelPop() { + logMutex.Lock() + defer logMutex.Unlock() + + len := len(logLevelStack) + logLevel, logLevelStack = logLevelStack[len-1], logLevelStack[:len-1] +} + +// Trace log if trace is greater than current log level +// The finest granularity +func Trace(msg ...interface{}) { + logMutex.RLock() + defer logMutex.RUnlock() + + if LevelTrace >= logLevel { + syslog.Println("D:", msg) + } +} + +// Debug log if debug is greater than current log level +func Debug(msg ...interface{}) { + logMutex.RLock() + defer logMutex.RUnlock() + + if LevelDebug >= logLevel { + syslog.Println("D:", msg) + } +} + +// Info log if info is greater than current log level +func Info(msg ...interface{}) { + logMutex.RLock() + defer logMutex.RUnlock() + + if LevelInfo >= logLevel { + syslog.Println("I:", msg) + } +} + +// Warn log if warn is greater than current log level +func Warn(msg ...interface{}) { + logMutex.RLock() + defer logMutex.RUnlock() + + if LevelWarn >= logLevel { + syslog.Println("W:", msg) + } +} + +// Error log if error is greater than current log level +func Error(msg ...interface{}) { + logMutex.RLock() + defer logMutex.RUnlock() + + if LevelError >= logLevel { + syslog.Println("E:", msg) + } +} + +// Fatal log unconditionally and panic +func Fatal(msg ...interface{}) { + syslog.Fatalln("F:", msg) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client.go b/vendor/github.com/rancher/sparse-tools/sparse/client.go new file mode 100644 index 00000000..4147a0dc --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/client.go @@ -0,0 +1,486 @@ +package sparse + +import ( + "crypto/sha1" + "net" + "os" + "strconv" + + fio "github.com/rancher/sparse-tools/directfio" + "github.com/rancher/sparse-tools/log" +) + +import "encoding/gob" + +import "errors" + +import "fmt" +import "time" + +// TCPEndPoint tcp connection address +type TCPEndPoint struct { + Host string + Port int16 +} + +const connectionRetries = 5 +const verboseClient = true + +// SyncFile synchronizes local file to remote host +func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int) (hashLocal []byte, err error) { + hashLocal = make([]byte, 0) // empty hash for errors + file, err := fio.OpenFile(localPath, os.O_RDONLY, 0) + if err != nil { + log.Error("Failed to open local source file:", localPath) + return + } + defer file.Close() + + size, errSize := file.Seek(0, os.SEEK_END) + if errSize != nil { + log.Error("Failed to get size of local source file:", localPath, errSize) + return + } + + conn := connect(addr.Host, strconv.Itoa(int(addr.Port)), timeout) + if nil == conn { + log.Error("Failed to connect to", addr) + return + } + defer conn.Close() + + encoder := gob.NewEncoder(conn) + decoder := gob.NewDecoder(conn) + status := sendSyncRequest(encoder, decoder, remotePath, size) + if !status { + return + } + + abortStream := make(chan error) + layoutStream := make(chan FileInterval, 128) + errStream := make(chan error) + + // Initiate interval loading... + err = loadFileLayout(abortStream, file, layoutStream, errStream) + if err != nil { + log.Error("Failed to retrieve local file layout:", err) + return + } + + fileStream := make(chan FileInterval, 128) + unorderedStream := make(chan HashedDataInterval, 128) + orderedStream := make(chan HashedDataInterval, 128) + + go IntervalSplitter(layoutStream, fileStream) + go FileReader(fileStream, file, unorderedStream) + go OrderIntervals("src:", unorderedStream, orderedStream) + + // Get remote file intervals and their hashes + netInStream := make(chan HashedInterval, 128) + netInStreamDone := make(chan bool) + go netDstReceiver(decoder, netInStream, netInStreamDone) + + return processDiff(abortStream, errStream, encoder, decoder, orderedStream, netInStream, netInStreamDone, file) +} + +func connect(host, port string, timeout int) net.Conn { + // connect to this socket + endpoint := host + ":" + port + raddr, err := net.ResolveTCPAddr("tcp", endpoint) + if err != nil { + log.Fatal("Connection address resolution error:", err) + } + timeStart := time.Now() + timeStop := timeStart.Add(time.Duration(timeout) * time.Second) + for timeNow := timeStart; timeNow.Before(timeStop); timeNow = time.Now() { + conn, err := net.DialTCP("tcp", nil, raddr) + if err == nil { + return conn + } + log.Warn("Failed connection to", endpoint, "Retrying...") + if timeNow != timeStart { + // only sleep after the second attempt to speedup tests + time.Sleep(1 * time.Second) + } + } + return nil +} + +func sendSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64) bool { + err := encoder.Encode(requestHeader{requestMagic, syncRequestCode}) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + return false + } + err = encoder.Encode(path) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + return false + } + err = encoder.Encode(size) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + return false + } + + var ack bool + err = decoder.Decode(&ack) + if err != nil { + log.Fatal("Client protocol decoder error:", err) + return false + } + + return ack +} + +// Get remote hashed intervals +func netDstReceiver(decoder *gob.Decoder, netInStream chan<- HashedInterval, netInStreamDone chan<- bool) { + status := true + for { + if verboseClient { + log.Debug("Client.netDstReceiver decoding...") + } + var r HashedInterval + err := decoder.Decode(&r) + if err != nil { + log.Fatal("Cient protocol error:", err) + status = false + break + } + // interval := r.Interval + if r.Kind == SparseIgnore { + if verboseClient { + log.Debug("Client.netDstReceiver got ") + } + break + } + if verboseClient { + switch r.Kind { + case SparseData: + log.Debug("Client.netDstReceiver got data", r.FileInterval, "hash[", len(r.Hash), "]") + case SparseHole: + log.Debug("Client.netDstReceiver got hole", r.FileInterval) + } + } + netInStream <- r + } + close(netInStream) + netInStreamDone <- status +} + +// file reading chunk +type fileChunk struct { + eof bool // end of stream: stop reader + header FileInterval +} + +// network transfer chunk +type diffChunk struct { + status bool // read file or network send error yield false + header DataInterval +} + +func processDiff(abortStream chan<- error, errStream <-chan error, encoder *gob.Encoder, decoder *gob.Decoder, local <-chan HashedDataInterval, remote <-chan HashedInterval, netInStreamDone <-chan bool, file *os.File) (hashLocal []byte, err error) { + // Local: __ _* + // Remote: *_ ** + hashLocal = make([]byte, 0) // empty hash for errors + const concurrentReaders = 4 + netStream := make(chan diffChunk, 128) + netStatus := make(chan netXferStatus) + go networkSender(netStream, encoder, netStatus) + // fileStream := make(chan fileChunk, 128) + // fileStatus := make(chan bool) + // for i := 0; i < concurrentReaders; i++ { + // if 0 == i { + // go fileReader(i, file, fileStream, netStream, fileStatus) + // } else { + // f, _ := os.Open(file.Name()) + // go fileReader(i, f, fileStream, netStream, fileStatus) + // } + // } + fileHasher := sha1.New() + fileHasher.Write(HashSalt) + + lrange := <-local + rrange := <-remote + for lrange.Len() != 0 { + if rrange.Len() == 0 { + // Copy local tail + if verboseClient { + logData("LHASH", lrange.Data) + } + hashFileData(fileHasher, lrange.Len(), lrange.Data) + processFileInterval(lrange, HashedInterval{FileInterval{SparseHole, lrange.Interval}, make([]byte, 0)}, netStream) + lrange = <-local + continue + } + // Diff + if verboseClient { + log.Debug("Diff:", lrange.HashedInterval, rrange) + } + if lrange.Begin == rrange.Begin { + if lrange.End > rrange.End { + data := lrange.Data + if len(data) > 0 { + data = lrange.Data[:rrange.Len()] + } + subrange := HashedDataInterval{HashedInterval{FileInterval{lrange.Kind, rrange.Interval}, lrange.Hash}, data} + if verboseClient { + logData("LHASH", subrange.Data) + } + + hashFileData(fileHasher, subrange.Len(), subrange.Data) + processFileInterval(subrange, rrange, netStream) + if len(data) > 0 { + lrange.Data = lrange.Data[subrange.Len():] + } + lrange.Begin = rrange.End + rrange = <-remote + continue + } else if lrange.End < rrange.End { + if verboseClient { + logData("LHASH", lrange.Data) + } + + hashFileData(fileHasher, lrange.Len(), lrange.Data) + processFileInterval(lrange, HashedInterval{FileInterval{rrange.Kind, lrange.Interval}, make([]byte, 0)}, netStream) + rrange.Begin = lrange.End + lrange = <-local + continue + } + if verboseClient { + logData("LHASH", lrange.Data) + } + hashFileData(fileHasher, lrange.Len(), lrange.Data) + processFileInterval(lrange, rrange, netStream) + lrange = <-local + rrange = <-remote + } else { + // Should never happen + log.Fatal("internal error") + err = errors.New("internal error") + return + } + } + log.Info("Finished processing file diff") + + // // stop file readers + // for i := 0; i < concurrentReaders; i++ { + // fileStream <- fileChunk{true, FileInterval{SparseHole, Interval{0, 0}}} + // <-fileStatus // wait for reader completion + // } + + status := true + err = <-errStream + if err != nil { + log.Error("Sync client file load aborted:", err) + status = false + } + // make sure we finished consuming dst hashes + status = <-netInStreamDone && status // netDstReceiver finished + log.Info("Finished consuming remote file hashes, status=", status) + + // Send end of transmission + netStream <- diffChunk{true, DataInterval{FileInterval{SparseIgnore, Interval{0, 0}}, make([]byte, 0)}} + + // get network sender status + net := <-netStatus + log.Info("Finished sending file diff of", net.byteCount, "(bytes), status=", net.status) + if !net.status { + err = errors.New("netwoek transfer failure") + return + } + + var statusRemote bool + err = decoder.Decode(&statusRemote) + if err != nil { + log.Fatal("Cient protocol remote status error:", err) + return + } + if !statusRemote { + err = errors.New("failure on remote sync site") + return + } + var hashRemote []byte + err = decoder.Decode(&hashRemote) + if err != nil { + log.Fatal("Cient protocol remote hash error:", err) + return + } + + // Compare file hashes + hashLocal = fileHasher.Sum(nil) + if isHashDifferent(hashLocal, hashRemote) { + log.Warn("hashLocal =", hashLocal) + log.Warn("hashRemote=", hashRemote) + err = errors.New("file hash divergence: storage error or block hash collision") + return + } + return +} + +func isHashDifferent(a, b []byte) bool { + if len(a) != len(b) { + return true + } + for i, val := range a { + if val != b[i] { + return true + } + } + return false // hashes are equal +} + +func processFileInterval(local HashedDataInterval, remote HashedInterval, netStream chan<- diffChunk) { + if local.Interval != remote.Interval { + log.Fatal("Sync.processFileInterval range internal error:", local.FileInterval, remote.FileInterval) + } + if local.Kind != remote.Kind { + // Different intreval types, send the diff + if local.Kind == SparseData && int64(len(local.Data)) != local.FileInterval.Len() { + log.Fatal("Sync.processFileInterval data internal error:", local.FileInterval.Len(), len(local.Data)) + } + netStream <- diffChunk{true, DataInterval{local.FileInterval, local.Data}} + return + } + + // The interval types are the same + if SparseHole == local.Kind { + // Process hole, no syncronization is required + local.Kind = SparseIgnore + netStream <- diffChunk{true, DataInterval{local.FileInterval, local.Data}} + return + } + + if local.Kind != SparseData { + log.Fatal("Sync.processFileInterval kind internal error:", local.FileInterval) + } + // Data file interval + if isHashDifferent(local.Hash, remote.Hash) { + if int64(len(local.Data)) != local.FileInterval.Len() { + log.Fatal("Sync.processFileInterval internal error:", local.FileInterval.Len(), len(local.Data)) + } + netStream <- diffChunk{true, DataInterval{local.FileInterval, local.Data}} + return + } + + // No diff, just communicate we processed it + //TODO: this apparently can be avoided but requires revision of the protocol + local.Kind = SparseIgnore + netStream <- diffChunk{true, DataInterval{local.FileInterval, make([]byte, 0)}} +} + +// prints chan codes and lengths to trace +// - sequence and interleaving of chan processing +// - how much of the chan buffer is used +const traceChannelLoad = false + +type netXferStatus struct { + status bool + byteCount int64 +} + +func networkSender(netStream <-chan diffChunk, encoder *gob.Encoder, netStatus chan<- netXferStatus) { + status := true + byteCount := int64(0) + for { + chunk := <-netStream + if 0 == chunk.header.Len() { + // eof: last 0 len header + if verboseClient { + log.Debug("Client.networkSender ") + } + err := encoder.Encode(chunk.header.FileInterval) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + status = false + } + break + } + + if !status { + // network error + continue // discard the chunk + } + if !chunk.status { + // read error + status = false + continue // discard the chunk + } + + if traceChannelLoad { + fmt.Fprint(os.Stderr, len(netStream), "n") + } + + // Encode and send data to the network + if verboseClient { + log.Debug("Client.networkSender sending:", chunk.header.FileInterval) + } + err := encoder.Encode(chunk.header.FileInterval) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + status = false + continue + } + if len(chunk.header.Data) == 0 { + continue + } + if verboseClient { + log.Debug("Client.networkSender sending data") + } + if int64(len(chunk.header.Data)) != chunk.header.FileInterval.Len() { + log.Fatal("Client.networkSender sending data internal error:", chunk.header.FileInterval.Len(), len(chunk.header.Data)) + } + err = encoder.Encode(chunk.header.Data) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + status = false + continue + } + byteCount += int64(len(chunk.header.Data)) + if traceChannelLoad { + fmt.Fprint(os.Stderr, "N\n") + } + } + netStatus <- netXferStatus{status, byteCount} +} + +// obsolete method +func fileReader(id int, file *os.File, fileStream <-chan fileChunk, netStream chan<- diffChunk, fileStatus chan<- bool) { + idBeg := map[int]string{0: "a", 1: "b", 2: "c", 3: "d"} + idEnd := map[int]string{0: "A", 1: "B", 2: "C", 3: "D"} + for { + chunk := <-fileStream + if chunk.eof { + break + } + if traceChannelLoad { + fmt.Fprint(os.Stderr, len(fileStream), idBeg[id]) + } + // Check interval type + r := chunk.header + if SparseData != r.Kind { + log.Fatal("internal error: noles should be send directly to netStream") + } + + // Read file data + data := make([]byte, r.Len()) + status := true + n, err := fio.ReadAt(file, data, r.Begin) + if err != nil { + log.Error("File read error") + status = false + } else if int64(n) != r.Len() { + log.Error("File read underrun") + status = false + } + + // Send file data + if traceChannelLoad { + fmt.Fprint(os.Stderr, idEnd[id]) + } + netStream <- diffChunk{status, DataInterval{r, data}} + } + log.Info("Finished reading file") + fileStatus <- true +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client_test.go b/vendor/github.com/rancher/sparse-tools/sparse/client_test.go new file mode 100644 index 00000000..7a35e183 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/client_test.go @@ -0,0 +1,587 @@ +package sparse + +import ( + "testing" + + "github.com/rancher/sparse-tools/log" +) + +const localhost = "127.0.0.1" +const timeout = 5 //seconds +var remoteAddr = TCPEndPoint{localhost, 5000} + +func TestSyncAnyFile(t *testing.T) { + src := "src.bar" + dst := "dst.bar" + run := false + + if run { + // Sync + go TestServer(remoteAddr, timeout) + _, err := SyncFile(src, remoteAddr, dst, timeout) + + // Verify + if err != nil { + t.Fatal("sync error") + } + if !filesAreEqual(src, dst) { + t.Fatal("file content diverged") + } + } +} + +func TestSyncFile1(t *testing.T) { + // D H D => D D H + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile2(t *testing.T) { + // H D H => D H H + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile3(t *testing.T) { + // D H D => D D + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile4(t *testing.T) { + // H D H => D H + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile5(t *testing.T) { + // H D H => H D + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile6(t *testing.T) { + // H D H => D + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile7(t *testing.T) { + // H D H => H + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile8(t *testing.T) { + // D H D => + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{} + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncFile9(t *testing.T) { + // H D H => + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{} + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff1(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff2(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff3(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff4(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff5(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff6(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff7(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff8(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff9(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff10(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff11(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff12(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff13(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff14(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff15(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff16(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff17(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 28 * Blocks}}, + {SparseHole, Interval{28 * Blocks, 32 * Blocks}}, + {SparseData, Interval{32 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff18(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 28 * Blocks}}, + {SparseHole, Interval{28 * Blocks, 36 * Blocks}}, + {SparseData, Interval{36 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff19(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 31 * Blocks}}, + {SparseHole, Interval{31 * Blocks, 33 * Blocks}}, + {SparseData, Interval{33 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff20(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 32 * Blocks}}, + {SparseHole, Interval{32 * Blocks, 36 * Blocks}}, + {SparseData, Interval{36 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseData, Interval{0, 30 * Blocks}}, + {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, + {SparseData, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff21(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 28 * Blocks}}, + {SparseData, Interval{28 * Blocks, 32 * Blocks}}, + {SparseHole, Interval{32 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff22(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 28 * Blocks}}, + {SparseData, Interval{28 * Blocks, 36 * Blocks}}, + {SparseHole, Interval{36 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff23(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 31 * Blocks}}, + {SparseData, Interval{31 * Blocks, 33 * Blocks}}, + {SparseHole, Interval{33 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncDiff24(t *testing.T) { + layoutLocal := []FileInterval{ + {SparseHole, Interval{0, 32 * Blocks}}, + {SparseData, Interval{32 * Blocks, 36 * Blocks}}, + {SparseHole, Interval{36 * Blocks, 100 * Blocks}}, + } + layoutRemote := []FileInterval{ + {SparseHole, Interval{0, 30 * Blocks}}, + {SparseData, Interval{30 * Blocks, 34 * Blocks}}, + {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, + } + testSyncFile(t, layoutLocal, layoutRemote) +} + +func TestSyncHash1(t *testing.T) { + var hash1, hash2 []byte + { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + } + layoutRemote := layoutLocal + hash1 = testSyncFile(t, layoutLocal, layoutRemote) + } + { + + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 3 * Blocks}}, + } + layoutRemote := layoutLocal + hash2 = testSyncFile(t, layoutLocal, layoutRemote) + } + if !isHashDifferent(hash1, hash2) { + t.Fatal("Files with same data content but different layouts should have unique hashes") + } +} + +func TestSyncHash2(t *testing.T) { + var hash1, hash2 []byte + { + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + } + layoutRemote := []FileInterval{} + hash1 = testSyncFile(t, layoutLocal, layoutRemote) + } + { + + layoutLocal := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 3 * Blocks}}, + } + layoutRemote := []FileInterval{} + hash2 = testSyncFile(t, layoutLocal, layoutRemote) + } + if !isHashDifferent(hash1, hash2) { + t.Fatal("Files with same data content but different layouts should have unique hashes") + } +} + +func testSyncFile(t *testing.T, layoutLocal, layoutRemote []FileInterval) (hashLocal []byte) { + localPath := tempFilePath("ssync-src-") + remotePath := tempFilePath("ssync-dst-") + // Only log errors + log.LevelPush(log.LevelError) + defer log.LevelPop() + + filesCleanup(localPath, remotePath) + defer filesCleanup(localPath, remotePath) + + // Create test files + createTestSparseFile(localPath, layoutLocal) + if len(layoutRemote) > 0 { + // only create destination test file if layout is speciifed + createTestSparseFile(remotePath, layoutRemote) + } + + // Sync + go TestServer(remoteAddr, timeout) + hashLocal, err := SyncFile(localPath, remoteAddr, remotePath, timeout) + + // Verify + if err != nil { + t.Fatal("sync error") + } + if !filesAreEqual(localPath, remotePath) { + t.Fatal("file content diverged") + } + return +} + +// created in current dir for benchmark tests +var localBigPath = "ssync-src-file.bar" +var remoteBigPath = "ssync-dst-file.bar" + +func Test_1G_cleanup(*testing.T) { + // remove temporaries if the benchmarks below are not run + filesCleanup(localBigPath, remoteBigPath) +} + +func Benchmark_1G_InitFiles(b *testing.B) { + // Setup files + layoutLocal := []FileInterval{ + {SparseData, Interval{0, (256 << 10) * Blocks}}, + } + layoutRemote := []FileInterval{} + + filesCleanup(localBigPath, remoteBigPath) + createTestSparseFile(localBigPath, layoutLocal) + createTestSparseFile(remoteBigPath, layoutRemote) +} + +func Benchmark_1G_SendFiles_Whole(b *testing.B) { + log.LevelPush(log.LevelInfo) + defer log.LevelPop() + + go TestServer(remoteAddr, timeout) + _, err := SyncFile(localBigPath, remoteAddr, remoteBigPath, timeout) + + if err != nil { + b.Fatal("sync error") + } +} + +func Benchmark_1G_SendFiles_Diff(b *testing.B) { + log.LevelPush(log.LevelInfo) + defer log.LevelPop() + + go TestServer(remoteAddr, timeout) + _, err := SyncFile(localBigPath, remoteAddr, remoteBigPath, timeout) + + if err != nil { + b.Fatal("sync error") + } +} + +func Benchmark_1G_CheckFiles(b *testing.B) { + if !filesAreEqual(localBigPath, remoteBigPath) { + b.Error("file content diverged") + return + } + filesCleanup(localBigPath, remoteBigPath) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/file.go b/vendor/github.com/rancher/sparse-tools/sparse/file.go new file mode 100644 index 00000000..68c349fe --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/file.go @@ -0,0 +1,141 @@ +package sparse + +import ( + "crypto/sha1" + "os" + + "fmt" + + fio "github.com/rancher/sparse-tools/directfio" + "github.com/rancher/sparse-tools/log" +) + +func loadFileLayout(abortStream <-chan error, file *os.File, layoutStream chan<- FileInterval, errStream chan<- error) error { + size, err := file.Seek(0, os.SEEK_END) + if err != nil { + return err + } + go RetrieveLayoutStream(abortStream, file, Interval{0, size}, layoutStream, errStream) + return nil +} + +// IntervalSplitter limits file intervals to predefined batch size +func IntervalSplitter(spltterStream <-chan FileInterval, fileStream chan<- FileInterval) { + const batch = 32 * Blocks + for r := range spltterStream { + if verboseServer { + log.Debug("Interval Splitter:", r) + } + switch r.Kind { + case SparseHole: + // Process hole + fileStream <- r + case SparseData: + // Process data in chunks + for offset := r.Begin; offset < r.End; { + size := batch + if offset+size > r.End { + size = r.End - offset + } + interval := Interval{offset, offset + size} + if size == batch && interval.End%batch != 0 { + interval.End = interval.End / batch * batch + } + log.Debug("Interval Splitter data:", interval) + fileStream <- FileInterval{SparseData, interval} + offset += interval.Len() + } + } + } + close(fileStream) +} + +// HashedInterval FileInterval plus its data hash (to be sent to the client) +type HashedInterval struct { + FileInterval + Hash []byte +} + +func (i HashedInterval) String() string { + if len(i.Hash) > 0 { + return fmt.Sprintf("%v #%2x%2x %2x%2x", i.FileInterval, i.Hash[0], i.Hash[1], i.Hash[2], i.Hash[3]) + } + return fmt.Sprintf("%v # ", i.FileInterval) +} + +// HashedDataInterval FileInterval plus its hash and data +type HashedDataInterval struct { + HashedInterval + Data []byte +} + +// DataInterval FileInterval plus its data +type DataInterval struct { + FileInterval + Data []byte +} + +// HashSalt is common client/server hash salt +var HashSalt = []byte("TODO: randomize and exchange between client/server") + +// FileReader supports concurrent file reading +func FileReader(fileStream <-chan FileInterval, file *os.File, unorderedStream chan<- HashedDataInterval) { + for r := range fileStream { + switch r.Kind { + case SparseHole: + // Process hole + // hash := sha1.New() + // binary.PutVariant(data, r.Len) + // fileHash.Write(data) + var hash, data []byte + unorderedStream <- HashedDataInterval{HashedInterval{r, hash}, data} + + case SparseData: + // Read file data + data := make([]byte, r.Len()) + status := true + n, err := fio.ReadAt(file, data, r.Begin) + if err != nil { + status = false + log.Error("File read error", status) + } else if int64(n) != r.Len() { + status = false + log.Error("File read underrun") + } + hasher := sha1.New() + hasher.Write(HashSalt) + hasher.Write(data) + hash := hasher.Sum(nil) + unorderedStream <- HashedDataInterval{HashedInterval{r, hash}, data} + } + } + close(unorderedStream) +} + +// OrderIntervals puts back "out of order" read results +func OrderIntervals(prefix string, unorderedStream <-chan HashedDataInterval, orderedStream chan<- HashedDataInterval) { + pos := int64(0) + var m map[int64]HashedDataInterval // out of order completions + for r := range unorderedStream { + // Handle "in order" range + if pos == r.Begin { + log.Debug(prefix, r) + orderedStream <- r + pos = r.End + continue + } + + // push "out of order"" range + m[r.Begin] = r + + // check the "out of order" stash for "in order" + for pop, existsNext := m[pos]; existsNext; { + // pop in order range + log.Debug(prefix, pop) + orderedStream <- pop + delete(m, pos) + pos = pop.End + } + } + close(orderedStream) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/layout.go b/vendor/github.com/rancher/sparse-tools/sparse/layout.go new file mode 100644 index 00000000..16a57997 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/layout.go @@ -0,0 +1,271 @@ +package sparse + +import ( + "os" + "syscall" + + "fmt" + + "github.com/frostschutz/go-fibmap" + "github.com/rancher/sparse-tools/log" +) + +// Interval [Begin, End) is non-inclusive at the End +type Interval struct { + Begin, End int64 +} + +// Len returns length of Interval +func (interval Interval) Len() int64 { + return interval.End - interval.Begin +} + +// String conversion +func (interval Interval) String() string { + return fmt.Sprintf("[%8d:%8d](%3d)", interval.Begin/Blocks, interval.End/Blocks, interval.Len()/Blocks) +} + +// FileIntervalKind distinguishes between data and hole +type FileIntervalKind int + +// Sparse file Interval types +const ( + SparseData FileIntervalKind = 1 + iota + SparseHole + SparseIgnore // ignore file interval (equal src vs dst part) +) + +// FileInterval describes either sparse data Interval or a hole +type FileInterval struct { + Kind FileIntervalKind + Interval +} + +func (i FileInterval) String() string { + kind := "?" + switch i.Kind { + case SparseData: + kind = "D" + case SparseHole: + kind = " " + case SparseIgnore: + kind = "i" + } + return fmt.Sprintf("%s%v", kind, i.Interval) +} + +// Storage block size in bytes +const ( + Blocks int64 = 4 << 10 // 4k +) + +// os.Seek sparse whence values. +const ( + // Adjust the file offset to the next location in the file + // greater than or equal to offset containing data. If offset + // points to data, then the file offset is set to offset. + seekData int = 3 + + // Adjust the file offset to the next hole in the file greater + // than or equal to offset. If offset points into the middle of + // a hole, then the file offset is set to offset. If there is no + // hole past offset, then the file offset is adjusted to the End + // of the file (i.e., there is an implicit hole at the End of any + // file). + seekHole int = 4 +) + +// syscall.Fallocate mode bits +const ( + // default is extend size + fallocFlKeepSize uint32 = 1 + + // de-allocates range + fallocFlPunchHole uint32 = 2 +) + +// RetrieveLayoutStream streams sparse file data/hole layout +// Based on fiemap +// To abort: abortStream <- error +// Check status: err := <- errStream +// Usage: go RetrieveLayoutStream(...) +func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, layoutStream chan<- FileInterval, errStream chan<- error) { + const extents = 1024 + const chunkSizeMax = 1 /*GB*/ << 30 + chunkSize := r.Len() + if chunkSize > chunkSizeMax { + chunkSize = chunkSizeMax + } + + chunk := Interval{r.Begin, r.Begin + chunkSize} + // Process file extents for each chunk + intervalLast := Interval{chunk.Begin, chunk.Begin} + for chunk.Begin < r.End { + if chunk.End > r.End { + chunk.End = r.End + } + + for more := true; more && chunk.Len() > 0; { + ext, errno := fibmap.Fiemap(file.Fd(), uint64(chunk.Begin), uint64(chunk.Len()), 1024) + if errno != 0 { + close(layoutStream) + errStream <- &os.PathError{Op: "Fiemap", Path: file.Name(), Err: errno} + return + } + if len(ext) == 0 { + break + } + + // Process each extents + for _, e := range ext { + interval := Interval{int64(e.Logical), int64(e.Logical + e.Length)} + log.Debug("Extent:", interval, e.Flags) + if e.Flags&fibmap.FIEMAP_EXTENT_LAST != 0 { + more = false + } + if intervalLast.End < interval.Begin { + if intervalLast.Len() > 0 { + // Pop last Data + layoutStream <- FileInterval{SparseData, intervalLast} + } + // report hole + intervalLast = Interval{intervalLast.End, interval.Begin} + layoutStream <- FileInterval{SparseHole, intervalLast} + + // Start data + intervalLast = interval + } else { + // coalesce + intervalLast.End = interval.End + } + chunk.Begin = interval.End + } + } + chunk = Interval{chunk.End, chunk.End + chunkSizeMax} + } + + if intervalLast.Len() > 0 { + // Pop last Data + layoutStream <- FileInterval{SparseData, intervalLast} + } + if intervalLast.End < r.End { + // report hole + layoutStream <- FileInterval{SparseHole, Interval{intervalLast.End, r.End}} + } + + close(layoutStream) + errStream <- nil + return +} + +// RetrieveLayoutStream0 streams sparse file data/hole layout +// Deprecated; Based on file.seek; use RetrieveLayoutStream instead +// To abort: abortStream <- error +// Check status: err := <- errStream +// Usage: go RetrieveLayoutStream(...) +func RetrieveLayoutStream0(abortStream <-chan error, file *os.File, r Interval, layoutStream chan<- FileInterval, errStream chan<- error) { + curr := r.Begin + + // Data or hole? + offsetData, errData := file.Seek(curr, seekData) + offsetHole, errHole := file.Seek(curr, seekHole) + var interval FileInterval + if errData != nil { + // Hole only + interval = FileInterval{SparseHole, Interval{curr, r.End}} + if interval.Len() > 0 { + layoutStream <- interval + } + close(layoutStream) + errStream <- nil + return + } else if errHole != nil { + // Data only + interval = FileInterval{SparseData, Interval{curr, r.End}} + if interval.Len() > 0 { + layoutStream <- interval + } + close(layoutStream) + errStream <- nil + return + } + + if offsetData < offsetHole { + interval = FileInterval{SparseData, Interval{curr, offsetHole}} + curr = offsetHole + } else { + interval = FileInterval{SparseHole, Interval{curr, offsetData}} + curr = offsetData + } + if interval.Len() > 0 { + layoutStream <- interval + } + + for curr < r.End { + // Check abort condition + select { + case err := <-abortStream: + close(layoutStream) + errStream <- err + return + default: + } + + var whence int + if SparseData == interval.Kind { + whence = seekData + } else { + whence = seekHole + } + + // Note: file.Seek masks syscall.ENXIO hence syscall is used instead + next, errno := syscall.Seek(int(file.Fd()), curr, whence) + if errno != nil { + switch errno { + case syscall.ENXIO: + // no more intervals + next = r.End // close the last interval + default: + // mimic standard "os"" package error handler + close(layoutStream) + errStream <- &os.PathError{Op: "seek", Path: file.Name(), Err: errno} + return + } + } + if SparseData == interval.Kind { + // End of data, handle the last hole if any + interval = FileInterval{SparseHole, Interval{curr, next}} + } else { + // End of hole, handle the last data if any + interval = FileInterval{SparseData, Interval{curr, next}} + } + curr = next + if interval.Len() > 0 { + layoutStream <- interval + } + } + close(layoutStream) + errStream <- nil + return +} + +// RetrieveLayout retrieves sparse file hole and data layout +func RetrieveLayout(file *os.File, r Interval) ([]FileInterval, error) { + layout := make([]FileInterval, 0, 1024) + abortStream := make(chan error) + layoutStream := make(chan FileInterval, 128) + errStream := make(chan error) + + go RetrieveLayoutStream(abortStream, file, r, layoutStream, errStream) + for interval := range layoutStream { + layout = append(layout, interval) + } + return layout, <-errStream +} + +// PunchHole in a sparse file, preserve file size +func PunchHole(file *os.File, hole Interval) error { + fd := int(file.Fd()) + mode := fallocFlPunchHole | fallocFlKeepSize + return syscall.Fallocate(fd, mode, hole.Begin, hole.Len()) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/layout_test.go b/vendor/github.com/rancher/sparse-tools/sparse/layout_test.go new file mode 100644 index 00000000..a1251f1e --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/layout_test.go @@ -0,0 +1,192 @@ +package sparse + +import ( + "os" + "reflect" + "testing" + + "github.com/rancher/sparse-tools/log" +) + +var name = tempFilePath("") + +func TestLayout0(t *testing.T) { + layoutModel := []FileInterval{} + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout1(t *testing.T) { + layoutModel := []FileInterval{{SparseHole, Interval{0, 4 * Blocks}}} + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout2(t *testing.T) { + layoutModel := []FileInterval{{SparseData, Interval{0, 4 * Blocks}}} + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout3(t *testing.T) { + layoutModel := []FileInterval{ + {SparseHole, Interval{0, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 4 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout4(t *testing.T) { + layoutModel := []FileInterval{ + {SparseData, Interval{0, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 4 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout5(t *testing.T) { + layoutModel := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout6(t *testing.T) { + layoutModel := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout7(t *testing.T) { + layoutModel := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutExpected := []FileInterval{ + {SparseData, Interval{0, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutExpected) +} + +func TestLayout8(t *testing.T) { + layoutModel := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutExpected := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 3 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutExpected) +} + +func TestLayout9(t *testing.T) { + layoutModel := []FileInterval{ + {SparseData, Interval{0, 256 * Blocks}}, + {SparseHole, Interval{256 * Blocks, (256<<10 - 256) * Blocks}}, + {SparseData, Interval{(256<<10 - 256) * Blocks, 256 << 10 * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout10(t *testing.T) { + layoutModel := []FileInterval{ + {SparseHole, Interval{0, (256<<10 - 128) * Blocks}}, + {SparseData, Interval{(256<<10 - 128) * Blocks, (256<<10 - 8) * Blocks}}, + {SparseHole, Interval{(256<<10 - 8) * Blocks, (256<<10 + 8) * Blocks}}, + {SparseData, Interval{(256<<10 + 8) * Blocks, (256<<10 + 128) * Blocks}}, + {SparseHole, Interval{(256<<10 + 128) * Blocks, (256 << 10 * 2) * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestLayout11(t *testing.T) { + layoutModel := []FileInterval{ + {SparseHole, Interval{0, (256<<10 - 8) * Blocks}}, + {SparseData, Interval{(256<<10 - 8) * Blocks, (256<<10 + 8) * Blocks}}, + {SparseHole, Interval{(256<<10 + 8) * Blocks, (256 << 10 * 2) * Blocks}}, + } + layoutTest(t, name, layoutModel, layoutModel) +} + +func TestPunchHole0(t *testing.T) { + layoutModel := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutExpected := []FileInterval{ + {SparseHole, Interval{0 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + punchHoleTest(t, name, layoutModel, Interval{0, 1 * Blocks}, layoutExpected) +} + +func layoutTest(t *testing.T, name string, layoutModel, layoutExpected []FileInterval) { + log.LevelPush(log.LevelInfo) + defer log.LevelPop() + + defer fileCleanup(name) + createTestSparseFile(name, layoutModel) + + f, err := os.Open(name) + if err != nil { + t.Fatal(err) + } + defer f.Close() + + size, err := f.Seek(0, os.SEEK_END) + if err != nil { + t.Fatal(err) + } + + layoutActual, err := RetrieveLayout(f, Interval{0, size}) + if err != nil || !reflect.DeepEqual(layoutExpected, layoutActual) { + t.Fatal("wrong sparse layout") + } + + if checkTestSparseFile(name, layoutModel) != nil { + t.Fatal("wrong sparse layout content") + } +} + +func punchHoleTest(t *testing.T, name string, layoutModel []FileInterval, hole Interval, layoutExpected []FileInterval) { + createTestSparseFile(name, layoutModel) + + defer fileCleanup(name) + f, err := os.OpenFile(name, os.O_RDWR, 0) + if err != nil { + t.Fatal(err) + } + defer f.Close() + + size, err := f.Seek(0, os.SEEK_END) + if err != nil { + t.Fatal(err) + } + + err = PunchHole(f, hole) + if err != nil { + t.Fatal(err) + } + + layoutActual, err := RetrieveLayout(f, Interval{0, size}) + if err != nil || !reflect.DeepEqual(layoutExpected, layoutActual) { + t.Fatal("wrong sparse layout") + } +} + +func makeData(interval FileInterval) []byte { + data := make([]byte, interval.Len()) + if SparseData == interval.Kind { + for i := range data { + data[i] = byte(interval.Begin/Blocks + 1) + } + } + return data +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/server.go b/vendor/github.com/rancher/sparse-tools/sparse/server.go new file mode 100644 index 00000000..8fe59db7 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/server.go @@ -0,0 +1,396 @@ +package sparse + +import ( + "crypto/sha1" + "encoding/binary" + "encoding/gob" + "hash" + "net" + "os" + "strconv" + "time" + + fio "github.com/rancher/sparse-tools/directfio" + "github.com/rancher/sparse-tools/log" +) + +// Server daemon +func Server(addr TCPEndPoint, timeout int) { + server(addr, true /*serve single connection for now*/, timeout) +} + +// TestServer daemon serves only one connection for each test then exits +func TestServer(addr TCPEndPoint, timeout int) { + server(addr, true, timeout) +} + +const verboseServer = true + +func server(addr TCPEndPoint, serveOnce /*test flag*/ bool, timeout int) { + serverConnectionTimeout := time.Duration(timeout) * time.Second + // listen on all interfaces + EndPoint := addr.Host + ":" + strconv.Itoa(int(addr.Port)) + laddr, err := net.ResolveTCPAddr("tcp", EndPoint) + if err != nil { + log.Fatal("Connection listener address resolution error:", err) + } + ln, err := net.ListenTCP("tcp", laddr) + if err != nil { + log.Fatal("Connection listener error:", err) + } + defer ln.Close() + ln.SetDeadline(time.Now().Add(serverConnectionTimeout)) + log.Info("Sync server is up...") + + for { + conn, err := ln.AcceptTCP() + if err != nil { + log.Fatal("Connection accept error:", err) + } + + if serveOnce { + // This is to avoid server listening port conflicts while running tests + // exit after single connection request + serveConnection(conn) + break + } + + go serveConnection(conn) + } + log.Info("Sync server exit.") +} + +type requestCode int + +const ( + requestMagic requestCode = 31415926 + syncRequestCode requestCode = 1 +) + +type requestHeader struct { + Magic requestCode + Code requestCode +} + +func serveConnection(conn net.Conn) { + defer conn.Close() + + decoder := gob.NewDecoder(conn) + var request requestHeader + err := decoder.Decode(&request) + if err != nil { + log.Fatal("Protocol decoder error:", err) + return + } + if requestMagic != request.Magic { + log.Error("Bad request") + return + } + + switch request.Code { + case syncRequestCode: + var path string + err := decoder.Decode(&path) + if err != nil { + log.Fatal("Protocol decoder error:", err) + return + } + var size int64 + err = decoder.Decode(&size) + if err != nil { + log.Fatal("Protocol decoder error:", err) + return + } + encoder := gob.NewEncoder(conn) + serveSyncRequest(encoder, decoder, path, size) + } +} + +func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64) { + + // Open destination file + file, err := fio.OpenFile(path, os.O_RDWR, 0666) + if err != nil { + file, err = os.Create(path) + if err != nil { + log.Error("Failed to create file:", string(path), err) + encoder.Encode(false) // NACK request + return + } + } + defer file.Close() + + // Resize the file + if err = file.Truncate(size); err != nil { + log.Error("Failed to resize file:", string(path), err) + encoder.Encode(false) // NACK request + return + } + + // open file + fileRO, err := fio.OpenFile(path, os.O_RDONLY, 0) + if err != nil { + log.Error("Failed to open file for reading:", string(path), err) + encoder.Encode(false) // NACK request + return + } + defer fileRO.Close() + + abortStream := make(chan error) + layoutStream := make(chan FileInterval, 128) + errStream := make(chan error) + + fileStream := make(chan FileInterval, 128) + unorderedStream := make(chan HashedDataInterval, 128) + orderedStream := make(chan HashedDataInterval, 128) + netOutStream := make(chan HashedInterval, 128) + netOutDoneStream := make(chan bool) + + netInStream := make(chan DataInterval, 128) + fileWrittenStreamDone := make(chan bool) + checksumStream := make(chan DataInterval, 128) + resultStream := make(chan []byte) + + // Initiate interval loading... + err = loadFileLayout(abortStream, fileRO, layoutStream, errStream) + if err != nil { + encoder.Encode(false) // NACK request + return + } + encoder.Encode(true) // ACK request + + go IntervalSplitter(layoutStream, fileStream) + go FileReader(fileStream, fileRO, unorderedStream) + go OrderIntervals("dst:", unorderedStream, orderedStream) + go Tee(orderedStream, netOutStream, checksumStream) + + // Send layout along with data hashes + go netSender(netOutStream, encoder, netOutDoneStream) + go netReceiver(decoder, file, netInStream, fileWrittenStreamDone) // receiver and checker + go Validator(checksumStream, netInStream, resultStream) + + // Block till completion + status := true + err = <-errStream // Done with file loadaing, possibly aborted on error + if err != nil { + log.Error("Sync server file load aborted:", err) + status = false + } + status = <-netOutDoneStream && status // done sending dst hashes + status = <-fileWrittenStreamDone && status // done writing dst file + hash := <-resultStream // done processing diffs + + // reply to client with status + log.Info("Sync sending server status=", status) + err = encoder.Encode(status) + if err != nil { + log.Fatal("Protocol encoder error:", err) + return + } + // reply with local hash + err = encoder.Encode(hash) + if err != nil { + log.Fatal("Protocol encoder error:", err) + return + } +} + +// Tee ordered intervals into the network and checksum checker +func Tee(orderedStream <-chan HashedDataInterval, netOutStream chan<- HashedInterval, checksumStream chan<- DataInterval) { + for r := range orderedStream { + netOutStream <- HashedInterval{r.FileInterval, r.Hash} + checksumStream <- DataInterval{r.FileInterval, r.Data} + } + close(netOutStream) + close(checksumStream) +} + +func netSender(netOutStream <-chan HashedInterval, encoder *gob.Encoder, netOutDoneStream chan<- bool) { + for r := range netOutStream { + if verboseServer { + log.Debug("Server.netSender: sending", r.FileInterval) + } + err := encoder.Encode(r) + if err != nil { + log.Fatal("Protocol encoder error:", err) + netOutDoneStream <- false + return + } + } + + rEOF := HashedInterval{FileInterval{SparseIgnore, Interval{}}, make([]byte, 0)} + if rEOF.Len() != 0 { + log.Fatal("Server.netSender internal error") + } + // err := encoder.Encode(HashedInterval{FileInterval{}, make([]byte, 0)}) + err := encoder.Encode(rEOF) + if err != nil { + log.Fatal("Protocol encoder error:", err) + netOutDoneStream <- false + return + } + if verboseServer { + log.Debug("Server.netSender: finished sending hashes") + } + netOutDoneStream <- true +} + +func netReceiver(decoder *gob.Decoder, file *os.File, netInStream chan<- DataInterval, fileWrittenStreamDone chan<- bool) { + // receive & process data diff + status := true + for status { + var delta FileInterval + err := decoder.Decode(&delta) + if err != nil { + log.Fatal("Protocol decoder error:", err) + status = false + break + } + log.Debug("receiving delta [", delta, "]") + if 0 == delta.Len() { + log.Debug("received end of transimission marker") + break // end of diff + } + switch delta.Kind { + case SparseData: + // Receive data + var data []byte + err = decoder.Decode(&data) + if err != nil { + log.Fatal("Protocol data decoder error:", err) + status = false + break + } + if int64(len(data)) != delta.Len() { + log.Fatal("Failed to receive data, expected=", delta.Len(), "received=", len(data)) + status = false + break + } + // Push for vaildator processing + netInStream <- DataInterval{delta, data} + + log.Debug("writing data...") + _, err = fio.WriteAt(file, data, delta.Begin) + if err != nil { + log.Error("Failed to write file") + status = false + break + } + case SparseHole: + // Push for vaildator processing + netInStream <- DataInterval{delta, make([]byte, 0)} + + log.Debug("trimming...") + err := PunchHole(file, delta.Interval) + if err != nil { + log.Error("Failed to trim file") + status = false + break + } + case SparseIgnore: + // Push for vaildator processing + netInStream <- DataInterval{delta, make([]byte, 0)} + log.Debug("ignoring...") + } + } + + log.Debug("Server.netReceiver done, sync") + close(netInStream) + fileWrittenStreamDone <- status +} + +func logData(prefix string, data []byte) { + size := len(data) + if size > 0 { + log.Debug("\t", prefix, "of", size, "bytes", data[0], "...") + } else { + log.Debug("\t", prefix, "of", size, "bytes") + } +} + +func hashFileData(fileHasher hash.Hash, dataLen int64, data []byte) { + // Hash hole length or data if any + if len(data) == 0 { + // hash hole + hole := make([]byte, 8) + binary.PutVarint(hole, dataLen) + fileHasher.Write(hole) + + } else { + fileHasher.Write(data) + } +} + +// Validator merges source and diff data; produces hash of the destination file +func Validator(checksumStream, netInStream <-chan DataInterval, resultStream chan<- []byte) { + fileHasher := sha1.New() + //TODO: error handling + fileHasher.Write(HashSalt) + r := <-checksumStream // original dst file data + q := <-netInStream // diff data + for q.Len() != 0 || r.Len() != 0 { + if r.Len() == 0 /*end of dst file*/ { + // Hash diff data + if verboseServer { + logData("RHASH", q.Data) + } + hashFileData(fileHasher, q.Len(), q.Data) + q = <-netInStream + } else if q.Len() == 0 /*end of diff file*/ { + // Hash original data + if verboseServer { + logData("RHASH", r.Data) + } + hashFileData(fileHasher, r.Len(), r.Data) + r = <-checksumStream + } else { + qi := q.Interval + ri := r.Interval + if qi.Begin == ri.Begin { + if qi.End > ri.End { + log.Fatal("Server.Validator internal error, diff=", q.FileInterval, "local=", r.FileInterval) + } else if qi.End < ri.End { + // Hash diff data + if verboseServer { + log.Debug("Server.Validator: hashing diff", q.FileInterval, r.FileInterval) + } + if verboseServer { + logData("RHASH", q.Data) + } + hashFileData(fileHasher, q.Len(), q.Data) + r.Begin = q.End + q = <-netInStream + } else { + if q.Kind == SparseIgnore { + // Hash original data + if verboseServer { + log.Debug("Server.Validator: hashing original", r.FileInterval) + } + if verboseServer { + logData("RHASH", r.Data) + } + hashFileData(fileHasher, r.Len(), r.Data) + } else { + // Hash diff data + if verboseServer { + log.Debug("Server.Validator: hashing diff", q.FileInterval) + } + if verboseServer { + logData("RHASH", q.Data) + } + hashFileData(fileHasher, q.Len(), q.Data) + } + q = <-netInStream + r = <-checksumStream + } + } else { + log.Fatal("Server.Validator internal error, diff=", q.FileInterval, "local=", r.FileInterval) + } + } + } + + if verboseServer { + log.Debug("Server.Validator: finished") + } + resultStream <- fileHasher.Sum(nil) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go new file mode 100644 index 00000000..2af5d3b9 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go @@ -0,0 +1,109 @@ +package sparse + +import ( + "os" + "syscall" + + fio "github.com/rancher/sparse-tools/directfio" + "github.com/rancher/sparse-tools/log" +) + +// FoldFile folds child snapshot data into its parent +func FoldFile(childFileName, parentFileName string) error { + + childFInfo, err := os.Stat(childFileName) + if err != nil { + panic("os.Stat(childFileName) failed, error: " + err.Error()) + } + parentFInfo, err := os.Stat(parentFileName) + if err != nil { + panic("os.Stat(parentFileName) failed, error: " + err.Error()) + } + + // ensure no directory + if childFInfo.IsDir() || parentFInfo.IsDir() { + panic("at least one file is directory, not a normal file") + } + + // ensure file sizes are equal + if childFInfo.Size() != parentFInfo.Size() { + panic("file sizes are not equal") + } + + // open child and parent files + childFile, err := fio.OpenFile(childFileName, os.O_RDONLY, 0) + if err != nil { + panic("Failed to open childFile, error: " + err.Error()) + } + defer childFile.Close() + + parentFile, err := fio.OpenFile(parentFileName, os.O_WRONLY, 0) + if err != nil { + panic("Failed to open parentFile, error: " + err.Error()) + } + defer parentFile.Close() + + return coalesce(parentFile, childFile) +} + +func coalesce(parentFile *os.File, childFile *os.File) error { + blockSize, err := getFileSystemBlockSize(childFile) + if err != nil { + panic("can't get FS block size, error: " + err.Error()) + } + var data, hole int64 + for { + data, err = syscall.Seek(int(childFile.Fd()), hole, seekData) + if err != nil { + // reaches EOF + errno := err.(syscall.Errno) + if errno == syscall.ENXIO { + break + } else { + // unexpected errors + log.Fatal("Failed to syscall.Seek SEEK_DATA") + return err + } + } + hole, err = syscall.Seek(int(childFile.Fd()), data, seekHole) + if err != nil { + log.Fatal("Failed to syscall.Seek SEEK_HOLE") + return err + } + + // now we have a data start offset and length(hole - data) + // let's read from child and write to parent file block by block + _, err = parentFile.Seek(data, os.SEEK_SET) + if err != nil { + log.Fatal("Failed to os.Seek os.SEEK_SET") + return err + } + + offset := data + buffer := fio.AllocateAligned(blockSize) + for offset != hole { + // read a block from child, maybe use bufio or Reader stream + n, err := fio.ReadAt(childFile, buffer, offset) + if n != len(buffer) || err != nil { + log.Fatal("Failed to read from childFile") + return err + } + // write a block to parent + n, err = fio.WriteAt(parentFile, buffer, offset) + if n != len(buffer) || err != nil { + log.Fatal("Failed to write to parentFile") + return err + } + offset += int64(n) + } + } + + return nil +} + +// get the file system block size +func getFileSystemBlockSize(f *os.File) (int, error) { + var stat syscall.Stat_t + err := syscall.Stat(f.Name(), &stat) + return int(stat.Blksize), err +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go b/vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go new file mode 100644 index 00000000..95e0f7dc --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go @@ -0,0 +1,149 @@ +package sparse + +import ( + "testing" + + "github.com/rancher/sparse-tools/log" +) + +func TestFoldLayout1(t *testing.T) { + // D H D => D D H + layoutFrom := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTo := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutModel := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + + layoutResult := foldLayout(layoutFrom, layoutTo) + status := checkLayout(layoutResult, layoutModel) + if !status { + t.Fatal("Folded layout diverged") + } +} + +func TestFoldLayout2(t *testing.T) { + // H D H => D H H + layoutFrom := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTo := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutModel := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + + layoutResult := foldLayout(layoutFrom, layoutTo) + status := checkLayout(layoutResult, layoutModel) + if !status { + t.Fatal("Folded layout diverged") + } +} + +func TestFoldFile1(t *testing.T) { + // D H D => D D H + layoutFrom := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseData, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTo := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + testFoldFile(t, layoutFrom, layoutTo) +} + +func TestFoldFile2(t *testing.T) { + // H D H => D H H + layoutFrom := []FileInterval{ + {SparseHole, Interval{0, 1 * Blocks}}, + {SparseData, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + layoutTo := []FileInterval{ + {SparseData, Interval{0, 1 * Blocks}}, + {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, + {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, + } + testFoldFile(t, layoutFrom, layoutTo) +} + +func foldLayout(from, to []FileInterval) []FileInterval { + if len(from) != len(to) { + log.Fatal("foldLayout: non equal length not implemented") + } + result := make([]FileInterval, len(to)) + copy(result, to) + for i, interval := range from { + if to[i].Interval != interval.Interval { + log.Fatal("foldLayout: subinterval feature not implemented") + } + if interval.Kind == SparseData { + result[i] = interval + } + } + return result +} + +func checkLayout(from, to []FileInterval) bool { + if len(from) != len(to) { + log.Error("checkLayout: non equal length:", len(from), len(to)) + return false + } + for i, interval := range from { + if to[i] != interval { + log.Error("checkayout: intervals not equal:", interval, to[i]) + return false + } + } + return true +} + +func testFoldFile(t *testing.T, layoutFrom, layoutTo []FileInterval) (hashLocal []byte) { + localPath := tempFilePath("sfold-src-") + remotePath := tempFilePath("sfold-dst-") + + // Only log errors + log.LevelPush(log.LevelError) + defer log.LevelPop() + + filesCleanup(localPath, remotePath) + defer filesCleanup(localPath, remotePath) + + // Create test files + createTestSparseFile(localPath, layoutFrom) + createTestSparseFile(remotePath, layoutTo) + layoutResult := foldLayout(layoutFrom, layoutTo) + + // Fold + err := FoldFile(localPath, remotePath) + + // Verify + if err != nil { + t.Fatal("Fold error:", err) + } + + err = checkTestSparseFile(remotePath, layoutResult) + if err != nil { + t.Fatal("Folded content diverged:", err) + } + return +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go b/vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go new file mode 100644 index 00000000..96f19ad7 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go @@ -0,0 +1,327 @@ +package sparse + +import ( + "bytes" + "errors" + "fmt" + "math/rand" + "os" + "testing" + + "time" + + "strconv" + + "github.com/rancher/sparse-tools/log" +) + +type TestFileInterval struct { + FileInterval + dataMask byte // XORed with other generated data bytes +} + +func (i TestFileInterval) String() string { + return fmt.Sprintf("{%v %2X}", i.FileInterval, i.dataMask) +} + +func TestRandomLayout10MB(t *testing.T) { + const seed = 0 + const size = 10 /*MB*/ << 20 + prefix := "ssync" + name := tempFilePath(prefix) + defer fileCleanup(name) + + layoutStream := generateLayout(prefix, size, seed) + layout1, layout2 := teeLayout(layoutStream) + + done := createTestSparseFileLayout(name, size, layout1) + layoutTmp := unstreamLayout(layout2) + <-done + log.Info("Done writing layout of ", len(layoutTmp), "items") + + layout := streamLayout(layoutTmp) + err := checkTestSparseFileLayout(name, layout) + if err != nil { + t.Fatal(err) + } +} + +func TestRandomLayout100MB(t *testing.T) { + const seed = 0 + const size = 100 /*MB*/ << 20 + prefix := "ssync" + name := tempFilePath(prefix) + defer fileCleanup(name) + + layoutStream := generateLayout(prefix, size, seed) + layout1, layout2 := teeLayout(layoutStream) + + done := createTestSparseFileLayout(name, size, layout1) + layoutTmp := unstreamLayout(layout2) + <-done + log.Info("Done writing layout of ", len(layoutTmp), "items") + + layout := streamLayout(layoutTmp) + err := checkTestSparseFileLayout(name, layout) + if err != nil { + t.Fatal(err) + } +} + +const srcPrefix = "ssync-src" +const dstPrefix = "ssync-dst" + +func TestRandomSync100MB(t *testing.T) { + const seed = 1 + const size = 100 /*MB*/ << 20 + srcName := tempFilePath(srcPrefix) + dstName := tempFilePath(dstPrefix) + RandomSync(t, size, seed, srcName, dstName, true /*create dstFile*/) +} + +func TestRandomSyncNoDst100MB(t *testing.T) { + const seed = 2 + const size = 100 /*MB*/ << 20 + srcName := tempFilePath(srcPrefix) + dstName := tempFilePath(dstPrefix) + RandomSync(t, size, seed, srcName, dstName, false /*no dstFile*/) +} + +func TestRandomSyncCustomGB(t *testing.T) { + if testing.Short() { + t.Skip("skipped custom random sync") + } + + // random seed + seed := time.Now().UnixNano() + log.LevelPush(log.LevelInfo) + defer log.LevelPop() + log.Info("seed=", seed) + + // default size + var size = int64(100) /*MB*/ << 20 + arg := os.Args[len(os.Args)-1] + sizeGB, err := strconv.Atoi(arg) + if err != nil { + log.Info("") + log.Info("Using default 100MB size for random seed test") + log.Info("For alternative size in GB and in current dir(vs tmp) use -timeout 10m -args ") + log.Info("Increase the optional -timeout value for 20GB and larger sizes") + log.Info("") + srcName := tempFilePath(srcPrefix) + dstName := tempFilePath(dstPrefix) + RandomSync(t, size, seed, srcName, dstName, true /*create dstFile*/) + } else { + log.Info("Using ", sizeGB, "(GB) size for random seed test") + size = int64(sizeGB) << 30 + srcName := tempBigFilePath(srcPrefix) + dstName := tempBigFilePath(dstPrefix) + RandomSync(t, size, seed, srcName, dstName, true /*create dstFile*/) + } +} + +func RandomSync(t *testing.T, size, seed int64, srcPath, dstPath string, dstCreate bool) { + const localhost = "127.0.0.1" + const timeout = 10 //seconds + var remoteAddr = TCPEndPoint{localhost, 5000} + + defer filesCleanup(srcPath, dstPath) + + srcLayoutStream1, srcLayoutStream2 := teeLayout(generateLayout(srcPrefix, size, seed)) + dstLayoutStream := generateLayout(dstPrefix, size, seed+1) + + srcDone := createTestSparseFileLayout(srcPath, size, srcLayoutStream1) + srcLayout := unstreamLayout(srcLayoutStream2) + if dstCreate { + // Create destination with some data + dstDone := createTestSparseFileLayout(dstPath, size, dstLayoutStream) + <-dstDone + } + <-srcDone + log.Info("Done writing layout of ", len(srcLayout), "items") + + log.Info("Syncing...") + + go TestServer(remoteAddr, timeout) + _, err := SyncFile(srcPath, remoteAddr, dstPath, timeout) + + if err != nil { + t.Fatal("sync error") + } + log.Info("...syncing done") + + log.Info("Checking...") + layoutStream := streamLayout(srcLayout) + err = checkTestSparseFileLayout(dstPath, layoutStream) + if err != nil { + t.Fatal(err) + } +} + +func unstreamLayout(in <-chan TestFileInterval) []TestFileInterval { + layout := make([]TestFileInterval, 0, 4096) + for i := range in { + log.Trace("unstream", i) + layout = append(layout, i) + } + return layout +} + +func streamLayout(in []TestFileInterval) (out chan TestFileInterval) { + out = make(chan TestFileInterval, 128) + + go func() { + for _, i := range in { + log.Trace("stream", i) + out <- i + } + close(out) + }() + + return out +} + +func teeLayout(in <-chan TestFileInterval) (out1 chan TestFileInterval, out2 chan TestFileInterval) { + out1 = make(chan TestFileInterval, 128) + out2 = make(chan TestFileInterval, 128) + + go func() { + for i := range in { + log.Trace("Tee1...") + out1 <- i + log.Trace("Tee2...") + out2 <- i + } + close(out1) + close(out2) + }() + + return out1, out2 +} + +func generateLayout(prefix string, size, seed int64) <-chan TestFileInterval { + const maxInterval = 256 // Blocks + layoutStream := make(chan TestFileInterval, 128) + r := rand.New(rand.NewSource(seed)) + + go func() { + offset := int64(0) + for offset < size { + blocks := int64(r.Intn(maxInterval)) + 1 // 1..maxInterval + length := blocks * Blocks + if offset+length > size { + // don't overshoot size + length = size - offset + } + + interval := Interval{offset, offset + length} + offset += interval.Len() + + kind := SparseHole + var mask byte + if r.Intn(2) == 0 { + // Data + kind = SparseData + mask = 0xAA * byte(r.Intn(10)/9) // 10% + } + t := TestFileInterval{FileInterval{kind, interval}, mask} + log.Debug(prefix, t) + layoutStream <- t + } + close(layoutStream) + }() + + return layoutStream +} + +func makeIntervalData(interval TestFileInterval) []byte { + data := make([]byte, interval.Len()) + if SparseData == interval.Kind { + for i := range data { + value := byte((interval.Begin + int64(i)) / Blocks) + data[i] = interval.dataMask ^ value + } + } + return data +} + +func createTestSparseFileLayout(name string, fileSize int64, layout <-chan TestFileInterval) (done chan struct{}) { + done = make(chan struct{}) + + // Fill up file with layout data + go func() { + f, err := os.Create(name) + if err != nil { + log.Fatal(err) + } + err = f.Truncate(fileSize) + if err != nil { + log.Fatal(err) + } + + for interval := range layout { + log.Debug("writing...", interval) + if SparseData == interval.Kind { + size := batch * Blocks + for offset := interval.Begin; offset < interval.End; { + if offset+size > interval.End { + size = interval.End - offset + } + chunkInterval := TestFileInterval{FileInterval{SparseData, Interval{offset, offset + size}}, interval.dataMask} + data := makeIntervalData(chunkInterval) + _, err = f.WriteAt(data, offset) + if err != nil { + log.Fatal(err) + } + offset += size + } + } + } + f.Sync() + f.Close() + close(done) + }() + + return done +} + +func checkTestSparseFileLayout(name string, layout <-chan TestFileInterval) error { + f, err := os.Open(name) + if err != nil { + log.Fatal(err) + } + defer f.Close() + + // Read and check data + for interval := range layout { + log.Debug("checking...", interval) + if SparseData == interval.Kind { + size := batch * Blocks + for offset := interval.Begin; offset < interval.End; { + if offset+size > interval.End { + size = interval.End - offset + } + dataModel := makeIntervalData(TestFileInterval{FileInterval{SparseData, Interval{offset, offset + size}}, interval.dataMask}) + data := make([]byte, size) + f.ReadAt(data, offset) + offset += size + + if !bytes.Equal(data, dataModel) { + return errors.New(fmt.Sprint("data equality check failure at", interval)) + } + } + } else if SparseHole == interval.Kind { + layoutActual, err := RetrieveLayout(f, interval.Interval) + if err != nil { + return errors.New(fmt.Sprint("hole retrieval failure at", interval, err)) + } + if len(layoutActual) != 1 { + return errors.New(fmt.Sprint("hole check failure at", interval)) + } + if layoutActual[0] != interval.FileInterval { + return errors.New(fmt.Sprint("hole equality check failure at", interval)) + } + } + } + return nil // success +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go b/vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go new file mode 100644 index 00000000..eec39acf --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go @@ -0,0 +1,133 @@ +package sparse + +import ( + "io/ioutil" + "os" + "os/exec" + + "bytes" + "errors" + "fmt" + + "github.com/rancher/sparse-tools/log" +) + +func filesAreEqual(aPath, bPath string) bool { + cmd := exec.Command("diff", aPath, bPath) + err := cmd.Run() + return nil == err +} + +func filesCleanup(src, dst string) { + fileCleanup(src) + fileCleanup(dst) +} + +func fileCleanup(path string) { + os.Remove(path) +} + +func tempFilePath(prefix string) string { + // Make a temporary file path + f, err := ioutil.TempFile("", "sparse-"+prefix) + if err != nil { + log.Fatal("Failed to make temp file", err) + } + defer f.Close() + return f.Name() +} + +// tempBigFileName is for files that are substantial in isze (for benchmark and stress tests) +// created in current directory +func tempBigFilePath(prefix string) string { + // Make a temporary file path in current dir + f, err := ioutil.TempFile(".", "sparse-"+prefix) + if err != nil { + log.Fatal("Failed to make temp file", err) + } + defer f.Close() + return f.Name() +} + +const batch = int64(32) // Blocks for single read/write + +func createTestSparseFile(name string, layout []FileInterval) { + f, err := os.Create(name) + if err != nil { + log.Fatal(err) + } + defer f.Close() + + if 0 == len(layout) { + return // empty file + } + + // Fill up data + for _, interval := range layout { + if SparseData == interval.Kind { + size := batch * Blocks + for offset := interval.Begin; offset < interval.End; { + if offset+size > interval.End { + size = interval.End - offset + } + data := makeData(FileInterval{SparseData, Interval{offset, offset + size}}) + f.WriteAt(data, offset) + offset += size + } + } + } + + // Resize the file to the last hole + last := len(layout) - 1 + if SparseHole == layout[last].Kind { + if err := f.Truncate(layout[last].End); err != nil { + log.Fatal(err) + } + } + + f.Sync() +} + +func checkTestSparseFile(name string, layout []FileInterval) error { + f, err := os.Open(name) + if err != nil { + log.Fatal(err) + } + defer f.Close() + + if 0 == len(layout) { + return nil // empty file + } + + // Read and check data + for _, interval := range layout { + if SparseData == interval.Kind { + size := batch * Blocks + for offset := interval.Begin; offset < interval.End; { + if offset+size > interval.End { + size = interval.End - offset + } + dataModel := makeData(FileInterval{SparseData, Interval{offset, offset + size}}) + data := make([]byte, size) + f.ReadAt(data, offset) + offset += size + + if !bytes.Equal(data, dataModel) { + return errors.New(fmt.Sprint("data equality check failure at", interval)) + } + } + } else if SparseHole == interval.Kind { + layoutActual, err := RetrieveLayout(f, interval.Interval) + if err != nil { + return errors.New(fmt.Sprint("hole retrieval failure at", interval, err)) + } + if len(layoutActual) != 1 { + return errors.New(fmt.Sprint("hole check failure at", interval)) + } + if layoutActual[0] != interval { + return errors.New(fmt.Sprint("hole equality check failure at", interval)) + } + } + } + return nil // success +} diff --git a/vendor/github.com/rancher/sparse-tools/trash.yml b/vendor/github.com/rancher/sparse-tools/trash.yml new file mode 100644 index 00000000..fe3b6b25 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/trash.yml @@ -0,0 +1,4 @@ +import: +- package: github.com/frostschutz/go-fibmap + version: 5fc9f8c1ed479f20414771a17b9686ee77029676 + repo: https://github.com/rancher/go-fibmap.git From dafe08e9a15fbedfca9efbafdcadfac725f6abf0 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 8 May 2016 08:53:39 -0700 Subject: [PATCH 042/357] Fix off-by-one error when deleting the last snapshot --- integration/core/test_cli.py | 31 +++++++++++++++++++++++++++++++ sync/sync.go | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 3e1e0b9d..aad9d1e0 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -290,3 +290,34 @@ def test_snapshot_rm(bin, controller_client, replica_client, replica_client2): assert len(new_chain) == 2 assert chain[0] == new_chain[0] assert chain[2] == new_chain[1] + + +def test_snapshot_last(bin, controller_client, replica_client, + replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + ]) + assert v.replicaCount == 1 + + cmd = [bin, 'add', REPLICA2] + subprocess.check_output(cmd) + output = subprocess.check_output([bin, 'snapshot', 'ls']) + output = output.splitlines()[1] + + chain = replica_client.list_replica()[0].chain + assert len(chain) == 2 + assert chain[0] == 'volume-head-001.img' + assert chain[1] == 'volume-snap-{}.img'.format(output) + + chain = replica_client2.list_replica()[0].chain + assert len(chain) == 2 + assert chain[0] == 'volume-head-001.img' + assert chain[1] == 'volume-snap-{}.img'.format(output) + + cmd = [bin, 'snapshot', 'rm', output] + with pytest.raises(subprocess.CalledProcessError): + subprocess.check_call(cmd) diff --git a/sync/sync.go b/sync/sync.go index eb2cfcf7..e8ab73ce 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -92,7 +92,7 @@ func (t *Task) coalesceSnapshot(replicaInController *rest.Replica, snapshot stri return fmt.Errorf("Snapshot %s not found on replica %s", snapshot, replicaInController.Address) case index == 0: return fmt.Errorf("Can not remove the head disk in the chain") - case index >= len(replica.Chain): + case index >= len(replica.Chain)-1: return fmt.Errorf("Can not remove the last disk in the chain") } From ba157c9da78a95323ec1b00de80d76edc4ffe4ab Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 8 May 2016 19:48:25 -0700 Subject: [PATCH 043/357] Update diff disk locations for >= deleted index --- replica/diff_disk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 37e0e539..1ed3e1d8 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -24,7 +24,7 @@ func (d *diffDisk) RemoveIndex(index int) error { } for i := 0; i < len(d.location); i++ { - if d.location[i] == byte(index) { + if d.location[i] >= byte(index) { // set back to unknown d.location[i] = 0 } From cab5c15583f41790dd528f639f63e2ccd8871107 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 8 May 2016 21:47:26 -0700 Subject: [PATCH 044/357] Add newline to error message --- app/snapshot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/snapshot.go b/app/snapshot.go index 936efd29..549f5c0e 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -84,7 +84,7 @@ func rmSnapshot(c *cli.Context) error { fmt.Printf("deleted %s\n", name) } else { lastErr = err - fmt.Fprintf(os.Stderr, "Failed to delete %s: %v", name, err) + fmt.Fprintf(os.Stderr, "Failed to delete %s: %v\n", name, err) } } From 62af8691dcf3f319ca0efa84bfcf4cc3892c0d7f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 9 May 2016 15:46:12 -0700 Subject: [PATCH 045/357] Gracefully shutdown frontend/TCMU Fix: #51 I've found that before TCMU device was removed from system, it will need to sync filesystem for existing caches. If backend had been shutted down before frontend, then there is no way for frontend(TCMU) to write into it. Also the lock shutdown process holds will block read/write to the backend as well. If TCMU cannot finish cache flushing, then: 1. We need to wait for filesystem accessing command timeout 2. Timed out SCSI command will result in SCSI error handling process, issue more commands, which we need to wait for completion as well. The worst case of not gracefully shutdown TCMU can result in couples of minutes unresponsive for longhorn and whatever process accessing disk IO at the time. --- controller/control.go | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/controller/control.go b/controller/control.go index 77c2535f..7b639b75 100644 --- a/controller/control.go +++ b/controller/control.go @@ -267,17 +267,40 @@ func (c *Controller) Close() error { return c.Shutdown() } -func (c *Controller) Shutdown() error { +func (c *Controller) shutdownFrontend() error { + // Make sure writing data won't be blocked + c.RLock() + defer c.RUnlock() + + if c.frontend != nil { + return c.frontend.Shutdown() + } + return nil +} + +func (c *Controller) shutdownBackend() error { c.Lock() defer c.Unlock() - c.backend.Close() + err := c.backend.Close() c.reset() - if c.frontend != nil { - return c.frontend.Shutdown() - } + return err +} +func (c *Controller) Shutdown() error { + /* + Need to shutdown frontend first because it will write + the final piece of data to backend + */ + err := c.shutdownFrontend() + if err != nil { + logrus.Error("Error when shutting down frontend:", err) + } + err = c.shutdownBackend() + if err != nil { + logrus.Error("Error when shutting down backend:", err) + } return nil } From bb5c22e5cd1ede5e02d4b6908e1729e560c8b4ea Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 9 May 2016 15:46:12 -0700 Subject: [PATCH 046/357] Fix unexpected exit when stop controller With message "poll error out with -1" --- frontend/tcmu/cfunc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index a2a85912..6d73da1e 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -53,7 +53,7 @@ bool tcmu_poll_master_fd(struct tcmulib_context *cxt) { ret = poll(&pfd, 1, -1); if (ret < 0) { errp("poll error out with %d", ret); - exit(1); + return false; } if (pfd.revents) { From cb06cb8af65ace8e4b9a861f80a6301bf91a679c Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 6 May 2016 15:51:32 -0700 Subject: [PATCH 047/357] Add backing file support --- Dockerfile.dapper | 8 ++++ app/backing_disable.go | 16 ++++++++ app/backing_qcow.go | 31 +++++++++++++++ app/replica.go | 11 +++++- backend/file/file.go | 4 ++ backend/remote/remote.go | 8 ++++ controller/control.go | 23 +++++++---- frontend/tcmu/frontend.go | 12 +++--- qcow/libqcow.go | 83 +++++++++++++++++++++++++++++++++++++++ replica/diff_disk.go | 16 +++++--- replica/directio.go | 19 +++++++++ replica/replica.go | 67 ++++++++++++++++++++++++------- replica/replica_test.go | 63 ++++++++++++++++++++++++----- replica/server.go | 42 ++++++++++++++------ scripts/build-cli | 2 +- types/types.go | 9 ++++- 16 files changed, 359 insertions(+), 55 deletions(-) create mode 100644 app/backing_disable.go create mode 100644 app/backing_qcow.go create mode 100644 qcow/libqcow.go create mode 100644 replica/directio.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index cf3577f9..4e8ea6f5 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -63,6 +63,14 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ git checkout e861cbf7058bbcdf1c0600469710dc07afeeeeb2 && \ go build -o /usr/local/bin/docker-longhorn-driver +# Install libqcow +RUN curl -sfL https://github.com/libyal/libqcow/releases/download/20160123/libqcow-alpha-20160123.tar.gz | tar xvzf - -C /usr/src +RUN cd /usr/src/libqcow-20160123 && \ + ./configure +RUN cd /usr/src/libqcow-20160123 && \ + make -j$(nproc) && \ + make install + VOLUME /tmp ENV TMPDIR /tmp ENTRYPOINT ["./scripts/entry"] diff --git a/app/backing_disable.go b/app/backing_disable.go new file mode 100644 index 00000000..ab1917ca --- /dev/null +++ b/app/backing_disable.go @@ -0,0 +1,16 @@ +// +build !qcow + +package app + +import ( + "fmt" + + "github.com/rancher/longhorn/replica" +) + +func openBackingFile(file string) (*replica.BackingFile, error) { + if file == "" { + return nil, nil + } + return nil, fmt.Errorf("Backing file is not supported") +} diff --git a/app/backing_qcow.go b/app/backing_qcow.go new file mode 100644 index 00000000..fbee64d5 --- /dev/null +++ b/app/backing_qcow.go @@ -0,0 +1,31 @@ +// +build qcow + +package app + +import ( + "github.com/rancher/longhorn/qcow" + "github.com/rancher/longhorn/replica" +) + +func openBackingFile(file string) (*replica.BackingFile, error) { + if file == "" { + return nil, nil + } + + f, err := qcow.Open(file) + if err != nil { + return nil, err + } + + size, err := f.Size() + if err != nil { + return nil, err + } + + return &replica.BackingFile{ + Name: file, + Disk: f, + Size: size, + SectorSize: 512, + }, nil +} diff --git a/app/replica.go b/app/replica.go index 6fcacdcb..321a8ca9 100644 --- a/app/replica.go +++ b/app/replica.go @@ -27,6 +27,10 @@ func ReplicaCmd() cli.Command { Name: "listen", Value: "localhost:9502", }, + cli.StringFlag{ + Name: "backing-file", + Usage: "qcow file to use as the base image of this disk", + }, cli.BoolTFlag{ Name: "sync-agent", }, @@ -49,7 +53,12 @@ func startReplica(c *cli.Context) error { } dir := c.Args()[0] - s := replica.NewServer(dir, 4096) + backingFile, err := openBackingFile(c.String("backing-file")) + if err != nil { + return err + } + + s := replica.NewServer(dir, backingFile, 4096) address := c.String("listen") size := c.String("size") diff --git a/backend/file/file.go b/backend/file/file.go index 4ec437f2..4f57a400 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -35,6 +35,10 @@ func (f *Wrapper) Size() (int64, error) { return stat.Size(), nil } +func (f *Wrapper) SectorSize() (int64, error) { + return 4096, nil +} + func (ff *Factory) Create(address string) (types.Backend, error) { logrus.Infof("Creating file: %s", address) file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE, 0600) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 260f6c37..0c132fc7 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -91,6 +91,14 @@ func (r *Remote) Size() (int64, error) { return strconv.ParseInt(replica.Size, 10, 0) } +func (r *Remote) SectorSize() (int64, error) { + replica, err := r.info() + if err != nil { + return 0, err + } + return replica.SectorSize, nil +} + func (r *Remote) info() (rest.Replica, error) { var replica rest.Replica req, err := http.NewRequest("GET", r.replicaURL, nil) diff --git a/controller/control.go b/controller/control.go index 77c2535f..1c8d8a65 100644 --- a/controller/control.go +++ b/controller/control.go @@ -11,12 +11,13 @@ import ( type Controller struct { sync.RWMutex - Name string - size int64 - replicas []types.Replica - factory types.BackendFactory - backend *replicator - frontend types.Frontend + Name string + size int64 + sectorSize int64 + replicas []types.Replica + factory types.BackendFactory + backend *replicator + frontend types.Frontend } func NewController(name string, factory types.BackendFactory, frontend types.Frontend) *Controller { @@ -183,7 +184,7 @@ func (c *Controller) Start(addresses ...string) error { defer func() { if len(c.replicas) > 0 && c.frontend != nil { - if err := c.frontend.Activate(c.Name, c.size, c); err != nil { + if err := c.frontend.Activate(c.Name, c.size, c.sectorSize, c); err != nil { // FATAL logrus.Fatalf("Failed to activate frontend: %v", err) } @@ -202,11 +203,19 @@ func (c *Controller) Start(addresses ...string) error { return err } + newSectorSize, err := newBackend.SectorSize() + if err != nil { + return err + } + if first { first = false c.size = newSize + c.sectorSize = newSectorSize } else if c.size != newSize { return fmt.Errorf("Backend sizes do not match %d != %d", c.size, newSize) + } else if c.sectorSize != newSectorSize { + return fmt.Errorf("Backend sizes do not match %d != %d", c.sectorSize, newSectorSize) } if err := c.addReplicaNoLock(newBackend, address, false); err != nil { diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index d6f1efa8..0ae4124e 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -34,12 +34,12 @@ type Tcmu struct { volume string } -func (t *Tcmu) Activate(name string, size int64, rw types.ReaderWriterAt) error { +func (t *Tcmu) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { t.volume = name t.Shutdown() - if err := PreEnableTcmu(name, size); err != nil { + if err := PreEnableTcmu(name, size, sectorSize); err != nil { return err } @@ -47,18 +47,18 @@ func (t *Tcmu) Activate(name string, size int64, rw types.ReaderWriterAt) error return err } - return PostEnableTcmu(name, size) + return PostEnableTcmu(name) } func (t *Tcmu) Shutdown() error { return TeardownTcmu(t.volume) } -func PreEnableTcmu(volume string, size int64) error { +func PreEnableTcmu(volume string, size, sectorSize int64) error { err := writeLines(path.Join(configDir, volume, "control"), []string{ fmt.Sprintf("dev_size=%d", size), fmt.Sprintf("dev_config=%s", GetDevConfig(volume)), - "hw_block_size=4096", + fmt.Sprintf("hw_block_size=%d", sectorSize), "async=1", }) if err != nil { @@ -70,7 +70,7 @@ func PreEnableTcmu(volume string, size int64) error { }) } -func PostEnableTcmu(volume string, size int64) error { +func PostEnableTcmu(volume string) error { prefix, nexusWnn := getScsiPrefixAndWnn(volume) err := writeLines(path.Join(prefix, "nexus"), []string{ diff --git a/qcow/libqcow.go b/qcow/libqcow.go new file mode 100644 index 00000000..c820a6c9 --- /dev/null +++ b/qcow/libqcow.go @@ -0,0 +1,83 @@ +// +build qcow +package qcow + +// #cgo LDFLAGS: -lqcow -lz +// #include +// #include +// #include +import "C" +import ( + "errors" + "fmt" + "io" + "unsafe" +) + +type Qcow struct { + file *C.libqcow_file_t +} + +func toError(e *C.libqcow_error_t) error { + buf := [1024]C.char{} + defer C.libqcow_error_free(&e) + if C.libqcow_error_sprint(e, &buf[0], 1023) < 0 { + return fmt.Errorf("Unknown error: %v", e) + } + return errors.New(C.GoString(&buf[0])) +} + +func Open(path string) (*Qcow, error) { + var f *C.libqcow_file_t + var qErr *C.libqcow_error_t + if C.libqcow_file_initialize(&f, &qErr) != 1 { + return nil, toError(qErr) + } + + name := C.CString(path) + defer C.free(unsafe.Pointer(name)) + + if C.libqcow_file_open(f, name, C.LIBQCOW_OPEN_READ, &qErr) != 1 { + C.libqcow_file_free(&f, nil) + return nil, toError(qErr) + } + + return &Qcow{file: f}, nil +} + +func (q *Qcow) WriteAt(buf []byte, off int64) (int, error) { + return 0, errors.New("Unsupported operation") +} + +func (q *Qcow) ReadAt(buf []byte, off int64) (int, error) { + var qErr *C.libqcow_error_t + ret := C.libqcow_file_read_buffer_at_offset(q.file, unsafe.Pointer(&buf[0]), + C.size_t(len(buf)), C.off64_t(off), &qErr) + if ret < 0 { + return 0, toError(qErr) + } + if ret == 0 { + return 0, io.EOF + } + return int(ret), nil +} + +func (q *Qcow) Close() error { + var qErr *C.libqcow_error_t + if C.libqcow_file_close(q.file, &qErr) != 1 { + return toError(qErr) + } + return nil +} + +func (q Qcow) Size() (int64, error) { + var result C.size64_t + var qErr *C.libqcow_error_t + if C.libqcow_file_get_media_size(q.file, &result, &qErr) != 1 { + return 0, toError(qErr) + } + return int64(result), nil +} + +func (q *Qcow) Fd() uintptr { + panic("Unsupported") +} diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 37e0e539..07d6f42c 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -2,10 +2,9 @@ package replica import ( "fmt" - "os" "github.com/frostschutz/go-fibmap" - fio "github.com/rancher/sparse-tools/directfio" + "github.com/rancher/longhorn/types" ) type diffDisk struct { @@ -14,7 +13,7 @@ type diffDisk struct { location []byte // list of files in child, parent, grandparent, etc order. // index 0 is nil and index 1 is the active write layer - files []*os.File + files []types.DiffDisk sectorSize int64 } @@ -44,7 +43,7 @@ func (d *diffDisk) WriteAt(buf []byte, offset int64) (int, error) { startSector := offset / d.sectorSize sectors := int64(len(buf)) / d.sectorSize - c, err := fio.WriteAt(d.files[target], buf, offset) + c, err := d.files[target].WriteAt(buf, offset) // Regardless of err mark bytes as written for i := int64(0); i < sectors; i++ { @@ -102,7 +101,7 @@ func (d *diffDisk) read(target byte, buf []byte, offset int64, startSector int64 bufStart := startSector * d.sectorSize bufEnd := sectors * d.sectorSize newBuf := buf[bufStart : bufStart+bufEnd] - return fio.ReadAt(d.files[target], newBuf, offset+bufStart) + return d.files[target].ReadAt(newBuf, offset+bufStart) } func (d *diffDisk) lookup(sector int64) (byte, error) { @@ -121,6 +120,13 @@ func (d *diffDisk) lookup(sector int64) (byte, error) { if target == 0 { for i := len(d.files) - 1; i > 0; i-- { + if i == 1 { + // This is important that for index 1 we don't check Fiemap because it may be a base image file + // Also the result has to be 1 + d.location[sector] = byte(i) + return byte(i), nil + } + e, err := fibmap.Fiemap(d.files[i].Fd(), uint64(sector*d.sectorSize), uint64(d.sectorSize), 1) if err != 0 { return byte(0), err diff --git a/replica/directio.go b/replica/directio.go new file mode 100644 index 00000000..514760a4 --- /dev/null +++ b/replica/directio.go @@ -0,0 +1,19 @@ +package replica + +import ( + "os" + + "github.com/rancher/sparse-tools/directfio" +) + +type directFile struct { + *os.File +} + +func (d *directFile) ReadAt(buf []byte, offset int64) (int, error) { + return directfio.ReadAt(d.File, buf, offset) +} + +func (d *directFile) WriteAt(buf []byte, offset int64) (int, error) { + return directfio.WriteAt(d.File, buf, offset) +} diff --git a/replica/replica.go b/replica/replica.go index 06504d25..a480bf35 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -13,6 +13,7 @@ import ( "syscall" "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" ) const ( @@ -38,12 +39,13 @@ type Replica struct { } type Info struct { - Size int64 - Head string - Dirty bool - Rebuilding bool - Parent string - SectorSize int64 + Size int64 + Head string + Dirty bool + Rebuilding bool + Parent string + SectorSize int64 + BackingFile *BackingFile `json:"-"` } type disk struct { @@ -51,13 +53,20 @@ type disk struct { Parent string } +type BackingFile struct { + Size int64 + SectorSize int64 + Name string + Disk types.DiffDisk +} + func ReadInfo(dir string) (Info, error) { var info Info err := (&Replica{dir: dir}).unmarshalFile(volumeMetaData, &info) return info, err } -func New(size, sectorSize int64, dir string) (*Replica, error) { +func New(size, sectorSize int64, dir string, backingFile *BackingFile) (*Replica, error) { if size%sectorSize != 0 { return nil, fmt.Errorf("Size %d not a multiple of sector size %d", size, sectorSize) } @@ -69,12 +78,14 @@ func New(size, sectorSize int64, dir string) (*Replica, error) { r := &Replica{ dir: dir, activeDiskData: make([]disk, 1), + diskData: map[string]disk{}, } r.info.Size = size r.info.SectorSize = sectorSize + r.info.BackingFile = backingFile r.volume.sectorSize = sectorSize r.volume.location = make([]byte, size/sectorSize) - r.volume.files = []*os.File{nil} + r.volume.files = []types.DiffDisk{nil} exists, err := r.readMetadata() if err != nil { @@ -95,9 +106,22 @@ func New(size, sectorSize int64, dir string) (*Replica, error) { r.info.Parent = r.diskData[r.info.Head].Parent + r.insertBackingFile() + return r, r.writeVolumeMetaData(true, r.info.Rebuilding) } +func (r *Replica) insertBackingFile() { + if r.info.BackingFile == nil { + return + } + + d := disk{name: r.info.BackingFile.Name} + r.activeDiskData = append([]disk{disk{}, d}, r.activeDiskData[1:]...) + r.volume.files = append([]types.DiffDisk{nil, r.info.BackingFile.Disk}, r.volume.files[1:]...) + r.diskData[d.name] = d +} + func (r *Replica) SetRebuilding(rebuilding bool) error { err := r.writeVolumeMetaData(true, rebuilding) if err != nil { @@ -108,7 +132,7 @@ func (r *Replica) SetRebuilding(rebuilding bool) error { } func (r *Replica) Reload() (*Replica, error) { - newReplica, err := New(r.info.Size, r.volume.sectorSize, r.dir) + newReplica, err := New(r.info.Size, r.volume.sectorSize, r.dir, r.info.BackingFile) if err != nil { return nil, err } @@ -199,9 +223,18 @@ func (r *Replica) writeVolumeMetaData(dirty, rebuilding bool) error { return r.encodeToFile(&info, volumeMetaData) } +func (r *Replica) isBackingFile(index int) bool { + if r.info.BackingFile == nil { + return false + } + return index == 1 +} + func (r *Replica) close() error { - for _, f := range r.volume.files { - f.Close() + for i, f := range r.volume.files { + if f != nil && !r.isBackingFile(i) { + f.Close() + } } return r.writeVolumeMetaData(false, r.info.Rebuilding) @@ -239,12 +272,18 @@ func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) return fmt.Sprintf(pattern, index+1), nil } -func (r *Replica) openFile(name string, flag int) (*os.File, error) { +func (r *Replica) openFile(name string, flag int) (types.DiffDisk, error) { // TODO: need to turn on O_DIRECT - return os.OpenFile(path.Join(r.dir, name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) + f, err := os.OpenFile(path.Join(r.dir, name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) + if err != nil { + return nil, err + } + return &directFile{ + File: f, + }, nil } -func (r *Replica) createNewHead(oldHead, parent string) (*os.File, disk, error) { +func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, error) { newHeadName, err := r.nextFile(diskPattern, headName, oldHead) if err != nil { return nil, disk{}, err diff --git a/replica/replica_test.go b/replica/replica_test.go index ec70c2e9..8015ff0c 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "os" + "path" "testing" . "gopkg.in/check.v1" @@ -24,7 +25,7 @@ func (s *TestSuite) TestCreate(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir) + r, err := New(9, 3, dir, nil) c.Assert(err, IsNil) defer r.Close() } @@ -34,7 +35,7 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir) + r, err := New(9, 3, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -61,7 +62,7 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir) + r, err := New(9, 3, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -98,7 +99,7 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir) + r, err := New(9, 3, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -135,7 +136,7 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir) + r, err := New(9, 3, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -181,7 +182,7 @@ func (s *TestSuite) TestRead(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9*b, b, dir) + r, err := New(9*b, b, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -196,7 +197,7 @@ func (s *TestSuite) TestWrite(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9*b, b, dir) + r, err := New(9*b, b, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -216,9 +217,9 @@ func (s *TestSuite) TestSnapshotReadWrite(c *C) { dir, err := ioutil.TempDir("", "replica") c.Logf("Volume: %s", dir) c.Assert(err, IsNil) - //defer os.RemoveAll(dir) + defer os.RemoveAll(dir) - r, err := New(3*b, b, dir) + r, err := New(3*b, b, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -257,3 +258,47 @@ func (s *TestSuite) TestSnapshotReadWrite(c *C) { byteEquals(c, readBuf, buf) byteEquals(c, r.volume.location, []byte{3, 2, 1}) } + +func (s *TestSuite) TestBackingFile(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Logf("Volume: %s", dir) + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + buf := make([]byte, 3*b) + fill(buf, 3) + + f, err := os.Create(path.Join(dir, "backing")) + c.Assert(err, IsNil) + defer f.Close() + _, err = f.Write(buf) + c.Assert(err, IsNil) + + backing := &BackingFile{ + Name: "backing", + Disk: f, + } + + r, err := New(3*b, b, dir, backing) + c.Assert(err, IsNil) + defer r.Close() + + chain, err := r.Chain() + c.Assert(err, IsNil) + c.Assert(len(chain), Equals, 2) + c.Assert(chain[0], Equals, "volume-head-000.img") + c.Assert(chain[1], Equals, "backing") + + newBuf := make([]byte, 1*b) + _, err = r.WriteAt(newBuf, b) + c.Assert(err, IsNil) + + newBuf2 := make([]byte, 3*b) + fill(newBuf2, 3) + fill(newBuf2[b:2*b], 0) + + _, err = r.ReadAt(buf, 0) + c.Assert(err, IsNil) + + byteEquals(c, buf, newBuf2) +} diff --git a/replica/server.go b/replica/server.go index 0afff2d1..1774f4a6 100644 --- a/replica/server.go +++ b/replica/server.go @@ -21,18 +21,34 @@ type State string type Server struct { sync.RWMutex - r *Replica - dir string - sectorSize int64 + r *Replica + dir string + defaultSectorSize int64 + backing *BackingFile } -func NewServer(dir string, sectorSize int64) *Server { +func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { return &Server{ - dir: dir, - sectorSize: sectorSize, + dir: dir, + backing: backing, + defaultSectorSize: sectorSize, } } +func (s *Server) getSectorSize() int64 { + if s.backing != nil && s.backing.SectorSize > 0 { + return s.backing.SectorSize + } + return s.defaultSectorSize +} + +func (s *Server) getSize(size int64) int64 { + if s.backing != nil && s.backing.Size > 0 { + return s.backing.Size + } + return size +} + func (s *Server) Create(size int64) error { s.Lock() defer s.Unlock() @@ -42,8 +58,11 @@ func (s *Server) Create(size int64) error { return nil } - logrus.Infof("Creating volume %s, size %d/%d", s.dir, size, s.sectorSize) - r, err := New(size, s.sectorSize, s.dir) + size = s.getSize(size) + sectorSize := s.getSectorSize() + + logrus.Infof("Creating volume %s, size %d/%d", s.dir, size, sectorSize) + r, err := New(size, sectorSize, s.dir, s.backing) if err != nil { return err } @@ -60,10 +79,11 @@ func (s *Server) Open() error { } _, info := s.Status() - size := info.Size + size := s.getSize(info.Size) + sectorSize := s.getSectorSize() - logrus.Infof("Opening volume %s, size %d/%d", s.dir, size, s.sectorSize) - r, err := New(size, s.sectorSize, s.dir) + logrus.Infof("Opening volume %s, size %d/%d", s.dir, size, sectorSize) + r, err := New(size, sectorSize, s.dir, s.backing) if err != nil { return err } diff --git a/scripts/build-cli b/scripts/build-cli index 7f20e771..24a50398 100755 --- a/scripts/build-cli +++ b/scripts/build-cli @@ -6,4 +6,4 @@ source $(dirname $0)/version cd $(dirname $0)/.. mkdir -p bin -go build -tags tcmu -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn +go build -tags "tcmu qcow" -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn diff --git a/types/types.go b/types/types.go index 89af9413..4b3f0970 100644 --- a/types/types.go +++ b/types/types.go @@ -13,11 +13,18 @@ type ReaderWriterAt interface { io.WriterAt } +type DiffDisk interface { + ReaderWriterAt + io.Closer + Fd() uintptr +} + type Backend interface { ReaderWriterAt io.Closer Snapshot(name string) error Size() (int64, error) + SectorSize() (int64, error) } type BackendFactory interface { @@ -46,6 +53,6 @@ type Replica struct { } type Frontend interface { - Activate(name string, size int64, rw ReaderWriterAt) error + Activate(name string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error } From c5b9ce38e55200f394fad674527fbb864be32cd2 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 12 May 2016 09:47:25 -0700 Subject: [PATCH 048/357] Add support for partial reads and writes --- qcow/libqcow.go | 1 + replica/diff_disk.go | 105 +++++++++++++++++++++++++++-- replica/replica.go | 9 ++- replica/replica_test.go | 143 +++++++++++++++++++++++++++++++++++++--- 4 files changed, 243 insertions(+), 15 deletions(-) diff --git a/qcow/libqcow.go b/qcow/libqcow.go index c820a6c9..012341b4 100644 --- a/qcow/libqcow.go +++ b/qcow/libqcow.go @@ -1,4 +1,5 @@ // +build qcow + package qcow // #cgo LDFLAGS: -lqcow -lz diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 07d6f42c..28ae0f8a 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -2,12 +2,14 @@ package replica import ( "fmt" + "sync" "github.com/frostschutz/go-fibmap" "github.com/rancher/longhorn/types" ) type diffDisk struct { + rmLock sync.Mutex // mapping of sector to index in the files array. a value of 0 is special meaning // we don't know the location yet. location []byte @@ -35,8 +37,61 @@ func (d *diffDisk) RemoveIndex(index int) error { } func (d *diffDisk) WriteAt(buf []byte, offset int64) (int, error) { + startOffset := offset % d.sectorSize + startCut := d.sectorSize - startOffset + endOffset := (int64(len(buf)) + offset) % d.sectorSize + + if len(buf) == 0 { + return 0, nil + } + + if startOffset == 0 && endOffset == 0 { + return d.fullWriteAt(buf, offset) + } + + // single block + if startCut >= int64(len(buf)) { + return d.readModifyWrite(buf, offset) + } + + if _, err := d.readModifyWrite(buf[0:startCut], offset); err != nil { + return 0, err + } + + if _, err := d.fullWriteAt(buf[startCut:int64(len(buf))-endOffset], offset+startCut); err != nil { + return 0, err + } + + if _, err := d.readModifyWrite(buf[int64(len(buf))-endOffset:], offset+int64(len(buf))-endOffset); err != nil { + return 0, err + } + + return len(buf), nil +} + +func (d *diffDisk) readModifyWrite(buf []byte, offset int64) (int, error) { + if len(buf) == 0 { + return 0, nil + } + + d.rmLock.Lock() + defer d.rmLock.Unlock() + + readBuf := make([]byte, d.sectorSize) + readOffset := (offset / d.sectorSize) * d.sectorSize + + if _, err := d.fullReadAt(readBuf, readOffset); err != nil { + return 0, err + } + + copy(readBuf[offset%d.sectorSize:], buf) + + return d.fullWriteAt(readBuf, readOffset) +} + +func (d *diffDisk) fullWriteAt(buf []byte, offset int64) (int, error) { if int64(len(buf))%d.sectorSize != 0 || offset%d.sectorSize != 0 { - return 0, fmt.Errorf("Write not a multiple of %d", d.sectorSize) + return 0, fmt.Errorf("Write len(%d), offset %d not a multiple of %d", len(buf), offset, d.sectorSize) } target := byte(len(d.files) - 1) @@ -54,10 +109,53 @@ func (d *diffDisk) WriteAt(buf []byte, offset int64) (int, error) { } func (d *diffDisk) ReadAt(buf []byte, offset int64) (int, error) { + startOffset := offset % d.sectorSize + startCut := d.sectorSize - startOffset + endOffset := (int64(len(buf)) + offset) % d.sectorSize + + if len(buf) == 0 { + return 0, nil + } + + if startOffset == 0 && endOffset == 0 { + return d.fullReadAt(buf, offset) + } + + readBuf := make([]byte, d.sectorSize) + if _, err := d.fullReadAt(readBuf, offset-startOffset); err != nil { + return 0, err + } + + copy(buf, readBuf[startOffset:]) + + if startCut >= int64(len(buf)) { + return len(buf), nil + } + + if _, err := d.fullReadAt(buf[startCut:int64(len(buf))-endOffset], offset+startCut); err != nil { + return 0, err + } + + if endOffset > 0 { + if _, err := d.fullReadAt(readBuf, offset+int64(len(buf))-endOffset); err != nil { + return 0, err + } + + copy(buf[int64(len(buf))-endOffset:], readBuf[:endOffset]) + } + + return len(buf), nil +} + +func (d *diffDisk) fullReadAt(buf []byte, offset int64) (int, error) { if int64(len(buf))%d.sectorSize != 0 || offset%d.sectorSize != 0 { return 0, fmt.Errorf("Read not a multiple of %d", d.sectorSize) } + if len(buf) == 0 { + return 0, nil + } + count := 0 sectors := int64(len(buf)) / d.sectorSize readSectors := int64(1) @@ -105,14 +203,13 @@ func (d *diffDisk) read(target byte, buf []byte, offset int64, startSector int64 } func (d *diffDisk) lookup(sector int64) (byte, error) { - dlength := int64(len(d.location)) - if sector >= dlength { + if sector >= int64(len(d.location)) { // We know the IO will result in EOF return byte(len(d.files) - 1), nil } // small optimization - if dlength == 2 { + if int64(len(d.files)) == 2 { return 1, nil } diff --git a/replica/replica.go b/replica/replica.go index a480bf35..56128f63 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -83,8 +83,13 @@ func New(size, sectorSize int64, dir string, backingFile *BackingFile) (*Replica r.info.Size = size r.info.SectorSize = sectorSize r.info.BackingFile = backingFile - r.volume.sectorSize = sectorSize - r.volume.location = make([]byte, size/sectorSize) + + r.volume.sectorSize = defaultSectorSize + locationSize := size / defaultSectorSize + if size%defaultSectorSize != 0 { + locationSize++ + } + r.volume.location = make([]byte, locationSize) r.volume.files = []types.DiffDisk{nil} exists, err := r.readMetadata() diff --git a/replica/replica_test.go b/replica/replica_test.go index 8015ff0c..7078e70e 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -5,13 +5,15 @@ import ( "io/ioutil" "os" "path" + "strconv" "testing" . "gopkg.in/check.v1" ) const ( - b = 4096 + b = 4096 + bs = 512 ) func Test(t *testing.T) { TestingT(t) } @@ -161,13 +163,13 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, Not(IsNil)) } -func byteEquals(c *C, left, right []byte) { - c.Assert(len(left), Equals, len(right)) +func byteEquals(c *C, expected, obtained []byte) { + c.Assert(len(expected), Equals, len(obtained)) - for i := range left { - l := fmt.Sprintf("%d=%x", i, left[i]) - r := fmt.Sprintf("%d=%x", i, right[i]) - c.Assert(l, Equals, r) + for i := range expected { + l := fmt.Sprintf("%d=%x", i, expected[i]) + r := fmt.Sprintf("%d=%x", i, obtained[i]) + c.Assert(r, Equals, l) } } @@ -285,9 +287,8 @@ func (s *TestSuite) TestBackingFile(c *C) { chain, err := r.Chain() c.Assert(err, IsNil) - c.Assert(len(chain), Equals, 2) + c.Assert(len(chain), Equals, 1) c.Assert(chain[0], Equals, "volume-head-000.img") - c.Assert(chain[1], Equals, "backing") newBuf := make([]byte, 1*b) _, err = r.WriteAt(newBuf, b) @@ -302,3 +303,127 @@ func (s *TestSuite) TestBackingFile(c *C) { byteEquals(c, buf, newBuf2) } + +func (s *TestSuite) partialWriteRead(c *C, totalLength, writeLength, writeOffset int64) { + fmt.Println("Starting partialWriteRead") + dir, err := ioutil.TempDir("", "replica") + c.Logf("Volume: %s", dir) + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + buf := make([]byte, totalLength) + fill(buf, 3) + + r, err := New(totalLength, b, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + _, err = r.WriteAt(buf, 0) + c.Assert(err, IsNil) + + err = r.Snapshot("000") + c.Assert(err, IsNil) + + buf = make([]byte, writeLength) + fill(buf, 1) + + _, err = r.WriteAt(buf, writeOffset) + c.Assert(err, IsNil) + + buf = make([]byte, totalLength) + _, err = r.ReadAt(buf, 0) + c.Assert(err, IsNil) + + expected := make([]byte, totalLength) + fill(expected, 3) + fill(expected[writeOffset:writeOffset+writeLength], 1) + + byteEquals(c, expected, buf) +} + +func (s *TestSuite) TestPartialWriteRead(c *C) { + s.partialWriteRead(c, 3*b, 3*bs, 2*bs) + s.partialWriteRead(c, 3*b, 3*bs, 21*bs) + + s.partialWriteRead(c, 3*b, 11*bs, 7*bs) + s.partialWriteRead(c, 4*b, 19*bs, 7*bs) + + s.partialWriteRead(c, 3*b, 19*bs, 5*bs) + s.partialWriteRead(c, 3*b, 19*bs, 0*bs) +} + +func (s *TestSuite) testPartialRead(c *C, totalLength int64, readBuf []byte, offset int64) (int, error) { + fmt.Println("Filling data for partialRead") + dir, err := ioutil.TempDir("", "replica") + fmt.Printf("Volume: %s\n", dir) + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + buf := make([]byte, totalLength) + fill(buf, 3) + + r, err := New(totalLength, b, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + for i := int64(0); i < totalLength; i += b { + buf := make([]byte, totalLength-i) + fill(buf, byte(i/b+1)) + err := r.Snapshot(strconv.Itoa(int(i))) + c.Assert(err, IsNil) + _, err = r.WriteAt(buf, i) + c.Assert(err, IsNil) + } + + fmt.Println("Starting partialRead", r.volume.location) + return r.ReadAt(readBuf, offset) +} + +func (s *TestSuite) TestPartialRead(c *C) { + buf := make([]byte, b) + _, err := s.testPartialRead(c, 3*b, buf, b/2) + c.Assert(err, IsNil) + + expected := make([]byte, b) + fill(expected[:b/2], 1) + fill(expected[b/2:], 2) + + byteEquals(c, expected, buf) +} + +func (s *TestSuite) TestPartialReadZeroStartOffset(c *C) { + buf := make([]byte, b+b/2) + _, err := s.testPartialRead(c, 3*b, buf, 0) + c.Assert(err, IsNil) + + expected := make([]byte, b+b/2) + fill(expected[:b], 1) + fill(expected[b:], 2) + + byteEquals(c, expected, buf) +} + +func (s *TestSuite) TestPartialFullRead(c *C) { + // Sanity test that filling data works right + buf := make([]byte, 2*b) + _, err := s.testPartialRead(c, 2*b, buf, 0) + c.Assert(err, IsNil) + + expected := make([]byte, 2*b) + fill(expected[:b], 1) + fill(expected[b:], 2) + + byteEquals(c, expected, buf) +} + +func (s *TestSuite) TestPartialReadZeroEndOffset(c *C) { + buf := make([]byte, b+b/2) + _, err := s.testPartialRead(c, 2*b, buf, b/2) + c.Assert(err, IsNil) + + expected := make([]byte, b+b/2) + fill(expected[:b/2], 1) + fill(expected[b/2:], 2) + + byteEquals(c, expected, buf) +} From e0a8ad94633321d59438111e93a30bd49eee0261 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 10 May 2016 15:04:11 -0700 Subject: [PATCH 049/357] Initial support for qcow in replica --- Dockerfile.dapper | 2 +- agent/controller/controller.go | 2 +- package/Dockerfile | 2 +- package/copy-binary | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100755 package/copy-binary diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 4e8ea6f5..9b961bff 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -60,7 +60,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/cjellick/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout e861cbf7058bbcdf1c0600469710dc07afeeeeb2 && \ + git checkout 04bcb09c92d736466a4366ef623bd6d678b1c878 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow diff --git a/agent/controller/controller.go b/agent/controller/controller.go index 73ab1e63..85d8e881 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -431,7 +431,7 @@ func (c *Controller) replicaMetadataAndClient() (int, map[string]*replica, error } // Unmarshalling the metadata as json is forcing it to a bad format - resp, err := http.Get(MetadataURL + "/self/service/metadata/longhorn/volume_size") + resp, err := http.Get(MetadataURL + "/self/service/metadata/volume/volume_size") if err != nil { return 0, nil, err } diff --git a/package/Dockerfile b/package/Dockerfile index 37b48b9a..db037d75 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -4,5 +4,5 @@ RUN apt-get update && apt-get install -y kmod curl RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin -COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver /usr/bin/ +COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary /usr/bin/ CMD ["longhorn"] diff --git a/package/copy-binary b/package/copy-binary new file mode 100755 index 00000000..9b298aaa --- /dev/null +++ b/package/copy-binary @@ -0,0 +1,3 @@ +#!/bin/bash + +cp $(which longhorn) /cmd From a8070a137432c3e815266b6c0189ee98119d9730 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 8 May 2016 22:50:46 -0700 Subject: [PATCH 050/357] Allow snapshot during rebuild, do not allow rm snapshot during rebuild --- replica/rest/model.go | 1 + sync/sync.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/replica/rest/model.go b/replica/rest/model.go index 216202b3..61f338ad 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -72,6 +72,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["reload"] = true actions["removedisk"] = true case replica.Rebuilding: + actions["snapshot"] = true actions["setrebuilding"] = true actions["close"] = true actions["reload"] = true diff --git a/sync/sync.go b/sync/sync.go index e8ab73ce..1d91c23d 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -26,6 +26,14 @@ func (t *Task) DeleteSnapshot(snapshot string) error { return err } + for _, r := range replicas { + if ok, err := t.isRebuilding(&r); err != nil { + return err + } else if ok { + return fmt.Errorf("Can not remove a snapshot because %s is rebuilding", r.Address) + } + } + for _, replica := range replicas { if err := t.coalesceSnapshot(&replica, snapshot); err != nil { return err @@ -70,6 +78,20 @@ func getNameAndIndex(chain []string, snapshot string) (string, int) { return snapshot, index } +func (t *Task) isRebuilding(replicaInController *rest.Replica) (bool, error) { + repClient, err := client.NewReplicaClient(replicaInController.Address) + if err != nil { + return false, err + } + + replica, err := repClient.GetReplica() + if err != nil { + return false, err + } + + return replica.Rebuilding, nil +} + func (t *Task) coalesceSnapshot(replicaInController *rest.Replica, snapshot string) error { if replicaInController.Mode != "RW" { return fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) From c23b8b2178096c831c147891e23bda705f77a46d Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 10 May 2016 15:04:11 -0700 Subject: [PATCH 051/357] Update driver and support image file detection --- Dockerfile.dapper | 4 ++-- package/Dockerfile | 2 +- package/copy-binary | 2 +- package/launch-replica-with-vm-backing-file | 11 +++++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100755 package/launch-replica-with-vm-backing-file diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 9b961bff..7c0a603e 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -58,9 +58,9 @@ RUN cd /usr/src/tcmu-runner && \ RUN GOPATH=/tmp/docker-longhorn-driver && \ mkdir -p $GOPATH/src/github.com/rancher && \ cd $GOPATH/src/github.com/rancher && \ - git clone https://github.com/cjellick/docker-longhorn-driver.git && \ + git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout 04bcb09c92d736466a4366ef623bd6d678b1c878 && \ + git checkout d9292c70a98d27d846ac1485e812c8215018528c && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow diff --git a/package/Dockerfile b/package/Dockerfile index db037d75..c3f95e99 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -4,5 +4,5 @@ RUN apt-get update && apt-get install -y kmod curl RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin -COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary /usr/bin/ +COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-replica-with-vm-backing-file /usr/bin/ CMD ["longhorn"] diff --git a/package/copy-binary b/package/copy-binary index 9b298aaa..db9ec569 100755 --- a/package/copy-binary +++ b/package/copy-binary @@ -1,3 +1,3 @@ #!/bin/bash -cp $(which longhorn) /cmd +cp $(which longhorn) $(which launch-replica-with-vm-backing-file) /cmd diff --git a/package/launch-replica-with-vm-backing-file b/package/launch-replica-with-vm-backing-file new file mode 100755 index 00000000..661b0b71 --- /dev/null +++ b/package/launch-replica-with-vm-backing-file @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +BASE_IMAGE_DIR_LIST=( `ls /base_image` ) +if [ ${#BASE_IMAGE_DIR_LIST[@]} -ne 1 ]; then + echo "/base_image directory must contain exactly one base image file" + exit 1 +fi +IMAGE_FILE="/base_image/${BASE_IMAGE_DIR_LIST[0]}" + + +/cmd/longhorn replica --backing-file ${IMAGE_FILE} "$@" \ No newline at end of file From 4f725838e862e2ef7e25e0db51bfcf2fc5fad020 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 13 May 2016 14:23:04 -0700 Subject: [PATCH 052/357] Default to 512 sectors always --- app/replica.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/replica.go b/app/replica.go index 321a8ca9..b19efa53 100644 --- a/app/replica.go +++ b/app/replica.go @@ -58,7 +58,7 @@ func startReplica(c *cli.Context) error { return err } - s := replica.NewServer(dir, backingFile, 4096) + s := replica.NewServer(dir, backingFile, 512) address := c.String("listen") size := c.String("size") From 59ce9145a4f5a9a74a22d5e3ba9983280d3dabf8 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Fri, 13 May 2016 14:31:43 -0700 Subject: [PATCH 053/357] Update driver and fix getting volume size --- Dockerfile.dapper | 2 +- agent/controller/controller.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 7c0a603e..6f3eb2b0 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -60,7 +60,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout d9292c70a98d27d846ac1485e812c8215018528c && \ + git checkout 9c95a3185196ee2ee16f9d6068d8eaa195a25e4c && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow diff --git a/agent/controller/controller.go b/agent/controller/controller.go index 85d8e881..98dee9c0 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -431,7 +431,7 @@ func (c *Controller) replicaMetadataAndClient() (int, map[string]*replica, error } // Unmarshalling the metadata as json is forcing it to a bad format - resp, err := http.Get(MetadataURL + "/self/service/metadata/volume/volume_size") + resp, err := http.Get(MetadataURL + "/self/service/metadata/volume/volume_config/size") if err != nil { return 0, nil, err } From 4814b2513cd9d5d08c4c6f467fb3e16c55c3881f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 13 May 2016 15:32:38 -0700 Subject: [PATCH 054/357] Set sector size correctly --- integration/core/test_cli.py | 2 +- integration/core/test_replica.py | 44 ++++++++++++++++---------------- replica/replica.go | 5 ++-- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index aad9d1e0..91530173 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -94,7 +94,7 @@ def open_replica(client): assert r.state == 'closed' assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index cc3d8149..e61b7bf0 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -49,7 +49,7 @@ def test_create(client): assert r.state == 'closed' assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -71,7 +71,7 @@ def test_open(client): assert not r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -81,7 +81,7 @@ def test_open(client): assert not r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -98,7 +98,7 @@ def test_close(client): assert not r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -108,7 +108,7 @@ def test_close(client): assert not r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -125,7 +125,7 @@ def test_snapshot(client): assert not r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -134,7 +134,7 @@ def test_snapshot(client): assert r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 r = r.snapshot(name='001') @@ -142,7 +142,7 @@ def test_snapshot(client): assert r.dirty assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.head == 'volume-head-002.img' assert r.parent == 'volume-snap-001.img' assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', @@ -165,7 +165,7 @@ def test_remove_disk(client): assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.head == 'volume-head-002.img' assert r.parent == 'volume-snap-000.img' assert r.chain == ['volume-head-002.img', 'volume-snap-000.img'] @@ -187,7 +187,7 @@ def test_remove_last_disk(client): assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.head == 'volume-head-002.img' assert r.parent == 'volume-snap-001.img' assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] @@ -208,7 +208,7 @@ def test_reload(client): r = r.removedisk(name='volume-snap-000.img') assert r.state == 'dirty' assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.head == 'volume-head-002.img' assert r.parent == 'volume-snap-001.img' assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] @@ -216,7 +216,7 @@ def test_reload(client): r = r.reload() assert r.state == 'dirty' assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] assert r.head == 'volume-head-002.img' assert r.parent == 'volume-snap-001.img' @@ -224,7 +224,7 @@ def test_reload(client): r = r.close().open() assert r.state == 'open' assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.chain == ['volume-head-002.img', 'volume-snap-001.img'] assert r.head == 'volume-head-002.img' assert r.parent == 'volume-snap-001.img' @@ -240,14 +240,14 @@ def test_reload_simple(client): assert r.state == 'open' assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' r = r.reload() assert r.state == 'open' assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -263,7 +263,7 @@ def test_rebuilding(client): assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] @@ -272,7 +272,7 @@ def test_rebuilding(client): assert r.state == 'rebuilding' assert r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] @@ -281,7 +281,7 @@ def test_rebuilding(client): assert r.state == 'rebuilding' assert r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] @@ -290,7 +290,7 @@ def test_rebuilding(client): assert r.state == 'rebuilding' assert r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] @@ -307,7 +307,7 @@ def test_not_rebuilding(client): assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] @@ -316,7 +316,7 @@ def test_not_rebuilding(client): assert r.state == 'rebuilding' assert r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] @@ -325,7 +325,7 @@ def test_not_rebuilding(client): assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) - assert r.sectorSize == 4096 + assert r.sectorSize == 512 assert r.parent == 'volume-snap-001.img' assert r.head == 'volume-head-001.img' assert r.chain == ['volume-head-001.img', 'volume-snap-001.img'] diff --git a/replica/replica.go b/replica/replica.go index 56128f63..f4cbf003 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -137,7 +137,7 @@ func (r *Replica) SetRebuilding(rebuilding bool) error { } func (r *Replica) Reload() (*Replica, error) { - newReplica, err := New(r.info.Size, r.volume.sectorSize, r.dir, r.info.BackingFile) + newReplica, err := New(r.info.Size, r.info.SectorSize, r.dir, r.info.BackingFile) if err != nil { return nil, err } @@ -374,7 +374,6 @@ func (r *Replica) createDisk(name string) error { info.Head = newHeadDisk.name info.Dirty = true info.Parent = newHeadDisk.Parent - info.SectorSize = r.volume.sectorSize if err := r.encodeToFile(&info, volumeMetaData); err != nil { return err @@ -431,7 +430,7 @@ func (r *Replica) readMetadata() (bool, error) { if err := r.unmarshalFile(file.Name(), &r.info); err != nil { return false, err } - r.volume.sectorSize = r.info.SectorSize + r.volume.sectorSize = defaultSectorSize } else if strings.HasSuffix(file.Name(), metadataSuffix) { if err := r.readDiskData(file.Name()); err != nil { return false, err From 9a2dcdd2f1db35794c19816746d53edb095165b6 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 13 May 2016 21:34:45 -0700 Subject: [PATCH 055/357] Send ping every 3 seconds to test connection --- rpc/client.go | 39 +++++++++++++++++++++++++++++++++++++++ rpc/server.go | 6 ++++++ rpc/types.go | 1 + 3 files changed, 46 insertions(+) diff --git a/rpc/client.go b/rpc/client.go index a72308d8..8f0a32e9 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -4,10 +4,15 @@ import ( "errors" "io" "net" + "time" "github.com/Sirupsen/logrus" ) +var ( + ErrPingTimeout = errors.New("Ping timeout") +) + type Client struct { end chan struct{} requests chan *Message @@ -42,6 +47,35 @@ func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { return c.operation(TypeRead, buf, offset) } +func (c *Client) Ping() error { + ret := make(chan error, 1) + go func() { + _, err := c.operation(TypePing, nil, 0) + ret <- err + }() + + select { + case err := <-ret: + return err + case <-time.After(2 * time.Second): + return ErrPingTimeout + } +} + +func (c *Client) checkPing() { + // don't ping if we know the connection is already bad + if c.err != nil { + return + } + + if err := c.Ping(); err != nil { + logrus.Errorf("Error monitoring wire: %v", err) + c.responses <- &Message{ + transportErr: err, + } + } +} + func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { msg := Message{ Type: op, @@ -70,9 +104,13 @@ func (c *Client) Close() { func (c *Client) loop() { defer close(c.send) + ticker := time.NewTicker(3 * time.Second) + defer ticker.Stop() for { select { + case <-ticker.C: + go c.checkPing() case <-c.end: return case req := <-c.requests: @@ -109,6 +147,7 @@ func (c *Client) handleRequest(req *Message) { func (c *Client) handleResponse(resp *Message) { if resp.transportErr != nil { c.err = resp.transportErr + logrus.Errorf("Got transport error: %v", c.err) // Terminate all in flight for _, msg := range c.messages { c.replyError(msg) diff --git a/rpc/server.go b/rpc/server.go index 5b51d8f3..bd39517e 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -46,6 +46,8 @@ func (s *Server) read() error { go s.handleRead(msg) case TypeWrite: go s.handleWrite(msg) + case TypePing: + go s.handlePong(msg) } } } @@ -60,6 +62,10 @@ func (s *Server) handleWrite(msg *Message) { s.pushResponse(c, msg, err) } +func (s *Server) handlePong(msg *Message) { + s.pushResponse(0, msg, nil) +} + func (s *Server) pushResponse(count int, msg *Message, err error) { msg.Type = TypeResponse if err == io.EOF { diff --git a/rpc/types.go b/rpc/types.go index b21fbc62..23ca4b95 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -8,6 +8,7 @@ const ( TypeResponse TypeError TypeEOF + TypePing messageSize = (32 + 32 + 32 + 64) / 8 readBufferSize = 8096 From df98dfa18ee39178e6d80d1db9b5b1a1c9eb3f8b Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Sat, 14 May 2016 09:02:18 -0700 Subject: [PATCH 056/357] Improve logging in several places --- agent/controller/controller.go | 2 +- app/add_replica.go | 2 +- app/controller.go | 2 +- app/ls_replica.go | 2 +- app/replica.go | 2 +- app/rm_replica.go | 2 +- app/snapshot.go | 8 ++++---- app/sync_agent.go | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/agent/controller/controller.go b/agent/controller/controller.go index 98dee9c0..c1b4e961 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -404,7 +404,7 @@ func (c *Controller) addReplica(r *replica) error { logrus.Warnf("longhorn add cli returned error %v while adding replica %v. Attempting to clean up.", err, address) replicas, err2 := c.client.ListReplicas() if err2 != nil { - logrus.Errorf("Error listing replicas while trying to clean up after failed add for replica %v", address) + logrus.Errorf("Error listing replicas while trying to clean up after failed add for replica %v: %v", address, err2) } else { for _, replica := range replicas { if replica.Address == address && replica.Mode != "RW" { diff --git a/app/add_replica.go b/app/add_replica.go index 0accc3fd..e1067d04 100644 --- a/app/add_replica.go +++ b/app/add_replica.go @@ -14,7 +14,7 @@ func AddReplicaCmd() cli.Command { ShortName: "add", Action: func(c *cli.Context) { if err := addReplica(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running add replica command: %v", err) } }, } diff --git a/app/controller.go b/app/controller.go index de763ba8..81531381 100644 --- a/app/controller.go +++ b/app/controller.go @@ -44,7 +44,7 @@ func ControllerCmd() cli.Command { }, Action: func(c *cli.Context) { if err := startController(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running controller command: %v.", err) } }, } diff --git a/app/ls_replica.go b/app/ls_replica.go index 3bd2a483..cd8ac8c6 100644 --- a/app/ls_replica.go +++ b/app/ls_replica.go @@ -16,7 +16,7 @@ func LsReplicaCmd() cli.Command { ShortName: "ls", Action: func(c *cli.Context) { if err := lsReplica(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running ls command: %v", err) } }, } diff --git a/app/replica.go b/app/replica.go index b19efa53..7aea9a1d 100644 --- a/app/replica.go +++ b/app/replica.go @@ -41,7 +41,7 @@ func ReplicaCmd() cli.Command { }, Action: func(c *cli.Context) { if err := startReplica(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running start replica command: %v", err) } }, } diff --git a/app/rm_replica.go b/app/rm_replica.go index 010f996b..027e3bda 100644 --- a/app/rm_replica.go +++ b/app/rm_replica.go @@ -13,7 +13,7 @@ func RmReplicaCmd() cli.Command { ShortName: "rm", Action: func(c *cli.Context) { if err := rmReplica(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running rm replica command: %v", err) } }, } diff --git a/app/snapshot.go b/app/snapshot.go index 549f5c0e..21907f31 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -23,7 +23,7 @@ func SnapshotCmd() cli.Command { }, Action: func(c *cli.Context) { if err := lsSnapshot(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running snapshot command: %v", err) } }, } @@ -34,7 +34,7 @@ func SnapshotCreateCmd() cli.Command { Name: "create", Action: func(c *cli.Context) { if err := createSnapshot(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running create snapshot command: %v", err) } }, } @@ -45,7 +45,7 @@ func SnapshotRmCmd() cli.Command { Name: "rm", Action: func(c *cli.Context) { if err := rmSnapshot(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running rm snapshot command: %v", err) } }, } @@ -56,7 +56,7 @@ func SnapshotLsCmd() cli.Command { Name: "ls", Action: func(c *cli.Context) { if err := lsSnapshot(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running ls snapshot command: %v", err) } }, } diff --git a/app/sync_agent.go b/app/sync_agent.go index a4310d83..f7ebe1a8 100644 --- a/app/sync_agent.go +++ b/app/sync_agent.go @@ -27,7 +27,7 @@ func SyncAgentCmd() cli.Command { }, Action: func(c *cli.Context) { if err := startSyncAgent(c); err != nil { - logrus.Fatal(err) + logrus.Fatalf("Error running sync-agent command: %v", err) } }, } From 7f6c55b492164c3e269b3b5f7b31048bc12f936f Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Sat, 14 May 2016 09:04:07 -0700 Subject: [PATCH 057/357] Add timeout to replica client --- client/replica_client.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/client/replica_client.go b/client/replica_client.go index be241b94..7211582c 100644 --- a/client/replica_client.go +++ b/client/replica_client.go @@ -17,9 +17,10 @@ import ( ) type ReplicaClient struct { - address string - syncAgent string - host string + address string + syncAgent string + host string + httpClient *http.Client } func NewReplicaClient(address string) (*ReplicaClient, error) { @@ -52,10 +53,16 @@ func NewReplicaClient(address string) (*ReplicaClient, error) { syncAgent := strings.Replace(address, fmt.Sprintf(":%d", port), fmt.Sprintf(":%d", port+2), -1) + timeout := time.Duration(10 * time.Second) + client := &http.Client{ + Timeout: timeout, + } + return &ReplicaClient{ - host: parts[0], - address: address, - syncAgent: syncAgent, + host: parts[0], + address: address, + syncAgent: syncAgent, + httpClient: client, }, nil } @@ -209,7 +216,7 @@ func (c *ReplicaClient) get(url string, obj interface{}) error { url = c.address + url } - resp, err := http.Get(url) + resp, err := c.httpClient.Get(url) if err != nil { return err } @@ -231,7 +238,8 @@ func (c *ReplicaClient) post(path string, req, resp interface{}) error { } logrus.Debugf("POST %s", url) - httpResp, err := http.Post(url, bodyType, bytes.NewBuffer(b)) + + httpResp, err := c.httpClient.Post(url, bodyType, bytes.NewBuffer(b)) if err != nil { return err } From 0b12986273e7ce2fb98072ac67261778f495ed98 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 14 May 2016 12:33:27 -0700 Subject: [PATCH 058/357] Add more logging around I/O errors in controller --- controller/control.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/controller/control.go b/controller/control.go index 2920f43b..4873e9a7 100644 --- a/controller/control.go +++ b/controller/control.go @@ -251,12 +251,14 @@ func (c *Controller) handleError(err error) error { if bErr, ok := err.(*BackendError); ok { c.Lock() if len(bErr.Errors) > 0 { - for address := range bErr.Errors { + for address, replicaErr := range bErr.Errors { + logrus.Errorf("Setting replica %s to ERR due to: %v", address, replicaErr) c.setReplicaModeNoLock(address, types.ERR) } // if we still have a good replica, do not return error for _, r := range c.replicas { if r.Mode == types.RW { + logrus.Errorf("Ignoring error because %s is mode RW: %v", r.Address, err) err = nil break } @@ -264,6 +266,9 @@ func (c *Controller) handleError(err error) error { } c.Unlock() } + if err != nil { + logrus.Errorf("I/O error: %v", err) + } return err } From c31eaacca1386e70023d6ccf83ff137189a74c2e Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 14 May 2016 21:20:31 -0700 Subject: [PATCH 059/357] Revert "Send ping every 3 seconds to test connection" This reverts commit 9a2dcdd2f1db35794c19816746d53edb095165b6. --- rpc/client.go | 39 --------------------------------------- rpc/server.go | 6 ------ rpc/types.go | 1 - 3 files changed, 46 deletions(-) diff --git a/rpc/client.go b/rpc/client.go index 8f0a32e9..a72308d8 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -4,15 +4,10 @@ import ( "errors" "io" "net" - "time" "github.com/Sirupsen/logrus" ) -var ( - ErrPingTimeout = errors.New("Ping timeout") -) - type Client struct { end chan struct{} requests chan *Message @@ -47,35 +42,6 @@ func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { return c.operation(TypeRead, buf, offset) } -func (c *Client) Ping() error { - ret := make(chan error, 1) - go func() { - _, err := c.operation(TypePing, nil, 0) - ret <- err - }() - - select { - case err := <-ret: - return err - case <-time.After(2 * time.Second): - return ErrPingTimeout - } -} - -func (c *Client) checkPing() { - // don't ping if we know the connection is already bad - if c.err != nil { - return - } - - if err := c.Ping(); err != nil { - logrus.Errorf("Error monitoring wire: %v", err) - c.responses <- &Message{ - transportErr: err, - } - } -} - func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { msg := Message{ Type: op, @@ -104,13 +70,9 @@ func (c *Client) Close() { func (c *Client) loop() { defer close(c.send) - ticker := time.NewTicker(3 * time.Second) - defer ticker.Stop() for { select { - case <-ticker.C: - go c.checkPing() case <-c.end: return case req := <-c.requests: @@ -147,7 +109,6 @@ func (c *Client) handleRequest(req *Message) { func (c *Client) handleResponse(resp *Message) { if resp.transportErr != nil { c.err = resp.transportErr - logrus.Errorf("Got transport error: %v", c.err) // Terminate all in flight for _, msg := range c.messages { c.replyError(msg) diff --git a/rpc/server.go b/rpc/server.go index bd39517e..5b51d8f3 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -46,8 +46,6 @@ func (s *Server) read() error { go s.handleRead(msg) case TypeWrite: go s.handleWrite(msg) - case TypePing: - go s.handlePong(msg) } } } @@ -62,10 +60,6 @@ func (s *Server) handleWrite(msg *Message) { s.pushResponse(c, msg, err) } -func (s *Server) handlePong(msg *Message) { - s.pushResponse(0, msg, nil) -} - func (s *Server) pushResponse(count int, msg *Message, err error) { msg.Type = TypeResponse if err == io.EOF { diff --git a/rpc/types.go b/rpc/types.go index 23ca4b95..b21fbc62 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -8,7 +8,6 @@ const ( TypeResponse TypeError TypeEOF - TypePing messageSize = (32 + 32 + 32 + 64) / 8 readBufferSize = 8096 From 90f7a6cedf0a3a245574ea0c6cf346926f934356 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 14 May 2016 21:58:18 -0700 Subject: [PATCH 060/357] Move ping logic to the control port --- app/replica.go | 11 ++++++-- backend/remote/remote.go | 58 +++++++++++++++++++++++++++++++++++++--- replica/rest/router.go | 4 +++ rpc/client.go | 6 +++++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/app/replica.go b/app/replica.go index 7aea9a1d..fced7bf3 100644 --- a/app/replica.go +++ b/app/replica.go @@ -83,9 +83,16 @@ func startReplica(c *cli.Context) error { go func() { server := rest.NewServer(s) router := http.Handler(rest.NewRouter(server)) - router = handlers.LoggingHandler(os.Stdout, router) + loggingHander := handlers.LoggingHandler(os.Stdout, router) + wrappedRouter := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if req.URL.Path == "/ping" { + router.ServeHTTP(rw, req) + } else { + loggingHander.ServeHTTP(rw, req) + } + }) logrus.Infof("Listening on control %s", controlAddress) - resp <- http.ListenAndServe(controlAddress, router) + resp <- http.ListenAndServe(controlAddress, wrappedRouter) }() go func() { diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 0c132fc7..b9f97830 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -3,6 +3,7 @@ package remote import ( "bytes" "encoding/json" + "errors" "fmt" "io" "net" @@ -18,8 +19,9 @@ import ( ) var ( - timeout = 30 * time.Second - requestBuffer = 1024 + timeout = 30 * time.Second + requestBuffer = 1024 + ErrPingTimeout = errors.New("Ping timeout") ) func New() types.BackendFactory { @@ -32,11 +34,14 @@ type Factory struct { type Remote struct { types.ReaderWriterAt name string + pingURL string replicaURL string httpClient *http.Client + closeChan chan struct{} } func (r *Remote) Close() error { + r.closeChan <- struct{}{} logrus.Infof("Closing: %s", r.name) return r.doAction("close", "") } @@ -131,9 +136,11 @@ func (rf *Factory) Create(address string) (types.Backend, error) { r := &Remote{ name: address, replicaURL: fmt.Sprintf("http://%s/v1/replicas/1", controlAddress), + pingURL: fmt.Sprintf("http://%s/ping", controlAddress), httpClient: &http.Client{ Timeout: timeout, }, + closeChan: make(chan struct{}, 1), } replica, err := r.info() @@ -150,7 +157,52 @@ func (rf *Factory) Create(address string) (types.Backend, error) { return nil, err } - r.ReaderWriterAt = rpc.NewClient(conn) + rpc := rpc.NewClient(conn) + go r.monitorPing(rpc) + + r.ReaderWriterAt = rpc return r, r.open() } + +func (r *Remote) monitorPing(client *rpc.Client) error { + ticker := time.NewTicker(3 * time.Second) + defer ticker.Stop() + + for { + select { + case <-r.closeChan: + break + case <-ticker.C: + if err := r.Ping(); err != nil { + logrus.Errorf("Failed to get ping response: %v", err) + client.SetError(err) + return err + } + } + } +} + +func (r *Remote) Ping() error { + ret := make(chan error, 1) + go func() { + resp, err := r.httpClient.Get(r.pingURL) + if err != nil { + ret <- err + return + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + ret <- fmt.Errorf("Non-200 response %d from ping to %s", resp.StatusCode, r.name) + return + } + ret <- nil + }() + + select { + case err := <-ret: + return err + case <-time.After(2 * time.Second): + return ErrPingTimeout + } +} diff --git a/replica/rest/router.go b/replica/rest/router.go index 2d36728c..a4d2e44c 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -24,6 +24,10 @@ func NewRouter(s *Server) *mux.Router { router := mux.NewRouter().StrictSlash(true) f := rest.HandleError + router.Methods("GET").Path("/ping").Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + rw.Write([]byte("pong")) + })) + // API framework routes router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) diff --git a/rpc/client.go b/rpc/client.go index a72308d8..8b7e445c 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -38,6 +38,12 @@ func (c *Client) WriteAt(buf []byte, offset int64) (int, error) { return c.operation(TypeWrite, buf, offset) } +func (c *Client) SetError(err error) { + c.responses <- &Message{ + transportErr: err, + } +} + func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { return c.operation(TypeRead, buf, offset) } From b40ae6542397acb384d826aabd26d25c7af5ff57 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 15 May 2016 16:46:02 -0700 Subject: [PATCH 061/357] Increase ping timeout to 10 seconds --- backend/remote/remote.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index b9f97830..c7fb9918 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -19,6 +19,8 @@ import ( ) var ( + pingTimeout = 10 * time.Second + pingInveral = 3 * time.Second timeout = 30 * time.Second requestBuffer = 1024 ErrPingTimeout = errors.New("Ping timeout") @@ -166,7 +168,7 @@ func (rf *Factory) Create(address string) (types.Backend, error) { } func (r *Remote) monitorPing(client *rpc.Client) error { - ticker := time.NewTicker(3 * time.Second) + ticker := time.NewTicker(pingInveral) defer ticker.Stop() for { @@ -202,7 +204,7 @@ func (r *Remote) Ping() error { select { case err := <-ret: return err - case <-time.After(2 * time.Second): + case <-time.After(pingTimeout): return ErrPingTimeout } } From 02f5abc9be2805e9f79d821bce72b79b45258202 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 15 May 2016 16:42:24 -0700 Subject: [PATCH 062/357] Release port after process dies --- sync/agent/process.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sync/agent/process.go b/sync/agent/process.go index 97734c89..05c58f5c 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -105,6 +105,9 @@ func (s *Server) CreateProcess(rw http.ResponseWriter, req *http.Request) error if err := s.launch(&p); err != nil { logrus.Errorf("Failed to launch %#v: %v", p, err) } + s.Lock() + delete(s.processesByPort, p.Port) + s.Unlock() }() apiContext.Write(&p) From d924600eb257ff945f94c0bbdbc77e18e70b394b Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Sun, 15 May 2016 20:15:44 -0700 Subject: [PATCH 063/357] update driver --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 6f3eb2b0..c436fd86 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -60,7 +60,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout 9c95a3185196ee2ee16f9d6068d8eaa195a25e4c && \ + git checkout b934aff313714b0e83c9b6f57c7b45ac649f43df && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From 1463f14a256cd3865c751f69272ef38a72329eaa Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 15 May 2016 21:39:29 -0700 Subject: [PATCH 064/357] Don't ping until open is succesful --- backend/remote/remote.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index c7fb9918..0de6455a 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -160,11 +160,15 @@ func (rf *Factory) Create(address string) (types.Backend, error) { } rpc := rpc.NewClient(conn) - go r.monitorPing(rpc) - r.ReaderWriterAt = rpc - return r, r.open() + if err := r.open(); err != nil { + return nil, err + } + + go r.monitorPing(rpc) + + return r, nil } func (r *Remote) monitorPing(client *rpc.Client) error { From 2ea15f7cbe2a3a02a35252e79aa8235193ef7ab9 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 15 May 2016 22:06:15 -0700 Subject: [PATCH 065/357] Terminate ping properly --- backend/remote/remote.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 0de6455a..2948223b 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -178,7 +178,7 @@ func (r *Remote) monitorPing(client *rpc.Client) error { for { select { case <-r.closeChan: - break + return nil case <-ticker.C: if err := r.Ping(); err != nil { logrus.Errorf("Failed to get ping response: %v", err) From 73463e2e02291155fa62663667b320bcb8d5efe4 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Mon, 16 May 2016 18:38:54 -0700 Subject: [PATCH 066/357] update docker-longhorn-driver commit --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index c436fd86..4dde82f6 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -60,7 +60,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout b934aff313714b0e83c9b6f57c7b45ac649f43df && \ + git checkout 2316da98aa7a46ae55afeef2499364df83291190 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From b5e4f88715e7a2e710c72d2c2175f90fee96245d Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 23 May 2016 11:14:18 -0700 Subject: [PATCH 067/357] Add backup code implementing objecstore.DeltaBlockBackupOperations --- qcow/libqcow.go | 2 +- replica/backup.go | 190 ++++++++++++++++ replica/backup_test.go | 188 +++++++++++++++ replica/extents.go | 64 ++++++ replica/replica.go | 43 +++- trash.yml | 5 +- vendor/github.com/rancher/convoy/.drone.yml | 4 + vendor/github.com/rancher/convoy/.gitignore | 26 +++ vendor/github.com/rancher/convoy/.package | 1 + .../rancher/convoy/.wrap-docker-args | 5 + .../rancher/convoy/Dockerfile.dapper | 59 +++++ vendor/github.com/rancher/convoy/LICENSE | 202 +++++++++++++++++ vendor/github.com/rancher/convoy/Makefile | 23 ++ vendor/github.com/rancher/convoy/README.md | 214 ++++++++++++++++++ vendor/github.com/rancher/convoy/apply.sh | 14 ++ vendor/github.com/rancher/convoy/main.go | 30 +++ .../rancher/convoy/metadata/devmapper.go | 40 ++++ .../rancher/convoy/metadata/devmapper_test.go | 92 ++++++++ .../rancher/convoy/metadata/metadata.go | 11 + vendor/github.com/rancher/convoy/trash.yml | 69 ++++++ 20 files changed, 1273 insertions(+), 9 deletions(-) create mode 100644 replica/backup.go create mode 100644 replica/backup_test.go create mode 100644 replica/extents.go create mode 100644 vendor/github.com/rancher/convoy/.drone.yml create mode 100644 vendor/github.com/rancher/convoy/.gitignore create mode 100644 vendor/github.com/rancher/convoy/.package create mode 100644 vendor/github.com/rancher/convoy/.wrap-docker-args create mode 100644 vendor/github.com/rancher/convoy/Dockerfile.dapper create mode 100644 vendor/github.com/rancher/convoy/LICENSE create mode 100644 vendor/github.com/rancher/convoy/Makefile create mode 100644 vendor/github.com/rancher/convoy/README.md create mode 100755 vendor/github.com/rancher/convoy/apply.sh create mode 100644 vendor/github.com/rancher/convoy/main.go create mode 100644 vendor/github.com/rancher/convoy/metadata/devmapper.go create mode 100644 vendor/github.com/rancher/convoy/metadata/devmapper_test.go create mode 100644 vendor/github.com/rancher/convoy/metadata/metadata.go create mode 100644 vendor/github.com/rancher/convoy/trash.yml diff --git a/qcow/libqcow.go b/qcow/libqcow.go index 012341b4..62b36dae 100644 --- a/qcow/libqcow.go +++ b/qcow/libqcow.go @@ -80,5 +80,5 @@ func (q Qcow) Size() (int64, error) { } func (q *Qcow) Fd() uintptr { - panic("Unsupported") + return 0 } diff --git a/replica/backup.go b/replica/backup.go new file mode 100644 index 00000000..a1cf96cc --- /dev/null +++ b/replica/backup.go @@ -0,0 +1,190 @@ +package replica + +import ( + "fmt" + "os" + "path" + + "github.com/rancher/convoy/metadata" +) + +const ( + snapBlockSize = 2 << 20 // 2MiB +) + +/* +type DeltaBlockBackupOperations interface { + HasSnapshot(id, volumeID string) bool + CompareSnapshot(id, compareID, volumeID string) (*metadata.Mappings, error) + OpenSnapshot(id, volumeID string) error + ReadSnapshot(id, volumeID string, start int64, data []byte) error + CloseSnapshot(id, volumeID string) error +} +*/ + +type Backup struct { + backingFile *BackingFile + replica *Replica + volumeID string + snapshotID string +} + +func NewBackup(backingFile *BackingFile) *Backup { + return &Backup{ + backingFile: backingFile, + } +} + +func (rb *Backup) HasSnapshot(id, volumeID string) bool { + data := path.Join(volumeID, id) + for _, file := range []string{data, data + ".meta"} { + if _, err := os.Stat(file); err != nil { + return false + } + } + return true +} + +func (rb *Backup) OpenSnapshot(id, volumeID string) error { + if rb.volumeID == volumeID && rb.snapshotID == id { + return nil + } + + if rb.volumeID != "" { + return fmt.Errorf("Volume %s and snapshot %s are already open, close first", rb.volumeID, rb.snapshotID) + } + + r, err := NewReadOnly(volumeID, id, rb.backingFile) + if err != nil { + return err + } + + rb.replica = r + rb.volumeID = volumeID + rb.snapshotID = id + + return nil +} + +func (rb *Backup) assertOpen(id, volumeID string) error { + if rb.volumeID != volumeID || rb.snapshotID != id { + return fmt.Errorf("Invalid state volume [%s] and snapshot [%s] are open, not [%s], [%s]", rb.volumeID, rb.snapshotID, id, volumeID) + } + return nil +} + +func (rb *Backup) ReadSnapshot(id, volumeID string, start int64, data []byte) error { + if err := rb.assertOpen(id, volumeID); err != nil { + return err + } + + if rb.snapshotID != id && rb.volumeID != volumeID { + return fmt.Errorf("Snapshot %s and volume %s are not open", id, volumeID) + } + + _, err := rb.replica.ReadAt(data, start) + return err +} + +func (rb *Backup) CloseSnapshot(id, volumeID string) error { + if rb.volumeID == "" { + return nil + } + + if err := rb.assertOpen(id, volumeID); err != nil { + return err + } + + err := rb.replica.Close() + + rb.replica = nil + rb.volumeID = "" + rb.snapshotID = "" + return err +} + +func (rb *Backup) CompareSnapshot(id, compareID, volumeID string) (*metadata.Mappings, error) { + if err := rb.assertOpen(id, volumeID); err != nil { + return nil, err + } + + rb.replica.Lock() + defer rb.replica.Unlock() + + from := rb.findIndex(id) + if from < 0 { + return nil, fmt.Errorf("Failed to find snapshot %s in chain", id) + } + + to := rb.findIndex(compareID) + if to < 0 { + return nil, fmt.Errorf("Failed to find snapshot %s in chain", compareID) + } + + mappings := &metadata.Mappings{ + BlockSize: snapBlockSize, + } + mapping := metadata.Mapping{ + Offset: -1, + } + + if err := preload(&rb.replica.volume); err != nil { + return nil, err + } + + for i, val := range rb.replica.volume.location { + if val <= byte(from) && val > byte(to) { + offset := int64(i) * rb.replica.volume.sectorSize + // align + offset -= (offset % snapBlockSize) + if mapping.Offset != offset { + mapping = metadata.Mapping{ + Offset: offset, + Size: snapBlockSize, + } + mappings.Mappings = append(mappings.Mappings, mapping) + } + } + } + + return mappings, nil +} + +func (rb *Backup) findIndex(id string) int { + if id == "" { + return 0 + } + + for i, disk := range rb.replica.activeDiskData { + if disk.name == id { + return i + } + } + return -1 +} + +func preload(d *diffDisk) error { + for i, f := range d.files { + if i == 0 { + continue + } + + if i == 1 { + // Reinitialize to zero so that we can detect holes in the base snapshot + for j := 0; j < len(d.location); j++ { + d.location[j] = 0 + } + } + + generator := newGenerator(d, f) + for offset := range generator.Generate() { + d.location[offset] = byte(i) + } + + if generator.Err() != nil { + return generator.Err() + } + } + + return nil +} diff --git a/replica/backup_test.go b/replica/backup_test.go new file mode 100644 index 00000000..808f59a5 --- /dev/null +++ b/replica/backup_test.go @@ -0,0 +1,188 @@ +package replica + +import ( + "io/ioutil" + "os" + "path" + + . "gopkg.in/check.v1" +) + +const ( + mb = 1 << 20 +) + +func (s *TestSuite) TestBackup(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(10*mb, bs, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + buf := make([]byte, 2*mb) + fill(buf, 1) + _, err = r.WriteAt(buf, mb) + c.Assert(err, IsNil) + + chain, err := r.Chain() + c.Assert(err, IsNil) + + rb := NewBackup(nil) + err = rb.OpenSnapshot(chain[0], dir) + c.Assert(err, IsNil) + + mappings, err := rb.CompareSnapshot(chain[0], "", dir) + c.Assert(err, IsNil) + c.Assert(len(mappings.Mappings), Equals, 2) + c.Assert(mappings.BlockSize, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[0].Offset, Equals, int64(0)) + c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Offset, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) +} + +func (s *TestSuite) TestBackupWithBackups(c *C) { + s.testBackupWithBackups(c, nil) +} + +func (s *TestSuite) TestBackupWithBackupsAndBacking(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + f, err := os.Create(path.Join(dir, "backing")) + c.Assert(err, IsNil) + defer f.Close() + + buf := make([]byte, 10*mb) + fill(buf, 10) + + _, err = f.Write(buf) + c.Assert(err, IsNil) + + backing := &BackingFile{ + Name: "backing", + Disk: f, + } + + s.testBackupWithBackups(c, backing) +} + +func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(10*mb, bs, dir, backingFile) + c.Assert(err, IsNil) + defer r.Close() + + // Write layout as follows + // 0 1 2 3 4 5 6 7 8 9 mb + // 003 X X X X X X X X X X + // 002 X X X X + // 001 X X X X + // 000 X X + buf := make([]byte, 2*mb) + fill(buf, 1) + _, err = r.WriteAt(buf, mb) + c.Assert(err, IsNil) + + err = r.Snapshot("001") + c.Assert(err, IsNil) + fill(buf, 2) + _, err = r.WriteAt(buf, 0) + c.Assert(err, IsNil) + _, err = r.WriteAt(buf, 4*mb) + c.Assert(err, IsNil) + + err = r.Snapshot("002") + c.Assert(err, IsNil) + fill(buf, 3) + _, err = r.WriteAt(buf, 4*mb) + c.Assert(err, IsNil) + _, err = r.WriteAt(buf, 8*mb) + c.Assert(err, IsNil) + + err = r.Snapshot("003") + c.Assert(err, IsNil) + buf = make([]byte, 10*mb) + fill(buf, 9) + _, err = r.WriteAt(buf, 0) + c.Assert(err, IsNil) + + chain, err := r.Chain() + + rb := NewBackup(nil) + + // Test 002 -> "" + err = rb.OpenSnapshot(chain[1], dir) + c.Assert(err, IsNil) + mappings, err := rb.CompareSnapshot(chain[1], "", dir) + c.Assert(err, IsNil) + c.Assert(len(mappings.Mappings), Equals, 4) + c.Assert(mappings.BlockSize, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[0].Offset, Equals, int64(0)) + c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Offset, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[2].Offset, Equals, int64(4*mb)) + c.Assert(mappings.Mappings[2].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[3].Offset, Equals, int64(8*mb)) + c.Assert(mappings.Mappings[3].Size, Equals, int64(2*mb)) + + // Test read + expected := make([]byte, 2*mb) + fill(expected, 2) + readBuf := make([]byte, 2*mb) + err = rb.ReadSnapshot(chain[1], dir, 0, readBuf) + c.Assert(err, IsNil) + byteEquals(c, readBuf, expected) + err = rb.CloseSnapshot(chain[1], dir) + c.Assert(err, IsNil) + + // Test 002 -> 001 + err = rb.OpenSnapshot(chain[1], dir) + c.Assert(err, IsNil) + mappings, err = rb.CompareSnapshot(chain[1], chain[2], dir) + c.Assert(err, IsNil) + c.Assert(len(mappings.Mappings), Equals, 2) + c.Assert(mappings.BlockSize, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[0].Offset, Equals, int64(4*mb)) + c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Offset, Equals, int64(8*mb)) + c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) + err = rb.CloseSnapshot(chain[1], dir) + + // Test 001 -> 000 + err = rb.OpenSnapshot(chain[2], dir) + c.Assert(err, IsNil) + mappings, err = rb.CompareSnapshot(chain[2], chain[3], dir) + c.Assert(err, IsNil) + c.Assert(len(mappings.Mappings), Equals, 2) + c.Assert(mappings.BlockSize, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[0].Offset, Equals, int64(0*mb)) + c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Offset, Equals, int64(4*mb)) + c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) + err = rb.CloseSnapshot(chain[2], dir) + c.Assert(err, IsNil) + + // Test 001 -> "" + err = rb.OpenSnapshot(chain[2], dir) + c.Assert(err, IsNil) + mappings, err = rb.CompareSnapshot(chain[2], "", dir) + c.Assert(err, IsNil) + c.Assert(len(mappings.Mappings), Equals, 3) + c.Assert(mappings.BlockSize, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[0].Offset, Equals, int64(0*mb)) + c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Offset, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[2].Offset, Equals, int64(4*mb)) + c.Assert(mappings.Mappings[2].Size, Equals, int64(2*mb)) + err = rb.CloseSnapshot(chain[2], dir) + c.Assert(err, IsNil) +} diff --git a/replica/extents.go b/replica/extents.go new file mode 100644 index 00000000..ce80872d --- /dev/null +++ b/replica/extents.go @@ -0,0 +1,64 @@ +package replica + +import ( + "github.com/frostschutz/go-fibmap" + "github.com/rancher/longhorn/types" +) + +type UsedGenerator struct { + err error + disk types.DiffDisk + d *diffDisk +} + +func newGenerator(diffDisk *diffDisk, disk types.DiffDisk) *UsedGenerator { + return &UsedGenerator{ + disk: disk, + d: diffDisk, + } +} + +func (u *UsedGenerator) Err() error { + return u.err +} + +func (u *UsedGenerator) Generate() <-chan int64 { + c := make(chan int64) + go u.findExtents(c) + return c +} + +func (u *UsedGenerator) findExtents(c chan<- int64) { + defer close(c) + + fd := u.disk.Fd() + + // The backing file will have a Fd of 0 + if fd == 0 { + return + } + + start := uint64(0) + end := uint64(len(u.d.location)) * uint64(u.d.sectorSize) + for { + extents, errno := fibmap.Fiemap(fd, start, end-start, 1024) + if errno != 0 { + u.err = errno + return + } + + if len(extents) == 0 { + return + } + + for _, extent := range extents { + start = extent.Logical + extent.Length + for i := int64(0); i < int64(extent.Length); i += u.d.sectorSize { + c <- (int64(extent.Logical) + i) / u.d.sectorSize + } + if extent.Flags&fibmap.FIEMAP_EXTENT_LAST != 0 { + return + } + } + } +} diff --git a/replica/replica.go b/replica/replica.go index f4cbf003..6b697d9d 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -36,6 +36,7 @@ type Replica struct { info Info diskData map[string]disk activeDiskData []disk + readOnly bool } type Info struct { @@ -67,6 +68,15 @@ func ReadInfo(dir string) (Info, error) { } func New(size, sectorSize int64, dir string, backingFile *BackingFile) (*Replica, error) { + return construct(false, size, sectorSize, dir, "", backingFile) +} + +func NewReadOnly(dir, head string, backingFile *BackingFile) (*Replica, error) { + // size and sectorSize don't matter because they will be read from metadata + return construct(true, 0, 512, dir, head, backingFile) +} + +func construct(readonly bool, size, sectorSize int64, dir, head string, backingFile *BackingFile) (*Replica, error) { if size%sectorSize != 0 { return nil, fmt.Errorf("Size %d not a multiple of sector size %d", size, sectorSize) } @@ -83,18 +93,28 @@ func New(size, sectorSize int64, dir string, backingFile *BackingFile) (*Replica r.info.Size = size r.info.SectorSize = sectorSize r.info.BackingFile = backingFile - r.volume.sectorSize = defaultSectorSize - locationSize := size / defaultSectorSize + + exists, err := r.readMetadata() + if err != nil { + return nil, err + } + + // Reference r.info.Size because it may have changed from reading + // metadata + locationSize := r.info.Size / r.volume.sectorSize if size%defaultSectorSize != 0 { locationSize++ } r.volume.location = make([]byte, locationSize) r.volume.files = []types.DiffDisk{nil} - exists, err := r.readMetadata() - if err != nil { - return nil, err + if r.readOnly && !exists { + return nil, os.ErrNotExist + } + + if head != "" { + r.info.Head = head } if exists { @@ -246,6 +266,10 @@ func (r *Replica) close() error { } func (r *Replica) encodeToFile(obj interface{}, file string) error { + if r.readOnly { + return nil + } + f, err := os.Create(path.Join(r.dir, file+".tmp")) if err != nil { return err @@ -278,7 +302,6 @@ func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) } func (r *Replica) openFile(name string, flag int) (types.DiffDisk, error) { - // TODO: need to turn on O_DIRECT f, err := os.OpenFile(path.Join(r.dir, name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) if err != nil { return nil, err @@ -344,6 +367,10 @@ func (r *Replica) rmDisk(name string) error { } func (r *Replica) createDisk(name string) error { + if r.readOnly { + return fmt.Errorf("Can not create disk on read-only replica") + } + done := false oldHead := r.info.Head newSnapName := fmt.Sprintf(diskName, name) @@ -492,6 +519,10 @@ func (r *Replica) Snapshot(name string) error { } func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { + if r.readOnly { + return 0, fmt.Errorf("Can not write on read-only replica") + } + r.RLock() r.info.Dirty = true c, err := r.volume.WriteAt(buf, offset) diff --git a/trash.yml b/trash.yml index 7db7acb3..af86c766 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,8 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 8ab53cdb89eb75f6ab104e44145303b04139689c - repo: https://github.com/ibuildthecloud/sparse-tools.git + version: c651f80b29e69cec8de4f8c8a402266844aa6e5f - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec +- package: github.com/rancher/convoy + version: a583d83d3104449580779b06e27a63bc7371b4d0 diff --git a/vendor/github.com/rancher/convoy/.drone.yml b/vendor/github.com/rancher/convoy/.drone.yml new file mode 100644 index 00000000..b0f0e2eb --- /dev/null +++ b/vendor/github.com/rancher/convoy/.drone.yml @@ -0,0 +1,4 @@ +image: rancher/dind:v1.10.0-rancher1 +script: + - wrapdocker + - make ci diff --git a/vendor/github.com/rancher/convoy/.gitignore b/vendor/github.com/rancher/convoy/.gitignore new file mode 100644 index 00000000..4eaf69ae --- /dev/null +++ b/vendor/github.com/rancher/convoy/.gitignore @@ -0,0 +1,26 @@ +# 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 + +longhorn/template.go diff --git a/vendor/github.com/rancher/convoy/.package b/vendor/github.com/rancher/convoy/.package new file mode 100644 index 00000000..443ab7bf --- /dev/null +++ b/vendor/github.com/rancher/convoy/.package @@ -0,0 +1 @@ +github.com/rancher/convoy diff --git a/vendor/github.com/rancher/convoy/.wrap-docker-args b/vendor/github.com/rancher/convoy/.wrap-docker-args new file mode 100644 index 00000000..6fe60d2a --- /dev/null +++ b/vendor/github.com/rancher/convoy/.wrap-docker-args @@ -0,0 +1,5 @@ +--privileged \ +-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \ +-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \ +-e CONVOY_TEST_AWS_REGION=${CONVOY_TEST_AWS_REGION} \ +-e CONVOY_TEST_AWS_BUCKET=${CONVOY_TEST_AWS_BUCKET} diff --git a/vendor/github.com/rancher/convoy/Dockerfile.dapper b/vendor/github.com/rancher/convoy/Dockerfile.dapper new file mode 100644 index 00000000..0c465004 --- /dev/null +++ b/vendor/github.com/rancher/convoy/Dockerfile.dapper @@ -0,0 +1,59 @@ +FROM ubuntu:16.04 + +# Install packages +RUN apt-get update && \ + apt-get install -y \ + cmake \ + curl \ + git \ + libglib2.0-dev \ + libkmod-dev \ + libnl-genl-3-dev \ + linux-libc-dev \ + pkg-config \ + psmisc \ + python-tox + +# Install Go 1.6 +RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz +RUN echo 'e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a go.tar.gz' | sha256sum -c && \ + tar xzf go.tar.gz -C /usr/local && \ + rm go.tar.gz +RUN mkdir -p /go +ENV PATH $PATH:/usr/local/go/bin +ENV GOPATH=/go + +# Go tools +RUN go get github.com/rancher/trash +RUN go get github.com/golang/lint/golint + +# Docker +RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ + chmod +x /usr/bin/docker + +# Install liblvm2 +RUN curl -o lvm.tar.gz https://git.fedorahosted.org/cgit/lvm2.git/snapshot/lvm2-2_02_103.tar.gz && \ + tar xzf lvm.tar.gz -C /usr/local/ && \ + cd /usr/local/lvm2-2_02_103 && \ + ./configure --enable-static_link && \ + make device-mapper && \ + make install_device-mapper + +# Install convoy-pdata_tools +RUN curl -sL https://github.com/rancher/thin-provisioning-tools/releases/download/convoy-v0.2.1/convoy-pdata_tools > /usr/local/bin/convoy-pdata_tools && \ + chmod a+x /usr/local/bin/convoy-pdata_tools + +# Setup environment +ENV PATH /go/bin:$PATH +ENV DAPPER_DOCKER_SOCKET true +ENV DAPPER_ENV TAG REPO +ENV DAPPER_OUTPUT ./bin ./dist +ENV DAPPER_RUN_ARGS --privileged +ENV DAPPER_SOURCE /go/src/github.com/rancher/convoy +ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache +WORKDIR ${DAPPER_SOURCE} + +VOLUME /tmp +ENV TMPDIR /tmp +ENTRYPOINT ["./scripts/entry"] +CMD ["build"] diff --git a/vendor/github.com/rancher/convoy/LICENSE b/vendor/github.com/rancher/convoy/LICENSE new file mode 100644 index 00000000..e06d2081 --- /dev/null +++ b/vendor/github.com/rancher/convoy/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/rancher/convoy/Makefile b/vendor/github.com/rancher/convoy/Makefile new file mode 100644 index 00000000..d7d72a16 --- /dev/null +++ b/vendor/github.com/rancher/convoy/Makefile @@ -0,0 +1,23 @@ +TARGETS := $(shell ls scripts) + +.dapper: + @echo Downloading dapper + @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp + @@chmod +x .dapper.tmp + @./.dapper.tmp -v + @mv .dapper.tmp .dapper + +$(TARGETS): .dapper + ./.dapper $@ + +trash: .dapper + ./.dapper -m bind trash + +trash-keep: .dapper + ./.dapper -m bind trash -k + +deps: trash + +.DEFAULT_GOAL := ci + +.PHONY: $(TARGETS) diff --git a/vendor/github.com/rancher/convoy/README.md b/vendor/github.com/rancher/convoy/README.md new file mode 100644 index 00000000..ce59d822 --- /dev/null +++ b/vendor/github.com/rancher/convoy/README.md @@ -0,0 +1,214 @@ +# Convoy [![Build Status](http://ci.rancher.io/api/badge/github.com/rancher/convoy/status.svg?branch=master)](http://ci.rancher.io/github.com/rancher/convoy) + +## Overview +Convoy is a Docker volume plugin for a variety of storage back-ends. It's designed to be a simple Docker volume plug-ins that supports vendor-specific extensions such as snapshots, backups and restore. It's written in Go and can be deployed as a standalone binary. + +[![Convoy_DEMO](https://asciinema.org/a/9y5nbp3h97vyyxnzuax9f568e.png)](https://asciinema.org/a/9y5nbp3h97vyyxnzuax9f568e?autoplay=1&loop=1&size=medium&speed=2) + +## Why we need Convoy? +Docker has various drivers(aufs, device mapper, etc) for container's root image, but not for volumes. User can create volume through ```docker run -v volname```, but it's disposable, cannot be easily reused for new containers or containers on the other hosts. For example, if you start a wordpress container with database, add some posts, remove the container, then the modified database would lost. + +Before volume plugin, the only way to reuse the volume is using host bind mount feature of Docker, as ```docker run -v /host_path:/container_path```, then maintain the content of the volume at ```/hostpath```. You can also use ```--volume-from``` but that would require original container still exists on the same host. + +Convoy used Docker volume plugin mechanism to provide persistent volume for Docker containers, and supports various of backends(e.g. device mapper, NFS, EBS) and more features like snapshot/backup/restore. So user would able to migrate the volumes between the hosts, share the same volume across the hosts, make scheduled snapshots of as well as recover to previous version of volume. It's much easier for user to manage data with Docker volumes with Convoy. + +### Backends supported by Convoy currently +* Device Mapper +* Virtual File System(VFS)/Network File System(NFS) +* Amazon Elastic Block Store(EBS) + +## Quick Start Guide +First let's make sure we have Docker 1.8 or above running. +``` +docker --version +``` +If not, install the latest Docker daemon as follows: +``` +curl -sSL https://get.docker.com/ | sh +``` +Once we have made sure we have the right Docker daemon running, we can install and configure Convoy volume plugin as follows: +``` +wget https://github.com/rancher/convoy/releases/download/v0.4.3/convoy.tar.gz +tar xvf convoy.tar.gz +sudo cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/ +sudo mkdir -p /etc/docker/plugins/ +sudo bash -c 'echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec' +``` +We can use file-backed loopback device to test and demo Convoy Device Mapper driver. Loopback device, however, is known to be unstable and should not be used in production. +``` +truncate -s 100G data.vol +truncate -s 1G metadata.vol +sudo losetup /dev/loop5 data.vol +sudo losetup /dev/loop6 metadata.vol +``` +Once we have the data and metadata device setup, we can start the Convoy plugin daemon as follows: +``` +sudo convoy daemon --drivers devicemapper --driver-opts dm.datadev=/dev/loop5 --driver-opts dm.metadatadev=/dev/loop6 +``` +We can create a Docker container with a convoy volume. As a test, we create a file called `/vol1/foo` in the convoy volume: +``` +sudo docker run -v vol1:/vol1 --volume-driver=convoy ubuntu touch /vol1/foo +``` +Next we take a snapshot of the convoy volume. We backup the snapshot to a local directory: (Backup to NFS share or S3 objectore is also supported.) +``` +sudo convoy snapshot create vol1 --name snap1vol1 +sudo mkdir -p /opt/convoy/ +sudo convoy backup create snap1vol1 --dest vfs:///opt/convoy/ +``` +The `convoy backup` command returns a URL string representing backup dataset. You can use the same URL string to recover the volume to another host: +``` +sudo convoy create res1 --backup +``` +The following command creates a new container and mounts the recovered convoy volume into that container: +``` +sudo docker run -v res1:/res1 --volume-driver=convoy ubuntu ls /res1/foo +``` +You should see the recovered file ```/res1/foo```. + +## Installation +Ensure you have Docker 1.8 or above installed. + +Download latest version of [convoy](https://github.com/rancher/convoy/releases/download/v0.4.3/convoy.tar.gz) and unzip it. Put the binaries in a directory in the execution ```$PATH``` of sudo and root users (e.g. /usr/local/bin). +``` +wget https://github.com/rancher/convoy/releases/download/v0.4.3/convoy.tar.gz +tar xvf convoy.tar.gz +sudo cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/ +``` +Run the following commands to setup the Convoy volume plugin for Docker: +``` +sudo mkdir -p /etc/docker/plugins/ +sudo bash -c 'echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec' +``` + +## Start Convoy Daemon + +You need to pass different arguments to convoy daemon depending on the choice of backend implementation. + +#### Device Mapper +For production environment, it's recommended to attach a new empty block device to the host Convoy running on for using Device Mapper driver. Then you can make two partitions out of the device using [`dm_dev_partition.sh`](https://raw.githubusercontent.com/rancher/convoy/master/tools/dm_dev_partition.sh) to get two block devices fitting for Device Mapper driver. See [Device Mapper Partition Helper](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#device-mapper-partition-helper) for more details. + +Device Mapper requires two block devices to create storage pool for all volumes and snapshots. Assuming you have two devices created, one data device called `/dev/convoy-vg/data` and the other metadata device called `/dev/convoy-vg/metadata`. You run the following command to start the Convoy daemon: +``` +sudo convoy daemon --drivers devicemapper --driver-opts dm.datadev=/dev/convoy-vg/data --driver-opts dm.metadatadev=/dev/convoy-vg/metadata +``` +* A default Device Mapper volume size is 100G. You can override it with the `---driver-opts dm.defaultvolumesize` option. +* You can take a look at [here](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#calculate-the-size-you-need-for-metadata-block-device) if you want to know how much storage need to be allocated for metadata device. + +#### NFS +First, mount the NFS share to the root directory used to store volumes. Substitute `` to the appropriate directory of your choice: +``` +sudo mkdir +sudo mount -t nfs :/path +``` +The NFS-based Convoy daemon can be started as follows: +``` +sudo convoy daemon --drivers vfs --driver-opts vfs.path= +``` + +#### EBS +Make sure you're running on EC2 instance, and has already [configured AWS credentials](https://github.com/aws/aws-sdk-go#configuring-credentials) correctly. +``` +sudo convoy daemon --drivers ebs +``` + +## Volume Commands +#### Create a Volume + +Volumes can be created using the `convoy create` command: +``` +sudo convoy create volume_name +``` +* Device Mapper: Default volume size is 100G. `--size` [option](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#create) is supported. +* EBS: Default volume size is 4G. `--size` and [some other options](https://github.com/rancher/convoy/blob/master/docs/ebs.md#create) are supported. + +We can also create a volume using the [`docker run`](https://github.com/rancher/convoy/blob/master/docs/docker.md#create-container) command. If the volume does not yet exist, a new volume will be created. Otherwise the existing volume will be used. +``` +sudo docker run -it -v test_volume:/test --volume-driver=convoy ubuntu +``` + +#### Delete a Volume +``` +sudo convoy delete +``` +or +``` +sudo docker rm -v +``` +* NFS or EBS: The `-r/--reference` option instructs the `convoy delete` command to only delete the reference to the volume from the current host and leave the underlying files on [NFS server](https://github.com/rancher/convoy/blob/master/docs/vfs.md#delete) or [EBS volume](https://github.com/rancher/convoy/blob/master/docs/ebs.md#delete) unchanged. This is useful when the volume need to be reused later. +* [`docker rm -v`](https://github.com/rancher/convoy/blob/master/docs/docker.md#delete-container) would be treated as `convoy delete` with `-r/--reference`. +* If you use `--rm` with `docker run`, all the volumes associated with the container would be deleted in the same way as executing `docker rm -v` when exit. See [Docker run reference](https://docs.docker.com/engine/reference/run/) for details. + +#### List and Inspect a Volume +``` +sudo convoy list +sudo convoy inspect vol1 +``` + +#### Take Snapshot of a Volume +``` +sudo convoy snapshot create vol1 --name snap1vol1 +``` + +#### Delete a Snapshot +``` +sudo convoy snapshot delete snap1vol1 +``` +* Device Mapper: please make sure you keep [the latest backed-up snapshot](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#backup-create) for the same volume available to enable incremental backup mechanism, since Convoy need it to calculate the differences between snapshots. + +#### Backup a Snapshot +* Device Mapper or VFS: We can backup a snapshot to S3 object store or an NFS mount/local directory: +``` +sudo convoy backup create snap1vol1 --dest s3://backup-bucket@us-west-2/ +``` +or +``` +sudo convoy backup create snap1vol1 --dest vfs:///opt/backup/ +``` + +The backup operation returns a URL string that uniquely idenfied the backup dataset. +``` +s3://backup-bucket@us-west-2/?backup=f98f9ea1-dd6e-4490-8212-6d50df1982ea\u0026volume=e0d386c5-6a24-446c-8111-1077d10356b0 +``` +If you're using S3, please make sure you have AWS credential ready either at ```~/.aws/credentials``` or as environment variables, as described [here](https://github.com/aws/aws-sdk-go#configuring-credentials). You may need to put credentials to ```/root/.aws/credentials``` or setup sudo environment variables in order to get S3 credential works. + +* EBS: `--dest` is [not needed](https://github.com/rancher/convoy/blob/master/docs/ebs.md#backup-create). Just do `convoy backup create snap1vol1`. + +#### Restore a Volume from Backup +``` +sudo convoy create res1 --backup +``` +* EBS: Current host must be in the [same region](https://github.com/rancher/convoy/blob/master/docs/ebs.md#create) of backup to be restored. + +#### Mount a Restored Volume into a Docker Container +We can use the standard `docker run` command to mount the restored volume into a Docker container: +``` +sudo docker run -it -v res1:/res1 --volume-driver convoy ubuntu +``` + +#### Mount an NFS-Backed Volume on Multiple Servers +You can mount an NFS-backed volume on multiple servers. You can use the standard `docker run` command to mount an existing NFS-backed mount into a Docker container. For example, if you have already created an NFS-based volume `vol1` on one host, you can run the following command to mount the existing `vol1` volume into a new container: +``` +sudo docker run -it -v vol1:/vol1 --volume-driver=convoy ubuntu +``` +## Support and Discussion +If you need any help with Convoy, please join us at either our [forum](http://forums.rancher.com/c/convoy) or [#rancher IRC channel](http://webchat.freenode.net/?channels=rancher). + +Feel free to submit any bugs, issues, and feature requests to [Convoy Issues](https://github.com/rancher/convoy/issues). + +## Contribution +Contribution are welcome! Please take a look at [Development Guide](https://github.com/rancher/convoy/blob/master/docs/development.md) if you want to how to build Convoy from source or running test cases. + +We love to hear new Convoy Driver ideas from you. Implemenations are most welcome! Please consider take a look at [enhancement ideas](https://github.com/rancher/convoy/labels/enhancement) if you want contribute. + +And of course, [bug fixes](https://github.com/rancher/convoy/issues) are always welcome! + +## References +[Convoy Command Line Reference](https://github.com/rancher/convoy/blob/master/docs/cli_reference.md) + +[Using Convoy with Docker](https://github.com/rancher/convoy/blob/master/docs/docker.md) +#### Driver Specific +[Device Mapper](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md) + +[Amazon Elastic Block Store](https://github.com/rancher/convoy/blob/master/docs/ebs.md) + +[Virtual File System/Network File System](https://github.com/rancher/convoy/blob/master/docs/vfs.md) diff --git a/vendor/github.com/rancher/convoy/apply.sh b/vendor/github.com/rancher/convoy/apply.sh new file mode 100755 index 00000000..f8c86158 --- /dev/null +++ b/vendor/github.com/rancher/convoy/apply.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source ${CATTLE_HOME:-/var/lib/cattle}/common/scripts.sh + +trap "touch $CATTLE_HOME/.pyagent-stamp" exit + +cd $(dirname $0) + +mkdir -p ${CATTLE_HOME}/bin + +cp bin/convoy bin/convoy-pdata_tools ${CATTLE_HOME}/bin + +chmod +x ${CATTLE_HOME}/bin/convoy +chmod +x ${CATTLE_HOME}/bin/convoy-pdata_tools diff --git a/vendor/github.com/rancher/convoy/main.go b/vendor/github.com/rancher/convoy/main.go new file mode 100644 index 00000000..812e4485 --- /dev/null +++ b/vendor/github.com/rancher/convoy/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/rancher/convoy/api" + "github.com/rancher/convoy/client" + "os" +) + +var ( + // version of Convoy + VERSION = "0.5.0-dev" +) + +func cleanup() { + if r := recover(); r != nil { + api.ResponseLogAndError(r) + os.Exit(1) + } +} + +func main() { + defer cleanup() + + cli := client.NewCli(VERSION) + err := cli.Run(os.Args) + if err != nil { + panic(fmt.Errorf("Error when executing command: %v", err)) + } +} diff --git a/vendor/github.com/rancher/convoy/metadata/devmapper.go b/vendor/github.com/rancher/convoy/metadata/devmapper.go new file mode 100644 index 00000000..77c994a8 --- /dev/null +++ b/vendor/github.com/rancher/convoy/metadata/devmapper.go @@ -0,0 +1,40 @@ +package metadata + +import ( + "encoding/xml" +) + +func DeviceMapperThinDeltaParser(data []byte, blockSize int64, includeSame bool) (*Mappings, error) { + type Entry struct { + XMLName xml.Name + Begin int64 `xml:"begin,attr"` + Length int64 `xml:"length,attr"` + } + + type Diff struct { + Entries []Entry `xml:",any"` + } + + type Superblock struct { + Diff Diff `xml:"diff"` + } + + superblock := &Superblock{} + if err := xml.Unmarshal(data, superblock); err != nil { + return nil, err + } + + mapping := &Mappings{} + for _, d := range superblock.Diff.Entries { + if !includeSame && d.XMLName.Local == "same" { + continue + } + var m Mapping + m.Offset = d.Begin * blockSize + m.Size = d.Length * blockSize + mapping.Mappings = append(mapping.Mappings, m) + } + mapping.BlockSize = blockSize + + return mapping, nil +} diff --git a/vendor/github.com/rancher/convoy/metadata/devmapper_test.go b/vendor/github.com/rancher/convoy/metadata/devmapper_test.go new file mode 100644 index 00000000..dfdf4bc4 --- /dev/null +++ b/vendor/github.com/rancher/convoy/metadata/devmapper_test.go @@ -0,0 +1,92 @@ +package metadata + +import ( + "testing" + + . "gopkg.in/check.v1" +) + +const ( + thinDeltaOutputSame = ` + + + + + + + + + ` + thinDeltaOutputDiff = ` + + + + + + ` + thinDeltaOutputMix = ` + + + + + + + + + ` + blockSize = 2097152 +) + +func Test(t *testing.T) { + TestingT(t) +} + +type TestSuite struct{} + +var _ = Suite(&TestSuite{}) + +func (s *TestSuite) TestThinDelta(c *C) { + mSame := Mappings{ + Mappings: []Mapping{ + {Offset: 0, Size: 1 * blockSize}, + {Offset: 1 * blockSize, Size: 1 * blockSize}, + {Offset: 4 * blockSize, Size: 3 * blockSize}, + {Offset: 8 * blockSize, Size: 1 * blockSize}, + {Offset: 12 * blockSize, Size: 1 * blockSize}, + }, + BlockSize: blockSize, + } + mDiff := Mappings{ + Mappings: []Mapping{ + {Offset: 0, Size: 1 * blockSize}, + {Offset: 4 * blockSize, Size: 1 * blockSize}, + }, + BlockSize: blockSize, + } + mMix := Mappings{ + Mappings: []Mapping{ + {Offset: 2 * blockSize, Size: 1 * blockSize}, + {Offset: 4 * blockSize, Size: 1 * blockSize}, + {Offset: 6 * blockSize, Size: 1 * blockSize}, + {Offset: 8 * blockSize, Size: 2 * blockSize}, + }, + BlockSize: blockSize, + } + + var ( + m *Mappings + err error + ) + + m, err = DeviceMapperThinDeltaParser([]byte(thinDeltaOutputSame), blockSize, true) + c.Assert(err, IsNil) + c.Assert(*m, DeepEquals, mSame) + + m, err = DeviceMapperThinDeltaParser([]byte(thinDeltaOutputMix), blockSize, false) + c.Assert(err, IsNil) + c.Assert(*m, DeepEquals, mMix) + + m, err = DeviceMapperThinDeltaParser([]byte(thinDeltaOutputDiff), blockSize, false) + c.Assert(err, IsNil) + c.Assert(*m, DeepEquals, mDiff) +} diff --git a/vendor/github.com/rancher/convoy/metadata/metadata.go b/vendor/github.com/rancher/convoy/metadata/metadata.go new file mode 100644 index 00000000..28c33dbc --- /dev/null +++ b/vendor/github.com/rancher/convoy/metadata/metadata.go @@ -0,0 +1,11 @@ +package metadata + +type Mapping struct { + Offset int64 + Size int64 +} + +type Mappings struct { + Mappings []Mapping + BlockSize int64 +} diff --git a/vendor/github.com/rancher/convoy/trash.yml b/vendor/github.com/rancher/convoy/trash.yml new file mode 100644 index 00000000..e543d0ab --- /dev/null +++ b/vendor/github.com/rancher/convoy/trash.yml @@ -0,0 +1,69 @@ +package: github.com/rancher/convoy + +import: +- package: github.com/Sirupsen/logrus + version: 6ba91e24c498b49d0363c723e9e2ab2b5b8fd012 + +- package: github.com/aws/aws-sdk-go/aws + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/endpoints + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/protocol/ec2query + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/protocol/query + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/protocol/rest + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/protocol/restxml + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/signer/v4 + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/private/waiter + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/service/ec2 + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/aws/aws-sdk-go/service/s3 + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc + +- package: github.com/codegangsta/cli + version: c31a7975863e7810c92e2e288a9ab074f9a88f29 + +- package: github.com/docker/docker/pkg/devicemapper + version: ea65c38ac0972709cdb371ce6b1886eb252a126e + +- package: github.com/go-ini/ini + version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 + +- package: github.com/gorilla/context + version: 215affda49addc4c8ef7e2534915df2c8c35c6cd + +- package: github.com/gorilla/mux + version: e444e69cbd2e2e3e0749a2f3c717cec491552bbf + +- package: github.com/jmespath/go-jmespath + version: c01cf91b011868172fdcd9f41838e80c9d716264 + +- package: github.com/mcuadros/go-version + version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 + +- package: github.com/satori/go.uuid + version: d41af8bb6a7704f00bc3b7cba9355ae6a5a80048 + +- package: golang.org/x/sys/unix + version: 442cd600860ce722f6615730eb008a37a87b13ee + +- package: gopkg.in/check.v1 + version: 4f90aeace3a26ad7021961c297b22c42160c7b25 + From 48e596b14451a51280dfeb1657050496d5e928d1 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 23 May 2016 16:49:11 -0700 Subject: [PATCH 068/357] Allow snapshot name to be specified --- controller/rest/model.go | 7 +++++++ controller/rest/volume.go | 7 ++++++- integration/core/test_cli.py | 8 ++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/controller/rest/model.go b/controller/rest/model.go index 25199077..cc743e50 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -40,6 +40,11 @@ type SnapshotOutput struct { client.Resource } +type SnapshotInput struct { + client.Resource + Name string `json:"name"` +} + func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { v := &Volume{ Resource: client.Resource{ @@ -91,6 +96,7 @@ func NewSchema() *client.Schemas { schemas.AddType("schema", client.Schema{}) schemas.AddType("startInput", StartInput{}) schemas.AddType("snapshotOutput", SnapshotOutput{}) + schemas.AddType("snapshotInput", SnapshotInput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} @@ -114,6 +120,7 @@ func NewSchema() *client.Schemas { Output: "volume", }, "snapshot": client.Action{ + Input: "snapshotInput", Output: "snapshotOutput", }, } diff --git a/controller/rest/volume.go b/controller/rest/volume.go index b8e2b826..4e28b5b7 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -59,7 +59,12 @@ func (s *Server) SnapshotVolume(rw http.ResponseWriter, req *http.Request) error return nil } - name, err := s.c.Snapshot("") + var input SnapshotInput + if err := apiContext.Read(&input); err != nil { + return err + } + + name, err := s.c.Snapshot(input.Name) if err != nil { return err } diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 91530173..10134e6a 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -196,11 +196,11 @@ def test_snapshot(bin, controller_client, replica_client, replica_client2): ]) assert v.replicaCount == 2 - snap = v.snapshot() - assert snap.id != '' + snap = v.snapshot(name='foo1') + assert snap.id == 'foo1' - snap2 = v.snapshot() - assert snap2.id != '' + snap2 = v.snapshot(name='foo2') + assert snap2.id == 'foo2' cmd = [bin, '--debug', 'snapshot'] output = subprocess.check_output(cmd) From f47d4783431ea8a0c02579e2bf593d62482fc48f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 24 May 2016 10:48:14 -0700 Subject: [PATCH 069/357] Change timeout back to a total of 5 seconds (2 second interval, 3 timeout) --- backend/remote/remote.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 2948223b..9f374c5d 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -19,8 +19,8 @@ import ( ) var ( - pingTimeout = 10 * time.Second - pingInveral = 3 * time.Second + pingTimeout = 3 * time.Second + pingInveral = 2 * time.Second timeout = 30 * time.Second requestBuffer = 1024 ErrPingTimeout = errors.New("Ping timeout") From 853f24b571e90f4aba3807bffa0125885fe01474 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 24 May 2016 17:50:36 -0700 Subject: [PATCH 070/357] vendor: Update ssync --- trash.yml | 2 +- .../github.com/Sirupsen/logrus/entry_test.go | 77 - .../Sirupsen/logrus/formatter_bench_test.go | 98 -- .../github.com/Sirupsen/logrus/hook_test.go | 122 -- .../Sirupsen/logrus/json_formatter_test.go | 120 -- .../github.com/Sirupsen/logrus/logrus_test.go | 301 ---- .../Sirupsen/logrus/text_formatter_test.go | 61 - vendor/github.com/codegangsta/cli/app_test.go | 1097 ------------- .../codegangsta/cli/command_test.go | 97 -- .../codegangsta/cli/context_test.go | 121 -- .../github.com/codegangsta/cli/flag_test.go | 859 ---------- .../github.com/codegangsta/cli/help_test.go | 110 -- .../codegangsta/cli/helpers_test.go | 19 - .../docker/go-units/duration_test.go | 81 - .../github.com/docker/go-units/size_test.go | 163 -- .../github.com/docker/go-units/ulimit_test.go | 74 - .../gorilla/context/context_test.go | 161 -- .../gorilla/handlers/canonical_test.go | 127 -- .../gorilla/handlers/compress_test.go | 154 -- .../github.com/gorilla/handlers/cors_test.go | 336 ---- .../gorilla/handlers/handlers_test.go | 354 ---- .../gorilla/handlers/proxy_headers_test.go | 100 -- .../gorilla/handlers/recovery_test.go | 44 - vendor/github.com/gorilla/mux/bench_test.go | 49 - vendor/github.com/gorilla/mux/mux_test.go | 1453 ----------------- vendor/github.com/gorilla/mux/old_test.go | 710 -------- .../gorilla/websocket/bench_test.go | 19 - .../gorilla/websocket/client_server_test.go | 451 ----- .../gorilla/websocket/client_test.go | 72 - .../github.com/gorilla/websocket/conn_test.go | 367 ----- .../gorilla/websocket/example_test.go | 46 - .../github.com/gorilla/websocket/json_test.go | 119 -- .../gorilla/websocket/server_test.go | 51 - .../github.com/gorilla/websocket/util_test.go | 34 - vendor/github.com/rancher/convoy/main.go | 30 - .../rancher/convoy/metadata/devmapper_test.go | 92 -- .../rancher/go-rancher-metadata/main.go | 31 - .../rancher/go-rancher/client/client_test.go | 218 --- vendor/github.com/rancher/go-rancher/main.go | 10 - .../sparse-tools/directfio/directfio_test.go | 286 ---- .../rancher/sparse-tools/sparse/client.go | 139 +- .../sparse-tools/sparse/client_test.go | 587 ------- .../rancher/sparse-tools/sparse/failpoint.go | 29 + .../rancher/sparse-tools/sparse/file.go | 118 +- .../rancher/sparse-tools/sparse/layout.go | 12 +- .../sparse-tools/sparse/layout_test.go | 192 --- .../rancher/sparse-tools/sparse/server.go | 115 +- .../rancher/sparse-tools/sparse/sfold_test.go | 149 -- .../rancher/sparse-tools/sparse/ssync_test.go | 327 ---- .../sparse-tools/sparse/testutil_test.go | 133 -- .../satori/go.uuid/benchmarks_test.go | 121 -- vendor/github.com/satori/go.uuid/uuid_test.go | 520 ------ vendor/gopkg.in/check.v1/benchmark_test.go | 91 -- vendor/gopkg.in/check.v1/bootstrap_test.go | 82 - vendor/gopkg.in/check.v1/check_test.go | 207 --- vendor/gopkg.in/check.v1/checkers_test.go | 272 --- vendor/gopkg.in/check.v1/export_test.go | 19 - vendor/gopkg.in/check.v1/fixture_test.go | 484 ------ vendor/gopkg.in/check.v1/foundation_test.go | 335 ---- vendor/gopkg.in/check.v1/helpers_test.go | 519 ------ vendor/gopkg.in/check.v1/printer_test.go | 104 -- vendor/gopkg.in/check.v1/reporter_test.go | 159 -- vendor/gopkg.in/check.v1/run_test.go | 419 ----- 63 files changed, 274 insertions(+), 13575 deletions(-) delete mode 100644 vendor/github.com/Sirupsen/logrus/entry_test.go delete mode 100644 vendor/github.com/Sirupsen/logrus/formatter_bench_test.go delete mode 100644 vendor/github.com/Sirupsen/logrus/hook_test.go delete mode 100644 vendor/github.com/Sirupsen/logrus/json_formatter_test.go delete mode 100644 vendor/github.com/Sirupsen/logrus/logrus_test.go delete mode 100644 vendor/github.com/Sirupsen/logrus/text_formatter_test.go delete mode 100644 vendor/github.com/codegangsta/cli/app_test.go delete mode 100644 vendor/github.com/codegangsta/cli/command_test.go delete mode 100644 vendor/github.com/codegangsta/cli/context_test.go delete mode 100644 vendor/github.com/codegangsta/cli/flag_test.go delete mode 100644 vendor/github.com/codegangsta/cli/help_test.go delete mode 100644 vendor/github.com/codegangsta/cli/helpers_test.go delete mode 100644 vendor/github.com/docker/go-units/duration_test.go delete mode 100644 vendor/github.com/docker/go-units/size_test.go delete mode 100644 vendor/github.com/docker/go-units/ulimit_test.go delete mode 100644 vendor/github.com/gorilla/context/context_test.go delete mode 100644 vendor/github.com/gorilla/handlers/canonical_test.go delete mode 100644 vendor/github.com/gorilla/handlers/compress_test.go delete mode 100644 vendor/github.com/gorilla/handlers/cors_test.go delete mode 100644 vendor/github.com/gorilla/handlers/handlers_test.go delete mode 100644 vendor/github.com/gorilla/handlers/proxy_headers_test.go delete mode 100644 vendor/github.com/gorilla/handlers/recovery_test.go delete mode 100644 vendor/github.com/gorilla/mux/bench_test.go delete mode 100644 vendor/github.com/gorilla/mux/mux_test.go delete mode 100644 vendor/github.com/gorilla/mux/old_test.go delete mode 100644 vendor/github.com/gorilla/websocket/bench_test.go delete mode 100644 vendor/github.com/gorilla/websocket/client_server_test.go delete mode 100644 vendor/github.com/gorilla/websocket/client_test.go delete mode 100644 vendor/github.com/gorilla/websocket/conn_test.go delete mode 100644 vendor/github.com/gorilla/websocket/example_test.go delete mode 100644 vendor/github.com/gorilla/websocket/json_test.go delete mode 100644 vendor/github.com/gorilla/websocket/server_test.go delete mode 100644 vendor/github.com/gorilla/websocket/util_test.go delete mode 100644 vendor/github.com/rancher/convoy/main.go delete mode 100644 vendor/github.com/rancher/convoy/metadata/devmapper_test.go delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/main.go delete mode 100644 vendor/github.com/rancher/go-rancher/client/client_test.go delete mode 100644 vendor/github.com/rancher/go-rancher/main.go delete mode 100644 vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go delete mode 100644 vendor/github.com/rancher/sparse-tools/sparse/client_test.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/failpoint.go delete mode 100644 vendor/github.com/rancher/sparse-tools/sparse/layout_test.go delete mode 100644 vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go delete mode 100644 vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go delete mode 100644 vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go delete mode 100644 vendor/github.com/satori/go.uuid/benchmarks_test.go delete mode 100644 vendor/github.com/satori/go.uuid/uuid_test.go delete mode 100644 vendor/gopkg.in/check.v1/benchmark_test.go delete mode 100644 vendor/gopkg.in/check.v1/bootstrap_test.go delete mode 100644 vendor/gopkg.in/check.v1/check_test.go delete mode 100644 vendor/gopkg.in/check.v1/checkers_test.go delete mode 100644 vendor/gopkg.in/check.v1/export_test.go delete mode 100644 vendor/gopkg.in/check.v1/fixture_test.go delete mode 100644 vendor/gopkg.in/check.v1/foundation_test.go delete mode 100644 vendor/gopkg.in/check.v1/helpers_test.go delete mode 100644 vendor/gopkg.in/check.v1/printer_test.go delete mode 100644 vendor/gopkg.in/check.v1/reporter_test.go delete mode 100644 vendor/gopkg.in/check.v1/run_test.go diff --git a/trash.yml b/trash.yml index af86c766..7a6a2813 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: c651f80b29e69cec8de4f8c8a402266844aa6e5f + version: 0f8c2192c58644b127721633789e8d637d712dfb - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/Sirupsen/logrus/entry_test.go b/vendor/github.com/Sirupsen/logrus/entry_test.go deleted file mode 100644 index 99c3b41d..00000000 --- a/vendor/github.com/Sirupsen/logrus/entry_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package logrus - -import ( - "bytes" - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestEntryWithError(t *testing.T) { - - assert := assert.New(t) - - defer func() { - ErrorKey = "error" - }() - - err := fmt.Errorf("kaboom at layer %d", 4711) - - assert.Equal(err, WithError(err).Data["error"]) - - logger := New() - logger.Out = &bytes.Buffer{} - entry := NewEntry(logger) - - assert.Equal(err, entry.WithError(err).Data["error"]) - - ErrorKey = "err" - - assert.Equal(err, entry.WithError(err).Data["err"]) - -} - -func TestEntryPanicln(t *testing.T) { - errBoom := fmt.Errorf("boom time") - - defer func() { - p := recover() - assert.NotNil(t, p) - - switch pVal := p.(type) { - case *Entry: - assert.Equal(t, "kaboom", pVal.Message) - assert.Equal(t, errBoom, pVal.Data["err"]) - default: - t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) - } - }() - - logger := New() - logger.Out = &bytes.Buffer{} - entry := NewEntry(logger) - entry.WithField("err", errBoom).Panicln("kaboom") -} - -func TestEntryPanicf(t *testing.T) { - errBoom := fmt.Errorf("boom again") - - defer func() { - p := recover() - assert.NotNil(t, p) - - switch pVal := p.(type) { - case *Entry: - assert.Equal(t, "kaboom true", pVal.Message) - assert.Equal(t, errBoom, pVal.Data["err"]) - default: - t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) - } - }() - - logger := New() - logger.Out = &bytes.Buffer{} - entry := NewEntry(logger) - entry.WithField("err", errBoom).Panicf("kaboom %v", true) -} diff --git a/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go b/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go deleted file mode 100644 index c6d290c7..00000000 --- a/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package logrus - -import ( - "fmt" - "testing" - "time" -) - -// smallFields is a small size data set for benchmarking -var smallFields = Fields{ - "foo": "bar", - "baz": "qux", - "one": "two", - "three": "four", -} - -// largeFields is a large size data set for benchmarking -var largeFields = Fields{ - "foo": "bar", - "baz": "qux", - "one": "two", - "three": "four", - "five": "six", - "seven": "eight", - "nine": "ten", - "eleven": "twelve", - "thirteen": "fourteen", - "fifteen": "sixteen", - "seventeen": "eighteen", - "nineteen": "twenty", - "a": "b", - "c": "d", - "e": "f", - "g": "h", - "i": "j", - "k": "l", - "m": "n", - "o": "p", - "q": "r", - "s": "t", - "u": "v", - "w": "x", - "y": "z", - "this": "will", - "make": "thirty", - "entries": "yeah", -} - -var errorFields = Fields{ - "foo": fmt.Errorf("bar"), - "baz": fmt.Errorf("qux"), -} - -func BenchmarkErrorTextFormatter(b *testing.B) { - doBenchmark(b, &TextFormatter{DisableColors: true}, errorFields) -} - -func BenchmarkSmallTextFormatter(b *testing.B) { - doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields) -} - -func BenchmarkLargeTextFormatter(b *testing.B) { - doBenchmark(b, &TextFormatter{DisableColors: true}, largeFields) -} - -func BenchmarkSmallColoredTextFormatter(b *testing.B) { - doBenchmark(b, &TextFormatter{ForceColors: true}, smallFields) -} - -func BenchmarkLargeColoredTextFormatter(b *testing.B) { - doBenchmark(b, &TextFormatter{ForceColors: true}, largeFields) -} - -func BenchmarkSmallJSONFormatter(b *testing.B) { - doBenchmark(b, &JSONFormatter{}, smallFields) -} - -func BenchmarkLargeJSONFormatter(b *testing.B) { - doBenchmark(b, &JSONFormatter{}, largeFields) -} - -func doBenchmark(b *testing.B, formatter Formatter, fields Fields) { - entry := &Entry{ - Time: time.Time{}, - Level: InfoLevel, - Message: "message", - Data: fields, - } - var d []byte - var err error - for i := 0; i < b.N; i++ { - d, err = formatter.Format(entry) - if err != nil { - b.Fatal(err) - } - b.SetBytes(int64(len(d))) - } -} diff --git a/vendor/github.com/Sirupsen/logrus/hook_test.go b/vendor/github.com/Sirupsen/logrus/hook_test.go deleted file mode 100644 index 13f34cb6..00000000 --- a/vendor/github.com/Sirupsen/logrus/hook_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package logrus - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -type TestHook struct { - Fired bool -} - -func (hook *TestHook) Fire(entry *Entry) error { - hook.Fired = true - return nil -} - -func (hook *TestHook) Levels() []Level { - return []Level{ - DebugLevel, - InfoLevel, - WarnLevel, - ErrorLevel, - FatalLevel, - PanicLevel, - } -} - -func TestHookFires(t *testing.T) { - hook := new(TestHook) - - LogAndAssertJSON(t, func(log *Logger) { - log.Hooks.Add(hook) - assert.Equal(t, hook.Fired, false) - - log.Print("test") - }, func(fields Fields) { - assert.Equal(t, hook.Fired, true) - }) -} - -type ModifyHook struct { -} - -func (hook *ModifyHook) Fire(entry *Entry) error { - entry.Data["wow"] = "whale" - return nil -} - -func (hook *ModifyHook) Levels() []Level { - return []Level{ - DebugLevel, - InfoLevel, - WarnLevel, - ErrorLevel, - FatalLevel, - PanicLevel, - } -} - -func TestHookCanModifyEntry(t *testing.T) { - hook := new(ModifyHook) - - LogAndAssertJSON(t, func(log *Logger) { - log.Hooks.Add(hook) - log.WithField("wow", "elephant").Print("test") - }, func(fields Fields) { - assert.Equal(t, fields["wow"], "whale") - }) -} - -func TestCanFireMultipleHooks(t *testing.T) { - hook1 := new(ModifyHook) - hook2 := new(TestHook) - - LogAndAssertJSON(t, func(log *Logger) { - log.Hooks.Add(hook1) - log.Hooks.Add(hook2) - - log.WithField("wow", "elephant").Print("test") - }, func(fields Fields) { - assert.Equal(t, fields["wow"], "whale") - assert.Equal(t, hook2.Fired, true) - }) -} - -type ErrorHook struct { - Fired bool -} - -func (hook *ErrorHook) Fire(entry *Entry) error { - hook.Fired = true - return nil -} - -func (hook *ErrorHook) Levels() []Level { - return []Level{ - ErrorLevel, - } -} - -func TestErrorHookShouldntFireOnInfo(t *testing.T) { - hook := new(ErrorHook) - - LogAndAssertJSON(t, func(log *Logger) { - log.Hooks.Add(hook) - log.Info("test") - }, func(fields Fields) { - assert.Equal(t, hook.Fired, false) - }) -} - -func TestErrorHookShouldFireOnError(t *testing.T) { - hook := new(ErrorHook) - - LogAndAssertJSON(t, func(log *Logger) { - log.Hooks.Add(hook) - log.Error("test") - }, func(fields Fields) { - assert.Equal(t, hook.Fired, true) - }) -} diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter_test.go b/vendor/github.com/Sirupsen/logrus/json_formatter_test.go deleted file mode 100644 index 1d708732..00000000 --- a/vendor/github.com/Sirupsen/logrus/json_formatter_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package logrus - -import ( - "encoding/json" - "errors" - - "testing" -) - -func TestErrorNotLost(t *testing.T) { - formatter := &JSONFormatter{} - - b, err := formatter.Format(WithField("error", errors.New("wild walrus"))) - if err != nil { - t.Fatal("Unable to format entry: ", err) - } - - entry := make(map[string]interface{}) - err = json.Unmarshal(b, &entry) - if err != nil { - t.Fatal("Unable to unmarshal formatted entry: ", err) - } - - if entry["error"] != "wild walrus" { - t.Fatal("Error field not set") - } -} - -func TestErrorNotLostOnFieldNotNamedError(t *testing.T) { - formatter := &JSONFormatter{} - - b, err := formatter.Format(WithField("omg", errors.New("wild walrus"))) - if err != nil { - t.Fatal("Unable to format entry: ", err) - } - - entry := make(map[string]interface{}) - err = json.Unmarshal(b, &entry) - if err != nil { - t.Fatal("Unable to unmarshal formatted entry: ", err) - } - - if entry["omg"] != "wild walrus" { - t.Fatal("Error field not set") - } -} - -func TestFieldClashWithTime(t *testing.T) { - formatter := &JSONFormatter{} - - b, err := formatter.Format(WithField("time", "right now!")) - if err != nil { - t.Fatal("Unable to format entry: ", err) - } - - entry := make(map[string]interface{}) - err = json.Unmarshal(b, &entry) - if err != nil { - t.Fatal("Unable to unmarshal formatted entry: ", err) - } - - if entry["fields.time"] != "right now!" { - t.Fatal("fields.time not set to original time field") - } - - if entry["time"] != "0001-01-01T00:00:00Z" { - t.Fatal("time field not set to current time, was: ", entry["time"]) - } -} - -func TestFieldClashWithMsg(t *testing.T) { - formatter := &JSONFormatter{} - - b, err := formatter.Format(WithField("msg", "something")) - if err != nil { - t.Fatal("Unable to format entry: ", err) - } - - entry := make(map[string]interface{}) - err = json.Unmarshal(b, &entry) - if err != nil { - t.Fatal("Unable to unmarshal formatted entry: ", err) - } - - if entry["fields.msg"] != "something" { - t.Fatal("fields.msg not set to original msg field") - } -} - -func TestFieldClashWithLevel(t *testing.T) { - formatter := &JSONFormatter{} - - b, err := formatter.Format(WithField("level", "something")) - if err != nil { - t.Fatal("Unable to format entry: ", err) - } - - entry := make(map[string]interface{}) - err = json.Unmarshal(b, &entry) - if err != nil { - t.Fatal("Unable to unmarshal formatted entry: ", err) - } - - if entry["fields.level"] != "something" { - t.Fatal("fields.level not set to original level field") - } -} - -func TestJSONEntryEndsWithNewline(t *testing.T) { - formatter := &JSONFormatter{} - - b, err := formatter.Format(WithField("level", "something")) - if err != nil { - t.Fatal("Unable to format entry: ", err) - } - - if b[len(b)-1] != '\n' { - t.Fatal("Expected JSON log entry to end with a newline") - } -} diff --git a/vendor/github.com/Sirupsen/logrus/logrus_test.go b/vendor/github.com/Sirupsen/logrus/logrus_test.go deleted file mode 100644 index efaacea2..00000000 --- a/vendor/github.com/Sirupsen/logrus/logrus_test.go +++ /dev/null @@ -1,301 +0,0 @@ -package logrus - -import ( - "bytes" - "encoding/json" - "strconv" - "strings" - "sync" - "testing" - - "github.com/stretchr/testify/assert" -) - -func LogAndAssertJSON(t *testing.T, log func(*Logger), assertions func(fields Fields)) { - var buffer bytes.Buffer - var fields Fields - - logger := New() - logger.Out = &buffer - logger.Formatter = new(JSONFormatter) - - log(logger) - - err := json.Unmarshal(buffer.Bytes(), &fields) - assert.Nil(t, err) - - assertions(fields) -} - -func LogAndAssertText(t *testing.T, log func(*Logger), assertions func(fields map[string]string)) { - var buffer bytes.Buffer - - logger := New() - logger.Out = &buffer - logger.Formatter = &TextFormatter{ - DisableColors: true, - } - - log(logger) - - fields := make(map[string]string) - for _, kv := range strings.Split(buffer.String(), " ") { - if !strings.Contains(kv, "=") { - continue - } - kvArr := strings.Split(kv, "=") - key := strings.TrimSpace(kvArr[0]) - val := kvArr[1] - if kvArr[1][0] == '"' { - var err error - val, err = strconv.Unquote(val) - assert.NoError(t, err) - } - fields[key] = val - } - assertions(fields) -} - -func TestPrint(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Print("test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test") - assert.Equal(t, fields["level"], "info") - }) -} - -func TestInfo(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Info("test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test") - assert.Equal(t, fields["level"], "info") - }) -} - -func TestWarn(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Warn("test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test") - assert.Equal(t, fields["level"], "warning") - }) -} - -func TestInfolnShouldAddSpacesBetweenStrings(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Infoln("test", "test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test test") - }) -} - -func TestInfolnShouldAddSpacesBetweenStringAndNonstring(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Infoln("test", 10) - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test 10") - }) -} - -func TestInfolnShouldAddSpacesBetweenTwoNonStrings(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Infoln(10, 10) - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "10 10") - }) -} - -func TestInfoShouldAddSpacesBetweenTwoNonStrings(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Infoln(10, 10) - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "10 10") - }) -} - -func TestInfoShouldNotAddSpacesBetweenStringAndNonstring(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Info("test", 10) - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test10") - }) -} - -func TestInfoShouldNotAddSpacesBetweenStrings(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.Info("test", "test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "testtest") - }) -} - -func TestWithFieldsShouldAllowAssignments(t *testing.T) { - var buffer bytes.Buffer - var fields Fields - - logger := New() - logger.Out = &buffer - logger.Formatter = new(JSONFormatter) - - localLog := logger.WithFields(Fields{ - "key1": "value1", - }) - - localLog.WithField("key2", "value2").Info("test") - err := json.Unmarshal(buffer.Bytes(), &fields) - assert.Nil(t, err) - - assert.Equal(t, "value2", fields["key2"]) - assert.Equal(t, "value1", fields["key1"]) - - buffer = bytes.Buffer{} - fields = Fields{} - localLog.Info("test") - err = json.Unmarshal(buffer.Bytes(), &fields) - assert.Nil(t, err) - - _, ok := fields["key2"] - assert.Equal(t, false, ok) - assert.Equal(t, "value1", fields["key1"]) -} - -func TestUserSuppliedFieldDoesNotOverwriteDefaults(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.WithField("msg", "hello").Info("test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test") - }) -} - -func TestUserSuppliedMsgFieldHasPrefix(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.WithField("msg", "hello").Info("test") - }, func(fields Fields) { - assert.Equal(t, fields["msg"], "test") - assert.Equal(t, fields["fields.msg"], "hello") - }) -} - -func TestUserSuppliedTimeFieldHasPrefix(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.WithField("time", "hello").Info("test") - }, func(fields Fields) { - assert.Equal(t, fields["fields.time"], "hello") - }) -} - -func TestUserSuppliedLevelFieldHasPrefix(t *testing.T) { - LogAndAssertJSON(t, func(log *Logger) { - log.WithField("level", 1).Info("test") - }, func(fields Fields) { - assert.Equal(t, fields["level"], "info") - assert.Equal(t, fields["fields.level"], 1.0) // JSON has floats only - }) -} - -func TestDefaultFieldsAreNotPrefixed(t *testing.T) { - LogAndAssertText(t, func(log *Logger) { - ll := log.WithField("herp", "derp") - ll.Info("hello") - ll.Info("bye") - }, func(fields map[string]string) { - for _, fieldName := range []string{"fields.level", "fields.time", "fields.msg"} { - if _, ok := fields[fieldName]; ok { - t.Fatalf("should not have prefixed %q: %v", fieldName, fields) - } - } - }) -} - -func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) { - - var buffer bytes.Buffer - var fields Fields - - logger := New() - logger.Out = &buffer - logger.Formatter = new(JSONFormatter) - - llog := logger.WithField("context", "eating raw fish") - - llog.Info("looks delicious") - - err := json.Unmarshal(buffer.Bytes(), &fields) - assert.NoError(t, err, "should have decoded first message") - assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields") - assert.Equal(t, fields["msg"], "looks delicious") - assert.Equal(t, fields["context"], "eating raw fish") - - buffer.Reset() - - llog.Warn("omg it is!") - - err = json.Unmarshal(buffer.Bytes(), &fields) - assert.NoError(t, err, "should have decoded second message") - assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields") - assert.Equal(t, fields["msg"], "omg it is!") - assert.Equal(t, fields["context"], "eating raw fish") - assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry") - -} - -func TestConvertLevelToString(t *testing.T) { - assert.Equal(t, "debug", DebugLevel.String()) - assert.Equal(t, "info", InfoLevel.String()) - assert.Equal(t, "warning", WarnLevel.String()) - assert.Equal(t, "error", ErrorLevel.String()) - assert.Equal(t, "fatal", FatalLevel.String()) - assert.Equal(t, "panic", PanicLevel.String()) -} - -func TestParseLevel(t *testing.T) { - l, err := ParseLevel("panic") - assert.Nil(t, err) - assert.Equal(t, PanicLevel, l) - - l, err = ParseLevel("fatal") - assert.Nil(t, err) - assert.Equal(t, FatalLevel, l) - - l, err = ParseLevel("error") - assert.Nil(t, err) - assert.Equal(t, ErrorLevel, l) - - l, err = ParseLevel("warn") - assert.Nil(t, err) - assert.Equal(t, WarnLevel, l) - - l, err = ParseLevel("warning") - assert.Nil(t, err) - assert.Equal(t, WarnLevel, l) - - l, err = ParseLevel("info") - assert.Nil(t, err) - assert.Equal(t, InfoLevel, l) - - l, err = ParseLevel("debug") - assert.Nil(t, err) - assert.Equal(t, DebugLevel, l) - - l, err = ParseLevel("invalid") - assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error()) -} - -func TestGetSetLevelRace(t *testing.T) { - wg := sync.WaitGroup{} - for i := 0; i < 100; i++ { - wg.Add(1) - go func(i int) { - defer wg.Done() - if i%2 == 0 { - SetLevel(InfoLevel) - } else { - GetLevel() - } - }(i) - - } - wg.Wait() -} diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter_test.go b/vendor/github.com/Sirupsen/logrus/text_formatter_test.go deleted file mode 100644 index e25a44f6..00000000 --- a/vendor/github.com/Sirupsen/logrus/text_formatter_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package logrus - -import ( - "bytes" - "errors" - "testing" - "time" -) - -func TestQuoting(t *testing.T) { - tf := &TextFormatter{DisableColors: true} - - checkQuoting := func(q bool, value interface{}) { - b, _ := tf.Format(WithField("test", value)) - idx := bytes.Index(b, ([]byte)("test=")) - cont := bytes.Contains(b[idx+5:], []byte{'"'}) - if cont != q { - if q { - t.Errorf("quoting expected for: %#v", value) - } else { - t.Errorf("quoting not expected for: %#v", value) - } - } - } - - checkQuoting(false, "abcd") - checkQuoting(false, "v1.0") - checkQuoting(false, "1234567890") - checkQuoting(true, "/foobar") - checkQuoting(true, "x y") - checkQuoting(true, "x,y") - checkQuoting(false, errors.New("invalid")) - checkQuoting(true, errors.New("invalid argument")) -} - -func TestTimestampFormat(t *testing.T) { - checkTimeStr := func(format string) { - customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format} - customStr, _ := customFormatter.Format(WithField("test", "test")) - timeStart := bytes.Index(customStr, ([]byte)("time=")) - timeEnd := bytes.Index(customStr, ([]byte)("level=")) - timeStr := customStr[timeStart+5 : timeEnd-1] - if timeStr[0] == '"' && timeStr[len(timeStr)-1] == '"' { - timeStr = timeStr[1 : len(timeStr)-1] - } - if format == "" { - format = time.RFC3339 - } - _, e := time.Parse(format, (string)(timeStr)) - if e != nil { - t.Errorf("time string \"%s\" did not match provided time format \"%s\": %s", timeStr, format, e) - } - } - - checkTimeStr("2006-01-02T15:04:05.000000000Z07:00") - checkTimeStr("Mon Jan _2 15:04:05 2006") - checkTimeStr("") -} - -// TODO add tests for sorting etc., this requires a parser for the text -// formatter output. diff --git a/vendor/github.com/codegangsta/cli/app_test.go b/vendor/github.com/codegangsta/cli/app_test.go deleted file mode 100644 index ebf26c70..00000000 --- a/vendor/github.com/codegangsta/cli/app_test.go +++ /dev/null @@ -1,1097 +0,0 @@ -package cli - -import ( - "bytes" - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "os" - "reflect" - "strings" - "testing" -) - -func ExampleApp_Run() { - // set args for examples sake - os.Args = []string{"greet", "--name", "Jeremy"} - - app := NewApp() - app.Name = "greet" - app.Flags = []Flag{ - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, - } - app.Action = func(c *Context) { - fmt.Printf("Hello %v\n", c.String("name")) - } - app.UsageText = "app [first_arg] [second_arg]" - app.Author = "Harrison" - app.Email = "harrison@lolwut.com" - app.Authors = []Author{Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}} - app.Run(os.Args) - // Output: - // Hello Jeremy -} - -func ExampleApp_Run_subcommand() { - // set args for examples sake - os.Args = []string{"say", "hi", "english", "--name", "Jeremy"} - app := NewApp() - app.Name = "say" - app.Commands = []Command{ - { - Name: "hello", - Aliases: []string{"hi"}, - Usage: "use it to see a description", - Description: "This is how we describe hello the function", - Subcommands: []Command{ - { - Name: "english", - Aliases: []string{"en"}, - Usage: "sends a greeting in english", - Description: "greets someone in english", - Flags: []Flag{ - StringFlag{ - Name: "name", - Value: "Bob", - Usage: "Name of the person to greet", - }, - }, - Action: func(c *Context) { - fmt.Println("Hello,", c.String("name")) - }, - }, - }, - }, - } - - app.Run(os.Args) - // Output: - // Hello, Jeremy -} - -func ExampleApp_Run_help() { - // set args for examples sake - os.Args = []string{"greet", "h", "describeit"} - - app := NewApp() - app.Name = "greet" - app.Flags = []Flag{ - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"}, - } - app.Commands = []Command{ - { - Name: "describeit", - Aliases: []string{"d"}, - Usage: "use it to see a description", - Description: "This is how we describe describeit the function", - Action: func(c *Context) { - fmt.Printf("i like to describe things") - }, - }, - } - app.Run(os.Args) - // Output: - // NAME: - // greet describeit - use it to see a description - // - // USAGE: - // greet describeit [arguments...] - // - // DESCRIPTION: - // This is how we describe describeit the function -} - -func ExampleApp_Run_bashComplete() { - // set args for examples sake - os.Args = []string{"greet", "--generate-bash-completion"} - - app := NewApp() - app.Name = "greet" - app.EnableBashCompletion = true - app.Commands = []Command{ - { - Name: "describeit", - Aliases: []string{"d"}, - Usage: "use it to see a description", - Description: "This is how we describe describeit the function", - Action: func(c *Context) { - fmt.Printf("i like to describe things") - }, - }, { - Name: "next", - Usage: "next example", - Description: "more stuff to see when generating bash completion", - Action: func(c *Context) { - fmt.Printf("the next example") - }, - }, - } - - app.Run(os.Args) - // Output: - // describeit - // d - // next - // help - // h -} - -func TestApp_Run(t *testing.T) { - s := "" - - app := NewApp() - app.Action = func(c *Context) { - s = s + c.Args().First() - } - - err := app.Run([]string{"command", "foo"}) - expect(t, err, nil) - err = app.Run([]string{"command", "bar"}) - expect(t, err, nil) - expect(t, s, "foobar") -} - -var commandAppTests = []struct { - name string - expected bool -}{ - {"foobar", true}, - {"batbaz", true}, - {"b", true}, - {"f", true}, - {"bat", false}, - {"nothing", false}, -} - -func TestApp_Command(t *testing.T) { - app := NewApp() - fooCommand := Command{Name: "foobar", Aliases: []string{"f"}} - batCommand := Command{Name: "batbaz", Aliases: []string{"b"}} - app.Commands = []Command{ - fooCommand, - batCommand, - } - - for _, test := range commandAppTests { - expect(t, app.Command(test.name) != nil, test.expected) - } -} - -func TestApp_CommandWithArgBeforeFlags(t *testing.T) { - var parsedOption, firstArg string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - StringFlag{Name: "option", Value: "", Usage: "some option"}, - }, - Action: func(c *Context) { - parsedOption = c.String("option") - firstArg = c.Args().First() - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"}) - - expect(t, parsedOption, "my-option") - expect(t, firstArg, "my-arg") -} - -func TestApp_RunAsSubcommandParseFlags(t *testing.T) { - var context *Context - - a := NewApp() - a.Commands = []Command{ - { - Name: "foo", - Action: func(c *Context) { - context = c - }, - Flags: []Flag{ - StringFlag{ - Name: "lang", - Value: "english", - Usage: "language for the greeting", - }, - }, - Before: func(_ *Context) error { return nil }, - }, - } - a.Run([]string{"", "foo", "--lang", "spanish", "abcd"}) - - expect(t, context.Args().Get(0), "abcd") - expect(t, context.String("lang"), "spanish") -} - -func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) { - var parsedOption string - var args []string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - StringFlag{Name: "option", Value: "", Usage: "some option"}, - }, - Action: func(c *Context) { - parsedOption = c.String("option") - args = c.Args() - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"}) - - expect(t, parsedOption, "my-option") - expect(t, args[0], "my-arg") - expect(t, args[1], "--") - expect(t, args[2], "--notARealFlag") -} - -func TestApp_CommandWithDash(t *testing.T) { - var args []string - - app := NewApp() - command := Command{ - Name: "cmd", - Action: func(c *Context) { - args = c.Args() - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "-"}) - - expect(t, args[0], "my-arg") - expect(t, args[1], "-") -} - -func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) { - var args []string - - app := NewApp() - command := Command{ - Name: "cmd", - Action: func(c *Context) { - args = c.Args() - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"}) - - expect(t, args[0], "my-arg") - expect(t, args[1], "--") - expect(t, args[2], "notAFlagAtAll") -} - -func TestApp_Float64Flag(t *testing.T) { - var meters float64 - - app := NewApp() - app.Flags = []Flag{ - Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"}, - } - app.Action = func(c *Context) { - meters = c.Float64("height") - } - - app.Run([]string{"", "--height", "1.93"}) - expect(t, meters, 1.93) -} - -func TestApp_ParseSliceFlags(t *testing.T) { - var parsedOption, firstArg string - var parsedIntSlice []int - var parsedStringSlice []string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - IntSliceFlag{Name: "p", Value: &IntSlice{}, Usage: "set one or more ip addr"}, - StringSliceFlag{Name: "ip", Value: &StringSlice{}, Usage: "set one or more ports to open"}, - }, - Action: func(c *Context) { - parsedIntSlice = c.IntSlice("p") - parsedStringSlice = c.StringSlice("ip") - parsedOption = c.String("option") - firstArg = c.Args().First() - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"}) - - IntsEquals := func(a, b []int) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true - } - - StrsEquals := func(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true - } - var expectedIntSlice = []int{22, 80} - var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"} - - if !IntsEquals(parsedIntSlice, expectedIntSlice) { - t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice) - } - - if !StrsEquals(parsedStringSlice, expectedStringSlice) { - t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice) - } -} - -func TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) { - var parsedIntSlice []int - var parsedStringSlice []string - - app := NewApp() - command := Command{ - Name: "cmd", - Flags: []Flag{ - IntSliceFlag{Name: "a", Usage: "set numbers"}, - StringSliceFlag{Name: "str", Usage: "set strings"}, - }, - Action: func(c *Context) { - parsedIntSlice = c.IntSlice("a") - parsedStringSlice = c.StringSlice("str") - }, - } - app.Commands = []Command{command} - - app.Run([]string{"", "cmd", "my-arg", "-a", "2", "-str", "A"}) - - var expectedIntSlice = []int{2} - var expectedStringSlice = []string{"A"} - - if parsedIntSlice[0] != expectedIntSlice[0] { - t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0]) - } - - if parsedStringSlice[0] != expectedStringSlice[0] { - t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0]) - } -} - -func TestApp_DefaultStdout(t *testing.T) { - app := NewApp() - - if app.Writer != os.Stdout { - t.Error("Default output writer not set.") - } -} - -type mockWriter struct { - written []byte -} - -func (fw *mockWriter) Write(p []byte) (n int, err error) { - if fw.written == nil { - fw.written = p - } else { - fw.written = append(fw.written, p...) - } - - return len(p), nil -} - -func (fw *mockWriter) GetWritten() (b []byte) { - return fw.written -} - -func TestApp_SetStdout(t *testing.T) { - w := &mockWriter{} - - app := NewApp() - app.Name = "test" - app.Writer = w - - err := app.Run([]string{"help"}) - - if err != nil { - t.Fatalf("Run error: %s", err) - } - - if len(w.written) == 0 { - t.Error("App did not write output to desired writer.") - } -} - -func TestApp_BeforeFunc(t *testing.T) { - beforeRun, subcommandRun := false, false - beforeError := fmt.Errorf("fail") - var err error - - app := NewApp() - - app.Before = func(c *Context) error { - beforeRun = true - s := c.String("opt") - if s == "fail" { - return beforeError - } - - return nil - } - - app.Commands = []Command{ - Command{ - Name: "sub", - Action: func(c *Context) { - subcommandRun = true - }, - }, - } - - app.Flags = []Flag{ - StringFlag{Name: "opt"}, - } - - // run with the Before() func succeeding - err = app.Run([]string{"command", "--opt", "succeed", "sub"}) - - if err != nil { - t.Fatalf("Run error: %s", err) - } - - if beforeRun == false { - t.Errorf("Before() not executed when expected") - } - - if subcommandRun == false { - t.Errorf("Subcommand not executed when expected") - } - - // reset - beforeRun, subcommandRun = false, false - - // run with the Before() func failing - err = app.Run([]string{"command", "--opt", "fail", "sub"}) - - // should be the same error produced by the Before func - if err != beforeError { - t.Errorf("Run error expected, but not received") - } - - if beforeRun == false { - t.Errorf("Before() not executed when expected") - } - - if subcommandRun == true { - t.Errorf("Subcommand executed when NOT expected") - } - -} - -func TestApp_AfterFunc(t *testing.T) { - afterRun, subcommandRun := false, false - afterError := fmt.Errorf("fail") - var err error - - app := NewApp() - - app.After = func(c *Context) error { - afterRun = true - s := c.String("opt") - if s == "fail" { - return afterError - } - - return nil - } - - app.Commands = []Command{ - Command{ - Name: "sub", - Action: func(c *Context) { - subcommandRun = true - }, - }, - } - - app.Flags = []Flag{ - StringFlag{Name: "opt"}, - } - - // run with the After() func succeeding - err = app.Run([]string{"command", "--opt", "succeed", "sub"}) - - if err != nil { - t.Fatalf("Run error: %s", err) - } - - if afterRun == false { - t.Errorf("After() not executed when expected") - } - - if subcommandRun == false { - t.Errorf("Subcommand not executed when expected") - } - - // reset - afterRun, subcommandRun = false, false - - // run with the Before() func failing - err = app.Run([]string{"command", "--opt", "fail", "sub"}) - - // should be the same error produced by the Before func - if err != afterError { - t.Errorf("Run error expected, but not received") - } - - if afterRun == false { - t.Errorf("After() not executed when expected") - } - - if subcommandRun == false { - t.Errorf("Subcommand not executed when expected") - } -} - -func TestAppNoHelpFlag(t *testing.T) { - oldFlag := HelpFlag - defer func() { - HelpFlag = oldFlag - }() - - HelpFlag = BoolFlag{} - - app := NewApp() - app.Writer = ioutil.Discard - err := app.Run([]string{"test", "-h"}) - - if err != flag.ErrHelp { - t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err) - } -} - -func TestAppHelpPrinter(t *testing.T) { - oldPrinter := HelpPrinter - defer func() { - HelpPrinter = oldPrinter - }() - - var wasCalled = false - HelpPrinter = func(w io.Writer, template string, data interface{}) { - wasCalled = true - } - - app := NewApp() - app.Run([]string{"-h"}) - - if wasCalled == false { - t.Errorf("Help printer expected to be called, but was not") - } -} - -func TestAppVersionPrinter(t *testing.T) { - oldPrinter := VersionPrinter - defer func() { - VersionPrinter = oldPrinter - }() - - var wasCalled = false - VersionPrinter = func(c *Context) { - wasCalled = true - } - - app := NewApp() - ctx := NewContext(app, nil, nil) - ShowVersion(ctx) - - if wasCalled == false { - t.Errorf("Version printer expected to be called, but was not") - } -} - -func TestAppCommandNotFound(t *testing.T) { - beforeRun, subcommandRun := false, false - app := NewApp() - - app.CommandNotFound = func(c *Context, command string) { - beforeRun = true - } - - app.Commands = []Command{ - Command{ - Name: "bar", - Action: func(c *Context) { - subcommandRun = true - }, - }, - } - - app.Run([]string{"command", "foo"}) - - expect(t, beforeRun, true) - expect(t, subcommandRun, false) -} - -func TestGlobalFlag(t *testing.T) { - var globalFlag string - var globalFlagSet bool - app := NewApp() - app.Flags = []Flag{ - StringFlag{Name: "global, g", Usage: "global"}, - } - app.Action = func(c *Context) { - globalFlag = c.GlobalString("global") - globalFlagSet = c.GlobalIsSet("global") - } - app.Run([]string{"command", "-g", "foo"}) - expect(t, globalFlag, "foo") - expect(t, globalFlagSet, true) - -} - -func TestGlobalFlagsInSubcommands(t *testing.T) { - subcommandRun := false - parentFlag := false - app := NewApp() - - app.Flags = []Flag{ - BoolFlag{Name: "debug, d", Usage: "Enable debugging"}, - } - - app.Commands = []Command{ - Command{ - Name: "foo", - Flags: []Flag{ - BoolFlag{Name: "parent, p", Usage: "Parent flag"}, - }, - Subcommands: []Command{ - { - Name: "bar", - Action: func(c *Context) { - if c.GlobalBool("debug") { - subcommandRun = true - } - if c.GlobalBool("parent") { - parentFlag = true - } - }, - }, - }, - }, - } - - app.Run([]string{"command", "-d", "foo", "-p", "bar"}) - - expect(t, subcommandRun, true) - expect(t, parentFlag, true) -} - -func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) { - var subcommandHelpTopics = [][]string{ - {"command", "foo", "--help"}, - {"command", "foo", "-h"}, - {"command", "foo", "help"}, - } - - for _, flagSet := range subcommandHelpTopics { - t.Logf("==> checking with flags %v", flagSet) - - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - - subCmdBar := Command{ - Name: "bar", - Usage: "does bar things", - } - subCmdBaz := Command{ - Name: "baz", - Usage: "does baz things", - } - cmd := Command{ - Name: "foo", - Description: "descriptive wall of text about how it does foo things", - Subcommands: []Command{subCmdBar, subCmdBaz}, - } - - app.Commands = []Command{cmd} - err := app.Run(flagSet) - - if err != nil { - t.Error(err) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if strings.Contains(output, "No help topic for") { - t.Errorf("expect a help topic, got none: \n%q", output) - } - - for _, shouldContain := range []string{ - cmd.Name, cmd.Description, - subCmdBar.Name, subCmdBar.Usage, - subCmdBaz.Name, subCmdBaz.Usage, - } { - if !strings.Contains(output, shouldContain) { - t.Errorf("want help to contain %q, did not: \n%q", shouldContain, output) - } - } - } -} - -func TestApp_Run_SubcommandFullPath(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "command" - subCmd := Command{ - Name: "bar", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "bar", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "command foo bar - does bar things") { - t.Errorf("expected full path to subcommand: %s", output) - } - if !strings.Contains(output, "command foo bar [arguments...]") { - t.Errorf("expected full path to subcommand: %s", output) - } -} - -func TestApp_Run_SubcommandHelpName(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "command" - subCmd := Command{ - Name: "bar", - HelpName: "custom", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "bar", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "custom - does bar things") { - t.Errorf("expected HelpName for subcommand: %s", output) - } - if !strings.Contains(output, "custom [arguments...]") { - t.Errorf("expected HelpName to subcommand: %s", output) - } -} - -func TestApp_Run_CommandHelpName(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "command" - subCmd := Command{ - Name: "bar", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - HelpName: "custom", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "bar", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "command foo bar - does bar things") { - t.Errorf("expected full path to subcommand: %s", output) - } - if !strings.Contains(output, "command foo bar [arguments...]") { - t.Errorf("expected full path to subcommand: %s", output) - } -} - -func TestApp_Run_CommandSubcommandHelpName(t *testing.T) { - app := NewApp() - buf := new(bytes.Buffer) - app.Writer = buf - app.Name = "base" - subCmd := Command{ - Name: "bar", - HelpName: "custom", - Usage: "does bar things", - } - cmd := Command{ - Name: "foo", - Description: "foo commands", - Subcommands: []Command{subCmd}, - } - app.Commands = []Command{cmd} - - err := app.Run([]string{"command", "foo", "--help"}) - if err != nil { - t.Error(err) - } - - output := buf.String() - if !strings.Contains(output, "base foo - foo commands") { - t.Errorf("expected full path to subcommand: %s", output) - } - if !strings.Contains(output, "base foo command [command options] [arguments...]") { - t.Errorf("expected full path to subcommand: %s", output) - } -} - -func TestApp_Run_Help(t *testing.T) { - var helpArguments = [][]string{{"boom", "--help"}, {"boom", "-h"}, {"boom", "help"}} - - for _, args := range helpArguments { - buf := new(bytes.Buffer) - - t.Logf("==> checking with arguments %v", args) - - app := NewApp() - app.Name = "boom" - app.Usage = "make an explosive entrance" - app.Writer = buf - app.Action = func(c *Context) { - buf.WriteString("boom I say!") - } - - err := app.Run(args) - if err != nil { - t.Error(err) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if !strings.Contains(output, "boom - make an explosive entrance") { - t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output) - } - } -} - -func TestApp_Run_Version(t *testing.T) { - var versionArguments = [][]string{{"boom", "--version"}, {"boom", "-v"}} - - for _, args := range versionArguments { - buf := new(bytes.Buffer) - - t.Logf("==> checking with arguments %v", args) - - app := NewApp() - app.Name = "boom" - app.Usage = "make an explosive entrance" - app.Version = "0.1.0" - app.Writer = buf - app.Action = func(c *Context) { - buf.WriteString("boom I say!") - } - - err := app.Run(args) - if err != nil { - t.Error(err) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if !strings.Contains(output, "0.1.0") { - t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output) - } - } -} - -func TestApp_Run_Categories(t *testing.T) { - app := NewApp() - app.Name = "categories" - app.Commands = []Command{ - Command{ - Name: "command1", - Category: "1", - }, - Command{ - Name: "command2", - Category: "1", - }, - Command{ - Name: "command3", - Category: "2", - }, - } - buf := new(bytes.Buffer) - app.Writer = buf - - app.Run([]string{"categories"}) - - expect := CommandCategories{ - &CommandCategory{ - Name: "1", - Commands: []Command{ - app.Commands[0], - app.Commands[1], - }, - }, - &CommandCategory{ - Name: "2", - Commands: []Command{ - app.Commands[2], - }, - }, - } - if !reflect.DeepEqual(app.Categories(), expect) { - t.Fatalf("expected categories %#v, to equal %#v", app.Categories(), expect) - } - - output := buf.String() - t.Logf("output: %q\n", buf.Bytes()) - - if !strings.Contains(output, "1:\n command1") { - t.Errorf("want buffer to include category %q, did not: \n%q", "1:\n command1", output) - } -} - -func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) { - app := NewApp() - app.Action = func(c *Context) {} - app.Before = func(c *Context) error { return fmt.Errorf("before error") } - app.After = func(c *Context) error { return fmt.Errorf("after error") } - - err := app.Run([]string{"foo"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.Contains(err.Error(), "before error") { - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) - } - if !strings.Contains(err.Error(), "after error") { - t.Errorf("expected text of error from After method, but got none in \"%v\"", err) - } -} - -func TestApp_Run_SubcommandDoesNotOverwriteErrorFromBefore(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - Command{ - Subcommands: []Command{ - Command{ - Name: "sub", - }, - }, - Name: "bar", - Before: func(c *Context) error { return fmt.Errorf("before error") }, - After: func(c *Context) error { return fmt.Errorf("after error") }, - }, - } - - err := app.Run([]string{"foo", "bar"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.Contains(err.Error(), "before error") { - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) - } - if !strings.Contains(err.Error(), "after error") { - t.Errorf("expected text of error from After method, but got none in \"%v\"", err) - } -} - -func TestApp_OnUsageError_WithWrongFlagValue(t *testing.T) { - app := NewApp() - app.Flags = []Flag{ - IntFlag{Name: "flag"}, - } - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { - if isSubcommand { - t.Errorf("Expect no subcommand") - } - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - } - app.Commands = []Command{ - Command{ - Name: "bar", - }, - } - - err := app.Run([]string{"foo", "--flag=wrong"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} - -func TestApp_OnUsageError_WithWrongFlagValue_ForSubcommand(t *testing.T) { - app := NewApp() - app.Flags = []Flag{ - IntFlag{Name: "flag"}, - } - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error { - if isSubcommand { - t.Errorf("Expect subcommand") - } - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - } - app.Commands = []Command{ - Command{ - Name: "bar", - }, - } - - err := app.Run([]string{"foo", "--flag=wrong", "bar"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} diff --git a/vendor/github.com/codegangsta/cli/command_test.go b/vendor/github.com/codegangsta/cli/command_test.go deleted file mode 100644 index 827da1df..00000000 --- a/vendor/github.com/codegangsta/cli/command_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package cli - -import ( - "errors" - "flag" - "fmt" - "io/ioutil" - "strings" - "testing" -) - -func TestCommandFlagParsing(t *testing.T) { - cases := []struct { - testArgs []string - skipFlagParsing bool - expectedErr error - }{ - {[]string{"blah", "blah", "-break"}, false, errors.New("flag provided but not defined: -break")}, // Test normal "not ignoring flags" flow - {[]string{"blah", "blah"}, true, nil}, // Test SkipFlagParsing without any args that look like flags - {[]string{"blah", "-break"}, true, nil}, // Test SkipFlagParsing with random flag arg - {[]string{"blah", "-help"}, true, nil}, // Test SkipFlagParsing with "special" help flag arg - } - - for _, c := range cases { - app := NewApp() - app.Writer = ioutil.Discard - set := flag.NewFlagSet("test", 0) - set.Parse(c.testArgs) - - context := NewContext(app, set, nil) - - command := Command{ - Name: "test-cmd", - Aliases: []string{"tc"}, - Usage: "this is for testing", - Description: "testing", - Action: func(_ *Context) {}, - } - - command.SkipFlagParsing = c.skipFlagParsing - - err := command.Run(context) - - expect(t, err, c.expectedErr) - expect(t, []string(context.Args()), c.testArgs) - } -} - -func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - Command{ - Name: "bar", - Before: func(c *Context) error { return fmt.Errorf("before error") }, - After: func(c *Context) error { return fmt.Errorf("after error") }, - }, - } - - err := app.Run([]string{"foo", "bar"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.Contains(err.Error(), "before error") { - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err) - } - if !strings.Contains(err.Error(), "after error") { - t.Errorf("expected text of error from After method, but got none in \"%v\"", err) - } -} - -func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) { - app := NewApp() - app.Commands = []Command{ - Command{ - Name: "bar", - Flags: []Flag{ - IntFlag{Name: "flag"}, - }, - OnUsageError: func(c *Context, err error) error { - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") { - t.Errorf("Expect an invalid value error, but got \"%v\"", err) - } - return errors.New("intercepted: " + err.Error()) - }, - }, - } - - err := app.Run([]string{"foo", "bar", "--flag=wrong"}) - if err == nil { - t.Fatalf("expected to receive error from Run, got none") - } - - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") { - t.Errorf("Expect an intercepted error, but got \"%v\"", err) - } -} diff --git a/vendor/github.com/codegangsta/cli/context_test.go b/vendor/github.com/codegangsta/cli/context_test.go deleted file mode 100644 index b8ab37d4..00000000 --- a/vendor/github.com/codegangsta/cli/context_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package cli - -import ( - "flag" - "testing" - "time" -) - -func TestNewContext(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int("myflag", 12, "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Int("myflag", 42, "doc") - globalCtx := NewContext(nil, globalSet, nil) - command := Command{Name: "mycommand"} - c := NewContext(nil, set, globalCtx) - c.Command = command - expect(t, c.Int("myflag"), 12) - expect(t, c.GlobalInt("myflag"), 42) - expect(t, c.Command.Name, "mycommand") -} - -func TestContext_Int(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Int("myflag", 12, "doc") - c := NewContext(nil, set, nil) - expect(t, c.Int("myflag"), 12) -} - -func TestContext_Duration(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Duration("myflag", time.Duration(12*time.Second), "doc") - c := NewContext(nil, set, nil) - expect(t, c.Duration("myflag"), time.Duration(12*time.Second)) -} - -func TestContext_String(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.String("myflag", "hello world", "doc") - c := NewContext(nil, set, nil) - expect(t, c.String("myflag"), "hello world") -} - -func TestContext_Bool(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - c := NewContext(nil, set, nil) - expect(t, c.Bool("myflag"), false) -} - -func TestContext_BoolT(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", true, "doc") - c := NewContext(nil, set, nil) - expect(t, c.BoolT("myflag"), true) -} - -func TestContext_Args(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - c := NewContext(nil, set, nil) - set.Parse([]string{"--myflag", "bat", "baz"}) - expect(t, len(c.Args()), 2) - expect(t, c.Bool("myflag"), true) -} - -func TestContext_NArg(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - c := NewContext(nil, set, nil) - set.Parse([]string{"--myflag", "bat", "baz"}) - expect(t, c.NArg(), 2) -} - -func TestContext_IsSet(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - set.String("otherflag", "hello world", "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Bool("myflagGlobal", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - c := NewContext(nil, set, globalCtx) - set.Parse([]string{"--myflag", "bat", "baz"}) - globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"}) - expect(t, c.IsSet("myflag"), true) - expect(t, c.IsSet("otherflag"), false) - expect(t, c.IsSet("bogusflag"), false) - expect(t, c.IsSet("myflagGlobal"), false) -} - -func TestContext_GlobalIsSet(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - set.String("otherflag", "hello world", "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Bool("myflagGlobal", true, "doc") - globalSet.Bool("myflagGlobalUnset", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - c := NewContext(nil, set, globalCtx) - set.Parse([]string{"--myflag", "bat", "baz"}) - globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"}) - expect(t, c.GlobalIsSet("myflag"), false) - expect(t, c.GlobalIsSet("otherflag"), false) - expect(t, c.GlobalIsSet("bogusflag"), false) - expect(t, c.GlobalIsSet("myflagGlobal"), true) - expect(t, c.GlobalIsSet("myflagGlobalUnset"), false) - expect(t, c.GlobalIsSet("bogusGlobal"), false) -} - -func TestContext_NumFlags(t *testing.T) { - set := flag.NewFlagSet("test", 0) - set.Bool("myflag", false, "doc") - set.String("otherflag", "hello world", "doc") - globalSet := flag.NewFlagSet("test", 0) - globalSet.Bool("myflagGlobal", true, "doc") - globalCtx := NewContext(nil, globalSet, nil) - c := NewContext(nil, set, globalCtx) - set.Parse([]string{"--myflag", "--otherflag=foo"}) - globalSet.Parse([]string{"--myflagGlobal"}) - expect(t, c.NumFlags(), 2) -} diff --git a/vendor/github.com/codegangsta/cli/flag_test.go b/vendor/github.com/codegangsta/cli/flag_test.go deleted file mode 100644 index 3caa70a4..00000000 --- a/vendor/github.com/codegangsta/cli/flag_test.go +++ /dev/null @@ -1,859 +0,0 @@ -package cli - -import ( - "fmt" - "os" - "reflect" - "strings" - "testing" - "runtime" -) - -var boolFlagTests = []struct { - name string - expected string -}{ - {"help", "--help\t"}, - {"h", "-h\t"}, -} - -func TestBoolFlagHelpOutput(t *testing.T) { - - for _, test := range boolFlagTests { - flag := BoolFlag{Name: test.name} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -var stringFlagTests = []struct { - name string - value string - expected string -}{ - {"help", "", "--help \t"}, - {"h", "", "-h \t"}, - {"h", "", "-h \t"}, - {"test", "Something", "--test \"Something\"\t"}, -} - -func TestStringFlagHelpOutput(t *testing.T) { - - for _, test := range stringFlagTests { - flag := StringFlag{Name: test.name, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestStringFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_FOO", "derp") - for _, test := range stringFlagTests { - flag := StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"} - output := flag.String() - - expectedSuffix := " [$APP_FOO]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_FOO%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with" + expectedSuffix, output) - } - } -} - -var stringSliceFlagTests = []struct { - name string - value *StringSlice - expected string -}{ - {"help", func() *StringSlice { - s := &StringSlice{} - s.Set("") - return s - }(), "--help [--help option --help option]\t"}, - {"h", func() *StringSlice { - s := &StringSlice{} - s.Set("") - return s - }(), "-h [-h option -h option]\t"}, - {"h", func() *StringSlice { - s := &StringSlice{} - s.Set("") - return s - }(), "-h [-h option -h option]\t"}, - {"test", func() *StringSlice { - s := &StringSlice{} - s.Set("Something") - return s - }(), "--test [--test option --test option]\t"}, -} - -func TestStringSliceFlagHelpOutput(t *testing.T) { - - for _, test := range stringSliceFlagTests { - flag := StringSliceFlag{Name: test.name, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_QWWX", "11,4") - for _, test := range stringSliceFlagTests { - flag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"} - output := flag.String() - - expectedSuffix := " [$APP_QWWX]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_QWWX%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%q does not end with" + expectedSuffix, output) - } - } -} - -var intFlagTests = []struct { - name string - expected string -}{ - {"help", "--help \"0\"\t"}, - {"h", "-h \"0\"\t"}, -} - -func TestIntFlagHelpOutput(t *testing.T) { - - for _, test := range intFlagTests { - flag := IntFlag{Name: test.name} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestIntFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2") - for _, test := range intFlagTests { - flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with" + expectedSuffix, output) - } - } -} - -var durationFlagTests = []struct { - name string - expected string -}{ - {"help", "--help \"0\"\t"}, - {"h", "-h \"0\"\t"}, -} - -func TestDurationFlagHelpOutput(t *testing.T) { - - for _, test := range durationFlagTests { - flag := DurationFlag{Name: test.name} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAR", "2h3m6s") - for _, test := range durationFlagTests { - flag := DurationFlag{Name: test.name, EnvVar: "APP_BAR"} - output := flag.String() - - expectedSuffix := " [$APP_BAR]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAR%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with" + expectedSuffix, output) - } - } -} - -var intSliceFlagTests = []struct { - name string - value *IntSlice - expected string -}{ - {"help", &IntSlice{}, "--help [--help option --help option]\t"}, - {"h", &IntSlice{}, "-h [-h option -h option]\t"}, - {"h", &IntSlice{}, "-h [-h option -h option]\t"}, - {"test", func() *IntSlice { - i := &IntSlice{} - i.Set("9") - return i - }(), "--test [--test option --test option]\t"}, -} - -func TestIntSliceFlagHelpOutput(t *testing.T) { - - for _, test := range intSliceFlagTests { - flag := IntSliceFlag{Name: test.name, Value: test.value} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_SMURF", "42,3") - for _, test := range intSliceFlagTests { - flag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"} - output := flag.String() - - expectedSuffix := " [$APP_SMURF]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_SMURF%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%q does not end with" + expectedSuffix, output) - } - } -} - -var float64FlagTests = []struct { - name string - expected string -}{ - {"help", "--help \"0\"\t"}, - {"h", "-h \"0\"\t"}, -} - -func TestFloat64FlagHelpOutput(t *testing.T) { - - for _, test := range float64FlagTests { - flag := Float64Flag{Name: test.name} - output := flag.String() - - if output != test.expected { - t.Errorf("%s does not match %s", output, test.expected) - } - } -} - -func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_BAZ", "99.4") - for _, test := range float64FlagTests { - flag := Float64Flag{Name: test.name, EnvVar: "APP_BAZ"} - output := flag.String() - - expectedSuffix := " [$APP_BAZ]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_BAZ%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with" + expectedSuffix, output) - } - } -} - -var genericFlagTests = []struct { - name string - value Generic - expected string -}{ - {"test", &Parser{"abc", "def"}, "--test \"abc,def\"\ttest flag"}, - {"t", &Parser{"abc", "def"}, "-t \"abc,def\"\ttest flag"}, -} - -func TestGenericFlagHelpOutput(t *testing.T) { - - for _, test := range genericFlagTests { - flag := GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"} - output := flag.String() - - if output != test.expected { - t.Errorf("%q does not match %q", output, test.expected) - } - } -} - -func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) { - os.Clearenv() - os.Setenv("APP_ZAP", "3") - for _, test := range genericFlagTests { - flag := GenericFlag{Name: test.name, EnvVar: "APP_ZAP"} - output := flag.String() - - expectedSuffix := " [$APP_ZAP]" - if runtime.GOOS == "windows" { - expectedSuffix = " [%APP_ZAP%]" - } - if !strings.HasSuffix(output, expectedSuffix) { - t.Errorf("%s does not end with" + expectedSuffix, output) - } - } -} - -func TestParseMultiString(t *testing.T) { - (&App{ - Flags: []Flag{ - StringFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) { - if ctx.String("serve") != "10" { - t.Errorf("main name not set") - } - if ctx.String("s") != "10" { - t.Errorf("short name not set") - } - }, - }).Run([]string{"run", "-s", "10"}) -} - -func TestParseDestinationString(t *testing.T) { - var dest string - a := App{ - Flags: []Flag{ - StringFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) { - if dest != "10" { - t.Errorf("expected destination String 10") - } - }, - } - a.Run([]string{"run", "--dest", "10"}) -} - -func TestParseMultiStringFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_COUNT", "20") - (&App{ - Flags: []Flag{ - StringFlag{Name: "count, c", EnvVar: "APP_COUNT"}, - }, - Action: func(ctx *Context) { - if ctx.String("count") != "20" { - t.Errorf("main name not set") - } - if ctx.String("c") != "20" { - t.Errorf("short name not set") - } - }, - }).Run([]string{"run"}) -} - -func TestParseMultiStringFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_COUNT", "20") - (&App{ - Flags: []Flag{ - StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"}, - }, - Action: func(ctx *Context) { - if ctx.String("count") != "20" { - t.Errorf("main name not set") - } - if ctx.String("c") != "20" { - t.Errorf("short name not set") - } - }, - }).Run([]string{"run"}) -} - -func TestParseMultiStringSlice(t *testing.T) { - (&App{ - Flags: []Flag{ - StringSliceFlag{Name: "serve, s", Value: &StringSlice{}}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) { - t.Errorf("short name not set") - } - }, - }).Run([]string{"run", "-s", "10", "-s", "20"}) -} - -func TestParseMultiStringSliceFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "APP_INTERVALS"}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) { - t.Errorf("short name not set from env") - } - }, - }).Run([]string{"run"}) -} - -func TestParseMultiStringSliceFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) { - t.Errorf("short name not set from env") - } - }, - }).Run([]string{"run"}) -} - -func TestParseMultiInt(t *testing.T) { - a := App{ - Flags: []Flag{ - IntFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) { - if ctx.Int("serve") != 10 { - t.Errorf("main name not set") - } - if ctx.Int("s") != 10 { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run", "-s", "10"}) -} - -func TestParseDestinationInt(t *testing.T) { - var dest int - a := App{ - Flags: []Flag{ - IntFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) { - if dest != 10 { - t.Errorf("expected destination Int 10") - } - }, - } - a.Run([]string{"run", "--dest", "10"}) -} - -func TestParseMultiIntFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "10") - a := App{ - Flags: []Flag{ - IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) { - if ctx.Int("timeout") != 10 { - t.Errorf("main name not set") - } - if ctx.Int("t") != 10 { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiIntFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "10") - a := App{ - Flags: []Flag{ - IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) { - if ctx.Int("timeout") != 10 { - t.Errorf("main name not set") - } - if ctx.Int("t") != 10 { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiIntSlice(t *testing.T) { - (&App{ - Flags: []Flag{ - IntSliceFlag{Name: "serve, s", Value: &IntSlice{}}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) { - t.Errorf("short name not set") - } - }, - }).Run([]string{"run", "-s", "10", "-s", "20"}) -} - -func TestParseMultiIntSliceFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "APP_INTERVALS"}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) { - t.Errorf("short name not set from env") - } - }, - }).Run([]string{"run"}) -} - -func TestParseMultiIntSliceFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_INTERVALS", "20,30,40") - - (&App{ - Flags: []Flag{ - IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) { - t.Errorf("short name not set from env") - } - }, - }).Run([]string{"run"}) -} - -func TestParseMultiFloat64(t *testing.T) { - a := App{ - Flags: []Flag{ - Float64Flag{Name: "serve, s"}, - }, - Action: func(ctx *Context) { - if ctx.Float64("serve") != 10.2 { - t.Errorf("main name not set") - } - if ctx.Float64("s") != 10.2 { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run", "-s", "10.2"}) -} - -func TestParseDestinationFloat64(t *testing.T) { - var dest float64 - a := App{ - Flags: []Flag{ - Float64Flag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) { - if dest != 10.2 { - t.Errorf("expected destination Float64 10.2") - } - }, - } - a.Run([]string{"run", "--dest", "10.2"}) -} - -func TestParseMultiFloat64FromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "15.5") - a := App{ - Flags: []Flag{ - Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) { - if ctx.Float64("timeout") != 15.5 { - t.Errorf("main name not set") - } - if ctx.Float64("t") != 15.5 { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiFloat64FromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_TIMEOUT_SECONDS", "15.5") - a := App{ - Flags: []Flag{ - Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"}, - }, - Action: func(ctx *Context) { - if ctx.Float64("timeout") != 15.5 { - t.Errorf("main name not set") - } - if ctx.Float64("t") != 15.5 { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBool(t *testing.T) { - a := App{ - Flags: []Flag{ - BoolFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) { - if ctx.Bool("serve") != true { - t.Errorf("main name not set") - } - if ctx.Bool("s") != true { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run", "--serve"}) -} - -func TestParseDestinationBool(t *testing.T) { - var dest bool - a := App{ - Flags: []Flag{ - BoolFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) { - if dest != true { - t.Errorf("expected destination Bool true") - } - }, - } - a.Run([]string{"run", "--dest"}) -} - -func TestParseMultiBoolFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "1") - a := App{ - Flags: []Flag{ - BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"}, - }, - Action: func(ctx *Context) { - if ctx.Bool("debug") != true { - t.Errorf("main name not set from env") - } - if ctx.Bool("d") != true { - t.Errorf("short name not set from env") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBoolFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "1") - a := App{ - Flags: []Flag{ - BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"}, - }, - Action: func(ctx *Context) { - if ctx.Bool("debug") != true { - t.Errorf("main name not set from env") - } - if ctx.Bool("d") != true { - t.Errorf("short name not set from env") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBoolT(t *testing.T) { - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "serve, s"}, - }, - Action: func(ctx *Context) { - if ctx.BoolT("serve") != true { - t.Errorf("main name not set") - } - if ctx.BoolT("s") != true { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run", "--serve"}) -} - -func TestParseDestinationBoolT(t *testing.T) { - var dest bool - a := App{ - Flags: []Flag{ - BoolTFlag{ - Name: "dest", - Destination: &dest, - }, - }, - Action: func(ctx *Context) { - if dest != true { - t.Errorf("expected destination BoolT true") - } - }, - } - a.Run([]string{"run", "--dest"}) -} - -func TestParseMultiBoolTFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "0") - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"}, - }, - Action: func(ctx *Context) { - if ctx.BoolT("debug") != false { - t.Errorf("main name not set from env") - } - if ctx.BoolT("d") != false { - t.Errorf("short name not set from env") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseMultiBoolTFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_DEBUG", "0") - a := App{ - Flags: []Flag{ - BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"}, - }, - Action: func(ctx *Context) { - if ctx.BoolT("debug") != false { - t.Errorf("main name not set from env") - } - if ctx.BoolT("d") != false { - t.Errorf("short name not set from env") - } - }, - } - a.Run([]string{"run"}) -} - -type Parser [2]string - -func (p *Parser) Set(value string) error { - parts := strings.Split(value, ",") - if len(parts) != 2 { - return fmt.Errorf("invalid format") - } - - (*p)[0] = parts[0] - (*p)[1] = parts[1] - - return nil -} - -func (p *Parser) String() string { - return fmt.Sprintf("%s,%s", p[0], p[1]) -} - -func TestParseGeneric(t *testing.T) { - a := App{ - Flags: []Flag{ - GenericFlag{Name: "serve, s", Value: &Parser{}}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) { - t.Errorf("main name not set") - } - if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) { - t.Errorf("short name not set") - } - }, - } - a.Run([]string{"run", "-s", "10,20"}) -} - -func TestParseGenericFromEnv(t *testing.T) { - os.Clearenv() - os.Setenv("APP_SERVE", "20,30") - a := App{ - Flags: []Flag{ - GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) { - t.Errorf("main name not set from env") - } - if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) { - t.Errorf("short name not set from env") - } - }, - } - a.Run([]string{"run"}) -} - -func TestParseGenericFromEnvCascade(t *testing.T) { - os.Clearenv() - os.Setenv("APP_FOO", "99,2000") - a := App{ - Flags: []Flag{ - GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"}, - }, - Action: func(ctx *Context) { - if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) { - t.Errorf("value not set from env") - } - }, - } - a.Run([]string{"run"}) -} diff --git a/vendor/github.com/codegangsta/cli/help_test.go b/vendor/github.com/codegangsta/cli/help_test.go deleted file mode 100644 index 0821f48a..00000000 --- a/vendor/github.com/codegangsta/cli/help_test.go +++ /dev/null @@ -1,110 +0,0 @@ -package cli - -import ( - "bytes" - "testing" -) - -func Test_ShowAppHelp_NoAuthor(t *testing.T) { - output := new(bytes.Buffer) - app := NewApp() - app.Writer = output - - c := NewContext(app, nil, nil) - - ShowAppHelp(c) - - if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 { - t.Errorf("expected\n%snot to include %s", output.String(), "AUTHOR(S):") - } -} - -func Test_ShowAppHelp_NoVersion(t *testing.T) { - output := new(bytes.Buffer) - app := NewApp() - app.Writer = output - - app.Version = "" - - c := NewContext(app, nil, nil) - - ShowAppHelp(c) - - if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 { - t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:") - } -} - -func Test_ShowAppHelp_HideVersion(t *testing.T) { - output := new(bytes.Buffer) - app := NewApp() - app.Writer = output - - app.HideVersion = true - - c := NewContext(app, nil, nil) - - ShowAppHelp(c) - - if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 { - t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:") - } -} - -func Test_Help_Custom_Flags(t *testing.T) { - oldFlag := HelpFlag - defer func() { - HelpFlag = oldFlag - }() - - HelpFlag = BoolFlag{ - Name: "help, x", - Usage: "show help", - } - - app := App{ - Flags: []Flag{ - BoolFlag{Name: "foo, h"}, - }, - Action: func(ctx *Context) { - if ctx.Bool("h") != true { - t.Errorf("custom help flag not set") - } - }, - } - output := new(bytes.Buffer) - app.Writer = output - app.Run([]string{"test", "-h"}) - if output.Len() > 0 { - t.Errorf("unexpected output: %s", output.String()) - } -} - -func Test_Version_Custom_Flags(t *testing.T) { - oldFlag := VersionFlag - defer func() { - VersionFlag = oldFlag - }() - - VersionFlag = BoolFlag{ - Name: "version, V", - Usage: "show version", - } - - app := App{ - Flags: []Flag{ - BoolFlag{Name: "foo, v"}, - }, - Action: func(ctx *Context) { - if ctx.Bool("v") != true { - t.Errorf("custom version flag not set") - } - }, - } - output := new(bytes.Buffer) - app.Writer = output - app.Run([]string{"test", "-v"}) - if output.Len() > 0 { - t.Errorf("unexpected output: %s", output.String()) - } -} diff --git a/vendor/github.com/codegangsta/cli/helpers_test.go b/vendor/github.com/codegangsta/cli/helpers_test.go deleted file mode 100644 index b1b7339f..00000000 --- a/vendor/github.com/codegangsta/cli/helpers_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package cli - -import ( - "reflect" - "testing" -) - -/* Test Helpers */ -func expect(t *testing.T, a interface{}, b interface{}) { - if !reflect.DeepEqual(a, b) { - t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) - } -} - -func refute(t *testing.T, a interface{}, b interface{}) { - if reflect.DeepEqual(a, b) { - t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) - } -} diff --git a/vendor/github.com/docker/go-units/duration_test.go b/vendor/github.com/docker/go-units/duration_test.go deleted file mode 100644 index 63baa515..00000000 --- a/vendor/github.com/docker/go-units/duration_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package units - -import ( - "fmt" - "testing" - "time" -) - -func ExampleHumanDuration() { - fmt.Println(HumanDuration(450 * time.Millisecond)) - fmt.Println(HumanDuration(47 * time.Second)) - fmt.Println(HumanDuration(1 * time.Minute)) - fmt.Println(HumanDuration(3 * time.Minute)) - fmt.Println(HumanDuration(35 * time.Minute)) - fmt.Println(HumanDuration(35*time.Minute + 40*time.Second)) - fmt.Println(HumanDuration(1 * time.Hour)) - fmt.Println(HumanDuration(1*time.Hour + 45*time.Minute)) - fmt.Println(HumanDuration(3 * time.Hour)) - fmt.Println(HumanDuration(3*time.Hour + 59*time.Minute)) - fmt.Println(HumanDuration(3*time.Hour + 60*time.Minute)) - fmt.Println(HumanDuration(24 * time.Hour)) - fmt.Println(HumanDuration(24*time.Hour + 12*time.Hour)) - fmt.Println(HumanDuration(2 * 24 * time.Hour)) - fmt.Println(HumanDuration(7 * 24 * time.Hour)) - fmt.Println(HumanDuration(13*24*time.Hour + 5*time.Hour)) - fmt.Println(HumanDuration(2 * 7 * 24 * time.Hour)) - fmt.Println(HumanDuration(2*7*24*time.Hour + 4*24*time.Hour)) - fmt.Println(HumanDuration(3 * 7 * 24 * time.Hour)) - fmt.Println(HumanDuration(4 * 7 * 24 * time.Hour)) - fmt.Println(HumanDuration(4*7*24*time.Hour + 3*24*time.Hour)) - fmt.Println(HumanDuration(1 * 30 * 24 * time.Hour)) - fmt.Println(HumanDuration(1*30*24*time.Hour + 2*7*24*time.Hour)) - fmt.Println(HumanDuration(2 * 30 * 24 * time.Hour)) - fmt.Println(HumanDuration(3*30*24*time.Hour + 1*7*24*time.Hour)) - fmt.Println(HumanDuration(5*30*24*time.Hour + 2*7*24*time.Hour)) - fmt.Println(HumanDuration(13 * 30 * 24 * time.Hour)) - fmt.Println(HumanDuration(23 * 30 * 24 * time.Hour)) - fmt.Println(HumanDuration(24 * 30 * 24 * time.Hour)) - fmt.Println(HumanDuration(24*30*24*time.Hour + 2*7*24*time.Hour)) - fmt.Println(HumanDuration(3*365*24*time.Hour + 2*30*24*time.Hour)) -} - -func TestHumanDuration(t *testing.T) { - // Useful duration abstractions - day := 24 * time.Hour - week := 7 * day - month := 30 * day - year := 365 * day - - assertEquals(t, "Less than a second", HumanDuration(450*time.Millisecond)) - assertEquals(t, "47 seconds", HumanDuration(47*time.Second)) - assertEquals(t, "About a minute", HumanDuration(1*time.Minute)) - assertEquals(t, "3 minutes", HumanDuration(3*time.Minute)) - assertEquals(t, "35 minutes", HumanDuration(35*time.Minute)) - assertEquals(t, "35 minutes", HumanDuration(35*time.Minute+40*time.Second)) - assertEquals(t, "About an hour", HumanDuration(1*time.Hour)) - assertEquals(t, "About an hour", HumanDuration(1*time.Hour+45*time.Minute)) - assertEquals(t, "3 hours", HumanDuration(3*time.Hour)) - assertEquals(t, "3 hours", HumanDuration(3*time.Hour+59*time.Minute)) - assertEquals(t, "4 hours", HumanDuration(3*time.Hour+60*time.Minute)) - assertEquals(t, "24 hours", HumanDuration(24*time.Hour)) - assertEquals(t, "36 hours", HumanDuration(1*day+12*time.Hour)) - assertEquals(t, "2 days", HumanDuration(2*day)) - assertEquals(t, "7 days", HumanDuration(7*day)) - assertEquals(t, "13 days", HumanDuration(13*day+5*time.Hour)) - assertEquals(t, "2 weeks", HumanDuration(2*week)) - assertEquals(t, "2 weeks", HumanDuration(2*week+4*day)) - assertEquals(t, "3 weeks", HumanDuration(3*week)) - assertEquals(t, "4 weeks", HumanDuration(4*week)) - assertEquals(t, "4 weeks", HumanDuration(4*week+3*day)) - assertEquals(t, "4 weeks", HumanDuration(1*month)) - assertEquals(t, "6 weeks", HumanDuration(1*month+2*week)) - assertEquals(t, "8 weeks", HumanDuration(2*month)) - assertEquals(t, "3 months", HumanDuration(3*month+1*week)) - assertEquals(t, "5 months", HumanDuration(5*month+2*week)) - assertEquals(t, "13 months", HumanDuration(13*month)) - assertEquals(t, "23 months", HumanDuration(23*month)) - assertEquals(t, "24 months", HumanDuration(24*month)) - assertEquals(t, "2 years", HumanDuration(24*month+2*week)) - assertEquals(t, "3 years", HumanDuration(3*year+2*month)) -} diff --git a/vendor/github.com/docker/go-units/size_test.go b/vendor/github.com/docker/go-units/size_test.go deleted file mode 100644 index 003bc89a..00000000 --- a/vendor/github.com/docker/go-units/size_test.go +++ /dev/null @@ -1,163 +0,0 @@ -package units - -import ( - "fmt" - "reflect" - "runtime" - "strings" - "testing" -) - -func ExampleBytesSize() { - fmt.Println(BytesSize(1024)) - fmt.Println(BytesSize(1024 * 1024)) - fmt.Println(BytesSize(1048576)) - fmt.Println(BytesSize(2 * MiB)) - fmt.Println(BytesSize(3.42 * GiB)) - fmt.Println(BytesSize(5.372 * TiB)) - fmt.Println(BytesSize(2.22 * PiB)) -} - -func ExampleHumanSize() { - fmt.Println(HumanSize(1000)) - fmt.Println(HumanSize(1024)) - fmt.Println(HumanSize(1000000)) - fmt.Println(HumanSize(1048576)) - fmt.Println(HumanSize(2 * MB)) - fmt.Println(HumanSize(float64(3.42 * GB))) - fmt.Println(HumanSize(float64(5.372 * TB))) - fmt.Println(HumanSize(float64(2.22 * PB))) -} - -func ExampleFromHumanSize() { - fmt.Println(FromHumanSize("32")) - fmt.Println(FromHumanSize("32b")) - fmt.Println(FromHumanSize("32B")) - fmt.Println(FromHumanSize("32k")) - fmt.Println(FromHumanSize("32K")) - fmt.Println(FromHumanSize("32kb")) - fmt.Println(FromHumanSize("32Kb")) - fmt.Println(FromHumanSize("32Mb")) - fmt.Println(FromHumanSize("32Gb")) - fmt.Println(FromHumanSize("32Tb")) - fmt.Println(FromHumanSize("32Pb")) -} - -func ExampleRAMInBytes() { - fmt.Println(RAMInBytes("32")) - fmt.Println(RAMInBytes("32b")) - fmt.Println(RAMInBytes("32B")) - fmt.Println(RAMInBytes("32k")) - fmt.Println(RAMInBytes("32K")) - fmt.Println(RAMInBytes("32kb")) - fmt.Println(RAMInBytes("32Kb")) - fmt.Println(RAMInBytes("32Mb")) - fmt.Println(RAMInBytes("32Gb")) - fmt.Println(RAMInBytes("32Tb")) - fmt.Println(RAMInBytes("32Pb")) - fmt.Println(RAMInBytes("32PB")) - fmt.Println(RAMInBytes("32P")) -} - -func TestBytesSize(t *testing.T) { - assertEquals(t, "1 KiB", BytesSize(1024)) - assertEquals(t, "1 MiB", BytesSize(1024*1024)) - assertEquals(t, "1 MiB", BytesSize(1048576)) - assertEquals(t, "2 MiB", BytesSize(2*MiB)) - assertEquals(t, "3.42 GiB", BytesSize(3.42*GiB)) - assertEquals(t, "5.372 TiB", BytesSize(5.372*TiB)) - assertEquals(t, "2.22 PiB", BytesSize(2.22*PiB)) -} - -func TestHumanSize(t *testing.T) { - assertEquals(t, "1 kB", HumanSize(1000)) - assertEquals(t, "1.024 kB", HumanSize(1024)) - assertEquals(t, "1 MB", HumanSize(1000000)) - assertEquals(t, "1.049 MB", HumanSize(1048576)) - assertEquals(t, "2 MB", HumanSize(2*MB)) - assertEquals(t, "3.42 GB", HumanSize(float64(3.42*GB))) - assertEquals(t, "5.372 TB", HumanSize(float64(5.372*TB))) - assertEquals(t, "2.22 PB", HumanSize(float64(2.22*PB))) -} - -func TestFromHumanSize(t *testing.T) { - assertSuccessEquals(t, 32, FromHumanSize, "32") - assertSuccessEquals(t, 32, FromHumanSize, "32b") - assertSuccessEquals(t, 32, FromHumanSize, "32B") - assertSuccessEquals(t, 32*KB, FromHumanSize, "32k") - assertSuccessEquals(t, 32*KB, FromHumanSize, "32K") - assertSuccessEquals(t, 32*KB, FromHumanSize, "32kb") - assertSuccessEquals(t, 32*KB, FromHumanSize, "32Kb") - assertSuccessEquals(t, 32*MB, FromHumanSize, "32Mb") - assertSuccessEquals(t, 32*GB, FromHumanSize, "32Gb") - assertSuccessEquals(t, 32*TB, FromHumanSize, "32Tb") - assertSuccessEquals(t, 32*PB, FromHumanSize, "32Pb") - - assertSuccessEquals(t, 32.5*KB, FromHumanSize, "32.5kB") - assertSuccessEquals(t, 32.5*KB, FromHumanSize, "32.5 kB") - assertSuccessEquals(t, 32, FromHumanSize, "32.5 B") - - assertError(t, FromHumanSize, "") - assertError(t, FromHumanSize, "hello") - assertError(t, FromHumanSize, "-32") - assertError(t, FromHumanSize, ".3kB") - assertError(t, FromHumanSize, " 32 ") - assertError(t, FromHumanSize, "32m b") - assertError(t, FromHumanSize, "32bm") -} - -func TestRAMInBytes(t *testing.T) { - assertSuccessEquals(t, 32, RAMInBytes, "32") - assertSuccessEquals(t, 32, RAMInBytes, "32b") - assertSuccessEquals(t, 32, RAMInBytes, "32B") - assertSuccessEquals(t, 32*KiB, RAMInBytes, "32k") - assertSuccessEquals(t, 32*KiB, RAMInBytes, "32K") - assertSuccessEquals(t, 32*KiB, RAMInBytes, "32kb") - assertSuccessEquals(t, 32*KiB, RAMInBytes, "32Kb") - assertSuccessEquals(t, 32*MiB, RAMInBytes, "32Mb") - assertSuccessEquals(t, 32*GiB, RAMInBytes, "32Gb") - assertSuccessEquals(t, 32*TiB, RAMInBytes, "32Tb") - assertSuccessEquals(t, 32*PiB, RAMInBytes, "32Pb") - assertSuccessEquals(t, 32*PiB, RAMInBytes, "32PB") - assertSuccessEquals(t, 32*PiB, RAMInBytes, "32P") - - assertSuccessEquals(t, 32, RAMInBytes, "32.3") - tmp := 32.3 * MiB - assertSuccessEquals(t, int64(tmp), RAMInBytes, "32.3 mb") - - assertError(t, RAMInBytes, "") - assertError(t, RAMInBytes, "hello") - assertError(t, RAMInBytes, "-32") - assertError(t, RAMInBytes, " 32 ") - assertError(t, RAMInBytes, "32m b") - assertError(t, RAMInBytes, "32bm") -} - -func assertEquals(t *testing.T, expected, actual interface{}) { - if expected != actual { - t.Errorf("Expected '%v' but got '%v'", expected, actual) - } -} - -// func that maps to the parse function signatures as testing abstraction -type parseFn func(string) (int64, error) - -// Define 'String()' for pretty-print -func (fn parseFn) String() string { - fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name() - return fnName[strings.LastIndex(fnName, ".")+1:] -} - -func assertSuccessEquals(t *testing.T, expected int64, fn parseFn, arg string) { - res, err := fn(arg) - if err != nil || res != expected { - t.Errorf("%s(\"%s\") -> expected '%d' but got '%d' with error '%v'", fn, arg, expected, res, err) - } -} - -func assertError(t *testing.T, fn parseFn, arg string) { - res, err := fn(arg) - if err == nil && res != -1 { - t.Errorf("%s(\"%s\") -> expected error but got '%d'", fn, arg, res) - } -} diff --git a/vendor/github.com/docker/go-units/ulimit_test.go b/vendor/github.com/docker/go-units/ulimit_test.go deleted file mode 100644 index 3e7f10fc..00000000 --- a/vendor/github.com/docker/go-units/ulimit_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package units - -import ( - "fmt" - "strconv" - "testing" -) - -func ExampleParseUlimit() { - fmt.Println(ParseUlimit("nofile=512:1024")) - fmt.Println(ParseUlimit("nofile=1024")) - fmt.Println(ParseUlimit("cpu=2:4")) - fmt.Println(ParseUlimit("cpu=6")) -} - -func TestParseUlimitValid(t *testing.T) { - u1 := &Ulimit{"nofile", 1024, 512} - if u2, _ := ParseUlimit("nofile=512:1024"); *u1 != *u2 { - t.Fatalf("expected %q, but got %q", u1, u2) - } -} - -func TestParseUlimitInvalidLimitType(t *testing.T) { - if _, err := ParseUlimit("notarealtype=1024:1024"); err == nil { - t.Fatalf("expected error on invalid ulimit type") - } -} - -func TestParseUlimitBadFormat(t *testing.T) { - if _, err := ParseUlimit("nofile:1024:1024"); err == nil { - t.Fatal("expected error on bad syntax") - } - - if _, err := ParseUlimit("nofile"); err == nil { - t.Fatal("expected error on bad syntax") - } - - if _, err := ParseUlimit("nofile="); err == nil { - t.Fatal("expected error on bad syntax") - } - if _, err := ParseUlimit("nofile=:"); err == nil { - t.Fatal("expected error on bad syntax") - } - if _, err := ParseUlimit("nofile=:1024"); err == nil { - t.Fatal("expected error on bad syntax") - } -} - -func TestParseUlimitHardLessThanSoft(t *testing.T) { - if _, err := ParseUlimit("nofile=1024:1"); err == nil { - t.Fatal("expected error on hard limit less than soft limit") - } -} - -func TestParseUlimitInvalidValueType(t *testing.T) { - if _, err := ParseUlimit("nofile=asdf"); err == nil { - t.Fatal("expected error on bad value type, but got no error") - } else if _, ok := err.(*strconv.NumError); !ok { - t.Fatalf("expected error on bad value type, but got `%s`", err) - } - - if _, err := ParseUlimit("nofile=1024:asdf"); err == nil { - t.Fatal("expected error on bad value type, but got no error") - } else if _, ok := err.(*strconv.NumError); !ok { - t.Fatalf("expected error on bad value type, but got `%s`", err) - } -} - -func TestUlimitStringOutput(t *testing.T) { - u := &Ulimit{"nofile", 1024, 512} - if s := u.String(); s != "nofile=512:1024" { - t.Fatal("expected String to return nofile=512:1024, but got", s) - } -} diff --git a/vendor/github.com/gorilla/context/context_test.go b/vendor/github.com/gorilla/context/context_test.go deleted file mode 100644 index 9814c501..00000000 --- a/vendor/github.com/gorilla/context/context_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// 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" - "testing" -) - -type keyType int - -const ( - key1 keyType = iota - key2 -) - -func TestContext(t *testing.T) { - assertEqual := func(val interface{}, exp interface{}) { - if val != exp { - t.Errorf("Expected %v, got %v.", exp, val) - } - } - - r, _ := http.NewRequest("GET", "http://localhost:8080/", nil) - emptyR, _ := http.NewRequest("GET", "http://localhost:8080/", nil) - - // Get() - assertEqual(Get(r, key1), nil) - - // Set() - Set(r, key1, "1") - assertEqual(Get(r, key1), "1") - assertEqual(len(data[r]), 1) - - Set(r, key2, "2") - assertEqual(Get(r, key2), "2") - assertEqual(len(data[r]), 2) - - //GetOk - value, ok := GetOk(r, key1) - assertEqual(value, "1") - assertEqual(ok, true) - - value, ok = GetOk(r, "not exists") - assertEqual(value, nil) - assertEqual(ok, false) - - Set(r, "nil value", nil) - value, ok = GetOk(r, "nil value") - assertEqual(value, nil) - assertEqual(ok, true) - - // GetAll() - values := GetAll(r) - assertEqual(len(values), 3) - - // GetAll() for empty request - values = GetAll(emptyR) - if values != nil { - t.Error("GetAll didn't return nil value for invalid request") - } - - // GetAllOk() - values, ok = GetAllOk(r) - assertEqual(len(values), 3) - assertEqual(ok, true) - - // GetAllOk() for empty request - values, ok = GetAllOk(emptyR) - assertEqual(value, nil) - assertEqual(ok, false) - - // Delete() - Delete(r, key1) - assertEqual(Get(r, key1), nil) - assertEqual(len(data[r]), 2) - - Delete(r, key2) - assertEqual(Get(r, key2), nil) - assertEqual(len(data[r]), 1) - - // Clear() - Clear(r) - assertEqual(len(data), 0) -} - -func parallelReader(r *http.Request, key string, iterations int, wait, done chan struct{}) { - <-wait - for i := 0; i < iterations; i++ { - Get(r, key) - } - done <- struct{}{} - -} - -func parallelWriter(r *http.Request, key, value string, iterations int, wait, done chan struct{}) { - <-wait - for i := 0; i < iterations; i++ { - Set(r, key, value) - } - done <- struct{}{} - -} - -func benchmarkMutex(b *testing.B, numReaders, numWriters, iterations int) { - - b.StopTimer() - r, _ := http.NewRequest("GET", "http://localhost:8080/", nil) - done := make(chan struct{}) - b.StartTimer() - - for i := 0; i < b.N; i++ { - wait := make(chan struct{}) - - for i := 0; i < numReaders; i++ { - go parallelReader(r, "test", iterations, wait, done) - } - - for i := 0; i < numWriters; i++ { - go parallelWriter(r, "test", "123", iterations, wait, done) - } - - close(wait) - - for i := 0; i < numReaders+numWriters; i++ { - <-done - } - - } - -} - -func BenchmarkMutexSameReadWrite1(b *testing.B) { - benchmarkMutex(b, 1, 1, 32) -} -func BenchmarkMutexSameReadWrite2(b *testing.B) { - benchmarkMutex(b, 2, 2, 32) -} -func BenchmarkMutexSameReadWrite4(b *testing.B) { - benchmarkMutex(b, 4, 4, 32) -} -func BenchmarkMutex1(b *testing.B) { - benchmarkMutex(b, 2, 8, 32) -} -func BenchmarkMutex2(b *testing.B) { - benchmarkMutex(b, 16, 4, 64) -} -func BenchmarkMutex3(b *testing.B) { - benchmarkMutex(b, 1, 2, 128) -} -func BenchmarkMutex4(b *testing.B) { - benchmarkMutex(b, 128, 32, 256) -} -func BenchmarkMutex5(b *testing.B) { - benchmarkMutex(b, 1024, 2048, 64) -} -func BenchmarkMutex6(b *testing.B) { - benchmarkMutex(b, 2048, 1024, 512) -} diff --git a/vendor/github.com/gorilla/handlers/canonical_test.go b/vendor/github.com/gorilla/handlers/canonical_test.go deleted file mode 100644 index 615e4b05..00000000 --- a/vendor/github.com/gorilla/handlers/canonical_test.go +++ /dev/null @@ -1,127 +0,0 @@ -package handlers - -import ( - "bufio" - "bytes" - "log" - "net/http" - "net/http/httptest" - "net/url" - "strings" - "testing" -) - -func TestCleanHost(t *testing.T) { - tests := []struct { - in, want string - }{ - {"www.google.com", "www.google.com"}, - {"www.google.com foo", "www.google.com"}, - {"www.google.com/foo", "www.google.com"}, - {" first character is a space", ""}, - } - for _, tt := range tests { - got := cleanHost(tt.in) - if tt.want != got { - t.Errorf("cleanHost(%q) = %q, want %q", tt.in, got, tt.want) - } - } -} - -func TestCanonicalHost(t *testing.T) { - gorilla := "http://www.gorillatoolkit.org" - - rr := httptest.NewRecorder() - r := newRequest("GET", "http://www.example.com/") - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - // Test a re-direct: should return a 302 Found. - CanonicalHost(gorilla, http.StatusFound)(testHandler).ServeHTTP(rr, r) - - if rr.Code != http.StatusFound { - t.Fatalf("bad status: got %v want %v", rr.Code, http.StatusFound) - } - - if rr.Header().Get("Location") != gorilla+r.URL.Path { - t.Fatalf("bad re-direct: got %q want %q", rr.Header().Get("Location"), gorilla+r.URL.Path) - } - -} - -func TestKeepsQueryString(t *testing.T) { - google := "https://www.google.com" - - rr := httptest.NewRecorder() - querystring := url.Values{"q": {"golang"}, "format": {"json"}}.Encode() - r := newRequest("GET", "http://www.example.com/search?"+querystring) - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - CanonicalHost(google, http.StatusFound)(testHandler).ServeHTTP(rr, r) - - want := google + r.URL.Path + "?" + querystring - if rr.Header().Get("Location") != want { - t.Fatalf("bad re-direct: got %q want %q", rr.Header().Get("Location"), want) - } -} - -func TestBadDomain(t *testing.T) { - rr := httptest.NewRecorder() - r := newRequest("GET", "http://www.example.com/") - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - // Test a bad domain - should return 200 OK. - CanonicalHost("%", http.StatusFound)(testHandler).ServeHTTP(rr, r) - - if rr.Code != http.StatusOK { - t.Fatalf("bad status: got %v want %v", rr.Code, http.StatusOK) - } -} - -func TestEmptyHost(t *testing.T) { - rr := httptest.NewRecorder() - r := newRequest("GET", "http://www.example.com/") - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - // Test a domain that returns an empty url.Host from url.Parse. - CanonicalHost("hello.com", http.StatusFound)(testHandler).ServeHTTP(rr, r) - - if rr.Code != http.StatusOK { - t.Fatalf("bad status: got %v want %v", rr.Code, http.StatusOK) - } -} - -func TestHeaderWrites(t *testing.T) { - gorilla := "http://www.gorillatoolkit.org" - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - }) - - // Catch the log output to ensure we don't write multiple headers. - var b bytes.Buffer - buf := bufio.NewWriter(&b) - tl := log.New(buf, "test: ", log.Lshortfile) - - srv := httptest.NewServer( - CanonicalHost(gorilla, http.StatusFound)(testHandler)) - defer srv.Close() - srv.Config.ErrorLog = tl - - _, err := http.Get(srv.URL) - if err != nil { - t.Fatal(err) - } - - err = buf.Flush() - if err != nil { - t.Fatal(err) - } - - // We rely on the error not changing: net/http does not export it. - if strings.Contains(b.String(), "multiple response.WriteHeader calls") { - t.Fatalf("re-direct did not return early: multiple header writes") - } -} diff --git a/vendor/github.com/gorilla/handlers/compress_test.go b/vendor/github.com/gorilla/handlers/compress_test.go deleted file mode 100644 index 6f07f440..00000000 --- a/vendor/github.com/gorilla/handlers/compress_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2013 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 handlers - -import ( - "bufio" - "io" - "net" - "net/http" - "net/http/httptest" - "strconv" - "testing" -) - -var contentType = "text/plain; charset=utf-8" - -func compressedRequest(w *httptest.ResponseRecorder, compression string) { - CompressHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Length", strconv.Itoa(9*1024)) - w.Header().Set("Content-Type", contentType) - for i := 0; i < 1024; i++ { - io.WriteString(w, "Gorilla!\n") - } - })).ServeHTTP(w, &http.Request{ - Method: "GET", - Header: http.Header{ - "Accept-Encoding": []string{compression}, - }, - }) - -} - -func TestCompressHandlerNoCompression(t *testing.T) { - w := httptest.NewRecorder() - compressedRequest(w, "") - if enc := w.HeaderMap.Get("Content-Encoding"); enc != "" { - t.Errorf("wrong content encoding, got %q want %q", enc, "") - } - if ct := w.HeaderMap.Get("Content-Type"); ct != contentType { - t.Errorf("wrong content type, got %q want %q", ct, contentType) - } - if w.Body.Len() != 1024*9 { - t.Errorf("wrong len, got %d want %d", w.Body.Len(), 1024*9) - } - if l := w.HeaderMap.Get("Content-Length"); l != "9216" { - t.Errorf("wrong content-length. got %q expected %d", l, 1024*9) - } -} - -func TestCompressHandlerGzip(t *testing.T) { - w := httptest.NewRecorder() - compressedRequest(w, "gzip") - if w.HeaderMap.Get("Content-Encoding") != "gzip" { - t.Errorf("wrong content encoding, got %q want %q", w.HeaderMap.Get("Content-Encoding"), "gzip") - } - if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" { - t.Errorf("wrong content type, got %s want %s", w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8") - } - if w.Body.Len() != 72 { - t.Errorf("wrong len, got %d want %d", w.Body.Len(), 72) - } - if l := w.HeaderMap.Get("Content-Length"); l != "" { - t.Errorf("wrong content-length. got %q expected %q", l, "") - } -} - -func TestCompressHandlerDeflate(t *testing.T) { - w := httptest.NewRecorder() - compressedRequest(w, "deflate") - if w.HeaderMap.Get("Content-Encoding") != "deflate" { - t.Fatalf("wrong content encoding, got %q want %q", w.HeaderMap.Get("Content-Encoding"), "deflate") - } - if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" { - t.Fatalf("wrong content type, got %s want %s", w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8") - } - if w.Body.Len() != 54 { - t.Fatalf("wrong len, got %d want %d", w.Body.Len(), 54) - } -} - -func TestCompressHandlerGzipDeflate(t *testing.T) { - w := httptest.NewRecorder() - compressedRequest(w, "gzip, deflate ") - if w.HeaderMap.Get("Content-Encoding") != "gzip" { - t.Fatalf("wrong content encoding, got %q want %q", w.HeaderMap.Get("Content-Encoding"), "gzip") - } - if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" { - t.Fatalf("wrong content type, got %s want %s", w.HeaderMap.Get("Content-Type"), "text/plain; charset=utf-8") - } -} - -type fullyFeaturedResponseWriter struct{} - -// Header/Write/WriteHeader implement the http.ResponseWriter interface. -func (fullyFeaturedResponseWriter) Header() http.Header { - return http.Header{} -} -func (fullyFeaturedResponseWriter) Write([]byte) (int, error) { - return 0, nil -} -func (fullyFeaturedResponseWriter) WriteHeader(int) {} - -// Flush implements the http.Flusher interface. -func (fullyFeaturedResponseWriter) Flush() {} - -// Hijack implements the http.Hijacker interface. -func (fullyFeaturedResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { - return nil, nil, nil -} - -// CloseNotify implements the http.CloseNotifier interface. -func (fullyFeaturedResponseWriter) CloseNotify() <-chan bool { - return nil -} - -func TestCompressHandlerPreserveInterfaces(t *testing.T) { - // Compile time validation fullyFeaturedResponseWriter implements all the - // interfaces we're asserting in the test case below. - var ( - _ http.Flusher = fullyFeaturedResponseWriter{} - _ http.CloseNotifier = fullyFeaturedResponseWriter{} - _ http.Hijacker = fullyFeaturedResponseWriter{} - ) - var h http.Handler = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { - comp := r.Header.Get("Accept-Encoding") - if _, ok := rw.(*compressResponseWriter); !ok { - t.Fatalf("ResponseWriter wasn't wrapped by compressResponseWriter, got %T type", rw) - } - if _, ok := rw.(http.Flusher); !ok { - t.Errorf("ResponseWriter lost http.Flusher interface for %q", comp) - } - if _, ok := rw.(http.CloseNotifier); !ok { - t.Errorf("ResponseWriter lost http.CloseNotifier interface for %q", comp) - } - if _, ok := rw.(http.Hijacker); !ok { - t.Errorf("ResponseWriter lost http.Hijacker interface for %q", comp) - } - }) - h = CompressHandler(h) - var ( - rw fullyFeaturedResponseWriter - ) - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create test request: %v", err) - } - r.Header.Set("Accept-Encoding", "gzip") - h.ServeHTTP(rw, r) - - r.Header.Set("Accept-Encoding", "deflate") - h.ServeHTTP(rw, r) -} diff --git a/vendor/github.com/gorilla/handlers/cors_test.go b/vendor/github.com/gorilla/handlers/cors_test.go deleted file mode 100644 index c63913ee..00000000 --- a/vendor/github.com/gorilla/handlers/cors_test.go +++ /dev/null @@ -1,336 +0,0 @@ -package handlers - -import ( - "net/http" - "net/http/httptest" - "strings" - "testing" -) - -func TestDefaultCORSHandlerReturnsOk(t *testing.T) { - r := newRequest("GET", "http://www.example.com/") - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusFound) - } -} - -func TestDefaultCORSHandlerReturnsOkWithOrigin(t *testing.T) { - r := newRequest("GET", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusFound) - } -} - -func TestCORSHandlerIgnoreOptionsFallsThrough(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusTeapot) - }) - - CORS(IgnoreOptions())(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusTeapot { - t.Fatalf("bad status: got %v want %v", status, http.StatusTeapot) - } -} - -func TestCORSHandlerSetsExposedHeaders(t *testing.T) { - // Test default configuration. - r := newRequest("GET", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(ExposedHeaders([]string{"X-CORS-TEST"}))(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsExposeHeadersHeader) - if header != "X-Cors-Test" { - t.Fatal("bad header: expected X-Cors-Test header, got empty header for method.") - } -} - -func TestCORSHandlerUnsetRequestMethodForPreflightBadRequest(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(AllowedMethods([]string{"DELETE"}))(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusBadRequest { - t.Fatalf("bad status: got %v want %v", status, http.StatusBadRequest) - } -} - -func TestCORSHandlerInvalidRequestMethodForPreflightMethodNotAllowed(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "DELETE") - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusMethodNotAllowed { - t.Fatalf("bad status: got %v want %v", status, http.StatusMethodNotAllowed) - } -} - -func TestCORSHandlerOptionsRequestMustNotBePassedToNextHandler(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "GET") - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - t.Fatal("Options request must not be passed to next handler") - }) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } -} - -func TestCORSHandlerAllowedMethodForPreflight(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "DELETE") - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(AllowedMethods([]string{"DELETE"}))(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsAllowMethodsHeader) - if header != "DELETE" { - t.Fatalf("bad header: expected DELETE method header, got empty header.") - } -} - -func TestCORSHandlerAllowMethodsNotSetForSimpleRequestPreflight(t *testing.T) { - for _, method := range defaultCorsMethods { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, method) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsAllowMethodsHeader) - if header != "" { - t.Fatalf("bad header: expected empty method header, got %s.", header) - } - } -} - -func TestCORSHandlerAllowedHeaderNotSetForSimpleRequestPreflight(t *testing.T) { - for _, simpleHeader := range defaultCorsHeaders { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "GET") - r.Header.Set(corsRequestHeadersHeader, simpleHeader) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsAllowHeadersHeader) - if header != "" { - t.Fatalf("bad header: expected empty header, got %s.", header) - } - } -} - -func TestCORSHandlerAllowedHeaderForPreflight(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "POST") - r.Header.Set(corsRequestHeadersHeader, "Content-Type") - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(AllowedHeaders([]string{"Content-Type"}))(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsAllowHeadersHeader) - if header != "Content-Type" { - t.Fatalf("bad header: expected Content-Type header, got empty header.") - } -} - -func TestCORSHandlerInvalidHeaderForPreflightForbidden(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "POST") - r.Header.Set(corsRequestHeadersHeader, "Content-Type") - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS()(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusForbidden { - t.Fatalf("bad status: got %v want %v", status, http.StatusForbidden) - } -} - -func TestCORSHandlerMaxAgeForPreflight(t *testing.T) { - r := newRequest("OPTIONS", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - r.Header.Set(corsRequestMethodHeader, "POST") - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(MaxAge(3500))(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsMaxAgeHeader) - if header != "600" { - t.Fatalf("bad header: expected %s to be %s, got %s.", corsMaxAgeHeader, "600", header) - } -} - -func TestCORSHandlerAllowedCredentials(t *testing.T) { - r := newRequest("GET", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(AllowCredentials())(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsAllowCredentialsHeader) - if header != "true" { - t.Fatalf("bad header: expected %s to be %s, got %s.", corsAllowCredentialsHeader, "true", header) - } -} - -func TestCORSHandlerMultipleAllowOriginsSetsVaryHeader(t *testing.T) { - r := newRequest("GET", "http://www.example.com/") - r.Header.Set("Origin", r.URL.String()) - - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - CORS(AllowedOrigins([]string{r.URL.String(), "http://google.com"}))(testHandler).ServeHTTP(rr, r) - - if status := rr.Code; status != http.StatusOK { - t.Fatalf("bad status: got %v want %v", status, http.StatusOK) - } - - header := rr.HeaderMap.Get(corsVaryHeader) - if header != corsOriginHeader { - t.Fatalf("bad header: expected %s to be %s, got %s.", corsVaryHeader, corsOriginHeader, header) - } -} - -func TestCORSWithMultipleHandlers(t *testing.T) { - var lastHandledBy string - corsMiddleware := CORS() - - testHandler1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - lastHandledBy = "testHandler1" - }) - testHandler2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - lastHandledBy = "testHandler2" - }) - - r1 := newRequest("GET", "http://www.example.com/") - rr1 := httptest.NewRecorder() - handler1 := corsMiddleware(testHandler1) - - corsMiddleware(testHandler2) - - handler1.ServeHTTP(rr1, r1) - if lastHandledBy != "testHandler1" { - t.Fatalf("bad CORS() registration: Handler served should be Handler registered") - } -} - -func TestCORSHandlerWithCustomValidator(t *testing.T) { - r := newRequest("GET", "http://a.example.com") - r.Header.Set("Origin", r.URL.String()) - rr := httptest.NewRecorder() - - testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - - originValidator := func(origin string) bool { - if strings.HasSuffix(origin, ".example.com") { - return true - } - return false - } - - CORS(AllowedOriginValidator(originValidator))(testHandler).ServeHTTP(rr, r) - header := rr.HeaderMap.Get(corsAllowOriginHeader) - if header != r.URL.String() { - t.Fatalf("bad header: expected %s to be %s, got %s.", corsAllowOriginHeader, r.URL.String(), header) - } - -} diff --git a/vendor/github.com/gorilla/handlers/handlers_test.go b/vendor/github.com/gorilla/handlers/handlers_test.go deleted file mode 100644 index 6ea7c7fa..00000000 --- a/vendor/github.com/gorilla/handlers/handlers_test.go +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright 2013 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 handlers - -import ( - "bytes" - "net" - "net/http" - "net/http/httptest" - "net/url" - "strings" - "testing" - "time" -) - -const ( - ok = "ok\n" - notAllowed = "Method not allowed\n" -) - -var okHandler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - w.Write([]byte(ok)) -}) - -func newRequest(method, url string) *http.Request { - req, err := http.NewRequest(method, url, nil) - if err != nil { - panic(err) - } - return req -} - -func TestMethodHandler(t *testing.T) { - tests := []struct { - req *http.Request - handler http.Handler - code int - allow string // Contents of the Allow header - body string - }{ - // No handlers - {newRequest("GET", "/foo"), MethodHandler{}, http.StatusMethodNotAllowed, "", notAllowed}, - {newRequest("OPTIONS", "/foo"), MethodHandler{}, http.StatusOK, "", ""}, - - // A single handler - {newRequest("GET", "/foo"), MethodHandler{"GET": okHandler}, http.StatusOK, "", ok}, - {newRequest("POST", "/foo"), MethodHandler{"GET": okHandler}, http.StatusMethodNotAllowed, "GET", notAllowed}, - - // Multiple handlers - {newRequest("GET", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusOK, "", ok}, - {newRequest("POST", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusOK, "", ok}, - {newRequest("DELETE", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusMethodNotAllowed, "GET, POST", notAllowed}, - {newRequest("OPTIONS", "/foo"), MethodHandler{"GET": okHandler, "POST": okHandler}, http.StatusOK, "GET, POST", ""}, - - // Override OPTIONS - {newRequest("OPTIONS", "/foo"), MethodHandler{"OPTIONS": okHandler}, http.StatusOK, "", ok}, - } - - for i, test := range tests { - rec := httptest.NewRecorder() - test.handler.ServeHTTP(rec, test.req) - if rec.Code != test.code { - t.Fatalf("%d: wrong code, got %d want %d", i, rec.Code, test.code) - } - if allow := rec.HeaderMap.Get("Allow"); allow != test.allow { - t.Fatalf("%d: wrong Allow, got %s want %s", i, allow, test.allow) - } - if body := rec.Body.String(); body != test.body { - t.Fatalf("%d: wrong body, got %q want %q", i, body, test.body) - } - } -} - -func TestWriteLog(t *testing.T) { - loc, err := time.LoadLocation("Europe/Warsaw") - if err != nil { - panic(err) - } - ts := time.Date(1983, 05, 26, 3, 30, 45, 0, loc) - - // A typical request with an OK response - req := newRequest("GET", "http://example.com") - req.RemoteAddr = "192.168.100.5" - - buf := new(bytes.Buffer) - writeLog(buf, req, *req.URL, ts, http.StatusOK, 100) - log := buf.String() - - expected := "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // CONNECT request over http/2.0 - req = &http.Request{ - Method: "CONNECT", - Proto: "HTTP/2.0", - ProtoMajor: 2, - ProtoMinor: 0, - URL: &url.URL{Host: "www.example.com:443"}, - Host: "www.example.com:443", - RemoteAddr: "192.168.100.5", - } - - buf = new(bytes.Buffer) - writeLog(buf, req, *req.URL, ts, http.StatusOK, 100) - log = buf.String() - - expected = "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"CONNECT www.example.com:443 HTTP/2.0\" 200 100\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // Request with an unauthorized user - req = newRequest("GET", "http://example.com") - req.RemoteAddr = "192.168.100.5" - req.URL.User = url.User("kamil") - - buf.Reset() - writeLog(buf, req, *req.URL, ts, http.StatusUnauthorized, 500) - log = buf.String() - - expected = "192.168.100.5 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 401 500\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // Request with url encoded parameters - req = newRequest("GET", "http://example.com/test?abc=hello%20world&a=b%3F") - req.RemoteAddr = "192.168.100.5" - - buf.Reset() - writeLog(buf, req, *req.URL, ts, http.StatusOK, 100) - log = buf.String() - - expected = "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"GET /test?abc=hello%20world&a=b%3F HTTP/1.1\" 200 100\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } -} - -func TestWriteCombinedLog(t *testing.T) { - loc, err := time.LoadLocation("Europe/Warsaw") - if err != nil { - panic(err) - } - ts := time.Date(1983, 05, 26, 3, 30, 45, 0, loc) - - // A typical request with an OK response - req := newRequest("GET", "http://example.com") - req.RemoteAddr = "192.168.100.5" - req.Header.Set("Referer", "http://example.com") - req.Header.Set( - "User-Agent", - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.33 "+ - "(KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33", - ) - - buf := new(bytes.Buffer) - writeCombinedLog(buf, req, *req.URL, ts, http.StatusOK, 100) - log := buf.String() - - expected := "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100 \"http://example.com\" " + - "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + - "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // CONNECT request over http/2.0 - req1 := &http.Request{ - Method: "CONNECT", - Host: "www.example.com:443", - Proto: "HTTP/2.0", - ProtoMajor: 2, - ProtoMinor: 0, - RemoteAddr: "192.168.100.5", - Header: http.Header{}, - URL: &url.URL{Host: "www.example.com:443"}, - } - req1.Header.Set("Referer", "http://example.com") - req1.Header.Set( - "User-Agent", - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.33 "+ - "(KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33", - ) - - buf = new(bytes.Buffer) - writeCombinedLog(buf, req1, *req1.URL, ts, http.StatusOK, 100) - log = buf.String() - - expected = "192.168.100.5 - - [26/May/1983:03:30:45 +0200] \"CONNECT www.example.com:443 HTTP/2.0\" 200 100 \"http://example.com\" " + - "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + - "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // Request with an unauthorized user - req.URL.User = url.User("kamil") - - buf.Reset() - writeCombinedLog(buf, req, *req.URL, ts, http.StatusUnauthorized, 500) - log = buf.String() - - expected = "192.168.100.5 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 401 500 \"http://example.com\" " + - "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + - "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // Test with remote ipv6 address - req.RemoteAddr = "::1" - - buf.Reset() - writeCombinedLog(buf, req, *req.URL, ts, http.StatusOK, 100) - log = buf.String() - - expected = "::1 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100 \"http://example.com\" " + - "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + - "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } - - // Test remote ipv6 addr, with port - req.RemoteAddr = net.JoinHostPort("::1", "65000") - - buf.Reset() - writeCombinedLog(buf, req, *req.URL, ts, http.StatusOK, 100) - log = buf.String() - - expected = "::1 - kamil [26/May/1983:03:30:45 +0200] \"GET / HTTP/1.1\" 200 100 \"http://example.com\" " + - "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) " + - "AppleWebKit/537.33 (KHTML, like Gecko) Chrome/27.0.1430.0 Safari/537.33\"\n" - if log != expected { - t.Fatalf("wrong log, got %q want %q", log, expected) - } -} - -func TestLogPathRewrites(t *testing.T) { - var buf bytes.Buffer - - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - req.URL.Path = "/" // simulate http.StripPrefix and friends - w.WriteHeader(200) - }) - logger := LoggingHandler(&buf, handler) - - logger.ServeHTTP(httptest.NewRecorder(), newRequest("GET", "/subdir/asdf")) - - if !strings.Contains(buf.String(), "GET /subdir/asdf HTTP") { - t.Fatalf("Got log %#v, wanted substring %#v", buf.String(), "GET /subdir/asdf HTTP") - } -} - -func BenchmarkWriteLog(b *testing.B) { - loc, err := time.LoadLocation("Europe/Warsaw") - if err != nil { - b.Fatalf(err.Error()) - } - ts := time.Date(1983, 05, 26, 3, 30, 45, 0, loc) - - req := newRequest("GET", "http://example.com") - req.RemoteAddr = "192.168.100.5" - - b.ResetTimer() - - buf := &bytes.Buffer{} - for i := 0; i < b.N; i++ { - buf.Reset() - writeLog(buf, req, *req.URL, ts, http.StatusUnauthorized, 500) - } -} - -func TestContentTypeHandler(t *testing.T) { - tests := []struct { - Method string - AllowContentTypes []string - ContentType string - Code int - }{ - {"POST", []string{"application/json"}, "application/json", http.StatusOK}, - {"POST", []string{"application/json", "application/xml"}, "application/json", http.StatusOK}, - {"POST", []string{"application/json"}, "application/json; charset=utf-8", http.StatusOK}, - {"POST", []string{"application/json"}, "application/json+xxx", http.StatusUnsupportedMediaType}, - {"POST", []string{"application/json"}, "text/plain", http.StatusUnsupportedMediaType}, - {"GET", []string{"application/json"}, "", http.StatusOK}, - {"GET", []string{}, "", http.StatusOK}, - } - for _, test := range tests { - r, err := http.NewRequest(test.Method, "/", nil) - if err != nil { - t.Error(err) - continue - } - - h := ContentTypeHandler(okHandler, test.AllowContentTypes...) - r.Header.Set("Content-Type", test.ContentType) - w := httptest.NewRecorder() - h.ServeHTTP(w, r) - if w.Code != test.Code { - t.Errorf("expected %d, got %d", test.Code, w.Code) - } - } -} - -func TestHTTPMethodOverride(t *testing.T) { - var tests = []struct { - Method string - OverrideMethod string - ExpectedMethod string - }{ - {"POST", "PUT", "PUT"}, - {"POST", "PATCH", "PATCH"}, - {"POST", "DELETE", "DELETE"}, - {"PUT", "DELETE", "PUT"}, - {"GET", "GET", "GET"}, - {"HEAD", "HEAD", "HEAD"}, - {"GET", "PUT", "GET"}, - {"HEAD", "DELETE", "HEAD"}, - } - - for _, test := range tests { - h := HTTPMethodOverrideHandler(okHandler) - reqs := make([]*http.Request, 0, 2) - - rHeader, err := http.NewRequest(test.Method, "/", nil) - if err != nil { - t.Error(err) - } - rHeader.Header.Set(HTTPMethodOverrideHeader, test.OverrideMethod) - reqs = append(reqs, rHeader) - - f := url.Values{HTTPMethodOverrideFormKey: []string{test.OverrideMethod}} - rForm, err := http.NewRequest(test.Method, "/", strings.NewReader(f.Encode())) - if err != nil { - t.Error(err) - } - rForm.Header.Set("Content-Type", "application/x-www-form-urlencoded") - reqs = append(reqs, rForm) - - for _, r := range reqs { - w := httptest.NewRecorder() - h.ServeHTTP(w, r) - if r.Method != test.ExpectedMethod { - t.Errorf("Expected %s, got %s", test.ExpectedMethod, r.Method) - } - } - } -} diff --git a/vendor/github.com/gorilla/handlers/proxy_headers_test.go b/vendor/github.com/gorilla/handlers/proxy_headers_test.go deleted file mode 100644 index 85282ef7..00000000 --- a/vendor/github.com/gorilla/handlers/proxy_headers_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package handlers - -import ( - "net/http" - "net/http/httptest" - "testing" -) - -type headerTable struct { - key string // header key - val string // header val - expected string // expected result -} - -func TestGetIP(t *testing.T) { - headers := []headerTable{ - {xForwardedFor, "8.8.8.8", "8.8.8.8"}, // Single address - {xForwardedFor, "8.8.8.8, 8.8.4.4", "8.8.8.8"}, // Multiple - {xForwardedFor, "[2001:db8:cafe::17]:4711", "[2001:db8:cafe::17]:4711"}, // IPv6 address - {xForwardedFor, "", ""}, // None - {xRealIP, "8.8.8.8", "8.8.8.8"}, // Single address - {xRealIP, "8.8.8.8, 8.8.4.4", "8.8.8.8, 8.8.4.4"}, // Multiple - {xRealIP, "[2001:db8:cafe::17]:4711", "[2001:db8:cafe::17]:4711"}, // IPv6 address - {xRealIP, "", ""}, // None - {forwarded, `for="_gazonk"`, "_gazonk"}, // Hostname - {forwarded, `For="[2001:db8:cafe::17]:4711`, `[2001:db8:cafe::17]:4711`}, // IPv6 address - {forwarded, `for=192.0.2.60;proto=http;by=203.0.113.43`, `192.0.2.60`}, // Multiple params - {forwarded, `for=192.0.2.43, for=198.51.100.17`, "192.0.2.43"}, // Multiple params - {forwarded, `for="workstation.local",for=198.51.100.17`, "workstation.local"}, // Hostname - } - - for _, v := range headers { - req := &http.Request{ - Header: http.Header{ - v.key: []string{v.val}, - }} - res := getIP(req) - if res != v.expected { - t.Fatalf("wrong header for %s: got %s want %s", v.key, res, - v.expected) - } - } -} - -func TestGetScheme(t *testing.T) { - headers := []headerTable{ - {xForwardedProto, "https", "https"}, - {xForwardedProto, "http", "http"}, - {xForwardedProto, "HTTP", "http"}, - {forwarded, `For="[2001:db8:cafe::17]:4711`, ""}, // No proto - {forwarded, `for=192.0.2.43, for=198.51.100.17;proto=https`, "https"}, // Multiple params before proto - {forwarded, `for=172.32.10.15; proto=https;by=127.0.0.1`, "https"}, // Space before proto - {forwarded, `for=192.0.2.60;proto=http;by=203.0.113.43`, "http"}, // Multiple params - } - - for _, v := range headers { - req := &http.Request{ - Header: http.Header{ - v.key: []string{v.val}, - }, - } - res := getScheme(req) - if res != v.expected { - t.Fatalf("wrong header for %s: got %s want %s", v.key, res, - v.expected) - } - } -} - -// Test the middleware end-to-end -func TestProxyHeaders(t *testing.T) { - rr := httptest.NewRecorder() - r := newRequest("GET", "/") - - r.Header.Set(xForwardedFor, "8.8.8.8") - r.Header.Set(xForwardedProto, "https") - - var addr string - var proto string - ProxyHeaders(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - addr = r.RemoteAddr - proto = r.URL.Scheme - })).ServeHTTP(rr, r) - - if rr.Code != http.StatusOK { - t.Fatalf("bad status: got %d want %d", rr.Code, http.StatusOK) - } - - if addr != r.Header.Get(xForwardedFor) { - t.Fatalf("wrong address: got %s want %s", addr, - r.Header.Get(xForwardedFor)) - } - - if proto != r.Header.Get(xForwardedProto) { - t.Fatalf("wrong address: got %s want %s", proto, - r.Header.Get(xForwardedProto)) - } - -} diff --git a/vendor/github.com/gorilla/handlers/recovery_test.go b/vendor/github.com/gorilla/handlers/recovery_test.go deleted file mode 100644 index 1ae0e580..00000000 --- a/vendor/github.com/gorilla/handlers/recovery_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package handlers - -import ( - "bytes" - "log" - "net/http" - "net/http/httptest" - "strings" - "testing" -) - -func TestRecoveryLoggerWithDefaultOptions(t *testing.T) { - var buf bytes.Buffer - log.SetOutput(&buf) - - handler := RecoveryHandler() - handlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - panic("Unexpected error!") - }) - - recovery := handler(handlerFunc) - recovery.ServeHTTP(httptest.NewRecorder(), newRequest("GET", "/subdir/asdf")) - - if !strings.Contains(buf.String(), "Unexpected error!") { - t.Fatalf("Got log %#v, wanted substring %#v", buf.String(), "Unexpected error!") - } -} - -func TestRecoveryLoggerWithCustomLogger(t *testing.T) { - var buf bytes.Buffer - var logger = log.New(&buf, "", log.LstdFlags) - - handler := RecoveryHandler(RecoveryLogger(logger), PrintRecoveryStack(false)) - handlerFunc := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - panic("Unexpected error!") - }) - - recovery := handler(handlerFunc) - recovery.ServeHTTP(httptest.NewRecorder(), newRequest("GET", "/subdir/asdf")) - - if !strings.Contains(buf.String(), "Unexpected error!") { - t.Fatalf("Got log %#v, wanted substring %#v", buf.String(), "Unexpected error!") - } -} diff --git a/vendor/github.com/gorilla/mux/bench_test.go b/vendor/github.com/gorilla/mux/bench_test.go deleted file mode 100644 index 946289b9..00000000 --- a/vendor/github.com/gorilla/mux/bench_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// 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 ( - "net/http" - "net/http/httptest" - "testing" -) - -func BenchmarkMux(b *testing.B) { - router := new(Router) - handler := func(w http.ResponseWriter, r *http.Request) {} - router.HandleFunc("/v1/{v1}", handler) - - request, _ := http.NewRequest("GET", "/v1/anything", nil) - for i := 0; i < b.N; i++ { - router.ServeHTTP(nil, request) - } -} - -func BenchmarkMuxAlternativeInRegexp(b *testing.B) { - router := new(Router) - handler := func(w http.ResponseWriter, r *http.Request) {} - router.HandleFunc("/v1/{v1:(a|b)}", handler) - - requestA, _ := http.NewRequest("GET", "/v1/a", nil) - requestB, _ := http.NewRequest("GET", "/v1/b", nil) - for i := 0; i < b.N; i++ { - router.ServeHTTP(nil, requestA) - router.ServeHTTP(nil, requestB) - } -} - -func BenchmarkManyPathVariables(b *testing.B) { - router := new(Router) - handler := func(w http.ResponseWriter, r *http.Request) {} - router.HandleFunc("/v1/{v1}/{v2}/{v3}/{v4}/{v5}", handler) - - matchingRequest, _ := http.NewRequest("GET", "/v1/1/2/3/4/5", nil) - notMatchingRequest, _ := http.NewRequest("GET", "/v1/1/2/3/4", nil) - recorder := httptest.NewRecorder() - for i := 0; i < b.N; i++ { - router.ServeHTTP(nil, matchingRequest) - router.ServeHTTP(recorder, notMatchingRequest) - } -} diff --git a/vendor/github.com/gorilla/mux/mux_test.go b/vendor/github.com/gorilla/mux/mux_test.go deleted file mode 100644 index a44d03f8..00000000 --- a/vendor/github.com/gorilla/mux/mux_test.go +++ /dev/null @@ -1,1453 +0,0 @@ -// 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" - "strings" - "testing" - - "github.com/gorilla/context" -) - -func (r *Route) GoString() string { - matchers := make([]string, len(r.matchers)) - for i, m := range r.matchers { - matchers[i] = fmt.Sprintf("%#v", m) - } - return fmt.Sprintf("&Route{matchers:[]matcher{%s}}", strings.Join(matchers, ", ")) -} - -func (r *routeRegexp) GoString() string { - return fmt.Sprintf("&routeRegexp{template: %q, matchHost: %t, matchQuery: %t, strictSlash: %t, regexp: regexp.MustCompile(%q), reverse: %q, varsN: %v, varsR: %v", r.template, r.matchHost, r.matchQuery, r.strictSlash, r.regexp.String(), r.reverse, r.varsN, r.varsR) -} - -type routeTest struct { - title string // title of the test - route *Route // the route being tested - request *http.Request // a request to test the route - vars map[string]string // the expected vars of the match - host string // the expected host of the match - path string // the expected path of the match - path_template string // the expected path template to match - host_template string // the expected host template to match - shouldMatch bool // whether the request is expected to match the route at all - shouldRedirect bool // whether the request should result in a redirect -} - -func TestHost(t *testing.T) { - // newRequestHost a new request with a method, url, and host header - newRequestHost := func(method, url, host string) *http.Request { - req, err := http.NewRequest(method, url, nil) - if err != nil { - panic(err) - } - req.Host = host - return req - } - - tests := []routeTest{ - { - title: "Host route match", - route: new(Route).Host("aaa.bbb.ccc"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{}, - host: "aaa.bbb.ccc", - path: "", - shouldMatch: true, - }, - { - title: "Host route, wrong host in request URL", - route: new(Route).Host("aaa.bbb.ccc"), - request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), - vars: map[string]string{}, - host: "aaa.bbb.ccc", - path: "", - shouldMatch: false, - }, - { - title: "Host route with port, match", - route: new(Route).Host("aaa.bbb.ccc:1234"), - request: newRequest("GET", "http://aaa.bbb.ccc:1234/111/222/333"), - vars: map[string]string{}, - host: "aaa.bbb.ccc:1234", - path: "", - shouldMatch: true, - }, - { - title: "Host route with port, wrong port in request URL", - route: new(Route).Host("aaa.bbb.ccc:1234"), - request: newRequest("GET", "http://aaa.bbb.ccc:9999/111/222/333"), - vars: map[string]string{}, - host: "aaa.bbb.ccc:1234", - path: "", - shouldMatch: false, - }, - { - title: "Host route, match with host in request header", - route: new(Route).Host("aaa.bbb.ccc"), - request: newRequestHost("GET", "/111/222/333", "aaa.bbb.ccc"), - vars: map[string]string{}, - host: "aaa.bbb.ccc", - path: "", - shouldMatch: true, - }, - { - title: "Host route, wrong host in request header", - route: new(Route).Host("aaa.bbb.ccc"), - request: newRequestHost("GET", "/111/222/333", "aaa.222.ccc"), - vars: map[string]string{}, - host: "aaa.bbb.ccc", - path: "", - shouldMatch: false, - }, - // BUG {new(Route).Host("aaa.bbb.ccc:1234"), newRequestHost("GET", "/111/222/333", "aaa.bbb.ccc:1234"), map[string]string{}, "aaa.bbb.ccc:1234", "", true}, - { - title: "Host route with port, wrong host in request header", - route: new(Route).Host("aaa.bbb.ccc:1234"), - request: newRequestHost("GET", "/111/222/333", "aaa.bbb.ccc:9999"), - vars: map[string]string{}, - host: "aaa.bbb.ccc:1234", - path: "", - shouldMatch: false, - }, - { - title: "Host route with pattern, match", - route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v1": "bbb"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `aaa.{v1:[a-z]{3}}.ccc`, - shouldMatch: true, - }, - { - title: "Host route with pattern, additional capturing group, match", - route: new(Route).Host("aaa.{v1:[a-z]{2}(b|c)}.ccc"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v1": "bbb"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `aaa.{v1:[a-z]{2}(b|c)}.ccc`, - shouldMatch: true, - }, - { - title: "Host route with pattern, wrong host in request URL", - route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc"), - request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), - vars: map[string]string{"v1": "bbb"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `aaa.{v1:[a-z]{3}}.ccc`, - shouldMatch: false, - }, - { - title: "Host route with multiple patterns, match", - route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, - shouldMatch: true, - }, - { - title: "Host route with multiple patterns, wrong host in request URL", - route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}"), - request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), - vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, - shouldMatch: false, - }, - { - title: "Host route with hyphenated name and pattern, match", - route: new(Route).Host("aaa.{v-1:[a-z]{3}}.ccc"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v-1": "bbb"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `aaa.{v-1:[a-z]{3}}.ccc`, - shouldMatch: true, - }, - { - title: "Host route with hyphenated name and pattern, additional capturing group, match", - route: new(Route).Host("aaa.{v-1:[a-z]{2}(b|c)}.ccc"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v-1": "bbb"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `aaa.{v-1:[a-z]{2}(b|c)}.ccc`, - shouldMatch: true, - }, - { - title: "Host route with multiple hyphenated names and patterns, match", - route: new(Route).Host("{v-1:[a-z]{3}}.{v-2:[a-z]{3}}.{v-3:[a-z]{3}}"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v-1": "aaa", "v-2": "bbb", "v-3": "ccc"}, - host: "aaa.bbb.ccc", - path: "", - host_template: `{v-1:[a-z]{3}}.{v-2:[a-z]{3}}.{v-3:[a-z]{3}}`, - shouldMatch: true, - }, - { - title: "Path route with single pattern with pipe, match", - route: new(Route).Path("/{category:a|b/c}"), - request: newRequest("GET", "http://localhost/a"), - vars: map[string]string{"category": "a"}, - host: "", - path: "/a", - path_template: `/{category:a|b/c}`, - shouldMatch: true, - }, - { - title: "Path route with single pattern with pipe, match", - route: new(Route).Path("/{category:a|b/c}"), - request: newRequest("GET", "http://localhost/b/c"), - vars: map[string]string{"category": "b/c"}, - host: "", - path: "/b/c", - path_template: `/{category:a|b/c}`, - shouldMatch: true, - }, - { - title: "Path route with multiple patterns with pipe, match", - route: new(Route).Path("/{category:a|b/c}/{product}/{id:[0-9]+}"), - request: newRequest("GET", "http://localhost/a/product_name/1"), - vars: map[string]string{"category": "a", "product": "product_name", "id": "1"}, - host: "", - path: "/a/product_name/1", - path_template: `/{category:a|b/c}/{product}/{id:[0-9]+}`, - shouldMatch: true, - }, - { - title: "Path route with multiple patterns with pipe, match", - route: new(Route).Path("/{category:a|b/c}/{product}/{id:[0-9]+}"), - request: newRequest("GET", "http://localhost/b/c/product_name/1"), - vars: map[string]string{"category": "b/c", "product": "product_name", "id": "1"}, - host: "", - path: "/b/c/product_name/1", - path_template: `/{category:a|b/c}/{product}/{id:[0-9]+}`, - shouldMatch: true, - }, - } - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestPath(t *testing.T) { - tests := []routeTest{ - { - title: "Path route, match", - route: new(Route).Path("/111/222/333"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{}, - host: "", - path: "/111/222/333", - shouldMatch: true, - }, - { - title: "Path route, match with trailing slash in request and path", - route: new(Route).Path("/111/"), - request: newRequest("GET", "http://localhost/111/"), - vars: map[string]string{}, - host: "", - path: "/111/", - shouldMatch: true, - }, - { - title: "Path route, do not match with trailing slash in path", - route: new(Route).Path("/111/"), - request: newRequest("GET", "http://localhost/111"), - vars: map[string]string{}, - host: "", - path: "/111", - path_template: `/111/`, - shouldMatch: false, - }, - { - title: "Path route, do not match with trailing slash in request", - route: new(Route).Path("/111"), - request: newRequest("GET", "http://localhost/111/"), - vars: map[string]string{}, - host: "", - path: "/111/", - path_template: `/111`, - shouldMatch: false, - }, - { - title: "Path route, wrong path in request in request URL", - route: new(Route).Path("/111/222/333"), - request: newRequest("GET", "http://localhost/1/2/3"), - vars: map[string]string{}, - host: "", - path: "/111/222/333", - shouldMatch: false, - }, - { - title: "Path route with pattern, match", - route: new(Route).Path("/111/{v1:[0-9]{3}}/333"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{"v1": "222"}, - host: "", - path: "/111/222/333", - path_template: `/111/{v1:[0-9]{3}}/333`, - shouldMatch: true, - }, - { - title: "Path route with pattern, URL in request does not match", - route: new(Route).Path("/111/{v1:[0-9]{3}}/333"), - request: newRequest("GET", "http://localhost/111/aaa/333"), - vars: map[string]string{"v1": "222"}, - host: "", - path: "/111/222/333", - path_template: `/111/{v1:[0-9]{3}}/333`, - shouldMatch: false, - }, - { - title: "Path route with multiple patterns, match", - route: new(Route).Path("/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{"v1": "111", "v2": "222", "v3": "333"}, - host: "", - path: "/111/222/333", - path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}`, - shouldMatch: true, - }, - { - title: "Path route with multiple patterns, URL in request does not match", - route: new(Route).Path("/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/aaa/333"), - vars: map[string]string{"v1": "111", "v2": "222", "v3": "333"}, - host: "", - path: "/111/222/333", - path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}/{v3:[0-9]{3}}`, - shouldMatch: false, - }, - { - title: "Path route with multiple patterns with pipe, match", - route: new(Route).Path("/{category:a|(b/c)}/{product}/{id:[0-9]+}"), - request: newRequest("GET", "http://localhost/a/product_name/1"), - vars: map[string]string{"category": "a", "product": "product_name", "id": "1"}, - host: "", - path: "/a/product_name/1", - path_template: `/{category:a|(b/c)}/{product}/{id:[0-9]+}`, - shouldMatch: true, - }, - { - title: "Path route with hyphenated name and pattern, match", - route: new(Route).Path("/111/{v-1:[0-9]{3}}/333"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{"v-1": "222"}, - host: "", - path: "/111/222/333", - path_template: `/111/{v-1:[0-9]{3}}/333`, - shouldMatch: true, - }, - { - title: "Path route with multiple hyphenated names and patterns, match", - route: new(Route).Path("/{v-1:[0-9]{3}}/{v-2:[0-9]{3}}/{v-3:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{"v-1": "111", "v-2": "222", "v-3": "333"}, - host: "", - path: "/111/222/333", - path_template: `/{v-1:[0-9]{3}}/{v-2:[0-9]{3}}/{v-3:[0-9]{3}}`, - shouldMatch: true, - }, - { - title: "Path route with multiple hyphenated names and patterns with pipe, match", - route: new(Route).Path("/{product-category:a|(b/c)}/{product-name}/{product-id:[0-9]+}"), - request: newRequest("GET", "http://localhost/a/product_name/1"), - vars: map[string]string{"product-category": "a", "product-name": "product_name", "product-id": "1"}, - host: "", - path: "/a/product_name/1", - path_template: `/{product-category:a|(b/c)}/{product-name}/{product-id:[0-9]+}`, - shouldMatch: true, - }, - { - title: "Path route with multiple hyphenated names and patterns with pipe and case insensitive, match", - route: new(Route).Path("/{type:(?i:daily|mini|variety)}-{date:\\d{4,4}-\\d{2,2}-\\d{2,2}}"), - request: newRequest("GET", "http://localhost/daily-2016-01-01"), - vars: map[string]string{"type": "daily", "date": "2016-01-01"}, - host: "", - path: "/daily-2016-01-01", - path_template: `/{type:(?i:daily|mini|variety)}-{date:\d{4,4}-\d{2,2}-\d{2,2}}`, - shouldMatch: true, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestPathPrefix(t *testing.T) { - tests := []routeTest{ - { - title: "PathPrefix route, match", - route: new(Route).PathPrefix("/111"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{}, - host: "", - path: "/111", - shouldMatch: true, - }, - { - title: "PathPrefix route, match substring", - route: new(Route).PathPrefix("/1"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{}, - host: "", - path: "/1", - shouldMatch: true, - }, - { - title: "PathPrefix route, URL prefix in request does not match", - route: new(Route).PathPrefix("/111"), - request: newRequest("GET", "http://localhost/1/2/3"), - vars: map[string]string{}, - host: "", - path: "/111", - shouldMatch: false, - }, - { - title: "PathPrefix route with pattern, match", - route: new(Route).PathPrefix("/111/{v1:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{"v1": "222"}, - host: "", - path: "/111/222", - path_template: `/111/{v1:[0-9]{3}}`, - shouldMatch: true, - }, - { - title: "PathPrefix route with pattern, URL prefix in request does not match", - route: new(Route).PathPrefix("/111/{v1:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/aaa/333"), - vars: map[string]string{"v1": "222"}, - host: "", - path: "/111/222", - path_template: `/111/{v1:[0-9]{3}}`, - shouldMatch: false, - }, - { - title: "PathPrefix route with multiple patterns, match", - route: new(Route).PathPrefix("/{v1:[0-9]{3}}/{v2:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/222/333"), - vars: map[string]string{"v1": "111", "v2": "222"}, - host: "", - path: "/111/222", - path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}`, - shouldMatch: true, - }, - { - title: "PathPrefix route with multiple patterns, URL prefix in request does not match", - route: new(Route).PathPrefix("/{v1:[0-9]{3}}/{v2:[0-9]{3}}"), - request: newRequest("GET", "http://localhost/111/aaa/333"), - vars: map[string]string{"v1": "111", "v2": "222"}, - host: "", - path: "/111/222", - path_template: `/{v1:[0-9]{3}}/{v2:[0-9]{3}}`, - shouldMatch: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestHostPath(t *testing.T) { - tests := []routeTest{ - { - title: "Host and Path route, match", - route: new(Route).Host("aaa.bbb.ccc").Path("/111/222/333"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{}, - host: "", - path: "", - path_template: `/111/222/333`, - host_template: `aaa.bbb.ccc`, - shouldMatch: true, - }, - { - title: "Host and Path route, wrong host in request URL", - route: new(Route).Host("aaa.bbb.ccc").Path("/111/222/333"), - request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), - vars: map[string]string{}, - host: "", - path: "", - path_template: `/111/222/333`, - host_template: `aaa.bbb.ccc`, - shouldMatch: false, - }, - { - title: "Host and Path route with pattern, match", - route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc").Path("/111/{v2:[0-9]{3}}/333"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v1": "bbb", "v2": "222"}, - host: "aaa.bbb.ccc", - path: "/111/222/333", - path_template: `/111/{v2:[0-9]{3}}/333`, - host_template: `aaa.{v1:[a-z]{3}}.ccc`, - shouldMatch: true, - }, - { - title: "Host and Path route with pattern, URL in request does not match", - route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc").Path("/111/{v2:[0-9]{3}}/333"), - request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), - vars: map[string]string{"v1": "bbb", "v2": "222"}, - host: "aaa.bbb.ccc", - path: "/111/222/333", - path_template: `/111/{v2:[0-9]{3}}/333`, - host_template: `aaa.{v1:[a-z]{3}}.ccc`, - shouldMatch: false, - }, - { - title: "Host and Path route with multiple patterns, match", - route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}").Path("/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}"), - request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), - vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc", "v4": "111", "v5": "222", "v6": "333"}, - host: "aaa.bbb.ccc", - path: "/111/222/333", - path_template: `/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}`, - host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, - shouldMatch: true, - }, - { - title: "Host and Path route with multiple patterns, URL in request does not match", - route: new(Route).Host("{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}").Path("/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}"), - request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), - vars: map[string]string{"v1": "aaa", "v2": "bbb", "v3": "ccc", "v4": "111", "v5": "222", "v6": "333"}, - host: "aaa.bbb.ccc", - path: "/111/222/333", - path_template: `/{v4:[0-9]{3}}/{v5:[0-9]{3}}/{v6:[0-9]{3}}`, - host_template: `{v1:[a-z]{3}}.{v2:[a-z]{3}}.{v3:[a-z]{3}}`, - shouldMatch: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestHeaders(t *testing.T) { - // newRequestHeaders creates a new request with a method, url, and headers - newRequestHeaders := func(method, url string, headers map[string]string) *http.Request { - req, err := http.NewRequest(method, url, nil) - if err != nil { - panic(err) - } - for k, v := range headers { - req.Header.Add(k, v) - } - return req - } - - tests := []routeTest{ - { - title: "Headers route, match", - route: new(Route).Headers("foo", "bar", "baz", "ding"), - request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "bar", "baz": "ding"}), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Headers route, bad header values", - route: new(Route).Headers("foo", "bar", "baz", "ding"), - request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "bar", "baz": "dong"}), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Headers route, regex header values to match", - route: new(Route).Headers("foo", "ba[zr]"), - request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "bar"}), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Headers route, regex header values to match", - route: new(Route).HeadersRegexp("foo", "ba[zr]"), - request: newRequestHeaders("GET", "http://localhost", map[string]string{"foo": "baz"}), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } - -} - -func TestMethods(t *testing.T) { - tests := []routeTest{ - { - title: "Methods route, match GET", - route: new(Route).Methods("GET", "POST"), - request: newRequest("GET", "http://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Methods route, match POST", - route: new(Route).Methods("GET", "POST"), - request: newRequest("POST", "http://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Methods route, bad method", - route: new(Route).Methods("GET", "POST"), - request: newRequest("PUT", "http://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestQueries(t *testing.T) { - tests := []routeTest{ - { - title: "Queries route, match", - route: new(Route).Queries("foo", "bar", "baz", "ding"), - request: newRequest("GET", "http://localhost?foo=bar&baz=ding"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route, match with a query string", - route: new(Route).Host("www.example.com").Path("/api").Queries("foo", "bar", "baz", "ding"), - request: newRequest("GET", "http://www.example.com/api?foo=bar&baz=ding"), - vars: map[string]string{}, - host: "", - path: "", - path_template: `/api`, - host_template: `www.example.com`, - shouldMatch: true, - }, - { - title: "Queries route, match with a query string out of order", - route: new(Route).Host("www.example.com").Path("/api").Queries("foo", "bar", "baz", "ding"), - request: newRequest("GET", "http://www.example.com/api?baz=ding&foo=bar"), - vars: map[string]string{}, - host: "", - path: "", - path_template: `/api`, - host_template: `www.example.com`, - shouldMatch: true, - }, - { - title: "Queries route, bad query", - route: new(Route).Queries("foo", "bar", "baz", "ding"), - request: newRequest("GET", "http://localhost?foo=bar&baz=dong"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with pattern, match", - route: new(Route).Queries("foo", "{v1}"), - request: newRequest("GET", "http://localhost?foo=bar"), - vars: map[string]string{"v1": "bar"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with multiple patterns, match", - route: new(Route).Queries("foo", "{v1}", "baz", "{v2}"), - request: newRequest("GET", "http://localhost?foo=bar&baz=ding"), - vars: map[string]string{"v1": "bar", "v2": "ding"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with regexp pattern, match", - route: new(Route).Queries("foo", "{v1:[0-9]+}"), - request: newRequest("GET", "http://localhost?foo=10"), - vars: map[string]string{"v1": "10"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with regexp pattern, regexp does not match", - route: new(Route).Queries("foo", "{v1:[0-9]+}"), - request: newRequest("GET", "http://localhost?foo=a"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with regexp pattern with quantifier, match", - route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), - request: newRequest("GET", "http://localhost?foo=1"), - vars: map[string]string{"v1": "1"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with regexp pattern with quantifier, additional variable in query string, match", - route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), - request: newRequest("GET", "http://localhost?bar=2&foo=1"), - vars: map[string]string{"v1": "1"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with regexp pattern with quantifier, regexp does not match", - route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), - request: newRequest("GET", "http://localhost?foo=12"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with regexp pattern with quantifier, additional capturing group", - route: new(Route).Queries("foo", "{v1:[0-9]{1}(a|b)}"), - request: newRequest("GET", "http://localhost?foo=1a"), - vars: map[string]string{"v1": "1a"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with regexp pattern with quantifier, additional variable in query string, regexp does not match", - route: new(Route).Queries("foo", "{v1:[0-9]{1}}"), - request: newRequest("GET", "http://localhost?foo=12"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with hyphenated name, match", - route: new(Route).Queries("foo", "{v-1}"), - request: newRequest("GET", "http://localhost?foo=bar"), - vars: map[string]string{"v-1": "bar"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with multiple hyphenated names, match", - route: new(Route).Queries("foo", "{v-1}", "baz", "{v-2}"), - request: newRequest("GET", "http://localhost?foo=bar&baz=ding"), - vars: map[string]string{"v-1": "bar", "v-2": "ding"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with hyphenate name and pattern, match", - route: new(Route).Queries("foo", "{v-1:[0-9]+}"), - request: newRequest("GET", "http://localhost?foo=10"), - vars: map[string]string{"v-1": "10"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with hyphenated name and pattern with quantifier, additional capturing group", - route: new(Route).Queries("foo", "{v-1:[0-9]{1}(a|b)}"), - request: newRequest("GET", "http://localhost?foo=1a"), - vars: map[string]string{"v-1": "1a"}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with empty value, should match", - route: new(Route).Queries("foo", ""), - request: newRequest("GET", "http://localhost?foo=bar"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with empty value and no parameter in request, should not match", - route: new(Route).Queries("foo", ""), - request: newRequest("GET", "http://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with empty value and empty parameter in request, should match", - route: new(Route).Queries("foo", ""), - request: newRequest("GET", "http://localhost?foo="), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route with overlapping value, should not match", - route: new(Route).Queries("foo", "bar"), - request: newRequest("GET", "http://localhost?foo=barfoo"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with no parameter in request, should not match", - route: new(Route).Queries("foo", "{bar}"), - request: newRequest("GET", "http://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - { - title: "Queries route with empty parameter in request, should match", - route: new(Route).Queries("foo", "{bar}"), - request: newRequest("GET", "http://localhost?foo="), - vars: map[string]string{"foo": ""}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Queries route, bad submatch", - route: new(Route).Queries("foo", "bar", "baz", "ding"), - request: newRequest("GET", "http://localhost?fffoo=bar&baz=dingggg"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestSchemes(t *testing.T) { - tests := []routeTest{ - // Schemes - { - title: "Schemes route, match https", - route: new(Route).Schemes("https", "ftp"), - request: newRequest("GET", "https://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Schemes route, match ftp", - route: new(Route).Schemes("https", "ftp"), - request: newRequest("GET", "ftp://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "Schemes route, bad scheme", - route: new(Route).Schemes("https", "ftp"), - request: newRequest("GET", "http://localhost"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - } - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestMatcherFunc(t *testing.T) { - m := func(r *http.Request, m *RouteMatch) bool { - if r.URL.Host == "aaa.bbb.ccc" { - return true - } - return false - } - - tests := []routeTest{ - { - title: "MatchFunc route, match", - route: new(Route).MatcherFunc(m), - request: newRequest("GET", "http://aaa.bbb.ccc"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: true, - }, - { - title: "MatchFunc route, non-match", - route: new(Route).MatcherFunc(m), - request: newRequest("GET", "http://aaa.222.ccc"), - vars: map[string]string{}, - host: "", - path: "", - shouldMatch: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestBuildVarsFunc(t *testing.T) { - tests := []routeTest{ - { - title: "BuildVarsFunc set on route", - route: new(Route).Path(`/111/{v1:\d}{v2:.*}`).BuildVarsFunc(func(vars map[string]string) map[string]string { - vars["v1"] = "3" - vars["v2"] = "a" - return vars - }), - request: newRequest("GET", "http://localhost/111/2"), - path: "/111/3a", - path_template: `/111/{v1:\d}{v2:.*}`, - shouldMatch: true, - }, - { - title: "BuildVarsFunc set on route and parent route", - route: new(Route).PathPrefix(`/{v1:\d}`).BuildVarsFunc(func(vars map[string]string) map[string]string { - vars["v1"] = "2" - return vars - }).Subrouter().Path(`/{v2:\w}`).BuildVarsFunc(func(vars map[string]string) map[string]string { - vars["v2"] = "b" - return vars - }), - request: newRequest("GET", "http://localhost/1/a"), - path: "/2/b", - path_template: `/{v1:\d}/{v2:\w}`, - shouldMatch: true, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestSubRouter(t *testing.T) { - subrouter1 := new(Route).Host("{v1:[a-z]+}.google.com").Subrouter() - subrouter2 := new(Route).PathPrefix("/foo/{v1}").Subrouter() - - tests := []routeTest{ - { - route: subrouter1.Path("/{v2:[a-z]+}"), - request: newRequest("GET", "http://aaa.google.com/bbb"), - vars: map[string]string{"v1": "aaa", "v2": "bbb"}, - host: "aaa.google.com", - path: "/bbb", - path_template: `/{v2:[a-z]+}`, - host_template: `{v1:[a-z]+}.google.com`, - shouldMatch: true, - }, - { - route: subrouter1.Path("/{v2:[a-z]+}"), - request: newRequest("GET", "http://111.google.com/111"), - vars: map[string]string{"v1": "aaa", "v2": "bbb"}, - host: "aaa.google.com", - path: "/bbb", - path_template: `/{v2:[a-z]+}`, - host_template: `{v1:[a-z]+}.google.com`, - shouldMatch: false, - }, - { - route: subrouter2.Path("/baz/{v2}"), - request: newRequest("GET", "http://localhost/foo/bar/baz/ding"), - vars: map[string]string{"v1": "bar", "v2": "ding"}, - host: "", - path: "/foo/bar/baz/ding", - path_template: `/foo/{v1}/baz/{v2}`, - shouldMatch: true, - }, - { - route: subrouter2.Path("/baz/{v2}"), - request: newRequest("GET", "http://localhost/foo/bar"), - vars: map[string]string{"v1": "bar", "v2": "ding"}, - host: "", - path: "/foo/bar/baz/ding", - path_template: `/foo/{v1}/baz/{v2}`, - shouldMatch: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestNamedRoutes(t *testing.T) { - r1 := NewRouter() - r1.NewRoute().Name("a") - r1.NewRoute().Name("b") - r1.NewRoute().Name("c") - - r2 := r1.NewRoute().Subrouter() - r2.NewRoute().Name("d") - r2.NewRoute().Name("e") - r2.NewRoute().Name("f") - - r3 := r2.NewRoute().Subrouter() - r3.NewRoute().Name("g") - r3.NewRoute().Name("h") - r3.NewRoute().Name("i") - - if r1.namedRoutes == nil || len(r1.namedRoutes) != 9 { - t.Errorf("Expected 9 named routes, got %v", r1.namedRoutes) - } else if r1.Get("i") == nil { - t.Errorf("Subroute name not registered") - } -} - -func TestStrictSlash(t *testing.T) { - r := NewRouter() - r.StrictSlash(true) - - tests := []routeTest{ - { - title: "Redirect path without slash", - route: r.NewRoute().Path("/111/"), - request: newRequest("GET", "http://localhost/111"), - vars: map[string]string{}, - host: "", - path: "/111/", - shouldMatch: true, - shouldRedirect: true, - }, - { - title: "Do not redirect path with slash", - route: r.NewRoute().Path("/111/"), - request: newRequest("GET", "http://localhost/111/"), - vars: map[string]string{}, - host: "", - path: "/111/", - shouldMatch: true, - shouldRedirect: false, - }, - { - title: "Redirect path with slash", - route: r.NewRoute().Path("/111"), - request: newRequest("GET", "http://localhost/111/"), - vars: map[string]string{}, - host: "", - path: "/111", - shouldMatch: true, - shouldRedirect: true, - }, - { - title: "Do not redirect path without slash", - route: r.NewRoute().Path("/111"), - request: newRequest("GET", "http://localhost/111"), - vars: map[string]string{}, - host: "", - path: "/111", - shouldMatch: true, - shouldRedirect: false, - }, - { - title: "Propagate StrictSlash to subrouters", - route: r.NewRoute().PathPrefix("/static/").Subrouter().Path("/images/"), - request: newRequest("GET", "http://localhost/static/images"), - vars: map[string]string{}, - host: "", - path: "/static/images/", - shouldMatch: true, - shouldRedirect: true, - }, - { - title: "Ignore StrictSlash for path prefix", - route: r.NewRoute().PathPrefix("/static/"), - request: newRequest("GET", "http://localhost/static/logo.png"), - vars: map[string]string{}, - host: "", - path: "/static/", - shouldMatch: true, - shouldRedirect: false, - }, - } - - for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - } -} - -func TestWalkSingleDepth(t *testing.T) { - r0 := NewRouter() - r1 := NewRouter() - r2 := NewRouter() - - r0.Path("/g") - r0.Path("/o") - r0.Path("/d").Handler(r1) - r0.Path("/r").Handler(r2) - r0.Path("/a") - - r1.Path("/z") - r1.Path("/i") - r1.Path("/l") - r1.Path("/l") - - r2.Path("/i") - r2.Path("/l") - r2.Path("/l") - - paths := []string{"g", "o", "r", "i", "l", "l", "a"} - depths := []int{0, 0, 0, 1, 1, 1, 0} - i := 0 - err := r0.Walk(func(route *Route, router *Router, ancestors []*Route) error { - matcher := route.matchers[0].(*routeRegexp) - if matcher.template == "/d" { - return SkipRouter - } - if len(ancestors) != depths[i] { - t.Errorf(`Expected depth of %d at i = %d; got "%d"`, depths[i], i, len(ancestors)) - } - if matcher.template != "/"+paths[i] { - t.Errorf(`Expected "/%s" at i = %d; got "%s"`, paths[i], i, matcher.template) - } - i++ - return nil - }) - if err != nil { - panic(err) - } - if i != len(paths) { - t.Errorf("Expected %d routes, found %d", len(paths), i) - } -} - -func TestWalkNested(t *testing.T) { - router := NewRouter() - - g := router.Path("/g").Subrouter() - o := g.PathPrefix("/o").Subrouter() - r := o.PathPrefix("/r").Subrouter() - i := r.PathPrefix("/i").Subrouter() - l1 := i.PathPrefix("/l").Subrouter() - l2 := l1.PathPrefix("/l").Subrouter() - l2.Path("/a") - - paths := []string{"/g", "/g/o", "/g/o/r", "/g/o/r/i", "/g/o/r/i/l", "/g/o/r/i/l/l", "/g/o/r/i/l/l/a"} - idx := 0 - err := router.Walk(func(route *Route, router *Router, ancestors []*Route) error { - path := paths[idx] - tpl := route.regexp.path.template - if tpl != path { - t.Errorf(`Expected %s got %s`, path, tpl) - } - idx++ - return nil - }) - if err != nil { - panic(err) - } - if idx != len(paths) { - t.Errorf("Expected %d routes, found %d", len(paths), idx) - } -} - -func TestSubrouterErrorHandling(t *testing.T) { - superRouterCalled := false - subRouterCalled := false - - router := NewRouter() - router.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - superRouterCalled = true - }) - subRouter := router.PathPrefix("/bign8").Subrouter() - subRouter.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - subRouterCalled = true - }) - - req, _ := http.NewRequest("GET", "http://localhost/bign8/was/here", nil) - router.ServeHTTP(NewRecorder(), req) - - if superRouterCalled { - t.Error("Super router 404 handler called when sub-router 404 handler is available.") - } - if !subRouterCalled { - t.Error("Sub-router 404 handler was not called.") - } -} - -// ---------------------------------------------------------------------------- -// Helpers -// ---------------------------------------------------------------------------- - -func getRouteTemplate(route *Route) string { - host, err := route.GetHostTemplate() - if err != nil { - host = "none" - } - path, err := route.GetPathTemplate() - if err != nil { - path = "none" - } - return fmt.Sprintf("Host: %v, Path: %v", host, path) -} - -func testRoute(t *testing.T, test routeTest) { - request := test.request - route := test.route - vars := test.vars - shouldMatch := test.shouldMatch - host := test.host - path := test.path - url := test.host + test.path - shouldRedirect := test.shouldRedirect - - var match RouteMatch - ok := route.Match(request, &match) - if ok != shouldMatch { - msg := "Should match" - if !shouldMatch { - msg = "Should not match" - } - t.Errorf("(%v) %v:\nRoute: %#v\nRequest: %#v\nVars: %v\n", test.title, msg, route, request, vars) - return - } - if shouldMatch { - if test.vars != nil && !stringMapEqual(test.vars, match.Vars) { - t.Errorf("(%v) Vars not equal: expected %v, got %v", test.title, vars, match.Vars) - return - } - if host != "" { - u, _ := test.route.URLHost(mapToPairs(match.Vars)...) - if host != u.Host { - t.Errorf("(%v) URLHost not equal: expected %v, got %v -- %v", test.title, host, u.Host, getRouteTemplate(route)) - return - } - } - if path != "" { - u, _ := route.URLPath(mapToPairs(match.Vars)...) - if path != u.Path { - t.Errorf("(%v) URLPath not equal: expected %v, got %v -- %v", test.title, path, u.Path, getRouteTemplate(route)) - return - } - } - if url != "" { - u, _ := route.URL(mapToPairs(match.Vars)...) - if url != u.Host+u.Path { - t.Errorf("(%v) URL not equal: expected %v, got %v -- %v", test.title, url, u.Host+u.Path, getRouteTemplate(route)) - return - } - } - if shouldRedirect && match.Handler == nil { - t.Errorf("(%v) Did not redirect", test.title) - return - } - if !shouldRedirect && match.Handler != nil { - t.Errorf("(%v) Unexpected redirect", test.title) - return - } - } -} - -func testTemplate(t *testing.T, test routeTest) { - route := test.route - path_template := test.path_template - if len(path_template) == 0 { - path_template = test.path - } - host_template := test.host_template - if len(host_template) == 0 { - host_template = test.host - } - - path_tmpl, path_err := route.GetPathTemplate() - if path_err == nil && path_tmpl != path_template { - t.Errorf("(%v) GetPathTemplate not equal: expected %v, got %v", test.title, path_template, path_tmpl) - } - - host_tmpl, host_err := route.GetHostTemplate() - if host_err == nil && host_tmpl != host_template { - t.Errorf("(%v) GetHostTemplate not equal: expected %v, got %v", test.title, host_template, host_tmpl) - } -} - -// Tests that the context is cleared or not cleared properly depending on -// the configuration of the router -func TestKeepContext(t *testing.T) { - func1 := func(w http.ResponseWriter, r *http.Request) {} - - r := NewRouter() - r.HandleFunc("/", func1).Name("func1") - - req, _ := http.NewRequest("GET", "http://localhost/", nil) - context.Set(req, "t", 1) - - res := new(http.ResponseWriter) - r.ServeHTTP(*res, req) - - if _, ok := context.GetOk(req, "t"); ok { - t.Error("Context should have been cleared at end of request") - } - - r.KeepContext = true - - req, _ = http.NewRequest("GET", "http://localhost/", nil) - context.Set(req, "t", 1) - - r.ServeHTTP(*res, req) - if _, ok := context.GetOk(req, "t"); !ok { - t.Error("Context should NOT have been cleared at end of request") - } - -} - -type TestA301ResponseWriter struct { - hh http.Header - status int -} - -func (ho TestA301ResponseWriter) Header() http.Header { - return http.Header(ho.hh) -} - -func (ho TestA301ResponseWriter) Write(b []byte) (int, error) { - return 0, nil -} - -func (ho TestA301ResponseWriter) WriteHeader(code int) { - ho.status = code -} - -func Test301Redirect(t *testing.T) { - m := make(http.Header) - - func1 := func(w http.ResponseWriter, r *http.Request) {} - func2 := func(w http.ResponseWriter, r *http.Request) {} - - r := NewRouter() - r.HandleFunc("/api/", func2).Name("func2") - r.HandleFunc("/", func1).Name("func1") - - req, _ := http.NewRequest("GET", "http://localhost//api/?abc=def", nil) - - res := TestA301ResponseWriter{ - hh: m, - status: 0, - } - r.ServeHTTP(&res, req) - - if "http://localhost/api/?abc=def" != res.hh["Location"][0] { - t.Errorf("Should have complete URL with query string") - } -} - -// https://plus.google.com/101022900381697718949/posts/eWy6DjFJ6uW -func TestSubrouterHeader(t *testing.T) { - expected := "func1 response" - func1 := func(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, expected) - } - func2 := func(http.ResponseWriter, *http.Request) {} - - r := NewRouter() - s := r.Headers("SomeSpecialHeader", "").Subrouter() - s.HandleFunc("/", func1).Name("func1") - r.HandleFunc("/", func2).Name("func2") - - req, _ := http.NewRequest("GET", "http://localhost/", nil) - req.Header.Add("SomeSpecialHeader", "foo") - match := new(RouteMatch) - matched := r.Match(req, match) - if !matched { - t.Errorf("Should match request") - } - if match.Route.GetName() != "func1" { - t.Errorf("Expecting func1 handler, got %s", match.Route.GetName()) - } - resp := NewRecorder() - match.Handler.ServeHTTP(resp, req) - if resp.Body.String() != expected { - t.Errorf("Expecting %q", expected) - } -} - -// mapToPairs converts a string map to a slice of string pairs -func mapToPairs(m map[string]string) []string { - var i int - p := make([]string, len(m)*2) - for k, v := range m { - p[i] = k - p[i+1] = v - i += 2 - } - return p -} - -// stringMapEqual checks the equality of two string maps -func stringMapEqual(m1, m2 map[string]string) bool { - nil1 := m1 == nil - nil2 := m2 == nil - if nil1 != nil2 || len(m1) != len(m2) { - return false - } - for k, v := range m1 { - if v != m2[k] { - return false - } - } - return true -} - -// newRequest is a helper function to create a new request with a method and url -func newRequest(method, url string) *http.Request { - req, err := http.NewRequest(method, url, nil) - if err != nil { - panic(err) - } - return req -} diff --git a/vendor/github.com/gorilla/mux/old_test.go b/vendor/github.com/gorilla/mux/old_test.go deleted file mode 100644 index c385a251..00000000 --- a/vendor/github.com/gorilla/mux/old_test.go +++ /dev/null @@ -1,710 +0,0 @@ -// Old tests ported to Go1. This is a mess. Want to drop it one day. - -// Copyright 2011 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" - "net/http" - "testing" -) - -// ---------------------------------------------------------------------------- -// ResponseRecorder -// ---------------------------------------------------------------------------- -// 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. - -// ResponseRecorder is an implementation of http.ResponseWriter that -// records its mutations for later inspection in tests. -type ResponseRecorder struct { - Code int // the HTTP response code from WriteHeader - HeaderMap http.Header // the HTTP response headers - Body *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to - Flushed bool -} - -// NewRecorder returns an initialized ResponseRecorder. -func NewRecorder() *ResponseRecorder { - return &ResponseRecorder{ - HeaderMap: make(http.Header), - Body: new(bytes.Buffer), - } -} - -// Header returns the response headers. -func (rw *ResponseRecorder) Header() http.Header { - return rw.HeaderMap -} - -// Write always succeeds and writes to rw.Body, if not nil. -func (rw *ResponseRecorder) Write(buf []byte) (int, error) { - if rw.Body != nil { - rw.Body.Write(buf) - } - if rw.Code == 0 { - rw.Code = http.StatusOK - } - return len(buf), nil -} - -// WriteHeader sets rw.Code. -func (rw *ResponseRecorder) WriteHeader(code int) { - rw.Code = code -} - -// Flush sets rw.Flushed to true. -func (rw *ResponseRecorder) Flush() { - rw.Flushed = true -} - -// ---------------------------------------------------------------------------- - -func TestRouteMatchers(t *testing.T) { - var scheme, host, path, query, method string - var headers map[string]string - var resultVars map[bool]map[string]string - - router := NewRouter() - router.NewRoute().Host("{var1}.google.com"). - Path("/{var2:[a-z]+}/{var3:[0-9]+}"). - Queries("foo", "bar"). - Methods("GET"). - Schemes("https"). - Headers("x-requested-with", "XMLHttpRequest") - router.NewRoute().Host("www.{var4}.com"). - PathPrefix("/foo/{var5:[a-z]+}/{var6:[0-9]+}"). - Queries("baz", "ding"). - Methods("POST"). - Schemes("http"). - Headers("Content-Type", "application/json") - - reset := func() { - // Everything match. - scheme = "https" - host = "www.google.com" - path = "/product/42" - query = "?foo=bar" - method = "GET" - headers = map[string]string{"X-Requested-With": "XMLHttpRequest"} - resultVars = map[bool]map[string]string{ - true: {"var1": "www", "var2": "product", "var3": "42"}, - false: {}, - } - } - - reset2 := func() { - // Everything match. - scheme = "http" - host = "www.google.com" - path = "/foo/product/42/path/that/is/ignored" - query = "?baz=ding" - method = "POST" - headers = map[string]string{"Content-Type": "application/json"} - resultVars = map[bool]map[string]string{ - true: {"var4": "google", "var5": "product", "var6": "42"}, - false: {}, - } - } - - match := func(shouldMatch bool) { - url := scheme + "://" + host + path + query - request, _ := http.NewRequest(method, url, nil) - for key, value := range headers { - request.Header.Add(key, value) - } - - var routeMatch RouteMatch - matched := router.Match(request, &routeMatch) - if matched != shouldMatch { - // Need better messages. :) - if matched { - t.Errorf("Should match.") - } else { - t.Errorf("Should not match.") - } - } - - if matched { - currentRoute := routeMatch.Route - if currentRoute == nil { - t.Errorf("Expected a current route.") - } - vars := routeMatch.Vars - expectedVars := resultVars[shouldMatch] - if len(vars) != len(expectedVars) { - t.Errorf("Expected vars: %v Got: %v.", expectedVars, vars) - } - for name, value := range vars { - if expectedVars[name] != value { - t.Errorf("Expected vars: %v Got: %v.", expectedVars, vars) - } - } - } - } - - // 1st route -------------------------------------------------------------- - - // Everything match. - reset() - match(true) - - // Scheme doesn't match. - reset() - scheme = "http" - match(false) - - // Host doesn't match. - reset() - host = "www.mygoogle.com" - match(false) - - // Path doesn't match. - reset() - path = "/product/notdigits" - match(false) - - // Query doesn't match. - reset() - query = "?foo=baz" - match(false) - - // Method doesn't match. - reset() - method = "POST" - match(false) - - // Header doesn't match. - reset() - headers = map[string]string{} - match(false) - - // Everything match, again. - reset() - match(true) - - // 2nd route -------------------------------------------------------------- - - // Everything match. - reset2() - match(true) - - // Scheme doesn't match. - reset2() - scheme = "https" - match(false) - - // Host doesn't match. - reset2() - host = "sub.google.com" - match(false) - - // Path doesn't match. - reset2() - path = "/bar/product/42" - match(false) - - // Query doesn't match. - reset2() - query = "?foo=baz" - match(false) - - // Method doesn't match. - reset2() - method = "GET" - match(false) - - // Header doesn't match. - reset2() - headers = map[string]string{} - match(false) - - // Everything match, again. - reset2() - match(true) -} - -type headerMatcherTest struct { - matcher headerMatcher - headers map[string]string - result bool -} - -var headerMatcherTests = []headerMatcherTest{ - { - matcher: headerMatcher(map[string]string{"x-requested-with": "XMLHttpRequest"}), - headers: map[string]string{"X-Requested-With": "XMLHttpRequest"}, - result: true, - }, - { - matcher: headerMatcher(map[string]string{"x-requested-with": ""}), - headers: map[string]string{"X-Requested-With": "anything"}, - result: true, - }, - { - matcher: headerMatcher(map[string]string{"x-requested-with": "XMLHttpRequest"}), - headers: map[string]string{}, - result: false, - }, -} - -type hostMatcherTest struct { - matcher *Route - url string - vars map[string]string - result bool -} - -var hostMatcherTests = []hostMatcherTest{ - { - matcher: NewRouter().NewRoute().Host("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}"), - url: "http://abc.def.ghi/", - vars: map[string]string{"foo": "abc", "bar": "def", "baz": "ghi"}, - result: true, - }, - { - matcher: NewRouter().NewRoute().Host("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}"), - url: "http://a.b.c/", - vars: map[string]string{"foo": "abc", "bar": "def", "baz": "ghi"}, - result: false, - }, -} - -type methodMatcherTest struct { - matcher methodMatcher - method string - result bool -} - -var methodMatcherTests = []methodMatcherTest{ - { - matcher: methodMatcher([]string{"GET", "POST", "PUT"}), - method: "GET", - result: true, - }, - { - matcher: methodMatcher([]string{"GET", "POST", "PUT"}), - method: "POST", - result: true, - }, - { - matcher: methodMatcher([]string{"GET", "POST", "PUT"}), - method: "PUT", - result: true, - }, - { - matcher: methodMatcher([]string{"GET", "POST", "PUT"}), - method: "DELETE", - result: false, - }, -} - -type pathMatcherTest struct { - matcher *Route - url string - vars map[string]string - result bool -} - -var pathMatcherTests = []pathMatcherTest{ - { - matcher: NewRouter().NewRoute().Path("/{foo:[0-9][0-9][0-9]}/{bar:[0-9][0-9][0-9]}/{baz:[0-9][0-9][0-9]}"), - url: "http://localhost:8080/123/456/789", - vars: map[string]string{"foo": "123", "bar": "456", "baz": "789"}, - result: true, - }, - { - matcher: NewRouter().NewRoute().Path("/{foo:[0-9][0-9][0-9]}/{bar:[0-9][0-9][0-9]}/{baz:[0-9][0-9][0-9]}"), - url: "http://localhost:8080/1/2/3", - vars: map[string]string{"foo": "123", "bar": "456", "baz": "789"}, - result: false, - }, -} - -type schemeMatcherTest struct { - matcher schemeMatcher - url string - result bool -} - -var schemeMatcherTests = []schemeMatcherTest{ - { - matcher: schemeMatcher([]string{"http", "https"}), - url: "http://localhost:8080/", - result: true, - }, - { - matcher: schemeMatcher([]string{"http", "https"}), - url: "https://localhost:8080/", - result: true, - }, - { - matcher: schemeMatcher([]string{"https"}), - url: "http://localhost:8080/", - result: false, - }, - { - matcher: schemeMatcher([]string{"http"}), - url: "https://localhost:8080/", - result: false, - }, -} - -type urlBuildingTest struct { - route *Route - vars []string - url string -} - -var urlBuildingTests = []urlBuildingTest{ - { - route: new(Route).Host("foo.domain.com"), - vars: []string{}, - url: "http://foo.domain.com", - }, - { - route: new(Route).Host("{subdomain}.domain.com"), - vars: []string{"subdomain", "bar"}, - url: "http://bar.domain.com", - }, - { - route: new(Route).Host("foo.domain.com").Path("/articles"), - vars: []string{}, - url: "http://foo.domain.com/articles", - }, - { - route: new(Route).Path("/articles"), - vars: []string{}, - url: "/articles", - }, - { - route: new(Route).Path("/articles/{category}/{id:[0-9]+}"), - vars: []string{"category", "technology", "id", "42"}, - url: "/articles/technology/42", - }, - { - route: new(Route).Host("{subdomain}.domain.com").Path("/articles/{category}/{id:[0-9]+}"), - vars: []string{"subdomain", "foo", "category", "technology", "id", "42"}, - url: "http://foo.domain.com/articles/technology/42", - }, -} - -func TestHeaderMatcher(t *testing.T) { - for _, v := range headerMatcherTests { - request, _ := http.NewRequest("GET", "http://localhost:8080/", nil) - for key, value := range v.headers { - request.Header.Add(key, value) - } - var routeMatch RouteMatch - result := v.matcher.Match(request, &routeMatch) - if result != v.result { - if v.result { - t.Errorf("%#v: should match %v.", v.matcher, request.Header) - } else { - t.Errorf("%#v: should not match %v.", v.matcher, request.Header) - } - } - } -} - -func TestHostMatcher(t *testing.T) { - for _, v := range hostMatcherTests { - request, _ := http.NewRequest("GET", v.url, nil) - var routeMatch RouteMatch - result := v.matcher.Match(request, &routeMatch) - vars := routeMatch.Vars - if result != v.result { - if v.result { - t.Errorf("%#v: should match %v.", v.matcher, v.url) - } else { - t.Errorf("%#v: should not match %v.", v.matcher, v.url) - } - } - if result { - if len(vars) != len(v.vars) { - t.Errorf("%#v: vars length should be %v, got %v.", v.matcher, len(v.vars), len(vars)) - } - for name, value := range vars { - if v.vars[name] != value { - t.Errorf("%#v: expected value %v for key %v, got %v.", v.matcher, v.vars[name], name, value) - } - } - } else { - if len(vars) != 0 { - t.Errorf("%#v: vars length should be 0, got %v.", v.matcher, len(vars)) - } - } - } -} - -func TestMethodMatcher(t *testing.T) { - for _, v := range methodMatcherTests { - request, _ := http.NewRequest(v.method, "http://localhost:8080/", nil) - var routeMatch RouteMatch - result := v.matcher.Match(request, &routeMatch) - if result != v.result { - if v.result { - t.Errorf("%#v: should match %v.", v.matcher, v.method) - } else { - t.Errorf("%#v: should not match %v.", v.matcher, v.method) - } - } - } -} - -func TestPathMatcher(t *testing.T) { - for _, v := range pathMatcherTests { - request, _ := http.NewRequest("GET", v.url, nil) - var routeMatch RouteMatch - result := v.matcher.Match(request, &routeMatch) - vars := routeMatch.Vars - if result != v.result { - if v.result { - t.Errorf("%#v: should match %v.", v.matcher, v.url) - } else { - t.Errorf("%#v: should not match %v.", v.matcher, v.url) - } - } - if result { - if len(vars) != len(v.vars) { - t.Errorf("%#v: vars length should be %v, got %v.", v.matcher, len(v.vars), len(vars)) - } - for name, value := range vars { - if v.vars[name] != value { - t.Errorf("%#v: expected value %v for key %v, got %v.", v.matcher, v.vars[name], name, value) - } - } - } else { - if len(vars) != 0 { - t.Errorf("%#v: vars length should be 0, got %v.", v.matcher, len(vars)) - } - } - } -} - -func TestSchemeMatcher(t *testing.T) { - for _, v := range schemeMatcherTests { - request, _ := http.NewRequest("GET", v.url, nil) - var routeMatch RouteMatch - result := v.matcher.Match(request, &routeMatch) - if result != v.result { - if v.result { - t.Errorf("%#v: should match %v.", v.matcher, v.url) - } else { - t.Errorf("%#v: should not match %v.", v.matcher, v.url) - } - } - } -} - -func TestUrlBuilding(t *testing.T) { - - for _, v := range urlBuildingTests { - u, _ := v.route.URL(v.vars...) - url := u.String() - if url != v.url { - t.Errorf("expected %v, got %v", v.url, url) - /* - reversePath := "" - reverseHost := "" - if v.route.pathTemplate != nil { - reversePath = v.route.pathTemplate.Reverse - } - if v.route.hostTemplate != nil { - reverseHost = v.route.hostTemplate.Reverse - } - - t.Errorf("%#v:\nexpected: %q\ngot: %q\nreverse path: %q\nreverse host: %q", v.route, v.url, url, reversePath, reverseHost) - */ - } - } - - ArticleHandler := func(w http.ResponseWriter, r *http.Request) { - } - - router := NewRouter() - router.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).Name("article") - - url, _ := router.Get("article").URL("category", "technology", "id", "42") - expected := "/articles/technology/42" - if url.String() != expected { - t.Errorf("Expected %v, got %v", expected, url.String()) - } -} - -func TestMatchedRouteName(t *testing.T) { - routeName := "stock" - router := NewRouter() - route := router.NewRoute().Path("/products/").Name(routeName) - - url := "http://www.example.com/products/" - request, _ := http.NewRequest("GET", url, nil) - var rv RouteMatch - ok := router.Match(request, &rv) - - if !ok || rv.Route != route { - t.Errorf("Expected same route, got %+v.", rv.Route) - } - - retName := rv.Route.GetName() - if retName != routeName { - t.Errorf("Expected %q, got %q.", routeName, retName) - } -} - -func TestSubRouting(t *testing.T) { - // Example from docs. - router := NewRouter() - subrouter := router.NewRoute().Host("www.example.com").Subrouter() - route := subrouter.NewRoute().Path("/products/").Name("products") - - url := "http://www.example.com/products/" - request, _ := http.NewRequest("GET", url, nil) - var rv RouteMatch - ok := router.Match(request, &rv) - - if !ok || rv.Route != route { - t.Errorf("Expected same route, got %+v.", rv.Route) - } - - u, _ := router.Get("products").URL() - builtURL := u.String() - // Yay, subroute aware of the domain when building! - if builtURL != url { - t.Errorf("Expected %q, got %q.", url, builtURL) - } -} - -func TestVariableNames(t *testing.T) { - route := new(Route).Host("{arg1}.domain.com").Path("/{arg1}/{arg2:[0-9]+}") - if route.err == nil { - t.Errorf("Expected error for duplicated variable names") - } -} - -func TestRedirectSlash(t *testing.T) { - var route *Route - var routeMatch RouteMatch - r := NewRouter() - - r.StrictSlash(false) - route = r.NewRoute() - if route.strictSlash != false { - t.Errorf("Expected false redirectSlash.") - } - - r.StrictSlash(true) - route = r.NewRoute() - if route.strictSlash != true { - t.Errorf("Expected true redirectSlash.") - } - - route = new(Route) - route.strictSlash = true - route.Path("/{arg1}/{arg2:[0-9]+}/") - request, _ := http.NewRequest("GET", "http://localhost/foo/123", nil) - routeMatch = RouteMatch{} - _ = route.Match(request, &routeMatch) - vars := routeMatch.Vars - if vars["arg1"] != "foo" { - t.Errorf("Expected foo.") - } - if vars["arg2"] != "123" { - t.Errorf("Expected 123.") - } - rsp := NewRecorder() - routeMatch.Handler.ServeHTTP(rsp, request) - if rsp.HeaderMap.Get("Location") != "http://localhost/foo/123/" { - t.Errorf("Expected redirect header.") - } - - route = new(Route) - route.strictSlash = true - route.Path("/{arg1}/{arg2:[0-9]+}") - request, _ = http.NewRequest("GET", "http://localhost/foo/123/", nil) - routeMatch = RouteMatch{} - _ = route.Match(request, &routeMatch) - vars = routeMatch.Vars - if vars["arg1"] != "foo" { - t.Errorf("Expected foo.") - } - if vars["arg2"] != "123" { - t.Errorf("Expected 123.") - } - rsp = NewRecorder() - routeMatch.Handler.ServeHTTP(rsp, request) - if rsp.HeaderMap.Get("Location") != "http://localhost/foo/123" { - t.Errorf("Expected redirect header.") - } -} - -// Test for the new regexp library, still not available in stable Go. -func TestNewRegexp(t *testing.T) { - var p *routeRegexp - var matches []string - - tests := map[string]map[string][]string{ - "/{foo:a{2}}": { - "/a": nil, - "/aa": {"aa"}, - "/aaa": nil, - "/aaaa": nil, - }, - "/{foo:a{2,}}": { - "/a": nil, - "/aa": {"aa"}, - "/aaa": {"aaa"}, - "/aaaa": {"aaaa"}, - }, - "/{foo:a{2,3}}": { - "/a": nil, - "/aa": {"aa"}, - "/aaa": {"aaa"}, - "/aaaa": nil, - }, - "/{foo:[a-z]{3}}/{bar:[a-z]{2}}": { - "/a": nil, - "/ab": nil, - "/abc": nil, - "/abcd": nil, - "/abc/ab": {"abc", "ab"}, - "/abc/abc": nil, - "/abcd/ab": nil, - }, - `/{foo:\w{3,}}/{bar:\d{2,}}`: { - "/a": nil, - "/ab": nil, - "/abc": nil, - "/abc/1": nil, - "/abc/12": {"abc", "12"}, - "/abcd/12": {"abcd", "12"}, - "/abcd/123": {"abcd", "123"}, - }, - } - - for pattern, paths := range tests { - p, _ = newRouteRegexp(pattern, false, false, false, false) - for path, result := range paths { - matches = p.regexp.FindStringSubmatch(path) - if result == nil { - if matches != nil { - t.Errorf("%v should not match %v.", pattern, path) - } - } else { - if len(matches) != len(result)+1 { - t.Errorf("Expected %v matches, got %v.", len(result)+1, len(matches)) - } else { - for k, v := range result { - if matches[k+1] != v { - t.Errorf("Expected %v, got %v.", v, matches[k+1]) - } - } - } - } - } - } -} diff --git a/vendor/github.com/gorilla/websocket/bench_test.go b/vendor/github.com/gorilla/websocket/bench_test.go deleted file mode 100644 index f66fc36b..00000000 --- a/vendor/github.com/gorilla/websocket/bench_test.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Gorilla WebSocket 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 websocket - -import ( - "testing" -) - -func BenchmarkMaskBytes(b *testing.B) { - var key [4]byte - data := make([]byte, 1024) - pos := 0 - for i := 0; i < b.N; i++ { - pos = maskBytes(key, pos, data) - } - b.SetBytes(int64(len(data))) -} diff --git a/vendor/github.com/gorilla/websocket/client_server_test.go b/vendor/github.com/gorilla/websocket/client_server_test.go deleted file mode 100644 index 3f7345dd..00000000 --- a/vendor/github.com/gorilla/websocket/client_server_test.go +++ /dev/null @@ -1,451 +0,0 @@ -// Copyright 2013 The Gorilla WebSocket 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 websocket - -import ( - "crypto/tls" - "crypto/x509" - "encoding/base64" - "io" - "io/ioutil" - "net" - "net/http" - "net/http/httptest" - "net/url" - "reflect" - "strings" - "testing" - "time" -) - -var cstUpgrader = Upgrader{ - Subprotocols: []string{"p0", "p1"}, - ReadBufferSize: 1024, - WriteBufferSize: 1024, - Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) { - http.Error(w, reason.Error(), status) - }, -} - -var cstDialer = Dialer{ - Subprotocols: []string{"p1", "p2"}, - ReadBufferSize: 1024, - WriteBufferSize: 1024, -} - -type cstHandler struct{ *testing.T } - -type cstServer struct { - *httptest.Server - URL string -} - -const ( - cstPath = "/a/b" - cstRawQuery = "x=y" - cstRequestURI = cstPath + "?" + cstRawQuery -) - -func newServer(t *testing.T) *cstServer { - var s cstServer - s.Server = httptest.NewServer(cstHandler{t}) - s.Server.URL += cstRequestURI - s.URL = makeWsProto(s.Server.URL) - return &s -} - -func newTLSServer(t *testing.T) *cstServer { - var s cstServer - s.Server = httptest.NewTLSServer(cstHandler{t}) - s.Server.URL += cstRequestURI - s.URL = makeWsProto(s.Server.URL) - return &s -} - -func (t cstHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if r.URL.Path != cstPath { - t.Logf("path=%v, want %v", r.URL.Path, cstPath) - http.Error(w, "bad path", 400) - return - } - if r.URL.RawQuery != cstRawQuery { - t.Logf("query=%v, want %v", r.URL.RawQuery, cstRawQuery) - http.Error(w, "bad path", 400) - return - } - subprotos := Subprotocols(r) - if !reflect.DeepEqual(subprotos, cstDialer.Subprotocols) { - t.Logf("subprotols=%v, want %v", subprotos, cstDialer.Subprotocols) - http.Error(w, "bad protocol", 400) - return - } - ws, err := cstUpgrader.Upgrade(w, r, http.Header{"Set-Cookie": {"sessionID=1234"}}) - if err != nil { - t.Logf("Upgrade: %v", err) - return - } - defer ws.Close() - - if ws.Subprotocol() != "p1" { - t.Logf("Subprotocol() = %s, want p1", ws.Subprotocol()) - ws.Close() - return - } - op, rd, err := ws.NextReader() - if err != nil { - t.Logf("NextReader: %v", err) - return - } - wr, err := ws.NextWriter(op) - if err != nil { - t.Logf("NextWriter: %v", err) - return - } - if _, err = io.Copy(wr, rd); err != nil { - t.Logf("NextWriter: %v", err) - return - } - if err := wr.Close(); err != nil { - t.Logf("Close: %v", err) - return - } -} - -func makeWsProto(s string) string { - return "ws" + strings.TrimPrefix(s, "http") -} - -func sendRecv(t *testing.T, ws *Conn) { - const message = "Hello World!" - if err := ws.SetWriteDeadline(time.Now().Add(time.Second)); err != nil { - t.Fatalf("SetWriteDeadline: %v", err) - } - if err := ws.WriteMessage(TextMessage, []byte(message)); err != nil { - t.Fatalf("WriteMessage: %v", err) - } - if err := ws.SetReadDeadline(time.Now().Add(time.Second)); err != nil { - t.Fatalf("SetReadDeadline: %v", err) - } - _, p, err := ws.ReadMessage() - if err != nil { - t.Fatalf("ReadMessage: %v", err) - } - if string(p) != message { - t.Fatalf("message=%s, want %s", p, message) - } -} - -func TestProxyDial(t *testing.T) { - - s := newServer(t) - defer s.Close() - - surl, _ := url.Parse(s.URL) - - cstDialer.Proxy = http.ProxyURL(surl) - - connect := false - origHandler := s.Server.Config.Handler - - // Capture the request Host header. - s.Server.Config.Handler = http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - if r.Method == "CONNECT" { - connect = true - w.WriteHeader(200) - return - } - - if !connect { - t.Log("connect not recieved") - http.Error(w, "connect not recieved", 405) - return - } - origHandler.ServeHTTP(w, r) - }) - - ws, _, err := cstDialer.Dial(s.URL, nil) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - sendRecv(t, ws) - - cstDialer.Proxy = http.ProxyFromEnvironment -} - -func TestProxyAuthorizationDial(t *testing.T) { - s := newServer(t) - defer s.Close() - - surl, _ := url.Parse(s.URL) - surl.User = url.UserPassword("username", "password") - cstDialer.Proxy = http.ProxyURL(surl) - - connect := false - origHandler := s.Server.Config.Handler - - // Capture the request Host header. - s.Server.Config.Handler = http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - proxyAuth := r.Header.Get("Proxy-Authorization") - expectedProxyAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte("username:password")) - if r.Method == "CONNECT" && proxyAuth == expectedProxyAuth { - connect = true - w.WriteHeader(200) - return - } - - if !connect { - t.Log("connect with proxy authorization not recieved") - http.Error(w, "connect with proxy authorization not recieved", 405) - return - } - origHandler.ServeHTTP(w, r) - }) - - ws, _, err := cstDialer.Dial(s.URL, nil) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - sendRecv(t, ws) - - cstDialer.Proxy = http.ProxyFromEnvironment -} - -func TestDial(t *testing.T) { - s := newServer(t) - defer s.Close() - - ws, _, err := cstDialer.Dial(s.URL, nil) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - sendRecv(t, ws) -} - -func TestDialTLS(t *testing.T) { - s := newTLSServer(t) - defer s.Close() - - certs := x509.NewCertPool() - for _, c := range s.TLS.Certificates { - roots, err := x509.ParseCertificates(c.Certificate[len(c.Certificate)-1]) - if err != nil { - t.Fatalf("error parsing server's root cert: %v", err) - } - for _, root := range roots { - certs.AddCert(root) - } - } - - u, _ := url.Parse(s.URL) - d := cstDialer - d.NetDial = func(network, addr string) (net.Conn, error) { return net.Dial(network, u.Host) } - d.TLSClientConfig = &tls.Config{RootCAs: certs} - ws, _, err := d.Dial("wss://example.com"+cstRequestURI, nil) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - sendRecv(t, ws) -} - -func xTestDialTLSBadCert(t *testing.T) { - // This test is deactivated because of noisy logging from the net/http package. - s := newTLSServer(t) - defer s.Close() - - ws, _, err := cstDialer.Dial(s.URL, nil) - if err == nil { - ws.Close() - t.Fatalf("Dial: nil") - } -} - -func xTestDialTLSNoVerify(t *testing.T) { - s := newTLSServer(t) - defer s.Close() - - d := cstDialer - d.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - ws, _, err := d.Dial(s.URL, nil) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - sendRecv(t, ws) -} - -func TestDialTimeout(t *testing.T) { - s := newServer(t) - defer s.Close() - - d := cstDialer - d.HandshakeTimeout = -1 - ws, _, err := d.Dial(s.URL, nil) - if err == nil { - ws.Close() - t.Fatalf("Dial: nil") - } -} - -func TestDialBadScheme(t *testing.T) { - s := newServer(t) - defer s.Close() - - ws, _, err := cstDialer.Dial(s.Server.URL, nil) - if err == nil { - ws.Close() - t.Fatalf("Dial: nil") - } -} - -func TestDialBadOrigin(t *testing.T) { - s := newServer(t) - defer s.Close() - - ws, resp, err := cstDialer.Dial(s.URL, http.Header{"Origin": {"bad"}}) - if err == nil { - ws.Close() - t.Fatalf("Dial: nil") - } - if resp == nil { - t.Fatalf("resp=nil, err=%v", err) - } - if resp.StatusCode != http.StatusForbidden { - t.Fatalf("status=%d, want %d", resp.StatusCode, http.StatusForbidden) - } -} - -func TestDialBadHeader(t *testing.T) { - s := newServer(t) - defer s.Close() - - for _, k := range []string{"Upgrade", - "Connection", - "Sec-Websocket-Key", - "Sec-Websocket-Version", - "Sec-Websocket-Protocol"} { - h := http.Header{} - h.Set(k, "bad") - ws, _, err := cstDialer.Dial(s.URL, http.Header{"Origin": {"bad"}}) - if err == nil { - ws.Close() - t.Errorf("Dial with header %s returned nil", k) - } - } -} - -func TestBadMethod(t *testing.T) { - s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ws, err := cstUpgrader.Upgrade(w, r, nil) - if err == nil { - t.Errorf("handshake succeeded, expect fail") - ws.Close() - } - })) - defer s.Close() - - resp, err := http.PostForm(s.URL, url.Values{}) - if err != nil { - t.Fatalf("PostForm returned error %v", err) - } - resp.Body.Close() - if resp.StatusCode != http.StatusMethodNotAllowed { - t.Errorf("Status = %d, want %d", resp.StatusCode, http.StatusMethodNotAllowed) - } -} - -func TestHandshake(t *testing.T) { - s := newServer(t) - defer s.Close() - - ws, resp, err := cstDialer.Dial(s.URL, http.Header{"Origin": {s.URL}}) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - - var sessionID string - for _, c := range resp.Cookies() { - if c.Name == "sessionID" { - sessionID = c.Value - } - } - if sessionID != "1234" { - t.Error("Set-Cookie not received from the server.") - } - - if ws.Subprotocol() != "p1" { - t.Errorf("ws.Subprotocol() = %s, want p1", ws.Subprotocol()) - } - sendRecv(t, ws) -} - -func TestRespOnBadHandshake(t *testing.T) { - const expectedStatus = http.StatusGone - const expectedBody = "This is the response body." - - s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(expectedStatus) - io.WriteString(w, expectedBody) - })) - defer s.Close() - - ws, resp, err := cstDialer.Dial(makeWsProto(s.URL), nil) - if err == nil { - ws.Close() - t.Fatalf("Dial: nil") - } - - if resp == nil { - t.Fatalf("resp=nil, err=%v", err) - } - - if resp.StatusCode != expectedStatus { - t.Errorf("resp.StatusCode=%d, want %d", resp.StatusCode, expectedStatus) - } - - p, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Fatalf("ReadFull(resp.Body) returned error %v", err) - } - - if string(p) != expectedBody { - t.Errorf("resp.Body=%s, want %s", p, expectedBody) - } -} - -// TestHostHeader confirms that the host header provided in the call to Dial is -// sent to the server. -func TestHostHeader(t *testing.T) { - s := newServer(t) - defer s.Close() - - specifiedHost := make(chan string, 1) - origHandler := s.Server.Config.Handler - - // Capture the request Host header. - s.Server.Config.Handler = http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - specifiedHost <- r.Host - origHandler.ServeHTTP(w, r) - }) - - ws, _, err := cstDialer.Dial(s.URL, http.Header{"Host": {"testhost"}}) - if err != nil { - t.Fatalf("Dial: %v", err) - } - defer ws.Close() - - if gotHost := <-specifiedHost; gotHost != "testhost" { - t.Fatalf("gotHost = %q, want \"testhost\"", gotHost) - } - - sendRecv(t, ws) -} diff --git a/vendor/github.com/gorilla/websocket/client_test.go b/vendor/github.com/gorilla/websocket/client_test.go deleted file mode 100644 index 7d2b0844..00000000 --- a/vendor/github.com/gorilla/websocket/client_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2014 The Gorilla WebSocket 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 websocket - -import ( - "net/url" - "reflect" - "testing" -) - -var parseURLTests = []struct { - s string - u *url.URL - rui string -}{ - {"ws://example.com/", &url.URL{Scheme: "ws", Host: "example.com", Opaque: "/"}, "/"}, - {"ws://example.com", &url.URL{Scheme: "ws", Host: "example.com", Opaque: "/"}, "/"}, - {"ws://example.com:7777/", &url.URL{Scheme: "ws", Host: "example.com:7777", Opaque: "/"}, "/"}, - {"wss://example.com/", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/"}, "/"}, - {"wss://example.com/a/b", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/a/b"}, "/a/b"}, - {"ss://example.com/a/b", nil, ""}, - {"ws://webmaster@example.com/", nil, ""}, - {"wss://example.com/a/b?x=y", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/a/b", RawQuery: "x=y"}, "/a/b?x=y"}, - {"wss://example.com?x=y", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/", RawQuery: "x=y"}, "/?x=y"}, -} - -func TestParseURL(t *testing.T) { - for _, tt := range parseURLTests { - u, err := parseURL(tt.s) - if tt.u != nil && err != nil { - t.Errorf("parseURL(%q) returned error %v", tt.s, err) - continue - } - if tt.u == nil { - if err == nil { - t.Errorf("parseURL(%q) did not return error", tt.s) - } - continue - } - if !reflect.DeepEqual(u, tt.u) { - t.Errorf("parseURL(%q) = %v, want %v", tt.s, u, tt.u) - continue - } - if u.RequestURI() != tt.rui { - t.Errorf("parseURL(%q).RequestURI() = %v, want %v", tt.s, u.RequestURI(), tt.rui) - } - } -} - -var hostPortNoPortTests = []struct { - u *url.URL - hostPort, hostNoPort string -}{ - {&url.URL{Scheme: "ws", Host: "example.com"}, "example.com:80", "example.com"}, - {&url.URL{Scheme: "wss", Host: "example.com"}, "example.com:443", "example.com"}, - {&url.URL{Scheme: "ws", Host: "example.com:7777"}, "example.com:7777", "example.com"}, - {&url.URL{Scheme: "wss", Host: "example.com:7777"}, "example.com:7777", "example.com"}, -} - -func TestHostPortNoPort(t *testing.T) { - for _, tt := range hostPortNoPortTests { - hostPort, hostNoPort := hostPortNoPort(tt.u) - if hostPort != tt.hostPort { - t.Errorf("hostPortNoPort(%v) returned hostPort %q, want %q", tt.u, hostPort, tt.hostPort) - } - if hostNoPort != tt.hostNoPort { - t.Errorf("hostPortNoPort(%v) returned hostNoPort %q, want %q", tt.u, hostNoPort, tt.hostNoPort) - } - } -} diff --git a/vendor/github.com/gorilla/websocket/conn_test.go b/vendor/github.com/gorilla/websocket/conn_test.go deleted file mode 100644 index 04c8dd8d..00000000 --- a/vendor/github.com/gorilla/websocket/conn_test.go +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2013 The Gorilla WebSocket 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 websocket - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "reflect" - "testing" - "testing/iotest" - "time" -) - -var _ net.Error = errWriteTimeout - -type fakeNetConn struct { - io.Reader - io.Writer -} - -func (c fakeNetConn) Close() error { return nil } -func (c fakeNetConn) LocalAddr() net.Addr { return nil } -func (c fakeNetConn) RemoteAddr() net.Addr { return nil } -func (c fakeNetConn) SetDeadline(t time.Time) error { return nil } -func (c fakeNetConn) SetReadDeadline(t time.Time) error { return nil } -func (c fakeNetConn) SetWriteDeadline(t time.Time) error { return nil } - -func TestFraming(t *testing.T) { - frameSizes := []int{0, 1, 2, 124, 125, 126, 127, 128, 129, 65534, 65535, 65536, 65537} - var readChunkers = []struct { - name string - f func(io.Reader) io.Reader - }{ - {"half", iotest.HalfReader}, - {"one", iotest.OneByteReader}, - {"asis", func(r io.Reader) io.Reader { return r }}, - } - - writeBuf := make([]byte, 65537) - for i := range writeBuf { - writeBuf[i] = byte(i) - } - - for _, isServer := range []bool{true, false} { - for _, chunker := range readChunkers { - - var connBuf bytes.Buffer - wc := newConn(fakeNetConn{Reader: nil, Writer: &connBuf}, isServer, 1024, 1024) - rc := newConn(fakeNetConn{Reader: chunker.f(&connBuf), Writer: nil}, !isServer, 1024, 1024) - - for _, n := range frameSizes { - for _, iocopy := range []bool{true, false} { - name := fmt.Sprintf("s:%v, r:%s, n:%d c:%v", isServer, chunker.name, n, iocopy) - - w, err := wc.NextWriter(TextMessage) - if err != nil { - t.Errorf("%s: wc.NextWriter() returned %v", name, err) - continue - } - var nn int - if iocopy { - var n64 int64 - n64, err = io.Copy(w, bytes.NewReader(writeBuf[:n])) - nn = int(n64) - } else { - nn, err = w.Write(writeBuf[:n]) - } - if err != nil || nn != n { - t.Errorf("%s: w.Write(writeBuf[:n]) returned %d, %v", name, nn, err) - continue - } - err = w.Close() - if err != nil { - t.Errorf("%s: w.Close() returned %v", name, err) - continue - } - - opCode, r, err := rc.NextReader() - if err != nil || opCode != TextMessage { - t.Errorf("%s: NextReader() returned %d, r, %v", name, opCode, err) - continue - } - rbuf, err := ioutil.ReadAll(r) - if err != nil { - t.Errorf("%s: ReadFull() returned rbuf, %v", name, err) - continue - } - - if len(rbuf) != n { - t.Errorf("%s: len(rbuf) is %d, want %d", name, len(rbuf), n) - continue - } - - for i, b := range rbuf { - if byte(i) != b { - t.Errorf("%s: bad byte at offset %d", name, i) - break - } - } - } - } - } - } -} - -func TestControl(t *testing.T) { - const message = "this is a ping/pong messsage" - for _, isServer := range []bool{true, false} { - for _, isWriteControl := range []bool{true, false} { - name := fmt.Sprintf("s:%v, wc:%v", isServer, isWriteControl) - var connBuf bytes.Buffer - wc := newConn(fakeNetConn{Reader: nil, Writer: &connBuf}, isServer, 1024, 1024) - rc := newConn(fakeNetConn{Reader: &connBuf, Writer: nil}, !isServer, 1024, 1024) - if isWriteControl { - wc.WriteControl(PongMessage, []byte(message), time.Now().Add(time.Second)) - } else { - w, err := wc.NextWriter(PongMessage) - if err != nil { - t.Errorf("%s: wc.NextWriter() returned %v", name, err) - continue - } - if _, err := w.Write([]byte(message)); err != nil { - t.Errorf("%s: w.Write() returned %v", name, err) - continue - } - if err := w.Close(); err != nil { - t.Errorf("%s: w.Close() returned %v", name, err) - continue - } - var actualMessage string - rc.SetPongHandler(func(s string) error { actualMessage = s; return nil }) - rc.NextReader() - if actualMessage != message { - t.Errorf("%s: pong=%q, want %q", name, actualMessage, message) - continue - } - } - } - } -} - -func TestCloseBeforeFinalFrame(t *testing.T) { - const bufSize = 512 - - expectedErr := &CloseError{Code: CloseNormalClosure, Text: "hello"} - - var b1, b2 bytes.Buffer - wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, 1024, bufSize) - rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, 1024, 1024) - - w, _ := wc.NextWriter(BinaryMessage) - w.Write(make([]byte, bufSize+bufSize/2)) - wc.WriteControl(CloseMessage, FormatCloseMessage(expectedErr.Code, expectedErr.Text), time.Now().Add(10*time.Second)) - w.Close() - - op, r, err := rc.NextReader() - if op != BinaryMessage || err != nil { - t.Fatalf("NextReader() returned %d, %v", op, err) - } - _, err = io.Copy(ioutil.Discard, r) - if !reflect.DeepEqual(err, expectedErr) { - t.Fatalf("io.Copy() returned %v, want %v", err, expectedErr) - } - _, _, err = rc.NextReader() - if !reflect.DeepEqual(err, expectedErr) { - t.Fatalf("NextReader() returned %v, want %v", err, expectedErr) - } -} - -func TestEOFBeforeFinalFrame(t *testing.T) { - const bufSize = 512 - - var b1, b2 bytes.Buffer - wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, 1024, bufSize) - rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, 1024, 1024) - - w, _ := wc.NextWriter(BinaryMessage) - w.Write(make([]byte, bufSize+bufSize/2)) - - op, r, err := rc.NextReader() - if op != BinaryMessage || err != nil { - t.Fatalf("NextReader() returned %d, %v", op, err) - } - _, err = io.Copy(ioutil.Discard, r) - if err != errUnexpectedEOF { - t.Fatalf("io.Copy() returned %v, want %v", err, errUnexpectedEOF) - } - _, _, err = rc.NextReader() - if err != errUnexpectedEOF { - t.Fatalf("NextReader() returned %v, want %v", err, errUnexpectedEOF) - } -} - -func TestReadLimit(t *testing.T) { - - const readLimit = 512 - message := make([]byte, readLimit+1) - - var b1, b2 bytes.Buffer - wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, 1024, readLimit-2) - rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, 1024, 1024) - rc.SetReadLimit(readLimit) - - // Send message at the limit with interleaved pong. - w, _ := wc.NextWriter(BinaryMessage) - w.Write(message[:readLimit-1]) - wc.WriteControl(PongMessage, []byte("this is a pong"), time.Now().Add(10*time.Second)) - w.Write(message[:1]) - w.Close() - - // Send message larger than the limit. - wc.WriteMessage(BinaryMessage, message[:readLimit+1]) - - op, _, err := rc.NextReader() - if op != BinaryMessage || err != nil { - t.Fatalf("1: NextReader() returned %d, %v", op, err) - } - op, r, err := rc.NextReader() - if op != BinaryMessage || err != nil { - t.Fatalf("2: NextReader() returned %d, %v", op, err) - } - _, err = io.Copy(ioutil.Discard, r) - if err != ErrReadLimit { - t.Fatalf("io.Copy() returned %v", err) - } -} - -func TestUnderlyingConn(t *testing.T) { - var b1, b2 bytes.Buffer - fc := fakeNetConn{Reader: &b1, Writer: &b2} - c := newConn(fc, true, 1024, 1024) - ul := c.UnderlyingConn() - if ul != fc { - t.Fatalf("Underlying conn is not what it should be.") - } -} - -func TestBufioReadBytes(t *testing.T) { - - // Test calling bufio.ReadBytes for value longer than read buffer size. - - m := make([]byte, 512) - m[len(m)-1] = '\n' - - var b1, b2 bytes.Buffer - wc := newConn(fakeNetConn{Reader: nil, Writer: &b1}, false, len(m)+64, len(m)+64) - rc := newConn(fakeNetConn{Reader: &b1, Writer: &b2}, true, len(m)-64, len(m)-64) - - w, _ := wc.NextWriter(BinaryMessage) - w.Write(m) - w.Close() - - op, r, err := rc.NextReader() - if op != BinaryMessage || err != nil { - t.Fatalf("NextReader() returned %d, %v", op, err) - } - - br := bufio.NewReader(r) - p, err := br.ReadBytes('\n') - if err != nil { - t.Fatalf("ReadBytes() returned %v", err) - } - if len(p) != len(m) { - t.Fatalf("read returnd %d bytes, want %d bytes", len(p), len(m)) - } -} - -var closeErrorTests = []struct { - err error - codes []int - ok bool -}{ - {&CloseError{Code: CloseNormalClosure}, []int{CloseNormalClosure}, true}, - {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived}, false}, - {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived, CloseNormalClosure}, true}, - {errors.New("hello"), []int{CloseNormalClosure}, false}, -} - -func TestCloseError(t *testing.T) { - for _, tt := range closeErrorTests { - ok := IsCloseError(tt.err, tt.codes...) - if ok != tt.ok { - t.Errorf("IsCloseError(%#v, %#v) returned %v, want %v", tt.err, tt.codes, ok, tt.ok) - } - } -} - -var unexpectedCloseErrorTests = []struct { - err error - codes []int - ok bool -}{ - {&CloseError{Code: CloseNormalClosure}, []int{CloseNormalClosure}, false}, - {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived}, true}, - {&CloseError{Code: CloseNormalClosure}, []int{CloseNoStatusReceived, CloseNormalClosure}, false}, - {errors.New("hello"), []int{CloseNormalClosure}, false}, -} - -func TestUnexpectedCloseErrors(t *testing.T) { - for _, tt := range unexpectedCloseErrorTests { - ok := IsUnexpectedCloseError(tt.err, tt.codes...) - if ok != tt.ok { - t.Errorf("IsUnexpectedCloseError(%#v, %#v) returned %v, want %v", tt.err, tt.codes, ok, tt.ok) - } - } -} - -type blockingWriter struct { - c1, c2 chan struct{} -} - -func (w blockingWriter) Write(p []byte) (int, error) { - // Allow main to continue - close(w.c1) - // Wait for panic in main - <-w.c2 - return len(p), nil -} - -func TestConcurrentWritePanic(t *testing.T) { - w := blockingWriter{make(chan struct{}), make(chan struct{})} - c := newConn(fakeNetConn{Reader: nil, Writer: w}, false, 1024, 1024) - go func() { - c.WriteMessage(TextMessage, []byte{}) - }() - - // wait for goroutine to block in write. - <-w.c1 - - defer func() { - close(w.c2) - if v := recover(); v != nil { - return - } - }() - - c.WriteMessage(TextMessage, []byte{}) - t.Fatal("should not get here") -} - -type failingReader struct{} - -func (r failingReader) Read(p []byte) (int, error) { - return 0, io.EOF -} - -func TestFailedConnectionReadPanic(t *testing.T) { - c := newConn(fakeNetConn{Reader: failingReader{}, Writer: nil}, false, 1024, 1024) - - defer func() { - if v := recover(); v != nil { - return - } - }() - - for i := 0; i < 20000; i++ { - c.ReadMessage() - } - t.Fatal("should not get here") -} diff --git a/vendor/github.com/gorilla/websocket/example_test.go b/vendor/github.com/gorilla/websocket/example_test.go deleted file mode 100644 index 96449eac..00000000 --- a/vendor/github.com/gorilla/websocket/example_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Gorilla WebSocket 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 websocket_test - -import ( - "log" - "net/http" - "testing" - - "github.com/gorilla/websocket" -) - -var ( - c *websocket.Conn - req *http.Request -) - -// The websocket.IsUnexpectedCloseError function is useful for identifying -// application and protocol errors. -// -// This server application works with a client application running in the -// browser. The client application does not explicitly close the websocket. The -// only expected close message from the client has the code -// websocket.CloseGoingAway. All other other close messages are likely the -// result of an application or protocol error and are logged to aid debugging. -func ExampleIsUnexpectedCloseError() { - - for { - messageType, p, err := c.ReadMessage() - if err != nil { - if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) { - log.Printf("error: %v, user-agent: %v", err, req.Header.Get("User-Agent")) - } - return - } - processMesage(messageType, p) - } -} - -func processMesage(mt int, p []byte) {} - -// TestX prevents godoc from showing this entire file in the example. Remove -// this function when a second example is added. -func TestX(t *testing.T) {} diff --git a/vendor/github.com/gorilla/websocket/json_test.go b/vendor/github.com/gorilla/websocket/json_test.go deleted file mode 100644 index 61100e48..00000000 --- a/vendor/github.com/gorilla/websocket/json_test.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2013 The Gorilla WebSocket 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 websocket - -import ( - "bytes" - "encoding/json" - "io" - "reflect" - "testing" -) - -func TestJSON(t *testing.T) { - var buf bytes.Buffer - c := fakeNetConn{&buf, &buf} - wc := newConn(c, true, 1024, 1024) - rc := newConn(c, false, 1024, 1024) - - var actual, expect struct { - A int - B string - } - expect.A = 1 - expect.B = "hello" - - if err := wc.WriteJSON(&expect); err != nil { - t.Fatal("write", err) - } - - if err := rc.ReadJSON(&actual); err != nil { - t.Fatal("read", err) - } - - if !reflect.DeepEqual(&actual, &expect) { - t.Fatal("equal", actual, expect) - } -} - -func TestPartialJSONRead(t *testing.T) { - var buf bytes.Buffer - c := fakeNetConn{&buf, &buf} - wc := newConn(c, true, 1024, 1024) - rc := newConn(c, false, 1024, 1024) - - var v struct { - A int - B string - } - v.A = 1 - v.B = "hello" - - messageCount := 0 - - // Partial JSON values. - - data, err := json.Marshal(v) - if err != nil { - t.Fatal(err) - } - for i := len(data) - 1; i >= 0; i-- { - if err := wc.WriteMessage(TextMessage, data[:i]); err != nil { - t.Fatal(err) - } - messageCount++ - } - - // Whitespace. - - if err := wc.WriteMessage(TextMessage, []byte(" ")); err != nil { - t.Fatal(err) - } - messageCount++ - - // Close. - - if err := wc.WriteMessage(CloseMessage, FormatCloseMessage(CloseNormalClosure, "")); err != nil { - t.Fatal(err) - } - - for i := 0; i < messageCount; i++ { - err := rc.ReadJSON(&v) - if err != io.ErrUnexpectedEOF { - t.Error("read", i, err) - } - } - - err = rc.ReadJSON(&v) - if _, ok := err.(*CloseError); !ok { - t.Error("final", err) - } -} - -func TestDeprecatedJSON(t *testing.T) { - var buf bytes.Buffer - c := fakeNetConn{&buf, &buf} - wc := newConn(c, true, 1024, 1024) - rc := newConn(c, false, 1024, 1024) - - var actual, expect struct { - A int - B string - } - expect.A = 1 - expect.B = "hello" - - if err := WriteJSON(wc, &expect); err != nil { - t.Fatal("write", err) - } - - if err := ReadJSON(rc, &actual); err != nil { - t.Fatal("read", err) - } - - if !reflect.DeepEqual(&actual, &expect) { - t.Fatal("equal", actual, expect) - } -} diff --git a/vendor/github.com/gorilla/websocket/server_test.go b/vendor/github.com/gorilla/websocket/server_test.go deleted file mode 100644 index 0a28141d..00000000 --- a/vendor/github.com/gorilla/websocket/server_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2013 The Gorilla WebSocket 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 websocket - -import ( - "net/http" - "reflect" - "testing" -) - -var subprotocolTests = []struct { - h string - protocols []string -}{ - {"", nil}, - {"foo", []string{"foo"}}, - {"foo,bar", []string{"foo", "bar"}}, - {"foo, bar", []string{"foo", "bar"}}, - {" foo, bar", []string{"foo", "bar"}}, - {" foo, bar ", []string{"foo", "bar"}}, -} - -func TestSubprotocols(t *testing.T) { - for _, st := range subprotocolTests { - r := http.Request{Header: http.Header{"Sec-Websocket-Protocol": {st.h}}} - protocols := Subprotocols(&r) - if !reflect.DeepEqual(st.protocols, protocols) { - t.Errorf("SubProtocols(%q) returned %#v, want %#v", st.h, protocols, st.protocols) - } - } -} - -var isWebSocketUpgradeTests = []struct { - ok bool - h http.Header -}{ - {false, http.Header{"Upgrade": {"websocket"}}}, - {false, http.Header{"Connection": {"upgrade"}}}, - {true, http.Header{"Connection": {"upgRade"}, "Upgrade": {"WebSocket"}}}, -} - -func TestIsWebSocketUpgrade(t *testing.T) { - for _, tt := range isWebSocketUpgradeTests { - ok := IsWebSocketUpgrade(&http.Request{Header: tt.h}) - if tt.ok != ok { - t.Errorf("IsWebSocketUpgrade(%v) returned %v, want %v", tt.h, ok, tt.ok) - } - } -} diff --git a/vendor/github.com/gorilla/websocket/util_test.go b/vendor/github.com/gorilla/websocket/util_test.go deleted file mode 100644 index 91f70ceb..00000000 --- a/vendor/github.com/gorilla/websocket/util_test.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Gorilla WebSocket 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 websocket - -import ( - "net/http" - "testing" -) - -var tokenListContainsValueTests = []struct { - value string - ok bool -}{ - {"WebSocket", true}, - {"WEBSOCKET", true}, - {"websocket", true}, - {"websockets", false}, - {"x websocket", false}, - {"websocket x", false}, - {"other,websocket,more", true}, - {"other, websocket, more", true}, -} - -func TestTokenListContainsValue(t *testing.T) { - for _, tt := range tokenListContainsValueTests { - h := http.Header{"Upgrade": {tt.value}} - ok := tokenListContainsValue(h, "Upgrade", "websocket") - if ok != tt.ok { - t.Errorf("tokenListContainsValue(h, n, %q) = %v, want %v", tt.value, ok, tt.ok) - } - } -} diff --git a/vendor/github.com/rancher/convoy/main.go b/vendor/github.com/rancher/convoy/main.go deleted file mode 100644 index 812e4485..00000000 --- a/vendor/github.com/rancher/convoy/main.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "fmt" - "github.com/rancher/convoy/api" - "github.com/rancher/convoy/client" - "os" -) - -var ( - // version of Convoy - VERSION = "0.5.0-dev" -) - -func cleanup() { - if r := recover(); r != nil { - api.ResponseLogAndError(r) - os.Exit(1) - } -} - -func main() { - defer cleanup() - - cli := client.NewCli(VERSION) - err := cli.Run(os.Args) - if err != nil { - panic(fmt.Errorf("Error when executing command: %v", err)) - } -} diff --git a/vendor/github.com/rancher/convoy/metadata/devmapper_test.go b/vendor/github.com/rancher/convoy/metadata/devmapper_test.go deleted file mode 100644 index dfdf4bc4..00000000 --- a/vendor/github.com/rancher/convoy/metadata/devmapper_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package metadata - -import ( - "testing" - - . "gopkg.in/check.v1" -) - -const ( - thinDeltaOutputSame = ` - - - - - - - - - ` - thinDeltaOutputDiff = ` - - - - - - ` - thinDeltaOutputMix = ` - - - - - - - - - ` - blockSize = 2097152 -) - -func Test(t *testing.T) { - TestingT(t) -} - -type TestSuite struct{} - -var _ = Suite(&TestSuite{}) - -func (s *TestSuite) TestThinDelta(c *C) { - mSame := Mappings{ - Mappings: []Mapping{ - {Offset: 0, Size: 1 * blockSize}, - {Offset: 1 * blockSize, Size: 1 * blockSize}, - {Offset: 4 * blockSize, Size: 3 * blockSize}, - {Offset: 8 * blockSize, Size: 1 * blockSize}, - {Offset: 12 * blockSize, Size: 1 * blockSize}, - }, - BlockSize: blockSize, - } - mDiff := Mappings{ - Mappings: []Mapping{ - {Offset: 0, Size: 1 * blockSize}, - {Offset: 4 * blockSize, Size: 1 * blockSize}, - }, - BlockSize: blockSize, - } - mMix := Mappings{ - Mappings: []Mapping{ - {Offset: 2 * blockSize, Size: 1 * blockSize}, - {Offset: 4 * blockSize, Size: 1 * blockSize}, - {Offset: 6 * blockSize, Size: 1 * blockSize}, - {Offset: 8 * blockSize, Size: 2 * blockSize}, - }, - BlockSize: blockSize, - } - - var ( - m *Mappings - err error - ) - - m, err = DeviceMapperThinDeltaParser([]byte(thinDeltaOutputSame), blockSize, true) - c.Assert(err, IsNil) - c.Assert(*m, DeepEquals, mSame) - - m, err = DeviceMapperThinDeltaParser([]byte(thinDeltaOutputMix), blockSize, false) - c.Assert(err, IsNil) - c.Assert(*m, DeepEquals, mMix) - - m, err = DeviceMapperThinDeltaParser([]byte(thinDeltaOutputDiff), blockSize, false) - c.Assert(err, IsNil) - c.Assert(*m, DeepEquals, mDiff) -} diff --git a/vendor/github.com/rancher/go-rancher-metadata/main.go b/vendor/github.com/rancher/go-rancher-metadata/main.go deleted file mode 100644 index fe3037eb..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/main.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "time" - - "github.com/Sirupsen/logrus" - "github.com/rancher/go-rancher-metadata/metadata" -) - -const ( - metadataUrl = "http://rancher-metadata/2015-12-19" -) - -func main() { - m := metadata.NewClient(metadataUrl) - - version := "init" - - for { - newVersion, err := m.GetVersion() - if err != nil { - logrus.Errorf("Error reading metadata version: %v", err) - } else if version == newVersion { - logrus.Debug("No changes in metadata version") - } else { - logrus.Debugf("Metadata version has changed, oldVersion=[%s], newVersion=[%s]", version, newVersion) - version = newVersion - } - time.Sleep(5 * time.Second) - } -} diff --git a/vendor/github.com/rancher/go-rancher/client/client_test.go b/vendor/github.com/rancher/go-rancher/client/client_test.go deleted file mode 100644 index ec71ef07..00000000 --- a/vendor/github.com/rancher/go-rancher/client/client_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package client - -import ( - "testing" - "time" -) - -const ( - PROJECT_URL = "http://localhost:8080/v1/projects/1a5/schemas" - URL = "http://localhost:8080/v1" - ACCESS_KEY = "admin" - SECRET_KEY = "adminpass" - MAX_WAIT = time.Duration(time.Second * 10) -) - -func newClient(t *testing.T, url string) *RancherClient { - client, err := NewRancherClient(&ClientOpts{ - Url: url, - AccessKey: ACCESS_KEY, - SecretKey: SECRET_KEY, - }) - - if err != nil { - t.Fatal("Failed to create client", err) - } - - return client -} - -func TestClientLoad(t *testing.T) { - client := newClient(t, URL) - if client.Schemas == nil { - t.Fatal("Failed to load schema") - } - - if len(client.Schemas.Data) == 0 { - t.Fatal("Schemas is empty") - } - - if _, ok := client.Types["container"]; !ok { - t.Fatal("Failed to find container type") - } -} - -func TestContainerList(t *testing.T) { - client := newClient(t, PROJECT_URL) - - /* Create a container to ensure list will return something */ - container, err := client.Container.Create(&Container{ - Name: "a name", - ImageUuid: "docker:nginx", - }) - if err != nil { - t.Fatal(err) - } - - defer client.Container.Delete(container) - - containers, err := client.Container.List(nil) - - if err != nil { - t.Fatal("Failed to list containers", err) - } - - if len(containers.Data) == 0 { - t.Fatal("No containers found") - } - - if len(containers.Data[0].Id) == 0 { - t.Fatal("Container ID is not set") - } - - listOpts := NewListOpts() - listOpts.Filters["id"] = "comeBackEmpty" - containers, err = client.Container.List(listOpts) - - if err != nil { - t.Fatal("Failed to list containers", err) - } - - if len(containers.Data) != 0 { - t.Fatal("Filter should have found no contianers.") - } -} - -func TestContainerCreate(t *testing.T) { - client := newClient(t, PROJECT_URL) - container, err := client.Container.Create(&Container{ - Name: "a name", - ImageUuid: "docker:nginx", - }) - - if err != nil { - t.Fatal(err) - } - - defer client.Container.Delete(container) - - if container.Name != "a name" { - t.Fatal("Field name is wrong [" + container.Name + "]") - } - - if container.ImageUuid != "docker:nginx" { - t.Fatal("Field imageUuid is wrong [" + container.ImageUuid + "]") - } -} - -func TestContainerUpdate(t *testing.T) { - client := newClient(t, PROJECT_URL) - container, err := client.Container.Create(&Container{ - Name: "a name", - ImageUuid: "docker:nginx", - }) - - if err != nil { - t.Fatal(err) - } - - defer client.Container.Delete(container) - - if container.Name != "a name" { - t.Fatal("Field name is wrong [" + container.Name + "]") - } - - container, err = client.Container.Update(container, &Container{ - Name: "a different name", - }) - - if container.Name != "a different name" { - t.Fatal("Field name is wrong [" + container.Name + "]") - } - - by_id_container, err := client.Container.ById(string(container.Id)) - if err != nil { - t.Fatal(err) - } - - if by_id_container.Id != container.Id { - t.Fatal("Container from by ID did not match") - } - - if by_id_container.Name != container.Name { - t.Fatal("Container from by ID did not match for name") - } -} - -func TestContainerDelete(t *testing.T) { - client := newClient(t, PROJECT_URL) - container, err := client.Container.Create(&Container{ - Name: "a name", - ImageUuid: "docker:nginx", - }) - - if err != nil { - t.Fatal(err) - } - - err = client.Container.Delete(container) - if err != nil { - t.Fatal("Failed to delete", err) - } -} - -func TestContainerNotExists(t *testing.T) { - client := newClient(t, PROJECT_URL) - ret, err := client.Container.ById("badId1") - if ret != nil || err != nil { - t.Fatal("Should receive nothing on 404") - } -} - -func TestAccountAction(t *testing.T) { - client := newClient(t, URL) - account, err := client.Account.Create(&Account{ - Name: "a name", - }) - - if err != nil { - t.Fatal(err) - } - - defer client.Account.Delete(account) - - account = waitAccountTransition(account, client, t) - if account.State == "inactive" { - t.Fatal("Account shouldnt be inactive.") - } - - account, err = client.Account.ActionDeactivate(account) - if err != nil { - t.Fatal(err) - } - - account = waitAccountTransition(account, client, t) - if account.State != "inactive" { - t.Fatal("Account didnt deactivate") - } -} - -func waitAccountTransition(account *Account, client *RancherClient, t *testing.T) *Account { - timeoutAt := time.Now().Add(MAX_WAIT) - ticker := time.NewTicker(time.Millisecond * 250) - defer ticker.Stop() - for tick := range ticker.C { - account, err := client.Account.ById(account.Id) - if err != nil { - t.Fatal("Couldn't get account") - } - if account.Transitioning != "yes" { - return account - } - if tick.After(timeoutAt) { - t.Fatal("Timed out waiting for account to activate.") - } - } - t.Fatal("Timed out waiting for account to activate.") - return nil -} diff --git a/vendor/github.com/rancher/go-rancher/main.go b/vendor/github.com/rancher/go-rancher/main.go deleted file mode 100644 index e8274c8a..00000000 --- a/vendor/github.com/rancher/go-rancher/main.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import ( - "fmt" - _ "github.com/rancher/go-rancher/client" -) - -func main() { - fmt.Println("I have nothing to do...") -} diff --git a/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go b/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go deleted file mode 100644 index 2ec0c0e6..00000000 --- a/vendor/github.com/rancher/sparse-tools/directfio/directfio_test.go +++ /dev/null @@ -1,286 +0,0 @@ -package directfio_test - -import ( - "bytes" - "os" - "testing" - - "log" - "time" - - "io/ioutil" - - "syscall" - - fio "github.com/rancher/sparse-tools/directfio" -) - -func tempFilePath() string { - // Make a temporary file path - f, err := ioutil.TempFile("", "fio-test") - if err != nil { - log.Fatal("Failed to make temp file", err) - } - defer f.Close() - return f.Name() -} - -// tempBigFileName is for files that are substantial in isze (for benchmark and stress tests) -// created in current directory -func tempBigFilePath() string { - // Make a temporary file path in current dir - f, err := ioutil.TempFile(".", "fio-test") - if err != nil { - log.Fatal("Failed to make temp file", err) - } - defer f.Close() - return f.Name() -} - -func cleanup(path string) { - // Cleanup - err := os.Remove(path) - if err != nil { - log.Fatal("Failed to remove file", path, err) - } -} - -func fillData(data []byte, start int) { - for i := 0; i < len(data); i++ { - data[i] = byte(start + i) - } -} - -func TestDirectFileIO1(t *testing.T) { - blocks := 4 - - // Init data - data1 := fio.AllocateAligned(blocks * fio.BlockSize) - fillData(data1, 0) - - path := tempFilePath() - defer cleanup(path) - { - // Write - f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0644) - if err != nil { - t.Fatal("Failed to OpenFile for write", err) - } - defer f.Close() - - _, err = f.WriteAt(data1, int64(blocks*fio.BlockSize)) - if err != nil { - t.Fatal("Failed to write", err) - } - } - - data2 := fio.AllocateAligned(blocks * fio.BlockSize) - { - // Read - f, err := os.OpenFile(path, os.O_RDONLY|syscall.O_DIRECT, 0) - if err != nil { - t.Fatal("Failed to OpenFile for read", err) - } - defer f.Close() - - _, err = f.ReadAt(data2, int64(blocks*fio.BlockSize)) - if err != nil { - t.Fatal("Failed to read", err) - } - } - - // Check - if !bytes.Equal(data1, data2) { - t.Fatal("Read not the same as written") - } -} - -func TestDirectFileIO2(t *testing.T) { - blocks := 4 - - // Init data - data1 := make([]byte, blocks*fio.BlockSize) - fillData(data1, 0) - - path := tempFilePath() - defer cleanup(path) - { - // Write - f, err := fio.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - t.Fatal("Failed to OpenFile for write", err) - } - defer f.Close() - - _, err = fio.WriteAt(f, data1, int64(blocks*fio.BlockSize)) - if err != nil { - t.Fatal("Failed to write", err) - } - } - - data2 := make([]byte, blocks*fio.BlockSize) - { - // Read - f, err := fio.OpenFile(path, os.O_RDONLY, 0) - if err != nil { - t.Fatal("Failed to OpenFile for read", err) - } - defer f.Close() - - _, err = fio.ReadAt(f, data2, int64(blocks*fio.BlockSize)) - if err != nil { - t.Fatal("Failed to read", err) - } - } - - // Check - if !bytes.Equal(data1, data2) { - t.Fatal("Read not the same as written") - } -} - -const fileSize = int64(1) /*GB*/ << 30 - -const FileMode = os.O_RDWR - -func write(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { - data := fio.AllocateAligned(batchSize) - fillData(data, 0) - - f, err := os.OpenFile(path, syscall.O_DIRECT|FileMode, 0) - if err != nil { - b.Fatal("Failed to OpenFile for write", err) - } - defer f.Close() - - for pos := offset; pos < offset+size; pos += int64(batchSize) { - _, err = f.WriteAt(data, pos) - if err != nil { - b.Fatal("Failed to write", err) - } - } - done <- true -} - -func read(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { - data := fio.AllocateAligned(batchSize) - - f, err := os.OpenFile(path, syscall.O_DIRECT|FileMode, 0) - if err != nil { - b.Fatal("Failed to OpenFile for read", err) - } - defer f.Close() - - for pos := offset; pos < offset+size; pos += int64(batchSize) { - _, err = f.ReadAt(data, pos) - if err != nil { - b.Fatal("Failed to read", err) - } - } - done <- true -} - -func writeUnaligned(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { - data := make([]byte, batchSize) - fillData(data, 0) - - f, err := fio.OpenFile(path, FileMode, 0) - if err != nil { - b.Fatal("Failed to OpenFile for write", err) - } - defer f.Close() - - for pos := offset; pos < offset+size; pos += int64(batchSize) { - _, err = fio.WriteAt(f, data, pos) - if err != nil { - b.Fatal("Failed to write", err) - } - } - done <- true -} - -func readUnaligned(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64) { - data := make([]byte, batchSize) - - f, err := fio.OpenFile(path, FileMode, 0) - if err != nil { - b.Fatal("Failed to OpenFile for read", err) - } - defer f.Close() - - for pos := offset; pos < offset+size; pos += int64(batchSize) { - _, err = fio.ReadAt(f, data, pos) - if err != nil { - b.Fatal("Failed to read", err) - } - } - done <- true -} - -func ioTest(title string, b *testing.B, path string, threads, batch int, io func(b *testing.B, path string, done chan<- bool, batchSize int, offset, size int64)) { - done := make(chan bool, threads) - chunkSize := fileSize / int64(threads) - - start := time.Now().UnixNano() - ioSize := batch * fio.BlockSize - for i := 0; i < threads; i++ { - go io(b, path, done, ioSize, int64(i)*chunkSize, chunkSize) - } - for i := 0; i < threads; i++ { - <-done - } - stop := time.Now().UnixNano() - if len(title) > 0 { - log.Println(title, ":", threads, "(threads) batch=", batch, "(blocks)", "thruput=", 1000000*fileSize/(1<<20)/((stop-start)/1000), "(MB/s)") - } -} - -func BenchmarkIO8(b *testing.B) { - path := tempBigFilePath() - - defer cleanup(path) - f, err := os.OpenFile(path, os.O_CREATE|FileMode, 0644) - if err != nil { - b.Fatal("Failed to OpenFile for write", err) - } - defer f.Close() - - f.Truncate(fileSize) - log.Println("") - ioTest("pilot write", b, path, 8, 32, write) - - for batch := 32; batch >= 1; batch >>= 1 { - log.Println("") - for threads := 1; threads <= 8; threads <<= 1 { - ioTest("write", b, path, threads, batch, write) - } - for threads := 1; threads <= 8; threads <<= 1 { - ioTest(" read", b, path, threads, batch, read) - } - } - -} - -func BenchmarkIO8u(b *testing.B) { - path := tempBigFilePath() - - defer cleanup(path) - f, err := os.OpenFile(path, os.O_CREATE|FileMode, 0644) - if err != nil { - b.Fatal("Failed to OpenFile for write", err) - } - defer f.Close() - f.Truncate(fileSize) - log.Println("") - ioTest("pilot write", b, path, 8, 32, writeUnaligned) - - for batch := 32; batch >= 1; batch >>= 1 { - log.Println("") - for threads := 1; threads <= 8; threads <<= 1 { - ioTest("unaligned write", b, path, threads, batch, writeUnaligned) - } - for threads := 1; threads <= 8; threads <<= 1 { - ioTest(" unaligned read", b, path, threads, batch, readUnaligned) - } - } -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client.go b/vendor/github.com/rancher/sparse-tools/sparse/client.go index 4147a0dc..4f7bf6ad 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/client.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/client.go @@ -6,6 +6,10 @@ import ( "os" "strconv" + "bytes" + + "encoding/binary" + fio "github.com/rancher/sparse-tools/directfio" "github.com/rancher/sparse-tools/log" ) @@ -17,6 +21,13 @@ import "errors" import "fmt" import "time" +// HashCollsisionError indicates block hash collision +type HashCollsisionError struct{} + +func (e *HashCollsisionError) Error() string { + return "file hash divergence: storage error or block hash collision" +} + // TCPEndPoint tcp connection address type TCPEndPoint struct { Host string @@ -28,6 +39,23 @@ const verboseClient = true // SyncFile synchronizes local file to remote host func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int) (hashLocal []byte, err error) { + for retries := 1; retries >= 0; retries-- { + hashLocal, err = syncFile(localPath, addr, remotePath, timeout, retries > 0) + if err != nil { + if _, ok := err.(*HashCollsisionError); ok { + // retry on HahsCollisionError + log.Warn("SSync: retrying on chunk hash collision...") + continue + } else { + log.Error("SSync error:", err) + } + } + break + } + return +} + +func syncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int, retry bool) (hashLocal []byte, err error) { hashLocal = make([]byte, 0) // empty hash for errors file, err := fio.OpenFile(localPath, os.O_RDONLY, 0) if err != nil { @@ -42,6 +70,8 @@ func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int return } + SetupFileIO(size%Blocks == 0) + conn := connect(addr.Host, strconv.Itoa(int(addr.Port)), timeout) if nil == conn { log.Error("Failed to connect to", addr) @@ -51,7 +81,11 @@ func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int encoder := gob.NewEncoder(conn) decoder := gob.NewDecoder(conn) - status := sendSyncRequest(encoder, decoder, remotePath, size) + + // Use unix time as hash salt + salt := make([]byte, binary.MaxVarintLen64) + binary.PutVarint(salt, time.Now().UnixNano()) + status := sendSyncRequest(encoder, decoder, remotePath, size, salt) if !status { return } @@ -72,7 +106,7 @@ func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int orderedStream := make(chan HashedDataInterval, 128) go IntervalSplitter(layoutStream, fileStream) - go FileReader(fileStream, file, unorderedStream) + FileReaderGroup(fileReaders, salt, fileStream, localPath, unorderedStream) go OrderIntervals("src:", unorderedStream, orderedStream) // Get remote file intervals and their hashes @@ -80,7 +114,7 @@ func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int netInStreamDone := make(chan bool) go netDstReceiver(decoder, netInStream, netInStreamDone) - return processDiff(abortStream, errStream, encoder, decoder, orderedStream, netInStream, netInStreamDone, file) + return processDiff(salt, abortStream, errStream, encoder, decoder, orderedStream, netInStream, netInStreamDone, retry) } func connect(host, port string, timeout int) net.Conn { @@ -106,7 +140,7 @@ func connect(host, port string, timeout int) net.Conn { return nil } -func sendSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64) bool { +func sendSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64, salt []byte) bool { err := encoder.Encode(requestHeader{requestMagic, syncRequestCode}) if err != nil { log.Fatal("Client protocol encoder error:", err) @@ -122,6 +156,11 @@ func sendSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, si log.Fatal("Client protocol encoder error:", err) return false } + err = encoder.Encode(salt) + if err != nil { + log.Fatal("Client protocol encoder error:", err) + return false + } var ack bool err = decoder.Decode(&ack) @@ -180,7 +219,7 @@ type diffChunk struct { header DataInterval } -func processDiff(abortStream chan<- error, errStream <-chan error, encoder *gob.Encoder, decoder *gob.Decoder, local <-chan HashedDataInterval, remote <-chan HashedInterval, netInStreamDone <-chan bool, file *os.File) (hashLocal []byte, err error) { +func processDiff(salt []byte, abortStream chan<- error, errStream <-chan error, encoder *gob.Encoder, decoder *gob.Decoder, local <-chan HashedDataInterval, remote <-chan HashedInterval, netInStreamDone <-chan bool, retry bool) (hashLocal []byte, err error) { // Local: __ _* // Remote: *_ ** hashLocal = make([]byte, 0) // empty hash for errors @@ -188,18 +227,8 @@ func processDiff(abortStream chan<- error, errStream <-chan error, encoder *gob. netStream := make(chan diffChunk, 128) netStatus := make(chan netXferStatus) go networkSender(netStream, encoder, netStatus) - // fileStream := make(chan fileChunk, 128) - // fileStatus := make(chan bool) - // for i := 0; i < concurrentReaders; i++ { - // if 0 == i { - // go fileReader(i, file, fileStream, netStream, fileStatus) - // } else { - // f, _ := os.Open(file.Name()) - // go fileReader(i, f, fileStream, netStream, fileStatus) - // } - // } fileHasher := sha1.New() - fileHasher.Write(HashSalt) + fileHasher.Write(salt) lrange := <-local rrange := <-remote @@ -257,19 +286,12 @@ func processDiff(abortStream chan<- error, errStream <-chan error, encoder *gob. rrange = <-remote } else { // Should never happen - log.Fatal("internal error") - err = errors.New("internal error") + log.Fatal("processDiff internal error") return } } log.Info("Finished processing file diff") - // // stop file readers - // for i := 0; i < concurrentReaders; i++ { - // fileStream <- fileChunk{true, FileInterval{SparseHole, Interval{0, 0}}} - // <-fileStatus // wait for reader completion - // } - status := true err = <-errStream if err != nil { @@ -310,25 +332,30 @@ func processDiff(abortStream chan<- error, errStream <-chan error, encoder *gob. // Compare file hashes hashLocal = fileHasher.Sum(nil) - if isHashDifferent(hashLocal, hashRemote) { + if isHashDifferent(hashLocal, hashRemote) || FailPointFileHashMatch() { log.Warn("hashLocal =", hashLocal) log.Warn("hashRemote=", hashRemote) - err = errors.New("file hash divergence: storage error or block hash collision") - return + err = &HashCollsisionError{} + } else { + retry = false // success, don't retry anymore + } + + // Final retry negotiation + { + err1 := encoder.Encode(retry) + if err1 != nil { + log.Fatal("Cient protocol remote retry error:", err) + } + err1 = decoder.Decode(&statusRemote) + if err1 != nil { + log.Fatal("Cient protocol remote retry status error:", err) + } } return } func isHashDifferent(a, b []byte) bool { - if len(a) != len(b) { - return true - } - for i, val := range a { - if val != b[i] { - return true - } - } - return false // hashes are equal + return !bytes.Equal(a, b) } func processFileInterval(local HashedDataInterval, remote HashedInterval, netStream chan<- diffChunk) { @@ -444,43 +471,3 @@ func networkSender(netStream <-chan diffChunk, encoder *gob.Encoder, netStatus c } netStatus <- netXferStatus{status, byteCount} } - -// obsolete method -func fileReader(id int, file *os.File, fileStream <-chan fileChunk, netStream chan<- diffChunk, fileStatus chan<- bool) { - idBeg := map[int]string{0: "a", 1: "b", 2: "c", 3: "d"} - idEnd := map[int]string{0: "A", 1: "B", 2: "C", 3: "D"} - for { - chunk := <-fileStream - if chunk.eof { - break - } - if traceChannelLoad { - fmt.Fprint(os.Stderr, len(fileStream), idBeg[id]) - } - // Check interval type - r := chunk.header - if SparseData != r.Kind { - log.Fatal("internal error: noles should be send directly to netStream") - } - - // Read file data - data := make([]byte, r.Len()) - status := true - n, err := fio.ReadAt(file, data, r.Begin) - if err != nil { - log.Error("File read error") - status = false - } else if int64(n) != r.Len() { - log.Error("File read underrun") - status = false - } - - // Send file data - if traceChannelLoad { - fmt.Fprint(os.Stderr, idEnd[id]) - } - netStream <- diffChunk{status, DataInterval{r, data}} - } - log.Info("Finished reading file") - fileStatus <- true -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client_test.go b/vendor/github.com/rancher/sparse-tools/sparse/client_test.go deleted file mode 100644 index 7a35e183..00000000 --- a/vendor/github.com/rancher/sparse-tools/sparse/client_test.go +++ /dev/null @@ -1,587 +0,0 @@ -package sparse - -import ( - "testing" - - "github.com/rancher/sparse-tools/log" -) - -const localhost = "127.0.0.1" -const timeout = 5 //seconds -var remoteAddr = TCPEndPoint{localhost, 5000} - -func TestSyncAnyFile(t *testing.T) { - src := "src.bar" - dst := "dst.bar" - run := false - - if run { - // Sync - go TestServer(remoteAddr, timeout) - _, err := SyncFile(src, remoteAddr, dst, timeout) - - // Verify - if err != nil { - t.Fatal("sync error") - } - if !filesAreEqual(src, dst) { - t.Fatal("file content diverged") - } - } -} - -func TestSyncFile1(t *testing.T) { - // D H D => D D H - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile2(t *testing.T) { - // H D H => D H H - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile3(t *testing.T) { - // D H D => D D - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile4(t *testing.T) { - // H D H => D H - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile5(t *testing.T) { - // H D H => H D - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile6(t *testing.T) { - // H D H => D - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile7(t *testing.T) { - // H D H => H - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile8(t *testing.T) { - // D H D => - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{} - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncFile9(t *testing.T) { - // H D H => - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{} - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff1(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff2(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff3(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff4(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff5(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff6(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff7(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff8(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff9(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff10(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff11(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff12(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff13(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff14(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff15(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff16(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff17(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 28 * Blocks}}, - {SparseHole, Interval{28 * Blocks, 32 * Blocks}}, - {SparseData, Interval{32 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff18(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 28 * Blocks}}, - {SparseHole, Interval{28 * Blocks, 36 * Blocks}}, - {SparseData, Interval{36 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff19(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 31 * Blocks}}, - {SparseHole, Interval{31 * Blocks, 33 * Blocks}}, - {SparseData, Interval{33 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff20(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 32 * Blocks}}, - {SparseHole, Interval{32 * Blocks, 36 * Blocks}}, - {SparseData, Interval{36 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseData, Interval{0, 30 * Blocks}}, - {SparseHole, Interval{30 * Blocks, 34 * Blocks}}, - {SparseData, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff21(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 28 * Blocks}}, - {SparseData, Interval{28 * Blocks, 32 * Blocks}}, - {SparseHole, Interval{32 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff22(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 28 * Blocks}}, - {SparseData, Interval{28 * Blocks, 36 * Blocks}}, - {SparseHole, Interval{36 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff23(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 31 * Blocks}}, - {SparseData, Interval{31 * Blocks, 33 * Blocks}}, - {SparseHole, Interval{33 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncDiff24(t *testing.T) { - layoutLocal := []FileInterval{ - {SparseHole, Interval{0, 32 * Blocks}}, - {SparseData, Interval{32 * Blocks, 36 * Blocks}}, - {SparseHole, Interval{36 * Blocks, 100 * Blocks}}, - } - layoutRemote := []FileInterval{ - {SparseHole, Interval{0, 30 * Blocks}}, - {SparseData, Interval{30 * Blocks, 34 * Blocks}}, - {SparseHole, Interval{34 * Blocks, 100 * Blocks}}, - } - testSyncFile(t, layoutLocal, layoutRemote) -} - -func TestSyncHash1(t *testing.T) { - var hash1, hash2 []byte - { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - } - layoutRemote := layoutLocal - hash1 = testSyncFile(t, layoutLocal, layoutRemote) - } - { - - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 3 * Blocks}}, - } - layoutRemote := layoutLocal - hash2 = testSyncFile(t, layoutLocal, layoutRemote) - } - if !isHashDifferent(hash1, hash2) { - t.Fatal("Files with same data content but different layouts should have unique hashes") - } -} - -func TestSyncHash2(t *testing.T) { - var hash1, hash2 []byte - { - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - } - layoutRemote := []FileInterval{} - hash1 = testSyncFile(t, layoutLocal, layoutRemote) - } - { - - layoutLocal := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 3 * Blocks}}, - } - layoutRemote := []FileInterval{} - hash2 = testSyncFile(t, layoutLocal, layoutRemote) - } - if !isHashDifferent(hash1, hash2) { - t.Fatal("Files with same data content but different layouts should have unique hashes") - } -} - -func testSyncFile(t *testing.T, layoutLocal, layoutRemote []FileInterval) (hashLocal []byte) { - localPath := tempFilePath("ssync-src-") - remotePath := tempFilePath("ssync-dst-") - // Only log errors - log.LevelPush(log.LevelError) - defer log.LevelPop() - - filesCleanup(localPath, remotePath) - defer filesCleanup(localPath, remotePath) - - // Create test files - createTestSparseFile(localPath, layoutLocal) - if len(layoutRemote) > 0 { - // only create destination test file if layout is speciifed - createTestSparseFile(remotePath, layoutRemote) - } - - // Sync - go TestServer(remoteAddr, timeout) - hashLocal, err := SyncFile(localPath, remoteAddr, remotePath, timeout) - - // Verify - if err != nil { - t.Fatal("sync error") - } - if !filesAreEqual(localPath, remotePath) { - t.Fatal("file content diverged") - } - return -} - -// created in current dir for benchmark tests -var localBigPath = "ssync-src-file.bar" -var remoteBigPath = "ssync-dst-file.bar" - -func Test_1G_cleanup(*testing.T) { - // remove temporaries if the benchmarks below are not run - filesCleanup(localBigPath, remoteBigPath) -} - -func Benchmark_1G_InitFiles(b *testing.B) { - // Setup files - layoutLocal := []FileInterval{ - {SparseData, Interval{0, (256 << 10) * Blocks}}, - } - layoutRemote := []FileInterval{} - - filesCleanup(localBigPath, remoteBigPath) - createTestSparseFile(localBigPath, layoutLocal) - createTestSparseFile(remoteBigPath, layoutRemote) -} - -func Benchmark_1G_SendFiles_Whole(b *testing.B) { - log.LevelPush(log.LevelInfo) - defer log.LevelPop() - - go TestServer(remoteAddr, timeout) - _, err := SyncFile(localBigPath, remoteAddr, remoteBigPath, timeout) - - if err != nil { - b.Fatal("sync error") - } -} - -func Benchmark_1G_SendFiles_Diff(b *testing.B) { - log.LevelPush(log.LevelInfo) - defer log.LevelPop() - - go TestServer(remoteAddr, timeout) - _, err := SyncFile(localBigPath, remoteAddr, remoteBigPath, timeout) - - if err != nil { - b.Fatal("sync error") - } -} - -func Benchmark_1G_CheckFiles(b *testing.B) { - if !filesAreEqual(localBigPath, remoteBigPath) { - b.Error("file content diverged") - return - } - filesCleanup(localBigPath, remoteBigPath) -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go b/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go new file mode 100644 index 00000000..4d6a2ef4 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go @@ -0,0 +1,29 @@ +package sparse + +import ( + "sync" + + "github.com/rancher/sparse-tools/log" +) + +var failFileHashMatch = false +var mutex sync.Mutex + +// SetFailPointFileHashMatch simulates file hash match failure +func SetFailPointFileHashMatch(fail bool) { + mutex.Lock() + failFileHashMatch = fail + mutex.Unlock() +} + +// FailPointFileHashMatch returns true if this failpoint is set, clears the failpoint +func FailPointFileHashMatch() bool { + mutex.Lock() + val := failFileHashMatch + if val { + log.Warn("FailPointFileHashMatch!") + failFileHashMatch = false + } + mutex.Unlock() + return val +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/file.go b/vendor/github.com/rancher/sparse-tools/sparse/file.go index 68c349fe..12514e3a 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/file.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/file.go @@ -6,10 +6,42 @@ import ( "fmt" + "sync" + fio "github.com/rancher/sparse-tools/directfio" "github.com/rancher/sparse-tools/log" ) +// File I/O methods for direct or bufferend I/O +var fileOpen func(name string, flag int, perm os.FileMode) (*os.File, error) +var fileReadAt func(file *os.File, data []byte, offset int64) (int, error) +var fileWriteAt func(file *os.File, data []byte, offset int64) (int, error) + +func fileBufferedOpen(name string, flag int, perm os.FileMode) (*os.File, error) { + return os.OpenFile(name, flag, perm) +} +func fileBufferedReadAt(file *os.File, data []byte, offset int64) (int, error) { + return file.ReadAt(data, offset) +} +func fileBufferedWriteAt(file *os.File, data []byte, offset int64) (int, error) { + return file.WriteAt(data, offset) +} + +// SetupFileIO Sets up direct file I/O or buffered for small unaligned files +func SetupFileIO(direct bool) { + if direct { + fileOpen = fio.OpenFile + fileReadAt = fio.ReadAt + fileWriteAt = fio.WriteAt + log.Info("Mode: directfio") + } else { + fileOpen = fileBufferedOpen + fileReadAt = fileBufferedReadAt + fileWriteAt = fileBufferedWriteAt + log.Info("Mode: buffered") + } +} + func loadFileLayout(abortStream <-chan error, file *os.File, layoutStream chan<- FileInterval, errStream chan<- error) error { size, err := file.Seek(0, os.SEEK_END) if err != nil { @@ -75,18 +107,43 @@ type DataInterval struct { Data []byte } -// HashSalt is common client/server hash salt -var HashSalt = []byte("TODO: randomize and exchange between client/server") +// FileReaderGroup starts specified number of readers +func FileReaderGroup(count int, salt []byte, fileStream <-chan FileInterval, path string, unorderedStream chan<- HashedDataInterval) { + var wgroup sync.WaitGroup + wgroup.Add(count) + for i := 0; i < count; i++ { + go FileReader(salt, fileStream, path, &wgroup, unorderedStream) + } + go func() { + wgroup.Wait() // all the readers join here + close(unorderedStream) + }() +} + +// FileWriterGroup starts specified number of writers +func FileWriterGroup(count int, fileStream <-chan DataInterval, path string) *sync.WaitGroup { + var wgroup sync.WaitGroup + wgroup.Add(count) + for i := 0; i < count; i++ { + go FileWriter(fileStream, path, &wgroup) + } + return &wgroup +} // FileReader supports concurrent file reading -func FileReader(fileStream <-chan FileInterval, file *os.File, unorderedStream chan<- HashedDataInterval) { +// multiple readres are allowed +func FileReader(salt []byte, fileStream <-chan FileInterval, path string, wgroup *sync.WaitGroup, unorderedStream chan<- HashedDataInterval) { + // open file + file, err := fileOpen(path, os.O_RDONLY, 0) + if err != nil { + log.Fatal("Failed to open file for reading:", string(path), err) + } + defer file.Close() + for r := range fileStream { switch r.Kind { case SparseHole: // Process hole - // hash := sha1.New() - // binary.PutVariant(data, r.Len) - // fileHash.Write(data) var hash, data []byte unorderedStream <- HashedDataInterval{HashedInterval{r, hash}, data} @@ -94,7 +151,7 @@ func FileReader(fileStream <-chan FileInterval, file *os.File, unorderedStream c // Read file data data := make([]byte, r.Len()) status := true - n, err := fio.ReadAt(file, data, r.Begin) + n, err := fileReadAt(file, data, r.Begin) if err != nil { status = false log.Error("File read error", status) @@ -103,33 +160,62 @@ func FileReader(fileStream <-chan FileInterval, file *os.File, unorderedStream c log.Error("File read underrun") } hasher := sha1.New() - hasher.Write(HashSalt) + hasher.Write(salt) hasher.Write(data) hash := hasher.Sum(nil) unorderedStream <- HashedDataInterval{HashedInterval{r, hash}, data} } } - close(unorderedStream) + wgroup.Done() // indicate to other readers we are done +} + +// FileWriter supports concurrent file reading +// add this writer to wgroup before invoking +func FileWriter(fileStream <-chan DataInterval, path string, wgroup *sync.WaitGroup) { + // open file + file, err := fileOpen(path, os.O_WRONLY, 0) + if err != nil { + log.Fatal("Failed to open file for wroting:", string(path), err) + } + defer file.Close() + + for r := range fileStream { + switch r.Kind { + case SparseHole: + log.Debug("trimming...") + err := PunchHole(file, r.Interval) + if err != nil { + log.Fatal("Failed to trim file") + } + + case SparseData: + log.Debug("writing data...") + _, err = fileWriteAt(file, r.Data, r.Begin) + if err != nil { + log.Fatal("Failed to write file") + } + } + } + wgroup.Done() } // OrderIntervals puts back "out of order" read results func OrderIntervals(prefix string, unorderedStream <-chan HashedDataInterval, orderedStream chan<- HashedDataInterval) { pos := int64(0) - var m map[int64]HashedDataInterval // out of order completions + m := make(map[int64]HashedDataInterval) // out of order completions for r := range unorderedStream { - // Handle "in order" range if pos == r.Begin { + // Handle "in order" range log.Debug(prefix, r) orderedStream <- r pos = r.End - continue + } else { + // push "out of order"" range + m[r.Begin] = r } - // push "out of order"" range - m[r.Begin] = r - // check the "out of order" stash for "in order" - for pop, existsNext := m[pos]; existsNext; { + for pop, existsNext := m[pos]; len(m) > 0 && existsNext; pop, existsNext = m[pos] { // pop in order range log.Debug(prefix, pop) orderedStream <- pop diff --git a/vendor/github.com/rancher/sparse-tools/sparse/layout.go b/vendor/github.com/rancher/sparse-tools/sparse/layout.go index 16a57997..8adc55ab 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/layout.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/layout.go @@ -22,7 +22,10 @@ func (interval Interval) Len() int64 { // String conversion func (interval Interval) String() string { - return fmt.Sprintf("[%8d:%8d](%3d)", interval.Begin/Blocks, interval.End/Blocks, interval.Len()/Blocks) + if interval.Begin%Blocks == 0 && interval.End%Blocks == 0 { + return fmt.Sprintf("[%8d:%8d](%3d)", interval.Begin/Blocks, interval.End/Blocks, interval.Len()/Blocks) + } + return fmt.Sprintf("{unaligned}[%8d:%8d](%3d)", interval.Begin, interval.End, interval.Len()) } // FileIntervalKind distinguishes between data and hole @@ -116,7 +119,7 @@ func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, l break } - // Process each extents + // Process each extent for _, e := range ext { interval := Interval{int64(e.Logical), int64(e.Logical + e.Length)} log.Debug("Extent:", interval, e.Flags) @@ -141,11 +144,14 @@ func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, l chunk.Begin = interval.End } } - chunk = Interval{chunk.End, chunk.End + chunkSizeMax} + chunk = Interval{chunk.End, chunk.End + chunkSize} } if intervalLast.Len() > 0 { // Pop last Data + if intervalLast.End > r.End { + intervalLast.End = r.End + } layoutStream <- FileInterval{SparseData, intervalLast} } if intervalLast.End < r.End { diff --git a/vendor/github.com/rancher/sparse-tools/sparse/layout_test.go b/vendor/github.com/rancher/sparse-tools/sparse/layout_test.go deleted file mode 100644 index a1251f1e..00000000 --- a/vendor/github.com/rancher/sparse-tools/sparse/layout_test.go +++ /dev/null @@ -1,192 +0,0 @@ -package sparse - -import ( - "os" - "reflect" - "testing" - - "github.com/rancher/sparse-tools/log" -) - -var name = tempFilePath("") - -func TestLayout0(t *testing.T) { - layoutModel := []FileInterval{} - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout1(t *testing.T) { - layoutModel := []FileInterval{{SparseHole, Interval{0, 4 * Blocks}}} - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout2(t *testing.T) { - layoutModel := []FileInterval{{SparseData, Interval{0, 4 * Blocks}}} - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout3(t *testing.T) { - layoutModel := []FileInterval{ - {SparseHole, Interval{0, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 4 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout4(t *testing.T) { - layoutModel := []FileInterval{ - {SparseData, Interval{0, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 4 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout5(t *testing.T) { - layoutModel := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout6(t *testing.T) { - layoutModel := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout7(t *testing.T) { - layoutModel := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutExpected := []FileInterval{ - {SparseData, Interval{0, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutExpected) -} - -func TestLayout8(t *testing.T) { - layoutModel := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutExpected := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 3 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutExpected) -} - -func TestLayout9(t *testing.T) { - layoutModel := []FileInterval{ - {SparseData, Interval{0, 256 * Blocks}}, - {SparseHole, Interval{256 * Blocks, (256<<10 - 256) * Blocks}}, - {SparseData, Interval{(256<<10 - 256) * Blocks, 256 << 10 * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout10(t *testing.T) { - layoutModel := []FileInterval{ - {SparseHole, Interval{0, (256<<10 - 128) * Blocks}}, - {SparseData, Interval{(256<<10 - 128) * Blocks, (256<<10 - 8) * Blocks}}, - {SparseHole, Interval{(256<<10 - 8) * Blocks, (256<<10 + 8) * Blocks}}, - {SparseData, Interval{(256<<10 + 8) * Blocks, (256<<10 + 128) * Blocks}}, - {SparseHole, Interval{(256<<10 + 128) * Blocks, (256 << 10 * 2) * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestLayout11(t *testing.T) { - layoutModel := []FileInterval{ - {SparseHole, Interval{0, (256<<10 - 8) * Blocks}}, - {SparseData, Interval{(256<<10 - 8) * Blocks, (256<<10 + 8) * Blocks}}, - {SparseHole, Interval{(256<<10 + 8) * Blocks, (256 << 10 * 2) * Blocks}}, - } - layoutTest(t, name, layoutModel, layoutModel) -} - -func TestPunchHole0(t *testing.T) { - layoutModel := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutExpected := []FileInterval{ - {SparseHole, Interval{0 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - punchHoleTest(t, name, layoutModel, Interval{0, 1 * Blocks}, layoutExpected) -} - -func layoutTest(t *testing.T, name string, layoutModel, layoutExpected []FileInterval) { - log.LevelPush(log.LevelInfo) - defer log.LevelPop() - - defer fileCleanup(name) - createTestSparseFile(name, layoutModel) - - f, err := os.Open(name) - if err != nil { - t.Fatal(err) - } - defer f.Close() - - size, err := f.Seek(0, os.SEEK_END) - if err != nil { - t.Fatal(err) - } - - layoutActual, err := RetrieveLayout(f, Interval{0, size}) - if err != nil || !reflect.DeepEqual(layoutExpected, layoutActual) { - t.Fatal("wrong sparse layout") - } - - if checkTestSparseFile(name, layoutModel) != nil { - t.Fatal("wrong sparse layout content") - } -} - -func punchHoleTest(t *testing.T, name string, layoutModel []FileInterval, hole Interval, layoutExpected []FileInterval) { - createTestSparseFile(name, layoutModel) - - defer fileCleanup(name) - f, err := os.OpenFile(name, os.O_RDWR, 0) - if err != nil { - t.Fatal(err) - } - defer f.Close() - - size, err := f.Seek(0, os.SEEK_END) - if err != nil { - t.Fatal(err) - } - - err = PunchHole(f, hole) - if err != nil { - t.Fatal(err) - } - - layoutActual, err := RetrieveLayout(f, Interval{0, size}) - if err != nil || !reflect.DeepEqual(layoutExpected, layoutActual) { - t.Fatal("wrong sparse layout") - } -} - -func makeData(interval FileInterval) []byte { - data := make([]byte, interval.Len()) - if SparseData == interval.Kind { - for i := range data { - data[i] = byte(interval.Begin/Blocks + 1) - } - } - return data -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/server.go b/vendor/github.com/rancher/sparse-tools/sparse/server.go index 8fe59db7..aa265229 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/server.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/server.go @@ -10,7 +10,6 @@ import ( "strconv" "time" - fio "github.com/rancher/sparse-tools/directfio" "github.com/rancher/sparse-tools/log" ) @@ -24,6 +23,8 @@ func TestServer(addr TCPEndPoint, timeout int) { server(addr, true, timeout) } +const fileReaders = 1 +const fileWriters = 1 const verboseServer = true func server(addr TCPEndPoint, serveOnce /*test flag*/ bool, timeout int) { @@ -51,11 +52,13 @@ func server(addr TCPEndPoint, serveOnce /*test flag*/ bool, timeout int) { if serveOnce { // This is to avoid server listening port conflicts while running tests // exit after single connection request - serveConnection(conn) - break + if serveConnection(conn) { + break // no retries + } + log.Warn("Server: waiting for client sync retry...") + } else { + go serveConnection(conn) } - - go serveConnection(conn) } log.Info("Sync server exit.") } @@ -72,7 +75,8 @@ type requestHeader struct { Code requestCode } -func serveConnection(conn net.Conn) { +// returns true if no retry is necessary +func serveConnection(conn net.Conn) bool { defer conn.Close() decoder := gob.NewDecoder(conn) @@ -80,11 +84,11 @@ func serveConnection(conn net.Conn) { err := decoder.Decode(&request) if err != nil { log.Fatal("Protocol decoder error:", err) - return + return true } if requestMagic != request.Magic { log.Error("Bad request") - return + return true } switch request.Code { @@ -93,46 +97,60 @@ func serveConnection(conn net.Conn) { err := decoder.Decode(&path) if err != nil { log.Fatal("Protocol decoder error:", err) - return + return true } var size int64 err = decoder.Decode(&size) if err != nil { log.Fatal("Protocol decoder error:", err) - return + return true + } + var salt []byte + err = decoder.Decode(&salt) + if err != nil { + log.Fatal("Protocol decoder error:", err) + return true } encoder := gob.NewEncoder(conn) - serveSyncRequest(encoder, decoder, path, size) + return serveSyncRequest(encoder, decoder, path, size, salt) } + return true } -func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64) { +// returns true if no retry is necessary +func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64, salt []byte) bool { + directFileIO := size%Blocks == 0 + SetupFileIO(directFileIO) // Open destination file - file, err := fio.OpenFile(path, os.O_RDWR, 0666) + file, err := fileOpen(path, os.O_RDWR, 0666) if err != nil { file, err = os.Create(path) if err != nil { log.Error("Failed to create file:", string(path), err) encoder.Encode(false) // NACK request - return + return true } } + // Setup close sequence + if directFileIO { + defer file.Sync() + } defer file.Close() // Resize the file if err = file.Truncate(size); err != nil { log.Error("Failed to resize file:", string(path), err) encoder.Encode(false) // NACK request - return + return true } // open file - fileRO, err := fio.OpenFile(path, os.O_RDONLY, 0) + fileRO, err := fileOpen(path, os.O_RDONLY, 0) if err != nil { log.Error("Failed to open file for reading:", string(path), err) encoder.Encode(false) // NACK request - return + return true } defer fileRO.Close() @@ -147,7 +165,8 @@ func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, s netOutDoneStream := make(chan bool) netInStream := make(chan DataInterval, 128) - fileWrittenStreamDone := make(chan bool) + fileWriteStream := make(chan DataInterval, 128) + deltaReceiverDoneDone := make(chan bool) checksumStream := make(chan DataInterval, 128) resultStream := make(chan []byte) @@ -155,19 +174,22 @@ func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, s err = loadFileLayout(abortStream, fileRO, layoutStream, errStream) if err != nil { encoder.Encode(false) // NACK request - return + return true } encoder.Encode(true) // ACK request go IntervalSplitter(layoutStream, fileStream) - go FileReader(fileStream, fileRO, unorderedStream) + FileReaderGroup(fileReaders, salt, fileStream, path, unorderedStream) go OrderIntervals("dst:", unorderedStream, orderedStream) go Tee(orderedStream, netOutStream, checksumStream) // Send layout along with data hashes go netSender(netOutStream, encoder, netOutDoneStream) - go netReceiver(decoder, file, netInStream, fileWrittenStreamDone) // receiver and checker - go Validator(checksumStream, netInStream, resultStream) + + // Start receiving deltas, write those and compute file hash + fileWritten := FileWriterGroup(fileWriters, fileWriteStream, path) + go netReceiver(decoder, file, netInStream, fileWriteStream, deltaReceiverDoneDone) // receiver and checker + go Validator(salt, checksumStream, netInStream, resultStream) // Block till completion status := true @@ -177,7 +199,8 @@ func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, s status = false } status = <-netOutDoneStream && status // done sending dst hashes - status = <-fileWrittenStreamDone && status // done writing dst file + status = <-deltaReceiverDoneDone && status // done writing dst file + fileWritten.Wait() // wait for write stream completion hash := <-resultStream // done processing diffs // reply to client with status @@ -185,14 +208,27 @@ func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, s err = encoder.Encode(status) if err != nil { log.Fatal("Protocol encoder error:", err) - return + return true } // reply with local hash err = encoder.Encode(hash) if err != nil { log.Fatal("Protocol encoder error:", err) - return + return true + } + + var retry bool + err = decoder.Decode(&retry) + if err != nil { + log.Fatal("Protocol retry decoder error:", err) + return true } + encoder.Encode(true) // ACK retry + if err != nil { + log.Fatal("Protocol retry encoder error:", err) + return true + } + return !retry // don't terminate server if retry expected } // Tee ordered intervals into the network and checksum checker @@ -235,7 +271,7 @@ func netSender(netOutStream <-chan HashedInterval, encoder *gob.Encoder, netOutD netOutDoneStream <- true } -func netReceiver(decoder *gob.Decoder, file *os.File, netInStream chan<- DataInterval, fileWrittenStreamDone chan<- bool) { +func netReceiver(decoder *gob.Decoder, file *os.File, netInStream chan<- DataInterval, fileStream chan<- DataInterval, deltaReceiverDone chan<- bool) { // receive & process data diff status := true for status { @@ -266,27 +302,15 @@ func netReceiver(decoder *gob.Decoder, file *os.File, netInStream chan<- DataInt status = false break } - // Push for vaildator processing + // Push for writing and vaildator processing + fileStream <- DataInterval{delta, data} netInStream <- DataInterval{delta, data} - log.Debug("writing data...") - _, err = fio.WriteAt(file, data, delta.Begin) - if err != nil { - log.Error("Failed to write file") - status = false - break - } case SparseHole: - // Push for vaildator processing + // Push for writing and vaildator processing + fileStream <- DataInterval{delta, make([]byte, 0)} netInStream <- DataInterval{delta, make([]byte, 0)} - log.Debug("trimming...") - err := PunchHole(file, delta.Interval) - if err != nil { - log.Error("Failed to trim file") - status = false - break - } case SparseIgnore: // Push for vaildator processing netInStream <- DataInterval{delta, make([]byte, 0)} @@ -296,7 +320,8 @@ func netReceiver(decoder *gob.Decoder, file *os.File, netInStream chan<- DataInt log.Debug("Server.netReceiver done, sync") close(netInStream) - fileWrittenStreamDone <- status + close(fileStream) + deltaReceiverDone <- status } func logData(prefix string, data []byte) { @@ -322,10 +347,10 @@ func hashFileData(fileHasher hash.Hash, dataLen int64, data []byte) { } // Validator merges source and diff data; produces hash of the destination file -func Validator(checksumStream, netInStream <-chan DataInterval, resultStream chan<- []byte) { +func Validator(salt []byte, checksumStream, netInStream <-chan DataInterval, resultStream chan<- []byte) { fileHasher := sha1.New() //TODO: error handling - fileHasher.Write(HashSalt) + fileHasher.Write(salt) r := <-checksumStream // original dst file data q := <-netInStream // diff data for q.Len() != 0 || r.Len() != 0 { diff --git a/vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go b/vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go deleted file mode 100644 index 95e0f7dc..00000000 --- a/vendor/github.com/rancher/sparse-tools/sparse/sfold_test.go +++ /dev/null @@ -1,149 +0,0 @@ -package sparse - -import ( - "testing" - - "github.com/rancher/sparse-tools/log" -) - -func TestFoldLayout1(t *testing.T) { - // D H D => D D H - layoutFrom := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTo := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutModel := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - - layoutResult := foldLayout(layoutFrom, layoutTo) - status := checkLayout(layoutResult, layoutModel) - if !status { - t.Fatal("Folded layout diverged") - } -} - -func TestFoldLayout2(t *testing.T) { - // H D H => D H H - layoutFrom := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTo := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutModel := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - - layoutResult := foldLayout(layoutFrom, layoutTo) - status := checkLayout(layoutResult, layoutModel) - if !status { - t.Fatal("Folded layout diverged") - } -} - -func TestFoldFile1(t *testing.T) { - // D H D => D D H - layoutFrom := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseData, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTo := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - testFoldFile(t, layoutFrom, layoutTo) -} - -func TestFoldFile2(t *testing.T) { - // H D H => D H H - layoutFrom := []FileInterval{ - {SparseHole, Interval{0, 1 * Blocks}}, - {SparseData, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - layoutTo := []FileInterval{ - {SparseData, Interval{0, 1 * Blocks}}, - {SparseHole, Interval{1 * Blocks, 2 * Blocks}}, - {SparseHole, Interval{2 * Blocks, 3 * Blocks}}, - } - testFoldFile(t, layoutFrom, layoutTo) -} - -func foldLayout(from, to []FileInterval) []FileInterval { - if len(from) != len(to) { - log.Fatal("foldLayout: non equal length not implemented") - } - result := make([]FileInterval, len(to)) - copy(result, to) - for i, interval := range from { - if to[i].Interval != interval.Interval { - log.Fatal("foldLayout: subinterval feature not implemented") - } - if interval.Kind == SparseData { - result[i] = interval - } - } - return result -} - -func checkLayout(from, to []FileInterval) bool { - if len(from) != len(to) { - log.Error("checkLayout: non equal length:", len(from), len(to)) - return false - } - for i, interval := range from { - if to[i] != interval { - log.Error("checkayout: intervals not equal:", interval, to[i]) - return false - } - } - return true -} - -func testFoldFile(t *testing.T, layoutFrom, layoutTo []FileInterval) (hashLocal []byte) { - localPath := tempFilePath("sfold-src-") - remotePath := tempFilePath("sfold-dst-") - - // Only log errors - log.LevelPush(log.LevelError) - defer log.LevelPop() - - filesCleanup(localPath, remotePath) - defer filesCleanup(localPath, remotePath) - - // Create test files - createTestSparseFile(localPath, layoutFrom) - createTestSparseFile(remotePath, layoutTo) - layoutResult := foldLayout(layoutFrom, layoutTo) - - // Fold - err := FoldFile(localPath, remotePath) - - // Verify - if err != nil { - t.Fatal("Fold error:", err) - } - - err = checkTestSparseFile(remotePath, layoutResult) - if err != nil { - t.Fatal("Folded content diverged:", err) - } - return -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go b/vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go deleted file mode 100644 index 96f19ad7..00000000 --- a/vendor/github.com/rancher/sparse-tools/sparse/ssync_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package sparse - -import ( - "bytes" - "errors" - "fmt" - "math/rand" - "os" - "testing" - - "time" - - "strconv" - - "github.com/rancher/sparse-tools/log" -) - -type TestFileInterval struct { - FileInterval - dataMask byte // XORed with other generated data bytes -} - -func (i TestFileInterval) String() string { - return fmt.Sprintf("{%v %2X}", i.FileInterval, i.dataMask) -} - -func TestRandomLayout10MB(t *testing.T) { - const seed = 0 - const size = 10 /*MB*/ << 20 - prefix := "ssync" - name := tempFilePath(prefix) - defer fileCleanup(name) - - layoutStream := generateLayout(prefix, size, seed) - layout1, layout2 := teeLayout(layoutStream) - - done := createTestSparseFileLayout(name, size, layout1) - layoutTmp := unstreamLayout(layout2) - <-done - log.Info("Done writing layout of ", len(layoutTmp), "items") - - layout := streamLayout(layoutTmp) - err := checkTestSparseFileLayout(name, layout) - if err != nil { - t.Fatal(err) - } -} - -func TestRandomLayout100MB(t *testing.T) { - const seed = 0 - const size = 100 /*MB*/ << 20 - prefix := "ssync" - name := tempFilePath(prefix) - defer fileCleanup(name) - - layoutStream := generateLayout(prefix, size, seed) - layout1, layout2 := teeLayout(layoutStream) - - done := createTestSparseFileLayout(name, size, layout1) - layoutTmp := unstreamLayout(layout2) - <-done - log.Info("Done writing layout of ", len(layoutTmp), "items") - - layout := streamLayout(layoutTmp) - err := checkTestSparseFileLayout(name, layout) - if err != nil { - t.Fatal(err) - } -} - -const srcPrefix = "ssync-src" -const dstPrefix = "ssync-dst" - -func TestRandomSync100MB(t *testing.T) { - const seed = 1 - const size = 100 /*MB*/ << 20 - srcName := tempFilePath(srcPrefix) - dstName := tempFilePath(dstPrefix) - RandomSync(t, size, seed, srcName, dstName, true /*create dstFile*/) -} - -func TestRandomSyncNoDst100MB(t *testing.T) { - const seed = 2 - const size = 100 /*MB*/ << 20 - srcName := tempFilePath(srcPrefix) - dstName := tempFilePath(dstPrefix) - RandomSync(t, size, seed, srcName, dstName, false /*no dstFile*/) -} - -func TestRandomSyncCustomGB(t *testing.T) { - if testing.Short() { - t.Skip("skipped custom random sync") - } - - // random seed - seed := time.Now().UnixNano() - log.LevelPush(log.LevelInfo) - defer log.LevelPop() - log.Info("seed=", seed) - - // default size - var size = int64(100) /*MB*/ << 20 - arg := os.Args[len(os.Args)-1] - sizeGB, err := strconv.Atoi(arg) - if err != nil { - log.Info("") - log.Info("Using default 100MB size for random seed test") - log.Info("For alternative size in GB and in current dir(vs tmp) use -timeout 10m -args ") - log.Info("Increase the optional -timeout value for 20GB and larger sizes") - log.Info("") - srcName := tempFilePath(srcPrefix) - dstName := tempFilePath(dstPrefix) - RandomSync(t, size, seed, srcName, dstName, true /*create dstFile*/) - } else { - log.Info("Using ", sizeGB, "(GB) size for random seed test") - size = int64(sizeGB) << 30 - srcName := tempBigFilePath(srcPrefix) - dstName := tempBigFilePath(dstPrefix) - RandomSync(t, size, seed, srcName, dstName, true /*create dstFile*/) - } -} - -func RandomSync(t *testing.T, size, seed int64, srcPath, dstPath string, dstCreate bool) { - const localhost = "127.0.0.1" - const timeout = 10 //seconds - var remoteAddr = TCPEndPoint{localhost, 5000} - - defer filesCleanup(srcPath, dstPath) - - srcLayoutStream1, srcLayoutStream2 := teeLayout(generateLayout(srcPrefix, size, seed)) - dstLayoutStream := generateLayout(dstPrefix, size, seed+1) - - srcDone := createTestSparseFileLayout(srcPath, size, srcLayoutStream1) - srcLayout := unstreamLayout(srcLayoutStream2) - if dstCreate { - // Create destination with some data - dstDone := createTestSparseFileLayout(dstPath, size, dstLayoutStream) - <-dstDone - } - <-srcDone - log.Info("Done writing layout of ", len(srcLayout), "items") - - log.Info("Syncing...") - - go TestServer(remoteAddr, timeout) - _, err := SyncFile(srcPath, remoteAddr, dstPath, timeout) - - if err != nil { - t.Fatal("sync error") - } - log.Info("...syncing done") - - log.Info("Checking...") - layoutStream := streamLayout(srcLayout) - err = checkTestSparseFileLayout(dstPath, layoutStream) - if err != nil { - t.Fatal(err) - } -} - -func unstreamLayout(in <-chan TestFileInterval) []TestFileInterval { - layout := make([]TestFileInterval, 0, 4096) - for i := range in { - log.Trace("unstream", i) - layout = append(layout, i) - } - return layout -} - -func streamLayout(in []TestFileInterval) (out chan TestFileInterval) { - out = make(chan TestFileInterval, 128) - - go func() { - for _, i := range in { - log.Trace("stream", i) - out <- i - } - close(out) - }() - - return out -} - -func teeLayout(in <-chan TestFileInterval) (out1 chan TestFileInterval, out2 chan TestFileInterval) { - out1 = make(chan TestFileInterval, 128) - out2 = make(chan TestFileInterval, 128) - - go func() { - for i := range in { - log.Trace("Tee1...") - out1 <- i - log.Trace("Tee2...") - out2 <- i - } - close(out1) - close(out2) - }() - - return out1, out2 -} - -func generateLayout(prefix string, size, seed int64) <-chan TestFileInterval { - const maxInterval = 256 // Blocks - layoutStream := make(chan TestFileInterval, 128) - r := rand.New(rand.NewSource(seed)) - - go func() { - offset := int64(0) - for offset < size { - blocks := int64(r.Intn(maxInterval)) + 1 // 1..maxInterval - length := blocks * Blocks - if offset+length > size { - // don't overshoot size - length = size - offset - } - - interval := Interval{offset, offset + length} - offset += interval.Len() - - kind := SparseHole - var mask byte - if r.Intn(2) == 0 { - // Data - kind = SparseData - mask = 0xAA * byte(r.Intn(10)/9) // 10% - } - t := TestFileInterval{FileInterval{kind, interval}, mask} - log.Debug(prefix, t) - layoutStream <- t - } - close(layoutStream) - }() - - return layoutStream -} - -func makeIntervalData(interval TestFileInterval) []byte { - data := make([]byte, interval.Len()) - if SparseData == interval.Kind { - for i := range data { - value := byte((interval.Begin + int64(i)) / Blocks) - data[i] = interval.dataMask ^ value - } - } - return data -} - -func createTestSparseFileLayout(name string, fileSize int64, layout <-chan TestFileInterval) (done chan struct{}) { - done = make(chan struct{}) - - // Fill up file with layout data - go func() { - f, err := os.Create(name) - if err != nil { - log.Fatal(err) - } - err = f.Truncate(fileSize) - if err != nil { - log.Fatal(err) - } - - for interval := range layout { - log.Debug("writing...", interval) - if SparseData == interval.Kind { - size := batch * Blocks - for offset := interval.Begin; offset < interval.End; { - if offset+size > interval.End { - size = interval.End - offset - } - chunkInterval := TestFileInterval{FileInterval{SparseData, Interval{offset, offset + size}}, interval.dataMask} - data := makeIntervalData(chunkInterval) - _, err = f.WriteAt(data, offset) - if err != nil { - log.Fatal(err) - } - offset += size - } - } - } - f.Sync() - f.Close() - close(done) - }() - - return done -} - -func checkTestSparseFileLayout(name string, layout <-chan TestFileInterval) error { - f, err := os.Open(name) - if err != nil { - log.Fatal(err) - } - defer f.Close() - - // Read and check data - for interval := range layout { - log.Debug("checking...", interval) - if SparseData == interval.Kind { - size := batch * Blocks - for offset := interval.Begin; offset < interval.End; { - if offset+size > interval.End { - size = interval.End - offset - } - dataModel := makeIntervalData(TestFileInterval{FileInterval{SparseData, Interval{offset, offset + size}}, interval.dataMask}) - data := make([]byte, size) - f.ReadAt(data, offset) - offset += size - - if !bytes.Equal(data, dataModel) { - return errors.New(fmt.Sprint("data equality check failure at", interval)) - } - } - } else if SparseHole == interval.Kind { - layoutActual, err := RetrieveLayout(f, interval.Interval) - if err != nil { - return errors.New(fmt.Sprint("hole retrieval failure at", interval, err)) - } - if len(layoutActual) != 1 { - return errors.New(fmt.Sprint("hole check failure at", interval)) - } - if layoutActual[0] != interval.FileInterval { - return errors.New(fmt.Sprint("hole equality check failure at", interval)) - } - } - } - return nil // success -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go b/vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go deleted file mode 100644 index eec39acf..00000000 --- a/vendor/github.com/rancher/sparse-tools/sparse/testutil_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package sparse - -import ( - "io/ioutil" - "os" - "os/exec" - - "bytes" - "errors" - "fmt" - - "github.com/rancher/sparse-tools/log" -) - -func filesAreEqual(aPath, bPath string) bool { - cmd := exec.Command("diff", aPath, bPath) - err := cmd.Run() - return nil == err -} - -func filesCleanup(src, dst string) { - fileCleanup(src) - fileCleanup(dst) -} - -func fileCleanup(path string) { - os.Remove(path) -} - -func tempFilePath(prefix string) string { - // Make a temporary file path - f, err := ioutil.TempFile("", "sparse-"+prefix) - if err != nil { - log.Fatal("Failed to make temp file", err) - } - defer f.Close() - return f.Name() -} - -// tempBigFileName is for files that are substantial in isze (for benchmark and stress tests) -// created in current directory -func tempBigFilePath(prefix string) string { - // Make a temporary file path in current dir - f, err := ioutil.TempFile(".", "sparse-"+prefix) - if err != nil { - log.Fatal("Failed to make temp file", err) - } - defer f.Close() - return f.Name() -} - -const batch = int64(32) // Blocks for single read/write - -func createTestSparseFile(name string, layout []FileInterval) { - f, err := os.Create(name) - if err != nil { - log.Fatal(err) - } - defer f.Close() - - if 0 == len(layout) { - return // empty file - } - - // Fill up data - for _, interval := range layout { - if SparseData == interval.Kind { - size := batch * Blocks - for offset := interval.Begin; offset < interval.End; { - if offset+size > interval.End { - size = interval.End - offset - } - data := makeData(FileInterval{SparseData, Interval{offset, offset + size}}) - f.WriteAt(data, offset) - offset += size - } - } - } - - // Resize the file to the last hole - last := len(layout) - 1 - if SparseHole == layout[last].Kind { - if err := f.Truncate(layout[last].End); err != nil { - log.Fatal(err) - } - } - - f.Sync() -} - -func checkTestSparseFile(name string, layout []FileInterval) error { - f, err := os.Open(name) - if err != nil { - log.Fatal(err) - } - defer f.Close() - - if 0 == len(layout) { - return nil // empty file - } - - // Read and check data - for _, interval := range layout { - if SparseData == interval.Kind { - size := batch * Blocks - for offset := interval.Begin; offset < interval.End; { - if offset+size > interval.End { - size = interval.End - offset - } - dataModel := makeData(FileInterval{SparseData, Interval{offset, offset + size}}) - data := make([]byte, size) - f.ReadAt(data, offset) - offset += size - - if !bytes.Equal(data, dataModel) { - return errors.New(fmt.Sprint("data equality check failure at", interval)) - } - } - } else if SparseHole == interval.Kind { - layoutActual, err := RetrieveLayout(f, interval.Interval) - if err != nil { - return errors.New(fmt.Sprint("hole retrieval failure at", interval, err)) - } - if len(layoutActual) != 1 { - return errors.New(fmt.Sprint("hole check failure at", interval)) - } - if layoutActual[0] != interval { - return errors.New(fmt.Sprint("hole equality check failure at", interval)) - } - } - } - return nil // success -} diff --git a/vendor/github.com/satori/go.uuid/benchmarks_test.go b/vendor/github.com/satori/go.uuid/benchmarks_test.go deleted file mode 100644 index b4e567fc..00000000 --- a/vendor/github.com/satori/go.uuid/benchmarks_test.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (C) 2013-2015 by Maxim Bublis -// -// 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. - -package uuid - -import ( - "testing" -) - -func BenchmarkFromBytes(b *testing.B) { - bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - for i := 0; i < b.N; i++ { - FromBytes(bytes) - } -} - -func BenchmarkFromString(b *testing.B) { - s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - for i := 0; i < b.N; i++ { - FromString(s) - } -} - -func BenchmarkFromStringUrn(b *testing.B) { - s := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" - for i := 0; i < b.N; i++ { - FromString(s) - } -} - -func BenchmarkFromStringWithBrackets(b *testing.B) { - s := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" - for i := 0; i < b.N; i++ { - FromString(s) - } -} - -func BenchmarkNewV1(b *testing.B) { - for i := 0; i < b.N; i++ { - NewV1() - } -} - -func BenchmarkNewV2(b *testing.B) { - for i := 0; i < b.N; i++ { - NewV2(DomainPerson) - } -} - -func BenchmarkNewV3(b *testing.B) { - for i := 0; i < b.N; i++ { - NewV3(NamespaceDNS, "www.example.com") - } -} - -func BenchmarkNewV4(b *testing.B) { - for i := 0; i < b.N; i++ { - NewV4() - } -} - -func BenchmarkNewV5(b *testing.B) { - for i := 0; i < b.N; i++ { - NewV5(NamespaceDNS, "www.example.com") - } -} - -func BenchmarkMarshalBinary(b *testing.B) { - u := NewV4() - for i := 0; i < b.N; i++ { - u.MarshalBinary() - } -} - -func BenchmarkMarshalText(b *testing.B) { - u := NewV4() - for i := 0; i < b.N; i++ { - u.MarshalText() - } -} - -func BenchmarkUnmarshalBinary(b *testing.B) { - bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - u := UUID{} - for i := 0; i < b.N; i++ { - u.UnmarshalBinary(bytes) - } -} - -func BenchmarkUnmarshalText(b *testing.B) { - bytes := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - u := UUID{} - for i := 0; i < b.N; i++ { - u.UnmarshalText(bytes) - } -} - -func BenchmarkMarshalToString(b *testing.B) { - u := NewV4() - for i := 0; i < b.N; i++ { - u.String() - } -} diff --git a/vendor/github.com/satori/go.uuid/uuid_test.go b/vendor/github.com/satori/go.uuid/uuid_test.go deleted file mode 100644 index aa275345..00000000 --- a/vendor/github.com/satori/go.uuid/uuid_test.go +++ /dev/null @@ -1,520 +0,0 @@ -// Copyright (C) 2013, 2015 by Maxim Bublis -// -// 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. - -package uuid - -import ( - "bytes" - "testing" -) - -func TestBytes(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - bytes1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - if !bytes.Equal(u.Bytes(), bytes1) { - t.Errorf("Incorrect bytes representation for UUID: %s", u) - } -} - -func TestString(t *testing.T) { - if NamespaceDNS.String() != "6ba7b810-9dad-11d1-80b4-00c04fd430c8" { - t.Errorf("Incorrect string representation for UUID: %s", NamespaceDNS.String()) - } -} - -func TestEqual(t *testing.T) { - if !Equal(NamespaceDNS, NamespaceDNS) { - t.Errorf("Incorrect comparison of %s and %s", NamespaceDNS, NamespaceDNS) - } - - if Equal(NamespaceDNS, NamespaceURL) { - t.Errorf("Incorrect comparison of %s and %s", NamespaceDNS, NamespaceURL) - } -} - -func TestOr(t *testing.T) { - u1 := UUID{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff} - u2 := UUID{0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00} - - u := UUID{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} - - if !Equal(u, Or(u1, u2)) { - t.Errorf("Incorrect bitwise OR result %s", Or(u1, u2)) - } -} - -func TestAnd(t *testing.T) { - u1 := UUID{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff} - u2 := UUID{0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00} - - u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - - if !Equal(u, And(u1, u2)) { - t.Errorf("Incorrect bitwise AND result %s", And(u1, u2)) - } -} - -func TestVersion(t *testing.T) { - u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - - if u.Version() != 1 { - t.Errorf("Incorrect version for UUID: %d", u.Version()) - } -} - -func TestSetVersion(t *testing.T) { - u := UUID{} - u.SetVersion(4) - - if u.Version() != 4 { - t.Errorf("Incorrect version for UUID after u.setVersion(4): %d", u.Version()) - } -} - -func TestVariant(t *testing.T) { - u1 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - - if u1.Variant() != VariantNCS { - t.Errorf("Incorrect variant for UUID variant %d: %d", VariantNCS, u1.Variant()) - } - - u2 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - - if u2.Variant() != VariantRFC4122 { - t.Errorf("Incorrect variant for UUID variant %d: %d", VariantRFC4122, u2.Variant()) - } - - u3 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - - if u3.Variant() != VariantMicrosoft { - t.Errorf("Incorrect variant for UUID variant %d: %d", VariantMicrosoft, u3.Variant()) - } - - u4 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - - if u4.Variant() != VariantFuture { - t.Errorf("Incorrect variant for UUID variant %d: %d", VariantFuture, u4.Variant()) - } -} - -func TestSetVariant(t *testing.T) { - u := new(UUID) - u.SetVariant() - - if u.Variant() != VariantRFC4122 { - t.Errorf("Incorrect variant for UUID after u.setVariant(): %d", u.Variant()) - } -} - -func TestFromBytes(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - u1, err := FromBytes(b1) - if err != nil { - t.Errorf("Error parsing UUID from bytes: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - b2 := []byte{} - - _, err = FromBytes(b2) - if err == nil { - t.Errorf("Should return error parsing from empty byte slice, got %s", err) - } -} - -func TestMarshalBinary(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - b2, err := u.MarshalBinary() - if err != nil { - t.Errorf("Error marshaling UUID: %s", err) - } - - if !bytes.Equal(b1, b2) { - t.Errorf("Marshaled UUID should be %s, got %s", b1, b2) - } -} - -func TestUnmarshalBinary(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - u1 := UUID{} - err := u1.UnmarshalBinary(b1) - if err != nil { - t.Errorf("Error unmarshaling UUID: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - b2 := []byte{} - u2 := UUID{} - - err = u2.UnmarshalBinary(b2) - if err == nil { - t.Errorf("Should return error unmarshalling from empty byte slice, got %s", err) - } -} - -func TestFromString(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - s2 := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" - s3 := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" - - _, err := FromString("") - if err == nil { - t.Errorf("Should return error trying to parse empty string, got %s", err) - } - - u1, err := FromString(s1) - if err != nil { - t.Errorf("Error parsing UUID from string: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - u2, err := FromString(s2) - if err != nil { - t.Errorf("Error parsing UUID from string: %s", err) - } - - if !Equal(u, u2) { - t.Errorf("UUIDs should be equal: %s and %s", u, u2) - } - - u3, err := FromString(s3) - if err != nil { - t.Errorf("Error parsing UUID from string: %s", err) - } - - if !Equal(u, u3) { - t.Errorf("UUIDs should be equal: %s and %s", u, u3) - } -} - -func TestFromStringShort(t *testing.T) { - // Invalid 35-character UUID string - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c" - - for i := len(s1); i >= 0; i-- { - _, err := FromString(s1[:i]) - if err == nil { - t.Errorf("Should return error trying to parse too short string, got %s", err) - } - } -} - -func TestFromStringOrNil(t *testing.T) { - u := FromStringOrNil("") - if u != Nil { - t.Errorf("Should return Nil UUID on parse failure, got %s", u) - } -} - -func TestFromBytesOrNil(t *testing.T) { - b := []byte{} - u := FromBytesOrNil(b) - if u != Nil { - t.Errorf("Should return Nil UUID on parse failure, got %s", u) - } -} - -func TestMarshalText(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - - b2, err := u.MarshalText() - if err != nil { - t.Errorf("Error marshaling UUID: %s", err) - } - - if !bytes.Equal(b1, b2) { - t.Errorf("Marshaled UUID should be %s, got %s", b1, b2) - } -} - -func TestUnmarshalText(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - - u1 := UUID{} - err := u1.UnmarshalText(b1) - if err != nil { - t.Errorf("Error unmarshaling UUID: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - b2 := []byte("") - u2 := UUID{} - - err = u2.UnmarshalText(b2) - if err == nil { - t.Errorf("Should return error trying to unmarshal from empty string") - } -} - -func TestValue(t *testing.T) { - u, err := FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - if err != nil { - t.Errorf("Error parsing UUID from string: %s", err) - } - - val, err := u.Value() - if err != nil { - t.Errorf("Error getting UUID value: %s", err) - } - - if val != u.String() { - t.Errorf("Wrong value returned, should be equal: %s and %s", val, u) - } -} - -func TestScanBinary(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - u1 := UUID{} - err := u1.Scan(b1) - if err != nil { - t.Errorf("Error unmarshaling UUID: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - b2 := []byte{} - u2 := UUID{} - - err = u2.Scan(b2) - if err == nil { - t.Errorf("Should return error unmarshalling from empty byte slice, got %s", err) - } -} - -func TestScanString(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - - u1 := UUID{} - err := u1.Scan(s1) - if err != nil { - t.Errorf("Error unmarshaling UUID: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - s2 := "" - u2 := UUID{} - - err = u2.Scan(s2) - if err == nil { - t.Errorf("Should return error trying to unmarshal from empty string") - } -} - -func TestScanText(t *testing.T) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - - u1 := UUID{} - err := u1.Scan(b1) - if err != nil { - t.Errorf("Error unmarshaling UUID: %s", err) - } - - if !Equal(u, u1) { - t.Errorf("UUIDs should be equal: %s and %s", u, u1) - } - - b2 := []byte("") - u2 := UUID{} - - err = u2.Scan(b2) - if err == nil { - t.Errorf("Should return error trying to unmarshal from empty string") - } -} - -func TestScanUnsupported(t *testing.T) { - u := UUID{} - - err := u.Scan(true) - if err == nil { - t.Errorf("Should return error trying to unmarshal from bool") - } -} - -func TestNewV1(t *testing.T) { - u := NewV1() - - if u.Version() != 1 { - t.Errorf("UUIDv1 generated with incorrect version: %d", u.Version()) - } - - if u.Variant() != VariantRFC4122 { - t.Errorf("UUIDv1 generated with incorrect variant: %d", u.Variant()) - } - - u1 := NewV1() - u2 := NewV1() - - if Equal(u1, u2) { - t.Errorf("UUIDv1 generated two equal UUIDs: %s and %s", u1, u2) - } - - oldFunc := epochFunc - epochFunc = func() uint64 { return 0 } - - u3 := NewV1() - u4 := NewV1() - - if Equal(u3, u4) { - t.Errorf("UUIDv1 generated two equal UUIDs: %s and %s", u3, u4) - } - - epochFunc = oldFunc -} - -func TestNewV2(t *testing.T) { - u1 := NewV2(DomainPerson) - - if u1.Version() != 2 { - t.Errorf("UUIDv2 generated with incorrect version: %d", u1.Version()) - } - - if u1.Variant() != VariantRFC4122 { - t.Errorf("UUIDv2 generated with incorrect variant: %d", u1.Variant()) - } - - u2 := NewV2(DomainGroup) - - if u2.Version() != 2 { - t.Errorf("UUIDv2 generated with incorrect version: %d", u2.Version()) - } - - if u2.Variant() != VariantRFC4122 { - t.Errorf("UUIDv2 generated with incorrect variant: %d", u2.Variant()) - } -} - -func TestNewV3(t *testing.T) { - u := NewV3(NamespaceDNS, "www.example.com") - - if u.Version() != 3 { - t.Errorf("UUIDv3 generated with incorrect version: %d", u.Version()) - } - - if u.Variant() != VariantRFC4122 { - t.Errorf("UUIDv3 generated with incorrect variant: %d", u.Variant()) - } - - if u.String() != "5df41881-3aed-3515-88a7-2f4a814cf09e" { - t.Errorf("UUIDv3 generated incorrectly: %s", u.String()) - } - - u = NewV3(NamespaceDNS, "python.org") - - if u.String() != "6fa459ea-ee8a-3ca4-894e-db77e160355e" { - t.Errorf("UUIDv3 generated incorrectly: %s", u.String()) - } - - u1 := NewV3(NamespaceDNS, "golang.org") - u2 := NewV3(NamespaceDNS, "golang.org") - if !Equal(u1, u2) { - t.Errorf("UUIDv3 generated different UUIDs for same namespace and name: %s and %s", u1, u2) - } - - u3 := NewV3(NamespaceDNS, "example.com") - if Equal(u1, u3) { - t.Errorf("UUIDv3 generated same UUIDs for different names in same namespace: %s and %s", u1, u2) - } - - u4 := NewV3(NamespaceURL, "golang.org") - if Equal(u1, u4) { - t.Errorf("UUIDv3 generated same UUIDs for sane names in different namespaces: %s and %s", u1, u4) - } -} - -func TestNewV4(t *testing.T) { - u := NewV4() - - if u.Version() != 4 { - t.Errorf("UUIDv4 generated with incorrect version: %d", u.Version()) - } - - if u.Variant() != VariantRFC4122 { - t.Errorf("UUIDv4 generated with incorrect variant: %d", u.Variant()) - } -} - -func TestNewV5(t *testing.T) { - u := NewV5(NamespaceDNS, "www.example.com") - - if u.Version() != 5 { - t.Errorf("UUIDv5 generated with incorrect version: %d", u.Version()) - } - - if u.Variant() != VariantRFC4122 { - t.Errorf("UUIDv5 generated with incorrect variant: %d", u.Variant()) - } - - u = NewV5(NamespaceDNS, "python.org") - - if u.String() != "886313e1-3b8a-5372-9b90-0c9aee199e5d" { - t.Errorf("UUIDv5 generated incorrectly: %s", u.String()) - } - - u1 := NewV5(NamespaceDNS, "golang.org") - u2 := NewV5(NamespaceDNS, "golang.org") - if !Equal(u1, u2) { - t.Errorf("UUIDv5 generated different UUIDs for same namespace and name: %s and %s", u1, u2) - } - - u3 := NewV5(NamespaceDNS, "example.com") - if Equal(u1, u3) { - t.Errorf("UUIDv5 generated same UUIDs for different names in same namespace: %s and %s", u1, u2) - } - - u4 := NewV5(NamespaceURL, "golang.org") - if Equal(u1, u4) { - t.Errorf("UUIDv3 generated same UUIDs for sane names in different namespaces: %s and %s", u1, u4) - } -} diff --git a/vendor/gopkg.in/check.v1/benchmark_test.go b/vendor/gopkg.in/check.v1/benchmark_test.go deleted file mode 100644 index 4dd827c1..00000000 --- a/vendor/gopkg.in/check.v1/benchmark_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// These tests verify the test running logic. - -package check_test - -import ( - "time" - . "gopkg.in/check.v1" -) - -var benchmarkS = Suite(&BenchmarkS{}) - -type BenchmarkS struct{} - -func (s *BenchmarkS) TestCountSuite(c *C) { - suitesRun += 1 -} - -func (s *BenchmarkS) TestBasicTestTiming(c *C) { - helper := FixtureHelper{sleepOn: "Test1", sleep: 1000000 * time.Nanosecond} - output := String{} - runConf := RunConf{Output: &output, Verbose: true} - Run(&helper, &runConf) - - expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t0\\.001s\n" + - "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t0\\.000s\n" - c.Assert(output.value, Matches, expected) -} - -func (s *BenchmarkS) TestStreamTestTiming(c *C) { - helper := FixtureHelper{sleepOn: "SetUpSuite", sleep: 1000000 * time.Nanosecond} - output := String{} - runConf := RunConf{Output: &output, Stream: true} - Run(&helper, &runConf) - - expected := "(?s).*\nPASS: check_test\\.go:[0-9]+: FixtureHelper\\.SetUpSuite\t *0\\.001s\n.*" - c.Assert(output.value, Matches, expected) -} - -func (s *BenchmarkS) TestBenchmark(c *C) { - helper := FixtureHelper{sleep: 100000} - output := String{} - runConf := RunConf{ - Output: &output, - Benchmark: true, - BenchmarkTime: 10000000, - Filter: "Benchmark1", - } - Run(&helper, &runConf) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Benchmark1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "SetUpTest") - c.Check(helper.calls[5], Equals, "Benchmark1") - c.Check(helper.calls[6], Equals, "TearDownTest") - // ... and more. - - expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n" - c.Assert(output.value, Matches, expected) -} - -func (s *BenchmarkS) TestBenchmarkBytes(c *C) { - helper := FixtureHelper{sleep: 100000} - output := String{} - runConf := RunConf{ - Output: &output, - Benchmark: true, - BenchmarkTime: 10000000, - Filter: "Benchmark2", - } - Run(&helper, &runConf) - - expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n" - c.Assert(output.value, Matches, expected) -} - -func (s *BenchmarkS) TestBenchmarkMem(c *C) { - helper := FixtureHelper{sleep: 100000} - output := String{} - runConf := RunConf{ - Output: &output, - Benchmark: true, - BenchmarkMem: true, - BenchmarkTime: 10000000, - Filter: "Benchmark3", - } - Run(&helper, &runConf) - - expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark3\t *100\t *[12][0-9]{5} ns/op\t *[0-9]+ B/op\t *[1-9] allocs/op\n" - c.Assert(output.value, Matches, expected) -} diff --git a/vendor/gopkg.in/check.v1/bootstrap_test.go b/vendor/gopkg.in/check.v1/bootstrap_test.go deleted file mode 100644 index e55f327c..00000000 --- a/vendor/gopkg.in/check.v1/bootstrap_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// These initial tests are for bootstrapping. They verify that we can -// basically use the testing infrastructure itself to check if the test -// system is working. -// -// These tests use will break down the test runner badly in case of -// errors because if they simply fail, we can't be sure the developer -// will ever see anything (because failing means the failing system -// somehow isn't working! :-) -// -// Do not assume *any* internal functionality works as expected besides -// what's actually tested here. - -package check_test - -import ( - "fmt" - "gopkg.in/check.v1" - "strings" -) - -type BootstrapS struct{} - -var boostrapS = check.Suite(&BootstrapS{}) - -func (s *BootstrapS) TestCountSuite(c *check.C) { - suitesRun += 1 -} - -func (s *BootstrapS) TestFailedAndFail(c *check.C) { - if c.Failed() { - critical("c.Failed() must be false first!") - } - c.Fail() - if !c.Failed() { - critical("c.Fail() didn't put the test in a failed state!") - } - c.Succeed() -} - -func (s *BootstrapS) TestFailedAndSucceed(c *check.C) { - c.Fail() - c.Succeed() - if c.Failed() { - critical("c.Succeed() didn't put the test back in a non-failed state") - } -} - -func (s *BootstrapS) TestLogAndGetTestLog(c *check.C) { - c.Log("Hello there!") - log := c.GetTestLog() - if log != "Hello there!\n" { - critical(fmt.Sprintf("Log() or GetTestLog() is not working! Got: %#v", log)) - } -} - -func (s *BootstrapS) TestLogfAndGetTestLog(c *check.C) { - c.Logf("Hello %v", "there!") - log := c.GetTestLog() - if log != "Hello there!\n" { - critical(fmt.Sprintf("Logf() or GetTestLog() is not working! Got: %#v", log)) - } -} - -func (s *BootstrapS) TestRunShowsErrors(c *check.C) { - output := String{} - check.Run(&FailHelper{}, &check.RunConf{Output: &output}) - if strings.Index(output.value, "Expected failure!") == -1 { - critical(fmt.Sprintf("RunWithWriter() output did not contain the "+ - "expected failure! Got: %#v", - output.value)) - } -} - -func (s *BootstrapS) TestRunDoesntShowSuccesses(c *check.C) { - output := String{} - check.Run(&SuccessHelper{}, &check.RunConf{Output: &output}) - if strings.Index(output.value, "Expected success!") != -1 { - critical(fmt.Sprintf("RunWithWriter() output contained a successful "+ - "test! Got: %#v", - output.value)) - } -} diff --git a/vendor/gopkg.in/check.v1/check_test.go b/vendor/gopkg.in/check.v1/check_test.go deleted file mode 100644 index 871b3252..00000000 --- a/vendor/gopkg.in/check.v1/check_test.go +++ /dev/null @@ -1,207 +0,0 @@ -// This file contains just a few generic helpers which are used by the -// other test files. - -package check_test - -import ( - "flag" - "fmt" - "os" - "regexp" - "runtime" - "testing" - "time" - - "gopkg.in/check.v1" -) - -// We count the number of suites run at least to get a vague hint that the -// test suite is behaving as it should. Otherwise a bug introduced at the -// very core of the system could go unperceived. -const suitesRunExpected = 8 - -var suitesRun int = 0 - -func Test(t *testing.T) { - check.TestingT(t) - if suitesRun != suitesRunExpected && flag.Lookup("check.f").Value.String() == "" { - critical(fmt.Sprintf("Expected %d suites to run rather than %d", - suitesRunExpected, suitesRun)) - } -} - -// ----------------------------------------------------------------------- -// Helper functions. - -// Break down badly. This is used in test cases which can't yet assume -// that the fundamental bits are working. -func critical(error string) { - fmt.Fprintln(os.Stderr, "CRITICAL: "+error) - os.Exit(1) -} - -// Return the file line where it's called. -func getMyLine() int { - if _, _, line, ok := runtime.Caller(1); ok { - return line - } - return -1 -} - -// ----------------------------------------------------------------------- -// Helper type implementing a basic io.Writer for testing output. - -// Type implementing the io.Writer interface for analyzing output. -type String struct { - value string -} - -// The only function required by the io.Writer interface. Will append -// written data to the String.value string. -func (s *String) Write(p []byte) (n int, err error) { - s.value += string(p) - return len(p), nil -} - -// Trivial wrapper to test errors happening on a different file -// than the test itself. -func checkEqualWrapper(c *check.C, obtained, expected interface{}) (result bool, line int) { - return c.Check(obtained, check.Equals, expected), getMyLine() -} - -// ----------------------------------------------------------------------- -// Helper suite for testing basic fail behavior. - -type FailHelper struct { - testLine int -} - -func (s *FailHelper) TestLogAndFail(c *check.C) { - s.testLine = getMyLine() - 1 - c.Log("Expected failure!") - c.Fail() -} - -// ----------------------------------------------------------------------- -// Helper suite for testing basic success behavior. - -type SuccessHelper struct{} - -func (s *SuccessHelper) TestLogAndSucceed(c *check.C) { - c.Log("Expected success!") -} - -// ----------------------------------------------------------------------- -// Helper suite for testing ordering and behavior of fixture. - -type FixtureHelper struct { - calls []string - panicOn string - skip bool - skipOnN int - sleepOn string - sleep time.Duration - bytes int64 -} - -func (s *FixtureHelper) trace(name string, c *check.C) { - s.calls = append(s.calls, name) - if name == s.panicOn { - panic(name) - } - if s.sleep > 0 && s.sleepOn == name { - time.Sleep(s.sleep) - } - if s.skip && s.skipOnN == len(s.calls)-1 { - c.Skip("skipOnN == n") - } -} - -func (s *FixtureHelper) SetUpSuite(c *check.C) { - s.trace("SetUpSuite", c) -} - -func (s *FixtureHelper) TearDownSuite(c *check.C) { - s.trace("TearDownSuite", c) -} - -func (s *FixtureHelper) SetUpTest(c *check.C) { - s.trace("SetUpTest", c) -} - -func (s *FixtureHelper) TearDownTest(c *check.C) { - s.trace("TearDownTest", c) -} - -func (s *FixtureHelper) Test1(c *check.C) { - s.trace("Test1", c) -} - -func (s *FixtureHelper) Test2(c *check.C) { - s.trace("Test2", c) -} - -func (s *FixtureHelper) Benchmark1(c *check.C) { - s.trace("Benchmark1", c) - for i := 0; i < c.N; i++ { - time.Sleep(s.sleep) - } -} - -func (s *FixtureHelper) Benchmark2(c *check.C) { - s.trace("Benchmark2", c) - c.SetBytes(1024) - for i := 0; i < c.N; i++ { - time.Sleep(s.sleep) - } -} - -func (s *FixtureHelper) Benchmark3(c *check.C) { - var x []int64 - s.trace("Benchmark3", c) - for i := 0; i < c.N; i++ { - time.Sleep(s.sleep) - x = make([]int64, 5) - _ = x - } -} - -// ----------------------------------------------------------------------- -// Helper which checks the state of the test and ensures that it matches -// the given expectations. Depends on c.Errorf() working, so shouldn't -// be used to test this one function. - -type expectedState struct { - name string - result interface{} - failed bool - log string -} - -// Verify the state of the test. Note that since this also verifies if -// the test is supposed to be in a failed state, no other checks should -// be done in addition to what is being tested. -func checkState(c *check.C, result interface{}, expected *expectedState) { - failed := c.Failed() - c.Succeed() - log := c.GetTestLog() - matched, matchError := regexp.MatchString("^"+expected.log+"$", log) - if matchError != nil { - c.Errorf("Error in matching expression used in testing %s", - expected.name) - } else if !matched { - c.Errorf("%s logged:\n----------\n%s----------\n\nExpected:\n----------\n%s\n----------", - expected.name, log, expected.log) - } - if result != expected.result { - c.Errorf("%s returned %#v rather than %#v", - expected.name, result, expected.result) - } - if failed != expected.failed { - if failed { - c.Errorf("%s has failed when it shouldn't", expected.name) - } else { - c.Errorf("%s has not failed when it should", expected.name) - } - } -} diff --git a/vendor/gopkg.in/check.v1/checkers_test.go b/vendor/gopkg.in/check.v1/checkers_test.go deleted file mode 100644 index 5c697474..00000000 --- a/vendor/gopkg.in/check.v1/checkers_test.go +++ /dev/null @@ -1,272 +0,0 @@ -package check_test - -import ( - "errors" - "gopkg.in/check.v1" - "reflect" - "runtime" -) - -type CheckersS struct{} - -var _ = check.Suite(&CheckersS{}) - -func testInfo(c *check.C, checker check.Checker, name string, paramNames []string) { - info := checker.Info() - if info.Name != name { - c.Fatalf("Got name %s, expected %s", info.Name, name) - } - if !reflect.DeepEqual(info.Params, paramNames) { - c.Fatalf("Got param names %#v, expected %#v", info.Params, paramNames) - } -} - -func testCheck(c *check.C, checker check.Checker, result bool, error string, params ...interface{}) ([]interface{}, []string) { - info := checker.Info() - if len(params) != len(info.Params) { - c.Fatalf("unexpected param count in test; expected %d got %d", len(info.Params), len(params)) - } - names := append([]string{}, info.Params...) - result_, error_ := checker.Check(params, names) - if result_ != result || error_ != error { - c.Fatalf("%s.Check(%#v) returned (%#v, %#v) rather than (%#v, %#v)", - info.Name, params, result_, error_, result, error) - } - return params, names -} - -func (s *CheckersS) TestComment(c *check.C) { - bug := check.Commentf("a %d bc", 42) - comment := bug.CheckCommentString() - if comment != "a 42 bc" { - c.Fatalf("Commentf returned %#v", comment) - } -} - -func (s *CheckersS) TestIsNil(c *check.C) { - testInfo(c, check.IsNil, "IsNil", []string{"value"}) - - testCheck(c, check.IsNil, true, "", nil) - testCheck(c, check.IsNil, false, "", "a") - - testCheck(c, check.IsNil, true, "", (chan int)(nil)) - testCheck(c, check.IsNil, false, "", make(chan int)) - testCheck(c, check.IsNil, true, "", (error)(nil)) - testCheck(c, check.IsNil, false, "", errors.New("")) - testCheck(c, check.IsNil, true, "", ([]int)(nil)) - testCheck(c, check.IsNil, false, "", make([]int, 1)) - testCheck(c, check.IsNil, false, "", int(0)) -} - -func (s *CheckersS) TestNotNil(c *check.C) { - testInfo(c, check.NotNil, "NotNil", []string{"value"}) - - testCheck(c, check.NotNil, false, "", nil) - testCheck(c, check.NotNil, true, "", "a") - - testCheck(c, check.NotNil, false, "", (chan int)(nil)) - testCheck(c, check.NotNil, true, "", make(chan int)) - testCheck(c, check.NotNil, false, "", (error)(nil)) - testCheck(c, check.NotNil, true, "", errors.New("")) - testCheck(c, check.NotNil, false, "", ([]int)(nil)) - testCheck(c, check.NotNil, true, "", make([]int, 1)) -} - -func (s *CheckersS) TestNot(c *check.C) { - testInfo(c, check.Not(check.IsNil), "Not(IsNil)", []string{"value"}) - - testCheck(c, check.Not(check.IsNil), false, "", nil) - testCheck(c, check.Not(check.IsNil), true, "", "a") -} - -type simpleStruct struct { - i int -} - -func (s *CheckersS) TestEquals(c *check.C) { - testInfo(c, check.Equals, "Equals", []string{"obtained", "expected"}) - - // The simplest. - testCheck(c, check.Equals, true, "", 42, 42) - testCheck(c, check.Equals, false, "", 42, 43) - - // Different native types. - testCheck(c, check.Equals, false, "", int32(42), int64(42)) - - // With nil. - testCheck(c, check.Equals, false, "", 42, nil) - - // Slices - testCheck(c, check.Equals, false, "runtime error: comparing uncomparable type []uint8", []byte{1, 2}, []byte{1, 2}) - - // Struct values - testCheck(c, check.Equals, true, "", simpleStruct{1}, simpleStruct{1}) - testCheck(c, check.Equals, false, "", simpleStruct{1}, simpleStruct{2}) - - // Struct pointers - testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{1}) - testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{2}) -} - -func (s *CheckersS) TestDeepEquals(c *check.C) { - testInfo(c, check.DeepEquals, "DeepEquals", []string{"obtained", "expected"}) - - // The simplest. - testCheck(c, check.DeepEquals, true, "", 42, 42) - testCheck(c, check.DeepEquals, false, "", 42, 43) - - // Different native types. - testCheck(c, check.DeepEquals, false, "", int32(42), int64(42)) - - // With nil. - testCheck(c, check.DeepEquals, false, "", 42, nil) - - // Slices - testCheck(c, check.DeepEquals, true, "", []byte{1, 2}, []byte{1, 2}) - testCheck(c, check.DeepEquals, false, "", []byte{1, 2}, []byte{1, 3}) - - // Struct values - testCheck(c, check.DeepEquals, true, "", simpleStruct{1}, simpleStruct{1}) - testCheck(c, check.DeepEquals, false, "", simpleStruct{1}, simpleStruct{2}) - - // Struct pointers - testCheck(c, check.DeepEquals, true, "", &simpleStruct{1}, &simpleStruct{1}) - testCheck(c, check.DeepEquals, false, "", &simpleStruct{1}, &simpleStruct{2}) -} - -func (s *CheckersS) TestHasLen(c *check.C) { - testInfo(c, check.HasLen, "HasLen", []string{"obtained", "n"}) - - testCheck(c, check.HasLen, true, "", "abcd", 4) - testCheck(c, check.HasLen, true, "", []int{1, 2}, 2) - testCheck(c, check.HasLen, false, "", []int{1, 2}, 3) - - testCheck(c, check.HasLen, false, "n must be an int", []int{1, 2}, "2") - testCheck(c, check.HasLen, false, "obtained value type has no length", nil, 2) -} - -func (s *CheckersS) TestErrorMatches(c *check.C) { - testInfo(c, check.ErrorMatches, "ErrorMatches", []string{"value", "regex"}) - - testCheck(c, check.ErrorMatches, false, "Error value is nil", nil, "some error") - testCheck(c, check.ErrorMatches, false, "Value is not an error", 1, "some error") - testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "some error") - testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "so.*or") - - // Verify params mutation - params, names := testCheck(c, check.ErrorMatches, false, "", errors.New("some error"), "other error") - c.Assert(params[0], check.Equals, "some error") - c.Assert(names[0], check.Equals, "error") -} - -func (s *CheckersS) TestMatches(c *check.C) { - testInfo(c, check.Matches, "Matches", []string{"value", "regex"}) - - // Simple matching - testCheck(c, check.Matches, true, "", "abc", "abc") - testCheck(c, check.Matches, true, "", "abc", "a.c") - - // Must match fully - testCheck(c, check.Matches, false, "", "abc", "ab") - testCheck(c, check.Matches, false, "", "abc", "bc") - - // String()-enabled values accepted - testCheck(c, check.Matches, true, "", reflect.ValueOf("abc"), "a.c") - testCheck(c, check.Matches, false, "", reflect.ValueOf("abc"), "a.d") - - // Some error conditions. - testCheck(c, check.Matches, false, "Obtained value is not a string and has no .String()", 1, "a.c") - testCheck(c, check.Matches, false, "Can't compile regex: error parsing regexp: missing closing ]: `[c$`", "abc", "a[c") -} - -func (s *CheckersS) TestPanics(c *check.C) { - testInfo(c, check.Panics, "Panics", []string{"function", "expected"}) - - // Some errors. - testCheck(c, check.Panics, false, "Function has not panicked", func() bool { return false }, "BOOM") - testCheck(c, check.Panics, false, "Function must take zero arguments", 1, "BOOM") - - // Plain strings. - testCheck(c, check.Panics, true, "", func() { panic("BOOM") }, "BOOM") - testCheck(c, check.Panics, false, "", func() { panic("KABOOM") }, "BOOM") - testCheck(c, check.Panics, true, "", func() bool { panic("BOOM") }, "BOOM") - - // Error values. - testCheck(c, check.Panics, true, "", func() { panic(errors.New("BOOM")) }, errors.New("BOOM")) - testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM")) - - type deep struct{ i int } - // Deep value - testCheck(c, check.Panics, true, "", func() { panic(&deep{99}) }, &deep{99}) - - // Verify params/names mutation - params, names := testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM")) - c.Assert(params[0], check.ErrorMatches, "KABOOM") - c.Assert(names[0], check.Equals, "panic") - - // Verify a nil panic - testCheck(c, check.Panics, true, "", func() { panic(nil) }, nil) - testCheck(c, check.Panics, false, "", func() { panic(nil) }, "NOPE") -} - -func (s *CheckersS) TestPanicMatches(c *check.C) { - testInfo(c, check.PanicMatches, "PanicMatches", []string{"function", "expected"}) - - // Error matching. - testCheck(c, check.PanicMatches, true, "", func() { panic(errors.New("BOOM")) }, "BO.M") - testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BO.M") - - // Some errors. - testCheck(c, check.PanicMatches, false, "Function has not panicked", func() bool { return false }, "BOOM") - testCheck(c, check.PanicMatches, false, "Function must take zero arguments", 1, "BOOM") - - // Plain strings. - testCheck(c, check.PanicMatches, true, "", func() { panic("BOOM") }, "BO.M") - testCheck(c, check.PanicMatches, false, "", func() { panic("KABOOM") }, "BOOM") - testCheck(c, check.PanicMatches, true, "", func() bool { panic("BOOM") }, "BO.M") - - // Verify params/names mutation - params, names := testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BOOM") - c.Assert(params[0], check.Equals, "KABOOM") - c.Assert(names[0], check.Equals, "panic") - - // Verify a nil panic - testCheck(c, check.PanicMatches, false, "Panic value is not a string or an error", func() { panic(nil) }, "") -} - -func (s *CheckersS) TestFitsTypeOf(c *check.C) { - testInfo(c, check.FitsTypeOf, "FitsTypeOf", []string{"obtained", "sample"}) - - // Basic types - testCheck(c, check.FitsTypeOf, true, "", 1, 0) - testCheck(c, check.FitsTypeOf, false, "", 1, int64(0)) - - // Aliases - testCheck(c, check.FitsTypeOf, false, "", 1, errors.New("")) - testCheck(c, check.FitsTypeOf, false, "", "error", errors.New("")) - testCheck(c, check.FitsTypeOf, true, "", errors.New("error"), errors.New("")) - - // Structures - testCheck(c, check.FitsTypeOf, false, "", 1, simpleStruct{}) - testCheck(c, check.FitsTypeOf, false, "", simpleStruct{42}, &simpleStruct{}) - testCheck(c, check.FitsTypeOf, true, "", simpleStruct{42}, simpleStruct{}) - testCheck(c, check.FitsTypeOf, true, "", &simpleStruct{42}, &simpleStruct{}) - - // Some bad values - testCheck(c, check.FitsTypeOf, false, "Invalid sample value", 1, interface{}(nil)) - testCheck(c, check.FitsTypeOf, false, "", interface{}(nil), 0) -} - -func (s *CheckersS) TestImplements(c *check.C) { - testInfo(c, check.Implements, "Implements", []string{"obtained", "ifaceptr"}) - - var e error - var re runtime.Error - testCheck(c, check.Implements, true, "", errors.New(""), &e) - testCheck(c, check.Implements, false, "", errors.New(""), &re) - - // Some bad values - testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, errors.New("")) - testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, interface{}(nil)) - testCheck(c, check.Implements, false, "", interface{}(nil), &e) -} diff --git a/vendor/gopkg.in/check.v1/export_test.go b/vendor/gopkg.in/check.v1/export_test.go deleted file mode 100644 index abb89a2d..00000000 --- a/vendor/gopkg.in/check.v1/export_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package check - -import "io" - -func PrintLine(filename string, line int) (string, error) { - return printLine(filename, line) -} - -func Indent(s, with string) string { - return indent(s, with) -} - -func NewOutputWriter(writer io.Writer, stream, verbose bool) *outputWriter { - return newOutputWriter(writer, stream, verbose) -} - -func (c *C) FakeSkip(reason string) { - c.reason = reason -} diff --git a/vendor/gopkg.in/check.v1/fixture_test.go b/vendor/gopkg.in/check.v1/fixture_test.go deleted file mode 100644 index 2bff9e16..00000000 --- a/vendor/gopkg.in/check.v1/fixture_test.go +++ /dev/null @@ -1,484 +0,0 @@ -// Tests for the behavior of the test fixture system. - -package check_test - -import ( - . "gopkg.in/check.v1" -) - -// ----------------------------------------------------------------------- -// Fixture test suite. - -type FixtureS struct{} - -var fixtureS = Suite(&FixtureS{}) - -func (s *FixtureS) TestCountSuite(c *C) { - suitesRun += 1 -} - -// ----------------------------------------------------------------------- -// Basic fixture ordering verification. - -func (s *FixtureS) TestOrder(c *C) { - helper := FixtureHelper{} - Run(&helper, nil) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "SetUpTest") - c.Check(helper.calls[5], Equals, "Test2") - c.Check(helper.calls[6], Equals, "TearDownTest") - c.Check(helper.calls[7], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 8) -} - -// ----------------------------------------------------------------------- -// Check the behavior when panics occur within tests and fixtures. - -func (s *FixtureS) TestPanicOnTest(c *C) { - helper := FixtureHelper{panicOn: "Test1"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "SetUpTest") - c.Check(helper.calls[5], Equals, "Test2") - c.Check(helper.calls[6], Equals, "TearDownTest") - c.Check(helper.calls[7], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 8) - - expected := "^\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: FixtureHelper.Test1\n\n" + - "\\.\\.\\. Panic: Test1 \\(PC=[xA-F0-9]+\\)\n\n" + - ".+:[0-9]+\n" + - " in (go)?panic\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.trace\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.Test1\n" + - "(.|\n)*$" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnSetUpTest(c *C) { - helper := FixtureHelper{panicOn: "SetUpTest"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "TearDownTest") - c.Check(helper.calls[3], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 4) - - expected := "^\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: " + - "FixtureHelper\\.SetUpTest\n\n" + - "\\.\\.\\. Panic: SetUpTest \\(PC=[xA-F0-9]+\\)\n\n" + - ".+:[0-9]+\n" + - " in (go)?panic\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.trace\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.SetUpTest\n" + - "(.|\n)*" + - "\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: " + - "FixtureHelper\\.Test1\n\n" + - "\\.\\.\\. Panic: Fixture has panicked " + - "\\(see related PANIC\\)\n$" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnTearDownTest(c *C) { - helper := FixtureHelper{panicOn: "TearDownTest"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 5) - - expected := "^\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: " + - "FixtureHelper.TearDownTest\n\n" + - "\\.\\.\\. Panic: TearDownTest \\(PC=[xA-F0-9]+\\)\n\n" + - ".+:[0-9]+\n" + - " in (go)?panic\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.trace\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.TearDownTest\n" + - "(.|\n)*" + - "\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: " + - "FixtureHelper\\.Test1\n\n" + - "\\.\\.\\. Panic: Fixture has panicked " + - "\\(see related PANIC\\)\n$" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnSetUpSuite(c *C) { - helper := FixtureHelper{panicOn: "SetUpSuite"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 2) - - expected := "^\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: " + - "FixtureHelper.SetUpSuite\n\n" + - "\\.\\.\\. Panic: SetUpSuite \\(PC=[xA-F0-9]+\\)\n\n" + - ".+:[0-9]+\n" + - " in (go)?panic\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.trace\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.SetUpSuite\n" + - "(.|\n)*$" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnTearDownSuite(c *C) { - helper := FixtureHelper{panicOn: "TearDownSuite"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "SetUpTest") - c.Check(helper.calls[5], Equals, "Test2") - c.Check(helper.calls[6], Equals, "TearDownTest") - c.Check(helper.calls[7], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 8) - - expected := "^\n-+\n" + - "PANIC: check_test\\.go:[0-9]+: " + - "FixtureHelper.TearDownSuite\n\n" + - "\\.\\.\\. Panic: TearDownSuite \\(PC=[xA-F0-9]+\\)\n\n" + - ".+:[0-9]+\n" + - " in (go)?panic\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.trace\n" + - ".*check_test.go:[0-9]+\n" + - " in FixtureHelper.TearDownSuite\n" + - "(.|\n)*$" - - c.Check(output.value, Matches, expected) -} - -// ----------------------------------------------------------------------- -// A wrong argument on a test or fixture will produce a nice error. - -func (s *FixtureS) TestPanicOnWrongTestArg(c *C) { - helper := WrongTestArgHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "TearDownTest") - c.Check(helper.calls[3], Equals, "SetUpTest") - c.Check(helper.calls[4], Equals, "Test2") - c.Check(helper.calls[5], Equals, "TearDownTest") - c.Check(helper.calls[6], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 7) - - expected := "^\n-+\n" + - "PANIC: fixture_test\\.go:[0-9]+: " + - "WrongTestArgHelper\\.Test1\n\n" + - "\\.\\.\\. Panic: WrongTestArgHelper\\.Test1 argument " + - "should be \\*check\\.C\n" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnWrongSetUpTestArg(c *C) { - helper := WrongSetUpTestArgHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(len(helper.calls), Equals, 0) - - expected := - "^\n-+\n" + - "PANIC: fixture_test\\.go:[0-9]+: " + - "WrongSetUpTestArgHelper\\.SetUpTest\n\n" + - "\\.\\.\\. Panic: WrongSetUpTestArgHelper\\.SetUpTest argument " + - "should be \\*check\\.C\n" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnWrongSetUpSuiteArg(c *C) { - helper := WrongSetUpSuiteArgHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(len(helper.calls), Equals, 0) - - expected := - "^\n-+\n" + - "PANIC: fixture_test\\.go:[0-9]+: " + - "WrongSetUpSuiteArgHelper\\.SetUpSuite\n\n" + - "\\.\\.\\. Panic: WrongSetUpSuiteArgHelper\\.SetUpSuite argument " + - "should be \\*check\\.C\n" - - c.Check(output.value, Matches, expected) -} - -// ----------------------------------------------------------------------- -// Nice errors also when tests or fixture have wrong arg count. - -func (s *FixtureS) TestPanicOnWrongTestArgCount(c *C) { - helper := WrongTestArgCountHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "TearDownTest") - c.Check(helper.calls[3], Equals, "SetUpTest") - c.Check(helper.calls[4], Equals, "Test2") - c.Check(helper.calls[5], Equals, "TearDownTest") - c.Check(helper.calls[6], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 7) - - expected := "^\n-+\n" + - "PANIC: fixture_test\\.go:[0-9]+: " + - "WrongTestArgCountHelper\\.Test1\n\n" + - "\\.\\.\\. Panic: WrongTestArgCountHelper\\.Test1 argument " + - "should be \\*check\\.C\n" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnWrongSetUpTestArgCount(c *C) { - helper := WrongSetUpTestArgCountHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(len(helper.calls), Equals, 0) - - expected := - "^\n-+\n" + - "PANIC: fixture_test\\.go:[0-9]+: " + - "WrongSetUpTestArgCountHelper\\.SetUpTest\n\n" + - "\\.\\.\\. Panic: WrongSetUpTestArgCountHelper\\.SetUpTest argument " + - "should be \\*check\\.C\n" - - c.Check(output.value, Matches, expected) -} - -func (s *FixtureS) TestPanicOnWrongSetUpSuiteArgCount(c *C) { - helper := WrongSetUpSuiteArgCountHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(len(helper.calls), Equals, 0) - - expected := - "^\n-+\n" + - "PANIC: fixture_test\\.go:[0-9]+: " + - "WrongSetUpSuiteArgCountHelper\\.SetUpSuite\n\n" + - "\\.\\.\\. Panic: WrongSetUpSuiteArgCountHelper" + - "\\.SetUpSuite argument should be \\*check\\.C\n" - - c.Check(output.value, Matches, expected) -} - -// ----------------------------------------------------------------------- -// Helper test suites with wrong function arguments. - -type WrongTestArgHelper struct { - FixtureHelper -} - -func (s *WrongTestArgHelper) Test1(t int) { -} - -type WrongSetUpTestArgHelper struct { - FixtureHelper -} - -func (s *WrongSetUpTestArgHelper) SetUpTest(t int) { -} - -type WrongSetUpSuiteArgHelper struct { - FixtureHelper -} - -func (s *WrongSetUpSuiteArgHelper) SetUpSuite(t int) { -} - -type WrongTestArgCountHelper struct { - FixtureHelper -} - -func (s *WrongTestArgCountHelper) Test1(c *C, i int) { -} - -type WrongSetUpTestArgCountHelper struct { - FixtureHelper -} - -func (s *WrongSetUpTestArgCountHelper) SetUpTest(c *C, i int) { -} - -type WrongSetUpSuiteArgCountHelper struct { - FixtureHelper -} - -func (s *WrongSetUpSuiteArgCountHelper) SetUpSuite(c *C, i int) { -} - -// ----------------------------------------------------------------------- -// Ensure fixture doesn't run without tests. - -type NoTestsHelper struct { - hasRun bool -} - -func (s *NoTestsHelper) SetUpSuite(c *C) { - s.hasRun = true -} - -func (s *NoTestsHelper) TearDownSuite(c *C) { - s.hasRun = true -} - -func (s *FixtureS) TestFixtureDoesntRunWithoutTests(c *C) { - helper := NoTestsHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Check(helper.hasRun, Equals, false) -} - -// ----------------------------------------------------------------------- -// Verify that checks and assertions work correctly inside the fixture. - -type FixtureCheckHelper struct { - fail string - completed bool -} - -func (s *FixtureCheckHelper) SetUpSuite(c *C) { - switch s.fail { - case "SetUpSuiteAssert": - c.Assert(false, Equals, true) - case "SetUpSuiteCheck": - c.Check(false, Equals, true) - } - s.completed = true -} - -func (s *FixtureCheckHelper) SetUpTest(c *C) { - switch s.fail { - case "SetUpTestAssert": - c.Assert(false, Equals, true) - case "SetUpTestCheck": - c.Check(false, Equals, true) - } - s.completed = true -} - -func (s *FixtureCheckHelper) Test(c *C) { - // Do nothing. -} - -func (s *FixtureS) TestSetUpSuiteCheck(c *C) { - helper := FixtureCheckHelper{fail: "SetUpSuiteCheck"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Assert(output.value, Matches, - "\n---+\n"+ - "FAIL: fixture_test\\.go:[0-9]+: "+ - "FixtureCheckHelper\\.SetUpSuite\n\n"+ - "fixture_test\\.go:[0-9]+:\n"+ - " c\\.Check\\(false, Equals, true\\)\n"+ - "\\.+ obtained bool = false\n"+ - "\\.+ expected bool = true\n\n") - c.Assert(helper.completed, Equals, true) -} - -func (s *FixtureS) TestSetUpSuiteAssert(c *C) { - helper := FixtureCheckHelper{fail: "SetUpSuiteAssert"} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Assert(output.value, Matches, - "\n---+\n"+ - "FAIL: fixture_test\\.go:[0-9]+: "+ - "FixtureCheckHelper\\.SetUpSuite\n\n"+ - "fixture_test\\.go:[0-9]+:\n"+ - " c\\.Assert\\(false, Equals, true\\)\n"+ - "\\.+ obtained bool = false\n"+ - "\\.+ expected bool = true\n\n") - c.Assert(helper.completed, Equals, false) -} - -// ----------------------------------------------------------------------- -// Verify that logging within SetUpTest() persists within the test log itself. - -type FixtureLogHelper struct { - c *C -} - -func (s *FixtureLogHelper) SetUpTest(c *C) { - s.c = c - c.Log("1") -} - -func (s *FixtureLogHelper) Test(c *C) { - c.Log("2") - s.c.Log("3") - c.Log("4") - c.Fail() -} - -func (s *FixtureLogHelper) TearDownTest(c *C) { - s.c.Log("5") -} - -func (s *FixtureS) TestFixtureLogging(c *C) { - helper := FixtureLogHelper{} - output := String{} - Run(&helper, &RunConf{Output: &output}) - c.Assert(output.value, Matches, - "\n---+\n"+ - "FAIL: fixture_test\\.go:[0-9]+: "+ - "FixtureLogHelper\\.Test\n\n"+ - "1\n2\n3\n4\n5\n") -} - -// ----------------------------------------------------------------------- -// Skip() within fixture methods. - -func (s *FixtureS) TestSkipSuite(c *C) { - helper := FixtureHelper{skip: true, skipOnN: 0} - output := String{} - result := Run(&helper, &RunConf{Output: &output}) - c.Assert(output.value, Equals, "") - c.Assert(helper.calls[0], Equals, "SetUpSuite") - c.Assert(helper.calls[1], Equals, "TearDownSuite") - c.Assert(len(helper.calls), Equals, 2) - c.Assert(result.Skipped, Equals, 2) -} - -func (s *FixtureS) TestSkipTest(c *C) { - helper := FixtureHelper{skip: true, skipOnN: 1} - output := String{} - result := Run(&helper, &RunConf{Output: &output}) - c.Assert(helper.calls[0], Equals, "SetUpSuite") - c.Assert(helper.calls[1], Equals, "SetUpTest") - c.Assert(helper.calls[2], Equals, "SetUpTest") - c.Assert(helper.calls[3], Equals, "Test2") - c.Assert(helper.calls[4], Equals, "TearDownTest") - c.Assert(helper.calls[5], Equals, "TearDownSuite") - c.Assert(len(helper.calls), Equals, 6) - c.Assert(result.Skipped, Equals, 1) -} diff --git a/vendor/gopkg.in/check.v1/foundation_test.go b/vendor/gopkg.in/check.v1/foundation_test.go deleted file mode 100644 index 8ecf7915..00000000 --- a/vendor/gopkg.in/check.v1/foundation_test.go +++ /dev/null @@ -1,335 +0,0 @@ -// These tests check that the foundations of gocheck are working properly. -// They already assume that fundamental failing is working already, though, -// since this was tested in bootstrap_test.go. Even then, some care may -// still have to be taken when using external functions, since they should -// of course not rely on functionality tested here. - -package check_test - -import ( - "fmt" - "gopkg.in/check.v1" - "log" - "os" - "regexp" - "strings" -) - -// ----------------------------------------------------------------------- -// Foundation test suite. - -type FoundationS struct{} - -var foundationS = check.Suite(&FoundationS{}) - -func (s *FoundationS) TestCountSuite(c *check.C) { - suitesRun += 1 -} - -func (s *FoundationS) TestErrorf(c *check.C) { - // Do not use checkState() here. It depends on Errorf() working. - expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+ - " c.Errorf(\"Error %%v!\", \"message\")\n"+ - "... Error: Error message!\n\n", - getMyLine()+1) - c.Errorf("Error %v!", "message") - failed := c.Failed() - c.Succeed() - if log := c.GetTestLog(); log != expectedLog { - c.Logf("Errorf() logged %#v rather than %#v", log, expectedLog) - c.Fail() - } - if !failed { - c.Logf("Errorf() didn't put the test in a failed state") - c.Fail() - } -} - -func (s *FoundationS) TestError(c *check.C) { - expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+ - " c\\.Error\\(\"Error \", \"message!\"\\)\n"+ - "\\.\\.\\. Error: Error message!\n\n", - getMyLine()+1) - c.Error("Error ", "message!") - checkState(c, nil, - &expectedState{ - name: "Error(`Error `, `message!`)", - failed: true, - log: expectedLog, - }) -} - -func (s *FoundationS) TestFailNow(c *check.C) { - defer (func() { - if !c.Failed() { - c.Error("FailNow() didn't fail the test") - } else { - c.Succeed() - if c.GetTestLog() != "" { - c.Error("Something got logged:\n" + c.GetTestLog()) - } - } - })() - - c.FailNow() - c.Log("FailNow() didn't stop the test") -} - -func (s *FoundationS) TestSucceedNow(c *check.C) { - defer (func() { - if c.Failed() { - c.Error("SucceedNow() didn't succeed the test") - } - if c.GetTestLog() != "" { - c.Error("Something got logged:\n" + c.GetTestLog()) - } - })() - - c.Fail() - c.SucceedNow() - c.Log("SucceedNow() didn't stop the test") -} - -func (s *FoundationS) TestFailureHeader(c *check.C) { - output := String{} - failHelper := FailHelper{} - check.Run(&failHelper, &check.RunConf{Output: &output}) - header := fmt.Sprintf(""+ - "\n-----------------------------------"+ - "-----------------------------------\n"+ - "FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n", - failHelper.testLine) - if strings.Index(output.value, header) == -1 { - c.Errorf(""+ - "Failure didn't print a proper header.\n"+ - "... Got:\n%s... Expected something with:\n%s", - output.value, header) - } -} - -func (s *FoundationS) TestFatal(c *check.C) { - var line int - defer (func() { - if !c.Failed() { - c.Error("Fatal() didn't fail the test") - } else { - c.Succeed() - expected := fmt.Sprintf("foundation_test.go:%d:\n"+ - " c.Fatal(\"Die \", \"now!\")\n"+ - "... Error: Die now!\n\n", - line) - if c.GetTestLog() != expected { - c.Error("Incorrect log:", c.GetTestLog()) - } - } - })() - - line = getMyLine() + 1 - c.Fatal("Die ", "now!") - c.Log("Fatal() didn't stop the test") -} - -func (s *FoundationS) TestFatalf(c *check.C) { - var line int - defer (func() { - if !c.Failed() { - c.Error("Fatalf() didn't fail the test") - } else { - c.Succeed() - expected := fmt.Sprintf("foundation_test.go:%d:\n"+ - " c.Fatalf(\"Die %%s!\", \"now\")\n"+ - "... Error: Die now!\n\n", - line) - if c.GetTestLog() != expected { - c.Error("Incorrect log:", c.GetTestLog()) - } - } - })() - - line = getMyLine() + 1 - c.Fatalf("Die %s!", "now") - c.Log("Fatalf() didn't stop the test") -} - -func (s *FoundationS) TestCallerLoggingInsideTest(c *check.C) { - log := fmt.Sprintf(""+ - "foundation_test.go:%d:\n"+ - " result := c.Check\\(10, check.Equals, 20\\)\n"+ - "\\.\\.\\. obtained int = 10\n"+ - "\\.\\.\\. expected int = 20\n\n", - getMyLine()+1) - result := c.Check(10, check.Equals, 20) - checkState(c, result, - &expectedState{ - name: "Check(10, Equals, 20)", - result: false, - failed: true, - log: log, - }) -} - -func (s *FoundationS) TestCallerLoggingInDifferentFile(c *check.C) { - result, line := checkEqualWrapper(c, 10, 20) - testLine := getMyLine() - 1 - log := fmt.Sprintf(""+ - "foundation_test.go:%d:\n"+ - " result, line := checkEqualWrapper\\(c, 10, 20\\)\n"+ - "check_test.go:%d:\n"+ - " return c.Check\\(obtained, check.Equals, expected\\), getMyLine\\(\\)\n"+ - "\\.\\.\\. obtained int = 10\n"+ - "\\.\\.\\. expected int = 20\n\n", - testLine, line) - checkState(c, result, - &expectedState{ - name: "Check(10, Equals, 20)", - result: false, - failed: true, - log: log, - }) -} - -// ----------------------------------------------------------------------- -// ExpectFailure() inverts the logic of failure. - -type ExpectFailureSucceedHelper struct{} - -func (s *ExpectFailureSucceedHelper) TestSucceed(c *check.C) { - c.ExpectFailure("It booms!") - c.Error("Boom!") -} - -type ExpectFailureFailHelper struct{} - -func (s *ExpectFailureFailHelper) TestFail(c *check.C) { - c.ExpectFailure("Bug #XYZ") -} - -func (s *FoundationS) TestExpectFailureFail(c *check.C) { - helper := ExpectFailureFailHelper{} - output := String{} - result := check.Run(&helper, &check.RunConf{Output: &output}) - - expected := "" + - "^\n-+\n" + - "FAIL: foundation_test\\.go:[0-9]+:" + - " ExpectFailureFailHelper\\.TestFail\n\n" + - "\\.\\.\\. Error: Test succeeded, but was expected to fail\n" + - "\\.\\.\\. Reason: Bug #XYZ\n$" - - matched, err := regexp.MatchString(expected, output.value) - if err != nil { - c.Error("Bad expression: ", expected) - } else if !matched { - c.Error("ExpectFailure() didn't log properly:\n", output.value) - } - - c.Assert(result.ExpectedFailures, check.Equals, 0) -} - -func (s *FoundationS) TestExpectFailureSucceed(c *check.C) { - helper := ExpectFailureSucceedHelper{} - output := String{} - result := check.Run(&helper, &check.RunConf{Output: &output}) - - c.Assert(output.value, check.Equals, "") - c.Assert(result.ExpectedFailures, check.Equals, 1) -} - -func (s *FoundationS) TestExpectFailureSucceedVerbose(c *check.C) { - helper := ExpectFailureSucceedHelper{} - output := String{} - result := check.Run(&helper, &check.RunConf{Output: &output, Verbose: true}) - - expected := "" + - "FAIL EXPECTED: foundation_test\\.go:[0-9]+:" + - " ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n" - - matched, err := regexp.MatchString(expected, output.value) - if err != nil { - c.Error("Bad expression: ", expected) - } else if !matched { - c.Error("ExpectFailure() didn't log properly:\n", output.value) - } - - c.Assert(result.ExpectedFailures, check.Equals, 1) -} - -// ----------------------------------------------------------------------- -// Skip() allows stopping a test without positive/negative results. - -type SkipTestHelper struct{} - -func (s *SkipTestHelper) TestFail(c *check.C) { - c.Skip("Wrong platform or whatever") - c.Error("Boom!") -} - -func (s *FoundationS) TestSkip(c *check.C) { - helper := SkipTestHelper{} - output := String{} - check.Run(&helper, &check.RunConf{Output: &output}) - - if output.value != "" { - c.Error("Skip() logged something:\n", output.value) - } -} - -func (s *FoundationS) TestSkipVerbose(c *check.C) { - helper := SkipTestHelper{} - output := String{} - check.Run(&helper, &check.RunConf{Output: &output, Verbose: true}) - - expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" + - " \\(Wrong platform or whatever\\)" - matched, err := regexp.MatchString(expected, output.value) - if err != nil { - c.Error("Bad expression: ", expected) - } else if !matched { - c.Error("Skip() didn't log properly:\n", output.value) - } -} - -// ----------------------------------------------------------------------- -// Check minimum *log.Logger interface provided by *check.C. - -type minLogger interface { - Output(calldepth int, s string) error -} - -func (s *BootstrapS) TestMinLogger(c *check.C) { - var logger minLogger - logger = log.New(os.Stderr, "", 0) - logger = c - logger.Output(0, "Hello there") - expected := `\[LOG\] [0-9]+:[0-9][0-9]\.[0-9][0-9][0-9] +Hello there\n` - output := c.GetTestLog() - c.Assert(output, check.Matches, expected) -} - -// ----------------------------------------------------------------------- -// Ensure that suites with embedded types are working fine, including the -// the workaround for issue 906. - -type EmbeddedInternalS struct { - called bool -} - -type EmbeddedS struct { - EmbeddedInternalS -} - -var embeddedS = check.Suite(&EmbeddedS{}) - -func (s *EmbeddedS) TestCountSuite(c *check.C) { - suitesRun += 1 -} - -func (s *EmbeddedInternalS) TestMethod(c *check.C) { - c.Error("TestMethod() of the embedded type was called!?") -} - -func (s *EmbeddedS) TestMethod(c *check.C) { - // http://code.google.com/p/go/issues/detail?id=906 - c.Check(s.called, check.Equals, false) // Go issue 906 is affecting the runner? - s.called = true -} diff --git a/vendor/gopkg.in/check.v1/helpers_test.go b/vendor/gopkg.in/check.v1/helpers_test.go deleted file mode 100644 index 4baa656b..00000000 --- a/vendor/gopkg.in/check.v1/helpers_test.go +++ /dev/null @@ -1,519 +0,0 @@ -// These tests verify the inner workings of the helper methods associated -// with check.T. - -package check_test - -import ( - "gopkg.in/check.v1" - "os" - "reflect" - "runtime" - "sync" -) - -var helpersS = check.Suite(&HelpersS{}) - -type HelpersS struct{} - -func (s *HelpersS) TestCountSuite(c *check.C) { - suitesRun += 1 -} - -// ----------------------------------------------------------------------- -// Fake checker and bug info to verify the behavior of Assert() and Check(). - -type MyChecker struct { - info *check.CheckerInfo - params []interface{} - names []string - result bool - error string -} - -func (checker *MyChecker) Info() *check.CheckerInfo { - if checker.info == nil { - return &check.CheckerInfo{Name: "MyChecker", Params: []string{"myobtained", "myexpected"}} - } - return checker.info -} - -func (checker *MyChecker) Check(params []interface{}, names []string) (bool, string) { - rparams := checker.params - rnames := checker.names - checker.params = append([]interface{}{}, params...) - checker.names = append([]string{}, names...) - if rparams != nil { - copy(params, rparams) - } - if rnames != nil { - copy(names, rnames) - } - return checker.result, checker.error -} - -type myCommentType string - -func (c myCommentType) CheckCommentString() string { - return string(c) -} - -func myComment(s string) myCommentType { - return myCommentType(s) -} - -// ----------------------------------------------------------------------- -// Ensure a real checker actually works fine. - -func (s *HelpersS) TestCheckerInterface(c *check.C) { - testHelperSuccess(c, "Check(1, Equals, 1)", true, func() interface{} { - return c.Check(1, check.Equals, 1) - }) -} - -// ----------------------------------------------------------------------- -// Tests for Check(), mostly the same as for Assert() following these. - -func (s *HelpersS) TestCheckSucceedWithExpected(c *check.C) { - checker := &MyChecker{result: true} - testHelperSuccess(c, "Check(1, checker, 2)", true, func() interface{} { - return c.Check(1, checker, 2) - }) - if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) { - c.Fatalf("Bad params for check: %#v", checker.params) - } -} - -func (s *HelpersS) TestCheckSucceedWithoutExpected(c *check.C) { - checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}} - testHelperSuccess(c, "Check(1, checker)", true, func() interface{} { - return c.Check(1, checker) - }) - if !reflect.DeepEqual(checker.params, []interface{}{1}) { - c.Fatalf("Bad params for check: %#v", checker.params) - } -} - -func (s *HelpersS) TestCheckFailWithExpected(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker, 2\\)\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n\n" - testHelperFailure(c, "Check(1, checker, 2)", false, false, log, - func() interface{} { - return c.Check(1, checker, 2) - }) -} - -func (s *HelpersS) TestCheckFailWithExpectedAndComment(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n" + - "\\.+ Hello world!\n\n" - testHelperFailure(c, "Check(1, checker, 2, msg)", false, false, log, - func() interface{} { - return c.Check(1, checker, 2, myComment("Hello world!")) - }) -} - -func (s *HelpersS) TestCheckFailWithExpectedAndStaticComment(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " // Nice leading comment\\.\n" + - " return c\\.Check\\(1, checker, 2\\) // Hello there\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n\n" - testHelperFailure(c, "Check(1, checker, 2, msg)", false, false, log, - func() interface{} { - // Nice leading comment. - return c.Check(1, checker, 2) // Hello there - }) -} - -func (s *HelpersS) TestCheckFailWithoutExpected(c *check.C) { - checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker\\)\n" + - "\\.+ myvalue int = 1\n\n" - testHelperFailure(c, "Check(1, checker)", false, false, log, - func() interface{} { - return c.Check(1, checker) - }) -} - -func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *check.C) { - checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" + - "\\.+ myvalue int = 1\n" + - "\\.+ Hello world!\n\n" - testHelperFailure(c, "Check(1, checker, msg)", false, false, log, - func() interface{} { - return c.Check(1, checker, myComment("Hello world!")) - }) -} - -func (s *HelpersS) TestCheckWithMissingExpected(c *check.C) { - checker := &MyChecker{result: true} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker\\)\n" + - "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" + - "\\.+ Wrong number of parameters for MyChecker: " + - "want 3, got 2\n\n" - testHelperFailure(c, "Check(1, checker, !?)", false, false, log, - func() interface{} { - return c.Check(1, checker) - }) -} - -func (s *HelpersS) TestCheckWithTooManyExpected(c *check.C) { - checker := &MyChecker{result: true} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker, 2, 3\\)\n" + - "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" + - "\\.+ Wrong number of parameters for MyChecker: " + - "want 3, got 4\n\n" - testHelperFailure(c, "Check(1, checker, 2, 3)", false, false, log, - func() interface{} { - return c.Check(1, checker, 2, 3) - }) -} - -func (s *HelpersS) TestCheckWithError(c *check.C) { - checker := &MyChecker{result: false, error: "Some not so cool data provided!"} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker, 2\\)\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n" + - "\\.+ Some not so cool data provided!\n\n" - testHelperFailure(c, "Check(1, checker, 2)", false, false, log, - func() interface{} { - return c.Check(1, checker, 2) - }) -} - -func (s *HelpersS) TestCheckWithNilChecker(c *check.C) { - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, nil\\)\n" + - "\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" + - "\\.+ Oops\\.\\. you've provided a nil checker!\n\n" - testHelperFailure(c, "Check(obtained, nil)", false, false, log, - func() interface{} { - return c.Check(1, nil) - }) -} - -func (s *HelpersS) TestCheckWithParamsAndNamesMutation(c *check.C) { - checker := &MyChecker{result: false, params: []interface{}{3, 4}, names: []string{"newobtained", "newexpected"}} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " return c\\.Check\\(1, checker, 2\\)\n" + - "\\.+ newobtained int = 3\n" + - "\\.+ newexpected int = 4\n\n" - testHelperFailure(c, "Check(1, checker, 2) with mutation", false, false, log, - func() interface{} { - return c.Check(1, checker, 2) - }) -} - -// ----------------------------------------------------------------------- -// Tests for Assert(), mostly the same as for Check() above. - -func (s *HelpersS) TestAssertSucceedWithExpected(c *check.C) { - checker := &MyChecker{result: true} - testHelperSuccess(c, "Assert(1, checker, 2)", nil, func() interface{} { - c.Assert(1, checker, 2) - return nil - }) - if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) { - c.Fatalf("Bad params for check: %#v", checker.params) - } -} - -func (s *HelpersS) TestAssertSucceedWithoutExpected(c *check.C) { - checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}} - testHelperSuccess(c, "Assert(1, checker)", nil, func() interface{} { - c.Assert(1, checker) - return nil - }) - if !reflect.DeepEqual(checker.params, []interface{}{1}) { - c.Fatalf("Bad params for check: %#v", checker.params) - } -} - -func (s *HelpersS) TestAssertFailWithExpected(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, checker, 2\\)\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n\n" - testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log, - func() interface{} { - c.Assert(1, checker, 2) - return nil - }) -} - -func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n" + - "\\.+ Hello world!\n\n" - testHelperFailure(c, "Assert(1, checker, 2, msg)", nil, true, log, - func() interface{} { - c.Assert(1, checker, 2, myComment("Hello world!")) - return nil - }) -} - -func (s *HelpersS) TestAssertFailWithoutExpected(c *check.C) { - checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, checker\\)\n" + - "\\.+ myvalue int = 1\n\n" - testHelperFailure(c, "Assert(1, checker)", nil, true, log, - func() interface{} { - c.Assert(1, checker) - return nil - }) -} - -func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *check.C) { - checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" + - "\\.+ myvalue int = 1\n" + - "\\.+ Hello world!\n\n" - testHelperFailure(c, "Assert(1, checker, msg)", nil, true, log, - func() interface{} { - c.Assert(1, checker, myComment("Hello world!")) - return nil - }) -} - -func (s *HelpersS) TestAssertWithMissingExpected(c *check.C) { - checker := &MyChecker{result: true} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, checker\\)\n" + - "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" + - "\\.+ Wrong number of parameters for MyChecker: " + - "want 3, got 2\n\n" - testHelperFailure(c, "Assert(1, checker, !?)", nil, true, log, - func() interface{} { - c.Assert(1, checker) - return nil - }) -} - -func (s *HelpersS) TestAssertWithError(c *check.C) { - checker := &MyChecker{result: false, error: "Some not so cool data provided!"} - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, checker, 2\\)\n" + - "\\.+ myobtained int = 1\n" + - "\\.+ myexpected int = 2\n" + - "\\.+ Some not so cool data provided!\n\n" - testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log, - func() interface{} { - c.Assert(1, checker, 2) - return nil - }) -} - -func (s *HelpersS) TestAssertWithNilChecker(c *check.C) { - log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" + - " c\\.Assert\\(1, nil\\)\n" + - "\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" + - "\\.+ Oops\\.\\. you've provided a nil checker!\n\n" - testHelperFailure(c, "Assert(obtained, nil)", nil, true, log, - func() interface{} { - c.Assert(1, nil) - return nil - }) -} - -// ----------------------------------------------------------------------- -// Ensure that values logged work properly in some interesting cases. - -func (s *HelpersS) TestValueLoggingWithArrays(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + - " return c\\.Check\\(\\[\\]byte{1, 2}, checker, \\[\\]byte{1, 3}\\)\n" + - "\\.+ myobtained \\[\\]uint8 = \\[\\]byte{0x1, 0x2}\n" + - "\\.+ myexpected \\[\\]uint8 = \\[\\]byte{0x1, 0x3}\n\n" - testHelperFailure(c, "Check([]byte{1}, chk, []byte{3})", false, false, log, - func() interface{} { - return c.Check([]byte{1, 2}, checker, []byte{1, 3}) - }) -} - -func (s *HelpersS) TestValueLoggingWithMultiLine(c *check.C) { - checker := &MyChecker{result: false} - log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + - " return c\\.Check\\(\"a\\\\nb\\\\n\", checker, \"a\\\\nb\\\\nc\"\\)\n" + - "\\.+ myobtained string = \"\" \\+\n" + - "\\.+ \"a\\\\n\" \\+\n" + - "\\.+ \"b\\\\n\"\n" + - "\\.+ myexpected string = \"\" \\+\n" + - "\\.+ \"a\\\\n\" \\+\n" + - "\\.+ \"b\\\\n\" \\+\n" + - "\\.+ \"c\"\n\n" - testHelperFailure(c, `Check("a\nb\n", chk, "a\nb\nc")`, false, false, log, - func() interface{} { - return c.Check("a\nb\n", checker, "a\nb\nc") - }) -} - -func (s *HelpersS) TestValueLoggingWithMultiLineException(c *check.C) { - // If the newline is at the end of the string, don't log as multi-line. - checker := &MyChecker{result: false} - log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" + - " return c\\.Check\\(\"a b\\\\n\", checker, \"a\\\\nb\"\\)\n" + - "\\.+ myobtained string = \"a b\\\\n\"\n" + - "\\.+ myexpected string = \"\" \\+\n" + - "\\.+ \"a\\\\n\" \\+\n" + - "\\.+ \"b\"\n\n" - testHelperFailure(c, `Check("a b\n", chk, "a\nb")`, false, false, log, - func() interface{} { - return c.Check("a b\n", checker, "a\nb") - }) -} - -// ----------------------------------------------------------------------- -// MakeDir() tests. - -type MkDirHelper struct { - path1 string - path2 string - isDir1 bool - isDir2 bool - isDir3 bool - isDir4 bool -} - -func (s *MkDirHelper) SetUpSuite(c *check.C) { - s.path1 = c.MkDir() - s.isDir1 = isDir(s.path1) -} - -func (s *MkDirHelper) Test(c *check.C) { - s.path2 = c.MkDir() - s.isDir2 = isDir(s.path2) -} - -func (s *MkDirHelper) TearDownSuite(c *check.C) { - s.isDir3 = isDir(s.path1) - s.isDir4 = isDir(s.path2) -} - -func (s *HelpersS) TestMkDir(c *check.C) { - helper := MkDirHelper{} - output := String{} - check.Run(&helper, &check.RunConf{Output: &output}) - c.Assert(output.value, check.Equals, "") - c.Check(helper.isDir1, check.Equals, true) - c.Check(helper.isDir2, check.Equals, true) - c.Check(helper.isDir3, check.Equals, true) - c.Check(helper.isDir4, check.Equals, true) - c.Check(helper.path1, check.Not(check.Equals), - helper.path2) - c.Check(isDir(helper.path1), check.Equals, false) - c.Check(isDir(helper.path2), check.Equals, false) -} - -func isDir(path string) bool { - if stat, err := os.Stat(path); err == nil { - return stat.IsDir() - } - return false -} - -// Concurrent logging should not corrupt the underling buffer. -// Use go test -race to detect the race in this test. -func (s *HelpersS) TestConcurrentLogging(c *check.C) { - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU())) - var start, stop sync.WaitGroup - start.Add(1) - for i, n := 0, runtime.NumCPU()*2; i < n; i++ { - stop.Add(1) - go func(i int) { - start.Wait() - for j := 0; j < 30; j++ { - c.Logf("Worker %d: line %d", i, j) - } - stop.Done() - }(i) - } - start.Done() - stop.Wait() -} - -// ----------------------------------------------------------------------- -// Test the TestName function - -type TestNameHelper struct { - name1 string - name2 string - name3 string - name4 string - name5 string -} - -func (s *TestNameHelper) SetUpSuite(c *check.C) { s.name1 = c.TestName() } -func (s *TestNameHelper) SetUpTest(c *check.C) { s.name2 = c.TestName() } -func (s *TestNameHelper) Test(c *check.C) { s.name3 = c.TestName() } -func (s *TestNameHelper) TearDownTest(c *check.C) { s.name4 = c.TestName() } -func (s *TestNameHelper) TearDownSuite(c *check.C) { s.name5 = c.TestName() } - -func (s *HelpersS) TestTestName(c *check.C) { - helper := TestNameHelper{} - output := String{} - check.Run(&helper, &check.RunConf{Output: &output}) - c.Check(helper.name1, check.Equals, "") - c.Check(helper.name2, check.Equals, "TestNameHelper.Test") - c.Check(helper.name3, check.Equals, "TestNameHelper.Test") - c.Check(helper.name4, check.Equals, "TestNameHelper.Test") - c.Check(helper.name5, check.Equals, "") -} - -// ----------------------------------------------------------------------- -// A couple of helper functions to test helper functions. :-) - -func testHelperSuccess(c *check.C, name string, expectedResult interface{}, closure func() interface{}) { - var result interface{} - defer (func() { - if err := recover(); err != nil { - panic(err) - } - checkState(c, result, - &expectedState{ - name: name, - result: expectedResult, - failed: false, - log: "", - }) - })() - result = closure() -} - -func testHelperFailure(c *check.C, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) { - var result interface{} - defer (func() { - if err := recover(); err != nil { - panic(err) - } - checkState(c, result, - &expectedState{ - name: name, - result: expectedResult, - failed: true, - log: log, - }) - })() - result = closure() - if shouldStop { - c.Logf("%s didn't stop when it should", name) - } -} diff --git a/vendor/gopkg.in/check.v1/printer_test.go b/vendor/gopkg.in/check.v1/printer_test.go deleted file mode 100644 index 538b2d52..00000000 --- a/vendor/gopkg.in/check.v1/printer_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package check_test - -import ( - . "gopkg.in/check.v1" -) - -var _ = Suite(&PrinterS{}) - -type PrinterS struct{} - -func (s *PrinterS) TestCountSuite(c *C) { - suitesRun += 1 -} - -var printTestFuncLine int - -func init() { - printTestFuncLine = getMyLine() + 3 -} - -func printTestFunc() { - println(1) // Comment1 - if 2 == 2 { // Comment2 - println(3) // Comment3 - } - switch 5 { - case 6: println(6) // Comment6 - println(7) - } - switch interface{}(9).(type) {// Comment9 - case int: println(10) - println(11) - } - select { - case <-(chan bool)(nil): println(14) - println(15) - default: println(16) - println(17) - } - println(19, - 20) - _ = func() { println(21) - println(22) - } - println(24, func() { - println(25) - }) - // Leading comment - // with multiple lines. - println(29) // Comment29 -} - -var printLineTests = []struct { - line int - output string -}{ - {1, "println(1) // Comment1"}, - {2, "if 2 == 2 { // Comment2\n ...\n}"}, - {3, "println(3) // Comment3"}, - {5, "switch 5 {\n...\n}"}, - {6, "case 6:\n println(6) // Comment6\n ..."}, - {7, "println(7)"}, - {9, "switch interface{}(9).(type) { // Comment9\n...\n}"}, - {10, "case int:\n println(10)\n ..."}, - {14, "case <-(chan bool)(nil):\n println(14)\n ..."}, - {15, "println(15)"}, - {16, "default:\n println(16)\n ..."}, - {17, "println(17)"}, - {19, "println(19,\n 20)"}, - {20, "println(19,\n 20)"}, - {21, "_ = func() {\n println(21)\n println(22)\n}"}, - {22, "println(22)"}, - {24, "println(24, func() {\n println(25)\n})"}, - {25, "println(25)"}, - {26, "println(24, func() {\n println(25)\n})"}, - {29, "// Leading comment\n// with multiple lines.\nprintln(29) // Comment29"}, -} - -func (s *PrinterS) TestPrintLine(c *C) { - for _, test := range printLineTests { - output, err := PrintLine("printer_test.go", printTestFuncLine+test.line) - c.Assert(err, IsNil) - c.Assert(output, Equals, test.output) - } -} - -var indentTests = []struct { - in, out string -}{ - {"", ""}, - {"\n", "\n"}, - {"a", ">>>a"}, - {"a\n", ">>>a\n"}, - {"a\nb", ">>>a\n>>>b"}, - {" ", ">>> "}, -} - -func (s *PrinterS) TestIndent(c *C) { - for _, test := range indentTests { - out := Indent(test.in, ">>>") - c.Assert(out, Equals, test.out) - } - -} diff --git a/vendor/gopkg.in/check.v1/reporter_test.go b/vendor/gopkg.in/check.v1/reporter_test.go deleted file mode 100644 index 0b7ed762..00000000 --- a/vendor/gopkg.in/check.v1/reporter_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package check_test - -import ( - "fmt" - "path/filepath" - "runtime" - - . "gopkg.in/check.v1" -) - -var _ = Suite(&reporterS{}) - -type reporterS struct { - testFile string -} - -func (s *reporterS) SetUpSuite(c *C) { - _, fileName, _, ok := runtime.Caller(0) - c.Assert(ok, Equals, true) - s.testFile = filepath.Base(fileName) -} - -func (s *reporterS) TestWrite(c *C) { - testString := "test string" - output := String{} - - dummyStream := true - dummyVerbose := true - o := NewOutputWriter(&output, dummyStream, dummyVerbose) - - o.Write([]byte(testString)) - c.Assert(output.value, Equals, testString) -} - -func (s *reporterS) TestWriteCallStartedWithStreamFlag(c *C) { - testLabel := "test started label" - stream := true - output := String{} - - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - - o.WriteCallStarted(testLabel, c) - expected := fmt.Sprintf("%s: %s:\\d+: %s\n", testLabel, s.testFile, c.TestName()) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallStartedWithoutStreamFlag(c *C) { - stream := false - output := String{} - - dummyLabel := "dummy" - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - - o.WriteCallStarted(dummyLabel, c) - c.Assert(output.value, Equals, "") -} - -func (s *reporterS) TestWriteCallProblemWithStreamFlag(c *C) { - testLabel := "test problem label" - stream := true - output := String{} - - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - - o.WriteCallProblem(testLabel, c) - expected := fmt.Sprintf("%s: %s:\\d+: %s\n\n", testLabel, s.testFile, c.TestName()) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallProblemWithoutStreamFlag(c *C) { - testLabel := "test problem label" - stream := false - output := String{} - - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - - o.WriteCallProblem(testLabel, c) - expected := fmt.Sprintf(""+ - "\n"+ - "----------------------------------------------------------------------\n"+ - "%s: %s:\\d+: %s\n\n", testLabel, s.testFile, c.TestName()) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallProblemWithoutStreamFlagWithLog(c *C) { - testLabel := "test problem label" - testLog := "test log" - stream := false - output := String{} - - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - - c.Log(testLog) - o.WriteCallProblem(testLabel, c) - expected := fmt.Sprintf(""+ - "\n"+ - "----------------------------------------------------------------------\n"+ - "%s: %s:\\d+: %s\n\n%s\n", testLabel, s.testFile, c.TestName(), testLog) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallSuccessWithStreamFlag(c *C) { - testLabel := "test success label" - stream := true - output := String{} - - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - - o.WriteCallSuccess(testLabel, c) - expected := fmt.Sprintf("%s: %s:\\d+: %s\t\\d\\.\\d+s\n\n", testLabel, s.testFile, c.TestName()) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallSuccessWithStreamFlagAndReason(c *C) { - testLabel := "test success label" - testReason := "test skip reason" - stream := true - output := String{} - - dummyVerbose := true - o := NewOutputWriter(&output, stream, dummyVerbose) - c.FakeSkip(testReason) - - o.WriteCallSuccess(testLabel, c) - expected := fmt.Sprintf("%s: %s:\\d+: %s \\(%s\\)\t\\d\\.\\d+s\n\n", - testLabel, s.testFile, c.TestName(), testReason) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallSuccessWithoutStreamFlagWithVerboseFlag(c *C) { - testLabel := "test success label" - stream := false - verbose := true - output := String{} - - o := NewOutputWriter(&output, stream, verbose) - - o.WriteCallSuccess(testLabel, c) - expected := fmt.Sprintf("%s: %s:\\d+: %s\t\\d\\.\\d+s\n", testLabel, s.testFile, c.TestName()) - c.Assert(output.value, Matches, expected) -} - -func (s *reporterS) TestWriteCallSuccessWithoutStreamFlagWithoutVerboseFlag(c *C) { - testLabel := "test success label" - stream := false - verbose := false - output := String{} - - o := NewOutputWriter(&output, stream, verbose) - - o.WriteCallSuccess(testLabel, c) - c.Assert(output.value, Equals, "") -} diff --git a/vendor/gopkg.in/check.v1/run_test.go b/vendor/gopkg.in/check.v1/run_test.go deleted file mode 100644 index f41fffc3..00000000 --- a/vendor/gopkg.in/check.v1/run_test.go +++ /dev/null @@ -1,419 +0,0 @@ -// These tests verify the test running logic. - -package check_test - -import ( - "errors" - . "gopkg.in/check.v1" - "os" - "sync" -) - -var runnerS = Suite(&RunS{}) - -type RunS struct{} - -func (s *RunS) TestCountSuite(c *C) { - suitesRun += 1 -} - -// ----------------------------------------------------------------------- -// Tests ensuring result counting works properly. - -func (s *RunS) TestSuccess(c *C) { - output := String{} - result := Run(&SuccessHelper{}, &RunConf{Output: &output}) - c.Check(result.Succeeded, Equals, 1) - c.Check(result.Failed, Equals, 0) - c.Check(result.Skipped, Equals, 0) - c.Check(result.Panicked, Equals, 0) - c.Check(result.FixturePanicked, Equals, 0) - c.Check(result.Missed, Equals, 0) - c.Check(result.RunError, IsNil) -} - -func (s *RunS) TestFailure(c *C) { - output := String{} - result := Run(&FailHelper{}, &RunConf{Output: &output}) - c.Check(result.Succeeded, Equals, 0) - c.Check(result.Failed, Equals, 1) - c.Check(result.Skipped, Equals, 0) - c.Check(result.Panicked, Equals, 0) - c.Check(result.FixturePanicked, Equals, 0) - c.Check(result.Missed, Equals, 0) - c.Check(result.RunError, IsNil) -} - -func (s *RunS) TestFixture(c *C) { - output := String{} - result := Run(&FixtureHelper{}, &RunConf{Output: &output}) - c.Check(result.Succeeded, Equals, 2) - c.Check(result.Failed, Equals, 0) - c.Check(result.Skipped, Equals, 0) - c.Check(result.Panicked, Equals, 0) - c.Check(result.FixturePanicked, Equals, 0) - c.Check(result.Missed, Equals, 0) - c.Check(result.RunError, IsNil) -} - -func (s *RunS) TestPanicOnTest(c *C) { - output := String{} - helper := &FixtureHelper{panicOn: "Test1"} - result := Run(helper, &RunConf{Output: &output}) - c.Check(result.Succeeded, Equals, 1) - c.Check(result.Failed, Equals, 0) - c.Check(result.Skipped, Equals, 0) - c.Check(result.Panicked, Equals, 1) - c.Check(result.FixturePanicked, Equals, 0) - c.Check(result.Missed, Equals, 0) - c.Check(result.RunError, IsNil) -} - -func (s *RunS) TestPanicOnSetUpTest(c *C) { - output := String{} - helper := &FixtureHelper{panicOn: "SetUpTest"} - result := Run(helper, &RunConf{Output: &output}) - c.Check(result.Succeeded, Equals, 0) - c.Check(result.Failed, Equals, 0) - c.Check(result.Skipped, Equals, 0) - c.Check(result.Panicked, Equals, 0) - c.Check(result.FixturePanicked, Equals, 1) - c.Check(result.Missed, Equals, 2) - c.Check(result.RunError, IsNil) -} - -func (s *RunS) TestPanicOnSetUpSuite(c *C) { - output := String{} - helper := &FixtureHelper{panicOn: "SetUpSuite"} - result := Run(helper, &RunConf{Output: &output}) - c.Check(result.Succeeded, Equals, 0) - c.Check(result.Failed, Equals, 0) - c.Check(result.Skipped, Equals, 0) - c.Check(result.Panicked, Equals, 0) - c.Check(result.FixturePanicked, Equals, 1) - c.Check(result.Missed, Equals, 2) - c.Check(result.RunError, IsNil) -} - -// ----------------------------------------------------------------------- -// Check result aggregation. - -func (s *RunS) TestAdd(c *C) { - result := &Result{ - Succeeded: 1, - Skipped: 2, - Failed: 3, - Panicked: 4, - FixturePanicked: 5, - Missed: 6, - ExpectedFailures: 7, - } - result.Add(&Result{ - Succeeded: 10, - Skipped: 20, - Failed: 30, - Panicked: 40, - FixturePanicked: 50, - Missed: 60, - ExpectedFailures: 70, - }) - c.Check(result.Succeeded, Equals, 11) - c.Check(result.Skipped, Equals, 22) - c.Check(result.Failed, Equals, 33) - c.Check(result.Panicked, Equals, 44) - c.Check(result.FixturePanicked, Equals, 55) - c.Check(result.Missed, Equals, 66) - c.Check(result.ExpectedFailures, Equals, 77) - c.Check(result.RunError, IsNil) -} - -// ----------------------------------------------------------------------- -// Check the Passed() method. - -func (s *RunS) TestPassed(c *C) { - c.Assert((&Result{}).Passed(), Equals, true) - c.Assert((&Result{Succeeded: 1}).Passed(), Equals, true) - c.Assert((&Result{Skipped: 1}).Passed(), Equals, true) - c.Assert((&Result{Failed: 1}).Passed(), Equals, false) - c.Assert((&Result{Panicked: 1}).Passed(), Equals, false) - c.Assert((&Result{FixturePanicked: 1}).Passed(), Equals, false) - c.Assert((&Result{Missed: 1}).Passed(), Equals, false) - c.Assert((&Result{RunError: errors.New("!")}).Passed(), Equals, false) -} - -// ----------------------------------------------------------------------- -// Check that result printing is working correctly. - -func (s *RunS) TestPrintSuccess(c *C) { - result := &Result{Succeeded: 5} - c.Check(result.String(), Equals, "OK: 5 passed") -} - -func (s *RunS) TestPrintFailure(c *C) { - result := &Result{Failed: 5} - c.Check(result.String(), Equals, "OOPS: 0 passed, 5 FAILED") -} - -func (s *RunS) TestPrintSkipped(c *C) { - result := &Result{Skipped: 5} - c.Check(result.String(), Equals, "OK: 0 passed, 5 skipped") -} - -func (s *RunS) TestPrintExpectedFailures(c *C) { - result := &Result{ExpectedFailures: 5} - c.Check(result.String(), Equals, "OK: 0 passed, 5 expected failures") -} - -func (s *RunS) TestPrintPanicked(c *C) { - result := &Result{Panicked: 5} - c.Check(result.String(), Equals, "OOPS: 0 passed, 5 PANICKED") -} - -func (s *RunS) TestPrintFixturePanicked(c *C) { - result := &Result{FixturePanicked: 5} - c.Check(result.String(), Equals, "OOPS: 0 passed, 5 FIXTURE-PANICKED") -} - -func (s *RunS) TestPrintMissed(c *C) { - result := &Result{Missed: 5} - c.Check(result.String(), Equals, "OOPS: 0 passed, 5 MISSED") -} - -func (s *RunS) TestPrintAll(c *C) { - result := &Result{Succeeded: 1, Skipped: 2, ExpectedFailures: 3, - Panicked: 4, FixturePanicked: 5, Missed: 6} - c.Check(result.String(), Equals, - "OOPS: 1 passed, 2 skipped, 3 expected failures, 4 PANICKED, "+ - "5 FIXTURE-PANICKED, 6 MISSED") -} - -func (s *RunS) TestPrintRunError(c *C) { - result := &Result{Succeeded: 1, Failed: 1, - RunError: errors.New("Kaboom!")} - c.Check(result.String(), Equals, "ERROR: Kaboom!") -} - -// ----------------------------------------------------------------------- -// Verify that the method pattern flag works correctly. - -func (s *RunS) TestFilterTestName(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: "Test[91]"} - Run(&helper, &runConf) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 5) -} - -func (s *RunS) TestFilterTestNameWithAll(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: ".*"} - Run(&helper, &runConf) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "SetUpTest") - c.Check(helper.calls[5], Equals, "Test2") - c.Check(helper.calls[6], Equals, "TearDownTest") - c.Check(helper.calls[7], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 8) -} - -func (s *RunS) TestFilterSuiteName(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: "FixtureHelper"} - Run(&helper, &runConf) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test1") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "SetUpTest") - c.Check(helper.calls[5], Equals, "Test2") - c.Check(helper.calls[6], Equals, "TearDownTest") - c.Check(helper.calls[7], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 8) -} - -func (s *RunS) TestFilterSuiteNameAndTestName(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: "FixtureHelper\\.Test2"} - Run(&helper, &runConf) - c.Check(helper.calls[0], Equals, "SetUpSuite") - c.Check(helper.calls[1], Equals, "SetUpTest") - c.Check(helper.calls[2], Equals, "Test2") - c.Check(helper.calls[3], Equals, "TearDownTest") - c.Check(helper.calls[4], Equals, "TearDownSuite") - c.Check(len(helper.calls), Equals, 5) -} - -func (s *RunS) TestFilterAllOut(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: "NotFound"} - Run(&helper, &runConf) - c.Check(len(helper.calls), Equals, 0) -} - -func (s *RunS) TestRequirePartialMatch(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: "est"} - Run(&helper, &runConf) - c.Check(len(helper.calls), Equals, 8) -} - -func (s *RunS) TestFilterError(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Filter: "]["} - result := Run(&helper, &runConf) - c.Check(result.String(), Equals, - "ERROR: Bad filter expression: error parsing regexp: missing closing ]: `[`") - c.Check(len(helper.calls), Equals, 0) -} - -// ----------------------------------------------------------------------- -// Verify that List works correctly. - -func (s *RunS) TestListFiltered(c *C) { - names := List(&FixtureHelper{}, &RunConf{Filter: "1"}) - c.Assert(names, DeepEquals, []string{ - "FixtureHelper.Test1", - }) -} - -func (s *RunS) TestList(c *C) { - names := List(&FixtureHelper{}, &RunConf{}) - c.Assert(names, DeepEquals, []string{ - "FixtureHelper.Test1", - "FixtureHelper.Test2", - }) -} - -// ----------------------------------------------------------------------- -// Verify that verbose mode prints tests which pass as well. - -func (s *RunS) TestVerboseMode(c *C) { - helper := FixtureHelper{} - output := String{} - runConf := RunConf{Output: &output, Verbose: true} - Run(&helper, &runConf) - - expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t *[.0-9]+s\n" + - "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n" - - c.Assert(output.value, Matches, expected) -} - -func (s *RunS) TestVerboseModeWithFailBeforePass(c *C) { - helper := FixtureHelper{panicOn: "Test1"} - output := String{} - runConf := RunConf{Output: &output, Verbose: true} - Run(&helper, &runConf) - - expected := "(?s).*PANIC.*\n-+\n" + // Should have an extra line. - "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n" - - c.Assert(output.value, Matches, expected) -} - -// ----------------------------------------------------------------------- -// Verify the stream output mode. In this mode there's no output caching. - -type StreamHelper struct { - l2 sync.Mutex - l3 sync.Mutex -} - -func (s *StreamHelper) SetUpSuite(c *C) { - c.Log("0") -} - -func (s *StreamHelper) Test1(c *C) { - c.Log("1") - s.l2.Lock() - s.l3.Lock() - go func() { - s.l2.Lock() // Wait for "2". - c.Log("3") - s.l3.Unlock() - }() -} - -func (s *StreamHelper) Test2(c *C) { - c.Log("2") - s.l2.Unlock() - s.l3.Lock() // Wait for "3". - c.Fail() - c.Log("4") -} - -func (s *RunS) TestStreamMode(c *C) { - helper := &StreamHelper{} - output := String{} - runConf := RunConf{Output: &output, Stream: true} - Run(helper, &runConf) - - expected := "START: run_test\\.go:[0-9]+: StreamHelper\\.SetUpSuite\n0\n" + - "PASS: run_test\\.go:[0-9]+: StreamHelper\\.SetUpSuite\t *[.0-9]+s\n\n" + - "START: run_test\\.go:[0-9]+: StreamHelper\\.Test1\n1\n" + - "PASS: run_test\\.go:[0-9]+: StreamHelper\\.Test1\t *[.0-9]+s\n\n" + - "START: run_test\\.go:[0-9]+: StreamHelper\\.Test2\n2\n3\n4\n" + - "FAIL: run_test\\.go:[0-9]+: StreamHelper\\.Test2\n\n" - - c.Assert(output.value, Matches, expected) -} - -type StreamMissHelper struct{} - -func (s *StreamMissHelper) SetUpSuite(c *C) { - c.Log("0") - c.Fail() -} - -func (s *StreamMissHelper) Test1(c *C) { - c.Log("1") -} - -func (s *RunS) TestStreamModeWithMiss(c *C) { - helper := &StreamMissHelper{} - output := String{} - runConf := RunConf{Output: &output, Stream: true} - Run(helper, &runConf) - - expected := "START: run_test\\.go:[0-9]+: StreamMissHelper\\.SetUpSuite\n0\n" + - "FAIL: run_test\\.go:[0-9]+: StreamMissHelper\\.SetUpSuite\n\n" + - "START: run_test\\.go:[0-9]+: StreamMissHelper\\.Test1\n" + - "MISS: run_test\\.go:[0-9]+: StreamMissHelper\\.Test1\n\n" - - c.Assert(output.value, Matches, expected) -} - -// ----------------------------------------------------------------------- -// Verify that that the keep work dir request indeed does so. - -type WorkDirSuite struct {} - -func (s *WorkDirSuite) Test(c *C) { - c.MkDir() -} - -func (s *RunS) TestKeepWorkDir(c *C) { - output := String{} - runConf := RunConf{Output: &output, Verbose: true, KeepWorkDir: true} - result := Run(&WorkDirSuite{}, &runConf) - - c.Assert(result.String(), Matches, ".*\nWORK=" + result.WorkDir) - - stat, err := os.Stat(result.WorkDir) - c.Assert(err, IsNil) - c.Assert(stat.IsDir(), Equals, true) -} From 0e42498c4d82b2eec1c4b202eefb9fa335ca06fb Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 25 May 2016 15:22:45 -0700 Subject: [PATCH 071/357] Update README.md Add build badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2403f020..d91900b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -longhorn +longhorn [![Build Status](https://ci-longhorn.rancher.io/api/badges/rancher/longhorn/status.svg)](https://ci-longhorn.rancher.io/rancher/longhorn) ======== A microservice that does micro things. From 4a5c34148ed06ba5cd28ef64a4473adc67997bc0 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 17:47:27 -0700 Subject: [PATCH 072/357] tcmu: Fix stop/start failure tcmu_poll_master_fd() will continue to get all events notification regarding device add/remove through the process lifetime. --- frontend/tcmu/main.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index 64904c37..fa88e906 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -26,12 +26,11 @@ import ( ) var ( - ready = false - log = logrus.WithFields(logrus.Fields{"pkg": "main"}) // this is super dirty backend types.ReaderWriterAt + cxt *C.struct_tcmulib_context ) type State struct { @@ -175,20 +174,21 @@ func shClose(dev Device) { } func start(rw types.ReaderWriterAt) error { - // this is super dirty - backend = rw - - cxt := C.tcmu_init() if cxt == nil { - return errors.New("TCMU ctx is nil") - } - - go func() { - for !ready { - result := C.tcmu_poll_master_fd(cxt) - log.Debugln("Poll master fd one more time, last result ", result) + // this is super dirty + backend = rw + cxt = C.tcmu_init() + if cxt == nil { + return errors.New("TCMU ctx is nil") } - }() + + go func() { + for { + result := C.tcmu_poll_master_fd(cxt) + log.Debugln("Poll master fd one more time, last result ", result) + } + }() + } return nil } From 6dc11df21abfbd3817b6f3b5e0acaf048ccfde00 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Jun 2016 16:30:38 -0700 Subject: [PATCH 073/357] tcmu: Add proper ID to volume --- frontend/tcmu/cfunc.go | 6 +++--- frontend/tcmu/frontend.go | 4 ++-- frontend/tcmu/main.go | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index 6d73da1e..102f457d 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -31,9 +31,9 @@ void sh_close_cgo(struct tcmu_device *dev) { } static struct tcmulib_handler sh_handler = { - .name = "Shorthorn TCMU handler", - .subtype = "file", - .cfg_desc = "dev_config=file/", + .name = "Longhorn TCMU handler", + .subtype = "longhorn", + .cfg_desc = "dev_config=longhorn//", .added = sh_open_cgo, .removed = sh_close_cgo, }; diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index 0ae4124e..ea548d30 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -43,7 +43,7 @@ func (t *Tcmu) Activate(name string, size, sectorSize int64, rw types.ReaderWrit return err } - if err := start(rw); err != nil { + if err := start(name, rw); err != nil { return err } @@ -169,7 +169,7 @@ func mknod(device string, major, minor int) error { } func GetDevConfig(volume string) string { - return fmt.Sprintf("file//root/%s", volume) + return fmt.Sprintf("longhorn//%s", volume) } func getScsiPrefixAndWnn(volume string) (string, string) { diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index fa88e906..5d60f1a5 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -18,6 +18,7 @@ extern void *allocate_buffer(int length); import "C" import ( "errors" + "strings" "sync" "unsafe" @@ -31,6 +32,7 @@ var ( // this is super dirty backend types.ReaderWriterAt cxt *C.struct_tcmulib_context + volume string ) type State struct { @@ -68,12 +70,17 @@ func shOpen(dev Device) int { log.Errorln("Cannot find configuration string") return -C.EINVAL } - //id := strings.TrimPrefix(cfgString, "file/") - //TODO check volume name here + + id := strings.TrimPrefix(cfgString, "longhorn//") + if id != volume { + log.Debugf("Ignore volume %s, which is not mine", id) + return -C.EINVAL + } + state.volume = id go state.HandleRequest(dev) - log.Debugln("Device added") + log.Debugf("Device %s added", state.volume) return 0 } @@ -173,10 +180,11 @@ func shClose(dev Device) { log.Debugln("Device removed") } -func start(rw types.ReaderWriterAt) error { +func start(name string, rw types.ReaderWriterAt) error { if cxt == nil { // this is super dirty backend = rw + volume = name cxt = C.tcmu_init() if cxt == nil { return errors.New("TCMU ctx is nil") From 93dc9c4167e85e2857a4a40aa3687c8c10a92a83 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 23 May 2016 23:04:56 -0700 Subject: [PATCH 074/357] Move client to replica/client and controller/client --- agent/controller/controller.go | 7 +++--- agent/status/controller.go | 2 +- agent/status/replica.go | 7 +++--- app/ls_replica.go | 5 ++-- .../client}/controller_client.go | 0 controller/rest/router.go | 15 ++---------- .../client/client.go | 0 replica/rest/router.go | 13 +++++++++-- sync/sync.go | 23 ++++++++++--------- 9 files changed, 37 insertions(+), 35 deletions(-) rename {client => controller/client}/controller_client.go (100%) rename client/replica_client.go => replica/client/client.go (100%) diff --git a/agent/controller/controller.go b/agent/controller/controller.go index c1b4e961..e745f131 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -12,8 +12,9 @@ import ( "github.com/rancher/go-rancher-metadata/metadata" - lclient "github.com/rancher/longhorn/client" + lclient "github.com/rancher/longhorn/controller/client" "github.com/rancher/longhorn/controller/rest" + replicaClient "github.com/rancher/longhorn/replica/client" ) const ( @@ -23,7 +24,7 @@ const ( ) type replica struct { - client *lclient.ReplicaClient + client *replicaClient.ReplicaClient host string port int healthState string @@ -468,7 +469,7 @@ func (c *Controller) replicaMetadataAndClient() (int, map[string]*replica, error } address := ReplicaAddress(r.host, r.port) - replicaClient, err := lclient.NewReplicaClient(address) + replicaClient, err := replicaClient.NewReplicaClient(address) if err != nil { return 0, nil, fmt.Errorf("Error getting client for replica %v: %v", address, err) } diff --git a/agent/status/controller.go b/agent/status/controller.go index 995ff0bc..8393fe4d 100644 --- a/agent/status/controller.go +++ b/agent/status/controller.go @@ -3,7 +3,7 @@ package status import ( "net/http" - "github.com/rancher/longhorn/client" + "github.com/rancher/longhorn/controller/client" ) type ControllerStatus struct { diff --git a/agent/status/replica.go b/agent/status/replica.go index a94c2754..02efb256 100644 --- a/agent/status/replica.go +++ b/agent/status/replica.go @@ -5,7 +5,8 @@ import ( "net/http" md "github.com/rancher/go-rancher-metadata/metadata" - "github.com/rancher/longhorn/client" + "github.com/rancher/longhorn/controller/client" + replicaClient "github.com/rancher/longhorn/replica/client" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/agent/controller" @@ -13,7 +14,7 @@ import ( type ReplicaStatus struct { controller *client.ControllerClient - replica *client.ReplicaClient + replica *replicaClient.ReplicaClient metadata *md.Client address string controllerLastError string @@ -31,7 +32,7 @@ func NewReplicaStatus() (*ReplicaStatus, error) { addr := controller.ReplicaAddress(self.PrimaryIp, 9502) controllerClient := client.NewControllerClient("http://controller:9501/v1") - replicaClient, err := client.NewReplicaClient("http://localhost:9502/v1") + replicaClient, err := replicaClient.NewReplicaClient("http://localhost:9502/v1") if err != nil { return nil, err } diff --git a/app/ls_replica.go b/app/ls_replica.go index cd8ac8c6..ff48d907 100644 --- a/app/ls_replica.go +++ b/app/ls_replica.go @@ -7,7 +7,8 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/client" + "github.com/rancher/longhorn/controller/client" + replicaClient "github.com/rancher/longhorn/replica/client" ) func LsReplicaCmd() cli.Command { @@ -53,7 +54,7 @@ func lsReplica(c *cli.Context) error { } func getChain(address string) ([]string, error) { - repClient, err := client.NewReplicaClient(address) + repClient, err := replicaClient.NewReplicaClient(address) if err != nil { return nil, err } diff --git a/client/controller_client.go b/controller/client/controller_client.go similarity index 100% rename from client/controller_client.go rename to controller/client/controller_client.go diff --git a/controller/rest/router.go b/controller/rest/router.go index f51c402b..7bd528b2 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -1,26 +1,15 @@ package rest import ( - "net/http" - "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" - "github.com/rancher/go-rancher/client" + "github.com/rancher/longhorn/replica/rest" ) -func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { - return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - if err := t(rw, req); err != nil { - apiContext := api.GetApiContext(req) - apiContext.WriteErr(err) - } - })) -} - func NewRouter(s *Server) *mux.Router { schemas := NewSchema() router := mux.NewRouter().StrictSlash(true) - f := HandleError + f := rest.HandleError // API framework routes router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) diff --git a/client/replica_client.go b/replica/client/client.go similarity index 100% rename from client/replica_client.go rename to replica/client/client.go diff --git a/replica/rest/router.go b/replica/rest/router.go index a4d2e44c..e0c363a4 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -5,9 +5,18 @@ import ( "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" - "github.com/rancher/longhorn/controller/rest" + "github.com/rancher/go-rancher/client" ) +func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { + return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if err := t(rw, req); err != nil { + apiContext := api.GetApiContext(req) + apiContext.WriteErr(err) + } + })) +} + func checkAction(s *Server, t func(http.ResponseWriter, *http.Request) error) func(http.ResponseWriter, *http.Request) error { return func(rw http.ResponseWriter, req *http.Request) error { replica := s.Replica(api.GetApiContext(req)) @@ -22,7 +31,7 @@ func checkAction(s *Server, t func(http.ResponseWriter, *http.Request) error) fu func NewRouter(s *Server) *mux.Router { schemas := NewSchema() router := mux.NewRouter().StrictSlash(true) - f := rest.HandleError + f := HandleError router.Methods("GET").Path("/ping").Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { rw.Write([]byte("pong")) diff --git a/sync/sync.go b/sync/sync.go index 1d91c23d..b1d83718 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -6,8 +6,9 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/client" + "github.com/rancher/longhorn/controller/client" "github.com/rancher/longhorn/controller/rest" + replicaClient "github.com/rancher/longhorn/replica/client" ) type Task struct { @@ -50,7 +51,7 @@ func (t *Task) DeleteSnapshot(snapshot string) error { } func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string) error { - repClient, err := client.NewReplicaClient(replicaInController.Address) + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return err } @@ -79,7 +80,7 @@ func getNameAndIndex(chain []string, snapshot string) (string, int) { } func (t *Task) isRebuilding(replicaInController *rest.Replica) (bool, error) { - repClient, err := client.NewReplicaClient(replicaInController.Address) + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return false, err } @@ -97,7 +98,7 @@ func (t *Task) coalesceSnapshot(replicaInController *rest.Replica, snapshot stri return fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) } - repClient, err := client.NewReplicaClient(replicaInController.Address) + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return err } @@ -173,7 +174,7 @@ func (t *Task) AddReplica(replica string) error { } func (t *Task) checkAndResetFailedRebuild(address string) error { - client, err := client.NewReplicaClient(address) + client, err := replicaClient.NewReplicaClient(address) if err != nil { return err } @@ -218,7 +219,7 @@ func (t *Task) setRw(replica string) error { return nil } -func (t *Task) reloadAndCheck(fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { +func (t *Task) reloadAndCheck(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { from, err := fromClient.GetReplica() if err != nil { return err @@ -239,7 +240,7 @@ func (t *Task) reloadAndCheck(fromClient *client.ReplicaClient, toClient *client return toClient.SetRebuilding(false) } -func (t *Task) syncFiles(fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { +func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { from, err := fromClient.GetReplica() if err != nil { return err @@ -296,7 +297,7 @@ func (t *Task) syncFiles(fromClient *client.ReplicaClient, toClient *client.Repl return nil } -func (t *Task) syncFile(from, to string, fromClient *client.ReplicaClient, toClient *client.ReplicaClient) error { +func (t *Task) syncFile(from, to string, fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { host, port, err := toClient.LaunchReceiver() if err != nil { return err @@ -317,14 +318,14 @@ func (t *Task) syncFile(from, to string, fromClient *client.ReplicaClient, toCli return err } -func (t *Task) getTransferClients(address string) (*client.ReplicaClient, *client.ReplicaClient, error) { +func (t *Task) getTransferClients(address string) (*replicaClient.ReplicaClient, *replicaClient.ReplicaClient, error) { from, err := t.getFromReplica() if err != nil { return nil, nil, err } logrus.Infof("Using replica %s as the source for rebuild ", from.Address) - fromClient, err := client.NewReplicaClient(from.Address) + fromClient, err := replicaClient.NewReplicaClient(from.Address) if err != nil { return nil, nil, err } @@ -335,7 +336,7 @@ func (t *Task) getTransferClients(address string) (*client.ReplicaClient, *clien } logrus.Infof("Using replica %s as the target for rebuild ", to.Address) - toClient, err := client.NewReplicaClient(to.Address) + toClient, err := replicaClient.NewReplicaClient(to.Address) if err != nil { return nil, nil, err } From c68a80156c3605f4a0f0a08818d414f8e2fab18a Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 24 May 2016 09:59:36 -0700 Subject: [PATCH 075/357] Add snapshot revert --- controller/control.go | 21 +++++---- controller/rest/model.go | 11 +++++ controller/rest/router.go | 1 + controller/rest/volume.go | 22 ++++++++++ controller/revert.go | 82 ++++++++++++++++++++++++++++++++++++ integration/core/test_cli.py | 32 ++++++++++++++ replica/client/client.go | 11 +++++ replica/replica.go | 38 +++++++++++++++++ replica/replica_test.go | 35 +++++++++++++++ replica/rest/model.go | 13 ++++++ replica/rest/replica.go | 10 +++++ replica/rest/router.go | 1 + replica/server.go | 18 ++++++++ 13 files changed, 287 insertions(+), 8 deletions(-) create mode 100644 controller/revert.go diff --git a/controller/control.go b/controller/control.go index 4873e9a7..8e7b06af 100644 --- a/controller/control.go +++ b/controller/control.go @@ -168,6 +168,18 @@ func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { } } +func (c *Controller) startFrontend() error { + if len(c.replicas) > 0 && c.frontend != nil { + if err := c.frontend.Activate(c.Name, c.size, c.sectorSize, c); err != nil { + // FATAL + logrus.Fatalf("Failed to activate frontend: %v", err) + // This will never be reached + return err + } + } + return nil +} + func (c *Controller) Start(addresses ...string) error { c.Lock() defer c.Unlock() @@ -182,14 +194,7 @@ func (c *Controller) Start(addresses ...string) error { c.reset() - defer func() { - if len(c.replicas) > 0 && c.frontend != nil { - if err := c.frontend.Activate(c.Name, c.size, c.sectorSize, c); err != nil { - // FATAL - logrus.Fatalf("Failed to activate frontend: %v", err) - } - } - }() + defer c.startFrontend() first := true for _, address := range addresses { diff --git a/controller/rest/model.go b/controller/rest/model.go index cc743e50..e218cfd6 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -45,6 +45,11 @@ type SnapshotInput struct { Name string `json:"name"` } +type RevertInput struct { + client.Resource + Name string `json:"name"` +} + func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { v := &Volume{ Resource: client.Resource{ @@ -61,6 +66,7 @@ func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { } else { v.Actions["shutdown"] = context.UrlBuilder.ActionLink(v.Resource, "shutdown") v.Actions["snapshot"] = context.UrlBuilder.ActionLink(v.Resource, "snapshot") + v.Actions["revert"] = context.UrlBuilder.ActionLink(v.Resource, "revert") } return v } @@ -97,6 +103,7 @@ func NewSchema() *client.Schemas { schemas.AddType("startInput", StartInput{}) schemas.AddType("snapshotOutput", SnapshotOutput{}) schemas.AddType("snapshotInput", SnapshotInput{}) + schemas.AddType("revertInput", RevertInput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} @@ -112,6 +119,10 @@ func NewSchema() *client.Schemas { volumes := schemas.AddType("volume", Volume{}) volumes.ResourceActions = map[string]client.Action{ + "revert": client.Action{ + Input: "revertInput", + Output: "volume", + }, "start": client.Action{ Input: "startInput", Output: "volume", diff --git a/controller/rest/router.go b/controller/rest/router.go index 7bd528b2..129491a9 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -23,6 +23,7 @@ func NewRouter(s *Server) *mux.Router { router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "start").Handler(f(schemas, s.StartVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "shutdown").Handler(f(schemas, s.ShutdownVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "snapshot").Handler(f(schemas, s.SnapshotVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "revert").Handler(f(schemas, s.RevertVolume)) // Replicas router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) diff --git a/controller/rest/volume.go b/controller/rest/volume.go index 4e28b5b7..f38e2e7d 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -49,6 +49,28 @@ func (s *Server) ShutdownVolume(rw http.ResponseWriter, req *http.Request) error return s.GetVolume(rw, req) } +func (s *Server) RevertVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var input RevertInput + if err := apiContext.Read(&input); err != nil { + return err + } + + if err := s.c.Revert(input.Name); err != nil { + return err + } + + return s.GetVolume(rw, req) +} + func (s *Server) SnapshotVolume(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) id := mux.Vars(req)["id"] diff --git a/controller/revert.go b/controller/revert.go new file mode 100644 index 00000000..4102d0c0 --- /dev/null +++ b/controller/revert.go @@ -0,0 +1,82 @@ +package controller + +import ( + "fmt" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/replica/client" + "github.com/rancher/longhorn/types" +) + +func (c *Controller) Revert(name string) error { + for _, rep := range c.replicas { + if rep.Mode != types.RW { + return fmt.Errorf("Replica %s is in mode %s", rep.Address, rep.Mode) + } + } + + clients, name, err := c.clientsAndSnapshot(name) + if err != nil { + return err + } + + if err := c.shutdownFrontend(); err != nil { + return err + } + + c.Lock() + defer c.Unlock() + + for address, client := range clients { + logrus.Infof("Reverting to snapshot %s on %s", name, address) + if err := client.Revert(name); err != nil { + c.setReplicaModeNoLock(address, types.ERR) + return err + } + } + + return c.startFrontend() +} + +func (c *Controller) clientsAndSnapshot(name string) (map[string]*client.ReplicaClient, string, error) { + clients := map[string]*client.ReplicaClient{} + + for _, replica := range c.replicas { + if !strings.HasPrefix(replica.Address, "tcp://") { + return nil, "", fmt.Errorf("Backend %s does not support revert", replica.Address) + } + + repClient, err := client.NewReplicaClient(replica.Address) + if err != nil { + return nil, "", err + } + + rep, err := repClient.GetReplica() + if err != nil { + return nil, "", err + } + + found := "" + for _, snapshot := range rep.Chain { + if snapshot == name { + found = name + break + } + fullName := "volume-snap-" + name + ".img" + if snapshot == fullName { + found = fullName + break + } + } + + if found == "" { + return nil, "", fmt.Errorf("Failed to find snapshot %s on %s", name, replica) + } + + name = found + clients[replica.Address] = repClient + } + + return clients, name, nil +} diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 10134e6a..6a1918ca 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -185,6 +185,38 @@ def test_replica_add_after_rebuild_failed(bin, controller_client, assert r.mode == 'RW' +def test_revert(bin, controller_client, replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + snap = v.snapshot(name='foo1') + assert snap.id == 'foo1' + + snap2 = v.snapshot(name='foo2') + assert snap2.id == 'foo2' + + r1 = replica_client.list_replica()[0] + r2 = replica_client2.list_replica()[0] + + assert r1.chain == ['volume-head-002.img', 'volume-snap-foo2.img', + 'volume-snap-foo1.img'] + assert r1.chain == r2.chain + + v.revert(name='foo1') + + r1 = replica_client.list_replica()[0] + r2 = replica_client2.list_replica()[0] + assert r1.chain == ['volume-head-003.img', 'volume-snap-foo1.img'] + assert r1.chain == r2.chain + + def test_snapshot(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) open_replica(replica_client2) diff --git a/replica/client/client.go b/replica/client/client.go index 7211582c..4519f07c 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -77,6 +77,17 @@ func (c *ReplicaClient) Create(size string) error { }, nil) } +func (c *ReplicaClient) Revert(name string) error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["revert"], rest.RevertInput{ + Name: name, + }, nil) +} + func (c *ReplicaClient) Close() error { r, err := c.GetReplica() if err != nil { diff --git a/replica/replica.go b/replica/replica.go index 6b697d9d..08ef1f8d 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -366,6 +366,37 @@ func (r *Replica) rmDisk(name string) error { return lastErr } +func (r *Replica) revertDisk(parent string) (*Replica, error) { + if _, err := os.Stat(path.Join(r.dir, parent)); err != nil { + return nil, err + } + + oldHead := r.info.Head + f, newHeadDisk, err := r.createNewHead(oldHead, parent) + if err != nil { + return nil, err + } + defer f.Close() + + info := r.info + info.Head = newHeadDisk.name + info.Dirty = true + info.Parent = newHeadDisk.Parent + + if err := r.encodeToFile(&info, volumeMetaData); err != nil { + r.encodeToFile(&r.info, volumeMetaData) + return nil, err + } + + rNew, err := r.Reload() + if err != nil { + return nil, err + } + + r.rmDisk(oldHead) + return rNew, nil +} + func (r *Replica) createDisk(name string) error { if r.readOnly { return fmt.Errorf("Can not create disk on read-only replica") @@ -518,6 +549,13 @@ func (r *Replica) Snapshot(name string) error { return r.createDisk(name) } +func (r *Replica) Revert(name string) (*Replica, error) { + r.Lock() + defer r.Unlock() + + return r.revertDisk(name) +} + func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { if r.readOnly { return 0, fmt.Errorf("Can not write on read-only replica") diff --git a/replica/replica_test.go b/replica/replica_test.go index 7078e70e..8422bb6a 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -59,6 +59,41 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.activeDiskData[1].Parent, Equals, "") } +func (s *TestSuite) TestRevert(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot("000") + c.Assert(err, IsNil) + + err = r.Snapshot("001") + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 4) + c.Assert(len(r.volume.files), Equals, 4) + + chain, err := r.Chain() + c.Assert(err, IsNil) + c.Assert(len(chain), Equals, 3) + c.Assert(chain[0], Equals, "volume-head-002.img") + c.Assert(chain[1], Equals, "volume-snap-001.img") + c.Assert(chain[2], Equals, "volume-snap-000.img") + + r, err = r.Revert("volume-snap-000.img") + c.Assert(err, IsNil) + + chain, err = r.Chain() + c.Assert(err, IsNil) + c.Assert(len(chain), Equals, 2) + c.Assert(chain[0], Equals, "volume-head-003.img") + c.Assert(chain[1], Equals, "volume-snap-000.img") +} + func (s *TestSuite) TestRemoveLast(c *C) { dir, err := ioutil.TempDir("", "replica") c.Assert(err, IsNil) diff --git a/replica/rest/model.go b/replica/rest/model.go index 61f338ad..a986c038 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -25,6 +25,11 @@ type CreateInput struct { Size string `json:"size"` } +type RevertInput struct { + client.Resource + Name string `json:"name"` +} + type RebuildingInput struct { client.Resource Rebuilding bool `json:"rebuilding"` @@ -62,15 +67,18 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["snapshot"] = true actions["reload"] = true actions["removedisk"] = true + actions["revert"] = true case replica.Closed: actions["open"] = true actions["removedisk"] = true + actions["revert"] = true case replica.Dirty: actions["setrebuilding"] = true actions["close"] = true actions["snapshot"] = true actions["reload"] = true actions["removedisk"] = true + actions["revert"] = true case replica.Rebuilding: actions["snapshot"] = true actions["setrebuilding"] = true @@ -107,6 +115,7 @@ func NewSchema() *client.Schemas { schemas.AddType("rebuildingInput", RebuildingInput{}) schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("removediskInput", RemoveDiskInput{}) + schemas.AddType("revertInput", RevertInput{}) replica := schemas.AddType("replica", Replica{}) replica.ResourceMethods = []string{"GET", "DELETE"} @@ -136,6 +145,10 @@ func NewSchema() *client.Schemas { Input: "createInput", Output: "replica", }, + "revert": client.Action{ + Input: "revertInput", + Output: "replica", + }, } return schemas diff --git a/replica/rest/replica.go b/replica/rest/replica.go index f94c0631..35a0f167 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -104,6 +104,16 @@ func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) erro return s.doOp(req, s.s.Snapshot(name)) } +func (s *Server) RevertReplica(rw http.ResponseWriter, req *http.Request) error { + var input RevertInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil && err != io.EOF { + return err + } + + return s.doOp(req, s.s.Revert(input.Name)) +} + func (s *Server) ReloadReplica(rw http.ResponseWriter, req *http.Request) error { return s.doOp(req, s.s.Reload()) } diff --git a/replica/rest/router.go b/replica/rest/router.go index e0c363a4..190911ac 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -57,6 +57,7 @@ func NewRouter(s *Server) *mux.Router { "removedisk": s.RemoveDisk, "setrebuilding": s.SetRebuilding, "create": s.Create, + "revert": s.RevertReplica, } for name, action := range actions { diff --git a/replica/server.go b/replica/server.go index 1774f4a6..c8d73006 100644 --- a/replica/server.go +++ b/replica/server.go @@ -147,6 +147,24 @@ func (s *Server) Replica() *Replica { return s.r } +func (s *Server) Revert(name string) error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Reverting to snapshot [%s] on volume [%s]", name) + r, err := s.r.Revert(name) + if err != nil { + return err + } + + s.r = r + return nil +} + func (s *Server) Snapshot(name string) error { s.Lock() defer s.Unlock() From 83cd1d98e32ae12ac232d7c5181c5e86f8245a43 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 17:26:31 -0700 Subject: [PATCH 076/357] cli: Add revert snapshot cli --- app/snapshot.go | 28 ++++++++++++++++++++++++++ controller/client/controller_client.go | 11 ++++++++++ replica/server.go | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/snapshot.go b/app/snapshot.go index 21907f31..508ac7dc 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -18,6 +18,7 @@ func SnapshotCmd() cli.Command { ShortName: "snapshot", Subcommands: []cli.Command{ SnapshotCreateCmd(), + SnapshotRevertCmd(), SnapshotLsCmd(), SnapshotRmCmd(), }, @@ -40,6 +41,17 @@ func SnapshotCreateCmd() cli.Command { } } +func SnapshotRevertCmd() cli.Command { + return cli.Command{ + Name: "revert", + Action: func(c *cli.Context) { + if err := revertSnapshot(c); err != nil { + logrus.Fatalf("Error running revert snapshot command: %v", err) + } + }, + } +} + func SnapshotRmCmd() cli.Command { return cli.Command{ Name: "rm", @@ -74,6 +86,22 @@ func createSnapshot(c *cli.Context) error { return nil } +func revertSnapshot(c *cli.Context) error { + cli := getCli(c) + + name := c.Args()[0] + if name == "" { + return fmt.Errorf("Missing parameter for snapshot") + } + + err := cli.RevertSnapshot(name) + if err != nil { + return err + } + + return nil +} + func rmSnapshot(c *cli.Context) error { var lastErr error url := c.GlobalString("url") diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 087a3d3c..377733df 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -52,6 +52,17 @@ func (c *ControllerClient) Snapshot() (string, error) { return output.Id, err } +func (c *ControllerClient) RevertSnapshot(snapshot string) error { + volume, err := c.GetVolume() + if err != nil { + return err + } + + return c.post(volume.Actions["revert"], rest.RevertInput{ + Name: snapshot, + }, nil) +} + func (c *ControllerClient) ListReplicas() ([]rest.Replica, error) { var resp rest.ReplicaCollection err := c.get("/replicas", &resp) diff --git a/replica/server.go b/replica/server.go index c8d73006..9b7e92e4 100644 --- a/replica/server.go +++ b/replica/server.go @@ -155,7 +155,7 @@ func (s *Server) Revert(name string) error { return nil } - logrus.Infof("Reverting to snapshot [%s] on volume [%s]", name) + logrus.Infof("Reverting to snapshot [%s] on volume", name) r, err := s.r.Revert(name) if err != nil { return err From 0141029e8ca6cddb4152d57f9d42a13ec7c09ead Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 21:45:23 -0700 Subject: [PATCH 077/357] replica: Remove volumeID double as path in backup code Assume the volume is in current directory. --- replica/backup.go | 11 +++++++---- replica/backup_test.go | 38 +++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/replica/backup.go b/replica/backup.go index a1cf96cc..2d44633c 100644 --- a/replica/backup.go +++ b/replica/backup.go @@ -3,7 +3,6 @@ package replica import ( "fmt" "os" - "path" "github.com/rancher/convoy/metadata" ) @@ -36,8 +35,8 @@ func NewBackup(backingFile *BackingFile) *Backup { } func (rb *Backup) HasSnapshot(id, volumeID string) bool { - data := path.Join(volumeID, id) - for _, file := range []string{data, data + ".meta"} { + //TODO Check current in the volume directory of volumeID + for _, file := range []string{id, id + ".meta"} { if _, err := os.Stat(file); err != nil { return false } @@ -54,7 +53,11 @@ func (rb *Backup) OpenSnapshot(id, volumeID string) error { return fmt.Errorf("Volume %s and snapshot %s are already open, close first", rb.volumeID, rb.snapshotID) } - r, err := NewReadOnly(volumeID, id, rb.backingFile) + dir, err := os.Getwd() + if err != nil { + return fmt.Errorf("Cannot get working directory: %v", err) + } + r, err := NewReadOnly(dir, id, rb.backingFile) if err != nil { return err } diff --git a/replica/backup_test.go b/replica/backup_test.go index 808f59a5..c8859c02 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -17,6 +17,9 @@ func (s *TestSuite) TestBackup(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) + err = os.Chdir(dir) + c.Assert(err, IsNil) + r, err := New(10*mb, bs, dir, nil) c.Assert(err, IsNil) defer r.Close() @@ -30,10 +33,11 @@ func (s *TestSuite) TestBackup(c *C) { c.Assert(err, IsNil) rb := NewBackup(nil) - err = rb.OpenSnapshot(chain[0], dir) + volume := "test" + err = rb.OpenSnapshot(chain[0], volume) c.Assert(err, IsNil) - mappings, err := rb.CompareSnapshot(chain[0], "", dir) + mappings, err := rb.CompareSnapshot(chain[0], "", volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 2) c.Assert(mappings.BlockSize, Equals, int64(2*mb)) @@ -75,6 +79,10 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(err, IsNil) defer os.RemoveAll(dir) + err = os.Chdir(dir) + c.Assert(err, IsNil) + volume := "test" + r, err := New(10*mb, bs, dir, backingFile) c.Assert(err, IsNil) defer r.Close() @@ -118,9 +126,9 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { rb := NewBackup(nil) // Test 002 -> "" - err = rb.OpenSnapshot(chain[1], dir) + err = rb.OpenSnapshot(chain[1], volume) c.Assert(err, IsNil) - mappings, err := rb.CompareSnapshot(chain[1], "", dir) + mappings, err := rb.CompareSnapshot(chain[1], "", volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 4) c.Assert(mappings.BlockSize, Equals, int64(2*mb)) @@ -137,16 +145,16 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { expected := make([]byte, 2*mb) fill(expected, 2) readBuf := make([]byte, 2*mb) - err = rb.ReadSnapshot(chain[1], dir, 0, readBuf) + err = rb.ReadSnapshot(chain[1], volume, 0, readBuf) c.Assert(err, IsNil) byteEquals(c, readBuf, expected) - err = rb.CloseSnapshot(chain[1], dir) + err = rb.CloseSnapshot(chain[1], volume) c.Assert(err, IsNil) // Test 002 -> 001 - err = rb.OpenSnapshot(chain[1], dir) + err = rb.OpenSnapshot(chain[1], volume) c.Assert(err, IsNil) - mappings, err = rb.CompareSnapshot(chain[1], chain[2], dir) + mappings, err = rb.CompareSnapshot(chain[1], chain[2], volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 2) c.Assert(mappings.BlockSize, Equals, int64(2*mb)) @@ -154,12 +162,12 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) c.Assert(mappings.Mappings[1].Offset, Equals, int64(8*mb)) c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) - err = rb.CloseSnapshot(chain[1], dir) + err = rb.CloseSnapshot(chain[1], volume) // Test 001 -> 000 - err = rb.OpenSnapshot(chain[2], dir) + err = rb.OpenSnapshot(chain[2], volume) c.Assert(err, IsNil) - mappings, err = rb.CompareSnapshot(chain[2], chain[3], dir) + mappings, err = rb.CompareSnapshot(chain[2], chain[3], volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 2) c.Assert(mappings.BlockSize, Equals, int64(2*mb)) @@ -167,13 +175,13 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) c.Assert(mappings.Mappings[1].Offset, Equals, int64(4*mb)) c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) - err = rb.CloseSnapshot(chain[2], dir) + err = rb.CloseSnapshot(chain[2], volume) c.Assert(err, IsNil) // Test 001 -> "" - err = rb.OpenSnapshot(chain[2], dir) + err = rb.OpenSnapshot(chain[2], volume) c.Assert(err, IsNil) - mappings, err = rb.CompareSnapshot(chain[2], "", dir) + mappings, err = rb.CompareSnapshot(chain[2], "", volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 3) c.Assert(mappings.BlockSize, Equals, int64(2*mb)) @@ -183,6 +191,6 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) c.Assert(mappings.Mappings[2].Offset, Equals, int64(4*mb)) c.Assert(mappings.Mappings[2].Size, Equals, int64(2*mb)) - err = rb.CloseSnapshot(chain[2], dir) + err = rb.CloseSnapshot(chain[2], volume) c.Assert(err, IsNil) } From 4ad050996bacec1b62d510733c5a48ede204ff1a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 21:45:23 -0700 Subject: [PATCH 078/357] backup: Add longhorn-backup --- backup/import_objectstore.go | 8 + backup/main.go | 333 + scripts/build | 1 + scripts/build-backup | 9 + trash.yml | 29 +- .../aws/aws-sdk-go/aws/awserr/error.go | 105 + .../aws/aws-sdk-go/aws/awserr/types.go | 135 + .../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/aws-sdk-go/aws/client/client.go | 120 + .../aws-sdk-go/aws/client/default_retryer.go | 45 + .../aws/client/metadata/client_info.go | 12 + .../github.com/aws/aws-sdk-go/aws/config.go | 270 + .../aws/aws-sdk-go/aws/convert_types.go | 357 + .../aws-sdk-go/aws/corehandlers/handlers.go | 139 + .../aws/corehandlers/param_validator.go | 144 + .../aws/credentials/chain_provider.go | 87 + .../aws-sdk-go/aws/credentials/credentials.go | 220 + .../ec2rolecreds/ec2_role_provider.go | 174 + .../aws/credentials/env_provider.go | 73 + .../aws-sdk-go/aws/credentials/example.ini | 12 + .../shared_credentials_provider.go | 147 + .../aws/credentials/static_provider.go | 44 + .../aws/aws-sdk-go/aws/defaults/defaults.go | 95 + .../aws/aws-sdk-go/aws/ec2metadata/api.go | 43 + .../aws/aws-sdk-go/aws/ec2metadata/service.go | 116 + .../github.com/aws/aws-sdk-go/aws/errors.go | 17 + .../github.com/aws/aws-sdk-go/aws/logger.go | 98 + .../aws/aws-sdk-go/aws/request/handlers.go | 140 + .../aws/aws-sdk-go/aws/request/request.go | 279 + .../aws/request/request_pagination.go | 104 + .../aws/aws-sdk-go/aws/request/retryer.go | 82 + .../aws/aws-sdk-go/aws/session/session.go | 111 + 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/endpoints/endpoints.go | 65 + .../private/endpoints/endpoints.json | 92 + .../private/endpoints/endpoints_map.go | 104 + .../private/protocol/query/build.go | 33 + .../protocol/query/queryutil/queryutil.go | 223 + .../private/protocol/query/unmarshal.go | 29 + .../private/protocol/query/unmarshal_error.go | 33 + .../aws-sdk-go/private/protocol/rest/build.go | 254 + .../private/protocol/rest/payload.go | 45 + .../private/protocol/rest/unmarshal.go | 183 + .../private/protocol/restxml/restxml.go | 57 + .../private/protocol/xml/xmlutil/build.go | 287 + .../private/protocol/xml/xmlutil/unmarshal.go | 260 + .../protocol/xml/xmlutil/xml_to_struct.go | 105 + .../aws/aws-sdk-go/private/signer/v4/v4.go | 365 + .../aws/aws-sdk-go/private/waiter/waiter.go | 136 + .../aws/aws-sdk-go/service/s3/api.go | 6267 +++++++++++++++++ .../aws-sdk-go/service/s3/bucket_location.go | 43 + .../aws/aws-sdk-go/service/s3/content_md5.go | 36 + .../aws-sdk-go/service/s3/customizations.go | 37 + .../service/s3/host_style_bucket.go | 60 + .../aws/aws-sdk-go/service/s3/service.go | 86 + .../aws/aws-sdk-go/service/s3/sse.go | 44 + .../aws-sdk-go/service/s3/statusok_error.go | 36 + .../aws-sdk-go/service/s3/unmarshal_error.go | 51 + .../aws/aws-sdk-go/service/s3/waiters.go | 117 + vendor/github.com/go-ini/ini/.gitignore | 4 + vendor/github.com/go-ini/ini/LICENSE | 191 + vendor/github.com/go-ini/ini/README.md | 590 ++ vendor/github.com/go-ini/ini/README_ZH.md | 577 ++ vendor/github.com/go-ini/ini/ini.go | 1027 +++ vendor/github.com/go-ini/ini/parser.go | 312 + vendor/github.com/go-ini/ini/struct.go | 351 + .../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 + vendor/github.com/jmespath/go-jmespath/api.go | 49 + .../go-jmespath/astnodetype_string.go | 16 + .../jmespath/go-jmespath/functions.go | 840 +++ .../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/mcuadros/go-version/.gitignore | 22 + .../mcuadros/go-version/.travis.yml | 1 + vendor/github.com/mcuadros/go-version/LICENSE | 19 + .../github.com/mcuadros/go-version/README.md | 82 + .../github.com/mcuadros/go-version/compare.go | 159 + .../mcuadros/go-version/constraint.go | 49 + vendor/github.com/mcuadros/go-version/doc.go | 6 + .../github.com/mcuadros/go-version/group.go | 269 + .../mcuadros/go-version/normalize.go | 116 + vendor/github.com/mcuadros/go-version/sort.go | 36 + .../mcuadros/go-version/stability.go | 83 + vendor/github.com/rancher/convoy/README.md | 2 +- .../convoy/convoydriver/convoydriver.go | 129 + .../rancher/convoy/logging/logging.go | 84 + .../rancher/convoy/objectstore/config.go | 202 + .../rancher/convoy/objectstore/deltablock.go | 389 + .../rancher/convoy/objectstore/driver.go | 63 + .../rancher/convoy/objectstore/objectstore.go | 185 + .../rancher/convoy/objectstore/singlefile.go | 136 + vendor/github.com/rancher/convoy/s3/s3.go | 191 + .../rancher/convoy/s3/s3_service.go | 157 + .../github.com/rancher/convoy/util/config.go | 155 + .../github.com/rancher/convoy/util/index.go | 55 + vendor/github.com/rancher/convoy/util/util.go | 433 ++ .../github.com/rancher/convoy/util/volume.go | 459 ++ .../rancher/convoy/vfs/vfs_objectstore.go | 185 + .../rancher/convoy/vfs/vfs_storage.go | 598 ++ vendor/golang.org/x/sys/unix/.gitignore | 1 + 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 + .../golang.org/x/sys/unix/asm_dragonfly_386.s | 29 + .../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 + 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 + 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/mkall.sh | 274 + vendor/golang.org/x/sys/unix/mkerrors.sh | 476 ++ vendor/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 + 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 | 74 + 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 | 79 + .../x/sys/unix/syscall_darwin_amd64.go | 81 + .../x/sys/unix/syscall_darwin_arm.go | 73 + .../x/sys/unix/syscall_darwin_arm64.go | 79 + .../x/sys/unix/syscall_dragonfly.go | 411 ++ .../x/sys/unix/syscall_dragonfly_386.go | 63 + .../x/sys/unix/syscall_dragonfly_amd64.go | 63 + .../golang.org/x/sys/unix/syscall_freebsd.go | 682 ++ .../x/sys/unix/syscall_freebsd_386.go | 63 + .../x/sys/unix/syscall_freebsd_amd64.go | 63 + .../x/sys/unix/syscall_freebsd_arm.go | 63 + vendor/golang.org/x/sys/unix/syscall_linux.go | 1097 +++ .../x/sys/unix/syscall_linux_386.go | 390 + .../x/sys/unix/syscall_linux_amd64.go | 148 + .../x/sys/unix/syscall_linux_arm.go | 252 + .../x/sys/unix/syscall_linux_arm64.go | 169 + .../x/sys/unix/syscall_linux_mips64x.go | 206 + .../x/sys/unix/syscall_linux_ppc64x.go | 98 + .../golang.org/x/sys/unix/syscall_netbsd.go | 492 ++ .../x/sys/unix/syscall_netbsd_386.go | 44 + .../x/sys/unix/syscall_netbsd_amd64.go | 44 + .../x/sys/unix/syscall_netbsd_arm.go | 44 + .../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 | 44 + .../x/sys/unix/syscall_openbsd_amd64.go | 44 + .../golang.org/x/sys/unix/syscall_solaris.go | 713 ++ .../x/sys/unix/syscall_solaris_amd64.go | 37 + 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 | 408 ++ 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_386.go | 1530 ++++ .../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 | 1817 +++++ .../x/sys/unix/zerrors_linux_amd64.go | 1818 +++++ .../x/sys/unix/zerrors_linux_arm.go | 1742 +++++ .../x/sys/unix/zerrors_linux_arm64.go | 1896 +++++ .../x/sys/unix/zerrors_linux_mips64.go | 1916 +++++ .../x/sys/unix/zerrors_linux_mips64le.go | 1916 +++++ .../x/sys/unix/zerrors_linux_ppc64.go | 1969 ++++++ .../x/sys/unix/zerrors_linux_ppc64le.go | 1968 ++++++ .../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 | 1426 ++++ .../x/sys/unix/zsyscall_darwin_amd64.go | 1442 ++++ .../x/sys/unix/zsyscall_darwin_arm.go | 1426 ++++ .../x/sys/unix/zsyscall_darwin_arm64.go | 1426 ++++ .../x/sys/unix/zsyscall_dragonfly_386.go | 1412 ++++ .../x/sys/unix/zsyscall_dragonfly_amd64.go | 1412 ++++ .../x/sys/unix/zsyscall_freebsd_386.go | 1664 +++++ .../x/sys/unix/zsyscall_freebsd_amd64.go | 1664 +++++ .../x/sys/unix/zsyscall_freebsd_arm.go | 1664 +++++ .../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 | 1733 +++++ .../x/sys/unix/zsyscall_linux_mips64.go | 1781 +++++ .../x/sys/unix/zsyscall_linux_mips64le.go | 1781 +++++ .../x/sys/unix/zsyscall_linux_ppc64.go | 1802 +++++ .../x/sys/unix/zsyscall_linux_ppc64le.go | 1802 +++++ .../x/sys/unix/zsyscall_netbsd_386.go | 1326 ++++ .../x/sys/unix/zsyscall_netbsd_amd64.go | 1326 ++++ .../x/sys/unix/zsyscall_netbsd_arm.go | 1326 ++++ .../x/sys/unix/zsyscall_openbsd_386.go | 1386 ++++ .../x/sys/unix/zsyscall_openbsd_amd64.go | 1386 ++++ .../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_386.go | 304 + .../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_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_386.go | 437 ++ .../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 | 590 ++ .../x/sys/unix/ztypes_linux_amd64.go | 608 ++ .../golang.org/x/sys/unix/ztypes_linux_arm.go | 579 ++ .../x/sys/unix/ztypes_linux_arm64.go | 595 ++ .../x/sys/unix/ztypes_linux_mips64.go | 599 ++ .../x/sys/unix/ztypes_linux_mips64le.go | 599 ++ .../x/sys/unix/ztypes_linux_ppc64.go | 605 ++ .../x/sys/unix/ztypes_linux_ppc64le.go | 605 ++ .../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 ++ 290 files changed, 129393 insertions(+), 2 deletions(-) create mode 100644 backup/import_objectstore.go create mode 100644 backup/main.go create mode 100755 scripts/build-backup 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/client.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.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/corehandlers/handlers.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.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/ec2rolecreds/ec2_role_provider.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/example.ini 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/defaults/defaults.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.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/session/session.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/endpoints/endpoints.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.json create mode 100644 vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints_map.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.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/protocol/restxml/restxml.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.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/private/waiter/waiter.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/api.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/customizations.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/host_style_bucket.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/service.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/sse.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/s3/waiters.go create mode 100644 vendor/github.com/go-ini/ini/.gitignore create mode 100644 vendor/github.com/go-ini/ini/LICENSE create mode 100644 vendor/github.com/go-ini/ini/README.md create mode 100644 vendor/github.com/go-ini/ini/README_ZH.md create mode 100644 vendor/github.com/go-ini/ini/ini.go create mode 100644 vendor/github.com/go-ini/ini/parser.go create mode 100644 vendor/github.com/go-ini/ini/struct.go create mode 100644 vendor/github.com/jmespath/go-jmespath/.gitignore create mode 100644 vendor/github.com/jmespath/go-jmespath/.travis.yml create mode 100644 vendor/github.com/jmespath/go-jmespath/LICENSE create mode 100644 vendor/github.com/jmespath/go-jmespath/Makefile create mode 100644 vendor/github.com/jmespath/go-jmespath/README.md 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/mcuadros/go-version/.gitignore create mode 100644 vendor/github.com/mcuadros/go-version/.travis.yml create mode 100644 vendor/github.com/mcuadros/go-version/LICENSE create mode 100644 vendor/github.com/mcuadros/go-version/README.md create mode 100644 vendor/github.com/mcuadros/go-version/compare.go create mode 100644 vendor/github.com/mcuadros/go-version/constraint.go create mode 100644 vendor/github.com/mcuadros/go-version/doc.go create mode 100644 vendor/github.com/mcuadros/go-version/group.go create mode 100644 vendor/github.com/mcuadros/go-version/normalize.go create mode 100644 vendor/github.com/mcuadros/go-version/sort.go create mode 100644 vendor/github.com/mcuadros/go-version/stability.go create mode 100644 vendor/github.com/rancher/convoy/convoydriver/convoydriver.go create mode 100644 vendor/github.com/rancher/convoy/logging/logging.go create mode 100644 vendor/github.com/rancher/convoy/objectstore/config.go create mode 100644 vendor/github.com/rancher/convoy/objectstore/deltablock.go create mode 100644 vendor/github.com/rancher/convoy/objectstore/driver.go create mode 100644 vendor/github.com/rancher/convoy/objectstore/objectstore.go create mode 100644 vendor/github.com/rancher/convoy/objectstore/singlefile.go create mode 100644 vendor/github.com/rancher/convoy/s3/s3.go create mode 100644 vendor/github.com/rancher/convoy/s3/s3_service.go create mode 100644 vendor/github.com/rancher/convoy/util/config.go create mode 100644 vendor/github.com/rancher/convoy/util/index.go create mode 100644 vendor/github.com/rancher/convoy/util/util.go create mode 100644 vendor/github.com/rancher/convoy/util/volume.go create mode 100644 vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go create mode 100644 vendor/github.com/rancher/convoy/vfs/vfs_storage.go create mode 100644 vendor/golang.org/x/sys/unix/.gitignore 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_386.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_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/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 100755 vendor/golang.org/x/sys/unix/mkall.sh create mode 100755 vendor/golang.org/x/sys/unix/mkerrors.sh create mode 100755 vendor/golang.org/x/sys/unix/mksyscall.pl create mode 100755 vendor/golang.org/x/sys/unix/mksyscall_solaris.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysnum_darwin.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysnum_linux.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl create mode 100755 vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl 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_386.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_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_386.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_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_386.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_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_386.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_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_386.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_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 diff --git a/backup/import_objectstore.go b/backup/import_objectstore.go new file mode 100644 index 00000000..f41f3df4 --- /dev/null +++ b/backup/import_objectstore.go @@ -0,0 +1,8 @@ +package main + +import ( + // Involve S3 objecstore drivers for registeration + _ "github.com/rancher/convoy/s3" + // Involve VFS convoy driver/objectstore driver for registeration + _ "github.com/rancher/convoy/vfs" +) diff --git a/backup/main.go b/backup/main.go new file mode 100644 index 00000000..62f381dd --- /dev/null +++ b/backup/main.go @@ -0,0 +1,333 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "path" + "runtime" + "runtime/debug" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + + "github.com/rancher/convoy/objectstore" + "github.com/rancher/convoy/util" + "github.com/rancher/longhorn/replica" +) + +const ( + DRIVERNAME = "longhorn" +) + +var ( + VERSION = "0.0.0" + log = logrus.WithFields(logrus.Fields{"pkg": "backup"}) + + backupCreateCmd = cli.Command{ + Name: "create", + Usage: "create a backup in objectstore: create ", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "dest", + Usage: "destination of backup if driver supports, would be url like s3://bucket@region/path/ or vfs:///path/", + }, + cli.StringFlag{ + Name: "volume", + Usage: "volume path, the base name will be used as volume name", + }, + }, + Action: cmdBackupCreate, + } + + backupRestoreCmd = cli.Command{ + Name: "restore", + Usage: "restore a backup to file: restore ", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "to", + Usage: "destination file of restoring, will be created if not exists", + }, + }, + Action: cmdBackupRestore, + } + + backupDeleteCmd = cli.Command{ + Name: "delete", + Usage: "delete a backup in objectstore: delete ", + Action: cmdBackupDelete, + } + + backupListCmd = cli.Command{ + Name: "list", + Usage: "list backups in objectstore: list ", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "volume", + Usage: "volume name", + }, + }, + Action: cmdBackupList, + } + + backupInspectCmd = cli.Command{ + Name: "inspect", + Usage: "inspect a backup: inspect ", + Action: cmdBackupInspect, + } +) + +// ResponseLogAndError would log the error before call ResponseError() +func ResponseLogAndError(v interface{}) { + if e, ok := v.(*logrus.Entry); ok { + e.Error(e.Message) + oldFormatter := e.Logger.Formatter + logrus.SetFormatter(&logrus.JSONFormatter{}) + s, err := e.String() + logrus.SetFormatter(oldFormatter) + if err != nil { + fmt.Println(err.Error()) + return + } + // Cosmetic since " would be escaped + fmt.Println(strings.Replace(s, "\"", "'", -1)) + } else { + e, isErr := v.(error) + _, isRuntimeErr := e.(runtime.Error) + if isErr && !isRuntimeErr { + logrus.Errorf(fmt.Sprint(e)) + fmt.Println(fmt.Sprint(e)) + } else { + logrus.Errorf("Caught FATAL error: %s", v) + debug.PrintStack() + fmt.Printf("Caught FATAL error: %s\n", v) + } + } +} + +func cleanup() { + if r := recover(); r != nil { + ResponseLogAndError(r) + os.Exit(1) + } +} + +func main() { + defer cleanup() + + app := cli.NewApp() + app.Version = VERSION + app.Commands = []cli.Command{ + backupCreateCmd, + backupRestoreCmd, + backupDeleteCmd, + backupListCmd, + backupInspectCmd, + } + app.Run(os.Args) +} + +func getName(c *cli.Context, key string, required bool) (string, error) { + var err error + var name string + if key == "" { + name = c.Args().First() + } else { + name, err = util.GetFlag(c, key, required, err) + if err != nil { + return "", err + } + } + if name == "" && !required { + return "", nil + } + + if err := util.CheckName(name); err != nil { + return "", err + } + return name, nil +} + +func ResponseOutput(v interface{}) ([]byte, error) { + j, err := json.MarshalIndent(v, "", "\t") + if err != nil { + return nil, err + } + return j, nil +} + +func cmdBackupCreate(c *cli.Context) { + if err := doBackupCreate(c); err != nil { + panic(err) + } +} + +func doBackupCreate(c *cli.Context) error { + var err error + + destURL, err := util.GetFlag(c, "dest", true, err) + if err != nil { + return err + } + + snapshotName, err := getName(c, "", true) + if err != nil { + return err + } + + volumePath, err := util.GetFlag(c, "volume", true, err) + if err != nil { + return err + } + + // Switch to one level upper than volume working directory + volumeName := path.Base(volumePath) + volumeDir := path.Dir(volumePath) + log.Info("volume dir, name", volumeDir, volumeName) + if volumeDir != "" { + if err := os.Chdir(volumeDir); err != nil { + return err + } + } + + volumeInfo, err := replica.ReadInfo(volumeName) + if err != nil { + return err + } + replicaBackup := replica.NewBackup(volumeInfo.BackingFile) + + volume := &objectstore.Volume{ + Name: volumeName, + Driver: DRIVERNAME, + Size: volumeInfo.Size, + CreatedTime: util.Now(), + } + snapshot := &objectstore.Snapshot{ + Name: snapshotName, + CreatedTime: util.Now(), + } + + log.Debugf("Starting backup for %v, snapshot %v, dest %v", volume, snapshot, destURL) + backupURL, err := objectstore.CreateDeltaBlockBackup(volume, snapshot, destURL, replicaBackup) + if err != nil { + return err + } + fmt.Println(backupURL) + return nil +} + +func cmdBackupDelete(c *cli.Context) { + if err := doBackupDelete(c); err != nil { + panic(err) + } +} + +func doBackupDelete(c *cli.Context) error { + var err error + backupURL, err := util.GetFlag(c, "", true, err) + if err != nil { + return err + } + backupURL = util.UnescapeURL(backupURL) + + if err := objectstore.DeleteDeltaBlockBackup(backupURL); err != nil { + return err + } + return nil +} + +func cmdBackupRestore(c *cli.Context) { + if err := doBackupRestore(c); err != nil { + panic(err) + } +} + +func doBackupRestore(c *cli.Context) error { + var err error + backupURL, err := util.GetFlag(c, "", true, err) + if err != nil { + return err + } + backupURL = util.UnescapeURL(backupURL) + + toFile, err := util.GetFlag(c, "to", true, err) + if err != nil { + return err + } + + if err := objectstore.RestoreDeltaBlockBackup(backupURL, toFile); err != nil { + return err + } + + if err := createNewSnapshotMetafile(toFile + ".meta"); err != nil { + return err + } + return nil +} + +func createNewSnapshotMetafile(file string) error { + f, err := os.Create(file + ".tmp") + if err != nil { + return err + } + defer f.Close() + + content := "{\"Parent\":\"\"}\n" + if _, err := f.Write([]byte(content)); err != nil { + return err + } + + if err := f.Close(); err != nil { + return err + } + + return os.Rename(file+".tmp", file) +} + +func cmdBackupList(c *cli.Context) { + if err := doBackupList(c); err != nil { + panic(err) + } +} + +func doBackupList(c *cli.Context) error { + var err error + + destURL, err := util.GetFlag(c, "", true, err) + volumeName, err := util.GetName(c, "volume", false, err) + if err != nil { + return err + + } + list, err := objectstore.List(volumeName, destURL, DRIVERNAME) + if err != nil { + return err + } + fmt.Println(list) + return nil +} + +func cmdBackupInspect(c *cli.Context) { + if err := doBackupInspect(c); err != nil { + panic(err) + } +} + +func doBackupInspect(c *cli.Context) error { + var err error + + backupURL, err := util.GetFlag(c, "", true, err) + if err != nil { + return err + } + backupURL = util.UnescapeURL(backupURL) + + info, err := objectstore.GetBackupInfo(backupURL) + if err != nil { + return nil + } + fmt.Println(info) + + return nil +} diff --git a/scripts/build b/scripts/build index 0347cab2..eba35192 100755 --- a/scripts/build +++ b/scripts/build @@ -5,3 +5,4 @@ cd $(dirname $0) ./build-cli ./build-agent +./build-backup diff --git a/scripts/build-backup b/scripts/build-backup new file mode 100755 index 00000000..a82e9946 --- /dev/null +++ b/scripts/build-backup @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source $(dirname $0)/version + +cd $(dirname $0)/.. + +mkdir -p bin +go build -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn-backup ./backup diff --git a/trash.yml b/trash.yml index 7a6a2813..13a9ce01 100644 --- a/trash.yml +++ b/trash.yml @@ -29,4 +29,31 @@ import: - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy - version: a583d83d3104449580779b06e27a63bc7371b4d0 + version: 2d75418d1f796c6b26e34f7fecf3c1e839a99479 +- package: github.com/mcuadros/go-version + version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 +- package: golang.org/x/sys/unix + version: 7a56174f0086b32866ebd746a794417edbc678a1 +- package: github.com/aws/aws-sdk-go/aws + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/endpoints + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/protocol/query + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/protocol/rest + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/protocol/restxml + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/signer/v4 + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/private/waiter + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/aws/aws-sdk-go/service/s3 + version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +- package: github.com/go-ini/ini + version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 +- package: github.com/jmespath/go-jmespath + version: c01cf91b011868172fdcd9f41838e80c9d716264 + 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 00000000..a52743be --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go @@ -0,0 +1,105 @@ +// 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:", err.Code(), err.Message()) +// +// // Prints out full error message, including original error if there was one. +// log.Println("Error:", err.Error()) +// +// // Get original error +// if origErr := err.Err(); 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 +} + +// 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 { + if e, ok := origErr.(Error); ok && e != nil { + return e + } + return newBaseError(code, message, origErr) +} + +// 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.Printf("Request failed", reqerr.Code(), reqerr.Message(), reqerr.RequestID()) +// } else { +// log.Printf("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 00000000..003a6e80 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awserr/types.go @@ -0,0 +1,135 @@ +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. + origErr 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 { + return &baseError{ + code: code, + message: message, + origErr: origErr, + } +} + +// Error returns the string representation of the error. +// +// See ErrorWithExtra for formatting. +// +// Satisfies the error interface. +func (b baseError) Error() string { + return SprintError(b.code, b.message, "", b.origErr) +} + +// 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. +func (b baseError) OrigErr() error { + return b.origErr +} + +// 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 +} 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 00000000..8429470b --- /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 00000000..59fa4a55 --- /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 00000000..4d2a01e8 --- /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 00000000..0de3eaa0 --- /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 00000000..b6432f1a --- /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/client.go b/vendor/github.com/aws/aws-sdk-go/aws/client/client.go new file mode 100644 index 00000000..c8d0564d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/client/client.go @@ -0,0 +1,120 @@ +package client + +import ( + "fmt" + "io/ioutil" + "net/http/httputil" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/request" +) + +// A Config provides configuration to a service client instance. +type Config struct { + Config *aws.Config + Handlers request.Handlers + Endpoint, SigningRegion string +} + +// ConfigProvider provides a generic way for a service client to receive +// the ClientConfig without circular dependencies. +type ConfigProvider interface { + ClientConfig(serviceName string, cfgs ...*aws.Config) Config +} + +// A Client implements the base client request and response handling +// used by all service clients. +type Client struct { + request.Retryer + metadata.ClientInfo + + Config aws.Config + Handlers request.Handlers +} + +// New will return a pointer to a new initialized service client. +func New(cfg aws.Config, info metadata.ClientInfo, handlers request.Handlers, options ...func(*Client)) *Client { + svc := &Client{ + Config: cfg, + ClientInfo: info, + Handlers: handlers, + } + + switch retryer, ok := cfg.Retryer.(request.Retryer); { + case ok: + svc.Retryer = retryer + case cfg.Retryer != nil && cfg.Logger != nil: + s := fmt.Sprintf("WARNING: %T does not implement request.Retryer; using DefaultRetryer instead", cfg.Retryer) + cfg.Logger.Log(s) + fallthrough + default: + maxRetries := aws.IntValue(cfg.MaxRetries) + if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries { + maxRetries = 3 + } + svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries} + } + + svc.AddDebugHandlers() + + for _, option := range options { + option(svc) + } + + return svc +} + +// NewRequest returns a new Request pointer for the service API +// operation and parameters. +func (c *Client) NewRequest(operation *request.Operation, params interface{}, data interface{}) *request.Request { + return request.New(c.Config, c.ClientInfo, c.Handlers, c.Retryer, operation, params, data) +} + +// AddDebugHandlers injects debug logging handlers into the service to log request +// debug information. +func (c *Client) AddDebugHandlers() { + if !c.Config.LogLevel.AtLeast(aws.LogDebug) { + return + } + + c.Handlers.Send.PushFront(logRequest) + c.Handlers.Send.PushBack(logResponse) +} + +const logReqMsg = `DEBUG: Request %s/%s Details: +---[ REQUEST POST-SIGN ]----------------------------- +%s +-----------------------------------------------------` + +func logRequest(r *request.Request) { + logBody := r.Config.LogLevel.Matches(aws.LogDebugWithHTTPBody) + dumpedBody, _ := httputil.DumpRequestOut(r.HTTPRequest, logBody) + + if logBody { + // Reset the request body because dumpRequest will re-wrap the r.HTTPRequest's + // Body as a NoOpCloser and will not be reset after read by the HTTP + // client reader. + r.Body.Seek(r.BodyStart, 0) + r.HTTPRequest.Body = ioutil.NopCloser(r.Body) + } + + r.Config.Logger.Log(fmt.Sprintf(logReqMsg, r.ClientInfo.ServiceName, r.Operation.Name, string(dumpedBody))) +} + +const logRespMsg = `DEBUG: Response %s/%s Details: +---[ RESPONSE ]-------------------------------------- +%s +-----------------------------------------------------` + +func logResponse(r *request.Request) { + var msg = "no response data" + if r.HTTPResponse != nil { + logBody := r.Config.LogLevel.Matches(aws.LogDebugWithHTTPBody) + dumpedBody, _ := httputil.DumpResponse(r.HTTPResponse, logBody) + msg = string(dumpedBody) + } else if r.Error != nil { + msg = r.Error.Error() + } + r.Config.Logger.Log(fmt.Sprintf(logRespMsg, r.ClientInfo.ServiceName, r.Operation.Name, msg)) +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go b/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go new file mode 100644 index 00000000..24d39ce5 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go @@ -0,0 +1,45 @@ +package client + +import ( + "math" + "math/rand" + "time" + + "github.com/aws/aws-sdk-go/aws/request" +) + +// DefaultRetryer implements basic retry logic using exponential backoff for +// most services. If you want to implement custom retry logic, implement the +// request.Retryer interface or create a structure type that composes this +// struct and override the specific methods. For example, to override only +// the MaxRetries method: +// +// type retryer struct { +// service.DefaultRetryer +// } +// +// // This implementation always has 100 max retries +// func (d retryer) MaxRetries() uint { return 100 } +type DefaultRetryer struct { + NumMaxRetries int +} + +// MaxRetries returns the number of maximum returns the service will use to make +// an individual API request. +func (d DefaultRetryer) MaxRetries() int { + return d.NumMaxRetries +} + +// RetryRules returns the delay duration before retrying this request again +func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration { + delay := int(math.Pow(2, float64(r.RetryCount))) * (rand.Intn(30) + 30) + return time.Duration(delay) * time.Millisecond +} + +// ShouldRetry returns if the request should be retried. +func (d DefaultRetryer) ShouldRetry(r *request.Request) bool { + if r.HTTPResponse.StatusCode >= 500 { + return true + } + return r.IsErrorRetryable() +} 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 00000000..4778056d --- /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 00000000..75fcc828 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/config.go @@ -0,0 +1,270 @@ +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 { + // 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 + + 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{} +} + +// 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 +} + +// 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.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.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 00000000..d6a7b08d --- /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/corehandlers/handlers.go b/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go new file mode 100644 index 00000000..1d3e656f --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go @@ -0,0 +1,139 @@ +package corehandlers + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "regexp" + "runtime" + "strconv" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// Interface for matching types which also have a Len method. +type lener interface { + Len() int +} + +// BuildContentLengthHandler builds the content length of a request based on the body, +// or will use the HTTPRequest.Header's "Content-Length" if defined. If unable +// to determine request body length and no "Content-Length" was specified it will panic. +var BuildContentLengthHandler = request.NamedHandler{Name: "core.BuildContentLengthHandler", Fn: func(r *request.Request) { + if slength := r.HTTPRequest.Header.Get("Content-Length"); slength != "" { + length, _ := strconv.ParseInt(slength, 10, 64) + r.HTTPRequest.ContentLength = length + return + } + + var length int64 + switch body := r.Body.(type) { + case nil: + length = 0 + case lener: + length = int64(body.Len()) + case io.Seeker: + r.BodyStart, _ = body.Seek(0, 1) + end, _ := body.Seek(0, 2) + body.Seek(r.BodyStart, 0) // make sure to seek back to original location + length = end - r.BodyStart + default: + panic("Cannot get length of body, must provide `ContentLength`") + } + + r.HTTPRequest.ContentLength = length + r.HTTPRequest.Header.Set("Content-Length", fmt.Sprintf("%d", length)) +}} + +// SDKVersionUserAgentHandler is a request handler for adding the SDK Version to the user agent. +var SDKVersionUserAgentHandler = request.NamedHandler{ + Name: "core.SDKVersionUserAgentHandler", + Fn: request.MakeAddToUserAgentHandler(aws.SDKName, aws.SDKVersion, + runtime.Version(), runtime.GOOS, runtime.GOARCH), +} + +var reStatusCode = regexp.MustCompile(`^(\d{3})`) + +// SendHandler is a request handler to send service request using HTTP client. +var SendHandler = request.NamedHandler{Name: "core.SendHandler", Fn: func(r *request.Request) { + var err error + r.HTTPResponse, err = r.Config.HTTPClient.Do(r.HTTPRequest) + if err != nil { + // Capture the case where url.Error is returned for error processing + // response. e.g. 301 without location header comes back as string + // error and r.HTTPResponse is nil. Other url redirect errors will + // comeback in a similar method. + if e, ok := err.(*url.Error); ok && e.Err != nil { + if s := reStatusCode.FindStringSubmatch(e.Err.Error()); s != nil { + code, _ := strconv.ParseInt(s[1], 10, 64) + r.HTTPResponse = &http.Response{ + StatusCode: int(code), + Status: http.StatusText(int(code)), + Body: ioutil.NopCloser(bytes.NewReader([]byte{})), + } + return + } + } + if r.HTTPResponse == nil { + // Add a dummy request response object to ensure the HTTPResponse + // value is consistent. + r.HTTPResponse = &http.Response{ + StatusCode: int(0), + Status: http.StatusText(int(0)), + Body: ioutil.NopCloser(bytes.NewReader([]byte{})), + } + } + // Catch all other request errors. + r.Error = awserr.New("RequestError", "send request failed", err) + r.Retryable = aws.Bool(true) // network errors are retryable + } +}} + +// ValidateResponseHandler is a request handler to validate service response. +var ValidateResponseHandler = request.NamedHandler{Name: "core.ValidateResponseHandler", Fn: func(r *request.Request) { + if r.HTTPResponse.StatusCode == 0 || r.HTTPResponse.StatusCode >= 300 { + // this may be replaced by an UnmarshalError handler + r.Error = awserr.New("UnknownError", "unknown error", nil) + } +}} + +// AfterRetryHandler performs final checks to determine if the request should +// be retried and how long to delay. +var AfterRetryHandler = request.NamedHandler{Name: "core.AfterRetryHandler", Fn: func(r *request.Request) { + // If one of the other handlers already set the retry state + // we don't want to override it based on the service's state + if r.Retryable == nil { + r.Retryable = aws.Bool(r.ShouldRetry(r)) + } + + if r.WillRetry() { + r.RetryDelay = r.RetryRules(r) + r.Config.SleepDelay(r.RetryDelay) + + // when the expired token exception occurs the credentials + // need to be expired locally so that the next request to + // get credentials will trigger a credentials refresh. + if r.IsErrorExpired() { + r.Config.Credentials.Expire() + } + + r.RetryCount++ + r.Error = nil + } +}} + +// ValidateEndpointHandler is a request handler to validate a request had the +// appropriate Region and Endpoint set. Will set r.Error if the endpoint or +// region is not valid. +var ValidateEndpointHandler = request.NamedHandler{Name: "core.ValidateEndpointHandler", Fn: func(r *request.Request) { + if r.ClientInfo.SigningRegion == "" && aws.StringValue(r.Config.Region) == "" { + r.Error = aws.ErrMissingRegion + } else if r.ClientInfo.Endpoint == "" { + r.Error = aws.ErrMissingEndpoint + } +}} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go b/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go new file mode 100644 index 00000000..3b53f5e0 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go @@ -0,0 +1,144 @@ +package corehandlers + +import ( + "fmt" + "reflect" + "strconv" + "strings" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// ValidateParametersHandler is a request handler to validate the input parameters. +// Validating parameters only has meaning if done prior to the request being sent. +var ValidateParametersHandler = request.NamedHandler{Name: "core.ValidateParametersHandler", Fn: func(r *request.Request) { + if r.ParamsFilled() { + v := validator{errors: []string{}} + v.validateAny(reflect.ValueOf(r.Params), "") + + if count := len(v.errors); count > 0 { + format := "%d validation errors:\n- %s" + msg := fmt.Sprintf(format, count, strings.Join(v.errors, "\n- ")) + r.Error = awserr.New("InvalidParameter", msg, nil) + } + } +}} + +// A validator validates values. Collects validations errors which occurs. +type validator struct { + errors []string +} + +// validateAny will validate any struct, slice or map type. All validations +// are also performed recursively for nested types. +func (v *validator) validateAny(value reflect.Value, path string) { + value = reflect.Indirect(value) + if !value.IsValid() { + return + } + + switch value.Kind() { + case reflect.Struct: + v.validateStruct(value, path) + case reflect.Slice: + for i := 0; i < value.Len(); i++ { + v.validateAny(value.Index(i), path+fmt.Sprintf("[%d]", i)) + } + case reflect.Map: + for _, n := range value.MapKeys() { + v.validateAny(value.MapIndex(n), path+fmt.Sprintf("[%q]", n.String())) + } + } +} + +// validateStruct will validate the struct value's fields. If the structure has +// nested types those types will be validated also. +func (v *validator) validateStruct(value reflect.Value, path string) { + prefix := "." + if path == "" { + prefix = "" + } + + for i := 0; i < value.Type().NumField(); i++ { + f := value.Type().Field(i) + if strings.ToLower(f.Name[0:1]) == f.Name[0:1] { + continue + } + fvalue := value.FieldByName(f.Name) + + err := validateField(f, fvalue, validateFieldRequired, validateFieldMin) + if err != nil { + v.errors = append(v.errors, fmt.Sprintf("%s: %s", err.Error(), path+prefix+f.Name)) + continue + } + + v.validateAny(fvalue, path+prefix+f.Name) + } +} + +type validatorFunc func(f reflect.StructField, fvalue reflect.Value) error + +func validateField(f reflect.StructField, fvalue reflect.Value, funcs ...validatorFunc) error { + for _, fn := range funcs { + if err := fn(f, fvalue); err != nil { + return err + } + } + return nil +} + +// Validates that a field has a valid value provided for required fields. +func validateFieldRequired(f reflect.StructField, fvalue reflect.Value) error { + if f.Tag.Get("required") == "" { + return nil + } + + switch fvalue.Kind() { + case reflect.Ptr, reflect.Slice, reflect.Map: + if fvalue.IsNil() { + return fmt.Errorf("missing required parameter") + } + default: + if !fvalue.IsValid() { + return fmt.Errorf("missing required parameter") + } + } + return nil +} + +// Validates that if a value is provided for a field, that value must be at +// least a minimum length. +func validateFieldMin(f reflect.StructField, fvalue reflect.Value) error { + minStr := f.Tag.Get("min") + if minStr == "" { + return nil + } + min, _ := strconv.ParseInt(minStr, 10, 64) + + kind := fvalue.Kind() + if kind == reflect.Ptr { + if fvalue.IsNil() { + return nil + } + fvalue = fvalue.Elem() + } + + switch fvalue.Kind() { + case reflect.String: + if int64(fvalue.Len()) < min { + return fmt.Errorf("field too short, minimum length %d", min) + } + case reflect.Slice, reflect.Map: + if fvalue.IsNil() { + return nil + } + if int64(fvalue.Len()) < min { + return fmt.Errorf("field too short, minimum length %d", min) + } + + // TODO min can also apply to number minimum value. + + } + return nil +} 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 00000000..115b4073 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go @@ -0,0 +1,87 @@ +package credentials + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" +) + +var ( + // ErrNoValidProvidersFoundInChain Is returned when there are no valid + // providers in the ChainProvider. + // + // @readonly + ErrNoValidProvidersFoundInChain = awserr.New("NoCredentialProviders", "no valid providers in chain", 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 +} + +// 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) { + for _, p := range c.Providers { + if creds, err := p.Retrieve(); err == nil { + c.curr = p + return creds, nil + } + } + c.curr = nil + + // TODO better error reporting. maybe report error for each failed retrieve? + + return Value{}, ErrNoValidProvidersFoundInChain +} + +// 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 00000000..5dd71f02 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/credentials.go @@ -0,0 +1,220 @@ +// 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 +} + +// 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/ec2rolecreds/ec2_role_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go new file mode 100644 index 00000000..04c8921a --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go @@ -0,0 +1,174 @@ +package ec2rolecreds + +import ( + "bufio" + "encoding/json" + "fmt" + "path" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/ec2metadata" +) + +// A EC2RoleProvider retrieves credentials from the EC2 service, and keeps track if +// those credentials are expired. +// +// Example how to configure the EC2RoleProvider with custom http Client, Endpoint +// or ExpiryWindow +// +// p := &ec2rolecreds.EC2RoleProvider{ +// // Pass in a custom timeout to be used when requesting +// // IAM EC2 Role credentials. +// Client: ec2metadata.New(sess, aws.Config{ +// HTTPClient: &http.Client{Timeout: 10 * time.Second}, +// }), +// +// // Do not use early expiry of credentials. If a non zero value is +// // specified the credentials will be expired early +// ExpiryWindow: 0, +// } +type EC2RoleProvider struct { + credentials.Expiry + + // Required EC2Metadata client to use when connecting to EC2 metadata service. + Client *ec2metadata.EC2Metadata + + // ExpiryWindow will allow the credentials to trigger refreshing prior to + // the credentials actually expiring. This is beneficial so race conditions + // with expiring credentials do not cause request to fail unexpectedly + // due to ExpiredTokenException exceptions. + // + // So a ExpiryWindow of 10s would cause calls to IsExpired() to return true + // 10 seconds before the credentials are actually expired. + // + // If ExpiryWindow is 0 or less it will be ignored. + ExpiryWindow time.Duration +} + +// NewCredentials returns a pointer to a new Credentials object wrapping +// the EC2RoleProvider. Takes a ConfigProvider to create a EC2Metadata client. +// The ConfigProvider is satisfied by the session.Session type. +func NewCredentials(c client.ConfigProvider, options ...func(*EC2RoleProvider)) *credentials.Credentials { + p := &EC2RoleProvider{ + Client: ec2metadata.New(c), + } + + for _, option := range options { + option(p) + } + + return credentials.NewCredentials(p) +} + +// NewCredentialsWithClient returns a pointer to a new Credentials object wrapping +// the EC2RoleProvider. Takes a EC2Metadata client to use when connecting to EC2 +// metadata service. +func NewCredentialsWithClient(client *ec2metadata.EC2Metadata, options ...func(*EC2RoleProvider)) *credentials.Credentials { + p := &EC2RoleProvider{ + Client: client, + } + + for _, option := range options { + option(p) + } + + return credentials.NewCredentials(p) +} + +// Retrieve retrieves credentials from the EC2 service. +// Error will be returned if the request fails, or unable to extract +// the desired credentials. +func (m *EC2RoleProvider) Retrieve() (credentials.Value, error) { + credsList, err := requestCredList(m.Client) + if err != nil { + return credentials.Value{}, err + } + + if len(credsList) == 0 { + return credentials.Value{}, awserr.New("EmptyEC2RoleList", "empty EC2 Role list", nil) + } + credsName := credsList[0] + + roleCreds, err := requestCred(m.Client, credsName) + if err != nil { + return credentials.Value{}, err + } + + m.SetExpiration(roleCreds.Expiration, m.ExpiryWindow) + + return credentials.Value{ + AccessKeyID: roleCreds.AccessKeyID, + SecretAccessKey: roleCreds.SecretAccessKey, + SessionToken: roleCreds.Token, + }, nil +} + +// A ec2RoleCredRespBody provides the shape for unmarshalling credential +// request responses. +type ec2RoleCredRespBody struct { + // Success State + Expiration time.Time + AccessKeyID string + SecretAccessKey string + Token string + + // Error state + Code string + Message string +} + +const iamSecurityCredsPath = "/iam/security-credentials" + +// requestCredList requests a list of credentials from the EC2 service. +// If there are no credentials, or there is an error making or receiving the request +func requestCredList(client *ec2metadata.EC2Metadata) ([]string, error) { + resp, err := client.GetMetadata(iamSecurityCredsPath) + if err != nil { + return nil, awserr.New("EC2RoleRequestError", "failed to list EC2 Roles", err) + } + + credsList := []string{} + s := bufio.NewScanner(strings.NewReader(resp)) + for s.Scan() { + credsList = append(credsList, s.Text()) + } + + if err := s.Err(); err != nil { + return nil, awserr.New("SerializationError", "failed to read list of EC2 Roles", err) + } + + return credsList, nil +} + +// requestCred requests the credentials for a specific credentials from the EC2 service. +// +// If the credentials cannot be found, or there is an error reading the response +// and error will be returned. +func requestCred(client *ec2metadata.EC2Metadata, credsName string) (ec2RoleCredRespBody, error) { + resp, err := client.GetMetadata(path.Join(iamSecurityCredsPath, credsName)) + if err != nil { + return ec2RoleCredRespBody{}, + awserr.New("EC2RoleRequestError", + fmt.Sprintf("failed to get %s EC2 Role credentials", credsName), + err) + } + + respCreds := ec2RoleCredRespBody{} + if err := json.NewDecoder(strings.NewReader(resp)).Decode(&respCreds); err != nil { + return ec2RoleCredRespBody{}, + awserr.New("SerializationError", + fmt.Sprintf("failed to decode %s EC2 Role credentials", credsName), + err) + } + + if respCreds.Code != "Success" { + // If an error code was returned something failed requesting the role. + return ec2RoleCredRespBody{}, awserr.New(respCreds.Code, respCreds.Message, nil) + } + + return respCreds, nil +} 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 00000000..043e861d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go @@ -0,0 +1,73 @@ +package credentials + +import ( + "os" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +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{}, ErrAccessKeyIDNotFound + } + + if secret == "" { + return Value{}, ErrSecretAccessKeyNotFound + } + + e.retrieved = true + return Value{ + AccessKeyID: id, + SecretAccessKey: secret, + SessionToken: os.Getenv("AWS_SESSION_TOKEN"), + }, 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/example.ini b/vendor/github.com/aws/aws-sdk-go/aws/credentials/example.ini new file mode 100644 index 00000000..7fc91d9d --- /dev/null +++ b/vendor/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/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 00000000..09bd00a9 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go @@ -0,0 +1,147 @@ +package credentials + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/go-ini/ini" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +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{}, err + } + + creds, err := loadProfile(filename, p.profile()) + if err != nil { + return Value{}, 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{}, awserr.New("SharedCredsLoad", "failed to load shared credentials file", err) + } + iniProfile, err := config.GetSection(profile) + if err != nil { + return Value{}, awserr.New("SharedCredsLoad", "failed to get profile", err) + } + + id, err := iniProfile.GetKey("aws_access_key_id") + if err != nil { + return Value{}, 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{}, 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(), + }, 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 00000000..530a9ac2 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go @@ -0,0 +1,44 @@ +package credentials + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" +) + +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{}, ErrStaticCredentialsEmpty + } + + 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/defaults/defaults.go b/vendor/github.com/aws/aws-sdk-go/aws/defaults/defaults.go new file mode 100644 index 00000000..50f831c8 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/defaults/defaults.go @@ -0,0 +1,95 @@ +// Package defaults is a collection of helpers to retrieve the SDK's default +// configuration and handlers. +// +// Generally this package shouldn't be used directly, but session.Session +// instead. This package is useful when you need to reset the defaults +// of a session or service client to the SDK defaults before setting +// additional parameters. +package defaults + +import ( + "net/http" + "os" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/corehandlers" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" + "github.com/aws/aws-sdk-go/aws/ec2metadata" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/endpoints" +) + +// A Defaults provides a collection of default values for SDK clients. +type Defaults struct { + Config *aws.Config + Handlers request.Handlers +} + +// Get returns the SDK's default values with Config and handlers pre-configured. +func Get() Defaults { + cfg := Config() + handlers := Handlers() + cfg.Credentials = CredChain(cfg, handlers) + + return Defaults{ + Config: cfg, + Handlers: handlers, + } +} + +// Config returns the default configuration without credentials. +// To retrieve a config with credentials also included use +// `defaults.Get().Config` instead. +// +// Generally you shouldn't need to use this method directly, but +// is available if you need to reset the configuration of an +// existing service client or session. +func Config() *aws.Config { + return aws.NewConfig(). + WithCredentials(credentials.AnonymousCredentials). + WithRegion(os.Getenv("AWS_REGION")). + WithHTTPClient(http.DefaultClient). + WithMaxRetries(aws.UseServiceDefaultRetries). + WithLogger(aws.NewDefaultLogger()). + WithLogLevel(aws.LogOff). + WithSleepDelay(time.Sleep) +} + +// Handlers returns the default request handlers. +// +// Generally you shouldn't need to use this method directly, but +// is available if you need to reset the request handlers of an +// existing service client or session. +func Handlers() request.Handlers { + var handlers request.Handlers + + handlers.Validate.PushBackNamed(corehandlers.ValidateEndpointHandler) + handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler) + handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler) + handlers.Send.PushBackNamed(corehandlers.SendHandler) + handlers.AfterRetry.PushBackNamed(corehandlers.AfterRetryHandler) + handlers.ValidateResponse.PushBackNamed(corehandlers.ValidateResponseHandler) + + return handlers +} + +// CredChain returns the default credential chain. +// +// Generally you shouldn't need to use this method directly, but +// is available if you need to reset the credentials of an +// existing service client or session's Config. +func CredChain(cfg *aws.Config, handlers request.Handlers) *credentials.Credentials { + endpoint, signingRegion := endpoints.EndpointForRegion(ec2metadata.ServiceName, *cfg.Region, true) + + return credentials.NewChainCredentials( + []credentials.Provider{ + &credentials.EnvProvider{}, + &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, + &ec2rolecreds.EC2RoleProvider{ + Client: ec2metadata.NewClient(*cfg, handlers, endpoint, signingRegion), + ExpiryWindow: 5 * time.Minute, + }, + }) +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go new file mode 100644 index 00000000..e5137ca1 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go @@ -0,0 +1,43 @@ +package ec2metadata + +import ( + "path" + + "github.com/aws/aws-sdk-go/aws/request" +) + +// GetMetadata uses the path provided to request +func (c *EC2Metadata) GetMetadata(p string) (string, error) { + op := &request.Operation{ + Name: "GetMetadata", + HTTPMethod: "GET", + HTTPPath: path.Join("/", "meta-data", p), + } + + output := &metadataOutput{} + req := c.NewRequest(op, nil, output) + + return output.Content, req.Send() +} + +// Region returns the region the instance is running in. +func (c *EC2Metadata) Region() (string, error) { + resp, err := c.GetMetadata("placement/availability-zone") + if err != nil { + return "", err + } + + // returns region without the suffix. Eg: us-west-2a becomes us-west-2 + return resp[:len(resp)-1], nil +} + +// Available returns if the application has access to the EC2 Metadata service. +// Can be used to determine if application is running within an EC2 Instance and +// the metadata service is available. +func (c *EC2Metadata) Available() bool { + if _, err := c.GetMetadata("instance-id"); err != nil { + return false + } + + return true +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go new file mode 100644 index 00000000..f0dc331e --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go @@ -0,0 +1,116 @@ +// Package ec2metadata provides the client for making API calls to the +// EC2 Metadata service. +package ec2metadata + +import ( + "io/ioutil" + "net" + "net/http" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/request" +) + +// ServiceName is the name of the service. +const ServiceName = "ec2metadata" + +// A EC2Metadata is an EC2 Metadata service Client. +type EC2Metadata struct { + *client.Client +} + +// New creates a new instance of the EC2Metadata client with a session. +// This client is safe to use across multiple goroutines. +// +// Example: +// // Create a EC2Metadata client from just a session. +// svc := ec2metadata.New(mySession) +// +// // Create a EC2Metadata client with additional configuration +// svc := ec2metadata.New(mySession, aws.NewConfig().WithLogLevel(aws.LogDebugHTTPBody)) +func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2Metadata { + c := p.ClientConfig(ServiceName, cfgs...) + return NewClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion) +} + +// NewClient returns a new EC2Metadata client. Should be used to create +// a client when not using a session. Generally using just New with a session +// is preferred. +func NewClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string, opts ...func(*client.Client)) *EC2Metadata { + // If the default http client is provided, replace it with a custom + // client using default timeouts. + if cfg.HTTPClient == http.DefaultClient { + cfg.HTTPClient = &http.Client{ + Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, + Dial: (&net.Dialer{ + // use a shorter timeout than default because the metadata + // service is local if it is running, and to fail faster + // if not running on an ec2 instance. + Timeout: 5 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + TLSHandshakeTimeout: 10 * time.Second, + }, + } + } + + svc := &EC2Metadata{ + Client: client.New( + cfg, + metadata.ClientInfo{ + ServiceName: ServiceName, + Endpoint: endpoint, + APIVersion: "latest", + }, + handlers, + ), + } + + svc.Handlers.Unmarshal.PushBack(unmarshalHandler) + svc.Handlers.UnmarshalError.PushBack(unmarshalError) + svc.Handlers.Validate.Clear() + svc.Handlers.Validate.PushBack(validateEndpointHandler) + + // Add additional options to the service config + for _, option := range opts { + option(svc.Client) + } + + return svc +} + +type metadataOutput struct { + Content string +} + +func unmarshalHandler(r *request.Request) { + defer r.HTTPResponse.Body.Close() + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "unable to unmarshal EC2 metadata respose", err) + } + + data := r.Data.(*metadataOutput) + data.Content = string(b) +} + +func unmarshalError(r *request.Request) { + defer r.HTTPResponse.Body.Close() + _, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "unable to unmarshal EC2 metadata error respose", err) + } + + // TODO extract the error... +} + +func validateEndpointHandler(r *request.Request) { + if r.ClientInfo.Endpoint == "" { + r.Error = aws.ErrMissingEndpoint + } +} 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 00000000..57663616 --- /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 00000000..f5369487 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/logger.go @@ -0,0 +1,98 @@ +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{}) +} + +// 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 00000000..3e90a797 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go @@ -0,0 +1,140 @@ +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 HandlerList manages zero or more handlers in a list. +type HandlerList struct { + list []NamedHandler +} + +// 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 { + var n HandlerList + 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 _, f := range l.list { + f.Fn(r) + } +} + +// 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 00000000..3735d7fa --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go @@ -0,0 +1,279 @@ +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 + + 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.Sign() + if r.Error != nil { + return "", r.Error + } + return r.HTTPRequest.URL.String(), 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) + 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)) + } + + // 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 00000000..2939ec47 --- /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 00000000..ab6fff5a --- /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/session/session.go b/vendor/github.com/aws/aws-sdk-go/aws/session/session.go new file mode 100644 index 00000000..6a0f371a --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/session/session.go @@ -0,0 +1,111 @@ +// Package session provides a way to create service clients with shared configuration +// and handlers. +// +// Generally this package should be used instead of the `defaults` package. +// +// A session should be used to share configurations and request handlers between multiple +// service clients. When service clients need specific configuration aws.Config can be +// used to provide additional configuration directly to the service client. +package session + +import ( + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/corehandlers" + "github.com/aws/aws-sdk-go/aws/defaults" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/endpoints" +) + +// A Session provides a central location to create service clients from and +// store configurations and request handlers for those services. +// +// Sessions are safe to create service clients concurrently, but it is not safe +// to mutate the session concurrently. +type Session struct { + Config *aws.Config + Handlers request.Handlers +} + +// New creates a new instance of the handlers merging in the provided Configs +// on top of the SDK's default configurations. Once the session is created it +// can be mutated to modify Configs or Handlers. The session is safe to be read +// concurrently, but it should not be written to concurrently. +// +// Example: +// // Create a session with the default config and request handlers. +// sess := session.New() +// +// // Create a session with a custom region +// sess := session.New(&aws.Config{Region: aws.String("us-east-1")}) +// +// // Create a session, and add additional handlers for all service +// // clients created with the session to inherit. Adds logging handler. +// sess := session.New() +// sess.Handlers.Send.PushFront(func(r *request.Request) { +// // Log every request made and its payload +// logger.Println("Request: %s/%s, Payload: %s", r.ClientInfo.ServiceName, r.Operation, r.Params) +// }) +// +// // Create a S3 client instance from a session +// sess := session.New() +// svc := s3.New(sess) +func New(cfgs ...*aws.Config) *Session { + def := defaults.Get() + s := &Session{ + Config: def.Config, + Handlers: def.Handlers, + } + s.Config.MergeIn(cfgs...) + + initHandlers(s) + + return s +} + +func initHandlers(s *Session) { + // Add the Validate parameter handler if it is not disabled. + s.Handlers.Validate.Remove(corehandlers.ValidateParametersHandler) + if !aws.BoolValue(s.Config.DisableParamValidation) { + s.Handlers.Validate.PushBackNamed(corehandlers.ValidateParametersHandler) + } +} + +// Copy creates and returns a copy of the current session, coping the config +// and handlers. If any additional configs are provided they will be merged +// on top of the session's copied config. +// +// Example: +// // Create a copy of the current session, configured for the us-west-2 region. +// sess.Copy(&aws.Config{Region: aws.String("us-west-2"}) +func (s *Session) Copy(cfgs ...*aws.Config) *Session { + newSession := &Session{ + Config: s.Config.Copy(cfgs...), + Handlers: s.Handlers.Copy(), + } + + initHandlers(newSession) + + return newSession +} + +// ClientConfig satisfies the client.ConfigProvider interface and is used to +// configure the service client instances. Passing the Session to the service +// client's constructor (New) will use this method to configure the client. +// +// Example: +// sess := session.New() +// s3.New(sess) +func (s *Session) ClientConfig(serviceName string, cfgs ...*aws.Config) client.Config { + s = s.Copy(cfgs...) + endpoint, signingRegion := endpoints.NormalizeEndpoint( + aws.StringValue(s.Config.Endpoint), serviceName, + aws.StringValue(s.Config.Region), aws.BoolValue(s.Config.DisableSSL)) + + return client.Config{ + Config: s.Config, + Handlers: s.Handlers, + Endpoint: endpoint, + SigningRegion: signingRegion, + } +} 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 00000000..0f067c57 --- /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 00000000..5c36d832 --- /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.0.8" diff --git a/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.go b/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.go new file mode 100644 index 00000000..2b279e65 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.go @@ -0,0 +1,65 @@ +// Package endpoints validates regional endpoints for services. +package endpoints + +//go:generate go run ../model/cli/gen-endpoints/main.go endpoints.json endpoints_map.go +//go:generate gofmt -s -w endpoints_map.go + +import ( + "fmt" + "regexp" + "strings" +) + +// NormalizeEndpoint takes and endpoint and service API information to return a +// normalized endpoint and signing region. If the endpoint is not an empty string +// the service name and region will be used to look up the service's API endpoint. +// If the endpoint is provided the scheme will be added if it is not present. +func NormalizeEndpoint(endpoint, serviceName, region string, disableSSL bool) (normEndpoint, signingRegion string) { + if endpoint == "" { + return EndpointForRegion(serviceName, region, disableSSL) + } + + return AddScheme(endpoint, disableSSL), "" +} + +// EndpointForRegion returns an endpoint and its signing region for a service and region. +// if the service and region pair are not found endpoint and signingRegion will be empty. +func EndpointForRegion(svcName, region string, disableSSL bool) (endpoint, signingRegion string) { + derivedKeys := []string{ + region + "/" + svcName, + region + "/*", + "*/" + svcName, + "*/*", + } + + for _, key := range derivedKeys { + if val, ok := endpointsMap.Endpoints[key]; ok { + ep := val.Endpoint + ep = strings.Replace(ep, "{region}", region, -1) + ep = strings.Replace(ep, "{service}", svcName, -1) + + endpoint = ep + signingRegion = val.SigningRegion + break + } + } + + return AddScheme(endpoint, disableSSL), signingRegion +} + +// Regular expression to determine if the endpoint string is prefixed with a scheme. +var schemeRE = regexp.MustCompile("^([^:]+)://") + +// AddScheme adds the HTTP or HTTPS schemes to a endpoint URL if there is no +// scheme. If disableSSL is true HTTP will be added instead of the default HTTPS. +func AddScheme(endpoint string, disableSSL bool) string { + if endpoint != "" && !schemeRE.MatchString(endpoint) { + scheme := "https" + if disableSSL { + scheme = "http" + } + endpoint = fmt.Sprintf("%s://%s", scheme, endpoint) + } + + return endpoint +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.json b/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.json new file mode 100644 index 00000000..7819eedc --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "endpoints": { + "*/*": { + "endpoint": "{service}.{region}.amazonaws.com" + }, + "cn-north-1/*": { + "endpoint": "{service}.{region}.amazonaws.com.cn", + "signatureVersion": "v4" + }, + "us-gov-west-1/iam": { + "endpoint": "iam.us-gov.amazonaws.com" + }, + "us-gov-west-1/sts": { + "endpoint": "sts.us-gov-west-1.amazonaws.com" + }, + "us-gov-west-1/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "*/cloudfront": { + "endpoint": "cloudfront.amazonaws.com", + "signingRegion": "us-east-1" + }, + "*/cloudsearchdomain": { + "endpoint": "", + "signingRegion": "us-east-1" + }, + "*/data.iot": { + "endpoint": "", + "signingRegion": "us-east-1" + }, + "*/ec2metadata": { + "endpoint": "http://169.254.169.254/latest", + "signingRegion": "us-east-1" + }, + "*/iam": { + "endpoint": "iam.amazonaws.com", + "signingRegion": "us-east-1" + }, + "*/importexport": { + "endpoint": "importexport.amazonaws.com", + "signingRegion": "us-east-1" + }, + "*/route53": { + "endpoint": "route53.amazonaws.com", + "signingRegion": "us-east-1" + }, + "*/sts": { + "endpoint": "sts.amazonaws.com", + "signingRegion": "us-east-1" + }, + "*/waf": { + "endpoint": "waf.amazonaws.com", + "signingRegion": "us-east-1" + }, + "us-east-1/sdb": { + "endpoint": "sdb.amazonaws.com", + "signingRegion": "us-east-1" + }, + "us-east-1/s3": { + "endpoint": "s3.amazonaws.com" + }, + "us-west-1/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "us-west-2/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "eu-west-1/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "ap-southeast-1/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "ap-southeast-2/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "ap-northeast-1/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "ap-northeast-2/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "sa-east-1/s3": { + "endpoint": "s3-{region}.amazonaws.com" + }, + "eu-central-1/s3": { + "endpoint": "{service}.{region}.amazonaws.com", + "signatureVersion": "v4" + } + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints_map.go b/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints_map.go new file mode 100644 index 00000000..9b2e1b69 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/endpoints/endpoints_map.go @@ -0,0 +1,104 @@ +package endpoints + +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + +type endpointStruct struct { + Version int + Endpoints map[string]endpointEntry +} + +type endpointEntry struct { + Endpoint string + SigningRegion string +} + +var endpointsMap = endpointStruct{ + Version: 2, + Endpoints: map[string]endpointEntry{ + "*/*": { + Endpoint: "{service}.{region}.amazonaws.com", + }, + "*/cloudfront": { + Endpoint: "cloudfront.amazonaws.com", + SigningRegion: "us-east-1", + }, + "*/cloudsearchdomain": { + Endpoint: "", + SigningRegion: "us-east-1", + }, + "*/data.iot": { + Endpoint: "", + SigningRegion: "us-east-1", + }, + "*/ec2metadata": { + Endpoint: "http://169.254.169.254/latest", + SigningRegion: "us-east-1", + }, + "*/iam": { + Endpoint: "iam.amazonaws.com", + SigningRegion: "us-east-1", + }, + "*/importexport": { + Endpoint: "importexport.amazonaws.com", + SigningRegion: "us-east-1", + }, + "*/route53": { + Endpoint: "route53.amazonaws.com", + SigningRegion: "us-east-1", + }, + "*/sts": { + Endpoint: "sts.amazonaws.com", + SigningRegion: "us-east-1", + }, + "*/waf": { + Endpoint: "waf.amazonaws.com", + SigningRegion: "us-east-1", + }, + "ap-northeast-1/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "ap-northeast-2/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "ap-southeast-1/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "ap-southeast-2/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "cn-north-1/*": { + Endpoint: "{service}.{region}.amazonaws.com.cn", + }, + "eu-central-1/s3": { + Endpoint: "{service}.{region}.amazonaws.com", + }, + "eu-west-1/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "sa-east-1/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "us-east-1/s3": { + Endpoint: "s3.amazonaws.com", + }, + "us-east-1/sdb": { + Endpoint: "sdb.amazonaws.com", + SigningRegion: "us-east-1", + }, + "us-gov-west-1/iam": { + Endpoint: "iam.us-gov.amazonaws.com", + }, + "us-gov-west-1/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "us-gov-west-1/sts": { + Endpoint: "sts.us-gov-west-1.amazonaws.com", + }, + "us-west-1/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + "us-west-2/s3": { + Endpoint: "s3-{region}.amazonaws.com", + }, + }, +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go new file mode 100644 index 00000000..2d78c35c --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go @@ -0,0 +1,33 @@ +// Package query provides serialisation of AWS query requests, and responses. +package query + +//go:generate go run ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/query.json build_test.go + +import ( + "net/url" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol/query/queryutil" +) + +// Build builds a request for an AWS Query service. +func Build(r *request.Request) { + body := url.Values{ + "Action": {r.Operation.Name}, + "Version": {r.ClientInfo.APIVersion}, + } + if err := queryutil.Parse(body, r.Params, false); err != nil { + r.Error = awserr.New("SerializationError", "failed encoding Query request", err) + return + } + + if r.ExpireTime == 0 { + r.HTTPRequest.Method = "POST" + r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") + r.SetBufferBody([]byte(body.Encode())) + } else { // This is a pre-signed request + r.HTTPRequest.Method = "GET" + r.HTTPRequest.URL.RawQuery = body.Encode() + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go new file mode 100644 index 00000000..4afa4cf0 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go @@ -0,0 +1,223 @@ +package queryutil + +import ( + "encoding/base64" + "fmt" + "net/url" + "reflect" + "sort" + "strconv" + "strings" + "time" +) + +// Parse parses an object i and fills a url.Values object. The isEC2 flag +// indicates if this is the EC2 Query sub-protocol. +func Parse(body url.Values, i interface{}, isEC2 bool) error { + q := queryParser{isEC2: isEC2} + return q.parseValue(body, reflect.ValueOf(i), "", "") +} + +func elemOf(value reflect.Value) reflect.Value { + for value.Kind() == reflect.Ptr { + value = value.Elem() + } + return value +} + +type queryParser struct { + isEC2 bool +} + +func (q *queryParser) parseValue(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error { + value = elemOf(value) + + // no need to handle zero values + if !value.IsValid() { + return nil + } + + t := tag.Get("type") + if t == "" { + switch value.Kind() { + case reflect.Struct: + t = "structure" + case reflect.Slice: + t = "list" + case reflect.Map: + t = "map" + } + } + + switch t { + case "structure": + return q.parseStruct(v, value, prefix) + case "list": + return q.parseList(v, value, prefix, tag) + case "map": + return q.parseMap(v, value, prefix, tag) + default: + return q.parseScalar(v, value, prefix, tag) + } +} + +func (q *queryParser) parseStruct(v url.Values, value reflect.Value, prefix string) error { + if !value.IsValid() { + return nil + } + + t := value.Type() + for i := 0; i < value.NumField(); i++ { + if c := t.Field(i).Name[0:1]; strings.ToLower(c) == c { + continue // ignore unexported fields + } + + elemValue := elemOf(value.Field(i)) + field := t.Field(i) + var name string + + if q.isEC2 { + name = field.Tag.Get("queryName") + } + if name == "" { + if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" { + name = field.Tag.Get("locationNameList") + } else if locName := field.Tag.Get("locationName"); locName != "" { + name = locName + } + if name != "" && q.isEC2 { + name = strings.ToUpper(name[0:1]) + name[1:] + } + } + if name == "" { + name = field.Name + } + + if prefix != "" { + name = prefix + "." + name + } + + if err := q.parseValue(v, elemValue, name, field.Tag); err != nil { + return err + } + } + return nil +} + +func (q *queryParser) parseList(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error { + // If it's empty, generate an empty value + if !value.IsNil() && value.Len() == 0 { + v.Set(prefix, "") + return nil + } + + // check for unflattened list member + if !q.isEC2 && tag.Get("flattened") == "" { + prefix += ".member" + } + + for i := 0; i < value.Len(); i++ { + slicePrefix := prefix + if slicePrefix == "" { + slicePrefix = strconv.Itoa(i + 1) + } else { + slicePrefix = slicePrefix + "." + strconv.Itoa(i+1) + } + if err := q.parseValue(v, value.Index(i), slicePrefix, ""); err != nil { + return err + } + } + return nil +} + +func (q *queryParser) parseMap(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error { + // If it's empty, generate an empty value + if !value.IsNil() && value.Len() == 0 { + v.Set(prefix, "") + return nil + } + + // check for unflattened list member + if !q.isEC2 && tag.Get("flattened") == "" { + prefix += ".entry" + } + + // sort keys for improved serialization consistency. + // this is not strictly necessary for protocol support. + mapKeyValues := value.MapKeys() + mapKeys := map[string]reflect.Value{} + mapKeyNames := make([]string, len(mapKeyValues)) + for i, mapKey := range mapKeyValues { + name := mapKey.String() + mapKeys[name] = mapKey + mapKeyNames[i] = name + } + sort.Strings(mapKeyNames) + + for i, mapKeyName := range mapKeyNames { + mapKey := mapKeys[mapKeyName] + mapValue := value.MapIndex(mapKey) + + kname := tag.Get("locationNameKey") + if kname == "" { + kname = "key" + } + vname := tag.Get("locationNameValue") + if vname == "" { + vname = "value" + } + + // serialize key + var keyName string + if prefix == "" { + keyName = strconv.Itoa(i+1) + "." + kname + } else { + keyName = prefix + "." + strconv.Itoa(i+1) + "." + kname + } + + if err := q.parseValue(v, mapKey, keyName, ""); err != nil { + return err + } + + // serialize value + var valueName string + if prefix == "" { + valueName = strconv.Itoa(i+1) + "." + vname + } else { + valueName = prefix + "." + strconv.Itoa(i+1) + "." + vname + } + + if err := q.parseValue(v, mapValue, valueName, ""); err != nil { + return err + } + } + + return nil +} + +func (q *queryParser) parseScalar(v url.Values, r reflect.Value, name string, tag reflect.StructTag) error { + switch value := r.Interface().(type) { + case string: + v.Set(name, value) + case []byte: + if !r.IsNil() { + v.Set(name, base64.StdEncoding.EncodeToString(value)) + } + case bool: + v.Set(name, strconv.FormatBool(value)) + case int64: + v.Set(name, strconv.FormatInt(value, 10)) + case int: + v.Set(name, strconv.Itoa(value)) + case float64: + v.Set(name, strconv.FormatFloat(value, 'f', -1, 64)) + case float32: + v.Set(name, strconv.FormatFloat(float64(value), 'f', -1, 32)) + case time.Time: + const ISO8601UTC = "2006-01-02T15:04:05Z" + v.Set(name, value.UTC().Format(ISO8601UTC)) + default: + return fmt.Errorf("unsupported value for param %s: %v (%s)", name, r.Interface(), r.Type().Name()) + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go new file mode 100644 index 00000000..f961029e --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go @@ -0,0 +1,29 @@ +package query + +//go:generate go run ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/query.json unmarshal_test.go + +import ( + "encoding/xml" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" +) + +// Unmarshal unmarshals a response for an AWS Query service. +func Unmarshal(r *request.Request) { + defer r.HTTPResponse.Body.Close() + if r.DataFilled() { + decoder := xml.NewDecoder(r.HTTPResponse.Body) + err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result") + if err != nil { + r.Error = awserr.New("SerializationError", "failed decoding Query response", err) + return + } + } +} + +// UnmarshalMeta unmarshals header response values for an AWS Query service. +func UnmarshalMeta(r *request.Request) { + r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.go new file mode 100644 index 00000000..08609d92 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.go @@ -0,0 +1,33 @@ +package query + +import ( + "encoding/xml" + "io" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +type xmlErrorResponse struct { + XMLName xml.Name `xml:"ErrorResponse"` + Code string `xml:"Error>Code"` + Message string `xml:"Error>Message"` + RequestID string `xml:"RequestId"` +} + +// UnmarshalError unmarshals an error response for an AWS Query service. +func UnmarshalError(r *request.Request) { + defer r.HTTPResponse.Body.Close() + + resp := &xmlErrorResponse{} + err := xml.NewDecoder(r.HTTPResponse.Body).Decode(resp) + if err != nil && err != io.EOF { + r.Error = awserr.New("SerializationError", "failed to decode query XML error response", err) + } else { + r.Error = awserr.NewRequestFailure( + awserr.New(resp.Code, resp.Message, nil), + r.HTTPResponse.StatusCode, + resp.RequestID, + ) + } +} 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 00000000..ed3c2e03 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go @@ -0,0 +1,254 @@ +// 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 == '~' + } +} + +// 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 00000000..4366de2e --- /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 00000000..27f47b02 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go @@ -0,0 +1,183 @@ +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" +) + +// 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.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/protocol/restxml/restxml.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/restxml.go new file mode 100644 index 00000000..a6bc0c74 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/restxml.go @@ -0,0 +1,57 @@ +// Package restxml provides RESTful XML serialisation of AWS +// requests and responses. +package restxml + +//go:generate go run ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/rest-xml.json build_test.go +//go:generate go run ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/rest-xml.json unmarshal_test.go + +import ( + "bytes" + "encoding/xml" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol/query" + "github.com/aws/aws-sdk-go/private/protocol/rest" + "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" +) + +// Build builds a request payload for the REST XML protocol. +func Build(r *request.Request) { + rest.Build(r) + + if t := rest.PayloadType(r.Params); t == "structure" || t == "" { + var buf bytes.Buffer + err := xmlutil.BuildXML(r.Params, xml.NewEncoder(&buf)) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to encode rest XML request", err) + return + } + r.SetBufferBody(buf.Bytes()) + } +} + +// Unmarshal unmarshals a payload response for the REST XML protocol. +func Unmarshal(r *request.Request) { + if t := rest.PayloadType(r.Data); t == "structure" || t == "" { + defer r.HTTPResponse.Body.Close() + decoder := xml.NewDecoder(r.HTTPResponse.Body) + err := xmlutil.UnmarshalXML(r.Data, decoder, "") + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST XML response", err) + return + } + } else { + rest.Unmarshal(r) + } +} + +// UnmarshalMeta unmarshals response headers for the REST XML protocol. +func UnmarshalMeta(r *request.Request) { + rest.UnmarshalMeta(r) +} + +// UnmarshalError unmarshals a response error for the REST XML protocol. +func UnmarshalError(r *request.Request) { + query.UnmarshalError(r) +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go new file mode 100644 index 00000000..0d76dffb --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go @@ -0,0 +1,287 @@ +// Package xmlutil provides XML serialisation of AWS requests and responses. +package xmlutil + +import ( + "encoding/base64" + "encoding/xml" + "fmt" + "reflect" + "sort" + "strconv" + "strings" + "time" +) + +// BuildXML will serialize params into an xml.Encoder. +// Error will be returned if the serialization of any of the params or nested values fails. +func BuildXML(params interface{}, e *xml.Encoder) error { + b := xmlBuilder{encoder: e, namespaces: map[string]string{}} + root := NewXMLElement(xml.Name{}) + if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil { + return err + } + for _, c := range root.Children { + for _, v := range c { + return StructToXML(e, v, false) + } + } + return nil +} + +// Returns the reflection element of a value, if it is a pointer. +func elemOf(value reflect.Value) reflect.Value { + for value.Kind() == reflect.Ptr { + value = value.Elem() + } + return value +} + +// A xmlBuilder serializes values from Go code to XML +type xmlBuilder struct { + encoder *xml.Encoder + namespaces map[string]string +} + +// buildValue generic XMLNode builder for any type. Will build value for their specific type +// struct, list, map, scalar. +// +// Also takes a "type" tag value to set what type a value should be converted to XMLNode as. If +// type is not provided reflect will be used to determine the value's type. +func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag reflect.StructTag) error { + value = elemOf(value) + if !value.IsValid() { // no need to handle zero values + return nil + } else if tag.Get("location") != "" { // don't handle non-body location values + return nil + } + + t := tag.Get("type") + if t == "" { + switch value.Kind() { + case reflect.Struct: + t = "structure" + case reflect.Slice: + t = "list" + case reflect.Map: + t = "map" + } + } + + switch t { + case "structure": + if field, ok := value.Type().FieldByName("_"); ok { + tag = tag + reflect.StructTag(" ") + field.Tag + } + return b.buildStruct(value, current, tag) + case "list": + return b.buildList(value, current, tag) + case "map": + return b.buildMap(value, current, tag) + default: + return b.buildScalar(value, current, tag) + } +} + +// buildStruct adds a struct and its fields to the current XMLNode. All fields any any nested +// types are converted to XMLNodes also. +func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag reflect.StructTag) error { + if !value.IsValid() { + return nil + } + + fieldAdded := false + + // unwrap payloads + if payload := tag.Get("payload"); payload != "" { + field, _ := value.Type().FieldByName(payload) + tag = field.Tag + value = elemOf(value.FieldByName(payload)) + + if !value.IsValid() { + return nil + } + } + + child := NewXMLElement(xml.Name{Local: tag.Get("locationName")}) + + // there is an xmlNamespace associated with this struct + if prefix, uri := tag.Get("xmlPrefix"), tag.Get("xmlURI"); uri != "" { + ns := xml.Attr{ + Name: xml.Name{Local: "xmlns"}, + Value: uri, + } + if prefix != "" { + b.namespaces[prefix] = uri // register the namespace + ns.Name.Local = "xmlns:" + prefix + } + + child.Attr = append(child.Attr, ns) + } + + t := value.Type() + for i := 0; i < value.NumField(); i++ { + if c := t.Field(i).Name[0:1]; strings.ToLower(c) == c { + continue // ignore unexported fields + } + + member := elemOf(value.Field(i)) + field := t.Field(i) + mTag := field.Tag + + if mTag.Get("location") != "" { // skip non-body members + continue + } + + memberName := mTag.Get("locationName") + if memberName == "" { + memberName = field.Name + mTag = reflect.StructTag(string(mTag) + ` locationName:"` + memberName + `"`) + } + if err := b.buildValue(member, child, mTag); err != nil { + return err + } + + fieldAdded = true + } + + if fieldAdded { // only append this child if we have one ore more valid members + current.AddChild(child) + } + + return nil +} + +// buildList adds the value's list items to the current XMLNode as children nodes. All +// nested values in the list are converted to XMLNodes also. +func (b *xmlBuilder) buildList(value reflect.Value, current *XMLNode, tag reflect.StructTag) error { + if value.IsNil() { // don't build omitted lists + return nil + } + + // check for unflattened list member + flattened := tag.Get("flattened") != "" + + xname := xml.Name{Local: tag.Get("locationName")} + if flattened { + for i := 0; i < value.Len(); i++ { + child := NewXMLElement(xname) + current.AddChild(child) + if err := b.buildValue(value.Index(i), child, ""); err != nil { + return err + } + } + } else { + list := NewXMLElement(xname) + current.AddChild(list) + + for i := 0; i < value.Len(); i++ { + iname := tag.Get("locationNameList") + if iname == "" { + iname = "member" + } + + child := NewXMLElement(xml.Name{Local: iname}) + list.AddChild(child) + if err := b.buildValue(value.Index(i), child, ""); err != nil { + return err + } + } + } + + return nil +} + +// buildMap adds the value's key/value pairs to the current XMLNode as children nodes. All +// nested values in the map are converted to XMLNodes also. +// +// Error will be returned if it is unable to build the map's values into XMLNodes +func (b *xmlBuilder) buildMap(value reflect.Value, current *XMLNode, tag reflect.StructTag) error { + if value.IsNil() { // don't build omitted maps + return nil + } + + maproot := NewXMLElement(xml.Name{Local: tag.Get("locationName")}) + current.AddChild(maproot) + current = maproot + + kname, vname := "key", "value" + if n := tag.Get("locationNameKey"); n != "" { + kname = n + } + if n := tag.Get("locationNameValue"); n != "" { + vname = n + } + + // sorting is not required for compliance, but it makes testing easier + keys := make([]string, value.Len()) + for i, k := range value.MapKeys() { + keys[i] = k.String() + } + sort.Strings(keys) + + for _, k := range keys { + v := value.MapIndex(reflect.ValueOf(k)) + + mapcur := current + if tag.Get("flattened") == "" { // add "entry" tag to non-flat maps + child := NewXMLElement(xml.Name{Local: "entry"}) + mapcur.AddChild(child) + mapcur = child + } + + kchild := NewXMLElement(xml.Name{Local: kname}) + kchild.Text = k + vchild := NewXMLElement(xml.Name{Local: vname}) + mapcur.AddChild(kchild) + mapcur.AddChild(vchild) + + if err := b.buildValue(v, vchild, ""); err != nil { + return err + } + } + + return nil +} + +// buildScalar will convert the value into a string and append it as a attribute or child +// of the current XMLNode. +// +// The value will be added as an attribute if tag contains a "xmlAttribute" attribute value. +// +// Error will be returned if the value type is unsupported. +func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag reflect.StructTag) error { + var str string + switch converted := value.Interface().(type) { + case string: + str = converted + case []byte: + if !value.IsNil() { + str = base64.StdEncoding.EncodeToString(converted) + } + case bool: + str = strconv.FormatBool(converted) + case int64: + str = strconv.FormatInt(converted, 10) + case int: + str = strconv.Itoa(converted) + case float64: + str = strconv.FormatFloat(converted, 'f', -1, 64) + case float32: + str = strconv.FormatFloat(float64(converted), 'f', -1, 32) + case time.Time: + const ISO8601UTC = "2006-01-02T15:04:05Z" + str = converted.UTC().Format(ISO8601UTC) + default: + return fmt.Errorf("unsupported value for param %s: %v (%s)", + tag.Get("locationName"), value.Interface(), value.Type().Name()) + } + + xname := xml.Name{Local: tag.Get("locationName")} + if tag.Get("xmlAttribute") != "" { // put into current node's attribute list + attr := xml.Attr{Name: xname, Value: str} + current.Attr = append(current.Attr, attr) + } else { // regular text node + current.AddChild(&XMLNode{Name: xname, Text: str}) + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go new file mode 100644 index 00000000..49f291a8 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go @@ -0,0 +1,260 @@ +package xmlutil + +import ( + "encoding/base64" + "encoding/xml" + "fmt" + "io" + "reflect" + "strconv" + "strings" + "time" +) + +// UnmarshalXML deserializes an xml.Decoder into the container v. V +// needs to match the shape of the XML expected to be decoded. +// If the shape doesn't match unmarshaling will fail. +func UnmarshalXML(v interface{}, d *xml.Decoder, wrapper string) error { + n, _ := XMLToStruct(d, nil) + if n.Children != nil { + for _, root := range n.Children { + for _, c := range root { + if wrappedChild, ok := c.Children[wrapper]; ok { + c = wrappedChild[0] // pull out wrapped element + } + + err := parse(reflect.ValueOf(v), c, "") + if err != nil { + if err == io.EOF { + return nil + } + return err + } + } + } + return nil + } + return nil +} + +// parse deserializes any value from the XMLNode. The type tag is used to infer the type, or reflect +// will be used to determine the type from r. +func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { + rtype := r.Type() + if rtype.Kind() == reflect.Ptr { + rtype = rtype.Elem() // check kind of actual element type + } + + t := tag.Get("type") + if t == "" { + switch rtype.Kind() { + case reflect.Struct: + t = "structure" + case reflect.Slice: + t = "list" + case reflect.Map: + t = "map" + } + } + + switch t { + case "structure": + if field, ok := rtype.FieldByName("_"); ok { + tag = field.Tag + } + return parseStruct(r, node, tag) + case "list": + return parseList(r, node, tag) + case "map": + return parseMap(r, node, tag) + default: + return parseScalar(r, node, tag) + } +} + +// parseStruct deserializes a structure and its fields from an XMLNode. Any nested +// types in the structure will also be deserialized. +func parseStruct(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { + t := r.Type() + if r.Kind() == reflect.Ptr { + if r.IsNil() { // create the structure if it's nil + s := reflect.New(r.Type().Elem()) + r.Set(s) + r = s + } + + r = r.Elem() + t = t.Elem() + } + + // unwrap any payloads + if payload := tag.Get("payload"); payload != "" { + field, _ := t.FieldByName(payload) + return parseStruct(r.FieldByName(payload), node, field.Tag) + } + + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + if c := field.Name[0:1]; strings.ToLower(c) == c { + continue // ignore unexported fields + } + + // figure out what this field is called + name := field.Name + if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" { + name = field.Tag.Get("locationNameList") + } else if locName := field.Tag.Get("locationName"); locName != "" { + name = locName + } + + // try to find the field by name in elements + elems := node.Children[name] + + if elems == nil { // try to find the field in attributes + for _, a := range node.Attr { + if name == a.Name.Local { + // turn this into a text node for de-serializing + elems = []*XMLNode{{Text: a.Value}} + } + } + } + + member := r.FieldByName(field.Name) + for _, elem := range elems { + err := parse(member, elem, field.Tag) + if err != nil { + return err + } + } + } + return nil +} + +// parseList deserializes a list of values from an XML node. Each list entry +// will also be deserialized. +func parseList(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { + t := r.Type() + + if tag.Get("flattened") == "" { // look at all item entries + mname := "member" + if name := tag.Get("locationNameList"); name != "" { + mname = name + } + + if Children, ok := node.Children[mname]; ok { + if r.IsNil() { + r.Set(reflect.MakeSlice(t, len(Children), len(Children))) + } + + for i, c := range Children { + err := parse(r.Index(i), c, "") + if err != nil { + return err + } + } + } + } else { // flattened list means this is a single element + if r.IsNil() { + r.Set(reflect.MakeSlice(t, 0, 0)) + } + + childR := reflect.Zero(t.Elem()) + r.Set(reflect.Append(r, childR)) + err := parse(r.Index(r.Len()-1), node, "") + if err != nil { + return err + } + } + + return nil +} + +// parseMap deserializes a map from an XMLNode. The direct children of the XMLNode +// will also be deserialized as map entries. +func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { + if r.IsNil() { + r.Set(reflect.MakeMap(r.Type())) + } + + if tag.Get("flattened") == "" { // look at all child entries + for _, entry := range node.Children["entry"] { + parseMapEntry(r, entry, tag) + } + } else { // this element is itself an entry + parseMapEntry(r, node, tag) + } + + return nil +} + +// parseMapEntry deserializes a map entry from a XML node. +func parseMapEntry(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { + kname, vname := "key", "value" + if n := tag.Get("locationNameKey"); n != "" { + kname = n + } + if n := tag.Get("locationNameValue"); n != "" { + vname = n + } + + keys, ok := node.Children[kname] + values := node.Children[vname] + if ok { + for i, key := range keys { + keyR := reflect.ValueOf(key.Text) + value := values[i] + valueR := reflect.New(r.Type().Elem()).Elem() + + parse(valueR, value, "") + r.SetMapIndex(keyR, valueR) + } + } + return nil +} + +// parseScaller deserializes an XMLNode value into a concrete type based on the +// interface type of r. +// +// Error is returned if the deserialization fails due to invalid type conversion, +// or unsupported interface type. +func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { + switch r.Interface().(type) { + case *string: + r.Set(reflect.ValueOf(&node.Text)) + return nil + case []byte: + b, err := base64.StdEncoding.DecodeString(node.Text) + if err != nil { + return err + } + r.Set(reflect.ValueOf(b)) + case *bool: + v, err := strconv.ParseBool(node.Text) + if err != nil { + return err + } + r.Set(reflect.ValueOf(&v)) + case *int64: + v, err := strconv.ParseInt(node.Text, 10, 64) + if err != nil { + return err + } + r.Set(reflect.ValueOf(&v)) + case *float64: + v, err := strconv.ParseFloat(node.Text, 64) + if err != nil { + return err + } + r.Set(reflect.ValueOf(&v)) + case *time.Time: + const ISO8601UTC = "2006-01-02T15:04:05Z" + t, err := time.Parse(ISO8601UTC, node.Text) + if err != nil { + return err + } + r.Set(reflect.ValueOf(&t)) + default: + return fmt.Errorf("unsupported value: %v (%s)", r.Interface(), r.Type()) + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go new file mode 100644 index 00000000..72c198a9 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go @@ -0,0 +1,105 @@ +package xmlutil + +import ( + "encoding/xml" + "io" + "sort" +) + +// A XMLNode contains the values to be encoded or decoded. +type XMLNode struct { + Name xml.Name `json:",omitempty"` + Children map[string][]*XMLNode `json:",omitempty"` + Text string `json:",omitempty"` + Attr []xml.Attr `json:",omitempty"` +} + +// NewXMLElement returns a pointer to a new XMLNode initialized to default values. +func NewXMLElement(name xml.Name) *XMLNode { + return &XMLNode{ + Name: name, + Children: map[string][]*XMLNode{}, + Attr: []xml.Attr{}, + } +} + +// AddChild adds child to the XMLNode. +func (n *XMLNode) AddChild(child *XMLNode) { + if _, ok := n.Children[child.Name.Local]; !ok { + n.Children[child.Name.Local] = []*XMLNode{} + } + n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child) +} + +// XMLToStruct converts a xml.Decoder stream to XMLNode with nested values. +func XMLToStruct(d *xml.Decoder, s *xml.StartElement) (*XMLNode, error) { + out := &XMLNode{} + for { + tok, err := d.Token() + if tok == nil || err == io.EOF { + break + } + if err != nil { + return out, err + } + + switch typed := tok.(type) { + case xml.CharData: + out.Text = string(typed.Copy()) + case xml.StartElement: + el := typed.Copy() + out.Attr = el.Attr + if out.Children == nil { + out.Children = map[string][]*XMLNode{} + } + + name := typed.Name.Local + slice := out.Children[name] + if slice == nil { + slice = []*XMLNode{} + } + node, e := XMLToStruct(d, &el) + if e != nil { + return out, e + } + node.Name = typed.Name + slice = append(slice, node) + out.Children[name] = slice + case xml.EndElement: + if s != nil && s.Name.Local == typed.Name.Local { // matching end token + return out, nil + } + } + } + return out, nil +} + +// StructToXML writes an XMLNode to a xml.Encoder as tokens. +func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error { + e.EncodeToken(xml.StartElement{Name: node.Name, Attr: node.Attr}) + + if node.Text != "" { + e.EncodeToken(xml.CharData([]byte(node.Text))) + } else if sorted { + sortedNames := []string{} + for k := range node.Children { + sortedNames = append(sortedNames, k) + } + sort.Strings(sortedNames) + + for _, k := range sortedNames { + for _, v := range node.Children[k] { + StructToXML(e, v, sorted) + } + } + } else { + for _, c := range node.Children { + for _, v := range c { + StructToXML(e, v, sorted) + } + } + } + + e.EncodeToken(xml.EndElement{Name: node.Name}) + return e.Flush() +} 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 00000000..dc176f31 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/signer/v4/v4.go @@ -0,0 +1,365 @@ +// 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 = map[string]bool{ + "Authorization": true, + "Content-Type": true, + "Content-Length": true, + "User-Agent": true, +} + +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 +} + +// 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, + } + + req.Error = s.sign() +} + +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 + if v4.isPresign { + v4.buildQuery() // no depends + } + v4.buildCanonicalHeaders() // depends on cred string + 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 (v4 *signer) buildQuery() { + for k, h := range v4.Request.Header { + if strings.HasPrefix(http.CanonicalHeaderKey(k), "X-Amz-") { + continue // never hoist x-amz-* headers, they must be signed + } + if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { + continue // never hoist ignored headers + } + + v4.Request.Header.Del(k) + v4.Query.Del(k) + for _, v := range h { + v4.Query.Add(k, v) + } + } +} + +func (v4 *signer) buildCanonicalHeaders() { + var headers []string + headers = append(headers, "host") + for k := range v4.Request.Header { + if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { + continue // ignored header + } + headers = append(headers, strings.ToLower(k)) + } + 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/private/waiter/waiter.go b/vendor/github.com/aws/aws-sdk-go/private/waiter/waiter.go new file mode 100644 index 00000000..e5fb1366 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/waiter/waiter.go @@ -0,0 +1,136 @@ +package waiter + +import ( + "fmt" + "reflect" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" +) + +// A Config provides a collection of configuration values to setup a generated +// waiter code with. +type Config struct { + Name string + Delay int + MaxAttempts int + Operation string + Acceptors []WaitAcceptor +} + +// A WaitAcceptor provides the information needed to wait for an API operation +// to complete. +type WaitAcceptor struct { + Expected interface{} + Matcher string + State string + Argument string +} + +// A Waiter provides waiting for an operation to complete. +type Waiter struct { + Config + Client interface{} + Input interface{} +} + +// Wait waits for an operation to complete, expire max attempts, or fail. Error +// is returned if the operation fails. +func (w *Waiter) Wait() error { + client := reflect.ValueOf(w.Client) + in := reflect.ValueOf(w.Input) + method := client.MethodByName(w.Config.Operation + "Request") + + for i := 0; i < w.MaxAttempts; i++ { + res := method.Call([]reflect.Value{in}) + req := res[0].Interface().(*request.Request) + req.Handlers.Build.PushBack(request.MakeAddToUserAgentFreeFormHandler("Waiter")) + + err := req.Send() + for _, a := range w.Acceptors { + if err != nil && a.Matcher != "error" { + // Only matcher error is valid if there is a request error + continue + } + + result := false + var vals []interface{} + switch a.Matcher { + case "pathAll", "path": + // Require all matches to be equal for result to match + vals, _ = awsutil.ValuesAtPath(req.Data, a.Argument) + result = true + for _, val := range vals { + if !awsutil.DeepEqual(val, a.Expected) { + result = false + break + } + } + case "pathAny": + // Only a single match needs to equal for the result to match + vals, _ = awsutil.ValuesAtPath(req.Data, a.Argument) + for _, val := range vals { + if awsutil.DeepEqual(val, a.Expected) { + result = true + break + } + } + case "status": + s := a.Expected.(int) + result = s == req.HTTPResponse.StatusCode + case "error": + if aerr, ok := err.(awserr.Error); ok { + result = aerr.Code() == a.Expected.(string) + } + case "pathList": + // ignored matcher + default: + logf(client, "WARNING: Waiter for %s encountered unexpected matcher: %s", + w.Config.Operation, a.Matcher) + } + + if !result { + // If there was no matching result found there is nothing more to do + // for this response, retry the request. + continue + } + + switch a.State { + case "success": + // waiter completed + return nil + case "failure": + // Waiter failure state triggered + return awserr.New("ResourceNotReady", + fmt.Sprintf("failed waiting for successful resource state"), err) + case "retry": + // clear the error and retry the operation + err = nil + default: + logf(client, "WARNING: Waiter for %s encountered unexpected state: %s", + w.Config.Operation, a.State) + } + } + if err != nil { + return err + } + + time.Sleep(time.Second * time.Duration(w.Delay)) + } + + return awserr.New("ResourceNotReady", + fmt.Sprintf("exceeded %d wait attempts", w.MaxAttempts), nil) +} + +func logf(client reflect.Value, msg string, args ...interface{}) { + cfgVal := client.FieldByName("Config") + if !cfgVal.IsValid() { + return + } + if cfg, ok := cfgVal.Interface().(*aws.Config); ok && cfg.Logger != nil { + cfg.Logger.Log(fmt.Sprintf(msg, args...)) + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/api.go b/vendor/github.com/aws/aws-sdk-go/service/s3/api.go new file mode 100644 index 00000000..1d631220 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/api.go @@ -0,0 +1,6267 @@ +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + +// Package s3 provides a client for Amazon Simple Storage Service. +package s3 + +import ( + "io" + "time" + + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" +) + +const opAbortMultipartUpload = "AbortMultipartUpload" + +// AbortMultipartUploadRequest generates a request for the AbortMultipartUpload operation. +func (c *S3) AbortMultipartUploadRequest(input *AbortMultipartUploadInput) (req *request.Request, output *AbortMultipartUploadOutput) { + op := &request.Operation{ + Name: opAbortMultipartUpload, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &AbortMultipartUploadInput{} + } + + req = c.newRequest(op, input, output) + output = &AbortMultipartUploadOutput{} + req.Data = output + return +} + +// Aborts a multipart upload. +// +// To verify that all parts have been removed, so you don't get charged for +// the part storage, you should call the List Parts operation and ensure the +// parts list is empty. +func (c *S3) AbortMultipartUpload(input *AbortMultipartUploadInput) (*AbortMultipartUploadOutput, error) { + req, out := c.AbortMultipartUploadRequest(input) + err := req.Send() + return out, err +} + +const opCompleteMultipartUpload = "CompleteMultipartUpload" + +// CompleteMultipartUploadRequest generates a request for the CompleteMultipartUpload operation. +func (c *S3) CompleteMultipartUploadRequest(input *CompleteMultipartUploadInput) (req *request.Request, output *CompleteMultipartUploadOutput) { + op := &request.Operation{ + Name: opCompleteMultipartUpload, + HTTPMethod: "POST", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &CompleteMultipartUploadInput{} + } + + req = c.newRequest(op, input, output) + output = &CompleteMultipartUploadOutput{} + req.Data = output + return +} + +// Completes a multipart upload by assembling previously uploaded parts. +func (c *S3) CompleteMultipartUpload(input *CompleteMultipartUploadInput) (*CompleteMultipartUploadOutput, error) { + req, out := c.CompleteMultipartUploadRequest(input) + err := req.Send() + return out, err +} + +const opCopyObject = "CopyObject" + +// CopyObjectRequest generates a request for the CopyObject operation. +func (c *S3) CopyObjectRequest(input *CopyObjectInput) (req *request.Request, output *CopyObjectOutput) { + op := &request.Operation{ + Name: opCopyObject, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &CopyObjectInput{} + } + + req = c.newRequest(op, input, output) + output = &CopyObjectOutput{} + req.Data = output + return +} + +// Creates a copy of an object that is already stored in Amazon S3. +func (c *S3) CopyObject(input *CopyObjectInput) (*CopyObjectOutput, error) { + req, out := c.CopyObjectRequest(input) + err := req.Send() + return out, err +} + +const opCreateBucket = "CreateBucket" + +// CreateBucketRequest generates a request for the CreateBucket operation. +func (c *S3) CreateBucketRequest(input *CreateBucketInput) (req *request.Request, output *CreateBucketOutput) { + op := &request.Operation{ + Name: opCreateBucket, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}", + } + + if input == nil { + input = &CreateBucketInput{} + } + + req = c.newRequest(op, input, output) + output = &CreateBucketOutput{} + req.Data = output + return +} + +// Creates a new bucket. +func (c *S3) CreateBucket(input *CreateBucketInput) (*CreateBucketOutput, error) { + req, out := c.CreateBucketRequest(input) + err := req.Send() + return out, err +} + +const opCreateMultipartUpload = "CreateMultipartUpload" + +// CreateMultipartUploadRequest generates a request for the CreateMultipartUpload operation. +func (c *S3) CreateMultipartUploadRequest(input *CreateMultipartUploadInput) (req *request.Request, output *CreateMultipartUploadOutput) { + op := &request.Operation{ + Name: opCreateMultipartUpload, + HTTPMethod: "POST", + HTTPPath: "/{Bucket}/{Key+}?uploads", + } + + if input == nil { + input = &CreateMultipartUploadInput{} + } + + req = c.newRequest(op, input, output) + output = &CreateMultipartUploadOutput{} + req.Data = output + return +} + +// Initiates a multipart upload and returns an upload ID. +// +// Note: After you initiate multipart upload and upload one or more parts, you +// must either complete or abort multipart upload in order to stop getting charged +// for storage of the uploaded parts. Only after you either complete or abort +// multipart upload, Amazon S3 frees up the parts storage and stops charging +// you for the parts storage. +func (c *S3) CreateMultipartUpload(input *CreateMultipartUploadInput) (*CreateMultipartUploadOutput, error) { + req, out := c.CreateMultipartUploadRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucket = "DeleteBucket" + +// DeleteBucketRequest generates a request for the DeleteBucket operation. +func (c *S3) DeleteBucketRequest(input *DeleteBucketInput) (req *request.Request, output *DeleteBucketOutput) { + op := &request.Operation{ + Name: opDeleteBucket, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}", + } + + if input == nil { + input = &DeleteBucketInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketOutput{} + req.Data = output + return +} + +// Deletes the bucket. All objects (including all object versions and Delete +// Markers) in the bucket must be deleted before the bucket itself can be deleted. +func (c *S3) DeleteBucket(input *DeleteBucketInput) (*DeleteBucketOutput, error) { + req, out := c.DeleteBucketRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucketCors = "DeleteBucketCors" + +// DeleteBucketCorsRequest generates a request for the DeleteBucketCors operation. +func (c *S3) DeleteBucketCorsRequest(input *DeleteBucketCorsInput) (req *request.Request, output *DeleteBucketCorsOutput) { + op := &request.Operation{ + Name: opDeleteBucketCors, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}?cors", + } + + if input == nil { + input = &DeleteBucketCorsInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketCorsOutput{} + req.Data = output + return +} + +// Deletes the cors configuration information set for the bucket. +func (c *S3) DeleteBucketCors(input *DeleteBucketCorsInput) (*DeleteBucketCorsOutput, error) { + req, out := c.DeleteBucketCorsRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucketLifecycle = "DeleteBucketLifecycle" + +// DeleteBucketLifecycleRequest generates a request for the DeleteBucketLifecycle operation. +func (c *S3) DeleteBucketLifecycleRequest(input *DeleteBucketLifecycleInput) (req *request.Request, output *DeleteBucketLifecycleOutput) { + op := &request.Operation{ + Name: opDeleteBucketLifecycle, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}?lifecycle", + } + + if input == nil { + input = &DeleteBucketLifecycleInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketLifecycleOutput{} + req.Data = output + return +} + +// Deletes the lifecycle configuration from the bucket. +func (c *S3) DeleteBucketLifecycle(input *DeleteBucketLifecycleInput) (*DeleteBucketLifecycleOutput, error) { + req, out := c.DeleteBucketLifecycleRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucketPolicy = "DeleteBucketPolicy" + +// DeleteBucketPolicyRequest generates a request for the DeleteBucketPolicy operation. +func (c *S3) DeleteBucketPolicyRequest(input *DeleteBucketPolicyInput) (req *request.Request, output *DeleteBucketPolicyOutput) { + op := &request.Operation{ + Name: opDeleteBucketPolicy, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}?policy", + } + + if input == nil { + input = &DeleteBucketPolicyInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketPolicyOutput{} + req.Data = output + return +} + +// Deletes the policy from the bucket. +func (c *S3) DeleteBucketPolicy(input *DeleteBucketPolicyInput) (*DeleteBucketPolicyOutput, error) { + req, out := c.DeleteBucketPolicyRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucketReplication = "DeleteBucketReplication" + +// DeleteBucketReplicationRequest generates a request for the DeleteBucketReplication operation. +func (c *S3) DeleteBucketReplicationRequest(input *DeleteBucketReplicationInput) (req *request.Request, output *DeleteBucketReplicationOutput) { + op := &request.Operation{ + Name: opDeleteBucketReplication, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}?replication", + } + + if input == nil { + input = &DeleteBucketReplicationInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketReplicationOutput{} + req.Data = output + return +} + +func (c *S3) DeleteBucketReplication(input *DeleteBucketReplicationInput) (*DeleteBucketReplicationOutput, error) { + req, out := c.DeleteBucketReplicationRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucketTagging = "DeleteBucketTagging" + +// DeleteBucketTaggingRequest generates a request for the DeleteBucketTagging operation. +func (c *S3) DeleteBucketTaggingRequest(input *DeleteBucketTaggingInput) (req *request.Request, output *DeleteBucketTaggingOutput) { + op := &request.Operation{ + Name: opDeleteBucketTagging, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}?tagging", + } + + if input == nil { + input = &DeleteBucketTaggingInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketTaggingOutput{} + req.Data = output + return +} + +// Deletes the tags from the bucket. +func (c *S3) DeleteBucketTagging(input *DeleteBucketTaggingInput) (*DeleteBucketTaggingOutput, error) { + req, out := c.DeleteBucketTaggingRequest(input) + err := req.Send() + return out, err +} + +const opDeleteBucketWebsite = "DeleteBucketWebsite" + +// DeleteBucketWebsiteRequest generates a request for the DeleteBucketWebsite operation. +func (c *S3) DeleteBucketWebsiteRequest(input *DeleteBucketWebsiteInput) (req *request.Request, output *DeleteBucketWebsiteOutput) { + op := &request.Operation{ + Name: opDeleteBucketWebsite, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}?website", + } + + if input == nil { + input = &DeleteBucketWebsiteInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteBucketWebsiteOutput{} + req.Data = output + return +} + +// This operation removes the website configuration from the bucket. +func (c *S3) DeleteBucketWebsite(input *DeleteBucketWebsiteInput) (*DeleteBucketWebsiteOutput, error) { + req, out := c.DeleteBucketWebsiteRequest(input) + err := req.Send() + return out, err +} + +const opDeleteObject = "DeleteObject" + +// DeleteObjectRequest generates a request for the DeleteObject operation. +func (c *S3) DeleteObjectRequest(input *DeleteObjectInput) (req *request.Request, output *DeleteObjectOutput) { + op := &request.Operation{ + Name: opDeleteObject, + HTTPMethod: "DELETE", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &DeleteObjectInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteObjectOutput{} + req.Data = output + return +} + +// Removes the null version (if there is one) of an object and inserts a delete +// marker, which becomes the latest version of the object. If there isn't a +// null version, Amazon S3 does not remove any objects. +func (c *S3) DeleteObject(input *DeleteObjectInput) (*DeleteObjectOutput, error) { + req, out := c.DeleteObjectRequest(input) + err := req.Send() + return out, err +} + +const opDeleteObjects = "DeleteObjects" + +// DeleteObjectsRequest generates a request for the DeleteObjects operation. +func (c *S3) DeleteObjectsRequest(input *DeleteObjectsInput) (req *request.Request, output *DeleteObjectsOutput) { + op := &request.Operation{ + Name: opDeleteObjects, + HTTPMethod: "POST", + HTTPPath: "/{Bucket}?delete", + } + + if input == nil { + input = &DeleteObjectsInput{} + } + + req = c.newRequest(op, input, output) + output = &DeleteObjectsOutput{} + req.Data = output + return +} + +// This operation enables you to delete multiple objects from a bucket using +// a single HTTP request. You may specify up to 1000 keys. +func (c *S3) DeleteObjects(input *DeleteObjectsInput) (*DeleteObjectsOutput, error) { + req, out := c.DeleteObjectsRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketAcl = "GetBucketAcl" + +// GetBucketAclRequest generates a request for the GetBucketAcl operation. +func (c *S3) GetBucketAclRequest(input *GetBucketAclInput) (req *request.Request, output *GetBucketAclOutput) { + op := &request.Operation{ + Name: opGetBucketAcl, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?acl", + } + + if input == nil { + input = &GetBucketAclInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketAclOutput{} + req.Data = output + return +} + +// Gets the access control policy for the bucket. +func (c *S3) GetBucketAcl(input *GetBucketAclInput) (*GetBucketAclOutput, error) { + req, out := c.GetBucketAclRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketCors = "GetBucketCors" + +// GetBucketCorsRequest generates a request for the GetBucketCors operation. +func (c *S3) GetBucketCorsRequest(input *GetBucketCorsInput) (req *request.Request, output *GetBucketCorsOutput) { + op := &request.Operation{ + Name: opGetBucketCors, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?cors", + } + + if input == nil { + input = &GetBucketCorsInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketCorsOutput{} + req.Data = output + return +} + +// Returns the cors configuration for the bucket. +func (c *S3) GetBucketCors(input *GetBucketCorsInput) (*GetBucketCorsOutput, error) { + req, out := c.GetBucketCorsRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketLifecycle = "GetBucketLifecycle" + +// GetBucketLifecycleRequest generates a request for the GetBucketLifecycle operation. +func (c *S3) GetBucketLifecycleRequest(input *GetBucketLifecycleInput) (req *request.Request, output *GetBucketLifecycleOutput) { + op := &request.Operation{ + Name: opGetBucketLifecycle, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?lifecycle", + } + + if input == nil { + input = &GetBucketLifecycleInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketLifecycleOutput{} + req.Data = output + return +} + +// Deprecated, see the GetBucketLifecycleConfiguration operation. +func (c *S3) GetBucketLifecycle(input *GetBucketLifecycleInput) (*GetBucketLifecycleOutput, error) { + req, out := c.GetBucketLifecycleRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketLifecycleConfiguration = "GetBucketLifecycleConfiguration" + +// GetBucketLifecycleConfigurationRequest generates a request for the GetBucketLifecycleConfiguration operation. +func (c *S3) GetBucketLifecycleConfigurationRequest(input *GetBucketLifecycleConfigurationInput) (req *request.Request, output *GetBucketLifecycleConfigurationOutput) { + op := &request.Operation{ + Name: opGetBucketLifecycleConfiguration, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?lifecycle", + } + + if input == nil { + input = &GetBucketLifecycleConfigurationInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketLifecycleConfigurationOutput{} + req.Data = output + return +} + +// Returns the lifecycle configuration information set on the bucket. +func (c *S3) GetBucketLifecycleConfiguration(input *GetBucketLifecycleConfigurationInput) (*GetBucketLifecycleConfigurationOutput, error) { + req, out := c.GetBucketLifecycleConfigurationRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketLocation = "GetBucketLocation" + +// GetBucketLocationRequest generates a request for the GetBucketLocation operation. +func (c *S3) GetBucketLocationRequest(input *GetBucketLocationInput) (req *request.Request, output *GetBucketLocationOutput) { + op := &request.Operation{ + Name: opGetBucketLocation, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?location", + } + + if input == nil { + input = &GetBucketLocationInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketLocationOutput{} + req.Data = output + return +} + +// Returns the region the bucket resides in. +func (c *S3) GetBucketLocation(input *GetBucketLocationInput) (*GetBucketLocationOutput, error) { + req, out := c.GetBucketLocationRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketLogging = "GetBucketLogging" + +// GetBucketLoggingRequest generates a request for the GetBucketLogging operation. +func (c *S3) GetBucketLoggingRequest(input *GetBucketLoggingInput) (req *request.Request, output *GetBucketLoggingOutput) { + op := &request.Operation{ + Name: opGetBucketLogging, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?logging", + } + + if input == nil { + input = &GetBucketLoggingInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketLoggingOutput{} + req.Data = output + return +} + +// Returns the logging status of a bucket and the permissions users have to +// view and modify that status. To use GET, you must be the bucket owner. +func (c *S3) GetBucketLogging(input *GetBucketLoggingInput) (*GetBucketLoggingOutput, error) { + req, out := c.GetBucketLoggingRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketNotification = "GetBucketNotification" + +// GetBucketNotificationRequest generates a request for the GetBucketNotification operation. +func (c *S3) GetBucketNotificationRequest(input *GetBucketNotificationConfigurationRequest) (req *request.Request, output *NotificationConfigurationDeprecated) { + op := &request.Operation{ + Name: opGetBucketNotification, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?notification", + } + + if input == nil { + input = &GetBucketNotificationConfigurationRequest{} + } + + req = c.newRequest(op, input, output) + output = &NotificationConfigurationDeprecated{} + req.Data = output + return +} + +// Deprecated, see the GetBucketNotificationConfiguration operation. +func (c *S3) GetBucketNotification(input *GetBucketNotificationConfigurationRequest) (*NotificationConfigurationDeprecated, error) { + req, out := c.GetBucketNotificationRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketNotificationConfiguration = "GetBucketNotificationConfiguration" + +// GetBucketNotificationConfigurationRequest generates a request for the GetBucketNotificationConfiguration operation. +func (c *S3) GetBucketNotificationConfigurationRequest(input *GetBucketNotificationConfigurationRequest) (req *request.Request, output *NotificationConfiguration) { + op := &request.Operation{ + Name: opGetBucketNotificationConfiguration, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?notification", + } + + if input == nil { + input = &GetBucketNotificationConfigurationRequest{} + } + + req = c.newRequest(op, input, output) + output = &NotificationConfiguration{} + req.Data = output + return +} + +// Returns the notification configuration of a bucket. +func (c *S3) GetBucketNotificationConfiguration(input *GetBucketNotificationConfigurationRequest) (*NotificationConfiguration, error) { + req, out := c.GetBucketNotificationConfigurationRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketPolicy = "GetBucketPolicy" + +// GetBucketPolicyRequest generates a request for the GetBucketPolicy operation. +func (c *S3) GetBucketPolicyRequest(input *GetBucketPolicyInput) (req *request.Request, output *GetBucketPolicyOutput) { + op := &request.Operation{ + Name: opGetBucketPolicy, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?policy", + } + + if input == nil { + input = &GetBucketPolicyInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketPolicyOutput{} + req.Data = output + return +} + +// Returns the policy of a specified bucket. +func (c *S3) GetBucketPolicy(input *GetBucketPolicyInput) (*GetBucketPolicyOutput, error) { + req, out := c.GetBucketPolicyRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketReplication = "GetBucketReplication" + +// GetBucketReplicationRequest generates a request for the GetBucketReplication operation. +func (c *S3) GetBucketReplicationRequest(input *GetBucketReplicationInput) (req *request.Request, output *GetBucketReplicationOutput) { + op := &request.Operation{ + Name: opGetBucketReplication, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?replication", + } + + if input == nil { + input = &GetBucketReplicationInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketReplicationOutput{} + req.Data = output + return +} + +func (c *S3) GetBucketReplication(input *GetBucketReplicationInput) (*GetBucketReplicationOutput, error) { + req, out := c.GetBucketReplicationRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketRequestPayment = "GetBucketRequestPayment" + +// GetBucketRequestPaymentRequest generates a request for the GetBucketRequestPayment operation. +func (c *S3) GetBucketRequestPaymentRequest(input *GetBucketRequestPaymentInput) (req *request.Request, output *GetBucketRequestPaymentOutput) { + op := &request.Operation{ + Name: opGetBucketRequestPayment, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?requestPayment", + } + + if input == nil { + input = &GetBucketRequestPaymentInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketRequestPaymentOutput{} + req.Data = output + return +} + +// Returns the request payment configuration of a bucket. +func (c *S3) GetBucketRequestPayment(input *GetBucketRequestPaymentInput) (*GetBucketRequestPaymentOutput, error) { + req, out := c.GetBucketRequestPaymentRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketTagging = "GetBucketTagging" + +// GetBucketTaggingRequest generates a request for the GetBucketTagging operation. +func (c *S3) GetBucketTaggingRequest(input *GetBucketTaggingInput) (req *request.Request, output *GetBucketTaggingOutput) { + op := &request.Operation{ + Name: opGetBucketTagging, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?tagging", + } + + if input == nil { + input = &GetBucketTaggingInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketTaggingOutput{} + req.Data = output + return +} + +// Returns the tag set associated with the bucket. +func (c *S3) GetBucketTagging(input *GetBucketTaggingInput) (*GetBucketTaggingOutput, error) { + req, out := c.GetBucketTaggingRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketVersioning = "GetBucketVersioning" + +// GetBucketVersioningRequest generates a request for the GetBucketVersioning operation. +func (c *S3) GetBucketVersioningRequest(input *GetBucketVersioningInput) (req *request.Request, output *GetBucketVersioningOutput) { + op := &request.Operation{ + Name: opGetBucketVersioning, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?versioning", + } + + if input == nil { + input = &GetBucketVersioningInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketVersioningOutput{} + req.Data = output + return +} + +// Returns the versioning state of a bucket. +func (c *S3) GetBucketVersioning(input *GetBucketVersioningInput) (*GetBucketVersioningOutput, error) { + req, out := c.GetBucketVersioningRequest(input) + err := req.Send() + return out, err +} + +const opGetBucketWebsite = "GetBucketWebsite" + +// GetBucketWebsiteRequest generates a request for the GetBucketWebsite operation. +func (c *S3) GetBucketWebsiteRequest(input *GetBucketWebsiteInput) (req *request.Request, output *GetBucketWebsiteOutput) { + op := &request.Operation{ + Name: opGetBucketWebsite, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?website", + } + + if input == nil { + input = &GetBucketWebsiteInput{} + } + + req = c.newRequest(op, input, output) + output = &GetBucketWebsiteOutput{} + req.Data = output + return +} + +// Returns the website configuration for a bucket. +func (c *S3) GetBucketWebsite(input *GetBucketWebsiteInput) (*GetBucketWebsiteOutput, error) { + req, out := c.GetBucketWebsiteRequest(input) + err := req.Send() + return out, err +} + +const opGetObject = "GetObject" + +// GetObjectRequest generates a request for the GetObject operation. +func (c *S3) GetObjectRequest(input *GetObjectInput) (req *request.Request, output *GetObjectOutput) { + op := &request.Operation{ + Name: opGetObject, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &GetObjectInput{} + } + + req = c.newRequest(op, input, output) + output = &GetObjectOutput{} + req.Data = output + return +} + +// Retrieves objects from Amazon S3. +func (c *S3) GetObject(input *GetObjectInput) (*GetObjectOutput, error) { + req, out := c.GetObjectRequest(input) + err := req.Send() + return out, err +} + +const opGetObjectAcl = "GetObjectAcl" + +// GetObjectAclRequest generates a request for the GetObjectAcl operation. +func (c *S3) GetObjectAclRequest(input *GetObjectAclInput) (req *request.Request, output *GetObjectAclOutput) { + op := &request.Operation{ + Name: opGetObjectAcl, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}/{Key+}?acl", + } + + if input == nil { + input = &GetObjectAclInput{} + } + + req = c.newRequest(op, input, output) + output = &GetObjectAclOutput{} + req.Data = output + return +} + +// Returns the access control list (ACL) of an object. +func (c *S3) GetObjectAcl(input *GetObjectAclInput) (*GetObjectAclOutput, error) { + req, out := c.GetObjectAclRequest(input) + err := req.Send() + return out, err +} + +const opGetObjectTorrent = "GetObjectTorrent" + +// GetObjectTorrentRequest generates a request for the GetObjectTorrent operation. +func (c *S3) GetObjectTorrentRequest(input *GetObjectTorrentInput) (req *request.Request, output *GetObjectTorrentOutput) { + op := &request.Operation{ + Name: opGetObjectTorrent, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}/{Key+}?torrent", + } + + if input == nil { + input = &GetObjectTorrentInput{} + } + + req = c.newRequest(op, input, output) + output = &GetObjectTorrentOutput{} + req.Data = output + return +} + +// Return torrent files from a bucket. +func (c *S3) GetObjectTorrent(input *GetObjectTorrentInput) (*GetObjectTorrentOutput, error) { + req, out := c.GetObjectTorrentRequest(input) + err := req.Send() + return out, err +} + +const opHeadBucket = "HeadBucket" + +// HeadBucketRequest generates a request for the HeadBucket operation. +func (c *S3) HeadBucketRequest(input *HeadBucketInput) (req *request.Request, output *HeadBucketOutput) { + op := &request.Operation{ + Name: opHeadBucket, + HTTPMethod: "HEAD", + HTTPPath: "/{Bucket}", + } + + if input == nil { + input = &HeadBucketInput{} + } + + req = c.newRequest(op, input, output) + output = &HeadBucketOutput{} + req.Data = output + return +} + +// This operation is useful to determine if a bucket exists and you have permission +// to access it. +func (c *S3) HeadBucket(input *HeadBucketInput) (*HeadBucketOutput, error) { + req, out := c.HeadBucketRequest(input) + err := req.Send() + return out, err +} + +const opHeadObject = "HeadObject" + +// HeadObjectRequest generates a request for the HeadObject operation. +func (c *S3) HeadObjectRequest(input *HeadObjectInput) (req *request.Request, output *HeadObjectOutput) { + op := &request.Operation{ + Name: opHeadObject, + HTTPMethod: "HEAD", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &HeadObjectInput{} + } + + req = c.newRequest(op, input, output) + output = &HeadObjectOutput{} + req.Data = output + return +} + +// The HEAD operation retrieves metadata from an object without returning the +// object itself. This operation is useful if you're only interested in an object's +// metadata. To use HEAD, you must have READ access to the object. +func (c *S3) HeadObject(input *HeadObjectInput) (*HeadObjectOutput, error) { + req, out := c.HeadObjectRequest(input) + err := req.Send() + return out, err +} + +const opListBuckets = "ListBuckets" + +// ListBucketsRequest generates a request for the ListBuckets operation. +func (c *S3) ListBucketsRequest(input *ListBucketsInput) (req *request.Request, output *ListBucketsOutput) { + op := &request.Operation{ + Name: opListBuckets, + HTTPMethod: "GET", + HTTPPath: "/", + } + + if input == nil { + input = &ListBucketsInput{} + } + + req = c.newRequest(op, input, output) + output = &ListBucketsOutput{} + req.Data = output + return +} + +// Returns a list of all buckets owned by the authenticated sender of the request. +func (c *S3) ListBuckets(input *ListBucketsInput) (*ListBucketsOutput, error) { + req, out := c.ListBucketsRequest(input) + err := req.Send() + return out, err +} + +const opListMultipartUploads = "ListMultipartUploads" + +// ListMultipartUploadsRequest generates a request for the ListMultipartUploads operation. +func (c *S3) ListMultipartUploadsRequest(input *ListMultipartUploadsInput) (req *request.Request, output *ListMultipartUploadsOutput) { + op := &request.Operation{ + Name: opListMultipartUploads, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?uploads", + Paginator: &request.Paginator{ + InputTokens: []string{"KeyMarker", "UploadIdMarker"}, + OutputTokens: []string{"NextKeyMarker", "NextUploadIdMarker"}, + LimitToken: "MaxUploads", + TruncationToken: "IsTruncated", + }, + } + + if input == nil { + input = &ListMultipartUploadsInput{} + } + + req = c.newRequest(op, input, output) + output = &ListMultipartUploadsOutput{} + req.Data = output + return +} + +// This operation lists in-progress multipart uploads. +func (c *S3) ListMultipartUploads(input *ListMultipartUploadsInput) (*ListMultipartUploadsOutput, error) { + req, out := c.ListMultipartUploadsRequest(input) + err := req.Send() + return out, err +} + +func (c *S3) ListMultipartUploadsPages(input *ListMultipartUploadsInput, fn func(p *ListMultipartUploadsOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.ListMultipartUploadsRequest(input) + page.Handlers.Build.PushBack(request.MakeAddToUserAgentFreeFormHandler("Paginator")) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*ListMultipartUploadsOutput), lastPage) + }) +} + +const opListObjectVersions = "ListObjectVersions" + +// ListObjectVersionsRequest generates a request for the ListObjectVersions operation. +func (c *S3) ListObjectVersionsRequest(input *ListObjectVersionsInput) (req *request.Request, output *ListObjectVersionsOutput) { + op := &request.Operation{ + Name: opListObjectVersions, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}?versions", + Paginator: &request.Paginator{ + InputTokens: []string{"KeyMarker", "VersionIdMarker"}, + OutputTokens: []string{"NextKeyMarker", "NextVersionIdMarker"}, + LimitToken: "MaxKeys", + TruncationToken: "IsTruncated", + }, + } + + if input == nil { + input = &ListObjectVersionsInput{} + } + + req = c.newRequest(op, input, output) + output = &ListObjectVersionsOutput{} + req.Data = output + return +} + +// Returns metadata about all of the versions of objects in a bucket. +func (c *S3) ListObjectVersions(input *ListObjectVersionsInput) (*ListObjectVersionsOutput, error) { + req, out := c.ListObjectVersionsRequest(input) + err := req.Send() + return out, err +} + +func (c *S3) ListObjectVersionsPages(input *ListObjectVersionsInput, fn func(p *ListObjectVersionsOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.ListObjectVersionsRequest(input) + page.Handlers.Build.PushBack(request.MakeAddToUserAgentFreeFormHandler("Paginator")) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*ListObjectVersionsOutput), lastPage) + }) +} + +const opListObjects = "ListObjects" + +// ListObjectsRequest generates a request for the ListObjects operation. +func (c *S3) ListObjectsRequest(input *ListObjectsInput) (req *request.Request, output *ListObjectsOutput) { + op := &request.Operation{ + Name: opListObjects, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}", + Paginator: &request.Paginator{ + InputTokens: []string{"Marker"}, + OutputTokens: []string{"NextMarker || Contents[-1].Key"}, + LimitToken: "MaxKeys", + TruncationToken: "IsTruncated", + }, + } + + if input == nil { + input = &ListObjectsInput{} + } + + req = c.newRequest(op, input, output) + output = &ListObjectsOutput{} + req.Data = output + return +} + +// Returns some or all (up to 1000) of the objects in a bucket. You can use +// the request parameters as selection criteria to return a subset of the objects +// in a bucket. +func (c *S3) ListObjects(input *ListObjectsInput) (*ListObjectsOutput, error) { + req, out := c.ListObjectsRequest(input) + err := req.Send() + return out, err +} + +func (c *S3) ListObjectsPages(input *ListObjectsInput, fn func(p *ListObjectsOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.ListObjectsRequest(input) + page.Handlers.Build.PushBack(request.MakeAddToUserAgentFreeFormHandler("Paginator")) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*ListObjectsOutput), lastPage) + }) +} + +const opListParts = "ListParts" + +// ListPartsRequest generates a request for the ListParts operation. +func (c *S3) ListPartsRequest(input *ListPartsInput) (req *request.Request, output *ListPartsOutput) { + op := &request.Operation{ + Name: opListParts, + HTTPMethod: "GET", + HTTPPath: "/{Bucket}/{Key+}", + Paginator: &request.Paginator{ + InputTokens: []string{"PartNumberMarker"}, + OutputTokens: []string{"NextPartNumberMarker"}, + LimitToken: "MaxParts", + TruncationToken: "IsTruncated", + }, + } + + if input == nil { + input = &ListPartsInput{} + } + + req = c.newRequest(op, input, output) + output = &ListPartsOutput{} + req.Data = output + return +} + +// Lists the parts that have been uploaded for a specific multipart upload. +func (c *S3) ListParts(input *ListPartsInput) (*ListPartsOutput, error) { + req, out := c.ListPartsRequest(input) + err := req.Send() + return out, err +} + +func (c *S3) ListPartsPages(input *ListPartsInput, fn func(p *ListPartsOutput, lastPage bool) (shouldContinue bool)) error { + page, _ := c.ListPartsRequest(input) + page.Handlers.Build.PushBack(request.MakeAddToUserAgentFreeFormHandler("Paginator")) + return page.EachPage(func(p interface{}, lastPage bool) bool { + return fn(p.(*ListPartsOutput), lastPage) + }) +} + +const opPutBucketAcl = "PutBucketAcl" + +// PutBucketAclRequest generates a request for the PutBucketAcl operation. +func (c *S3) PutBucketAclRequest(input *PutBucketAclInput) (req *request.Request, output *PutBucketAclOutput) { + op := &request.Operation{ + Name: opPutBucketAcl, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?acl", + } + + if input == nil { + input = &PutBucketAclInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketAclOutput{} + req.Data = output + return +} + +// Sets the permissions on a bucket using access control lists (ACL). +func (c *S3) PutBucketAcl(input *PutBucketAclInput) (*PutBucketAclOutput, error) { + req, out := c.PutBucketAclRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketCors = "PutBucketCors" + +// PutBucketCorsRequest generates a request for the PutBucketCors operation. +func (c *S3) PutBucketCorsRequest(input *PutBucketCorsInput) (req *request.Request, output *PutBucketCorsOutput) { + op := &request.Operation{ + Name: opPutBucketCors, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?cors", + } + + if input == nil { + input = &PutBucketCorsInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketCorsOutput{} + req.Data = output + return +} + +// Sets the cors configuration for a bucket. +func (c *S3) PutBucketCors(input *PutBucketCorsInput) (*PutBucketCorsOutput, error) { + req, out := c.PutBucketCorsRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketLifecycle = "PutBucketLifecycle" + +// PutBucketLifecycleRequest generates a request for the PutBucketLifecycle operation. +func (c *S3) PutBucketLifecycleRequest(input *PutBucketLifecycleInput) (req *request.Request, output *PutBucketLifecycleOutput) { + op := &request.Operation{ + Name: opPutBucketLifecycle, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?lifecycle", + } + + if input == nil { + input = &PutBucketLifecycleInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketLifecycleOutput{} + req.Data = output + return +} + +// Deprecated, see the PutBucketLifecycleConfiguration operation. +func (c *S3) PutBucketLifecycle(input *PutBucketLifecycleInput) (*PutBucketLifecycleOutput, error) { + req, out := c.PutBucketLifecycleRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketLifecycleConfiguration = "PutBucketLifecycleConfiguration" + +// PutBucketLifecycleConfigurationRequest generates a request for the PutBucketLifecycleConfiguration operation. +func (c *S3) PutBucketLifecycleConfigurationRequest(input *PutBucketLifecycleConfigurationInput) (req *request.Request, output *PutBucketLifecycleConfigurationOutput) { + op := &request.Operation{ + Name: opPutBucketLifecycleConfiguration, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?lifecycle", + } + + if input == nil { + input = &PutBucketLifecycleConfigurationInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketLifecycleConfigurationOutput{} + req.Data = output + return +} + +// Sets lifecycle configuration for your bucket. If a lifecycle configuration +// exists, it replaces it. +func (c *S3) PutBucketLifecycleConfiguration(input *PutBucketLifecycleConfigurationInput) (*PutBucketLifecycleConfigurationOutput, error) { + req, out := c.PutBucketLifecycleConfigurationRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketLogging = "PutBucketLogging" + +// PutBucketLoggingRequest generates a request for the PutBucketLogging operation. +func (c *S3) PutBucketLoggingRequest(input *PutBucketLoggingInput) (req *request.Request, output *PutBucketLoggingOutput) { + op := &request.Operation{ + Name: opPutBucketLogging, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?logging", + } + + if input == nil { + input = &PutBucketLoggingInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketLoggingOutput{} + req.Data = output + return +} + +// Set the logging parameters for a bucket and to specify permissions for who +// can view and modify the logging parameters. To set the logging status of +// a bucket, you must be the bucket owner. +func (c *S3) PutBucketLogging(input *PutBucketLoggingInput) (*PutBucketLoggingOutput, error) { + req, out := c.PutBucketLoggingRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketNotification = "PutBucketNotification" + +// PutBucketNotificationRequest generates a request for the PutBucketNotification operation. +func (c *S3) PutBucketNotificationRequest(input *PutBucketNotificationInput) (req *request.Request, output *PutBucketNotificationOutput) { + op := &request.Operation{ + Name: opPutBucketNotification, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?notification", + } + + if input == nil { + input = &PutBucketNotificationInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketNotificationOutput{} + req.Data = output + return +} + +// Deprecated, see the PutBucketNotificationConfiguraiton operation. +func (c *S3) PutBucketNotification(input *PutBucketNotificationInput) (*PutBucketNotificationOutput, error) { + req, out := c.PutBucketNotificationRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketNotificationConfiguration = "PutBucketNotificationConfiguration" + +// PutBucketNotificationConfigurationRequest generates a request for the PutBucketNotificationConfiguration operation. +func (c *S3) PutBucketNotificationConfigurationRequest(input *PutBucketNotificationConfigurationInput) (req *request.Request, output *PutBucketNotificationConfigurationOutput) { + op := &request.Operation{ + Name: opPutBucketNotificationConfiguration, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?notification", + } + + if input == nil { + input = &PutBucketNotificationConfigurationInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketNotificationConfigurationOutput{} + req.Data = output + return +} + +// Enables notifications of specified events for a bucket. +func (c *S3) PutBucketNotificationConfiguration(input *PutBucketNotificationConfigurationInput) (*PutBucketNotificationConfigurationOutput, error) { + req, out := c.PutBucketNotificationConfigurationRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketPolicy = "PutBucketPolicy" + +// PutBucketPolicyRequest generates a request for the PutBucketPolicy operation. +func (c *S3) PutBucketPolicyRequest(input *PutBucketPolicyInput) (req *request.Request, output *PutBucketPolicyOutput) { + op := &request.Operation{ + Name: opPutBucketPolicy, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?policy", + } + + if input == nil { + input = &PutBucketPolicyInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketPolicyOutput{} + req.Data = output + return +} + +// Replaces a policy on a bucket. If the bucket already has a policy, the one +// in this request completely replaces it. +func (c *S3) PutBucketPolicy(input *PutBucketPolicyInput) (*PutBucketPolicyOutput, error) { + req, out := c.PutBucketPolicyRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketReplication = "PutBucketReplication" + +// PutBucketReplicationRequest generates a request for the PutBucketReplication operation. +func (c *S3) PutBucketReplicationRequest(input *PutBucketReplicationInput) (req *request.Request, output *PutBucketReplicationOutput) { + op := &request.Operation{ + Name: opPutBucketReplication, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?replication", + } + + if input == nil { + input = &PutBucketReplicationInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketReplicationOutput{} + req.Data = output + return +} + +// Creates a new replication configuration (or replaces an existing one, if +// present). +func (c *S3) PutBucketReplication(input *PutBucketReplicationInput) (*PutBucketReplicationOutput, error) { + req, out := c.PutBucketReplicationRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketRequestPayment = "PutBucketRequestPayment" + +// PutBucketRequestPaymentRequest generates a request for the PutBucketRequestPayment operation. +func (c *S3) PutBucketRequestPaymentRequest(input *PutBucketRequestPaymentInput) (req *request.Request, output *PutBucketRequestPaymentOutput) { + op := &request.Operation{ + Name: opPutBucketRequestPayment, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?requestPayment", + } + + if input == nil { + input = &PutBucketRequestPaymentInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketRequestPaymentOutput{} + req.Data = output + return +} + +// Sets the request payment configuration for a bucket. By default, the bucket +// owner pays for downloads from the bucket. This configuration parameter enables +// the bucket owner (only) to specify that the person requesting the download +// will be charged for the download. Documentation on requester pays buckets +// can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html +func (c *S3) PutBucketRequestPayment(input *PutBucketRequestPaymentInput) (*PutBucketRequestPaymentOutput, error) { + req, out := c.PutBucketRequestPaymentRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketTagging = "PutBucketTagging" + +// PutBucketTaggingRequest generates a request for the PutBucketTagging operation. +func (c *S3) PutBucketTaggingRequest(input *PutBucketTaggingInput) (req *request.Request, output *PutBucketTaggingOutput) { + op := &request.Operation{ + Name: opPutBucketTagging, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?tagging", + } + + if input == nil { + input = &PutBucketTaggingInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketTaggingOutput{} + req.Data = output + return +} + +// Sets the tags for a bucket. +func (c *S3) PutBucketTagging(input *PutBucketTaggingInput) (*PutBucketTaggingOutput, error) { + req, out := c.PutBucketTaggingRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketVersioning = "PutBucketVersioning" + +// PutBucketVersioningRequest generates a request for the PutBucketVersioning operation. +func (c *S3) PutBucketVersioningRequest(input *PutBucketVersioningInput) (req *request.Request, output *PutBucketVersioningOutput) { + op := &request.Operation{ + Name: opPutBucketVersioning, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?versioning", + } + + if input == nil { + input = &PutBucketVersioningInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketVersioningOutput{} + req.Data = output + return +} + +// Sets the versioning state of an existing bucket. To set the versioning state, +// you must be the bucket owner. +func (c *S3) PutBucketVersioning(input *PutBucketVersioningInput) (*PutBucketVersioningOutput, error) { + req, out := c.PutBucketVersioningRequest(input) + err := req.Send() + return out, err +} + +const opPutBucketWebsite = "PutBucketWebsite" + +// PutBucketWebsiteRequest generates a request for the PutBucketWebsite operation. +func (c *S3) PutBucketWebsiteRequest(input *PutBucketWebsiteInput) (req *request.Request, output *PutBucketWebsiteOutput) { + op := &request.Operation{ + Name: opPutBucketWebsite, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}?website", + } + + if input == nil { + input = &PutBucketWebsiteInput{} + } + + req = c.newRequest(op, input, output) + output = &PutBucketWebsiteOutput{} + req.Data = output + return +} + +// Set the website configuration for a bucket. +func (c *S3) PutBucketWebsite(input *PutBucketWebsiteInput) (*PutBucketWebsiteOutput, error) { + req, out := c.PutBucketWebsiteRequest(input) + err := req.Send() + return out, err +} + +const opPutObject = "PutObject" + +// PutObjectRequest generates a request for the PutObject operation. +func (c *S3) PutObjectRequest(input *PutObjectInput) (req *request.Request, output *PutObjectOutput) { + op := &request.Operation{ + Name: opPutObject, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &PutObjectInput{} + } + + req = c.newRequest(op, input, output) + output = &PutObjectOutput{} + req.Data = output + return +} + +// Adds an object to a bucket. +func (c *S3) PutObject(input *PutObjectInput) (*PutObjectOutput, error) { + req, out := c.PutObjectRequest(input) + err := req.Send() + return out, err +} + +const opPutObjectAcl = "PutObjectAcl" + +// PutObjectAclRequest generates a request for the PutObjectAcl operation. +func (c *S3) PutObjectAclRequest(input *PutObjectAclInput) (req *request.Request, output *PutObjectAclOutput) { + op := &request.Operation{ + Name: opPutObjectAcl, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}/{Key+}?acl", + } + + if input == nil { + input = &PutObjectAclInput{} + } + + req = c.newRequest(op, input, output) + output = &PutObjectAclOutput{} + req.Data = output + return +} + +// uses the acl subresource to set the access control list (ACL) permissions +// for an object that already exists in a bucket +func (c *S3) PutObjectAcl(input *PutObjectAclInput) (*PutObjectAclOutput, error) { + req, out := c.PutObjectAclRequest(input) + err := req.Send() + return out, err +} + +const opRestoreObject = "RestoreObject" + +// RestoreObjectRequest generates a request for the RestoreObject operation. +func (c *S3) RestoreObjectRequest(input *RestoreObjectInput) (req *request.Request, output *RestoreObjectOutput) { + op := &request.Operation{ + Name: opRestoreObject, + HTTPMethod: "POST", + HTTPPath: "/{Bucket}/{Key+}?restore", + } + + if input == nil { + input = &RestoreObjectInput{} + } + + req = c.newRequest(op, input, output) + output = &RestoreObjectOutput{} + req.Data = output + return +} + +// Restores an archived copy of an object back into Amazon S3 +func (c *S3) RestoreObject(input *RestoreObjectInput) (*RestoreObjectOutput, error) { + req, out := c.RestoreObjectRequest(input) + err := req.Send() + return out, err +} + +const opUploadPart = "UploadPart" + +// UploadPartRequest generates a request for the UploadPart operation. +func (c *S3) UploadPartRequest(input *UploadPartInput) (req *request.Request, output *UploadPartOutput) { + op := &request.Operation{ + Name: opUploadPart, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &UploadPartInput{} + } + + req = c.newRequest(op, input, output) + output = &UploadPartOutput{} + req.Data = output + return +} + +// Uploads a part in a multipart upload. +// +// Note: After you initiate multipart upload and upload one or more parts, you +// must either complete or abort multipart upload in order to stop getting charged +// for storage of the uploaded parts. Only after you either complete or abort +// multipart upload, Amazon S3 frees up the parts storage and stops charging +// you for the parts storage. +func (c *S3) UploadPart(input *UploadPartInput) (*UploadPartOutput, error) { + req, out := c.UploadPartRequest(input) + err := req.Send() + return out, err +} + +const opUploadPartCopy = "UploadPartCopy" + +// UploadPartCopyRequest generates a request for the UploadPartCopy operation. +func (c *S3) UploadPartCopyRequest(input *UploadPartCopyInput) (req *request.Request, output *UploadPartCopyOutput) { + op := &request.Operation{ + Name: opUploadPartCopy, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &UploadPartCopyInput{} + } + + req = c.newRequest(op, input, output) + output = &UploadPartCopyOutput{} + req.Data = output + return +} + +// Uploads a part by copying data from an existing object as data source. +func (c *S3) UploadPartCopy(input *UploadPartCopyInput) (*UploadPartCopyOutput, error) { + req, out := c.UploadPartCopyRequest(input) + err := req.Send() + return out, err +} + +type AbortMultipartUploadInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` +} + +// String returns the string representation +func (s AbortMultipartUploadInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AbortMultipartUploadInput) GoString() string { + return s.String() +} + +type AbortMultipartUploadOutput struct { + _ struct{} `type:"structure"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` +} + +// String returns the string representation +func (s AbortMultipartUploadOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AbortMultipartUploadOutput) GoString() string { + return s.String() +} + +type AccessControlPolicy struct { + _ struct{} `type:"structure"` + + // A list of grants. + Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"` + + Owner *Owner `type:"structure"` +} + +// String returns the string representation +func (s AccessControlPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AccessControlPolicy) GoString() string { + return s.String() +} + +type Bucket struct { + _ struct{} `type:"structure"` + + // Date the bucket was created. + CreationDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + // The name of the bucket. + Name *string `type:"string"` +} + +// String returns the string representation +func (s Bucket) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Bucket) GoString() string { + return s.String() +} + +type BucketLifecycleConfiguration struct { + _ struct{} `type:"structure"` + + Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s BucketLifecycleConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s BucketLifecycleConfiguration) GoString() string { + return s.String() +} + +type BucketLoggingStatus struct { + _ struct{} `type:"structure"` + + LoggingEnabled *LoggingEnabled `type:"structure"` +} + +// String returns the string representation +func (s BucketLoggingStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s BucketLoggingStatus) GoString() string { + return s.String() +} + +type CORSConfiguration struct { + _ struct{} `type:"structure"` + + CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s CORSConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CORSConfiguration) GoString() string { + return s.String() +} + +type CORSRule struct { + _ struct{} `type:"structure"` + + // Specifies which headers are allowed in a pre-flight OPTIONS request. + AllowedHeaders []*string `locationName:"AllowedHeader" type:"list" flattened:"true"` + + // Identifies HTTP methods that the domain/origin specified in the rule is allowed + // to execute. + AllowedMethods []*string `locationName:"AllowedMethod" type:"list" flattened:"true" required:"true"` + + // One or more origins you want customers to be able to access the bucket from. + AllowedOrigins []*string `locationName:"AllowedOrigin" type:"list" flattened:"true" required:"true"` + + // One or more headers in the response that you want customers to be able to + // access from their applications (for example, from a JavaScript XMLHttpRequest + // object). + ExposeHeaders []*string `locationName:"ExposeHeader" type:"list" flattened:"true"` + + // The time in seconds that your browser is to cache the preflight response + // for the specified resource. + MaxAgeSeconds *int64 `type:"integer"` +} + +// String returns the string representation +func (s CORSRule) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CORSRule) GoString() string { + return s.String() +} + +type CloudFunctionConfiguration struct { + _ struct{} `type:"structure"` + + CloudFunction *string `type:"string"` + + // Bucket event for which to send notifications. + Event *string `type:"string" enum:"Event"` + + Events []*string `locationName:"Event" type:"list" flattened:"true"` + + // Optional unique identifier for configurations in a notification configuration. + // If you don't provide one, Amazon S3 will assign an ID. + Id *string `type:"string"` + + InvocationRole *string `type:"string"` +} + +// String returns the string representation +func (s CloudFunctionConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CloudFunctionConfiguration) GoString() string { + return s.String() +} + +type CommonPrefix struct { + _ struct{} `type:"structure"` + + Prefix *string `type:"string"` +} + +// String returns the string representation +func (s CommonPrefix) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CommonPrefix) GoString() string { + return s.String() +} + +type CompleteMultipartUploadInput struct { + _ struct{} `type:"structure" payload:"MultipartUpload"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + MultipartUpload *CompletedMultipartUpload `locationName:"CompleteMultipartUpload" type:"structure"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` +} + +// String returns the string representation +func (s CompleteMultipartUploadInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CompleteMultipartUploadInput) GoString() string { + return s.String() +} + +type CompleteMultipartUploadOutput struct { + _ struct{} `type:"structure"` + + Bucket *string `type:"string"` + + // Entity tag of the object. + ETag *string `type:"string"` + + // If the object expiration is configured, this will contain the expiration + // date (expiry-date) and rule ID (rule-id). The value of rule-id is URL encoded. + Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"` + + Key *string `min:"1" type:"string"` + + Location *string `type:"string"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // Version of the object. + VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` +} + +// String returns the string representation +func (s CompleteMultipartUploadOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CompleteMultipartUploadOutput) GoString() string { + return s.String() +} + +type CompletedMultipartUpload struct { + _ struct{} `type:"structure"` + + Parts []*CompletedPart `locationName:"Part" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s CompletedMultipartUpload) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CompletedMultipartUpload) GoString() string { + return s.String() +} + +type CompletedPart struct { + _ struct{} `type:"structure"` + + // Entity tag returned when the part was uploaded. + ETag *string `type:"string"` + + // Part number that identifies the part. This is a positive integer between + // 1 and 10,000. + PartNumber *int64 `type:"integer"` +} + +// String returns the string representation +func (s CompletedPart) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CompletedPart) GoString() string { + return s.String() +} + +type Condition struct { + _ struct{} `type:"structure"` + + // The HTTP error code when the redirect is applied. In the event of an error, + // if the error code equals this value, then the specified redirect is applied. + // Required when parent element Condition is specified and sibling KeyPrefixEquals + // is not specified. If both are specified, then both must be true for the redirect + // to be applied. + HttpErrorCodeReturnedEquals *string `type:"string"` + + // The object key name prefix when the redirect is applied. For example, to + // redirect requests for ExamplePage.html, the key prefix will be ExamplePage.html. + // To redirect request for all pages with the prefix docs/, the key prefix will + // be /docs, which identifies all objects in the docs/ folder. Required when + // the parent element Condition is specified and sibling HttpErrorCodeReturnedEquals + // is not specified. If both conditions are specified, both must be true for + // the redirect to be applied. + KeyPrefixEquals *string `type:"string"` +} + +// String returns the string representation +func (s Condition) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Condition) GoString() string { + return s.String() +} + +type CopyObjectInput struct { + _ struct{} `type:"structure"` + + // The canned ACL to apply to the object. + ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Specifies caching behavior along the request/reply chain. + CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"` + + // Specifies presentational information for the object. + ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"` + + // Specifies what content encodings have been applied to the object and thus + // what decoding mechanisms must be applied to obtain the media-type referenced + // by the Content-Type header field. + ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"` + + // The language the content is in. + ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"` + + // A standard MIME type describing the format of the object data. + ContentType *string `location:"header" locationName:"Content-Type" type:"string"` + + // The name of the source bucket and key name of the source object, separated + // by a slash (/). Must be URL-encoded. + CopySource *string `location:"header" locationName:"x-amz-copy-source" type:"string" required:"true"` + + // Copies the object if its entity tag (ETag) matches the specified tag. + CopySourceIfMatch *string `location:"header" locationName:"x-amz-copy-source-if-match" type:"string"` + + // Copies the object if it has been modified since the specified time. + CopySourceIfModifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-modified-since" type:"timestamp" timestampFormat:"rfc822"` + + // Copies the object if its entity tag (ETag) is different than the specified + // ETag. + CopySourceIfNoneMatch *string `location:"header" locationName:"x-amz-copy-source-if-none-match" type:"string"` + + // Copies the object if it hasn't been modified since the specified time. + CopySourceIfUnmodifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-unmodified-since" type:"timestamp" timestampFormat:"rfc822"` + + // Specifies the algorithm to use when decrypting the source object (e.g., AES256). + CopySourceSSECustomerAlgorithm *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use to decrypt + // the source object. The encryption key provided in this header must be one + // that was used when the source object was created. + CopySourceSSECustomerKey *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + CopySourceSSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key-MD5" type:"string"` + + // The date and time at which the object is no longer cacheable. + Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"` + + // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object. + GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"` + + // Allows grantee to read the object data and its metadata. + GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"` + + // Allows grantee to read the object ACL. + GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"` + + // Allows grantee to write the ACL for the applicable object. + GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // A map of metadata to store with the object in S3. + Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"` + + // Specifies whether the metadata is copied from the source object or replaced + // with metadata provided in the request. + MetadataDirective *string `location:"header" locationName:"x-amz-metadata-directive" type:"string" enum:"MetadataDirective"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT + // requests for an object protected by AWS KMS will fail if not made via SSL + // or using SigV4. Documentation on configuring any of the officially supported + // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // The type of storage to use for the object. Defaults to 'STANDARD'. + StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string" enum:"StorageClass"` + + // If the bucket is configured as a website, redirects requests for this object + // to another object in the same bucket or to an external URL. Amazon S3 stores + // the value of this header in the object metadata. + WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` +} + +// String returns the string representation +func (s CopyObjectInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CopyObjectInput) GoString() string { + return s.String() +} + +type CopyObjectOutput struct { + _ struct{} `type:"structure" payload:"CopyObjectResult"` + + CopyObjectResult *CopyObjectResult `type:"structure"` + + CopySourceVersionId *string `location:"header" locationName:"x-amz-copy-source-version-id" type:"string"` + + // If the object expiration is configured, the response includes this header. + Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // Version ID of the newly created copy. + VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` +} + +// String returns the string representation +func (s CopyObjectOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CopyObjectOutput) GoString() string { + return s.String() +} + +type CopyObjectResult struct { + _ struct{} `type:"structure"` + + ETag *string `type:"string"` + + LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` +} + +// String returns the string representation +func (s CopyObjectResult) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CopyObjectResult) GoString() string { + return s.String() +} + +type CopyPartResult struct { + _ struct{} `type:"structure"` + + // Entity tag of the object. + ETag *string `type:"string"` + + // Date and time at which the object was uploaded. + LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` +} + +// String returns the string representation +func (s CopyPartResult) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CopyPartResult) GoString() string { + return s.String() +} + +type CreateBucketConfiguration struct { + _ struct{} `type:"structure"` + + // Specifies the region where the bucket will be created. If you don't specify + // a region, the bucket will be created in US Standard. + LocationConstraint *string `type:"string" enum:"BucketLocationConstraint"` +} + +// String returns the string representation +func (s CreateBucketConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateBucketConfiguration) GoString() string { + return s.String() +} + +type CreateBucketInput struct { + _ struct{} `type:"structure" payload:"CreateBucketConfiguration"` + + // The canned ACL to apply to the bucket. + ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"BucketCannedACL"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + CreateBucketConfiguration *CreateBucketConfiguration `locationName:"CreateBucketConfiguration" type:"structure"` + + // Allows grantee the read, write, read ACP, and write ACP permissions on the + // bucket. + GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"` + + // Allows grantee to list the objects in the bucket. + GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"` + + // Allows grantee to read the bucket ACL. + GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"` + + // Allows grantee to create, overwrite, and delete any object in the bucket. + GrantWrite *string `location:"header" locationName:"x-amz-grant-write" type:"string"` + + // Allows grantee to write the ACL for the applicable bucket. + GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` +} + +// String returns the string representation +func (s CreateBucketInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateBucketInput) GoString() string { + return s.String() +} + +type CreateBucketOutput struct { + _ struct{} `type:"structure"` + + Location *string `location:"header" locationName:"Location" type:"string"` +} + +// String returns the string representation +func (s CreateBucketOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateBucketOutput) GoString() string { + return s.String() +} + +type CreateMultipartUploadInput struct { + _ struct{} `type:"structure"` + + // The canned ACL to apply to the object. + ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Specifies caching behavior along the request/reply chain. + CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"` + + // Specifies presentational information for the object. + ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"` + + // Specifies what content encodings have been applied to the object and thus + // what decoding mechanisms must be applied to obtain the media-type referenced + // by the Content-Type header field. + ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"` + + // The language the content is in. + ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"` + + // A standard MIME type describing the format of the object data. + ContentType *string `location:"header" locationName:"Content-Type" type:"string"` + + // The date and time at which the object is no longer cacheable. + Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"` + + // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object. + GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"` + + // Allows grantee to read the object data and its metadata. + GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"` + + // Allows grantee to read the object ACL. + GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"` + + // Allows grantee to write the ACL for the applicable object. + GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // A map of metadata to store with the object in S3. + Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT + // requests for an object protected by AWS KMS will fail if not made via SSL + // or using SigV4. Documentation on configuring any of the officially supported + // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // The type of storage to use for the object. Defaults to 'STANDARD'. + StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string" enum:"StorageClass"` + + // If the bucket is configured as a website, redirects requests for this object + // to another object in the same bucket or to an external URL. Amazon S3 stores + // the value of this header in the object metadata. + WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` +} + +// String returns the string representation +func (s CreateMultipartUploadInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateMultipartUploadInput) GoString() string { + return s.String() +} + +type CreateMultipartUploadOutput struct { + _ struct{} `type:"structure"` + + // Name of the bucket to which the multipart upload was initiated. + Bucket *string `locationName:"Bucket" type:"string"` + + // Object key for which the multipart upload was initiated. + Key *string `min:"1" type:"string"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // ID for the initiated multipart upload. + UploadId *string `type:"string"` +} + +// String returns the string representation +func (s CreateMultipartUploadOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateMultipartUploadOutput) GoString() string { + return s.String() +} + +type Delete struct { + _ struct{} `type:"structure"` + + Objects []*ObjectIdentifier `locationName:"Object" type:"list" flattened:"true" required:"true"` + + // Element to enable quiet mode for the request. When you add this element, + // you must set its value to true. + Quiet *bool `type:"boolean"` +} + +// String returns the string representation +func (s Delete) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Delete) GoString() string { + return s.String() +} + +type DeleteBucketCorsInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketCorsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketCorsInput) GoString() string { + return s.String() +} + +type DeleteBucketCorsOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketCorsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketCorsOutput) GoString() string { + return s.String() +} + +type DeleteBucketInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketInput) GoString() string { + return s.String() +} + +type DeleteBucketLifecycleInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketLifecycleInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketLifecycleInput) GoString() string { + return s.String() +} + +type DeleteBucketLifecycleOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketLifecycleOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketLifecycleOutput) GoString() string { + return s.String() +} + +type DeleteBucketOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketOutput) GoString() string { + return s.String() +} + +type DeleteBucketPolicyInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketPolicyInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketPolicyInput) GoString() string { + return s.String() +} + +type DeleteBucketPolicyOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketPolicyOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketPolicyOutput) GoString() string { + return s.String() +} + +type DeleteBucketReplicationInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketReplicationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketReplicationInput) GoString() string { + return s.String() +} + +type DeleteBucketReplicationOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketReplicationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketReplicationOutput) GoString() string { + return s.String() +} + +type DeleteBucketTaggingInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketTaggingInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketTaggingInput) GoString() string { + return s.String() +} + +type DeleteBucketTaggingOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketTaggingOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketTaggingOutput) GoString() string { + return s.String() +} + +type DeleteBucketWebsiteInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteBucketWebsiteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketWebsiteInput) GoString() string { + return s.String() +} + +type DeleteBucketWebsiteOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteBucketWebsiteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteBucketWebsiteOutput) GoString() string { + return s.String() +} + +type DeleteMarkerEntry struct { + _ struct{} `type:"structure"` + + // Specifies whether the object is (true) or is not (false) the latest version + // of an object. + IsLatest *bool `type:"boolean"` + + // The object key. + Key *string `min:"1" type:"string"` + + // Date and time the object was last modified. + LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + Owner *Owner `type:"structure"` + + // Version ID of an object. + VersionId *string `type:"string"` +} + +// String returns the string representation +func (s DeleteMarkerEntry) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteMarkerEntry) GoString() string { + return s.String() +} + +type DeleteObjectInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // The concatenation of the authentication device's serial number, a space, + // and the value that is displayed on your authentication device. + MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // VersionId used to reference a specific version of the object. + VersionId *string `location:"querystring" locationName:"versionId" type:"string"` +} + +// String returns the string representation +func (s DeleteObjectInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteObjectInput) GoString() string { + return s.String() +} + +type DeleteObjectOutput struct { + _ struct{} `type:"structure"` + + // Specifies whether the versioned object that was permanently deleted was (true) + // or was not (false) a delete marker. + DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // Returns the version ID of the delete marker created as a result of the DELETE + // operation. + VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` +} + +// String returns the string representation +func (s DeleteObjectOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteObjectOutput) GoString() string { + return s.String() +} + +type DeleteObjectsInput struct { + _ struct{} `type:"structure" payload:"Delete"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Delete *Delete `locationName:"Delete" type:"structure" required:"true"` + + // The concatenation of the authentication device's serial number, a space, + // and the value that is displayed on your authentication device. + MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` +} + +// String returns the string representation +func (s DeleteObjectsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteObjectsInput) GoString() string { + return s.String() +} + +type DeleteObjectsOutput struct { + _ struct{} `type:"structure"` + + Deleted []*DeletedObject `type:"list" flattened:"true"` + + Errors []*Error `locationName:"Error" type:"list" flattened:"true"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` +} + +// String returns the string representation +func (s DeleteObjectsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteObjectsOutput) GoString() string { + return s.String() +} + +type DeletedObject struct { + _ struct{} `type:"structure"` + + DeleteMarker *bool `type:"boolean"` + + DeleteMarkerVersionId *string `type:"string"` + + Key *string `min:"1" type:"string"` + + VersionId *string `type:"string"` +} + +// String returns the string representation +func (s DeletedObject) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeletedObject) GoString() string { + return s.String() +} + +type Destination struct { + _ struct{} `type:"structure"` + + // Amazon resource name (ARN) of the bucket where you want Amazon S3 to store + // replicas of the object identified by the rule. + Bucket *string `type:"string" required:"true"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"StorageClass"` +} + +// String returns the string representation +func (s Destination) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Destination) GoString() string { + return s.String() +} + +type Error struct { + _ struct{} `type:"structure"` + + Code *string `type:"string"` + + Key *string `min:"1" type:"string"` + + Message *string `type:"string"` + + VersionId *string `type:"string"` +} + +// String returns the string representation +func (s Error) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Error) GoString() string { + return s.String() +} + +type ErrorDocument struct { + _ struct{} `type:"structure"` + + // The object key name to use when a 4XX class error occurs. + Key *string `min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s ErrorDocument) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ErrorDocument) GoString() string { + return s.String() +} + +// Container for key value pair that defines the criteria for the filter rule. +type FilterRule struct { + _ struct{} `type:"structure"` + + // Object key name prefix or suffix identifying one or more objects to which + // the filtering rule applies. Maximum prefix length can be up to 1,024 characters. + // Overlapping prefixes and suffixes are not supported. For more information, + // go to Configuring Event Notifications (http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) + // in the Amazon Simple Storage Service Developer Guide. + Name *string `type:"string" enum:"FilterRuleName"` + + Value *string `type:"string"` +} + +// String returns the string representation +func (s FilterRule) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s FilterRule) GoString() string { + return s.String() +} + +type GetBucketAclInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketAclInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketAclInput) GoString() string { + return s.String() +} + +type GetBucketAclOutput struct { + _ struct{} `type:"structure"` + + // A list of grants. + Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"` + + Owner *Owner `type:"structure"` +} + +// String returns the string representation +func (s GetBucketAclOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketAclOutput) GoString() string { + return s.String() +} + +type GetBucketCorsInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketCorsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketCorsInput) GoString() string { + return s.String() +} + +type GetBucketCorsOutput struct { + _ struct{} `type:"structure"` + + CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s GetBucketCorsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketCorsOutput) GoString() string { + return s.String() +} + +type GetBucketLifecycleConfigurationInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketLifecycleConfigurationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLifecycleConfigurationInput) GoString() string { + return s.String() +} + +type GetBucketLifecycleConfigurationOutput struct { + _ struct{} `type:"structure"` + + Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s GetBucketLifecycleConfigurationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLifecycleConfigurationOutput) GoString() string { + return s.String() +} + +type GetBucketLifecycleInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketLifecycleInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLifecycleInput) GoString() string { + return s.String() +} + +type GetBucketLifecycleOutput struct { + _ struct{} `type:"structure"` + + Rules []*Rule `locationName:"Rule" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s GetBucketLifecycleOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLifecycleOutput) GoString() string { + return s.String() +} + +type GetBucketLocationInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketLocationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLocationInput) GoString() string { + return s.String() +} + +type GetBucketLocationOutput struct { + _ struct{} `type:"structure"` + + LocationConstraint *string `type:"string" enum:"BucketLocationConstraint"` +} + +// String returns the string representation +func (s GetBucketLocationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLocationOutput) GoString() string { + return s.String() +} + +type GetBucketLoggingInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketLoggingInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLoggingInput) GoString() string { + return s.String() +} + +type GetBucketLoggingOutput struct { + _ struct{} `type:"structure"` + + LoggingEnabled *LoggingEnabled `type:"structure"` +} + +// String returns the string representation +func (s GetBucketLoggingOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketLoggingOutput) GoString() string { + return s.String() +} + +type GetBucketNotificationConfigurationRequest struct { + _ struct{} `type:"structure"` + + // Name of the buket to get the notification configuration for. + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketNotificationConfigurationRequest) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketNotificationConfigurationRequest) GoString() string { + return s.String() +} + +type GetBucketPolicyInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketPolicyInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketPolicyInput) GoString() string { + return s.String() +} + +type GetBucketPolicyOutput struct { + _ struct{} `type:"structure" payload:"Policy"` + + // The bucket policy as a JSON document. + Policy *string `type:"string"` +} + +// String returns the string representation +func (s GetBucketPolicyOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketPolicyOutput) GoString() string { + return s.String() +} + +type GetBucketReplicationInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketReplicationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketReplicationInput) GoString() string { + return s.String() +} + +type GetBucketReplicationOutput struct { + _ struct{} `type:"structure" payload:"ReplicationConfiguration"` + + // Container for replication rules. You can add as many as 1,000 rules. Total + // replication configuration size can be up to 2 MB. + ReplicationConfiguration *ReplicationConfiguration `type:"structure"` +} + +// String returns the string representation +func (s GetBucketReplicationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketReplicationOutput) GoString() string { + return s.String() +} + +type GetBucketRequestPaymentInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketRequestPaymentInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketRequestPaymentInput) GoString() string { + return s.String() +} + +type GetBucketRequestPaymentOutput struct { + _ struct{} `type:"structure"` + + // Specifies who pays for the download and request fees. + Payer *string `type:"string" enum:"Payer"` +} + +// String returns the string representation +func (s GetBucketRequestPaymentOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketRequestPaymentOutput) GoString() string { + return s.String() +} + +type GetBucketTaggingInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketTaggingInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketTaggingInput) GoString() string { + return s.String() +} + +type GetBucketTaggingOutput struct { + _ struct{} `type:"structure"` + + TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"` +} + +// String returns the string representation +func (s GetBucketTaggingOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketTaggingOutput) GoString() string { + return s.String() +} + +type GetBucketVersioningInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketVersioningInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketVersioningInput) GoString() string { + return s.String() +} + +type GetBucketVersioningOutput struct { + _ struct{} `type:"structure"` + + // Specifies whether MFA delete is enabled in the bucket versioning configuration. + // This element is only returned if the bucket has been configured with MFA + // delete. If the bucket has never been so configured, this element is not returned. + MFADelete *string `locationName:"MfaDelete" type:"string" enum:"MFADeleteStatus"` + + // The versioning state of the bucket. + Status *string `type:"string" enum:"BucketVersioningStatus"` +} + +// String returns the string representation +func (s GetBucketVersioningOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketVersioningOutput) GoString() string { + return s.String() +} + +type GetBucketWebsiteInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetBucketWebsiteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketWebsiteInput) GoString() string { + return s.String() +} + +type GetBucketWebsiteOutput struct { + _ struct{} `type:"structure"` + + ErrorDocument *ErrorDocument `type:"structure"` + + IndexDocument *IndexDocument `type:"structure"` + + RedirectAllRequestsTo *RedirectAllRequestsTo `type:"structure"` + + RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"` +} + +// String returns the string representation +func (s GetBucketWebsiteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBucketWebsiteOutput) GoString() string { + return s.String() +} + +type GetObjectAclInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // VersionId used to reference a specific version of the object. + VersionId *string `location:"querystring" locationName:"versionId" type:"string"` +} + +// String returns the string representation +func (s GetObjectAclInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetObjectAclInput) GoString() string { + return s.String() +} + +type GetObjectAclOutput struct { + _ struct{} `type:"structure"` + + // A list of grants. + Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"` + + Owner *Owner `type:"structure"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` +} + +// String returns the string representation +func (s GetObjectAclOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetObjectAclOutput) GoString() string { + return s.String() +} + +type GetObjectInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Return the object only if its entity tag (ETag) is the same as the one specified, + // otherwise return a 412 (precondition failed). + IfMatch *string `location:"header" locationName:"If-Match" type:"string"` + + // Return the object only if it has been modified since the specified time, + // otherwise return a 304 (not modified). + IfModifiedSince *time.Time `location:"header" locationName:"If-Modified-Since" type:"timestamp" timestampFormat:"rfc822"` + + // Return the object only if its entity tag (ETag) is different from the one + // specified, otherwise return a 304 (not modified). + IfNoneMatch *string `location:"header" locationName:"If-None-Match" type:"string"` + + // Return the object only if it has not been modified since the specified time, + // otherwise return a 412 (precondition failed). + IfUnmodifiedSince *time.Time `location:"header" locationName:"If-Unmodified-Since" type:"timestamp" timestampFormat:"rfc822"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Downloads the specified range bytes of an object. For more information about + // the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35. + Range *string `location:"header" locationName:"Range" type:"string"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Sets the Cache-Control header of the response. + ResponseCacheControl *string `location:"querystring" locationName:"response-cache-control" type:"string"` + + // Sets the Content-Disposition header of the response + ResponseContentDisposition *string `location:"querystring" locationName:"response-content-disposition" type:"string"` + + // Sets the Content-Encoding header of the response. + ResponseContentEncoding *string `location:"querystring" locationName:"response-content-encoding" type:"string"` + + // Sets the Content-Language header of the response. + ResponseContentLanguage *string `location:"querystring" locationName:"response-content-language" type:"string"` + + // Sets the Content-Type header of the response. + ResponseContentType *string `location:"querystring" locationName:"response-content-type" type:"string"` + + // Sets the Expires header of the response. + ResponseExpires *time.Time `location:"querystring" locationName:"response-expires" type:"timestamp" timestampFormat:"iso8601"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // VersionId used to reference a specific version of the object. + VersionId *string `location:"querystring" locationName:"versionId" type:"string"` +} + +// String returns the string representation +func (s GetObjectInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetObjectInput) GoString() string { + return s.String() +} + +type GetObjectOutput struct { + _ struct{} `type:"structure" payload:"Body"` + + AcceptRanges *string `location:"header" locationName:"accept-ranges" type:"string"` + + // Object data. + Body io.ReadCloser `type:"blob"` + + // Specifies caching behavior along the request/reply chain. + CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"` + + // Specifies presentational information for the object. + ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"` + + // Specifies what content encodings have been applied to the object and thus + // what decoding mechanisms must be applied to obtain the media-type referenced + // by the Content-Type header field. + ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"` + + // The language the content is in. + ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"` + + // Size of the body in bytes. + ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"` + + // The portion of the object returned in the response. + ContentRange *string `location:"header" locationName:"Content-Range" type:"string"` + + // A standard MIME type describing the format of the object data. + ContentType *string `location:"header" locationName:"Content-Type" type:"string"` + + // Specifies whether the object retrieved was (true) or was not (false) a Delete + // Marker. If false, this response header does not appear in the response. + DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"` + + // An ETag is an opaque identifier assigned by a web server to a specific version + // of a resource found at a URL + ETag *string `location:"header" locationName:"ETag" type:"string"` + + // If the object expiration is configured (see PUT Bucket lifecycle), the response + // includes this header. It includes the expiry-date and rule-id key value pairs + // providing object expiration information. The value of the rule-id is URL + // encoded. + Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"` + + // The date and time at which the object is no longer cacheable. + Expires *string `location:"header" locationName:"Expires" type:"string"` + + // Last modified date of the object + LastModified *time.Time `location:"header" locationName:"Last-Modified" type:"timestamp" timestampFormat:"rfc822"` + + // A map of metadata to store with the object in S3. + Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"` + + // This is set to the number of metadata entries not returned in x-amz-meta + // headers. This can happen if you create metadata using an API like SOAP that + // supports more flexible metadata than the REST API. For example, using SOAP, + // you can create metadata whose values are not legal HTTP headers. + MissingMeta *int64 `location:"header" locationName:"x-amz-missing-meta" type:"integer"` + + ReplicationStatus *string `location:"header" locationName:"x-amz-replication-status" type:"string" enum:"ReplicationStatus"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // Provides information about object restoration operation and expiration time + // of the restored object copy. + Restore *string `location:"header" locationName:"x-amz-restore" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string" enum:"StorageClass"` + + // Version of the object. + VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` + + // If the bucket is configured as a website, redirects requests for this object + // to another object in the same bucket or to an external URL. Amazon S3 stores + // the value of this header in the object metadata. + WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` +} + +// String returns the string representation +func (s GetObjectOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetObjectOutput) GoString() string { + return s.String() +} + +type GetObjectTorrentInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` +} + +// String returns the string representation +func (s GetObjectTorrentInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetObjectTorrentInput) GoString() string { + return s.String() +} + +type GetObjectTorrentOutput struct { + _ struct{} `type:"structure" payload:"Body"` + + Body io.ReadCloser `type:"blob"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` +} + +// String returns the string representation +func (s GetObjectTorrentOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetObjectTorrentOutput) GoString() string { + return s.String() +} + +type Grant struct { + _ struct{} `type:"structure"` + + Grantee *Grantee `type:"structure"` + + // Specifies the permission given to the grantee. + Permission *string `type:"string" enum:"Permission"` +} + +// String returns the string representation +func (s Grant) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Grant) GoString() string { + return s.String() +} + +type Grantee struct { + _ struct{} `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"` + + // Screen name of the grantee. + DisplayName *string `type:"string"` + + // Email address of the grantee. + EmailAddress *string `type:"string"` + + // The canonical user ID of the grantee. + ID *string `type:"string"` + + // Type of grantee + Type *string `locationName:"xsi:type" type:"string" xmlAttribute:"true" required:"true" enum:"Type"` + + // URI of the grantee group. + URI *string `type:"string"` +} + +// String returns the string representation +func (s Grantee) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Grantee) GoString() string { + return s.String() +} + +type HeadBucketInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` +} + +// String returns the string representation +func (s HeadBucketInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HeadBucketInput) GoString() string { + return s.String() +} + +type HeadBucketOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s HeadBucketOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HeadBucketOutput) GoString() string { + return s.String() +} + +type HeadObjectInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Return the object only if its entity tag (ETag) is the same as the one specified, + // otherwise return a 412 (precondition failed). + IfMatch *string `location:"header" locationName:"If-Match" type:"string"` + + // Return the object only if it has been modified since the specified time, + // otherwise return a 304 (not modified). + IfModifiedSince *time.Time `location:"header" locationName:"If-Modified-Since" type:"timestamp" timestampFormat:"rfc822"` + + // Return the object only if its entity tag (ETag) is different from the one + // specified, otherwise return a 304 (not modified). + IfNoneMatch *string `location:"header" locationName:"If-None-Match" type:"string"` + + // Return the object only if it has not been modified since the specified time, + // otherwise return a 412 (precondition failed). + IfUnmodifiedSince *time.Time `location:"header" locationName:"If-Unmodified-Since" type:"timestamp" timestampFormat:"rfc822"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Downloads the specified range bytes of an object. For more information about + // the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35. + Range *string `location:"header" locationName:"Range" type:"string"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // VersionId used to reference a specific version of the object. + VersionId *string `location:"querystring" locationName:"versionId" type:"string"` +} + +// String returns the string representation +func (s HeadObjectInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HeadObjectInput) GoString() string { + return s.String() +} + +type HeadObjectOutput struct { + _ struct{} `type:"structure"` + + AcceptRanges *string `location:"header" locationName:"accept-ranges" type:"string"` + + // Specifies caching behavior along the request/reply chain. + CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"` + + // Specifies presentational information for the object. + ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"` + + // Specifies what content encodings have been applied to the object and thus + // what decoding mechanisms must be applied to obtain the media-type referenced + // by the Content-Type header field. + ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"` + + // The language the content is in. + ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"` + + // Size of the body in bytes. + ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"` + + // A standard MIME type describing the format of the object data. + ContentType *string `location:"header" locationName:"Content-Type" type:"string"` + + // Specifies whether the object retrieved was (true) or was not (false) a Delete + // Marker. If false, this response header does not appear in the response. + DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"` + + // An ETag is an opaque identifier assigned by a web server to a specific version + // of a resource found at a URL + ETag *string `location:"header" locationName:"ETag" type:"string"` + + // If the object expiration is configured (see PUT Bucket lifecycle), the response + // includes this header. It includes the expiry-date and rule-id key value pairs + // providing object expiration information. The value of the rule-id is URL + // encoded. + Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"` + + // The date and time at which the object is no longer cacheable. + Expires *string `location:"header" locationName:"Expires" type:"string"` + + // Last modified date of the object + LastModified *time.Time `location:"header" locationName:"Last-Modified" type:"timestamp" timestampFormat:"rfc822"` + + // A map of metadata to store with the object in S3. + Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"` + + // This is set to the number of metadata entries not returned in x-amz-meta + // headers. This can happen if you create metadata using an API like SOAP that + // supports more flexible metadata than the REST API. For example, using SOAP, + // you can create metadata whose values are not legal HTTP headers. + MissingMeta *int64 `location:"header" locationName:"x-amz-missing-meta" type:"integer"` + + ReplicationStatus *string `location:"header" locationName:"x-amz-replication-status" type:"string" enum:"ReplicationStatus"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // Provides information about object restoration operation and expiration time + // of the restored object copy. + Restore *string `location:"header" locationName:"x-amz-restore" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string" enum:"StorageClass"` + + // Version of the object. + VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` + + // If the bucket is configured as a website, redirects requests for this object + // to another object in the same bucket or to an external URL. Amazon S3 stores + // the value of this header in the object metadata. + WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` +} + +// String returns the string representation +func (s HeadObjectOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HeadObjectOutput) GoString() string { + return s.String() +} + +type IndexDocument struct { + _ struct{} `type:"structure"` + + // A suffix that is appended to a request that is for a directory on the website + // endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ + // the data that is returned will be for the object with the key name images/index.html) + // The suffix must not be empty and must not include a slash character. + Suffix *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s IndexDocument) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s IndexDocument) GoString() string { + return s.String() +} + +type Initiator struct { + _ struct{} `type:"structure"` + + // Name of the Principal. + DisplayName *string `type:"string"` + + // If the principal is an AWS account, it provides the Canonical User ID. If + // the principal is an IAM User, it provides a user ARN value. + ID *string `type:"string"` +} + +// String returns the string representation +func (s Initiator) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Initiator) GoString() string { + return s.String() +} + +// Container for object key name prefix and suffix filtering rules. +type KeyFilter struct { + _ struct{} `type:"structure"` + + // A list of containers for key value pair that defines the criteria for the + // filter rule. + FilterRules []*FilterRule `locationName:"FilterRule" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s KeyFilter) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s KeyFilter) GoString() string { + return s.String() +} + +// Container for specifying the AWS Lambda notification configuration. +type LambdaFunctionConfiguration struct { + _ struct{} `type:"structure"` + + Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"` + + // Container for object key name filtering rules. For information about key + // name filtering, go to Configuring Event Notifications (http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) + // in the Amazon Simple Storage Service Developer Guide. + Filter *NotificationConfigurationFilter `type:"structure"` + + // Optional unique identifier for configurations in a notification configuration. + // If you don't provide one, Amazon S3 will assign an ID. + Id *string `type:"string"` + + // Lambda cloud function ARN that Amazon S3 can invoke when it detects events + // of the specified type. + LambdaFunctionArn *string `locationName:"CloudFunction" type:"string" required:"true"` +} + +// String returns the string representation +func (s LambdaFunctionConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LambdaFunctionConfiguration) GoString() string { + return s.String() +} + +type LifecycleConfiguration struct { + _ struct{} `type:"structure"` + + Rules []*Rule `locationName:"Rule" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s LifecycleConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LifecycleConfiguration) GoString() string { + return s.String() +} + +type LifecycleExpiration struct { + _ struct{} `type:"structure"` + + // Indicates at what date the object is to be moved or deleted. Should be in + // GMT ISO 8601 Format. + Date *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + // Indicates the lifetime, in days, of the objects that are subject to the rule. + // The value must be a non-zero positive integer. + Days *int64 `type:"integer"` +} + +// String returns the string representation +func (s LifecycleExpiration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LifecycleExpiration) GoString() string { + return s.String() +} + +type LifecycleRule struct { + _ struct{} `type:"structure"` + + Expiration *LifecycleExpiration `type:"structure"` + + // Unique identifier for the rule. The value cannot be longer than 255 characters. + ID *string `type:"string"` + + // Specifies when noncurrent object versions expire. Upon expiration, Amazon + // S3 permanently deletes the noncurrent object versions. You set this lifecycle + // configuration action on a bucket that has versioning enabled (or suspended) + // to request that Amazon S3 delete noncurrent object versions at a specific + // period in the object's lifetime. + NoncurrentVersionExpiration *NoncurrentVersionExpiration `type:"structure"` + + NoncurrentVersionTransitions []*NoncurrentVersionTransition `locationName:"NoncurrentVersionTransition" type:"list" flattened:"true"` + + // Prefix identifying one or more objects to which the rule applies. + Prefix *string `type:"string" required:"true"` + + // If 'Enabled', the rule is currently being applied. If 'Disabled', the rule + // is not currently being applied. + Status *string `type:"string" required:"true" enum:"ExpirationStatus"` + + Transitions []*Transition `locationName:"Transition" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s LifecycleRule) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LifecycleRule) GoString() string { + return s.String() +} + +type ListBucketsInput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s ListBucketsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListBucketsInput) GoString() string { + return s.String() +} + +type ListBucketsOutput struct { + _ struct{} `type:"structure"` + + Buckets []*Bucket `locationNameList:"Bucket" type:"list"` + + Owner *Owner `type:"structure"` +} + +// String returns the string representation +func (s ListBucketsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListBucketsOutput) GoString() string { + return s.String() +} + +type ListMultipartUploadsInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Character you use to group keys. + Delimiter *string `location:"querystring" locationName:"delimiter" type:"string"` + + // Requests Amazon S3 to encode the object keys in the response and specifies + // the encoding method to use. An object key may contain any Unicode character; + // however, XML 1.0 parser cannot parse some characters, such as characters + // with an ASCII value from 0 to 10. For characters that are not supported in + // XML 1.0, you can add this parameter to request that Amazon S3 encode the + // keys in the response. + EncodingType *string `location:"querystring" locationName:"encoding-type" type:"string" enum:"EncodingType"` + + // Together with upload-id-marker, this parameter specifies the multipart upload + // after which listing should begin. + KeyMarker *string `location:"querystring" locationName:"key-marker" type:"string"` + + // Sets the maximum number of multipart uploads, from 1 to 1,000, to return + // in the response body. 1,000 is the maximum number of uploads that can be + // returned in a response. + MaxUploads *int64 `location:"querystring" locationName:"max-uploads" type:"integer"` + + // Lists in-progress uploads only for those keys that begin with the specified + // prefix. + Prefix *string `location:"querystring" locationName:"prefix" type:"string"` + + // Together with key-marker, specifies the multipart upload after which listing + // should begin. If key-marker is not specified, the upload-id-marker parameter + // is ignored. + UploadIdMarker *string `location:"querystring" locationName:"upload-id-marker" type:"string"` +} + +// String returns the string representation +func (s ListMultipartUploadsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListMultipartUploadsInput) GoString() string { + return s.String() +} + +type ListMultipartUploadsOutput struct { + _ struct{} `type:"structure"` + + // Name of the bucket to which the multipart upload was initiated. + Bucket *string `type:"string"` + + CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"` + + Delimiter *string `type:"string"` + + // Encoding type used by Amazon S3 to encode object keys in the response. + EncodingType *string `type:"string" enum:"EncodingType"` + + // Indicates whether the returned list of multipart uploads is truncated. A + // value of true indicates that the list was truncated. The list can be truncated + // if the number of multipart uploads exceeds the limit allowed or specified + // by max uploads. + IsTruncated *bool `type:"boolean"` + + // The key at or after which the listing began. + KeyMarker *string `type:"string"` + + // Maximum number of multipart uploads that could have been included in the + // response. + MaxUploads *int64 `type:"integer"` + + // When a list is truncated, this element specifies the value that should be + // used for the key-marker request parameter in a subsequent request. + NextKeyMarker *string `type:"string"` + + // When a list is truncated, this element specifies the value that should be + // used for the upload-id-marker request parameter in a subsequent request. + NextUploadIdMarker *string `type:"string"` + + // When a prefix is provided in the request, this field contains the specified + // prefix. The result contains only keys starting with the specified prefix. + Prefix *string `type:"string"` + + // Upload ID after which listing began. + UploadIdMarker *string `type:"string"` + + Uploads []*MultipartUpload `locationName:"Upload" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s ListMultipartUploadsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListMultipartUploadsOutput) GoString() string { + return s.String() +} + +type ListObjectVersionsInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // A delimiter is a character you use to group keys. + Delimiter *string `location:"querystring" locationName:"delimiter" type:"string"` + + // Requests Amazon S3 to encode the object keys in the response and specifies + // the encoding method to use. An object key may contain any Unicode character; + // however, XML 1.0 parser cannot parse some characters, such as characters + // with an ASCII value from 0 to 10. For characters that are not supported in + // XML 1.0, you can add this parameter to request that Amazon S3 encode the + // keys in the response. + EncodingType *string `location:"querystring" locationName:"encoding-type" type:"string" enum:"EncodingType"` + + // Specifies the key to start with when listing objects in a bucket. + KeyMarker *string `location:"querystring" locationName:"key-marker" type:"string"` + + // Sets the maximum number of keys returned in the response. The response might + // contain fewer keys but will never contain more. + MaxKeys *int64 `location:"querystring" locationName:"max-keys" type:"integer"` + + // Limits the response to keys that begin with the specified prefix. + Prefix *string `location:"querystring" locationName:"prefix" type:"string"` + + // Specifies the object version you want to start listing from. + VersionIdMarker *string `location:"querystring" locationName:"version-id-marker" type:"string"` +} + +// String returns the string representation +func (s ListObjectVersionsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListObjectVersionsInput) GoString() string { + return s.String() +} + +type ListObjectVersionsOutput struct { + _ struct{} `type:"structure"` + + CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"` + + DeleteMarkers []*DeleteMarkerEntry `locationName:"DeleteMarker" type:"list" flattened:"true"` + + Delimiter *string `type:"string"` + + // Encoding type used by Amazon S3 to encode object keys in the response. + EncodingType *string `type:"string" enum:"EncodingType"` + + // A flag that indicates whether or not Amazon S3 returned all of the results + // that satisfied the search criteria. If your results were truncated, you can + // make a follow-up paginated request using the NextKeyMarker and NextVersionIdMarker + // response parameters as a starting place in another request to return the + // rest of the results. + IsTruncated *bool `type:"boolean"` + + // Marks the last Key returned in a truncated response. + KeyMarker *string `type:"string"` + + MaxKeys *int64 `type:"integer"` + + Name *string `type:"string"` + + // Use this value for the key marker request parameter in a subsequent request. + NextKeyMarker *string `type:"string"` + + // Use this value for the next version id marker parameter in a subsequent request. + NextVersionIdMarker *string `type:"string"` + + Prefix *string `type:"string"` + + VersionIdMarker *string `type:"string"` + + Versions []*ObjectVersion `locationName:"Version" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s ListObjectVersionsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListObjectVersionsOutput) GoString() string { + return s.String() +} + +type ListObjectsInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // A delimiter is a character you use to group keys. + Delimiter *string `location:"querystring" locationName:"delimiter" type:"string"` + + // Requests Amazon S3 to encode the object keys in the response and specifies + // the encoding method to use. An object key may contain any Unicode character; + // however, XML 1.0 parser cannot parse some characters, such as characters + // with an ASCII value from 0 to 10. For characters that are not supported in + // XML 1.0, you can add this parameter to request that Amazon S3 encode the + // keys in the response. + EncodingType *string `location:"querystring" locationName:"encoding-type" type:"string" enum:"EncodingType"` + + // Specifies the key to start with when listing objects in a bucket. + Marker *string `location:"querystring" locationName:"marker" type:"string"` + + // Sets the maximum number of keys returned in the response. The response might + // contain fewer keys but will never contain more. + MaxKeys *int64 `location:"querystring" locationName:"max-keys" type:"integer"` + + // Limits the response to keys that begin with the specified prefix. + Prefix *string `location:"querystring" locationName:"prefix" type:"string"` +} + +// String returns the string representation +func (s ListObjectsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListObjectsInput) GoString() string { + return s.String() +} + +type ListObjectsOutput struct { + _ struct{} `type:"structure"` + + CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"` + + Contents []*Object `type:"list" flattened:"true"` + + Delimiter *string `type:"string"` + + // Encoding type used by Amazon S3 to encode object keys in the response. + EncodingType *string `type:"string" enum:"EncodingType"` + + // A flag that indicates whether or not Amazon S3 returned all of the results + // that satisfied the search criteria. + IsTruncated *bool `type:"boolean"` + + Marker *string `type:"string"` + + MaxKeys *int64 `type:"integer"` + + Name *string `type:"string"` + + // When response is truncated (the IsTruncated element value in the response + // is true), you can use the key name in this field as marker in the subsequent + // request to get next set of objects. Amazon S3 lists objects in alphabetical + // order Note: This element is returned only if you have delimiter request parameter + // specified. If response does not include the NextMaker and it is truncated, + // you can use the value of the last Key in the response as the marker in the + // subsequent request to get the next set of object keys. + NextMarker *string `type:"string"` + + Prefix *string `type:"string"` +} + +// String returns the string representation +func (s ListObjectsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListObjectsOutput) GoString() string { + return s.String() +} + +type ListPartsInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Sets the maximum number of parts to return. + MaxParts *int64 `location:"querystring" locationName:"max-parts" type:"integer"` + + // Specifies the part after which listing should begin. Only parts with higher + // part numbers will be listed. + PartNumberMarker *int64 `location:"querystring" locationName:"part-number-marker" type:"integer"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Upload ID identifying the multipart upload whose parts are being listed. + UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` +} + +// String returns the string representation +func (s ListPartsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListPartsInput) GoString() string { + return s.String() +} + +type ListPartsOutput struct { + _ struct{} `type:"structure"` + + // Name of the bucket to which the multipart upload was initiated. + Bucket *string `type:"string"` + + // Identifies who initiated the multipart upload. + Initiator *Initiator `type:"structure"` + + // Indicates whether the returned list of parts is truncated. + IsTruncated *bool `type:"boolean"` + + // Object key for which the multipart upload was initiated. + Key *string `min:"1" type:"string"` + + // Maximum number of parts that were allowed in the response. + MaxParts *int64 `type:"integer"` + + // When a list is truncated, this element specifies the last part in the list, + // as well as the value to use for the part-number-marker request parameter + // in a subsequent request. + NextPartNumberMarker *int64 `type:"integer"` + + Owner *Owner `type:"structure"` + + // Part number after which listing begins. + PartNumberMarker *int64 `type:"integer"` + + Parts []*Part `locationName:"Part" type:"list" flattened:"true"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"StorageClass"` + + // Upload ID identifying the multipart upload whose parts are being listed. + UploadId *string `type:"string"` +} + +// String returns the string representation +func (s ListPartsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListPartsOutput) GoString() string { + return s.String() +} + +type LoggingEnabled struct { + _ struct{} `type:"structure"` + + // Specifies the bucket where you want Amazon S3 to store server access logs. + // You can have your logs delivered to any bucket that you own, including the + // same bucket that is being logged. You can also configure multiple buckets + // to deliver their logs to the same target bucket. In this case you should + // choose a different TargetPrefix for each source bucket so that the delivered + // log files can be distinguished by key. + TargetBucket *string `type:"string"` + + TargetGrants []*TargetGrant `locationNameList:"Grant" type:"list"` + + // This element lets you specify a prefix for the keys that the log files will + // be stored under. + TargetPrefix *string `type:"string"` +} + +// String returns the string representation +func (s LoggingEnabled) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoggingEnabled) GoString() string { + return s.String() +} + +type MultipartUpload struct { + _ struct{} `type:"structure"` + + // Date and time at which the multipart upload was initiated. + Initiated *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + // Identifies who initiated the multipart upload. + Initiator *Initiator `type:"structure"` + + // Key of the object for which the multipart upload was initiated. + Key *string `min:"1" type:"string"` + + Owner *Owner `type:"structure"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"StorageClass"` + + // Upload ID that identifies the multipart upload. + UploadId *string `type:"string"` +} + +// String returns the string representation +func (s MultipartUpload) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MultipartUpload) GoString() string { + return s.String() +} + +// Specifies when noncurrent object versions expire. Upon expiration, Amazon +// S3 permanently deletes the noncurrent object versions. You set this lifecycle +// configuration action on a bucket that has versioning enabled (or suspended) +// to request that Amazon S3 delete noncurrent object versions at a specific +// period in the object's lifetime. +type NoncurrentVersionExpiration struct { + _ struct{} `type:"structure"` + + // Specifies the number of days an object is noncurrent before Amazon S3 can + // perform the associated action. For information about the noncurrent days + // calculations, see How Amazon S3 Calculates When an Object Became Noncurrent + // (/AmazonS3/latest/dev/s3-access-control.html) in the Amazon Simple Storage + // Service Developer Guide. + NoncurrentDays *int64 `type:"integer"` +} + +// String returns the string representation +func (s NoncurrentVersionExpiration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s NoncurrentVersionExpiration) GoString() string { + return s.String() +} + +// Container for the transition rule that describes when noncurrent objects +// transition to the STANDARD_IA or GLACIER storage class. If your bucket is +// versioning-enabled (or versioning is suspended), you can set this action +// to request that Amazon S3 transition noncurrent object versions to the STANDARD_IA +// or GLACIER storage class at a specific period in the object's lifetime. +type NoncurrentVersionTransition struct { + _ struct{} `type:"structure"` + + // Specifies the number of days an object is noncurrent before Amazon S3 can + // perform the associated action. For information about the noncurrent days + // calculations, see How Amazon S3 Calculates When an Object Became Noncurrent + // (/AmazonS3/latest/dev/s3-access-control.html) in the Amazon Simple Storage + // Service Developer Guide. + NoncurrentDays *int64 `type:"integer"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"TransitionStorageClass"` +} + +// String returns the string representation +func (s NoncurrentVersionTransition) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s NoncurrentVersionTransition) GoString() string { + return s.String() +} + +// Container for specifying the notification configuration of the bucket. If +// this element is empty, notifications are turned off on the bucket. +type NotificationConfiguration struct { + _ struct{} `type:"structure"` + + LambdaFunctionConfigurations []*LambdaFunctionConfiguration `locationName:"CloudFunctionConfiguration" type:"list" flattened:"true"` + + QueueConfigurations []*QueueConfiguration `locationName:"QueueConfiguration" type:"list" flattened:"true"` + + TopicConfigurations []*TopicConfiguration `locationName:"TopicConfiguration" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s NotificationConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s NotificationConfiguration) GoString() string { + return s.String() +} + +type NotificationConfigurationDeprecated struct { + _ struct{} `type:"structure"` + + CloudFunctionConfiguration *CloudFunctionConfiguration `type:"structure"` + + QueueConfiguration *QueueConfigurationDeprecated `type:"structure"` + + TopicConfiguration *TopicConfigurationDeprecated `type:"structure"` +} + +// String returns the string representation +func (s NotificationConfigurationDeprecated) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s NotificationConfigurationDeprecated) GoString() string { + return s.String() +} + +// Container for object key name filtering rules. For information about key +// name filtering, go to Configuring Event Notifications (http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) +// in the Amazon Simple Storage Service Developer Guide. +type NotificationConfigurationFilter struct { + _ struct{} `type:"structure"` + + // Container for object key name prefix and suffix filtering rules. + Key *KeyFilter `locationName:"S3Key" type:"structure"` +} + +// String returns the string representation +func (s NotificationConfigurationFilter) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s NotificationConfigurationFilter) GoString() string { + return s.String() +} + +type Object struct { + _ struct{} `type:"structure"` + + ETag *string `type:"string"` + + Key *string `min:"1" type:"string"` + + LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + Owner *Owner `type:"structure"` + + Size *int64 `type:"integer"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"ObjectStorageClass"` +} + +// String returns the string representation +func (s Object) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Object) GoString() string { + return s.String() +} + +type ObjectIdentifier struct { + _ struct{} `type:"structure"` + + // Key name of the object to delete. + Key *string `min:"1" type:"string" required:"true"` + + // VersionId for the specific version of the object to delete. + VersionId *string `type:"string"` +} + +// String returns the string representation +func (s ObjectIdentifier) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ObjectIdentifier) GoString() string { + return s.String() +} + +type ObjectVersion struct { + _ struct{} `type:"structure"` + + ETag *string `type:"string"` + + // Specifies whether the object is (true) or is not (false) the latest version + // of an object. + IsLatest *bool `type:"boolean"` + + // The object key. + Key *string `min:"1" type:"string"` + + // Date and time the object was last modified. + LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + Owner *Owner `type:"structure"` + + // Size in bytes of the object. + Size *int64 `type:"integer"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"ObjectVersionStorageClass"` + + // Version ID of an object. + VersionId *string `type:"string"` +} + +// String returns the string representation +func (s ObjectVersion) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ObjectVersion) GoString() string { + return s.String() +} + +type Owner struct { + _ struct{} `type:"structure"` + + DisplayName *string `type:"string"` + + ID *string `type:"string"` +} + +// String returns the string representation +func (s Owner) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Owner) GoString() string { + return s.String() +} + +type Part struct { + _ struct{} `type:"structure"` + + // Entity tag returned when the part was uploaded. + ETag *string `type:"string"` + + // Date and time at which the part was uploaded. + LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + // Part number identifying the part. This is a positive integer between 1 and + // 10,000. + PartNumber *int64 `type:"integer"` + + // Size of the uploaded part data. + Size *int64 `type:"integer"` +} + +// String returns the string representation +func (s Part) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Part) GoString() string { + return s.String() +} + +type PutBucketAclInput struct { + _ struct{} `type:"structure" payload:"AccessControlPolicy"` + + // The canned ACL to apply to the bucket. + ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"BucketCannedACL"` + + AccessControlPolicy *AccessControlPolicy `locationName:"AccessControlPolicy" type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Allows grantee the read, write, read ACP, and write ACP permissions on the + // bucket. + GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"` + + // Allows grantee to list the objects in the bucket. + GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"` + + // Allows grantee to read the bucket ACL. + GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"` + + // Allows grantee to create, overwrite, and delete any object in the bucket. + GrantWrite *string `location:"header" locationName:"x-amz-grant-write" type:"string"` + + // Allows grantee to write the ACL for the applicable bucket. + GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` +} + +// String returns the string representation +func (s PutBucketAclInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketAclInput) GoString() string { + return s.String() +} + +type PutBucketAclOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketAclOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketAclOutput) GoString() string { + return s.String() +} + +type PutBucketCorsInput struct { + _ struct{} `type:"structure" payload:"CORSConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + CORSConfiguration *CORSConfiguration `locationName:"CORSConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketCorsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketCorsInput) GoString() string { + return s.String() +} + +type PutBucketCorsOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketCorsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketCorsOutput) GoString() string { + return s.String() +} + +type PutBucketLifecycleConfigurationInput struct { + _ struct{} `type:"structure" payload:"LifecycleConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + LifecycleConfiguration *BucketLifecycleConfiguration `locationName:"LifecycleConfiguration" type:"structure"` +} + +// String returns the string representation +func (s PutBucketLifecycleConfigurationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketLifecycleConfigurationInput) GoString() string { + return s.String() +} + +type PutBucketLifecycleConfigurationOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketLifecycleConfigurationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketLifecycleConfigurationOutput) GoString() string { + return s.String() +} + +type PutBucketLifecycleInput struct { + _ struct{} `type:"structure" payload:"LifecycleConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + LifecycleConfiguration *LifecycleConfiguration `locationName:"LifecycleConfiguration" type:"structure"` +} + +// String returns the string representation +func (s PutBucketLifecycleInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketLifecycleInput) GoString() string { + return s.String() +} + +type PutBucketLifecycleOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketLifecycleOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketLifecycleOutput) GoString() string { + return s.String() +} + +type PutBucketLoggingInput struct { + _ struct{} `type:"structure" payload:"BucketLoggingStatus"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + BucketLoggingStatus *BucketLoggingStatus `locationName:"BucketLoggingStatus" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketLoggingInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketLoggingInput) GoString() string { + return s.String() +} + +type PutBucketLoggingOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketLoggingOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketLoggingOutput) GoString() string { + return s.String() +} + +type PutBucketNotificationConfigurationInput struct { + _ struct{} `type:"structure" payload:"NotificationConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Container for specifying the notification configuration of the bucket. If + // this element is empty, notifications are turned off on the bucket. + NotificationConfiguration *NotificationConfiguration `locationName:"NotificationConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketNotificationConfigurationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketNotificationConfigurationInput) GoString() string { + return s.String() +} + +type PutBucketNotificationConfigurationOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketNotificationConfigurationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketNotificationConfigurationOutput) GoString() string { + return s.String() +} + +type PutBucketNotificationInput struct { + _ struct{} `type:"structure" payload:"NotificationConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + NotificationConfiguration *NotificationConfigurationDeprecated `locationName:"NotificationConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketNotificationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketNotificationInput) GoString() string { + return s.String() +} + +type PutBucketNotificationOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketNotificationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketNotificationOutput) GoString() string { + return s.String() +} + +type PutBucketPolicyInput struct { + _ struct{} `type:"structure" payload:"Policy"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // The bucket policy as a JSON document. + Policy *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s PutBucketPolicyInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketPolicyInput) GoString() string { + return s.String() +} + +type PutBucketPolicyOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketPolicyOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketPolicyOutput) GoString() string { + return s.String() +} + +type PutBucketReplicationInput struct { + _ struct{} `type:"structure" payload:"ReplicationConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Container for replication rules. You can add as many as 1,000 rules. Total + // replication configuration size can be up to 2 MB. + ReplicationConfiguration *ReplicationConfiguration `locationName:"ReplicationConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketReplicationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketReplicationInput) GoString() string { + return s.String() +} + +type PutBucketReplicationOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketReplicationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketReplicationOutput) GoString() string { + return s.String() +} + +type PutBucketRequestPaymentInput struct { + _ struct{} `type:"structure" payload:"RequestPaymentConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + RequestPaymentConfiguration *RequestPaymentConfiguration `locationName:"RequestPaymentConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketRequestPaymentInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketRequestPaymentInput) GoString() string { + return s.String() +} + +type PutBucketRequestPaymentOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketRequestPaymentOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketRequestPaymentOutput) GoString() string { + return s.String() +} + +type PutBucketTaggingInput struct { + _ struct{} `type:"structure" payload:"Tagging"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Tagging *Tagging `locationName:"Tagging" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketTaggingInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketTaggingInput) GoString() string { + return s.String() +} + +type PutBucketTaggingOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketTaggingOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketTaggingOutput) GoString() string { + return s.String() +} + +type PutBucketVersioningInput struct { + _ struct{} `type:"structure" payload:"VersioningConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // The concatenation of the authentication device's serial number, a space, + // and the value that is displayed on your authentication device. + MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"` + + VersioningConfiguration *VersioningConfiguration `locationName:"VersioningConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketVersioningInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketVersioningInput) GoString() string { + return s.String() +} + +type PutBucketVersioningOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketVersioningOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketVersioningOutput) GoString() string { + return s.String() +} + +type PutBucketWebsiteInput struct { + _ struct{} `type:"structure" payload:"WebsiteConfiguration"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + WebsiteConfiguration *WebsiteConfiguration `locationName:"WebsiteConfiguration" type:"structure" required:"true"` +} + +// String returns the string representation +func (s PutBucketWebsiteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketWebsiteInput) GoString() string { + return s.String() +} + +type PutBucketWebsiteOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PutBucketWebsiteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutBucketWebsiteOutput) GoString() string { + return s.String() +} + +type PutObjectAclInput struct { + _ struct{} `type:"structure" payload:"AccessControlPolicy"` + + // The canned ACL to apply to the object. + ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` + + AccessControlPolicy *AccessControlPolicy `locationName:"AccessControlPolicy" type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Allows grantee the read, write, read ACP, and write ACP permissions on the + // bucket. + GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"` + + // Allows grantee to list the objects in the bucket. + GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"` + + // Allows grantee to read the bucket ACL. + GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"` + + // Allows grantee to create, overwrite, and delete any object in the bucket. + GrantWrite *string `location:"header" locationName:"x-amz-grant-write" type:"string"` + + // Allows grantee to write the ACL for the applicable bucket. + GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` +} + +// String returns the string representation +func (s PutObjectAclInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutObjectAclInput) GoString() string { + return s.String() +} + +type PutObjectAclOutput struct { + _ struct{} `type:"structure"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` +} + +// String returns the string representation +func (s PutObjectAclOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutObjectAclOutput) GoString() string { + return s.String() +} + +type PutObjectInput struct { + _ struct{} `type:"structure" payload:"Body"` + + // The canned ACL to apply to the object. + ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` + + // Object data. + Body io.ReadSeeker `type:"blob"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Specifies caching behavior along the request/reply chain. + CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"` + + // Specifies presentational information for the object. + ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"` + + // Specifies what content encodings have been applied to the object and thus + // what decoding mechanisms must be applied to obtain the media-type referenced + // by the Content-Type header field. + ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"` + + // The language the content is in. + ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"` + + // Size of the body in bytes. This parameter is useful when the size of the + // body cannot be determined automatically. + ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"` + + // A standard MIME type describing the format of the object data. + ContentType *string `location:"header" locationName:"Content-Type" type:"string"` + + // The date and time at which the object is no longer cacheable. + Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"` + + // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object. + GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"` + + // Allows grantee to read the object data and its metadata. + GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"` + + // Allows grantee to read the object ACL. + GrantReadACP *string `location:"header" locationName:"x-amz-grant-read-acp" type:"string"` + + // Allows grantee to write the ACL for the applicable object. + GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // A map of metadata to store with the object in S3. + Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // Specifies the AWS KMS key ID to use for object encryption. All GET and PUT + // requests for an object protected by AWS KMS will fail if not made via SSL + // or using SigV4. Documentation on configuring any of the officially supported + // AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // The type of storage to use for the object. Defaults to 'STANDARD'. + StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string" enum:"StorageClass"` + + // If the bucket is configured as a website, redirects requests for this object + // to another object in the same bucket or to an external URL. Amazon S3 stores + // the value of this header in the object metadata. + WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` +} + +// String returns the string representation +func (s PutObjectInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutObjectInput) GoString() string { + return s.String() +} + +type PutObjectOutput struct { + _ struct{} `type:"structure"` + + // Entity tag for the uploaded object. + ETag *string `location:"header" locationName:"ETag" type:"string"` + + // If the object expiration is configured, this will contain the expiration + // date (expiry-date) and rule ID (rule-id). The value of rule-id is URL encoded. + Expiration *string `location:"header" locationName:"x-amz-expiration" type:"string"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` + + // Version of the object. + VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` +} + +// String returns the string representation +func (s PutObjectOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutObjectOutput) GoString() string { + return s.String() +} + +// Container for specifying an configuration when you want Amazon S3 to publish +// events to an Amazon Simple Queue Service (Amazon SQS) queue. +type QueueConfiguration struct { + _ struct{} `type:"structure"` + + Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"` + + // Container for object key name filtering rules. For information about key + // name filtering, go to Configuring Event Notifications (http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) + // in the Amazon Simple Storage Service Developer Guide. + Filter *NotificationConfigurationFilter `type:"structure"` + + // Optional unique identifier for configurations in a notification configuration. + // If you don't provide one, Amazon S3 will assign an ID. + Id *string `type:"string"` + + // Amazon SQS queue ARN to which Amazon S3 will publish a message when it detects + // events of specified type. + QueueArn *string `locationName:"Queue" type:"string" required:"true"` +} + +// String returns the string representation +func (s QueueConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s QueueConfiguration) GoString() string { + return s.String() +} + +type QueueConfigurationDeprecated struct { + _ struct{} `type:"structure"` + + // Bucket event for which to send notifications. + Event *string `type:"string" enum:"Event"` + + Events []*string `locationName:"Event" type:"list" flattened:"true"` + + // Optional unique identifier for configurations in a notification configuration. + // If you don't provide one, Amazon S3 will assign an ID. + Id *string `type:"string"` + + Queue *string `type:"string"` +} + +// String returns the string representation +func (s QueueConfigurationDeprecated) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s QueueConfigurationDeprecated) GoString() string { + return s.String() +} + +type Redirect struct { + _ struct{} `type:"structure"` + + // The host name to use in the redirect request. + HostName *string `type:"string"` + + // The HTTP redirect code to use on the response. Not required if one of the + // siblings is present. + HttpRedirectCode *string `type:"string"` + + // Protocol to use (http, https) when redirecting requests. The default is the + // protocol that is used in the original request. + Protocol *string `type:"string" enum:"Protocol"` + + // The object key prefix to use in the redirect request. For example, to redirect + // requests for all pages with prefix docs/ (objects in the docs/ folder) to + // documents/, you can set a condition block with KeyPrefixEquals set to docs/ + // and in the Redirect set ReplaceKeyPrefixWith to /documents. Not required + // if one of the siblings is present. Can be present only if ReplaceKeyWith + // is not provided. + ReplaceKeyPrefixWith *string `type:"string"` + + // The specific object key to use in the redirect request. For example, redirect + // request to error.html. Not required if one of the sibling is present. Can + // be present only if ReplaceKeyPrefixWith is not provided. + ReplaceKeyWith *string `type:"string"` +} + +// String returns the string representation +func (s Redirect) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Redirect) GoString() string { + return s.String() +} + +type RedirectAllRequestsTo struct { + _ struct{} `type:"structure"` + + // Name of the host where requests will be redirected. + HostName *string `type:"string" required:"true"` + + // Protocol to use (http, https) when redirecting requests. The default is the + // protocol that is used in the original request. + Protocol *string `type:"string" enum:"Protocol"` +} + +// String returns the string representation +func (s RedirectAllRequestsTo) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RedirectAllRequestsTo) GoString() string { + return s.String() +} + +// Container for replication rules. You can add as many as 1,000 rules. Total +// replication configuration size can be up to 2 MB. +type ReplicationConfiguration struct { + _ struct{} `type:"structure"` + + // Amazon Resource Name (ARN) of an IAM role for Amazon S3 to assume when replicating + // the objects. + Role *string `type:"string" required:"true"` + + // Container for information about a particular replication rule. Replication + // configuration must have at least one rule and can contain up to 1,000 rules. + Rules []*ReplicationRule `locationName:"Rule" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s ReplicationConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ReplicationConfiguration) GoString() string { + return s.String() +} + +type ReplicationRule struct { + _ struct{} `type:"structure"` + + Destination *Destination `type:"structure" required:"true"` + + // Unique identifier for the rule. The value cannot be longer than 255 characters. + ID *string `type:"string"` + + // Object keyname prefix identifying one or more objects to which the rule applies. + // Maximum prefix length can be up to 1,024 characters. Overlapping prefixes + // are not supported. + Prefix *string `type:"string" required:"true"` + + // The rule is ignored if status is not Enabled. + Status *string `type:"string" required:"true" enum:"ReplicationRuleStatus"` +} + +// String returns the string representation +func (s ReplicationRule) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ReplicationRule) GoString() string { + return s.String() +} + +type RequestPaymentConfiguration struct { + _ struct{} `type:"structure"` + + // Specifies who pays for the download and request fees. + Payer *string `type:"string" required:"true" enum:"Payer"` +} + +// String returns the string representation +func (s RequestPaymentConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RequestPaymentConfiguration) GoString() string { + return s.String() +} + +type RestoreObjectInput struct { + _ struct{} `type:"structure" payload:"RestoreRequest"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + RestoreRequest *RestoreRequest `locationName:"RestoreRequest" type:"structure"` + + VersionId *string `location:"querystring" locationName:"versionId" type:"string"` +} + +// String returns the string representation +func (s RestoreObjectInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RestoreObjectInput) GoString() string { + return s.String() +} + +type RestoreObjectOutput struct { + _ struct{} `type:"structure"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` +} + +// String returns the string representation +func (s RestoreObjectOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RestoreObjectOutput) GoString() string { + return s.String() +} + +type RestoreRequest struct { + _ struct{} `type:"structure"` + + // Lifetime of the active copy in days + Days *int64 `type:"integer" required:"true"` +} + +// String returns the string representation +func (s RestoreRequest) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RestoreRequest) GoString() string { + return s.String() +} + +type RoutingRule struct { + _ struct{} `type:"structure"` + + // A container for describing a condition that must be met for the specified + // redirect to apply. For example, 1. If request is for pages in the /docs folder, + // redirect to the /documents folder. 2. If request results in HTTP error 4xx, + // redirect request to another host where you might process the error. + Condition *Condition `type:"structure"` + + // Container for redirect information. You can redirect requests to another + // host, to another page, or with another protocol. In the event of an error, + // you can can specify a different error code to return. + Redirect *Redirect `type:"structure" required:"true"` +} + +// String returns the string representation +func (s RoutingRule) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RoutingRule) GoString() string { + return s.String() +} + +type Rule struct { + _ struct{} `type:"structure"` + + Expiration *LifecycleExpiration `type:"structure"` + + // Unique identifier for the rule. The value cannot be longer than 255 characters. + ID *string `type:"string"` + + // Specifies when noncurrent object versions expire. Upon expiration, Amazon + // S3 permanently deletes the noncurrent object versions. You set this lifecycle + // configuration action on a bucket that has versioning enabled (or suspended) + // to request that Amazon S3 delete noncurrent object versions at a specific + // period in the object's lifetime. + NoncurrentVersionExpiration *NoncurrentVersionExpiration `type:"structure"` + + // Container for the transition rule that describes when noncurrent objects + // transition to the STANDARD_IA or GLACIER storage class. If your bucket is + // versioning-enabled (or versioning is suspended), you can set this action + // to request that Amazon S3 transition noncurrent object versions to the STANDARD_IA + // or GLACIER storage class at a specific period in the object's lifetime. + NoncurrentVersionTransition *NoncurrentVersionTransition `type:"structure"` + + // Prefix identifying one or more objects to which the rule applies. + Prefix *string `type:"string" required:"true"` + + // If 'Enabled', the rule is currently being applied. If 'Disabled', the rule + // is not currently being applied. + Status *string `type:"string" required:"true" enum:"ExpirationStatus"` + + Transition *Transition `type:"structure"` +} + +// String returns the string representation +func (s Rule) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Rule) GoString() string { + return s.String() +} + +type Tag struct { + _ struct{} `type:"structure"` + + // Name of the tag. + Key *string `min:"1" type:"string" required:"true"` + + // Value of the tag. + Value *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s Tag) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Tag) GoString() string { + return s.String() +} + +type Tagging struct { + _ struct{} `type:"structure"` + + TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"` +} + +// String returns the string representation +func (s Tagging) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Tagging) GoString() string { + return s.String() +} + +type TargetGrant struct { + _ struct{} `type:"structure"` + + Grantee *Grantee `type:"structure"` + + // Logging permissions assigned to the Grantee for the bucket. + Permission *string `type:"string" enum:"BucketLogsPermission"` +} + +// String returns the string representation +func (s TargetGrant) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TargetGrant) GoString() string { + return s.String() +} + +// Container for specifying the configuration when you want Amazon S3 to publish +// events to an Amazon Simple Notification Service (Amazon SNS) topic. +type TopicConfiguration struct { + _ struct{} `type:"structure"` + + Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"` + + // Container for object key name filtering rules. For information about key + // name filtering, go to Configuring Event Notifications (http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) + // in the Amazon Simple Storage Service Developer Guide. + Filter *NotificationConfigurationFilter `type:"structure"` + + // Optional unique identifier for configurations in a notification configuration. + // If you don't provide one, Amazon S3 will assign an ID. + Id *string `type:"string"` + + // Amazon SNS topic ARN to which Amazon S3 will publish a message when it detects + // events of specified type. + TopicArn *string `locationName:"Topic" type:"string" required:"true"` +} + +// String returns the string representation +func (s TopicConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TopicConfiguration) GoString() string { + return s.String() +} + +type TopicConfigurationDeprecated struct { + _ struct{} `type:"structure"` + + // Bucket event for which to send notifications. + Event *string `type:"string" enum:"Event"` + + Events []*string `locationName:"Event" type:"list" flattened:"true"` + + // Optional unique identifier for configurations in a notification configuration. + // If you don't provide one, Amazon S3 will assign an ID. + Id *string `type:"string"` + + // Amazon SNS topic to which Amazon S3 will publish a message to report the + // specified events for the bucket. + Topic *string `type:"string"` +} + +// String returns the string representation +func (s TopicConfigurationDeprecated) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TopicConfigurationDeprecated) GoString() string { + return s.String() +} + +type Transition struct { + _ struct{} `type:"structure"` + + // Indicates at what date the object is to be moved or deleted. Should be in + // GMT ISO 8601 Format. + Date *time.Time `type:"timestamp" timestampFormat:"iso8601"` + + // Indicates the lifetime, in days, of the objects that are subject to the rule. + // The value must be a non-zero positive integer. + Days *int64 `type:"integer"` + + // The class of storage used to store the object. + StorageClass *string `type:"string" enum:"TransitionStorageClass"` +} + +// String returns the string representation +func (s Transition) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Transition) GoString() string { + return s.String() +} + +type UploadPartCopyInput struct { + _ struct{} `type:"structure"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // The name of the source bucket and key name of the source object, separated + // by a slash (/). Must be URL-encoded. + CopySource *string `location:"header" locationName:"x-amz-copy-source" type:"string" required:"true"` + + // Copies the object if its entity tag (ETag) matches the specified tag. + CopySourceIfMatch *string `location:"header" locationName:"x-amz-copy-source-if-match" type:"string"` + + // Copies the object if it has been modified since the specified time. + CopySourceIfModifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-modified-since" type:"timestamp" timestampFormat:"rfc822"` + + // Copies the object if its entity tag (ETag) is different than the specified + // ETag. + CopySourceIfNoneMatch *string `location:"header" locationName:"x-amz-copy-source-if-none-match" type:"string"` + + // Copies the object if it hasn't been modified since the specified time. + CopySourceIfUnmodifiedSince *time.Time `location:"header" locationName:"x-amz-copy-source-if-unmodified-since" type:"timestamp" timestampFormat:"rfc822"` + + // The range of bytes to copy from the source object. The range value must use + // the form bytes=first-last, where the first and last are the zero-based byte + // offsets to copy. For example, bytes=0-9 indicates that you want to copy the + // first ten bytes of the source. You can copy a range only if the source object + // is greater than 5 GB. + CopySourceRange *string `location:"header" locationName:"x-amz-copy-source-range" type:"string"` + + // Specifies the algorithm to use when decrypting the source object (e.g., AES256). + CopySourceSSECustomerAlgorithm *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use to decrypt + // the source object. The encryption key provided in this header must be one + // that was used when the source object was created. + CopySourceSSECustomerKey *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + CopySourceSSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-copy-source-server-side-encryption-customer-key-MD5" type:"string"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Part number of part being copied. This is a positive integer between 1 and + // 10,000. + PartNumber *int64 `location:"querystring" locationName:"partNumber" type:"integer" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. This must be the same encryption key specified in the initiate multipart + // upload request. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // Upload ID identifying the multipart upload whose part is being copied. + UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` +} + +// String returns the string representation +func (s UploadPartCopyInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UploadPartCopyInput) GoString() string { + return s.String() +} + +type UploadPartCopyOutput struct { + _ struct{} `type:"structure" payload:"CopyPartResult"` + + CopyPartResult *CopyPartResult `type:"structure"` + + // The version of the source object that was copied, if you have enabled versioning + // on the source bucket. + CopySourceVersionId *string `location:"header" locationName:"x-amz-copy-source-version-id" type:"string"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` +} + +// String returns the string representation +func (s UploadPartCopyOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UploadPartCopyOutput) GoString() string { + return s.String() +} + +type UploadPartInput struct { + _ struct{} `type:"structure" payload:"Body"` + + Body io.ReadSeeker `type:"blob"` + + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` + + // Size of the body in bytes. This parameter is useful when the size of the + // body cannot be determined automatically. + ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"` + + Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` + + // Part number of part being uploaded. This is a positive integer between 1 + // and 10,000. + PartNumber *int64 `location:"querystring" locationName:"partNumber" type:"integer" required:"true"` + + // Confirms that the requester knows that she or he will be charged for the + // request. Bucket owners need not specify this parameter in their requests. + // Documentation on downloading objects from requester pays buckets can be found + // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html + RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` + + // Specifies the algorithm to use to when encrypting the object (e.g., AES256). + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // Specifies the customer-provided encryption key for Amazon S3 to use in encrypting + // data. This value is used to store the object and then it is discarded; Amazon + // does not store the encryption key. The key must be appropriate for use with + // the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm + // header. This must be the same encryption key specified in the initiate multipart + // upload request. + SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"` + + // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. + // Amazon S3 uses this header for a message integrity check to ensure the encryption + // key was transmitted without error. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // Upload ID identifying the multipart upload whose part is being uploaded. + UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` +} + +// String returns the string representation +func (s UploadPartInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UploadPartInput) GoString() string { + return s.String() +} + +type UploadPartOutput struct { + _ struct{} `type:"structure"` + + // Entity tag for the uploaded object. + ETag *string `location:"header" locationName:"ETag" type:"string"` + + // If present, indicates that the requester was successfully charged for the + // request. + RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header confirming the encryption algorithm + // used. + SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"` + + // If server-side encryption with a customer-provided encryption key was requested, + // the response will include this header to provide round trip message integrity + // verification of the customer-provided encryption key. + SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"` + + // If present, specifies the ID of the AWS Key Management Service (KMS) master + // encryption key that was used for the object. + SSEKMSKeyId *string `location:"header" locationName:"x-amz-server-side-encryption-aws-kms-key-id" type:"string"` + + // The Server-side encryption algorithm used when storing this object in S3 + // (e.g., AES256, aws:kms). + ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` +} + +// String returns the string representation +func (s UploadPartOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UploadPartOutput) GoString() string { + return s.String() +} + +type VersioningConfiguration struct { + _ struct{} `type:"structure"` + + // Specifies whether MFA delete is enabled in the bucket versioning configuration. + // This element is only returned if the bucket has been configured with MFA + // delete. If the bucket has never been so configured, this element is not returned. + MFADelete *string `locationName:"MfaDelete" type:"string" enum:"MFADelete"` + + // The versioning state of the bucket. + Status *string `type:"string" enum:"BucketVersioningStatus"` +} + +// String returns the string representation +func (s VersioningConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VersioningConfiguration) GoString() string { + return s.String() +} + +type WebsiteConfiguration struct { + _ struct{} `type:"structure"` + + ErrorDocument *ErrorDocument `type:"structure"` + + IndexDocument *IndexDocument `type:"structure"` + + RedirectAllRequestsTo *RedirectAllRequestsTo `type:"structure"` + + RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"` +} + +// String returns the string representation +func (s WebsiteConfiguration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s WebsiteConfiguration) GoString() string { + return s.String() +} + +const ( + // @enum BucketCannedACL + BucketCannedACLPrivate = "private" + // @enum BucketCannedACL + BucketCannedACLPublicRead = "public-read" + // @enum BucketCannedACL + BucketCannedACLPublicReadWrite = "public-read-write" + // @enum BucketCannedACL + BucketCannedACLAuthenticatedRead = "authenticated-read" +) + +const ( + // @enum BucketLocationConstraint + BucketLocationConstraintEu = "EU" + // @enum BucketLocationConstraint + BucketLocationConstraintEuWest1 = "eu-west-1" + // @enum BucketLocationConstraint + BucketLocationConstraintUsWest1 = "us-west-1" + // @enum BucketLocationConstraint + BucketLocationConstraintUsWest2 = "us-west-2" + // @enum BucketLocationConstraint + BucketLocationConstraintApSoutheast1 = "ap-southeast-1" + // @enum BucketLocationConstraint + BucketLocationConstraintApSoutheast2 = "ap-southeast-2" + // @enum BucketLocationConstraint + BucketLocationConstraintApNortheast1 = "ap-northeast-1" + // @enum BucketLocationConstraint + BucketLocationConstraintSaEast1 = "sa-east-1" + // @enum BucketLocationConstraint + BucketLocationConstraintCnNorth1 = "cn-north-1" + // @enum BucketLocationConstraint + BucketLocationConstraintEuCentral1 = "eu-central-1" +) + +const ( + // @enum BucketLogsPermission + BucketLogsPermissionFullControl = "FULL_CONTROL" + // @enum BucketLogsPermission + BucketLogsPermissionRead = "READ" + // @enum BucketLogsPermission + BucketLogsPermissionWrite = "WRITE" +) + +const ( + // @enum BucketVersioningStatus + BucketVersioningStatusEnabled = "Enabled" + // @enum BucketVersioningStatus + BucketVersioningStatusSuspended = "Suspended" +) + +// Requests Amazon S3 to encode the object keys in the response and specifies +// the encoding method to use. An object key may contain any Unicode character; +// however, XML 1.0 parser cannot parse some characters, such as characters +// with an ASCII value from 0 to 10. For characters that are not supported in +// XML 1.0, you can add this parameter to request that Amazon S3 encode the +// keys in the response. +const ( + // @enum EncodingType + EncodingTypeUrl = "url" +) + +// Bucket event for which to send notifications. +const ( + // @enum Event + EventS3ReducedRedundancyLostObject = "s3:ReducedRedundancyLostObject" + // @enum Event + EventS3ObjectCreated = "s3:ObjectCreated:*" + // @enum Event + EventS3ObjectCreatedPut = "s3:ObjectCreated:Put" + // @enum Event + EventS3ObjectCreatedPost = "s3:ObjectCreated:Post" + // @enum Event + EventS3ObjectCreatedCopy = "s3:ObjectCreated:Copy" + // @enum Event + EventS3ObjectCreatedCompleteMultipartUpload = "s3:ObjectCreated:CompleteMultipartUpload" + // @enum Event + EventS3ObjectRemoved = "s3:ObjectRemoved:*" + // @enum Event + EventS3ObjectRemovedDelete = "s3:ObjectRemoved:Delete" + // @enum Event + EventS3ObjectRemovedDeleteMarkerCreated = "s3:ObjectRemoved:DeleteMarkerCreated" +) + +const ( + // @enum ExpirationStatus + ExpirationStatusEnabled = "Enabled" + // @enum ExpirationStatus + ExpirationStatusDisabled = "Disabled" +) + +const ( + // @enum FilterRuleName + FilterRuleNamePrefix = "prefix" + // @enum FilterRuleName + FilterRuleNameSuffix = "suffix" +) + +const ( + // @enum MFADelete + MFADeleteEnabled = "Enabled" + // @enum MFADelete + MFADeleteDisabled = "Disabled" +) + +const ( + // @enum MFADeleteStatus + MFADeleteStatusEnabled = "Enabled" + // @enum MFADeleteStatus + MFADeleteStatusDisabled = "Disabled" +) + +const ( + // @enum MetadataDirective + MetadataDirectiveCopy = "COPY" + // @enum MetadataDirective + MetadataDirectiveReplace = "REPLACE" +) + +const ( + // @enum ObjectCannedACL + ObjectCannedACLPrivate = "private" + // @enum ObjectCannedACL + ObjectCannedACLPublicRead = "public-read" + // @enum ObjectCannedACL + ObjectCannedACLPublicReadWrite = "public-read-write" + // @enum ObjectCannedACL + ObjectCannedACLAuthenticatedRead = "authenticated-read" + // @enum ObjectCannedACL + ObjectCannedACLAwsExecRead = "aws-exec-read" + // @enum ObjectCannedACL + ObjectCannedACLBucketOwnerRead = "bucket-owner-read" + // @enum ObjectCannedACL + ObjectCannedACLBucketOwnerFullControl = "bucket-owner-full-control" +) + +const ( + // @enum ObjectStorageClass + ObjectStorageClassStandard = "STANDARD" + // @enum ObjectStorageClass + ObjectStorageClassReducedRedundancy = "REDUCED_REDUNDANCY" + // @enum ObjectStorageClass + ObjectStorageClassGlacier = "GLACIER" +) + +const ( + // @enum ObjectVersionStorageClass + ObjectVersionStorageClassStandard = "STANDARD" +) + +const ( + // @enum Payer + PayerRequester = "Requester" + // @enum Payer + PayerBucketOwner = "BucketOwner" +) + +const ( + // @enum Permission + PermissionFullControl = "FULL_CONTROL" + // @enum Permission + PermissionWrite = "WRITE" + // @enum Permission + PermissionWriteAcp = "WRITE_ACP" + // @enum Permission + PermissionRead = "READ" + // @enum Permission + PermissionReadAcp = "READ_ACP" +) + +const ( + // @enum Protocol + ProtocolHttp = "http" + // @enum Protocol + ProtocolHttps = "https" +) + +const ( + // @enum ReplicationRuleStatus + ReplicationRuleStatusEnabled = "Enabled" + // @enum ReplicationRuleStatus + ReplicationRuleStatusDisabled = "Disabled" +) + +const ( + // @enum ReplicationStatus + ReplicationStatusComplete = "COMPLETE" + // @enum ReplicationStatus + ReplicationStatusPending = "PENDING" + // @enum ReplicationStatus + ReplicationStatusFailed = "FAILED" + // @enum ReplicationStatus + ReplicationStatusReplica = "REPLICA" +) + +// If present, indicates that the requester was successfully charged for the +// request. +const ( + // @enum RequestCharged + RequestChargedRequester = "requester" +) + +// Confirms that the requester knows that she or he will be charged for the +// request. Bucket owners need not specify this parameter in their requests. +// Documentation on downloading objects from requester pays buckets can be found +// at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html +const ( + // @enum RequestPayer + RequestPayerRequester = "requester" +) + +const ( + // @enum ServerSideEncryption + ServerSideEncryptionAes256 = "AES256" + // @enum ServerSideEncryption + ServerSideEncryptionAwsKms = "aws:kms" +) + +const ( + // @enum StorageClass + StorageClassStandard = "STANDARD" + // @enum StorageClass + StorageClassReducedRedundancy = "REDUCED_REDUNDANCY" + // @enum StorageClass + StorageClassStandardIa = "STANDARD_IA" +) + +const ( + // @enum TransitionStorageClass + TransitionStorageClassGlacier = "GLACIER" + // @enum TransitionStorageClass + TransitionStorageClassStandardIa = "STANDARD_IA" +) + +const ( + // @enum Type + TypeCanonicalUser = "CanonicalUser" + // @enum Type + TypeAmazonCustomerByEmail = "AmazonCustomerByEmail" + // @enum Type + TypeGroup = "Group" +) diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location.go b/vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location.go new file mode 100644 index 00000000..c3a2702d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location.go @@ -0,0 +1,43 @@ +package s3 + +import ( + "io/ioutil" + "regexp" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" +) + +var reBucketLocation = regexp.MustCompile(`>([^<>]+)<\/Location`) + +func buildGetBucketLocation(r *request.Request) { + if r.DataFilled() { + out := r.Data.(*GetBucketLocationOutput) + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "failed reading response body", err) + return + } + + match := reBucketLocation.FindSubmatch(b) + if len(match) > 1 { + loc := string(match[1]) + out.LocationConstraint = &loc + } + } +} + +func populateLocationConstraint(r *request.Request) { + if r.ParamsFilled() && aws.StringValue(r.Config.Region) != "us-east-1" { + in := r.Params.(*CreateBucketInput) + if in.CreateBucketConfiguration == nil { + r.Params = awsutil.CopyOf(r.Params) + in = r.Params.(*CreateBucketInput) + in.CreateBucketConfiguration = &CreateBucketConfiguration{ + LocationConstraint: r.Config.Region, + } + } + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go b/vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go new file mode 100644 index 00000000..9fc5df94 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go @@ -0,0 +1,36 @@ +package s3 + +import ( + "crypto/md5" + "encoding/base64" + "io" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// contentMD5 computes and sets the HTTP Content-MD5 header for requests that +// require it. +func contentMD5(r *request.Request) { + h := md5.New() + + // hash the body. seek back to the first position after reading to reset + // the body for transmission. copy errors may be assumed to be from the + // body. + _, err := io.Copy(h, r.Body) + if err != nil { + r.Error = awserr.New("ContentMD5", "failed to read body", err) + return + } + _, err = r.Body.Seek(0, 0) + if err != nil { + r.Error = awserr.New("ContentMD5", "failed to seek body", err) + return + } + + // encode the md5 checksum in base64 and set the request header. + sum := h.Sum(nil) + sum64 := make([]byte, base64.StdEncoding.EncodedLen(len(sum))) + base64.StdEncoding.Encode(sum64, sum) + r.HTTPRequest.Header.Set("Content-MD5", string(sum64)) +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/customizations.go b/vendor/github.com/aws/aws-sdk-go/service/s3/customizations.go new file mode 100644 index 00000000..c227f242 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/customizations.go @@ -0,0 +1,37 @@ +package s3 + +import ( + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/request" +) + +func init() { + initClient = func(c *client.Client) { + // Support building custom host-style bucket endpoints + c.Handlers.Build.PushFront(updateHostWithBucket) + + // Require SSL when using SSE keys + c.Handlers.Validate.PushBack(validateSSERequiresSSL) + c.Handlers.Build.PushBack(computeSSEKeys) + + // S3 uses custom error unmarshaling logic + c.Handlers.UnmarshalError.Clear() + c.Handlers.UnmarshalError.PushBack(unmarshalError) + } + + initRequest = func(r *request.Request) { + switch r.Operation.Name { + case opPutBucketCors, opPutBucketLifecycle, opPutBucketPolicy, opPutBucketTagging, opDeleteObjects, opPutBucketLifecycleConfiguration: + // These S3 operations require Content-MD5 to be set + r.Handlers.Build.PushBack(contentMD5) + case opGetBucketLocation: + // GetBucketLocation has custom parsing logic + r.Handlers.Unmarshal.PushFront(buildGetBucketLocation) + case opCreateBucket: + // Auto-populate LocationConstraint with current region + r.Handlers.Validate.PushFront(populateLocationConstraint) + case opCopyObject, opUploadPartCopy, opCompleteMultipartUpload: + r.Handlers.Unmarshal.PushFront(copyMultipartStatusOKUnmarhsalError) + } + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/host_style_bucket.go b/vendor/github.com/aws/aws-sdk-go/service/s3/host_style_bucket.go new file mode 100644 index 00000000..b7cf4f9c --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/host_style_bucket.go @@ -0,0 +1,60 @@ +package s3 + +import ( + "regexp" + "strings" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" +) + +var reDomain = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`) +var reIPAddress = regexp.MustCompile(`^(\d+\.){3}\d+$`) + +// dnsCompatibleBucketName returns true if the bucket name is DNS compatible. +// Buckets created outside of the classic region MUST be DNS compatible. +func dnsCompatibleBucketName(bucket string) bool { + return reDomain.MatchString(bucket) && + !reIPAddress.MatchString(bucket) && + !strings.Contains(bucket, "..") +} + +// hostStyleBucketName returns true if the request should put the bucket in +// the host. This is false if S3ForcePathStyle is explicitly set or if the +// bucket is not DNS compatible. +func hostStyleBucketName(r *request.Request, bucket string) bool { + if aws.BoolValue(r.Config.S3ForcePathStyle) { + return false + } + + // Bucket might be DNS compatible but dots in the hostname will fail + // certificate validation, so do not use host-style. + if r.HTTPRequest.URL.Scheme == "https" && strings.Contains(bucket, ".") { + return false + } + + // GetBucketLocation should be able to be called from any region within + // a partition, and return the associated region of the bucket. + if r.Operation.Name == opGetBucketLocation { + return false + } + + // Use host-style if the bucket is DNS compatible + return dnsCompatibleBucketName(bucket) +} + +func updateHostWithBucket(r *request.Request) { + b, _ := awsutil.ValuesAtPath(r.Params, "Bucket") + if len(b) == 0 { + return + } + + if bucket := b[0].(*string); aws.StringValue(bucket) != "" && hostStyleBucketName(r, *bucket) { + r.HTTPRequest.URL.Host = *bucket + "." + r.HTTPRequest.URL.Host + r.HTTPRequest.URL.Path = strings.Replace(r.HTTPRequest.URL.Path, "/{Bucket}", "", -1) + if r.HTTPRequest.URL.Path == "" { + r.HTTPRequest.URL.Path = "/" + } + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/service.go b/vendor/github.com/aws/aws-sdk-go/service/s3/service.go new file mode 100644 index 00000000..e80d9542 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/service.go @@ -0,0 +1,86 @@ +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + +package s3 + +import ( + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol/restxml" + "github.com/aws/aws-sdk-go/private/signer/v4" +) + +// S3 is a client for Amazon S3. +//The service client's operations are safe to be used concurrently. +// It is not safe to mutate any of the client's properties though. +type S3 struct { + *client.Client +} + +// Used for custom client initialization logic +var initClient func(*client.Client) + +// Used for custom request initialization logic +var initRequest func(*request.Request) + +// A ServiceName is the name of the service the client will make API calls to. +const ServiceName = "s3" + +// New creates a new instance of the S3 client with a session. +// If additional configuration is needed for the client instance use the optional +// aws.Config parameter to add your extra config. +// +// Example: +// // Create a S3 client from just a session. +// svc := s3.New(mySession) +// +// // Create a S3 client with additional configuration +// svc := s3.New(mySession, aws.NewConfig().WithRegion("us-west-2")) +func New(p client.ConfigProvider, cfgs ...*aws.Config) *S3 { + c := p.ClientConfig(ServiceName, cfgs...) + return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion) +} + +// newClient creates, initializes and returns a new service client instance. +func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *S3 { + svc := &S3{ + Client: client.New( + cfg, + metadata.ClientInfo{ + ServiceName: ServiceName, + SigningRegion: signingRegion, + Endpoint: endpoint, + APIVersion: "2006-03-01", + }, + handlers, + ), + } + + // Handlers + svc.Handlers.Sign.PushBack(v4.Sign) + svc.Handlers.Build.PushBack(restxml.Build) + svc.Handlers.Unmarshal.PushBack(restxml.Unmarshal) + svc.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta) + svc.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError) + + // Run custom client initialization if present + if initClient != nil { + initClient(svc.Client) + } + + return svc +} + +// newRequest creates a new request for a S3 operation and runs any +// custom request initialization. +func (c *S3) newRequest(op *request.Operation, params, data interface{}) *request.Request { + req := c.NewRequest(op, params, data) + + // Run custom request initialization if present + if initRequest != nil { + initRequest(req) + } + + return req +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/sse.go b/vendor/github.com/aws/aws-sdk-go/service/s3/sse.go new file mode 100644 index 00000000..268ea2fb --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/sse.go @@ -0,0 +1,44 @@ +package s3 + +import ( + "crypto/md5" + "encoding/base64" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" +) + +var errSSERequiresSSL = awserr.New("ConfigError", "cannot send SSE keys over HTTP.", nil) + +func validateSSERequiresSSL(r *request.Request) { + if r.HTTPRequest.URL.Scheme != "https" { + p, _ := awsutil.ValuesAtPath(r.Params, "SSECustomerKey||CopySourceSSECustomerKey") + if len(p) > 0 { + r.Error = errSSERequiresSSL + } + } +} + +func computeSSEKeys(r *request.Request) { + headers := []string{ + "x-amz-server-side-encryption-customer-key", + "x-amz-copy-source-server-side-encryption-customer-key", + } + + for _, h := range headers { + md5h := h + "-md5" + if key := r.HTTPRequest.Header.Get(h); key != "" { + // Base64-encode the value + b64v := base64.StdEncoding.EncodeToString([]byte(key)) + r.HTTPRequest.Header.Set(h, b64v) + + // Add MD5 if it wasn't computed + if r.HTTPRequest.Header.Get(md5h) == "" { + sum := md5.Sum([]byte(key)) + b64sum := base64.StdEncoding.EncodeToString(sum[:]) + r.HTTPRequest.Header.Set(md5h, b64sum) + } + } + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go b/vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go new file mode 100644 index 00000000..ce65fcda --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go @@ -0,0 +1,36 @@ +package s3 + +import ( + "bytes" + "io/ioutil" + "net/http" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +func copyMultipartStatusOKUnmarhsalError(r *request.Request) { + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "unable to read response body", err) + return + } + body := bytes.NewReader(b) + r.HTTPResponse.Body = aws.ReadSeekCloser(body) + defer r.HTTPResponse.Body.(aws.ReaderSeekerCloser).Seek(0, 0) + + if body.Len() == 0 { + // If there is no body don't attempt to parse the body. + return + } + + unmarshalError(r) + if err, ok := r.Error.(awserr.Error); ok && err != nil { + if err.Code() == "SerializationError" { + r.Error = nil + return + } + r.HTTPResponse.StatusCode = http.StatusServiceUnavailable + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go b/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go new file mode 100644 index 00000000..30470ac1 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go @@ -0,0 +1,51 @@ +package s3 + +import ( + "encoding/xml" + "fmt" + "io" + "net/http" + "strings" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +type xmlErrorResponse struct { + XMLName xml.Name `xml:"Error"` + Code string `xml:"Code"` + Message string `xml:"Message"` +} + +func unmarshalError(r *request.Request) { + defer r.HTTPResponse.Body.Close() + + if r.HTTPResponse.StatusCode == http.StatusMovedPermanently { + r.Error = awserr.New("BucketRegionError", + fmt.Sprintf("incorrect region, the bucket is not in '%s' region", aws.StringValue(r.Config.Region)), nil) + return + } + + if r.HTTPResponse.ContentLength == int64(0) { + // No body, use status code to generate an awserr.Error + r.Error = awserr.NewRequestFailure( + awserr.New(strings.Replace(r.HTTPResponse.Status, " ", "", -1), r.HTTPResponse.Status, nil), + r.HTTPResponse.StatusCode, + "", + ) + return + } + + resp := &xmlErrorResponse{} + err := xml.NewDecoder(r.HTTPResponse.Body).Decode(resp) + if err != nil && err != io.EOF { + r.Error = awserr.New("SerializationError", "failed to decode S3 XML error response", nil) + } else { + r.Error = awserr.NewRequestFailure( + awserr.New(resp.Code, resp.Message, nil), + r.HTTPResponse.StatusCode, + "", + ) + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/waiters.go b/vendor/github.com/aws/aws-sdk-go/service/s3/waiters.go new file mode 100644 index 00000000..4879fca8 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/waiters.go @@ -0,0 +1,117 @@ +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + +package s3 + +import ( + "github.com/aws/aws-sdk-go/private/waiter" +) + +func (c *S3) WaitUntilBucketExists(input *HeadBucketInput) error { + waiterCfg := waiter.Config{ + Operation: "HeadBucket", + Delay: 5, + MaxAttempts: 20, + Acceptors: []waiter.WaitAcceptor{ + { + State: "success", + Matcher: "status", + Argument: "", + Expected: 200, + }, + { + State: "success", + Matcher: "status", + Argument: "", + Expected: 403, + }, + { + State: "retry", + Matcher: "status", + Argument: "", + Expected: 404, + }, + }, + } + + w := waiter.Waiter{ + Client: c, + Input: input, + Config: waiterCfg, + } + return w.Wait() +} + +func (c *S3) WaitUntilBucketNotExists(input *HeadBucketInput) error { + waiterCfg := waiter.Config{ + Operation: "HeadBucket", + Delay: 5, + MaxAttempts: 20, + Acceptors: []waiter.WaitAcceptor{ + { + State: "success", + Matcher: "status", + Argument: "", + Expected: 404, + }, + }, + } + + w := waiter.Waiter{ + Client: c, + Input: input, + Config: waiterCfg, + } + return w.Wait() +} + +func (c *S3) WaitUntilObjectExists(input *HeadObjectInput) error { + waiterCfg := waiter.Config{ + Operation: "HeadObject", + Delay: 5, + MaxAttempts: 20, + Acceptors: []waiter.WaitAcceptor{ + { + State: "success", + Matcher: "status", + Argument: "", + Expected: 200, + }, + { + State: "retry", + Matcher: "status", + Argument: "", + Expected: 404, + }, + }, + } + + w := waiter.Waiter{ + Client: c, + Input: input, + Config: waiterCfg, + } + return w.Wait() +} + +func (c *S3) WaitUntilObjectNotExists(input *HeadObjectInput) error { + waiterCfg := waiter.Config{ + Operation: "HeadObject", + Delay: 5, + MaxAttempts: 20, + Acceptors: []waiter.WaitAcceptor{ + { + State: "success", + Matcher: "status", + Argument: "", + Expected: 404, + }, + }, + } + + w := waiter.Waiter{ + Client: c, + Input: input, + Config: waiterCfg, + } + return w.Wait() +} diff --git a/vendor/github.com/go-ini/ini/.gitignore b/vendor/github.com/go-ini/ini/.gitignore new file mode 100644 index 00000000..7adca943 --- /dev/null +++ b/vendor/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/vendor/github.com/go-ini/ini/LICENSE b/vendor/github.com/go-ini/ini/LICENSE new file mode 100644 index 00000000..37ec93a1 --- /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/README.md b/vendor/github.com/go-ini/ini/README.md new file mode 100644 index 00000000..c52f63a4 --- /dev/null +++ b/vendor/github.com/go-ini/ini/README.md @@ -0,0 +1,590 @@ +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 + +### Testing + +If you want to test on your machine, please apply `-t` flag: + + go get -t gopkg.in/ini.v1 + +## 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")) +``` + +### 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 +``` + +To auto-split value into slice: + +```go +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(",") +``` + +### 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/vendor/github.com/go-ini/ini/README_ZH.md b/vendor/github.com/go-ini/ini/README_ZH.md new file mode 100644 index 00000000..ce6d8eb4 --- /dev/null +++ b/vendor/github.com/go-ini/ini/README_ZH.md @@ -0,0 +1,577 @@ +本包提供了 Go 语言中读写 INI 文件的功能。 + +## 功能特性 + +- 支持覆盖加载多个数据源(`[]byte` 或文件) +- 支持递归读取键值 +- 支持读取父子分区 +- 支持读取自增键名 +- 支持读取多行的键值 +- 支持大量辅助方法 +- 支持在读取时直接转换为 Go 语言类型 +- 支持读取和 **写入** 分区和键的注释 +- 轻松操作分区、键值和注释 +- 在保存文件时分区和键值会保持原有的顺序 + +## 下载安装 + +使用一个特定版本: + + go get gopkg.in/ini.v1 + +使用最新版: + + go get github.com/go-ini/ini + +### 测试安装 + +如果您想要在自己的机器上运行测试,请使用 `-t` 标记: + + go get -t gopkg.in/ini.v1 + +## 开始使用 + +### 从数据源加载 + +一个 **数据源** 可以是 `[]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")) +``` + +### 操作分区(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 +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 +// ... +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/vendor/github.com/go-ini/ini/ini.go b/vendor/github.com/go-ini/ini/ini.go new file mode 100644 index 00000000..1a27f068 --- /dev/null +++ b/vendor/github.com/go-ini/ini/ini.go @@ -0,0 +1,1027 @@ +// 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 ( + DEFAULT_SECTION = "DEFAULT" + // Maximum allowed depth when recursively substituing variable names. + _DEPTH_VALUES = 99 + + _VERSION = "1.8.6" +) + +func Version() string { + return _VERSION +} + +var ( + LineBreak = "\n" + + // Variable regexp pattern: %(variable)s + varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`) + + // Write spaces around "=" to look better. + PrettyFormat = true +) + +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 a interface that returns file content. +type dataSource interface { + ReadCloser() (io.ReadCloser, error) +} + +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 +} + +type sourceData struct { + data []byte +} + +func (s *sourceData) ReadCloser() (io.ReadCloser, error) { + return &bytesReadCloser{bytes.NewReader(s.data)}, nil +} + +// ____ __. +// | |/ _|____ ___.__. +// | <_/ __ < | | +// | | \ ___/\___ | +// |____|__ \___ > ____| +// \/ \/\/ + +// 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. +func (k *Key) Float64s(delim string) []float64 { + strs := k.Strings(delim) + vals := make([]float64, len(strs)) + for i := range strs { + vals[i], _ = strconv.ParseFloat(strs[i], 64) + } + return vals +} + +// Ints returns list of int divided by given delimiter. +func (k *Key) Ints(delim string) []int { + strs := k.Strings(delim) + vals := make([]int, len(strs)) + for i := range strs { + vals[i], _ = strconv.Atoi(strs[i]) + } + return vals +} + +// Int64s returns list of int64 divided by given delimiter. +func (k *Key) Int64s(delim string) []int64 { + strs := k.Strings(delim) + vals := make([]int64, len(strs)) + for i := range strs { + vals[i], _ = strconv.ParseInt(strs[i], 10, 64) + } + return vals +} + +// Uints returns list of uint divided by given delimiter. +func (k *Key) Uints(delim string) []uint { + strs := k.Strings(delim) + vals := make([]uint, len(strs)) + for i := range strs { + u, _ := strconv.ParseUint(strs[i], 10, 0) + vals[i] = uint(u) + } + return vals +} + +// Uint64s returns list of uint64 divided by given delimiter. +func (k *Key) Uint64s(delim string) []uint64 { + strs := k.Strings(delim) + vals := make([]uint64, len(strs)) + for i := range strs { + vals[i], _ = strconv.ParseUint(strs[i], 10, 64) + } + return vals +} + +// TimesFormat parses with given format and returns list of time.Time divided by given delimiter. +func (k *Key) TimesFormat(format, delim string) []time.Time { + strs := k.Strings(delim) + vals := make([]time.Time, len(strs)) + for i := range strs { + vals[i], _ = time.Parse(format, strs[i]) + } + return vals +} + +// Times parses with RFC3339 format and returns list of time.Time divided by given delimiter. +func (k *Key) Times(delim string) []time.Time { + return k.TimesFormat(time.RFC3339, delim) +} + +// 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 +} + +// _________ __ .__ +// / _____/ ____ _____/ |_|__| ____ ____ +// \_____ \_/ __ \_/ ___\ __\ |/ _ \ / \ +// / \ ___/\ \___| | | ( <_> ) | \ +// /_______ /\___ >\___ >__| |__|\____/|___| / +// \/ \/ \/ \/ + +// 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 + } + } +} + +// ___________.__.__ +// \_ _____/|__| | ____ +// | __) | | | _/ __ \ +// | \ | | |_\ ___/ +// \___ / |__|____/\___ > +// \/ \/ + +// 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 + + NameMapper +} + +// newFile initializes File object with given data sources. +func newFile(dataSources []dataSource) *File { + return &File{ + BlockMode: true, + dataSources: dataSources, + sections: make(map[string]*Section), + sectionList: make([]string, 0, 10), + } +} + +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) + } +} + +// Load loads and parses from INI data sources. +// Arguments can be mixed of file name with string type, or raw data in []byte. +func Load(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) + if err = f.Reload(); err != nil { + return nil, err + } + return f, nil +} + +// 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("error when getting section: section '%s' not exists", 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 { + 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 file content into io.Writer with given value indention. +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 { + 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 + } + } + + 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 + `"""` + } + + 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(kname + 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/parser.go b/vendor/github.com/go-ini/ini/parser.go new file mode 100644 index 00000000..1c1bf91f --- /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/struct.go b/vendor/github.com/go-ini/ini/struct.go new file mode 100644 index 00000000..3fb92c39 --- /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/jmespath/go-jmespath/.gitignore b/vendor/github.com/jmespath/go-jmespath/.gitignore new file mode 100644 index 00000000..531fcc11 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/.gitignore @@ -0,0 +1,4 @@ +jpgo +jmespath-fuzz.zip +cpu.out +go-jmespath.test diff --git a/vendor/github.com/jmespath/go-jmespath/.travis.yml b/vendor/github.com/jmespath/go-jmespath/.travis.yml new file mode 100644 index 00000000..1f980775 --- /dev/null +++ b/vendor/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/vendor/github.com/jmespath/go-jmespath/LICENSE b/vendor/github.com/jmespath/go-jmespath/LICENSE new file mode 100644 index 00000000..b03310a9 --- /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/Makefile b/vendor/github.com/jmespath/go-jmespath/Makefile new file mode 100644 index 00000000..ad17bf00 --- /dev/null +++ b/vendor/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/corpus + +bench: + go test -bench . -cpuprofile cpu.out + +pprof-cpu: + go tool pprof ./go-jmespath.test ./cpu.out diff --git a/vendor/github.com/jmespath/go-jmespath/README.md b/vendor/github.com/jmespath/go-jmespath/README.md new file mode 100644 index 00000000..187ef676 --- /dev/null +++ b/vendor/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/vendor/github.com/jmespath/go-jmespath/api.go b/vendor/github.com/jmespath/go-jmespath/api.go new file mode 100644 index 00000000..9cfa988b --- /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 00000000..1cd2d239 --- /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 00000000..8a3f2ef0 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/functions.go @@ -0,0 +1,840 @@ +package jmespath + +import ( + "encoding/json" + "errors" + "fmt" + "math" + "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": functionEntry{ + name: "length", + arguments: []argSpec{ + argSpec{types: []jpType{jpString, jpArray, jpObject}}, + }, + handler: jpfLength, + }, + "starts_with": functionEntry{ + name: "starts_with", + arguments: []argSpec{ + argSpec{types: []jpType{jpString}}, + argSpec{types: []jpType{jpString}}, + }, + handler: jpfStartsWith, + }, + "abs": functionEntry{ + name: "abs", + arguments: []argSpec{ + argSpec{types: []jpType{jpNumber}}, + }, + handler: jpfAbs, + }, + "avg": functionEntry{ + name: "avg", + arguments: []argSpec{ + argSpec{types: []jpType{jpArrayNumber}}, + }, + handler: jpfAvg, + }, + "ceil": functionEntry{ + name: "ceil", + arguments: []argSpec{ + argSpec{types: []jpType{jpNumber}}, + }, + handler: jpfCeil, + }, + "contains": functionEntry{ + name: "contains", + arguments: []argSpec{ + argSpec{types: []jpType{jpArray, jpString}}, + argSpec{types: []jpType{jpAny}}, + }, + handler: jpfContains, + }, + "ends_with": functionEntry{ + name: "ends_with", + arguments: []argSpec{ + argSpec{types: []jpType{jpString}}, + argSpec{types: []jpType{jpString}}, + }, + handler: jpfEndsWith, + }, + "floor": functionEntry{ + name: "floor", + arguments: []argSpec{ + argSpec{types: []jpType{jpNumber}}, + }, + handler: jpfFloor, + }, + "map": functionEntry{ + name: "amp", + arguments: []argSpec{ + argSpec{types: []jpType{jpExpref}}, + argSpec{types: []jpType{jpArray}}, + }, + handler: jpfMap, + hasExpRef: true, + }, + "max": functionEntry{ + name: "max", + arguments: []argSpec{ + argSpec{types: []jpType{jpArrayNumber, jpArrayString}}, + }, + handler: jpfMax, + }, + "merge": functionEntry{ + name: "merge", + arguments: []argSpec{ + argSpec{types: []jpType{jpObject}, variadic: true}, + }, + handler: jpfMerge, + }, + "max_by": functionEntry{ + name: "max_by", + arguments: []argSpec{ + argSpec{types: []jpType{jpArray}}, + argSpec{types: []jpType{jpExpref}}, + }, + handler: jpfMaxBy, + hasExpRef: true, + }, + "sum": functionEntry{ + name: "sum", + arguments: []argSpec{ + argSpec{types: []jpType{jpArrayNumber}}, + }, + handler: jpfSum, + }, + "min": functionEntry{ + name: "min", + arguments: []argSpec{ + argSpec{types: []jpType{jpArrayNumber, jpArrayString}}, + }, + handler: jpfMin, + }, + "min_by": functionEntry{ + name: "min_by", + arguments: []argSpec{ + argSpec{types: []jpType{jpArray}}, + argSpec{types: []jpType{jpExpref}}, + }, + handler: jpfMinBy, + hasExpRef: true, + }, + "type": functionEntry{ + name: "type", + arguments: []argSpec{ + argSpec{types: []jpType{jpAny}}, + }, + handler: jpfType, + }, + "keys": functionEntry{ + name: "keys", + arguments: []argSpec{ + argSpec{types: []jpType{jpObject}}, + }, + handler: jpfKeys, + }, + "values": functionEntry{ + name: "values", + arguments: []argSpec{ + argSpec{types: []jpType{jpObject}}, + }, + handler: jpfValues, + }, + "sort": functionEntry{ + name: "sort", + arguments: []argSpec{ + argSpec{types: []jpType{jpArrayString, jpArrayNumber}}, + }, + handler: jpfSort, + }, + "sort_by": functionEntry{ + name: "sort_by", + arguments: []argSpec{ + argSpec{types: []jpType{jpArray}}, + argSpec{types: []jpType{jpExpref}}, + }, + handler: jpfSortBy, + hasExpRef: true, + }, + "join": functionEntry{ + name: "join", + arguments: []argSpec{ + argSpec{types: []jpType{jpString}}, + argSpec{types: []jpType{jpArrayString}}, + }, + handler: jpfJoin, + }, + "reverse": functionEntry{ + name: "reverse", + arguments: []argSpec{ + argSpec{types: []jpType{jpArray, jpString}}, + }, + handler: jpfReverse, + }, + "to_array": functionEntry{ + name: "to_array", + arguments: []argSpec{ + argSpec{types: []jpType{jpAny}}, + }, + handler: jpfToArray, + }, + "to_string": functionEntry{ + name: "to_string", + arguments: []argSpec{ + argSpec{types: []jpType{jpAny}}, + }, + handler: jpfToString, + }, + "to_number": functionEntry{ + name: "to_number", + arguments: []argSpec{ + argSpec{types: []jpType{jpAny}}, + }, + handler: jpfToNumber, + }, + "not_null": functionEntry{ + name: "not_null", + arguments: []argSpec{ + 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 _, ok := arg.([]interface{}); ok { + 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 c, ok := arg.([]interface{}); ok { + return float64(len(c)), 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 00000000..13c74604 --- /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 00000000..817900c8 --- /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 00000000..c8f4bceb --- /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{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{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 00000000..dae79cbd --- /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 00000000..ddc1b7d7 --- /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/mcuadros/go-version/.gitignore b/vendor/github.com/mcuadros/go-version/.gitignore new file mode 100644 index 00000000..00268614 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/.gitignore @@ -0,0 +1,22 @@ +# 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 diff --git a/vendor/github.com/mcuadros/go-version/.travis.yml b/vendor/github.com/mcuadros/go-version/.travis.yml new file mode 100644 index 00000000..4f2ee4d9 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/.travis.yml @@ -0,0 +1 @@ +language: go diff --git a/vendor/github.com/mcuadros/go-version/LICENSE b/vendor/github.com/mcuadros/go-version/LICENSE new file mode 100644 index 00000000..b3154896 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Máximo Cuadros + +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/mcuadros/go-version/README.md b/vendor/github.com/mcuadros/go-version/README.md new file mode 100644 index 00000000..b6addcd0 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/README.md @@ -0,0 +1,82 @@ +go-version [![Build Status](https://travis-ci.org/mcuadros/go-version.png?branch=master)](https://travis-ci.org/mcuadros/go-version) [![GoDoc](https://godoc.org/github.com/mcuadros/go-version?status.png)](http://godoc.org/github.com/mcuadros/go-version) +============================== + +Version normalizer and comparison library for go, heavy based on PHP version_compare function and Version comparsion libs from [Composer](https://github.com/composer/composer) PHP project + +Installation +------------ + +The recommended way to install go-version + +``` +go get github.com/mcuadros/go-version +``` + +Examples +-------- + +How import the package + +```go +import ( + "github.com/mcuadros/go-version" +) +``` + +`version.Normalize()`: Normalizes a version string to be able to perform comparisons on it + +```go +version.Normalize("10.4.13-b") +//Returns: 10.4.13.0-beta +``` + + +`version.CompareSimple()`: Compares two normalizated version number strings + +```go +version.CompareSimple("1.2", "1.0.1") +//Returns: 1 + +version.CompareSimple("1.0rc1", "1.0") +//Returns: -1 +``` + + +`version.Compare()`: Compares two normalizated version number strings, for a particular relationship + +```go +version.Compare("1.0-dev", "1.0", "<") +//Returns: true + +version.Compare("1.0rc1", "1.0", ">=") +//Returns: false + +version.Compare("2.3.4", "v3.1.2", "<") +//Returns: true +``` + +`version.ConstrainGroup.Match()`: Match a given version againts a group of constrains, read about constraint string format at [Composer documentation](http://getcomposer.org/doc/01-basic-usage.md#package-versions) + +```go +c := version.NewConstrainGroupFromString(">2.0,<=3.0") +c.Match("2.5.0beta") +//Returns: true + +c := version.NewConstrainGroupFromString("~1.2.3") +c.Match("1.2.3.5") +//Returns: true +``` + +`version.Sort()`: Sorts a string slice of version number strings using version.CompareSimple() + +```go +version.Sort([]string{"1.10-dev", "1.0rc1", "1.0", "1.0-dev"}) +//Returns []string{"1.0-dev", "1.0rc1", "1.0", "1.10-dev"} +``` + +License +------- + +MIT, see [LICENSE](LICENSE) + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mcuadros/go-version/trend.png)](https://bitdeli.com/free "Bitdeli Badge") diff --git a/vendor/github.com/mcuadros/go-version/compare.go b/vendor/github.com/mcuadros/go-version/compare.go new file mode 100644 index 00000000..84dc3fa1 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/compare.go @@ -0,0 +1,159 @@ +package version + +import ( + "regexp" + "strconv" + "strings" +) + +var regexpSigns = regexp.MustCompile(`[_\-+]`) +var regexpDotBeforeDigit = regexp.MustCompile(`([^.\d]+)`) +var regexpMultipleDots = regexp.MustCompile(`\.{2,}`) + +var specialForms = map[string]int{ + "dev": -6, + "alpha": -5, + "a": -5, + "beta": -4, + "b": -4, + "RC": -3, + "rc": -3, + "#": -2, + "p": 1, + "pl": 1, +} + +// Compares two version number strings, for a particular relationship +// +// Usage +// version.Compare("2.3.4", "v3.1.2", "<") +// Returns: true +// +// version.Compare("1.0rc1", "1.0", ">=") +// Returns: false +func Compare(version1, version2, operator string) bool { + version1N := Normalize(version1) + version2N := Normalize(version2) + + return CompareNormalized(version1N, version2N, operator) +} + +// Compares two normalizated version number strings, for a particular relationship +// +// The function first replaces _, - and + with a dot . in the version strings +// and also inserts dots . before and after any non number so that for example +// '4.3.2RC1' becomes '4.3.2.RC.1'. +// +// Then it splits the results like if you were using Split(version, '.'). +// Then it compares the parts starting from left to right. If a part contains +// special version strings these are handled in the following order: any string +// not found in this list: +// < dev < alpha = a < beta = b < RC = rc < # < pl = p. +// +// Usage +// version.CompareNormalized("1.0-dev", "1.0", "<") +// Returns: true +// +// version.CompareNormalized("1.0rc1", "1.0", ">=") +// Returns: false +// +// version.CompareNormalized("1.0", "1.0b1", "ge") +// Returns: true +func CompareNormalized(version1, version2, operator string) bool { + compare := CompareSimple(version1, version2) + + switch { + case operator == ">" || operator == "gt": + return compare > 0 + case operator == ">=" || operator == "ge": + return compare >= 0 + case operator == "<=" || operator == "le": + return compare <= 0 + case operator == "==" || operator == "=" || operator == "eq": + return compare == 0 + case operator == "<>" || operator == "!=" || operator == "ne": + return compare != 0 + case operator == "" || operator == "<" || operator == "lt": + return compare < 0 + } + + return false +} + +// Compares two normalizated version number strings +// +// Just the same of CompareVersion but return a int result, 0 if both version +// are equal, 1 if the right side is bigger and -1 if the right side is lower +// +// Usage +// version.CompareSimple("1.2", "1.0.1") +// Returns: 1 +// +// version.CompareSimple("1.0rc1", "1.0") +// Returns: -1 +func CompareSimple(version1, version2 string) int { + var x, r, l int = 0, 0, 0 + + v1, v2 := prepVersion(version1), prepVersion(version2) + len1, len2 := len(v1), len(v2) + + if len1 > len2 { + x = len1 + } else { + x = len2 + } + + for i := 0; i < x; i++ { + if i < len1 && i < len2 { + if v1[i] == v2[i] { + continue + } + } + + r = 0 + if i < len1 { + r = numVersion(v1[i]) + } + + l = 0 + if i < len2 { + l = numVersion(v2[i]) + } + + if r < l { + return -1 + } else if r > l { + return 1 + } + } + + return 0 +} + +func prepVersion(version string) []string { + if len(version) == 0 { + return []string{""} + } + + version = regexpSigns.ReplaceAllString(version, ".") + version = regexpDotBeforeDigit.ReplaceAllString(version, ".$1.") + version = regexpMultipleDots.ReplaceAllString(version, ".") + + return strings.Split(version, ".") +} + +func numVersion(value string) int { + if value == "" { + return 0 + } + + if number, err := strconv.Atoi(value); err == nil { + return number + } + + if special, ok := specialForms[value]; ok { + return special + } + + return -7 +} diff --git a/vendor/github.com/mcuadros/go-version/constraint.go b/vendor/github.com/mcuadros/go-version/constraint.go new file mode 100644 index 00000000..8dc2cfcc --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/constraint.go @@ -0,0 +1,49 @@ +package version + +import ( + "strings" +) + +type Constraint struct { + operator string + version string +} + +// Return a new Constrain and sets operator and version to compare +func NewConstrain(operator, version string) *Constraint { + constraint := new(Constraint) + constraint.SetOperator(operator) + constraint.SetVersion(version) + + return constraint +} + +// Sets operator to compare +func (self *Constraint) SetOperator(operator string) { + self.operator = operator +} + +// Get operator to compare +func (self *Constraint) GetOperator() string { + return self.operator +} + +// Sets version to compare +func (self *Constraint) SetVersion(version string) { + self.version = version +} + +// Get version to compare +func (self *Constraint) GetVersion() string { + return self.version +} + +// Match a given version againts the constraint +func (self *Constraint) Match(version string) bool { + return Compare(version, self.version, self.operator) +} + +// Return a string representation +func (self *Constraint) String() string { + return strings.Trim(self.operator+" "+self.version, " ") +} diff --git a/vendor/github.com/mcuadros/go-version/doc.go b/vendor/github.com/mcuadros/go-version/doc.go new file mode 100644 index 00000000..763f6183 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/doc.go @@ -0,0 +1,6 @@ +/* +Version normalizer and comparison library for go, heavy based on PHP +version_compare function and Version comparsion libs from Composer +(https://github.com/composer/composer) PHP project +*/ +package version \ No newline at end of file diff --git a/vendor/github.com/mcuadros/go-version/group.go b/vendor/github.com/mcuadros/go-version/group.go new file mode 100644 index 00000000..b25a30c0 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/group.go @@ -0,0 +1,269 @@ +package version + +import ( + "regexp" + "strconv" + "strings" +) + +type ConstraintGroup struct { + constraints []*Constraint +} + +// Return a new NewConstrainGroup +func NewConstrainGroup() *ConstraintGroup { + group := new(ConstraintGroup) + + return group +} + +// Return a new NewConstrainGroup and create the constraints based on a string +// +// Version constraints can be specified in a few different ways: +// +// Exact version: You can specify the exact version of a package, for +// example 1.0.2. +// +// Range: By using comparison operators you can specify ranges of valid versions. +// Valid operators are >, >=, <, <=, !=. An example range would be >=1.0. You can +// define multiple ranges, separated by a comma: >=1.0,<2.0. +// +// Wildcard: You can specify a pattern with a * wildcard. 1.0.* is the equivalent +// of >=1.0,<1.1. +// +// Next Significant Release (Tilde Operator): The ~ operator is best explained by +// example: ~1.2 is equivalent to >=1.2,<2.0, while ~1.2.3 is equivalent to +// >=1.2.3,<1.3. As you can see it is mostly useful for projects respecting +// semantic versioning. A common usage would be to mark the minimum minor +// version you depend on, like ~1.2 (which allows anything up to, but not +// including, 2.0). Since in theory there should be no backwards compatibility +// breaks until 2.0, that works well. Another way of looking at it is that +// using ~ specifies a minimum version, but allows the last digit specified +// to go up. +// +// By default only stable releases are taken into consideration. If you would like +// to also get RC, beta, alpha or dev versions of your dependencies you can do so +// using stability flags. To change that for all packages instead of doing per +// dependency you can also use the minimum-stability setting. +// +// From: http://getcomposer.org/doc/01-basic-usage.md#package-versions +func NewConstrainGroupFromString(name string) *ConstraintGroup { + group := new(ConstraintGroup) + group.fromString(name) + + return group +} + +// Adds a Contraint to the group +func (self *ConstraintGroup) AddConstraint(constraint ...*Constraint) { + if self.constraints == nil { + self.constraints = make([]*Constraint, 0) + } + + self.constraints = append(self.constraints, constraint...) +} + +// Return all the constraints +func (self *ConstraintGroup) GetConstraints() []*Constraint { + return self.constraints +} + +// Match a given version againts the group +// +// Usage +// c := version.NewConstrainGroupFromString(">2.0,<=3.0") +// c.Match("2.5.0beta") +// Returns: true +// +// c := version.NewConstrainGroupFromString("~1.2.3") +// c.Match("1.2.3.5") +// Returns: true +func (self *ConstraintGroup) Match(version string) bool { + for _, constraint := range self.constraints { + if constraint.Match(version) == false { + return false + } + } + + return true +} + +func (self *ConstraintGroup) fromString(constraint string) bool { + result := RegFind(`(?i)^([^,\s]*?)@(stable|RC|beta|alpha|dev)$`, constraint) + if result != nil { + constraint = result[1] + if constraint == "" { + constraint = "*" + } + } + + result = RegFind(`(?i)^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$`, constraint) + if result != nil { + if result[1] != "" { + constraint = result[1] + } + } + + constraints := RegSplit(`\s*,\s*`, strings.Trim(constraint, " ")) + + if len(constraints) > 1 { + for _, part := range constraints { + self.AddConstraint(self.parseConstraint(part)...) + } + + return true + } + + self.AddConstraint(self.parseConstraint(constraints[0])...) + + return true +} + +func (self *ConstraintGroup) parseConstraint(constraint string) []*Constraint { + + stabilityModifier := "" + + result := RegFind(`(?i)^([^,\s]+?)@(stable|RC|beta|alpha|dev)$`, constraint) + if result != nil { + constraint = result[1] + if result[2] != "stable" { + stabilityModifier = result[2] + } + } + + result = RegFind(`^[x*](\.[x*])*$`, constraint) + if result != nil { + return make([]*Constraint, 0) + } + + highVersion := "" + lowVersion := "" + + result = RegFind(`(?i)^~(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?`+modifierRegex+`?$`, constraint) + if result != nil { + if len(result) > 4 && result[4] != "" { + last, _ := strconv.Atoi(result[3]) + highVersion = result[1] + "." + result[2] + "." + strconv.Itoa(last+1) + ".0-dev" + lowVersion = result[1] + "." + result[2] + "." + result[3] + "." + result[4] + } else if len(result) > 3 && result[3] != "" { + last, _ := strconv.Atoi(result[2]) + highVersion = result[1] + "." + strconv.Itoa(last+1) + ".0.0-dev" + lowVersion = result[1] + "." + result[2] + "." + result[3] + ".0" + } else { + last, _ := strconv.Atoi(result[1]) + highVersion = strconv.Itoa(last+1) + ".0.0.0-dev" + if len(result) > 2 && result[2] != "" { + lowVersion = result[1] + "." + result[2] + ".0.0" + } else { + lowVersion = result[1] + ".0.0.0" + } + } + + if len(result) > 5 && result[5] != "" { + lowVersion = lowVersion + "-" + expandStability(result[5]) + + } + + if len(result) > 6 && result[6] != "" { + lowVersion = lowVersion + result[6] + } + + if len(result) > 7 && result[7] != "" { + lowVersion = lowVersion + "-dev" + } + + return []*Constraint{ + {">=", lowVersion}, + {"<", highVersion}, + } + } + + result = RegFind(`^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.[x*]$`, constraint) + if result != nil { + if len(result) > 3 && result[3] != "" { + highVersion = result[1] + "." + result[2] + "." + result[3] + ".9999999" + if result[3] == "0" { + last, _ := strconv.Atoi(result[2]) + lowVersion = result[1] + "." + strconv.Itoa(last-1) + ".9999999.9999999" + } else { + last, _ := strconv.Atoi(result[3]) + lowVersion = result[1] + "." + result[2] + "." + strconv.Itoa(last-1) + ".9999999" + } + + } else if len(result) > 2 && result[2] != "" { + highVersion = result[1] + "." + result[2] + ".9999999.9999999" + if result[2] == "0" { + last, _ := strconv.Atoi(result[1]) + lowVersion = strconv.Itoa(last-1) + ".9999999.9999999.9999999" + } else { + last, _ := strconv.Atoi(result[2]) + lowVersion = result[1] + "." + strconv.Itoa(last-1) + ".9999999.9999999" + } + + } else { + highVersion = result[1] + ".9999999.9999999.9999999" + if result[1] == "0" { + return []*Constraint{{"<", highVersion}} + } else { + last, _ := strconv.Atoi(result[1]) + lowVersion = strconv.Itoa(last-1) + ".9999999.9999999.9999999" + } + } + + return []*Constraint{ + {">", lowVersion}, + {"<", highVersion}, + } + } + + // match operators constraints + result = RegFind(`^(<>|!=|>=?|<=?|==?)?\s*(.*)`, constraint) + if result != nil { + version := Normalize(result[2]) + + if stabilityModifier != "" && parseStability(version) == "stable" { + version = version + "-" + stabilityModifier + } else if result[1] == "<" { + match := RegFind(`(?i)-stable$`, result[2]) + if match == nil { + version = version + "-dev" + } + } + + if len(result) > 1 && result[1] != "" { + return []*Constraint{{result[1], version}} + } else { + return []*Constraint{{"=", version}} + + } + } + + return []*Constraint{{constraint, stabilityModifier}} +} + +func RegFind(pattern, subject string) []string { + reg := regexp.MustCompile(pattern) + matched := reg.FindAllStringSubmatch(subject, -1) + + if matched != nil { + return matched[0] + } + + return nil +} + +func RegSplit(pattern, subject string) []string { + reg := regexp.MustCompile(pattern) + indexes := reg.FindAllStringIndex(subject, -1) + + laststart := 0 + result := make([]string, len(indexes)+1) + + for i, element := range indexes { + result[i] = subject[laststart:element[0]] + laststart = element[1] + } + + result[len(indexes)] = subject[laststart:len(subject)] + return result +} diff --git a/vendor/github.com/mcuadros/go-version/normalize.go b/vendor/github.com/mcuadros/go-version/normalize.go new file mode 100644 index 00000000..e2945c9a --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/normalize.go @@ -0,0 +1,116 @@ +package version + +import ( + "regexp" + "strings" +) + +var modifierRegex = `[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?` + +var regexpMasterLikeBranches = regexp.MustCompile(`^(?:dev-)?(?:master|trunk|default)$`) +var regexpBranchNormalize = regexp.MustCompile(`(?i)^v?(\d+)(\.(?:\d+|[x*]))?(\.(?:\d+|[x*]))?(\.(?:\d+|[x*]))?$`) + +// Normalizes a version string to be able to perform comparisons on it +// +// Example: +// version.Normalize("10.4.13-b") +// Returns: 10.4.13.0-beta +// +func Normalize(version string) string { + + // ignore aliases and just assume the alias is required instead of the source + result := RegFind(`^([^,\s]+) +as +([^,\s]+)$`, version) + if result != nil { + version = result[1] + } + + // match master-like branches + if regexpMasterLikeBranches.MatchString(strings.ToLower(version)) { + return "9999999-dev" + } + + if strings.HasPrefix(strings.ToLower(version), "dev-") { + return "dev-" + version[4:len(version)] + } + + index := 0 + + // match classical versioning + result = RegFind(`(?i)^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?`+modifierRegex+`$`, version) + if result != nil { + version = "" + for _, val := range result[1:5] { + if val != "" { + version = version + val + } else { + version = version + ".0" + } + } + + index = 5 + } else { + // match date-based versioning + result = RegFind(`(?i)^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)`+modifierRegex+`$`, version) + if result != nil { + version = regexp.MustCompile(`\D`).ReplaceAllString(result[1], "-") + index = 2 + } + } + + if index != 0 { + if result[index] != "" { + if result[index] == "stable" { + return version + } + + version = version + "-" + expandStability(result[index]) + if result[index+1] != "" { + version = version + result[index+1] + } + } + + if result[index+2] != "" { + version = version + "-dev" + } + + return version + } + + result = RegFind(`(?i)(.*?)[.-]?dev$`, version) + if result != nil { + return normalizeBranch(result[1]) + } + + return version +} + +func normalizeBranch(name string) string { + name = strings.Trim(name, " ") + + if name == "master" || name == "trunk" || name == "default" { + return Normalize(name) + } + + replace := strings.NewReplacer("*", "9999999", "x", "9999999") + + matched := regexpBranchNormalize.FindAllStringSubmatch(name, -1) + if matched != nil { + name = "" + for _, val := range matched[0][1:5] { + if val != "" { + name = name + replace.Replace(val) + } else { + name = name + ".9999999" + } + } + + return name + "-dev" + + } + + if strings.HasSuffix(strings.ToLower(name), "-dev") { + return name + } + + return "dev-" + name +} diff --git a/vendor/github.com/mcuadros/go-version/sort.go b/vendor/github.com/mcuadros/go-version/sort.go new file mode 100644 index 00000000..70eb2ca9 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/sort.go @@ -0,0 +1,36 @@ +package version + +import ( + "sort" +) + +// Sorts a string slice of version number strings using version.CompareSimple() +// +// Example: +// version.Sort([]string{"1.10-dev", "1.0rc1", "1.0", "1.0-dev"}) +// Returns []string{"1.0-dev", "1.0rc1", "1.0", "1.10-dev"} +// +func Sort(versionStrings []string) { + versions := versionSlice(versionStrings) + sort.Sort(versions) +} + +type versionSlice []string + +func (s versionSlice) Len() int { + return len(s) +} + +func (s versionSlice) Less(i, j int) bool { + cmp := CompareSimple(Normalize(s[i]), Normalize(s[j])) + if cmp == 0 { + return s[i] < s[j] + } + return cmp < 0 +} + +func (s versionSlice) Swap(i, j int) { + tmp := s[j] + s[j] = s[i] + s[i] = tmp +} diff --git a/vendor/github.com/mcuadros/go-version/stability.go b/vendor/github.com/mcuadros/go-version/stability.go new file mode 100644 index 00000000..566f7d90 --- /dev/null +++ b/vendor/github.com/mcuadros/go-version/stability.go @@ -0,0 +1,83 @@ +package version + +import ( + "regexp" + "strings" +) + +const ( + Development = iota + Alpha + Beta + RC + Stable +) + +func expandStability(stability string) string { + stability = strings.ToLower(stability) + + switch stability { + case "a": + return "alpha" + case "b": + return "beta" + case "p": + return "patch" + case "pl": + return "patch" + case "rc": + return "RC" + } + + return stability +} + +func parseStability(version string) string { + version = regexp.MustCompile(`(?i)#.+$`).ReplaceAllString(version, " ") + version = strings.ToLower(version) + + if strings.HasPrefix(version, "dev-") || strings.HasSuffix(version, "-dev") { + return "dev" + } + + result := RegFind(`(?i)^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?`+modifierRegex+`$`, version) + if result != nil { + if len(result) > 3 { + return "dev" + } + } + + if result[1] != "" { + if "beta" == result[1] || "b" == result[1] { + return "beta" + } + if "alpha" == result[1] || "a" == result[1] { + return "alpha" + } + if "rc" == result[1] { + return "RC" + } + } + + return "stable" +} + +func GetStability(version string) int { + result := RegFind(`(?i)(stable|RC|beta|alpha|dev)`, Normalize(version)) + if len(result) == 0 { + return Stable + } + + switch result[1] { + case "dev": + return Development + case "alpha": + return Alpha + case "beta": + return Beta + case "RC": + return RC + } + + return Stable +} diff --git a/vendor/github.com/rancher/convoy/README.md b/vendor/github.com/rancher/convoy/README.md index ce59d822..33a0a1a7 100644 --- a/vendor/github.com/rancher/convoy/README.md +++ b/vendor/github.com/rancher/convoy/README.md @@ -8,7 +8,7 @@ Convoy is a Docker volume plugin for a variety of storage back-ends. It's desig ## Why we need Convoy? Docker has various drivers(aufs, device mapper, etc) for container's root image, but not for volumes. User can create volume through ```docker run -v volname```, but it's disposable, cannot be easily reused for new containers or containers on the other hosts. For example, if you start a wordpress container with database, add some posts, remove the container, then the modified database would lost. -Before volume plugin, the only way to reuse the volume is using host bind mount feature of Docker, as ```docker run -v /host_path:/container_path```, then maintain the content of the volume at ```/hostpath```. You can also use ```--volume-from``` but that would require original container still exists on the same host. +Before volume plugin, the only way to reuse the volume is using host bind mount feature of Docker, as ```docker run -v /host_path:/container_path```, then maintain the content of the volume at ```/host_path```. You can also use ```--volume-from``` but that would require original container still exists on the same host. Convoy used Docker volume plugin mechanism to provide persistent volume for Docker containers, and supports various of backends(e.g. device mapper, NFS, EBS) and more features like snapshot/backup/restore. So user would able to migrate the volumes between the hosts, share the same volume across the hosts, make scheduled snapshots of as well as recover to previous version of volume. It's much easier for user to manage data with Docker volumes with Convoy. diff --git a/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go b/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go new file mode 100644 index 00000000..16c864c5 --- /dev/null +++ b/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go @@ -0,0 +1,129 @@ +package convoydriver + +import ( + "fmt" + "github.com/Sirupsen/logrus" + "path/filepath" +) + +/* +InitFunc is the initialize function for each ConvoyDriver. Each driver must +implement this function and register itself through Register(). + +The registered function would be called upon Convoy need a ConvoyDriver +instance, and it would return a valid ConvoyDriver for operation. + +The registered function would take a "root" path, used as driver's configuration +file path, and a map of configuration specified for the driver. +*/ +type InitFunc func(root string, config map[string]string) (ConvoyDriver, error) + +/* +ConvoyDriver interface would provide all the functionality needed for driver +specific handling. Driver can choose to implement some or all of the available +operations interfaces to provide different functionality to Convoy user. +xxxOps() should return error if the functionality is not implemented by the +driver. +*/ +type ConvoyDriver interface { + Name() string + Info() (map[string]string, error) + + VolumeOps() (VolumeOperations, error) + SnapshotOps() (SnapshotOperations, error) + BackupOps() (BackupOperations, error) +} + +type Request struct { + Name string + Options map[string]string +} + +/* +VolumeOperations is Convoy Driver volume related operations interface. Any +Convoy Driver must implement this interface. +*/ +type VolumeOperations interface { + Name() string + CreateVolume(req Request) error + DeleteVolume(req Request) error + MountVolume(req Request) (string, error) + UmountVolume(req Request) error + MountPoint(req Request) (string, error) + GetVolumeInfo(name string) (map[string]string, error) + ListVolume(opts map[string]string) (map[string]map[string]string, error) +} + +/* +SnapshotOperations is Convoy Driver snapshot related operations interface. Any +Convoy Driver want to operate snapshots must implement this interface. +*/ +type SnapshotOperations interface { + Name() string + CreateSnapshot(req Request) error + DeleteSnapshot(req Request) error + GetSnapshotInfo(req Request) (map[string]string, error) + ListSnapshot(opts map[string]string) (map[string]map[string]string, error) +} + +/* +BackupOperations is Convoy Driver backup related operations interface. Any +Convoy Driver want to provide backup functionality must implement this +interface. Restore would need to be implemented in +VolumeOperations.CreateVolume() with opts[OPT_BACKUP_URL] +*/ +type BackupOperations interface { + Name() string + CreateBackup(snapshotID, volumeID, destURL string, opts map[string]string) (string, error) + DeleteBackup(backupURL string) error + GetBackupInfo(backupURL string) (map[string]string, error) + ListBackup(destURL string, opts map[string]string) (map[string]map[string]string, error) +} + +const ( + OPT_MOUNT_POINT = "MountPoint" + OPT_SIZE = "Size" + OPT_FORMAT = "Format" + OPT_VOLUME_NAME = "VolumeName" + OPT_VOLUME_DRIVER_ID = "VolumeDriverID" + OPT_VOLUME_TYPE = "VolumeType" + OPT_VOLUME_IOPS = "VolumeIOPS" + OPT_VOLUME_CREATED_TIME = "VolumeCreatedAt" + OPT_SNAPSHOT_NAME = "SnapshotName" + OPT_SNAPSHOT_CREATED_TIME = "SnapshotCreatedAt" + OPT_BACKUP_URL = "BackupURL" + OPT_REFERENCE_ONLY = "ReferenceOnly" + OPT_PREPARE_FOR_VM = "PrepareForVM" + OPT_FILESYSTEM = "Filesystem" +) + +var ( + initializers map[string]InitFunc + log = logrus.WithFields(logrus.Fields{"pkg": "convoydriver"}) +) + +func init() { + initializers = make(map[string]InitFunc) +} + +/* +Register would add specified InitFunc of Convoy Driver to the known driver list. +*/ +func Register(name string, initFunc InitFunc) error { + if _, exists := initializers[name]; exists { + return fmt.Errorf("Driver %s has already been registered", name) + } + initializers[name] = initFunc + return nil +} + +/* +GetDriver would be called each time when a Convoy Driver instance is needed. +*/ +func GetDriver(name, root string, config map[string]string) (ConvoyDriver, error) { + if _, exists := initializers[name]; !exists { + return nil, fmt.Errorf("Driver %v is not supported!", name) + } + drvRoot := filepath.Join(root, name) + return initializers[name](drvRoot, config) +} diff --git a/vendor/github.com/rancher/convoy/logging/logging.go b/vendor/github.com/rancher/convoy/logging/logging.go new file mode 100644 index 00000000..cd7c812d --- /dev/null +++ b/vendor/github.com/rancher/convoy/logging/logging.go @@ -0,0 +1,84 @@ +package logging + +import ( + "fmt" + "github.com/Sirupsen/logrus" +) + +const ( + LOG_FIELD_DRIVER = "driver" + LOG_FIELD_VOLUME = "volume" + LOG_FIELD_VOLUME_DEV = "volume_dev" + LOG_FIELD_VOLUME_NAME = "volume_name" + LOG_FIELD_ORIN_VOLUME = "original_volume" + LOG_FIELD_SNAPSHOT = "snapshot" + LOG_FIELD_LAST_SNAPSHOT = "last_snapshot" + LOG_FIELD_BACKUP_URL = "backup_url" + LOG_FIELD_DEST_URL = "dest_url" + LOG_FIELD_MOUNTPOINT = "mountpoint" + LOG_FIELD_NAMESPACE = "namespace" + LOG_FIELD_CFG = "config_file" + LOG_FIELD_SIZE = "size" + LOG_FIELD_FILESYSTEM = "filesystem" + LOG_FIELD_OPTION = "option" + LOG_FIELD_NEED_FORMAT = "need_format" + LOG_FIELD_BLOCKSIZE = "blocksize" + LOG_FIELD_KIND = "kind" + LOG_FIELD_FILEPATH = "filepath" + LOG_FIELD_CONTEXT = "context" + LOG_FIELD_OPTS = "opts" + + LOG_FIELD_EVENT = "event" + LOG_EVENT_INIT = "init" + LOG_EVENT_CREATE = "create" + LOG_EVENT_DELETE = "delete" + LOG_EVENT_FORMAT = "format" + LOG_EVENT_LIST = "list" + LOG_EVENT_MOUNT = "mount" + LOG_EVENT_UMOUNT = "umount" + LOG_EVENT_MOUNTPOINT = "mountpoint" + LOG_EVENT_ACTIVATE = "activate" + LOG_EVENT_DEACTIVATE = "deactivate" + LOG_EVENT_REGISTER = "register" + LOG_EVENT_DEREGISTER = "deregister" + LOG_EVENT_ADD = "add" + LOG_EVENT_REMOVE = "remove" + LOG_EVENT_BACKUP = "backup" + LOG_EVENT_RESTORE = "restore" + LOG_EVENT_LOAD = "load" + LOG_EVENT_SAVE = "save" + LOG_EVENT_COMPARE = "compare" + LOG_EVENT_UPLOAD = "upload" + LOG_EVENT_DOWNLOAD = "download" + + LOG_FIELD_REASON = "reason" + LOG_REASON_PREPARE = "prepare" + LOG_REASON_START = "start" + LOG_REASON_COMPLETE = "complete" + LOG_REASON_FAILURE = "failure" + LOG_REASON_ROLLBACK = "rollback" + LOG_REASON_FALLBACK = "fallback" + + LOG_FIELD_OBJECT = "object" + LOG_OBJECT_DRIVER = "driver" + LOG_OBJECT_VOLUME = "volume" + LOG_OBJECT_SNAPSHOT = "snapshot" + LOG_OBJECT_BACKUP_URL = "backup_url" + LOG_OBJECT_DEST_URL = "dest_url" + LOG_OBJECT_CONFIG = "config" +) + +// Error is a wrapper for a go error contains more details +type Error struct { + entry *logrus.Entry + error +} + +// ErrorWithFields is a helper for searchable error fields output +func ErrorWithFields(pkg string, fields logrus.Fields, format string, v ...interface{}) Error { + fields["pkg"] = pkg + entry := logrus.WithFields(fields) + entry.Message = fmt.Sprintf(format, v...) + + return Error{entry, fmt.Errorf(format, v...)} +} diff --git a/vendor/github.com/rancher/convoy/objectstore/config.go b/vendor/github.com/rancher/convoy/objectstore/config.go new file mode 100644 index 00000000..59eff438 --- /dev/null +++ b/vendor/github.com/rancher/convoy/objectstore/config.go @@ -0,0 +1,202 @@ +package objectstore + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/util" + "path/filepath" + + . "github.com/rancher/convoy/logging" +) + +const ( + OBJECTSTORE_BASE = "convoy-objectstore" + VOLUME_SEPARATE_LAYER1 = 2 + VOLUME_SEPARATE_LAYER2 = 4 + + VOLUME_DIRECTORY = "volumes" + VOLUME_CONFIG_FILE = "volume.cfg" + BACKUP_DIRECTORY = "backups" + BACKUP_CONFIG_PREFIX = "backup_" + + CFG_SUFFIX = ".cfg" +) + +func getBackupConfigName(id string) string { + return BACKUP_CONFIG_PREFIX + id + CFG_SUFFIX +} + +func loadConfigInObjectStore(filePath string, driver ObjectStoreDriver, v interface{}) error { + size := driver.FileSize(filePath) + if size < 0 { + return fmt.Errorf("cannot find %v in objectstore", filePath) + } + rc, err := driver.Read(filePath) + if err != nil { + return err + } + defer rc.Close() + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_START, + LOG_FIELD_OBJECT: LOG_OBJECT_CONFIG, + LOG_FIELD_KIND: driver.Kind(), + LOG_FIELD_FILEPATH: filePath, + }).Debug() + if err := json.NewDecoder(rc).Decode(v); err != nil { + return err + } + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_COMPLETE, + LOG_FIELD_OBJECT: LOG_OBJECT_CONFIG, + LOG_FIELD_KIND: driver.Kind(), + LOG_FIELD_FILEPATH: filePath, + }).Debug() + return nil +} + +func saveConfigInObjectStore(filePath string, driver ObjectStoreDriver, v interface{}) error { + j, err := json.Marshal(v) + if err != nil { + return err + } + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_START, + LOG_FIELD_OBJECT: LOG_OBJECT_CONFIG, + LOG_FIELD_KIND: driver.Kind(), + LOG_FIELD_FILEPATH: filePath, + }).Debug() + if err := driver.Write(filePath, bytes.NewReader(j)); err != nil { + return err + } + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_COMPLETE, + LOG_FIELD_OBJECT: LOG_OBJECT_CONFIG, + LOG_FIELD_KIND: driver.Kind(), + LOG_FIELD_FILEPATH: filePath, + }).Debug() + return nil +} + +func volumeExists(volumeName string, driver ObjectStoreDriver) bool { + volumeFile := getVolumeFilePath(volumeName) + return driver.FileExists(volumeFile) +} + +func getVolumePath(volumeName string) string { + name := volumeName + //Fix short volume name, add '!' at the end which cannot be used in valid name + for l := len(volumeName); l < 4; l++ { + name = name + "!" + } + volumeLayer1 := name[0:VOLUME_SEPARATE_LAYER1] + volumeLayer2 := name[VOLUME_SEPARATE_LAYER1:VOLUME_SEPARATE_LAYER2] + return filepath.Join(OBJECTSTORE_BASE, VOLUME_DIRECTORY, volumeLayer1, volumeLayer2, name) +} + +func getVolumeFilePath(volumeName string) string { + volumePath := getVolumePath(volumeName) + volumeCfg := VOLUME_CONFIG_FILE + return filepath.Join(volumePath, volumeCfg) +} + +func getVolumeNames(driver ObjectStoreDriver) ([]string, error) { + names := []string{} + + volumePathBase := filepath.Join(OBJECTSTORE_BASE, VOLUME_DIRECTORY) + lv1Dirs, err := driver.List(volumePathBase) + // Directory doesn't exist + if err != nil { + return names, nil + } + for _, lv1 := range lv1Dirs { + lv1Path := filepath.Join(volumePathBase, lv1) + lv2Dirs, err := driver.List(lv1Path) + if err != nil { + return nil, err + } + for _, lv2 := range lv2Dirs { + lv2Path := filepath.Join(lv1Path, lv2) + volumeNames, err := driver.List(lv2Path) + if err != nil { + return nil, err + } + names = append(names, volumeNames...) + } + } + return names, nil +} + +func loadVolume(volumeName string, driver ObjectStoreDriver) (*Volume, error) { + v := &Volume{} + file := getVolumeFilePath(volumeName) + if err := loadConfigInObjectStore(file, driver, v); err != nil { + return nil, err + } + return v, nil +} + +func saveVolume(v *Volume, driver ObjectStoreDriver) error { + file := getVolumeFilePath(v.Name) + if err := saveConfigInObjectStore(file, driver, v); err != nil { + return err + } + return nil +} + +func getBackupNamesForVolume(volumeName string, driver ObjectStoreDriver) ([]string, error) { + result := []string{} + fileList, err := driver.List(getBackupPath(volumeName)) + if err != nil { + // path doesn't exist + return result, nil + } + return util.ExtractNames(fileList, BACKUP_CONFIG_PREFIX, CFG_SUFFIX) +} + +func getBackupPath(volumeName string) string { + return filepath.Join(getVolumePath(volumeName), BACKUP_DIRECTORY) + "/" +} + +func getBackupConfigPath(backupName, volumeName string) string { + path := getBackupPath(volumeName) + fileName := getBackupConfigName(backupName) + return filepath.Join(path, fileName) +} + +func backupExists(backupName, volumeName string, bsDriver ObjectStoreDriver) bool { + return bsDriver.FileExists(getBackupConfigPath(backupName, volumeName)) +} + +func loadBackup(backupName, volumeName string, bsDriver ObjectStoreDriver) (*Backup, error) { + backup := &Backup{} + if err := loadConfigInObjectStore(getBackupConfigPath(backupName, volumeName), bsDriver, backup); err != nil { + return nil, err + } + return backup, nil +} + +func saveBackup(backup *Backup, bsDriver ObjectStoreDriver) error { + filePath := getBackupConfigPath(backup.Name, backup.VolumeName) + if bsDriver.FileExists(filePath) { + log.Warnf("Snapshot configuration file %v already exists, would remove it\n", filePath) + if err := bsDriver.Remove(filePath); err != nil { + return err + } + } + if err := saveConfigInObjectStore(filePath, bsDriver, backup); err != nil { + return err + } + return nil +} + +func removeBackup(backup *Backup, bsDriver ObjectStoreDriver) error { + filePath := getBackupConfigPath(backup.Name, backup.VolumeName) + if err := bsDriver.Remove(filePath); err != nil { + return err + } + log.Debugf("Removed %v on objectstore", filePath) + return nil +} diff --git a/vendor/github.com/rancher/convoy/objectstore/deltablock.go b/vendor/github.com/rancher/convoy/objectstore/deltablock.go new file mode 100644 index 00000000..f9f6adec --- /dev/null +++ b/vendor/github.com/rancher/convoy/objectstore/deltablock.go @@ -0,0 +1,389 @@ +package objectstore + +import ( + "fmt" + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/metadata" + "github.com/rancher/convoy/util" + "io" + "os" + "path/filepath" + + . "github.com/rancher/convoy/logging" +) + +type BlockMapping struct { + Offset int64 + BlockChecksum string +} + +type DeltaBlockBackupOperations interface { + HasSnapshot(id, volumeID string) bool + CompareSnapshot(id, compareID, volumeID string) (*metadata.Mappings, error) + OpenSnapshot(id, volumeID string) error + ReadSnapshot(id, volumeID string, start int64, data []byte) error + CloseSnapshot(id, volumeID string) error +} + +const ( + DEFAULT_BLOCK_SIZE = 2097152 + + BLOCKS_DIRECTORY = "blocks" + BLOCK_SEPARATE_LAYER1 = 2 + BLOCK_SEPARATE_LAYER2 = 4 +) + +func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, deltaOps DeltaBlockBackupOperations) (string, error) { + if deltaOps == nil { + return "", fmt.Errorf("Missing DeltaBlockBackupOperations") + } + + bsDriver, err := GetObjectStoreDriver(destURL) + if err != nil { + return "", err + } + + if err := addVolume(volume, bsDriver); err != nil { + return "", err + } + + // Update volume from objectstore + volume, err = loadVolume(volume.Name, bsDriver) + if err != nil { + return "", err + } + + lastBackupName := volume.LastBackupName + + var lastSnapshotName string + var lastBackup *Backup + if lastBackupName != "" { + lastBackup, err = loadBackup(lastBackupName, volume.Name, bsDriver) + if err != nil { + return "", err + } + + lastSnapshotName = lastBackup.SnapshotName + if lastSnapshotName == snapshot.Name { + //Generate full snapshot if the snapshot has been backed up last time + lastSnapshotName = "" + log.Debug("Would create full snapshot metadata") + } else if !deltaOps.HasSnapshot(lastSnapshotName, volume.Name) { + // It's possible that the snapshot in objectstore doesn't exist + // in local storage + lastSnapshotName = "" + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_FALLBACK, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_SNAPSHOT: lastSnapshotName, + LOG_FIELD_VOLUME: volume.Name, + }).Debug("Cannot find last snapshot in local storage, would process with full backup") + } + } + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_START, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_EVENT: LOG_EVENT_COMPARE, + LOG_FIELD_SNAPSHOT: snapshot.Name, + LOG_FIELD_LAST_SNAPSHOT: lastSnapshotName, + }).Debug("Generating snapshot changed blocks metadata") + + if err := deltaOps.OpenSnapshot(snapshot.Name, volume.Name); err != nil { + return "", err + } + defer deltaOps.CloseSnapshot(snapshot.Name, volume.Name) + + delta, err := deltaOps.CompareSnapshot(snapshot.Name, lastSnapshotName, volume.Name) + if err != nil { + return "", err + } + if delta.BlockSize != DEFAULT_BLOCK_SIZE { + return "", fmt.Errorf("Currently doesn't support different block sizes driver other than %v", DEFAULT_BLOCK_SIZE) + } + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_COMPLETE, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_EVENT: LOG_EVENT_COMPARE, + LOG_FIELD_SNAPSHOT: snapshot.Name, + LOG_FIELD_LAST_SNAPSHOT: lastSnapshotName, + }).Debug("Generated snapshot changed blocks metadata") + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_START, + LOG_FIELD_EVENT: LOG_EVENT_BACKUP, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_SNAPSHOT: snapshot.Name, + }).Debug("Creating backup") + + deltaBackup := &Backup{ + Name: util.GenerateName("backup"), + VolumeName: volume.Name, + SnapshotName: snapshot.Name, + Blocks: []BlockMapping{}, + } + mCounts := len(delta.Mappings) + for m, d := range delta.Mappings { + if d.Size%delta.BlockSize != 0 { + return "", fmt.Errorf("Mapping's size %v is not multiples of backup block size %v", + d.Size, delta.BlockSize) + } + block := make([]byte, DEFAULT_BLOCK_SIZE) + blkCounts := d.Size / delta.BlockSize + for i := int64(0); i < blkCounts; i++ { + offset := d.Offset + i*delta.BlockSize + log.Debugf("Backup for %v: segment %v/%v, blocks %v/%v", snapshot.Name, m+1, mCounts, i+1, blkCounts) + err := deltaOps.ReadSnapshot(snapshot.Name, volume.Name, offset, block) + if err != nil { + return "", err + } + checksum := util.GetChecksum(block) + blkFile := getBlockFilePath(volume.Name, checksum) + if bsDriver.FileSize(blkFile) >= 0 { + blockMapping := BlockMapping{ + Offset: offset, + BlockChecksum: checksum, + } + deltaBackup.Blocks = append(deltaBackup.Blocks, blockMapping) + log.Debugf("Found existed block match at %v", blkFile) + continue + } + + rs, err := util.CompressData(block) + if err != nil { + return "", err + } + + if err := bsDriver.Write(blkFile, rs); err != nil { + return "", err + } + log.Debugf("Created new block file at %v", blkFile) + + blockMapping := BlockMapping{ + Offset: offset, + BlockChecksum: checksum, + } + deltaBackup.Blocks = append(deltaBackup.Blocks, blockMapping) + } + } + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_COMPLETE, + LOG_FIELD_EVENT: LOG_EVENT_BACKUP, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_SNAPSHOT: snapshot.Name, + }).Debug("Created snapshot changed blocks") + + backup := mergeSnapshotMap(deltaBackup, lastBackup) + backup.SnapshotName = snapshot.Name + backup.SnapshotCreatedAt = snapshot.CreatedTime + backup.CreatedTime = util.Now() + + if err := saveBackup(backup, bsDriver); err != nil { + return "", err + } + + volume.LastBackupName = backup.Name + if err := saveVolume(volume, bsDriver); err != nil { + return "", err + } + + return encodeBackupURL(backup.Name, volume.Name, destURL), nil +} + +func mergeSnapshotMap(deltaBackup, lastBackup *Backup) *Backup { + if lastBackup == nil { + return deltaBackup + } + backup := &Backup{ + Name: deltaBackup.Name, + VolumeName: deltaBackup.VolumeName, + SnapshotName: deltaBackup.SnapshotName, + Blocks: []BlockMapping{}, + } + var d, l int + for d, l = 0, 0; d < len(deltaBackup.Blocks) && l < len(lastBackup.Blocks); { + dB := deltaBackup.Blocks[d] + lB := lastBackup.Blocks[l] + if dB.Offset == lB.Offset { + backup.Blocks = append(backup.Blocks, dB) + d++ + l++ + } else if dB.Offset < lB.Offset { + backup.Blocks = append(backup.Blocks, dB) + d++ + } else { + //dB.Offset > lB.offset + backup.Blocks = append(backup.Blocks, lB) + l++ + } + } + + if d == len(deltaBackup.Blocks) { + backup.Blocks = append(backup.Blocks, lastBackup.Blocks[l:]...) + } else { + backup.Blocks = append(backup.Blocks, deltaBackup.Blocks[d:]...) + } + + return backup +} + +func RestoreDeltaBlockBackup(backupURL, volDevName string) error { + bsDriver, err := GetObjectStoreDriver(backupURL) + if err != nil { + return err + } + + srcBackupName, srcVolumeName, err := decodeBackupURL(backupURL) + if err != nil { + return err + } + + if _, err := loadVolume(srcVolumeName, bsDriver); err != nil { + return generateError(logrus.Fields{ + LOG_FIELD_VOLUME: srcVolumeName, + LOG_FIELD_BACKUP_URL: backupURL, + }, "Volume doesn't exist in objectstore: %v", err) + } + + volDev, err := os.Create(volDevName) + if err != nil { + return err + } + defer volDev.Close() + + backup, err := loadBackup(srcBackupName, srcVolumeName, bsDriver) + if err != nil { + return err + } + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_START, + LOG_FIELD_EVENT: LOG_EVENT_RESTORE, + LOG_FIELD_OBJECT: LOG_FIELD_SNAPSHOT, + LOG_FIELD_SNAPSHOT: srcBackupName, + LOG_FIELD_ORIN_VOLUME: srcVolumeName, + LOG_FIELD_VOLUME_DEV: volDevName, + LOG_FIELD_BACKUP_URL: backupURL, + }).Debug() + blkCounts := len(backup.Blocks) + for i, block := range backup.Blocks { + log.Debugf("Restore for %v: block %v, %v/%v", volDevName, block.BlockChecksum, i+1, blkCounts) + blkFile := getBlockFilePath(srcVolumeName, block.BlockChecksum) + rc, err := bsDriver.Read(blkFile) + if err != nil { + return err + } + r, err := util.DecompressAndVerify(rc, block.BlockChecksum) + rc.Close() + if err != nil { + return err + } + if _, err := volDev.Seek(block.Offset, 0); err != nil { + return err + } + if _, err := io.CopyN(volDev, r, DEFAULT_BLOCK_SIZE); err != nil { + return err + } + } + + return nil +} + +func DeleteDeltaBlockBackup(backupURL string) error { + bsDriver, err := GetObjectStoreDriver(backupURL) + if err != nil { + return err + } + + backupName, volumeName, err := decodeBackupURL(backupURL) + if err != nil { + return err + } + + v, err := loadVolume(volumeName, bsDriver) + if err != nil { + return fmt.Errorf("Cannot find volume %v in objectstore", volumeName, err) + } + + backup, err := loadBackup(backupName, volumeName, bsDriver) + if err != nil { + return err + } + discardBlockSet := make(map[string]bool) + for _, blk := range backup.Blocks { + discardBlockSet[blk.BlockChecksum] = true + } + discardBlockCounts := len(discardBlockSet) + + if err := removeBackup(backup, bsDriver); err != nil { + return err + } + + if backup.Name == v.LastBackupName { + v.LastBackupName = "" + if err := saveVolume(v, bsDriver); err != nil { + return err + } + } + + backupNames, err := getBackupNamesForVolume(volumeName, bsDriver) + if err != nil { + return err + } + if len(backupNames) == 0 { + log.Debugf("No snapshot existed for the volume %v, removing volume", volumeName) + if err := removeVolume(volumeName, bsDriver); err != nil { + log.Warningf("Failed to remove volume %v due to: %v", volumeName, err.Error()) + } + return nil + } + + log.Debug("GC started") + for _, backupName := range backupNames { + backup, err := loadBackup(backupName, volumeName, bsDriver) + if err != nil { + return err + } + for _, blk := range backup.Blocks { + if _, exists := discardBlockSet[blk.BlockChecksum]; exists { + delete(discardBlockSet, blk.BlockChecksum) + discardBlockCounts-- + if discardBlockCounts == 0 { + break + } + } + } + if discardBlockCounts == 0 { + break + } + } + + var blkFileList []string + for blk := range discardBlockSet { + blkFileList = append(blkFileList, getBlockFilePath(volumeName, blk)) + log.Debugf("Found unused blocks %v for volume %v", blk, volumeName) + } + if err := bsDriver.Remove(blkFileList...); err != nil { + return err + } + log.Debug("Removed unused blocks for volume ", volumeName) + + log.Debug("GC completed") + log.Debug("Removed objectstore backup ", backupName) + + return nil +} + +func getBlockPath(volumeName string) string { + return filepath.Join(getVolumePath(volumeName), BLOCKS_DIRECTORY) + "/" +} + +func getBlockFilePath(volumeName, checksum string) string { + blockSubDirLayer1 := checksum[0:BLOCK_SEPARATE_LAYER1] + blockSubDirLayer2 := checksum[BLOCK_SEPARATE_LAYER1:BLOCK_SEPARATE_LAYER2] + path := filepath.Join(getBlockPath(volumeName), blockSubDirLayer1, blockSubDirLayer2) + fileName := checksum + ".blk" + + return filepath.Join(path, fileName) +} diff --git a/vendor/github.com/rancher/convoy/objectstore/driver.go b/vendor/github.com/rancher/convoy/objectstore/driver.go new file mode 100644 index 00000000..b9de7be8 --- /dev/null +++ b/vendor/github.com/rancher/convoy/objectstore/driver.go @@ -0,0 +1,63 @@ +package objectstore + +import ( + "fmt" + "github.com/Sirupsen/logrus" + "io" + "net/url" + + . "github.com/rancher/convoy/logging" +) + +type InitFunc func(destURL string) (ObjectStoreDriver, error) + +type ObjectStoreDriver interface { + Kind() string + GetURL() string + FileExists(filePath string) bool + FileSize(filePath string) int64 + Remove(names ...string) error // Bahavior like "rm -rf" + Read(src string) (io.ReadCloser, error) // Caller needs to close + Write(dst string, rs io.ReadSeeker) error + List(path string) ([]string, error) // Behavior like "ls", not like "find" + Upload(src, dst string) error + Download(src, dst string) error +} + +var ( + initializers map[string]InitFunc +) + +var ( + log = logrus.WithFields(logrus.Fields{"pkg": "objectstore"}) +) + +func generateError(fields logrus.Fields, format string, v ...interface{}) error { + return ErrorWithFields("objectstore", fields, format, v) +} + +func init() { + initializers = make(map[string]InitFunc) +} + +func RegisterDriver(kind string, initFunc InitFunc) error { + if _, exists := initializers[kind]; exists { + return fmt.Errorf("%s has already been registered", kind) + } + initializers[kind] = initFunc + return nil +} + +func GetObjectStoreDriver(destURL string) (ObjectStoreDriver, error) { + if destURL == "" { + return nil, fmt.Errorf("Destination URL hasn't been specified") + } + u, err := url.Parse(destURL) + if err != nil { + return nil, err + } + if _, exists := initializers[u.Scheme]; !exists { + return nil, fmt.Errorf("Driver %v is not supported!", u.Scheme) + } + return initializers[u.Scheme](destURL) +} diff --git a/vendor/github.com/rancher/convoy/objectstore/objectstore.go b/vendor/github.com/rancher/convoy/objectstore/objectstore.go new file mode 100644 index 00000000..a745ae61 --- /dev/null +++ b/vendor/github.com/rancher/convoy/objectstore/objectstore.go @@ -0,0 +1,185 @@ +package objectstore + +import ( + "fmt" + "github.com/rancher/convoy/util" + "net/url" + "strconv" +) + +type Volume struct { + Name string + Driver string + Size int64 + CreatedTime string + LastBackupName string +} + +type Snapshot struct { + Name string + CreatedTime string +} + +type Backup struct { + Name string + Driver string + VolumeName string + SnapshotName string + SnapshotCreatedAt string + CreatedTime string + + Blocks []BlockMapping `json:",omitempty"` + SingleFile BackupFile `json:",omitempty"` +} + +func addVolume(volume *Volume, driver ObjectStoreDriver) error { + if volumeExists(volume.Name, driver) { + return nil + } + + if err := saveVolume(volume, driver); err != nil { + log.Error("Fail add volume ", volume.Name) + return err + } + log.Debug("Added objectstore volume ", volume.Name) + + return nil +} + +func removeVolume(volumeName string, driver ObjectStoreDriver) error { + if !volumeExists(volumeName, driver) { + return fmt.Errorf("Volume %v doesn't exist in objectstore", volumeName) + } + + volumeDir := getVolumePath(volumeName) + if err := driver.Remove(volumeDir); err != nil { + return err + } + log.Debug("Removed volume directory in objectstore: ", volumeDir) + log.Debug("Removed objectstore volume ", volumeName) + + return nil +} + +func encodeBackupURL(backupName, volumeName, destURL string) string { + v := url.Values{} + v.Add("volume", volumeName) + v.Add("backup", backupName) + return destURL + "?" + v.Encode() +} + +func decodeBackupURL(backupURL string) (string, string, error) { + u, err := url.Parse(backupURL) + if err != nil { + return "", "", err + } + v := u.Query() + volumeName := v.Get("volume") + backupName := v.Get("backup") + if !util.ValidateName(volumeName) || !util.ValidateName(backupName) { + return "", "", fmt.Errorf("Invalid name parsed, got %v and %v", backupName, volumeName) + } + return backupName, volumeName, nil +} + +func addListVolume(resp map[string]map[string]string, volumeName string, driver ObjectStoreDriver, storageDriverName string) error { + if volumeName == "" { + return fmt.Errorf("Invalid empty volume Name") + } + + backupNames, err := getBackupNamesForVolume(volumeName, driver) + if err != nil { + return err + } + + volume, err := loadVolume(volumeName, driver) + if err != nil { + return err + } + //Skip any volumes not owned by specified storage driver + if volume.Driver != storageDriverName { + return nil + } + + for _, backupName := range backupNames { + backup, err := loadBackup(backupName, volumeName, driver) + if err != nil { + return err + } + r := fillBackupInfo(backup, volume, driver.GetURL()) + resp[r["BackupURL"]] = r + } + return nil +} + +func List(volumeName, destURL, storageDriverName string) (map[string]map[string]string, error) { + driver, err := GetObjectStoreDriver(destURL) + if err != nil { + return nil, err + } + resp := make(map[string]map[string]string) + if volumeName != "" { + if err = addListVolume(resp, volumeName, driver, storageDriverName); err != nil { + return nil, err + } + } else { + volumeNames, err := getVolumeNames(driver) + if err != nil { + return nil, err + } + for _, volumeName := range volumeNames { + if err := addListVolume(resp, volumeName, driver, storageDriverName); err != nil { + return nil, err + } + } + } + return resp, nil +} + +func fillBackupInfo(backup *Backup, volume *Volume, destURL string) map[string]string { + return map[string]string{ + "BackupName": backup.Name, + "BackupURL": encodeBackupURL(backup.Name, backup.VolumeName, destURL), + "DriverName": volume.Driver, + "VolumeName": backup.VolumeName, + "VolumeSize": strconv.FormatInt(volume.Size, 10), + "VolumeCreatedAt": volume.CreatedTime, + "SnapshotName": backup.SnapshotName, + "SnapshotCreatedAt": backup.SnapshotCreatedAt, + "CreatedTime": backup.CreatedTime, + } +} + +func GetBackupInfo(backupURL string) (map[string]string, error) { + driver, err := GetObjectStoreDriver(backupURL) + if err != nil { + return nil, err + } + backupName, volumeName, err := decodeBackupURL(backupURL) + if err != nil { + return nil, err + } + + volume, err := loadVolume(volumeName, driver) + if err != nil { + return nil, err + } + + backup, err := loadBackup(backupName, volumeName, driver) + if err != nil { + return nil, err + } + return fillBackupInfo(backup, volume, driver.GetURL()), nil +} + +func LoadVolume(backupURL string) (*Volume, error) { + _, volumeName, err := decodeBackupURL(backupURL) + if err != nil { + return nil, err + } + driver, err := GetObjectStoreDriver(backupURL) + if err != nil { + return nil, err + } + return loadVolume(volumeName, driver) +} diff --git a/vendor/github.com/rancher/convoy/objectstore/singlefile.go b/vendor/github.com/rancher/convoy/objectstore/singlefile.go new file mode 100644 index 00000000..0ecda0b5 --- /dev/null +++ b/vendor/github.com/rancher/convoy/objectstore/singlefile.go @@ -0,0 +1,136 @@ +package objectstore + +import ( + "fmt" + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/util" + "path/filepath" + + . "github.com/rancher/convoy/logging" +) + +const ( + BACKUP_FILES_DIRECTORY = "BackupFiles" +) + +type BackupFile struct { + FilePath string +} + +func getSingleFileBackupFilePath(sfBackup *Backup) string { + backupFileName := sfBackup.Name + ".bak" + return filepath.Join(getVolumePath(sfBackup.VolumeName), BACKUP_FILES_DIRECTORY, backupFileName) +} + +func CreateSingleFileBackup(volume *Volume, snapshot *Snapshot, filePath, destURL string) (string, error) { + driver, err := GetObjectStoreDriver(destURL) + if err != nil { + return "", err + } + + if err := addVolume(volume, driver); err != nil { + return "", err + } + + volume, err = loadVolume(volume.Name, driver) + if err != nil { + return "", err + } + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_START, + LOG_FIELD_EVENT: LOG_EVENT_BACKUP, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_SNAPSHOT: snapshot.Name, + LOG_FIELD_FILEPATH: filePath, + }).Debug("Creating backup") + + backup := &Backup{ + Name: util.GenerateName("backup"), + VolumeName: volume.Name, + SnapshotName: snapshot.Name, + SnapshotCreatedAt: snapshot.CreatedTime, + } + backup.SingleFile.FilePath = getSingleFileBackupFilePath(backup) + + if err := driver.Upload(filePath, backup.SingleFile.FilePath); err != nil { + return "", err + } + + backup.CreatedTime = util.Now() + if err := saveBackup(backup, driver); err != nil { + return "", err + } + + log.WithFields(logrus.Fields{ + LOG_FIELD_REASON: LOG_REASON_COMPLETE, + LOG_FIELD_EVENT: LOG_EVENT_BACKUP, + LOG_FIELD_OBJECT: LOG_OBJECT_SNAPSHOT, + LOG_FIELD_SNAPSHOT: snapshot.Name, + }).Debug("Created backup") + + return encodeBackupURL(backup.Name, volume.Name, destURL), nil +} + +func RestoreSingleFileBackup(backupURL, path string) (string, error) { + driver, err := GetObjectStoreDriver(backupURL) + if err != nil { + return "", err + } + + srcBackupName, srcVolumeName, err := decodeBackupURL(backupURL) + if err != nil { + return "", err + } + + if _, err := loadVolume(srcVolumeName, driver); err != nil { + return "", generateError(logrus.Fields{ + LOG_FIELD_VOLUME: srcVolumeName, + LOG_FIELD_BACKUP_URL: backupURL, + }, "Volume doesn't exist in objectstore: %v", err) + } + + backup, err := loadBackup(srcBackupName, srcVolumeName, driver) + if err != nil { + return "", err + } + + dstFile := filepath.Join(path, filepath.Base(backup.SingleFile.FilePath)) + if err := driver.Download(backup.SingleFile.FilePath, dstFile); err != nil { + return "", err + } + + return dstFile, nil +} + +func DeleteSingleFileBackup(backupURL string) error { + driver, err := GetObjectStoreDriver(backupURL) + if err != nil { + return err + } + + backupName, volumeName, err := decodeBackupURL(backupURL) + if err != nil { + return err + } + + _, err = loadVolume(volumeName, driver) + if err != nil { + return fmt.Errorf("Cannot find volume %v in objectstore", volumeName, err) + } + + backup, err := loadBackup(backupName, volumeName, driver) + if err != nil { + return err + } + + if err := driver.Remove(backup.SingleFile.FilePath); err != nil { + return err + } + + if err := removeBackup(backup, driver); err != nil { + return err + } + + return nil +} diff --git a/vendor/github.com/rancher/convoy/s3/s3.go b/vendor/github.com/rancher/convoy/s3/s3.go new file mode 100644 index 00000000..6af0931e --- /dev/null +++ b/vendor/github.com/rancher/convoy/s3/s3.go @@ -0,0 +1,191 @@ +package s3 + +import ( + "fmt" + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/objectstore" + "io" + "net/url" + "os" + "path/filepath" + "strings" +) + +var ( + log = logrus.WithFields(logrus.Fields{"pkg": "s3"}) +) + +type S3ObjectStoreDriver struct { + destURL string + path string + service S3Service +} + +const ( + KIND = "s3" +) + +func init() { + objectstore.RegisterDriver(KIND, initFunc) +} + +func initFunc(destURL string) (objectstore.ObjectStoreDriver, error) { + b := &S3ObjectStoreDriver{} + + u, err := url.Parse(destURL) + if err != nil { + return nil, err + } + + if u.Scheme != KIND { + return nil, fmt.Errorf("BUG: Why dispatch %v to %v?", u.Scheme, KIND) + } + + if u.User != nil { + b.service.Region = u.Host + b.service.Bucket = u.User.Username() + } else { + //We would depends on AWS_REGION environment variable + b.service.Bucket = u.Host + } + b.path = u.Path + if b.service.Bucket == "" || b.path == "" { + return nil, fmt.Errorf("Invalid URL. Must be either s3://bucket@region/path/, or s3://bucket/path") + } + + //Leading '/' can cause mystery problems for s3 + b.path = strings.TrimLeft(b.path, "/") + + //Test connection + if _, err := b.List(""); err != nil { + return nil, err + } + + b.destURL = KIND + "://" + b.service.Bucket + if b.service.Region != "" { + b.destURL += "@" + b.service.Region + } + b.destURL += "/" + b.path + + log.Debug("Loaded driver for %v", b.destURL) + return b, nil +} + +func (s *S3ObjectStoreDriver) Kind() string { + return KIND +} + +func (s *S3ObjectStoreDriver) GetURL() string { + return s.destURL +} + +func (s *S3ObjectStoreDriver) updatePath(path string) string { + return filepath.Join(s.path, path) +} + +func (s *S3ObjectStoreDriver) List(listPath string) ([]string, error) { + var result []string + + path := s.updatePath(listPath) + "/" + contents, prefixes, err := s.service.ListObjects(path, "/") + if err != nil { + log.Error("Fail to list s3: ", err) + return result, err + } + + sizeC := len(contents) + sizeP := len(prefixes) + if sizeC == 0 && sizeP == 0 { + return result, nil + } + result = []string{} + for _, obj := range contents { + r := strings.TrimPrefix(*obj.Key, path) + if r != "" { + result = append(result, r) + } + } + for _, p := range prefixes { + r := strings.TrimPrefix(*p.Prefix, path) + r = strings.TrimSuffix(r, "/") + if r != "" { + result = append(result, r) + } + } + + return result, nil +} + +func (s *S3ObjectStoreDriver) FileExists(filePath string) bool { + return s.FileSize(filePath) >= 0 +} + +func (s *S3ObjectStoreDriver) FileSize(filePath string) int64 { + path := s.updatePath(filePath) + head, err := s.service.HeadObject(path) + if err != nil { + return -1 + } + if head.ContentLength == nil { + return -1 + } + return *head.ContentLength +} + +func (s *S3ObjectStoreDriver) Remove(names ...string) error { + if len(names) == 0 { + return nil + } + paths := make([]string, len(names)) + for i, name := range names { + paths[i] = s.updatePath(name) + } + return s.service.DeleteObjects(paths) +} + +func (s *S3ObjectStoreDriver) Read(src string) (io.ReadCloser, error) { + path := s.updatePath(src) + rc, err := s.service.GetObject(path) + if err != nil { + return nil, err + } + return rc, nil +} + +func (s *S3ObjectStoreDriver) Write(dst string, rs io.ReadSeeker) error { + path := s.updatePath(dst) + return s.service.PutObject(path, rs) +} + +func (s *S3ObjectStoreDriver) Upload(src, dst string) error { + file, err := os.Open(src) + if err != nil { + return nil + } + defer file.Close() + path := s.updatePath(dst) + return s.service.PutObject(path, file) +} + +func (s *S3ObjectStoreDriver) Download(src, dst string) error { + if _, err := os.Stat(dst); err != nil { + os.Remove(dst) + } + f, err := os.Create(dst) + if err != nil { + return err + } + defer f.Close() + path := s.updatePath(src) + rc, err := s.service.GetObject(path) + if err != nil { + return err + } + defer rc.Close() + + _, err = io.Copy(f, rc) + if err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/rancher/convoy/s3/s3_service.go b/vendor/github.com/rancher/convoy/s3/s3_service.go new file mode 100644 index 00000000..4107c8ff --- /dev/null +++ b/vendor/github.com/rancher/convoy/s3/s3_service.go @@ -0,0 +1,157 @@ +package s3 + +import ( + "fmt" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/s3" + "io" +) + +type S3Service struct { + Region string + Bucket string +} + +func (s *S3Service) New() (*s3.S3, error) { + return s3.New(session.New(), &aws.Config{Region: &s.Region}), nil +} + +func (s *S3Service) Close() { +} + +func parseAwsError(resp string, err error) error { + log.Errorln(resp) + if awsErr, ok := err.(awserr.Error); ok { + message := fmt.Sprintln("AWS Error: ", awsErr.Code(), awsErr.Message(), awsErr.OrigErr()) + if reqErr, ok := err.(awserr.RequestFailure); ok { + message += fmt.Sprintln(reqErr.StatusCode(), reqErr.RequestID()) + } + return fmt.Errorf(message) + } + return err +} + +func (s *S3Service) ListObjects(key, delimiter string) ([]*s3.Object, []*s3.CommonPrefix, error) { + svc, err := s.New() + if err != nil { + return nil, nil, err + } + defer s.Close() + // WARNING: Directory must end in "/" in S3, otherwise it may match + // unintentially + params := &s3.ListObjectsInput{ + Bucket: aws.String(s.Bucket), + Prefix: aws.String(key), + Delimiter: aws.String(delimiter), + } + resp, err := svc.ListObjects(params) + if err != nil { + return nil, nil, parseAwsError(resp.String(), err) + } + return resp.Contents, resp.CommonPrefixes, nil +} + +func (s *S3Service) HeadObject(key string) (*s3.HeadObjectOutput, error) { + svc, err := s.New() + if err != nil { + return nil, err + } + defer s.Close() + params := &s3.HeadObjectInput{ + Bucket: aws.String(s.Bucket), + Key: aws.String(key), + } + resp, err := svc.HeadObject(params) + if err != nil { + return nil, parseAwsError(resp.String(), err) + } + return resp, nil +} + +func (s *S3Service) PutObject(key string, reader io.ReadSeeker) error { + svc, err := s.New() + if err != nil { + return err + } + defer s.Close() + + params := &s3.PutObjectInput{ + Bucket: aws.String(s.Bucket), + Key: aws.String(key), + Body: reader, + } + + resp, err := svc.PutObject(params) + if err != nil { + return parseAwsError(resp.String(), err) + } + return nil +} + +func (s *S3Service) GetObject(key string) (io.ReadCloser, error) { + svc, err := s.New() + if err != nil { + return nil, err + } + defer s.Close() + + params := &s3.GetObjectInput{ + Bucket: aws.String(s.Bucket), + Key: aws.String(key), + } + + resp, err := svc.GetObject(params) + if err != nil { + return nil, parseAwsError(resp.String(), err) + } + + return resp.Body, nil +} + +func (s *S3Service) DeleteObjects(keys []string) error { + var keyList []string + totalSize := 0 + for _, key := range keys { + contents, _, err := s.ListObjects(key, "") + if err != nil { + return err + } + size := len(contents) + if size == 0 { + continue + } + totalSize += size + for _, obj := range contents { + keyList = append(keyList, *obj.Key) + } + } + + svc, err := s.New() + if err != nil { + return err + } + defer s.Close() + + identifiers := make([]*s3.ObjectIdentifier, totalSize) + for i, k := range keyList { + identifiers[i] = &s3.ObjectIdentifier{ + Key: aws.String(k), + } + } + quiet := true + params := &s3.DeleteObjectsInput{ + Bucket: aws.String(s.Bucket), + Delete: &s3.Delete{ + Objects: identifiers, + Quiet: &quiet, + }, + } + + resp, err := svc.DeleteObjects(params) + if err != nil { + return parseAwsError(resp.String(), err) + } + return nil +} diff --git a/vendor/github.com/rancher/convoy/util/config.go b/vendor/github.com/rancher/convoy/util/config.go new file mode 100644 index 00000000..65c6ab9e --- /dev/null +++ b/vendor/github.com/rancher/convoy/util/config.go @@ -0,0 +1,155 @@ +package util + +import ( + "encoding/json" + "errors" + "fmt" + "os" + "path" + "path/filepath" + "reflect" +) + +var errDoesNotExist = errors.New("No such volume") + +func LoadConfig(fileName string, v interface{}) error { + if _, err := os.Stat(fileName); err != nil { + return err + } + + file, err := os.Open(fileName) + if err != nil { + return err + } + + defer file.Close() + + if err = json.NewDecoder(file).Decode(v); err != nil { + return err + } + return nil +} + +func SaveConfig(fileName string, v interface{}) error { + tmpFileName := fileName + ".tmp" + + f, err := os.Create(tmpFileName) + if err != nil { + return err + } + + if err := json.NewEncoder(f).Encode(v); err != nil { + f.Close() + return err + } + f.Close() + + if _, err = os.Stat(fileName); err == nil { + if err = os.Remove(fileName); err != nil { + return err + } + } + + if err := os.Rename(tmpFileName, fileName); err != nil { + return err + } + + return nil +} + +func ConfigExists(fileName string) bool { + _, err := os.Stat(fileName) + return err == nil +} + +func RemoveConfig(fileName string) error { + if _, err := Execute("rm", []string{"-f", fileName}); err != nil { + return err + } + return nil +} + +func ListConfigIDs(root, prefix, suffix string) ([]string, error) { + pattern := path.Join(root, fmt.Sprintf("%s*%s", prefix, suffix)) + out, err := filepath.Glob(pattern) + if err != nil { + return nil, err + } + if len(out) == 0 { + return []string{}, nil + } + for i := range out { + out[i] = path.Base(out[i]) + } + return ExtractNames(out, prefix, suffix) +} + +type ObjectOperations interface { + ConfigFile() (string, error) +} + +func getObjectOps(obj interface{}) (ObjectOperations, error) { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return nil, fmt.Errorf("BUG: Non-pointer was passed in") + } + t := reflect.TypeOf(obj).Elem() + ops, ok := obj.(ObjectOperations) + if !ok { + return nil, fmt.Errorf("BUG: %v doesn't implement necessary methods for accessing object", t) + } + return ops, nil +} + +func ObjectConfig(obj interface{}) (string, error) { + ops, err := getObjectOps(obj) + if err != nil { + return "", err + } + config, err := ops.ConfigFile() + if err != nil { + return "", err + } + return config, nil +} + +func ObjectLoad(obj interface{}) error { + config, err := ObjectConfig(obj) + if err != nil { + return err + } + if !ConfigExists(config) { + return errDoesNotExist + } + if err := LoadConfig(config, obj); err != nil { + return err + } + return nil +} + +func ObjectExists(obj interface{}) (bool, error) { + config, err := ObjectConfig(obj) + if err != nil { + return false, err + } + return ConfigExists(config), nil +} + +func ObjectSave(obj interface{}) error { + config, err := ObjectConfig(obj) + if err != nil { + return err + } + return SaveConfig(config, obj) +} + +func ObjectDelete(obj interface{}) error { + config, err := ObjectConfig(obj) + if err != nil { + return err + } + return RemoveConfig(config) +} + +func IsNotExistsError(err error) bool { + return err == errDoesNotExist +} diff --git a/vendor/github.com/rancher/convoy/util/index.go b/vendor/github.com/rancher/convoy/util/index.go new file mode 100644 index 00000000..2b00e849 --- /dev/null +++ b/vendor/github.com/rancher/convoy/util/index.go @@ -0,0 +1,55 @@ +package util + +import ( + "fmt" + "sync" +) + +type Index struct { + data map[string]string + lock *sync.RWMutex +} + +func NewIndex() *Index { + return &Index{data: make(map[string]string), lock: &sync.RWMutex{}} +} + +func (idx *Index) Add(key, value string) error { + if key == "" { + return fmt.Errorf("BUG: Invalid empty index key") + } + if value == "" { + return fmt.Errorf("BUG: Invalid empty index value") + } + + idx.lock.Lock() + defer idx.lock.Unlock() + + if oldValue, exists := idx.data[key]; exists { + if oldValue != value { + return fmt.Errorf("BUG: Conflict when updating index, %v was mapped to %v, but %v want to be mapped too", key, oldValue, value) + } + return nil + } + idx.data[key] = value + return nil +} + +func (idx *Index) Delete(key string) error { + if key == "" { + return fmt.Errorf("BUG: Invalid empty index key") + } + + idx.lock.Lock() + defer idx.lock.Unlock() + + delete(idx.data, key) + return nil +} + +func (idx *Index) Get(key string) string { + idx.lock.RLock() + defer idx.lock.RUnlock() + + return idx.data[key] +} diff --git a/vendor/github.com/rancher/convoy/util/util.go b/vendor/github.com/rancher/convoy/util/util.go new file mode 100644 index 00000000..9e1cacd0 --- /dev/null +++ b/vendor/github.com/rancher/convoy/util/util.go @@ -0,0 +1,433 @@ +package util + +import ( + "bytes" + "compress/gzip" + "crypto/sha512" + "encoding/hex" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net" + "net/http" + "os" + "os/exec" + "regexp" + "strconv" + "strings" + "time" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/mcuadros/go-version" + "github.com/satori/go.uuid" + "golang.org/x/sys/unix" +) + +const ( + PRESERVED_CHECKSUM_LENGTH = 64 +) + +var ( + log = logrus.WithFields(logrus.Fields{"pkg": "util"}) + + cmdTimeout time.Duration = time.Minute // one minute by default +) + +func InitTimeout(timeout string) { + if timeout == "" { + return + } + + duration, err := time.ParseDuration(timeout) + if err != nil || duration < cmdTimeout { + log.Errorf("Invalid timeout value %s specified, default to one minute", timeout) + return + } + + log.Debugf("Set command timeout value to: %s", duration.String()) + cmdTimeout = duration +} + +func EncodeData(v interface{}) (*bytes.Buffer, error) { + param := bytes.NewBuffer(nil) + j, err := json.Marshal(v) + if err != nil { + return nil, err + } + if _, err := param.Write(j); err != nil { + return nil, err + } + return param, nil +} + +func MkdirIfNotExists(path string) error { + if _, err := os.Stat(path); os.IsNotExist(err) { + if err := os.MkdirAll(path, os.ModeDir|0700); err != nil { + return err + } + } + return nil +} + +func GetChecksum(data []byte) string { + checksumBytes := sha512.Sum512(data) + checksum := hex.EncodeToString(checksumBytes[:])[:PRESERVED_CHECKSUM_LENGTH] + return checksum +} + +func LockFile(fileName string) (*os.File, error) { + f, err := os.Create(fileName) + if err != nil { + return nil, err + } + if err := unix.Flock(int(f.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil { + f.Close() + return nil, err + } + return f, nil +} + +func UnlockFile(f *os.File) error { + defer f.Close() + if err := unix.Flock(int(f.Fd()), unix.LOCK_UN); err != nil { + return err + } + if _, err := Execute("rm", []string{f.Name()}); err != nil { + return err + } + return nil +} + +func SliceToMap(slices []string) map[string]string { + result := map[string]string{} + for _, v := range slices { + pair := strings.Split(v, "=") + if len(pair) != 2 { + return nil + } + result[pair[0]] = pair[1] + } + return result +} + +func GetFileChecksum(filePath string) (string, error) { + output, err := Execute("sha512sum", []string{"-b", filePath}) + if err != nil { + return "", err + } + return strings.Split(string(output), " ")[0], nil +} + +func CompressFile(filePath string) error { + if _, err := Execute("gzip", []string{filePath}); err != nil { + return err + } + return nil +} + +func DecompressFile(filePath string) error { + if _, err := Execute("gunzip", []string{filePath}); err != nil { + return err + } + return nil +} + +func CompressDir(sourceDir, targetFile string) error { + tmpFile := targetFile + ".tmp" + if _, err := Execute("tar", []string{"cf", tmpFile, "-C", sourceDir, "."}); err != nil { + return err + } + if _, err := Execute("gzip", []string{tmpFile}); err != nil { + return err + } + if _, err := Execute("mv", []string{"-f", tmpFile + ".gz", targetFile}); err != nil { + return err + } + return nil +} + +// If sourceFile is inside targetDir, it would be deleted automatically +func DecompressDir(sourceFile, targetDir string) error { + tmpDir := targetDir + ".tmp" + if _, err := Execute("rm", []string{"-rf", tmpDir}); err != nil { + return err + } + if err := os.Mkdir(tmpDir, os.ModeDir|0700); err != nil { + return err + } + if _, err := Execute("tar", []string{"xf", sourceFile, "-C", tmpDir}); err != nil { + return err + } + if _, err := Execute("rm", []string{"-rf", targetDir}); err != nil { + return err + } + if _, err := Execute("mv", []string{"-f", tmpDir, targetDir}); err != nil { + return err + } + return nil +} + +func Copy(src, dst string) error { + if _, err := Execute("cp", []string{src, dst}); err != nil { + return err + } + return nil +} + +func AttachLoopbackDevice(file string, readonly bool) (string, error) { + params := []string{"--show", "-f"} + if readonly { + params = append(params, "-r") + } + params = append(params, file) + out, err := Execute("losetup", params) + if err != nil { + return "", err + } + if len(out) == 0 { + return "", fmt.Errorf("losetup --show doesn't return device name") + } + return strings.TrimSpace(out), nil +} + +func DetachLoopbackDevice(file, dev string) error { + output, err := Execute("losetup", []string{dev}) + if err != nil { + return err + } + out := strings.TrimSpace(string(output)) + suffix := "(" + file + ")" + if !strings.HasSuffix(out, suffix) { + return fmt.Errorf("Unmatched source file, output %v, suffix %v", out, suffix) + } + if _, err := Execute("losetup", []string{"-d", dev}); err != nil { + return err + } + return nil +} + +func ValidateName(name string) bool { + validName := regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`) + return validName.MatchString(name) +} + +func CheckName(name string) error { + if name == "" { + return nil + } + if !ValidateName(name) { + return fmt.Errorf("Invalid name %v", name) + } + return nil +} + +func ParseSize(size string) (int64, error) { + if size == "" { + return 0, nil + } + size = strings.ToLower(size) + readableSize := regexp.MustCompile(`^[0-9.]+[kmgt]$`) + if !readableSize.MatchString(size) { + value, err := strconv.ParseInt(size, 10, 64) + return value, err + } + + last := len(size) - 1 + unit := string(size[last]) + value, err := strconv.ParseInt(size[:last], 10, 64) + if err != nil { + return 0, err + } + + kb := int64(1024) + mb := 1024 * kb + gb := 1024 * mb + tb := 1024 * gb + switch unit { + case "k": + value *= kb + case "m": + value *= mb + case "g": + value *= gb + case "t": + value *= tb + default: + return 0, fmt.Errorf("Unrecongized size value %v", size) + } + return value, err +} + +func CheckBinaryVersion(binaryName, minVersion string, args []string) error { + output, err := exec.Command(binaryName, args...).CombinedOutput() + if err != nil { + return fmt.Errorf("Failed version check for %s, due to %s", binaryName, err.Error()) + } + v := strings.TrimSpace(string(output)) + if version.Compare(v, minVersion, "<") { + return fmt.Errorf("Minimal require version for %s is %s, detected %s", + binaryName, minVersion, v) + } + return nil +} + +func Execute(binary string, args []string) (string, error) { + var output []byte + var err error + cmd := exec.Command(binary, args...) + done := make(chan struct{}) + + go func() { + output, err = cmd.CombinedOutput() + done <- struct{}{} + }() + + select { + case <-done: + case <-time.After(cmdTimeout): + if cmd.Process != nil { + cmd.Process.Kill() + } + return "", fmt.Errorf("Timeout executing: %v %v, output %v, error %v", binary, args, string(output), err) + } + + if err != nil { + return "", fmt.Errorf("Failed to execute: %v %v, output %v, error %v", binary, args, string(output), err) + } + return string(output), nil +} + +func Now() string { + return time.Now().Format(time.RubyDate) +} + +func CompressData(data []byte) (io.ReadSeeker, error) { + var b bytes.Buffer + w := gzip.NewWriter(&b) + if _, err := w.Write(data); err != nil { + w.Close() + return nil, err + } + w.Close() + return bytes.NewReader(b.Bytes()), nil +} + +func DecompressAndVerify(src io.Reader, checksum string) (io.Reader, error) { + r, err := gzip.NewReader(src) + if err != nil { + return nil, err + } + block, err := ioutil.ReadAll(r) + if err != nil { + return nil, err + } + if GetChecksum(block) != checksum { + return nil, fmt.Errorf("Checksum verification failed for block!") + } + return bytes.NewReader(block), nil +} + +func GetName(v interface{}, key string, required bool, err error) (string, error) { + name, err := GetFlag(v, key, required, err) + if err != nil { + return name, err + } + if !required && name == "" { + return name, nil + } + if err := CheckName(name); err != nil { + return "", err + } + return name, nil +} + +func RequiredMissingError(name string) error { + return fmt.Errorf("Cannot find valid required parameter:", name) +} + +func GetFlag(v interface{}, key string, required bool, err error) (string, error) { + if err != nil { + return "", err + } + value := "" + switch v := v.(type) { + default: + return "", fmt.Errorf("Unexpected type for getLowerCaseFlag") + case *cli.Context: + if key == "" { + value = v.Args().First() + } else { + value = v.String(key) + } + case map[string]string: + value = v[key] + case *http.Request: + if err := v.ParseForm(); err != nil { + return "", err + } + value = v.FormValue(key) + } + if required && value == "" { + err = RequiredMissingError(key) + } + return value, err +} + +func UnescapeURL(url string) string { + // Deal with escape in url inputed from bash + result := strings.Replace(url, "\\u0026", "&", 1) + result = strings.Replace(result, "u0026", "&", 1) + return result +} + +func ValidNetworkAddr(addr string) bool { + //Is it a IP + ip := net.ParseIP(addr) + if ip != nil { + return true + } + //Or host + ips, err := net.LookupIP(addr) + if err != nil { + return false + } + if ips == nil || len(ips) == 0 { + return false + } + return true +} + +func GetFieldFromOpts(name string, opts map[string]string) (string, error) { + value, exists := opts[name] + if !exists { + return "", fmt.Errorf("Cannot find field named %v in options", name) + } + return value, nil +} + +func ExtractNames(names []string, prefix, suffix string) ([]string, error) { + result := []string{} + for i := range names { + f := names[i] + // Remove additional slash if exists + f = strings.TrimLeft(f, "/") + f = strings.TrimPrefix(f, prefix) + f = strings.TrimSuffix(f, suffix) + if !ValidateName(f) { + return nil, fmt.Errorf("Invalid name %v was processed to extract name with prefix %v surfix %v", names[i], prefix, suffix) + } + result = append(result, f) + } + return result, nil +} + +func GenerateName(prefix string) string { + suffix := strings.Replace(NewUUID(), "-", "", -1) + return prefix + "-" + suffix[:16] +} + +func NewUUID() string { + return uuid.NewV4().String() +} diff --git a/vendor/github.com/rancher/convoy/util/volume.go b/vendor/github.com/rancher/convoy/util/volume.go new file mode 100644 index 00000000..e3afcaae --- /dev/null +++ b/vendor/github.com/rancher/convoy/util/volume.go @@ -0,0 +1,459 @@ +package util + +import ( + "fmt" + "os" + "path/filepath" + "reflect" + "strconv" + "strings" +) + +const ( + MOUNT_BINARY = "mount" + UMOUNT_BINARY = "umount" + NSENTER_BINARY = "nsenter" + + IMAGE_FILE_NAME = "disk.img" + BLOCK_DEV_NAME = "disk.dev" + + FILE_TYPE_REGULAR = "regular file" + FILE_TYPE_DIRECTORY = "directory" + FILE_TYPE_BLOCKDEVICE = "block special file" + + FILE_STAT_FORMAT_SIZE = "%s" + FILE_STAT_FORMAT_TYPE = "%F" + FILE_STAT_FORMAT_MAJOR_MINOR = "%t %T" +) + +var ( + mountNamespaceFD = "" +) + +/* Caller must implement VolumeHelper interface, and must have fields "Name" and "MountPoint" */ +type VolumeHelper interface { + GetDevice() (string, error) + GetMountOpts() []string + GenerateDefaultMountPoint() string +} + +func getFieldString(obj interface{}, field string) (string, error) { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return "", fmt.Errorf("BUG: Non-pointer was passed in") + } + t := reflect.TypeOf(obj).Elem() + if _, found := t.FieldByName(field); !found { + return "", fmt.Errorf("BUG: %v doesn't have required field %v", t, field) + } + return reflect.ValueOf(obj).Elem().FieldByName(field).String(), nil +} + +func setFieldString(obj interface{}, field string, value string) error { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Errorf("BUG: Non-pointer was passed in") + } + t := reflect.TypeOf(obj).Elem() + if _, found := t.FieldByName(field); !found { + return fmt.Errorf("BUG: %v doesn't have required field %v", t, field) + } + v := reflect.ValueOf(obj).Elem().FieldByName(field) + if !v.CanSet() { + return fmt.Errorf("BUG: %v doesn't have setable field %v", t, field) + } + v.SetString(value) + return nil +} + +func getVolumeName(v VolumeHelper) string { + // We should already pass the test in getVolumeOps + value, err := getFieldString(v, "Name") + if err != nil { + panic(err) + } + return value +} + +func getVolumeMountPoint(v VolumeHelper) string { + // We should already pass the test in getVolumeOps + value, err := getFieldString(v, "MountPoint") + if err != nil { + panic(err) + } + return value +} + +func setVolumeMountPoint(v VolumeHelper, value string) { + // We should already pass the test in getVolumeOps + if err := setFieldString(v, "MountPoint", value); err != nil { + panic(err) + } +} + +func getVolumeOps(obj interface{}) (VolumeHelper, error) { + var err error + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return nil, fmt.Errorf("BUG: Non-pointer was passed in") + } + _, err = getFieldString(obj, "Name") + if err != nil { + return nil, err + } + mountpoint, err := getFieldString(obj, "MountPoint") + if err != nil { + return nil, err + } + if err = setFieldString(obj, "MountPoint", mountpoint); err != nil { + return nil, err + } + t := reflect.TypeOf(obj).Elem() + ops, ok := obj.(VolumeHelper) + if !ok { + return nil, fmt.Errorf("BUG: %v doesn't implement necessary methods for accessing volume", t) + } + return ops, nil +} + +func isMounted(mountPoint string) bool { + output, err := callMount([]string{}, []string{}) + if err != nil { + return false + } + lines := strings.Split(output, "\n") + for _, line := range lines { + if strings.Contains(line, mountPoint) { + return true + } + } + return false +} + +func VolumeMount(v interface{}, mountPoint string, remount bool) (string, error) { + vol, err := getVolumeOps(v) + if err != nil { + return "", err + } + dev, err := vol.GetDevice() + if err != nil { + return "", err + } + opts := vol.GetMountOpts() + createMountpoint := false + if mountPoint == "" { + mountPoint = vol.GenerateDefaultMountPoint() + // Create of directory cannot be done before umount, because it + // won't be recognized as a directory file when mounted sometime + createMountpoint = true + } + existMount := getVolumeMountPoint(vol) + if existMount != "" && existMount != mountPoint { + return "", fmt.Errorf("Volume %v was already mounted at %v, but asked to mount at %v", getVolumeName(vol), existMount, mountPoint) + } + if remount && isMounted(mountPoint) { + log.Debugf("Umount existing mountpoint %v", mountPoint) + if err := callUmount([]string{mountPoint}); err != nil { + return "", err + } + } + if createMountpoint { + if err := callMkdirIfNotExists(mountPoint); err != nil { + return "", err + } + } + if !isMounted(mountPoint) { + log.Debugf("Volume %v is being mounted it to %v, with option %v", getVolumeName(vol), mountPoint, opts) + _, err = callMount(opts, []string{dev, mountPoint}) + if err != nil { + return "", err + } + } + setVolumeMountPoint(vol, mountPoint) + return mountPoint, nil +} + +func VolumeUmount(v interface{}) error { + vol, err := getVolumeOps(v) + if err != nil { + return err + } + mountPoint := getVolumeMountPoint(vol) + if mountPoint == "" { + log.Debugf("Umount a umounted volume %v", getVolumeName(vol)) + return nil + } + if err := callUmount([]string{mountPoint}); err != nil { + return err + } + if mountPoint == vol.GenerateDefaultMountPoint() { + if err := os.Remove(mountPoint); err != nil { + log.Warnf("Cannot cleanup mount point directory %v due to %v\n", mountPoint, err) + } + } + setVolumeMountPoint(vol, "") + return nil +} + +func callMkdirIfNotExists(dirName string) error { + cmdName := "mkdir" + cmdArgs := []string{"-p", dirName} + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + _, err := Execute(cmdName, cmdArgs) + if err != nil { + return err + } + return nil +} + +func callMount(opts, args []string) (string, error) { + cmdName := MOUNT_BINARY + cmdArgs := opts + cmdArgs = append(cmdArgs, args...) + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + output, err := Execute(cmdName, cmdArgs) + if err != nil { + return "", err + } + return output, nil +} + +func callUmount(args []string) error { + cmdName := UMOUNT_BINARY + cmdArgs := args + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + if _, err := Execute(cmdName, cmdArgs); err != nil { + return err + } + return nil +} + +func InitMountNamespace(fd string) error { + if fd == "" { + return nil + } + if _, err := Execute(NSENTER_BINARY, []string{"-V"}); err != nil { + return fmt.Errorf("Cannot find nsenter for namespace switching") + } + if _, err := Execute(NSENTER_BINARY, []string{"--mount=" + fd, "mount"}); err != nil { + return fmt.Errorf("Invalid mount namespace %v, error %v", fd, err) + } + + mountNamespaceFD = fd + log.Debugf("Would mount volume in namespace %v", fd) + return nil +} + +func updateMountNamespace(name string, args []string) (string, []string) { + if mountNamespaceFD == "" { + return name, args + } + cmdArgs := []string{ + "--mount=" + mountNamespaceFD, + name, + } + cmdArgs = append(cmdArgs, args...) + cmdName := NSENTER_BINARY + log.Debugf("Execute in namespace %v: %v %v", mountNamespaceFD, cmdName, cmdArgs) + return cmdName, cmdArgs +} + +func getFileStat(file string, format string) (string, error) { + cmdName := "stat" + cmdArgs := []string{"-c", format, file} + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + output, err := Execute(cmdName, cmdArgs) + if err != nil { + return "", err + } + return strings.TrimSpace(output), nil +} + +func getFileType(file string) (string, error) { + return getFileStat(file, FILE_STAT_FORMAT_TYPE) +} + +func getDevMajorMinor(file string) (string, error) { + return getFileStat(file, FILE_STAT_FORMAT_MAJOR_MINOR) +} + +func getFileSize(file string) (int64, error) { + output, err := getFileStat(file, FILE_STAT_FORMAT_SIZE) + if err != nil { + return 0, err + } + size, err := strconv.ParseInt(strings.TrimSpace(output), 10, 64) + if err != nil { + return 0, err + } + return size, nil +} + +func VolumeMountPointFileExists(v interface{}, file string, expectType string) bool { + vol, err := getVolumeOps(v) + if err != nil { + panic("BUG: VolumeMountPointDirectoryExists was called with invalid variable") + } + mp := getVolumeMountPoint(vol) + if mp == "" { + panic("BUG: VolumeMountPointDirectoryExists was called before volume mounted") + } + path := filepath.Join(mp, file) + + fileType, err := getFileType(path) + if err != nil { + return false + } + + if fileType == expectType { + return true + } + fmt.Println(fileType, expectType) + return false +} + +func VolumeMountPointDirectoryCreate(v interface{}, dirName string) error { + vol, err := getVolumeOps(v) + if err != nil { + panic("BUG: VolumeMountPointDirectoryCreate was called with invalid variable") + } + mp := getVolumeMountPoint(vol) + if mp == "" { + panic("BUG: VolumeMountPointDirectoryCreate was called before volume mounted") + } + path := filepath.Join(mp, dirName) + + cmdName := "mkdir" + cmdArgs := []string{"-p", path} + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + if _, err := Execute(cmdName, cmdArgs); err != nil { + return err + } + return nil +} + +func VolumeMountPointDirectoryRemove(v interface{}, dirName string) error { + vol, err := getVolumeOps(v) + if err != nil { + panic("BUG: VolumeMountPointDirectoryRemove was called with invalid variable") + } + mp := getVolumeMountPoint(vol) + if mp == "" { + panic("BUG: VolumeMountPointDirectoryRemove was called before volume mounted") + } + path := filepath.Join(mp, dirName) + + cmdName := "rm" + cmdArgs := []string{"-rf", path} + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + if _, err := Execute(cmdName, cmdArgs); err != nil { + return err + } + return nil +} + +func createImage(file string, size int64) error { + cmdName := "truncate" + cmdArgs := []string{ + "-s", + strconv.FormatInt(size, 10), + file, + } + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + if _, err := Execute(cmdName, cmdArgs); err != nil { + return err + } + return nil +} + +func prepareImage(dir string, size int64) error { + file := filepath.Join(dir, IMAGE_FILE_NAME) + fileType, err := getFileType(file) + if err == nil { + if fileType != FILE_TYPE_REGULAR { + return fmt.Errorf("The image is already exists at %v, but not a file? It's %v", file, fileType) + } + // File already exists, don't need to do anything + fileSize, err := getFileSize(file) + if err != nil { + return err + } + if fileSize != size { + log.Warnf("The existing image file size %v is different from specified size %v", fileSize, size) + } + return nil + } + + if err := createImage(file, size); err != nil { + return err + } + return nil +} + +func MountPointPrepareImageFile(mp string, size int64) error { + fileType, err := getFileType(mp) + if err != nil { + return err + } + if fileType != FILE_TYPE_DIRECTORY { + return fmt.Errorf("Cannot prepare image for invalid file with type '%v' at %v", fileType, mp) + } + if err := prepareImage(mp, size); err != nil { + return err + } + return nil +} + +func makeBlockDeviceNode(file, major, minor string) error { + cmdName := "mknod" + cmdArgs := []string{ + "-m=600", + file, + "b", + major, + minor, + } + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + if _, err := Execute(cmdName, cmdArgs); err != nil { + return err + } + return nil +} + +func MountPointRemoveFile(file string) error { + cmdName := "rm" + cmdArgs := []string{ + "-f", + file, + } + cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) + if _, err := Execute(cmdName, cmdArgs); err != nil { + return err + } + return nil +} + +func MountPointPrepareBlockDevice(mp string, dev string) error { + file := filepath.Join(mp, BLOCK_DEV_NAME) + fileType, err := getFileType(file) + if err == nil { + if fileType != FILE_TYPE_BLOCKDEVICE { + return fmt.Errorf("The file is already exists at %v, but not a block device? It's %v", file, fileType) + } + // Old device should be cleaned up already, so it's a bug + log.Warnf("Old device wasn't cleaned up, clean it up now") + if err := MountPointRemoveFile(file); err != nil { + return fmt.Errorf("Fail to cleanup device file at %v", file) + } + } + + mm, err := getFileStat(dev, FILE_STAT_FORMAT_MAJOR_MINOR) + if err != nil { + return err + } + log.Debugf("Create block device at %v with major minor as %v", file, mm) + + major := strings.Split(mm, " ")[0] + minor := strings.Split(mm, " ")[1] + if err := makeBlockDeviceNode(file, major, minor); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go b/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go new file mode 100644 index 00000000..7ca4d337 --- /dev/null +++ b/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go @@ -0,0 +1,185 @@ +package vfs + +import ( + "fmt" + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/objectstore" + "github.com/rancher/convoy/util" + "io" + "net/url" + "os" + "path/filepath" + "strings" +) + +var ( + log = logrus.WithFields(logrus.Fields{"pkg": "vfs"}) +) + +type VfsObjectStoreDriver struct { + destURL string + path string +} + +const ( + KIND = "vfs" + + VFS_PATH = "vfs.path" + + MAX_CLEANUP_LEVEL = 10 +) + +func init() { + objectstore.RegisterDriver(KIND, initFunc) +} + +func initFunc(destURL string) (objectstore.ObjectStoreDriver, error) { + b := &VfsObjectStoreDriver{} + u, err := url.Parse(destURL) + if err != nil { + return nil, err + } + + if u.Scheme != KIND { + return nil, fmt.Errorf("BUG: Why dispatch %v to %v?", u.Scheme, KIND) + } + + if u.Host != "" { + return nil, fmt.Errorf("VFS path must follow: vfs:///path/ format") + } + + b.path = u.Path + + if b.path == "" { + return nil, fmt.Errorf("Cannot find vfs path") + } + if _, err := b.List(""); err != nil { + return nil, fmt.Errorf("VFS path %v doesn't exist or is not a directory", b.path) + } + + b.destURL = KIND + "://" + b.path + log.Debug("Loaded driver for %v", b.destURL) + return b, nil +} + +func (v *VfsObjectStoreDriver) updatePath(path string) string { + return filepath.Join(v.path, path) +} + +func (v *VfsObjectStoreDriver) preparePath(file string) error { + if err := os.MkdirAll(filepath.Dir(v.updatePath(file)), os.ModeDir|0700); err != nil { + return err + } + return nil +} + +func (v *VfsObjectStoreDriver) Kind() string { + return KIND +} + +func (v *VfsObjectStoreDriver) GetURL() string { + return v.destURL +} + +func (v *VfsObjectStoreDriver) FileSize(filePath string) int64 { + file := v.updatePath(filePath) + st, err := os.Stat(file) + if err != nil || st.IsDir() { + return -1 + } + return st.Size() +} + +func (v *VfsObjectStoreDriver) FileExists(filePath string) bool { + return v.FileSize(filePath) >= 0 +} + +func (v *VfsObjectStoreDriver) Remove(names ...string) error { + for _, name := range names { + if err := os.RemoveAll(v.updatePath(name)); err != nil { + return err + } + //Also automatically cleanup upper level directories + dir := v.updatePath(name) + for i := 0; i < MAX_CLEANUP_LEVEL; i++ { + dir = filepath.Dir(dir) + // If directory is not empty, then we don't need to continue + if err := os.Remove(dir); err != nil { + break + } + } + } + return nil +} + +func (v *VfsObjectStoreDriver) Read(src string) (io.ReadCloser, error) { + file, err := os.Open(v.updatePath(src)) + if err != nil { + return nil, err + } + return file, nil +} + +func (v *VfsObjectStoreDriver) Write(dst string, rs io.ReadSeeker) error { + tmpFile := dst + ".tmp" + if v.FileExists(tmpFile) { + v.Remove(tmpFile) + } + if err := v.preparePath(dst); err != nil { + return err + } + file, err := os.Create(v.updatePath(tmpFile)) + if err != nil { + return err + } + defer file.Close() + _, err = io.Copy(file, rs) + if err != nil { + return err + } + + if v.FileExists(dst) { + v.Remove(dst) + } + return os.Rename(v.updatePath(tmpFile), v.updatePath(dst)) +} + +func (v *VfsObjectStoreDriver) List(path string) ([]string, error) { + out, err := util.Execute("ls", []string{"-1", v.updatePath(path)}) + if err != nil { + return nil, err + } + var result []string + if len(out) == 0 { + return result, nil + } + result = strings.Split(strings.TrimSpace(string(out)), "\n") + return result, nil +} + +func (v *VfsObjectStoreDriver) Upload(src, dst string) error { + tmpDst := dst + ".tmp" + if v.FileExists(tmpDst) { + v.Remove(tmpDst) + } + if err := v.preparePath(dst); err != nil { + return err + } + _, err := util.Execute("cp", []string{src, v.updatePath(tmpDst)}) + if err != nil { + return err + } + _, err = util.Execute("mv", []string{v.updatePath(tmpDst), v.updatePath(dst)}) + if err != nil { + return err + } + return nil +} + +func (v *VfsObjectStoreDriver) Download(src, dst string) error { + _, err := util.Execute("cp", []string{v.updatePath(src), dst}) + if err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/rancher/convoy/vfs/vfs_storage.go b/vendor/github.com/rancher/convoy/vfs/vfs_storage.go new file mode 100644 index 00000000..a4cc3945 --- /dev/null +++ b/vendor/github.com/rancher/convoy/vfs/vfs_storage.go @@ -0,0 +1,598 @@ +package vfs + +import ( + "fmt" + "os" + "path/filepath" + "strconv" + "sync" + + . "github.com/rancher/convoy/convoydriver" + "github.com/rancher/convoy/objectstore" + "github.com/rancher/convoy/util" +) + +const ( + DRIVER_NAME = "vfs" + DRIVER_CONFIG_FILE = "vfs.cfg" + + VOLUME_CFG_PREFIX = "volume_" + VFS_CFG_PREFIX = DRIVER_NAME + "_" + CFG_POSTFIX = ".json" + + SNAPSHOT_PATH = "snapshots" + + VFS_DEFAULT_VOLUME_SIZE = "vfs.defaultvolumesize" + DEFAULT_VOLUME_SIZE = "100G" +) + +type Driver struct { + mutex *sync.RWMutex + Device +} + +func init() { + Register(DRIVER_NAME, Init) +} + +func (d *Driver) Name() string { + return DRIVER_NAME +} + +type Device struct { + Root string + Path string + ConfigPath string + DefaultVolumeSize int64 +} + +func (dev *Device) ConfigFile() (string, error) { + if dev.Root == "" { + return "", fmt.Errorf("BUG: Invalid empty device config path") + } + return filepath.Join(dev.Root, DRIVER_CONFIG_FILE), nil +} + +type Snapshot struct { + Name string + CreatedTime string + VolumeUUID string + FilePath string +} + +type Volume struct { + Name string + Size int64 + Path string + MountPoint string + PrepareForVM bool + CreatedTime string + Snapshots map[string]Snapshot + + configPath string +} + +func (v *Volume) ConfigFile() (string, error) { + if v.Name == "" { + return "", fmt.Errorf("BUG: Invalid empty volume name") + } + if v.configPath == "" { + return "", fmt.Errorf("BUG: Invalid empty volume config path") + } + return filepath.Join(v.configPath, VFS_CFG_PREFIX+VOLUME_CFG_PREFIX+v.Name+CFG_POSTFIX), nil +} + +func (device *Device) listVolumeNames() ([]string, error) { + return util.ListConfigIDs(device.ConfigPath, VFS_CFG_PREFIX+VOLUME_CFG_PREFIX, CFG_POSTFIX) +} + +func Init(root string, config map[string]string) (ConvoyDriver, error) { + dev := &Device{ + Root: root, + } + exists, err := util.ObjectExists(dev) + if err != nil { + return nil, err + } + if exists { + if err := util.ObjectLoad(dev); err != nil { + return nil, err + } + } else { + if err := util.MkdirIfNotExists(root); err != nil { + return nil, err + } + + path := config[VFS_PATH] + configPath := filepath.Join(path, "config") + if path == "" { + return nil, fmt.Errorf("VFS driver base path unspecified") + } + if err := util.MkdirIfNotExists(path); err != nil { + return nil, err + } + if err := util.MkdirIfNotExists(configPath); err != nil { + return nil, err + } + + dev = &Device{ + Root: root, + Path: path, + ConfigPath: configPath, + } + + if _, exists := config[VFS_DEFAULT_VOLUME_SIZE]; !exists { + config[VFS_DEFAULT_VOLUME_SIZE] = DEFAULT_VOLUME_SIZE + } + volumeSize, err := util.ParseSize(config[VFS_DEFAULT_VOLUME_SIZE]) + if err != nil || volumeSize == 0 { + return nil, fmt.Errorf("Illegal default volume size specified") + } + dev.DefaultVolumeSize = volumeSize + } + + // For upgrade case + if dev.DefaultVolumeSize == 0 { + dev.DefaultVolumeSize, err = util.ParseSize(DEFAULT_VOLUME_SIZE) + if err != nil || dev.DefaultVolumeSize == 0 { + return nil, fmt.Errorf("Illegal default volume size specified") + } + } + + if err := util.ObjectSave(dev); err != nil { + return nil, err + } + d := &Driver{ + mutex: &sync.RWMutex{}, + Device: *dev, + } + + return d, nil +} + +func (d *Driver) Info() (map[string]string, error) { + return map[string]string{ + "Root": d.Root, + "Path": d.Path, + "DefaultVolumeSize": strconv.FormatInt(d.DefaultVolumeSize, 10), + }, nil +} + +func (d *Driver) VolumeOps() (VolumeOperations, error) { + return d, nil +} + +func (d *Driver) blankVolume(id string) *Volume { + return &Volume{ + configPath: d.ConfigPath, + Name: id, + } +} + +func (d *Driver) getSize(opts map[string]string, defaultVolumeSize int64) (int64, error) { + size := opts[OPT_SIZE] + if size == "" || size == "0" { + size = strconv.FormatInt(defaultVolumeSize, 10) + } + return util.ParseSize(size) +} + +func (d *Driver) CreateVolume(req Request) error { + d.mutex.Lock() + defer d.mutex.Unlock() + + id := req.Name + opts := req.Options + volume := d.blankVolume(id) + + lockFile, err := flock(volume) + if err != nil { + return fmt.Errorf("Coudln't get flock. Error: %v", err) + } + defer util.UnlockFile(lockFile) + + backupURL := opts[OPT_BACKUP_URL] + if backupURL != "" { + objVolume, err := objectstore.LoadVolume(backupURL) + if err != nil { + return err + } + if objVolume.Driver != d.Name() { + return fmt.Errorf("Cannot restore backup of %v to %v", objVolume.Driver, d.Name()) + } + } + + exists, err := util.ObjectExists(volume) + if err != nil { + return err + } + if exists { + return nil + } + + volume.PrepareForVM, err = strconv.ParseBool(opts[OPT_PREPARE_FOR_VM]) + if err != nil { + return err + } + if volume.PrepareForVM { + volume.Size, err = d.getSize(opts, d.DefaultVolumeSize) + if err != nil { + return err + } + } + + volumePath := filepath.Join(d.Path, id) + if err := util.MkdirIfNotExists(volumePath); err != nil { + return err + } + volume.Path = volumePath + volume.CreatedTime = util.Now() + volume.Snapshots = make(map[string]Snapshot) + volume.Name = id + + if backupURL != "" { + file, err := objectstore.RestoreSingleFileBackup(backupURL, volumePath) + if err != nil { + return err + } + // file would be removed after this because it's under volumePath + if err := util.DecompressDir(file, volumePath); err != nil { + return err + } + } + return util.ObjectSave(volume) +} + +func (d *Driver) DeleteVolume(req Request) error { + d.mutex.Lock() + defer d.mutex.Unlock() + + id := req.Name + opts := req.Options + + volume := d.blankVolume(id) + + lockFile, err := flock(volume) + if err != nil { + return fmt.Errorf("Coudln't get flock. Error: %v", err) + } + defer util.UnlockFile(lockFile) + + if err := util.ObjectLoad(volume); err != nil { + return err + } + + if volume.MountPoint != "" { + return fmt.Errorf("Cannot delete volume %v. It is still mounted", id) + } + referenceOnly, _ := strconv.ParseBool(opts[OPT_REFERENCE_ONLY]) + if !referenceOnly { + log.Debugf("Cleaning up %v for volume %v", volume.Path, id) + if out, err := util.Execute("rm", []string{"-rf", volume.Path}); err != nil { + return fmt.Errorf("Fail to cleanup the volume, output: %v, error: %v", out, err.Error()) + } + } + return util.ObjectDelete(volume) +} + +func (d *Driver) MountVolume(req Request) (string, error) { + d.mutex.Lock() + defer d.mutex.Unlock() + + id := req.Name + opts := req.Options + + volume := d.blankVolume(id) + if err := util.ObjectLoad(volume); err != nil { + return "", err + } + + specifiedPoint := opts[OPT_MOUNT_POINT] + if specifiedPoint != "" { + return "", fmt.Errorf("VFS doesn't support specified mount point") + } + if volume.MountPoint == "" { + volume.MountPoint = volume.Path + } + if volume.PrepareForVM { + if err := util.MountPointPrepareImageFile(volume.MountPoint, volume.Size); err != nil { + return "", err + } + } + + lockFile, err := flock(volume) + if err != nil { + return "", fmt.Errorf("Coudln't get flock. Error: %v", err) + } + defer util.UnlockFile(lockFile) + + if err := util.ObjectSave(volume); err != nil { + return "", err + } + return volume.MountPoint, nil +} + +func (d *Driver) UmountVolume(req Request) error { + d.mutex.Lock() + defer d.mutex.Unlock() + + id := req.Name + + volume := d.blankVolume(id) + if err := util.ObjectLoad(volume); err != nil { + return err + } + + if volume.MountPoint != "" { + volume.MountPoint = "" + } + + lockFile, err := flock(volume) + if err != nil { + return fmt.Errorf("Coudln't get flock. Error: %v", err) + } + defer util.UnlockFile(lockFile) + return util.ObjectSave(volume) +} + +func (d *Driver) ListVolume(opts map[string]string) (map[string]map[string]string, error) { + d.mutex.RLock() + defer d.mutex.RUnlock() + + volumeIDs, err := d.listVolumeNames() + if err != nil { + return nil, err + } + result := map[string]map[string]string{} + for _, id := range volumeIDs { + result[id], err = d.getVolumeInfo(id) + if err != nil { + return nil, err + } + } + return result, nil +} + +func (d *Driver) GetVolumeInfo(name string) (map[string]string, error) { + d.mutex.RLock() + defer d.mutex.RUnlock() + return d.getVolumeInfo(name) +} + +func (d *Driver) getVolumeInfo(name string) (map[string]string, error) { + volume := d.blankVolume(name) + if err := util.ObjectLoad(volume); err != nil { + return nil, err + } + + size := "0" + prepareForVM := strconv.FormatBool(volume.PrepareForVM) + if volume.PrepareForVM { + size = strconv.FormatInt(volume.Size, 10) + } + return map[string]string{ + "Path": volume.Path, + OPT_MOUNT_POINT: volume.MountPoint, + OPT_SIZE: size, + OPT_PREPARE_FOR_VM: prepareForVM, + OPT_VOLUME_NAME: volume.Name, + OPT_VOLUME_CREATED_TIME: volume.CreatedTime, + }, nil +} + +func (d *Driver) MountPoint(req Request) (string, error) { + d.mutex.RLock() + defer d.mutex.RUnlock() + + id := req.Name + + volume := d.blankVolume(id) + if err := util.ObjectLoad(volume); err != nil { + return "", err + } + return volume.MountPoint, nil +} + +func (d *Driver) SnapshotOps() (SnapshotOperations, error) { + return d, nil +} + +func (d *Driver) getSnapshotFilePath(snapshotID, volumeID string) string { + return filepath.Join(d.Root, SNAPSHOT_PATH, volumeID+"_"+snapshotID+".tar.gz") +} + +func (d *Driver) CreateSnapshot(req Request) error { + d.mutex.Lock() + defer d.mutex.Unlock() + + id := req.Name + volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options) + if err != nil { + return err + } + + volume := d.blankVolume(volumeID) + if err := util.ObjectLoad(volume); err != nil { + return err + } + if _, exists := volume.Snapshots[id]; exists { + return fmt.Errorf("Snapshot %v already exists for volume %v", id, volumeID) + } + snapFile := d.getSnapshotFilePath(id, volumeID) + if err := util.MkdirIfNotExists(filepath.Dir(snapFile)); err != nil { + return err + } + if err := util.CompressDir(volume.Path, snapFile); err != nil { + return err + } + volume.Snapshots[id] = Snapshot{ + Name: id, + CreatedTime: util.Now(), + VolumeUUID: volumeID, + FilePath: snapFile, + } + + lockFile, err := flock(volume) + if err != nil { + return fmt.Errorf("Coudln't get flock. Error: %v", err) + } + defer util.UnlockFile(lockFile) + return util.ObjectSave(volume) +} + +func (d *Driver) DeleteSnapshot(req Request) error { + d.mutex.Lock() + defer d.mutex.Unlock() + + volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options) + if err != nil { + return err + } + return d.deleteSnapshot(req.Name, volumeID) +} + +func (d *Driver) deleteSnapshot(id, volumeID string) error { + volume := d.blankVolume(volumeID) + if err := util.ObjectLoad(volume); err != nil { + return err + } + snapshot, exists := volume.Snapshots[id] + if !exists { + return fmt.Errorf("Snapshot %v doesn't exists for volume %v", id, volumeID) + } + if err := os.Remove(snapshot.FilePath); err != nil { + return err + } + delete(volume.Snapshots, id) + + lockFile, err := flock(volume) + if err != nil { + return fmt.Errorf("Coudln't get flock. Error: %v", err) + } + defer util.UnlockFile(lockFile) + return util.ObjectSave(volume) +} + +func (d *Driver) GetSnapshotInfo(req Request) (map[string]string, error) { + d.mutex.Lock() + defer d.mutex.Unlock() + + volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options) + if err != nil { + return nil, err + } + + return d.getSnapshotInfo(req.Name, volumeID) +} + +func (d *Driver) getSnapshotInfo(id, volumeID string) (map[string]string, error) { + volume := d.blankVolume(volumeID) + if err := util.ObjectLoad(volume); err != nil { + return nil, err + } + snapshot, exists := volume.Snapshots[id] + if !exists { + return nil, fmt.Errorf("Snapshot %v doesn't exists for volume %v", id, volumeID) + } + return map[string]string{ + OPT_SNAPSHOT_NAME: snapshot.Name, + OPT_SNAPSHOT_CREATED_TIME: snapshot.CreatedTime, + "VolumeUUID": snapshot.VolumeUUID, + "FilePath": snapshot.FilePath, + }, nil +} + +func (d *Driver) ListSnapshot(opts map[string]string) (map[string]map[string]string, error) { + d.mutex.Lock() + defer d.mutex.Unlock() + + var ( + volumeIDs []string + err error + ) + snapshots := make(map[string]map[string]string) + specifiedVolumeID, _ := util.GetFieldFromOpts(OPT_VOLUME_NAME, opts) + if specifiedVolumeID != "" { + volumeIDs = []string{ + specifiedVolumeID, + } + } else { + volumeIDs, err = d.listVolumeNames() + if err != nil { + return nil, err + } + } + for _, volumeID := range volumeIDs { + volume := d.blankVolume(volumeID) + if err := util.ObjectLoad(volume); err != nil { + return nil, err + } + for snapshotID := range volume.Snapshots { + snapshots[snapshotID], err = d.getSnapshotInfo(snapshotID, volumeID) + if err != nil { + return nil, err + } + } + } + return snapshots, nil +} + +func (d *Driver) BackupOps() (BackupOperations, error) { + return d, nil +} + +func (d *Driver) CreateBackup(snapshotID, volumeID, destURL string, opts map[string]string) (string, error) { + volume := d.blankVolume(volumeID) + if err := util.ObjectLoad(volume); err != nil { + return "", err + } + snapshot, exists := volume.Snapshots[snapshotID] + if !exists { + return "", fmt.Errorf("Cannot find snapshot %v for volume %v", snapshotID, volumeID) + } + objVolume := &objectstore.Volume{ + Name: volume.Name, + Driver: d.Name(), + CreatedTime: opts[OPT_VOLUME_CREATED_TIME], + } + objSnapshot := &objectstore.Snapshot{ + Name: snapshotID, + CreatedTime: opts[OPT_SNAPSHOT_CREATED_TIME], + } + return objectstore.CreateSingleFileBackup(objVolume, objSnapshot, snapshot.FilePath, destURL) +} + +func (d *Driver) DeleteBackup(backupURL string) error { + objVolume, err := objectstore.LoadVolume(backupURL) + if err != nil { + return err + } + if objVolume.Driver != d.Name() { + return fmt.Errorf("BUG: Wrong driver handling DeleteBackup(), driver should be %v but is %v", objVolume.Driver, d.Name()) + } + return objectstore.DeleteSingleFileBackup(backupURL) +} + +func (d *Driver) GetBackupInfo(backupURL string) (map[string]string, error) { + objVolume, err := objectstore.LoadVolume(backupURL) + if err != nil { + return nil, err + } + if objVolume.Driver != d.Name() { + return nil, fmt.Errorf("BUG: Wrong driver handling DeleteBackup(), driver should be %v but is %v", objVolume.Driver, d.Name()) + } + return objectstore.GetBackupInfo(backupURL) +} + +func (d *Driver) ListBackup(destURL string, opts map[string]string) (map[string]map[string]string, error) { + return objectstore.List(opts[OPT_VOLUME_NAME], destURL, d.Name()) +} + +func flock(volume *Volume) (*os.File, error) { + cf, err := volume.ConfigFile() + if err != nil { + return nil, err + } + lockPath := cf + ".lock" + return util.LockFile(lockPath) +} diff --git a/vendor/golang.org/x/sys/unix/.gitignore b/vendor/golang.org/x/sys/unix/.gitignore new file mode 100644 index 00000000..e4827159 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/.gitignore @@ -0,0 +1 @@ +_obj/ 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 00000000..8ed2fdb9 --- /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 00000000..8a727831 --- /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 00000000..6321421f --- /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 00000000..333242d5 --- /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 00000000..97e01743 --- /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_386.s b/vendor/golang.org/x/sys/unix/asm_dragonfly_386.s new file mode 100644 index 00000000..7e55e0d3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_dragonfly_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-32 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-44 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-56 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-32 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 + JMP 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 00000000..d5ed6726 --- /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 00000000..c9a0a260 --- /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 00000000..35172477 --- /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 00000000..9227c875 --- /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 00000000..4db29093 --- /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 00000000..44e25c62 --- /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 00000000..cf0b5746 --- /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 00000000..4be9bfed --- /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 00000000..724e580c --- /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 00000000..8d231feb --- /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_netbsd_386.s b/vendor/golang.org/x/sys/unix/asm_netbsd_386.s new file mode 100644 index 00000000..48bdcd76 --- /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 00000000..2ede05c7 --- /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 00000000..e8928571 --- /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 00000000..00576f3c --- /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 00000000..790ef77f --- /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 00000000..43ed17a0 --- /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/constants.go b/vendor/golang.org/x/sys/unix/constants.go new file mode 100644 index 00000000..a96f0ebc --- /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 00000000..45e281a0 --- /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 00000000..92222625 --- /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 00000000..ce67a595 --- /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 00000000..362831c3 --- /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 00000000..94c82321 --- /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 00000000..07f6be03 --- /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 00000000..bffe1a77 --- /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/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh new file mode 100755 index 00000000..de95a4bb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -0,0 +1,274 @@ +#!/usr/bin/env bash +# Copyright 2009 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# The unix package provides access to the raw system call +# interface of the underlying operating system. Porting Go to +# a new architecture/operating system combination requires +# some manual effort, though there are tools that automate +# much of the process. The auto-generated files have names +# beginning with z. +# +# This script runs or (given -n) prints suggested commands to generate z files +# for the current system. Running those commands is not automatic. +# This script is documentation more than anything else. +# +# * asm_${GOOS}_${GOARCH}.s +# +# This hand-written assembly file implements system call dispatch. +# There are three entry points: +# +# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr); +# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr); +# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr); +# +# The first and second are the standard ones; they differ only in +# how many arguments can be passed to the kernel. +# The third is for low-level use by the ForkExec wrapper; +# unlike the first two, it does not call into the scheduler to +# let it know that a system call is running. +# +# * syscall_${GOOS}.go +# +# This hand-written Go file implements system calls that need +# special handling and lists "//sys" comments giving prototypes +# for ones that can be auto-generated. Mksyscall reads those +# comments to generate the stubs. +# +# * syscall_${GOOS}_${GOARCH}.go +# +# Same as syscall_${GOOS}.go except that it contains code specific +# to ${GOOS} on one particular architecture. +# +# * types_${GOOS}.c +# +# This hand-written C file includes standard C headers and then +# creates typedef or enum names beginning with a dollar sign +# (use of $ in variable names is a gcc extension). The hardest +# part about preparing this file is figuring out which headers to +# include and which symbols need to be #defined to get the +# actual data structures that pass through to the kernel system calls. +# Some C libraries present alternate versions for binary compatibility +# and translate them on the way in and out of system calls, but +# there is almost always a #define that can get the real ones. +# See types_darwin.c and types_linux.c for examples. +# +# * zerror_${GOOS}_${GOARCH}.go +# +# This machine-generated file defines the system's error numbers, +# error strings, and signal numbers. The generator is "mkerrors.sh". +# Usually no arguments are needed, but mkerrors.sh will pass its +# arguments on to godefs. +# +# * zsyscall_${GOOS}_${GOARCH}.go +# +# Generated by mksyscall.pl; see syscall_${GOOS}.go above. +# +# * zsysnum_${GOOS}_${GOARCH}.go +# +# Generated by mksysnum_${GOOS}. +# +# * ztypes_${GOOS}_${GOARCH}.go +# +# Generated by godefs; see types_${GOOS}.c above. + +GOOSARCH="${GOOS}_${GOARCH}" + +# defaults +mksyscall="./mksyscall.pl" +mkerrors="./mkerrors.sh" +zerrors="zerrors_$GOOSARCH.go" +mksysctl="" +zsysctl="zsysctl_$GOOSARCH.go" +mksysnum= +mktypes= +run="sh" + +case "$1" in +-syscalls) + for i in zsyscall*go + do + sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i + rm _$i + done + exit 0 + ;; +-n) + run="cat" + shift +esac + +case "$#" in +0) + ;; +*) + echo 'usage: mkall.sh [-n]' 1>&2 + exit 2 +esac + +GOOSARCH_in=syscall_$GOOSARCH.go +case "$GOOSARCH" in +_* | *_ | _) + echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 + exit 1 + ;; +darwin_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32" + mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_amd64) + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_arm) + mkerrors="$mkerrors" + mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_arm64) + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +dragonfly_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32 -dragonfly" + mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +dragonfly_amd64) + mkerrors="$mkerrors -m64" + mksyscall="./mksyscall.pl -dragonfly" + mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32" + mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_amd64) + mkerrors="$mkerrors -m64" + mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_arm) + mkerrors="$mkerrors" + mksyscall="./mksyscall.pl -l32 -arm" + mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl" + # Let the type of C char be singed for making the bare syscall + # API consistent across over platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +linux_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32" + mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_amd64) + unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1) + if [ "$unistd_h" = "" ]; then + echo >&2 cannot find unistd_64.h + exit 1 + fi + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +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 -" + 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 singed 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" + ;; +netbsd_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32 -netbsd" + mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +netbsd_amd64) + mkerrors="$mkerrors -m64" + mksyscall="./mksyscall.pl -netbsd" + mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32 -openbsd" + mksysctl="./mksysctl_openbsd.pl" + zsysctl="zsysctl_openbsd.go" + mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_amd64) + mkerrors="$mkerrors -m64" + mksyscall="./mksyscall.pl -openbsd" + mksysctl="./mksysctl_openbsd.pl" + zsysctl="zsysctl_openbsd.go" + mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +solaris_amd64) + mksyscall="./mksyscall_solaris.pl" + mkerrors="$mkerrors -m64" + mksysnum= + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +*) + echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2 + exit 1 + ;; +esac + +( + if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi + case "$GOOS" in + *) + syscall_goos="syscall_$GOOS.go" + case "$GOOS" in + darwin | dragonfly | freebsd | netbsd | openbsd) + syscall_goos="syscall_bsd.go $syscall_goos" + ;; + esac + if [ -n "$mksyscall" ]; then echo "$mksyscall $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 "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go"; + echo "$mktypes types_$GOOS.go | gofmt >>ztypes_$GOOSARCH.go"; + fi +) | $run diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh new file mode 100755 index 00000000..c40d788c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -0,0 +1,476 @@ +#!/usr/bin/env bash +# Copyright 2009 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# Generate Go code listing errors and other #defined constant +# values (ENAMETOOLONG etc.), by asking the preprocessor +# about the definitions. + +unset LANG +export LC_ALL=C +export LC_CTYPE=C + +if test -z "$GOARCH" -o -z "$GOOS"; then + echo 1>&2 "GOARCH or GOOS not defined in environment" + exit 1 +fi + +CC=${CC:-cc} + +if [[ "$GOOS" -eq "solaris" ]]; then + # Assumes GNU versions of utilities in PATH. + export PATH=/usr/gnu/bin:$PATH +fi + +uname=$(uname) + +includes_Darwin=' +#define _DARWIN_C_SOURCE +#define KERNEL +#define _DARWIN_USE_64_BIT_INODE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' + +includes_DragonFly=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' + +includes_FreeBSD=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __FreeBSD__ >= 10 +#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10 +#undef SIOCAIFADDR +#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data +#undef SIOCSIFPHYADDR +#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data +#endif +' + +includes_Linux=' +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE +#ifndef __LP64__ +#define _FILE_OFFSET_BITS 64 +#endif +#define _GNU_SOURCE + +#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 + +#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=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Needed since refers to it... +#define schedppq 1 +' + +includes_OpenBSD=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// We keep some constants not supported in OpenBSD 5.5 and beyond for +// the promise of compatibility. +#define EMUL_ENABLED 0x1 +#define EMUL_NATIVE 0x2 +#define IPV6_FAITH 0x1d +#define IPV6_OPTIONS 0x1 +#define IPV6_RTHDR_STRICT 0x1 +#define IPV6_SOCKOPT_RESERVED1 0x3 +#define SIOCGIFGENERIC 0xc020693a +#define SIOCSIFGENERIC 0x80206939 +#define WALTSIG 0x4 +' + +includes_SunOS=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' + + +includes=' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +' +ccflags="$@" + +# Write go tool cgo -godefs input. +( + echo package unix + echo + echo '/*' + indirect="includes_$(uname)" + echo "${!indirect} $includes" + echo '*/' + echo 'import "C"' + echo 'import "syscall"' + echo + echo 'const (' + + # The gcc command line prints all the #defines + # it encounters while processing the input + echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags | + awk ' + $1 != "#define" || $2 ~ /\(/ || $3 == "" {next} + + $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers + $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next} + $2 ~ /^(SCM_SRCRT)$/ {next} + $2 ~ /^(MAP_FAILED)$/ {next} + $2 ~ /^ELF_.*$/ {next}# contains ELF_ARCH, etc. + + $2 ~ /^EXTATTR_NAMESPACE_NAMES/ || + $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next} + + $2 !~ /^ETH_/ && + $2 !~ /^EPROC_/ && + $2 !~ /^EQUIV_/ && + $2 !~ /^EXPR_/ && + $2 ~ /^E[A-Z0-9_]+$/ || + $2 ~ /^B[0-9_]+$/ || + $2 == "BOTHER" || + $2 ~ /^CI?BAUD(EX)?$/ || + $2 == "IBSHIFT" || + $2 ~ /^V[A-Z0-9]+$/ || + $2 ~ /^CS[A-Z0-9]/ || + $2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ || + $2 ~ /^IGN/ || + $2 ~ /^IX(ON|ANY|OFF)$/ || + $2 ~ /^IN(LCR|PCK)$/ || + $2 ~ /(^FLU?SH)|(FLU?SH$)/ || + $2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ || + $2 == "BRKINT" || + $2 == "HUPCL" || + $2 == "PENDIN" || + $2 == "TOSTOP" || + $2 == "XCASE" || + $2 == "ALTWERASE" || + $2 == "NOKERNINFO" || + $2 ~ /^PAR/ || + $2 ~ /^SIG[^_]/ || + $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ || + $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ || + $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ || + $2 ~ /^O?XTABS$/ || + $2 ~ /^TC[IO](ON|OFF)$/ || + $2 ~ /^IN_/ || + $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || + $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ || + $2 == "ICMPV6_FILTER" || + $2 == "SOMAXCONN" || + $2 == "NAME_MAX" || + $2 == "IFNAMSIZ" || + $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ || + $2 ~ /^SYSCTL_VERS/ || + $2 ~ /^(MS|MNT)_/ || + $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || + $2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ || + $2 ~ /^LINUX_REBOOT_CMD_/ || + $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || + $2 !~ "NLA_TYPE_MASK" && + $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ || + $2 ~ /^SIOC/ || + $2 ~ /^TIOC/ || + $2 ~ /^TCGET/ || + $2 ~ /^TCSET/ || + $2 ~ /^TC(FLSH|SBRKP?|XONC)$/ || + $2 !~ "RTF_BITS" && + $2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ || + $2 ~ /^BIOC/ || + $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ || + $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ || + $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ || + $2 ~ /^CLONE_[A-Z_]+/ || + $2 !~ /^(BPF_TIMEVAL)$/ && + $2 ~ /^(BPF|DLT)_/ || + $2 ~ /^CLOCK_/ || + $2 !~ "WMESGLEN" && + $2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)} + $2 ~ /^__WCOREFLAG$/ {next} + $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} + + {next} + ' | sort + + echo ')' +) >_const.go + +# Pull out the error names for later. +errors=$( + echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' | + sort +) + +# Pull out the signal names for later. +signals=$( + echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | + egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | + sort +) + +# Again, writing regexps to a file. +echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' | + sort >_error.grep +echo '#include ' | $CC -x c - -E -dM $ccflags | + awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | + egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | + sort >_signal.grep + +echo '// mkerrors.sh' "$@" +echo '// 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 +echo '// Errors' +echo 'const (' +cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/' +echo ')' + +echo +echo '// Signals' +echo 'const (' +cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/' +echo ')' + +# Run C program to print error and syscall strings. +( + echo -E " +#include +#include +#include +#include +#include +#include + +#define nelem(x) (sizeof(x)/sizeof((x)[0])) + +enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below + +int errors[] = { +" + for i in $errors + do + echo -E ' '$i, + done + + echo -E " +}; + +int signals[] = { +" + for i in $signals + do + echo -E ' '$i, + done + + # Use -E because on some systems bash builtin interprets \n itself. + echo -E ' +}; + +static int +intcmp(const void *a, const void *b) +{ + return *(int*)a - *(int*)b; +} + +int +main(void) +{ + int i, j, e; + char buf[1024], *p; + + printf("\n\n// Error table\n"); + printf("var errors = [...]string {\n"); + qsort(errors, nelem(errors), sizeof errors[0], intcmp); + for(i=0; i 0 && errors[i-1] == e) + continue; + strcpy(buf, strerror(e)); + // lowercase first letter: Bad -> bad, but STREAM -> STREAM. + if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) + buf[0] += a - A; + printf("\t%d: \"%s\",\n", e, buf); + } + printf("}\n\n"); + + printf("\n\n// Signal table\n"); + printf("var signals = [...]string {\n"); + qsort(signals, nelem(signals), sizeof signals[0], intcmp); + for(i=0; i 0 && signals[i-1] == e) + continue; + strcpy(buf, strsignal(e)); + // lowercase first letter: Bad -> bad, but STREAM -> STREAM. + if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) + buf[0] += a - A; + // cut trailing : number. + p = strrchr(buf, ":"[0]); + if(p) + *p = '\0'; + printf("\t%d: \"%s\",\n", e, buf); + } + printf("}\n\n"); + + return 0; +} + +' +) >_errors.c + +$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out diff --git a/vendor/golang.org/x/sys/unix/mksyscall.pl b/vendor/golang.org/x/sys/unix/mksyscall.pl new file mode 100755 index 00000000..b1e7766d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mksyscall.pl @@ -0,0 +1,323 @@ +#!/usr/bin/env perl +# Copyright 2009 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# This program reads a file containing function prototypes +# (like syscall_darwin.go) and generates system call bodies. +# The prototypes are marked by lines beginning with "//sys" +# and read like func declarations if //sys is replaced by func, but: +# * The parameter lists must give a name for each argument. +# This includes return parameters. +# * The parameter lists must give a type for each argument: +# the (x, y, z int) shorthand is not allowed. +# * If the return parameter is an error number, it must be named errno. + +# A line beginning with //sysnb is like //sys, except that the +# goroutine will not be suspended during the execution of the system +# call. This must only be used for system calls which can never +# block, as otherwise the system call could cause all goroutines to +# hang. + +use strict; + +my $cmdline = "mksyscall.pl " . join(' ', @ARGV); +my $errors = 0; +my $_32bit = ""; +my $plan9 = 0; +my $openbsd = 0; +my $netbsd = 0; +my $dragonfly = 0; +my $arm = 0; # 64-bit value should use (even, odd)-pair + +if($ARGV[0] eq "-b32") { + $_32bit = "big-endian"; + shift; +} elsif($ARGV[0] eq "-l32") { + $_32bit = "little-endian"; + shift; +} +if($ARGV[0] eq "-plan9") { + $plan9 = 1; + shift; +} +if($ARGV[0] eq "-openbsd") { + $openbsd = 1; + shift; +} +if($ARGV[0] eq "-netbsd") { + $netbsd = 1; + shift; +} +if($ARGV[0] eq "-dragonfly") { + $dragonfly = 1; + shift; +} +if($ARGV[0] eq "-arm") { + $arm = 1; + shift; +} + +if($ARGV[0] =~ /^-/) { + print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n"; + 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*//; + $list =~ s/\s*$//; + if($list eq "") { + return (); + } + return split(/\s*,\s*/, $list); +} + +sub parseparam($) { + my ($p) = @_; + if($p !~ /^(\S*) (\S*)$/) { + print STDERR "$ARGV:$.: malformed parameter: $p\n"; + $errors = 1; + return ("xx", "int"); + } + return ($1, $2); +} + +my $text = ""; +while(<>) { + chomp; + s/\s+/ /g; + s/^\s+//; + s/\s+$//; + my $nonblock = /^\/\/sysnb /; + next if !/^\/\/sys / && !$nonblock; + + # Line must be of the form + # func Open(path string, mode int, perm int) (fd int, errno error) + # Split into name, in params, out params. + if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) { + print STDERR "$ARGV:$.: malformed //sys declaration\n"; + $errors = 1; + next; + } + my ($func, $in, $out, $sysname) = ($2, $3, $4, $5); + + # Split argument lists on comma. + my @in = parseparamlist($in); + my @out = parseparamlist($out); + + # Try in vain to keep people from editing this file. + # The theory is that they jump into the middle of the file + # without reading the header. + $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"; + + # Go function header. + my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : ""; + $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl; + + # Check if err return available + my $errvar = ""; + foreach my $p (@out) { + my ($name, $type) = parseparam($p); + if($type eq "error") { + $errvar = $name; + last; + } + } + + # Prepare arguments to Syscall. + my @args = (); + my @uses = (); + my $n = 0; + foreach my $p (@in) { + my ($name, $type) = parseparam($p); + if($type =~ /^\*/) { + push @args, "uintptr(unsafe.Pointer($name))"; + } elsif($type eq "string" && $errvar ne "") { + $text .= "\tvar _p$n *byte\n"; + $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n"; + $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n"; + push @args, "uintptr(unsafe.Pointer(_p$n))"; + push @uses, "use(unsafe.Pointer(_p$n))"; + $n++; + } elsif($type eq "string") { + print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n"; + $text .= "\tvar _p$n *byte\n"; + $text .= "\t_p$n, _ = BytePtrFromString($name)\n"; + push @args, "uintptr(unsafe.Pointer(_p$n))"; + push @uses, "use(unsafe.Pointer(_p$n))"; + $n++; + } elsif($type =~ /^\[\](.*)/) { + # Convert slice into pointer, length. + # Have to be careful not to take address of &a[0] if len == 0: + # pass dummy pointer in that case. + # Used to pass nil, but some OSes or simulators reject write(fd, nil, 0). + $text .= "\tvar _p$n unsafe.Pointer\n"; + $text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}"; + $text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}"; + $text .= "\n"; + push @args, "uintptr(_p$n)", "uintptr(len($name))"; + $n++; + } elsif($type eq "int64" && ($openbsd || $netbsd)) { + push @args, "0"; + if($_32bit eq "big-endian") { + push @args, "uintptr($name>>32)", "uintptr($name)"; + } elsif($_32bit eq "little-endian") { + push @args, "uintptr($name)", "uintptr($name>>32)"; + } else { + push @args, "uintptr($name)"; + } + } elsif($type eq "int64" && $dragonfly) { + if ($func !~ /^extp(read|write)/i) { + push @args, "0"; + } + if($_32bit eq "big-endian") { + push @args, "uintptr($name>>32)", "uintptr($name)"; + } elsif($_32bit eq "little-endian") { + push @args, "uintptr($name)", "uintptr($name>>32)"; + } else { + push @args, "uintptr($name)"; + } + } elsif($type eq "int64" && $_32bit ne "") { + if(@args % 2 && $arm) { + # arm abi specifies 64-bit argument uses + # (even, odd) pair + push @args, "0" + } + if($_32bit eq "big-endian") { + push @args, "uintptr($name>>32)", "uintptr($name)"; + } else { + push @args, "uintptr($name)", "uintptr($name>>32)"; + } + } else { + push @args, "uintptr($name)"; + } + } + + # Determine which form to use; pad args with zeros. + my $asm = "Syscall"; + if ($nonblock) { + $asm = "RawSyscall"; + } + if(@args <= 3) { + while(@args < 3) { + push @args, "0"; + } + } elsif(@args <= 6) { + $asm .= "6"; + while(@args < 6) { + push @args, "0"; + } + } elsif(@args <= 9) { + $asm .= "9"; + while(@args < 9) { + push @args, "0"; + } + } else { + print STDERR "$ARGV:$.: too many arguments to system call\n"; + } + + # System call number. + if($sysname eq "") { + $sysname = "SYS_$func"; + $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar + $sysname =~ y/a-z/A-Z/; + } + + # Actual call. + my $args = join(', ', @args); + my $call = "$asm($sysname, $args)"; + + # Assign return values. + my $body = ""; + my @ret = ("_", "_", "_"); + my $do_errno = 0; + for(my $i=0; $i<@out; $i++) { + my $p = $out[$i]; + my ($name, $type) = parseparam($p); + my $reg = ""; + if($name eq "err" && !$plan9) { + $reg = "e1"; + $ret[2] = $reg; + $do_errno = 1; + } elsif($name eq "err" && $plan9) { + $ret[0] = "r0"; + $ret[2] = "e1"; + next; + } else { + $reg = sprintf("r%d", $i); + $ret[$i] = $reg; + } + if($type eq "bool") { + $reg = "$reg != 0"; + } + if($type eq "int64" && $_32bit ne "") { + # 64-bit number in r1:r0 or r0:r1. + if($i+2 > @out) { + print STDERR "$ARGV:$.: not enough registers for int64 return\n"; + } + if($_32bit eq "big-endian") { + $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1); + } else { + $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i); + } + $ret[$i] = sprintf("r%d", $i); + $ret[$i+1] = sprintf("r%d", $i+1); + } + if($reg ne "e1" || $plan9) { + $body .= "\t$name = $type($reg)\n"; + } + } + if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") { + $text .= "\t$call\n"; + } else { + $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n"; + } + foreach my $use (@uses) { + $text .= "\t$use\n"; + } + $text .= $body; + + if ($plan9 && $ret[2] eq "e1") { + $text .= "\tif int32(r0) == -1 {\n"; + $text .= "\t\terr = e1\n"; + $text .= "\t}\n"; + } elsif ($do_errno) { + $text .= "\tif e1 != 0 {\n"; + $text .= "\t\terr = errnoErr(e1)\n"; + $text .= "\t}\n"; + } + $text .= "\treturn\n"; + $text .= "}\n\n"; +} + +chomp $text; +chomp $text; + +if($errors) { + exit 1; +} + +print <) { + chomp; + s/\s+/ /g; + s/^\s+//; + s/\s+$//; + $package = $1 if !$package && /^package (\S+)$/; + my $nonblock = /^\/\/sysnb /; + next if !/^\/\/sys / && !$nonblock; + + # Line must be of the form + # func Open(path string, mode int, perm int) (fd int, err error) + # Split into name, in params, out params. + if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) { + print STDERR "$ARGV:$.: malformed //sys declaration\n"; + $errors = 1; + next; + } + my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6); + + # Split argument lists on comma. + my @in = parseparamlist($in); + my @out = parseparamlist($out); + + # So file name. + if($modname eq "") { + $modname = "libc"; + } + + # System call name. + if($sysname eq "") { + $sysname = "$func"; + } + + # System call pointer variable name. + my $sysvarname = "proc$sysname"; + + my $strconvfunc = "BytePtrFromString"; + my $strconvtype = "*byte"; + + $sysname =~ y/A-Z/a-z/; # All libc functions are lowercase. + + # Runtime import of function to allow cross-platform builds. + $dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n"; + # Link symbol to proc address variable. + $linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n"; + # Library proc address variable. + push @vars, $sysvarname; + + # Go function header. + $out = join(', ', @out); + if($out ne "") { + $out = " ($out)"; + } + if($text ne "") { + $text .= "\n" + } + $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out; + + # Check if err return available + my $errvar = ""; + foreach my $p (@out) { + my ($name, $type) = parseparam($p); + if($type eq "error") { + $errvar = $name; + last; + } + } + + # Prepare arguments to Syscall. + my @args = (); + my @uses = (); + my $n = 0; + foreach my $p (@in) { + my ($name, $type) = parseparam($p); + if($type =~ /^\*/) { + push @args, "uintptr(unsafe.Pointer($name))"; + } elsif($type eq "string" && $errvar ne "") { + $text .= "\tvar _p$n $strconvtype\n"; + $text .= "\t_p$n, $errvar = $strconvfunc($name)\n"; + $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n"; + push @args, "uintptr(unsafe.Pointer(_p$n))"; + push @uses, "use(unsafe.Pointer(_p$n))"; + $n++; + } elsif($type eq "string") { + print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n"; + $text .= "\tvar _p$n $strconvtype\n"; + $text .= "\t_p$n, _ = $strconvfunc($name)\n"; + push @args, "uintptr(unsafe.Pointer(_p$n))"; + push @uses, "use(unsafe.Pointer(_p$n))"; + $n++; + } elsif($type =~ /^\[\](.*)/) { + # Convert slice into pointer, length. + # Have to be careful not to take address of &a[0] if len == 0: + # pass nil in that case. + $text .= "\tvar _p$n *$1\n"; + $text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n"; + push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))"; + $n++; + } elsif($type eq "int64" && $_32bit ne "") { + if($_32bit eq "big-endian") { + push @args, "uintptr($name >> 32)", "uintptr($name)"; + } else { + push @args, "uintptr($name)", "uintptr($name >> 32)"; + } + } elsif($type eq "bool") { + $text .= "\tvar _p$n uint32\n"; + $text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n"; + push @args, "uintptr(_p$n)"; + $n++; + } else { + push @args, "uintptr($name)"; + } + } + my $nargs = @args; + + # Determine which form to use; pad args with zeros. + my $asm = "sysvicall6"; + if ($nonblock) { + $asm = "rawSysvicall6"; + } + if(@args <= 6) { + while(@args < 6) { + push @args, "0"; + } + } else { + print STDERR "$ARGV:$.: too many arguments to system call\n"; + } + + # Actual call. + my $args = join(', ', @args); + my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)"; + + # Assign return values. + my $body = ""; + my $failexpr = ""; + my @ret = ("_", "_", "_"); + my @pout= (); + my $do_errno = 0; + for(my $i=0; $i<@out; $i++) { + my $p = $out[$i]; + my ($name, $type) = parseparam($p); + my $reg = ""; + if($name eq "err") { + $reg = "e1"; + $ret[2] = $reg; + $do_errno = 1; + } else { + $reg = sprintf("r%d", $i); + $ret[$i] = $reg; + } + if($type eq "bool") { + $reg = "$reg != 0"; + } + if($type eq "int64" && $_32bit ne "") { + # 64-bit number in r1:r0 or r0:r1. + if($i+2 > @out) { + print STDERR "$ARGV:$.: not enough registers for int64 return\n"; + } + if($_32bit eq "big-endian") { + $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1); + } else { + $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i); + } + $ret[$i] = sprintf("r%d", $i); + $ret[$i+1] = sprintf("r%d", $i+1); + } + if($reg ne "e1") { + $body .= "\t$name = $type($reg)\n"; + } + } + if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") { + $text .= "\t$call\n"; + } else { + $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n"; + } + foreach my $use (@uses) { + $text .= "\t$use\n"; + } + $text .= $body; + + if ($do_errno) { + $text .= "\tif e1 != 0 {\n"; + $text .= "\t\terr = e1\n"; + $text .= "\t}\n"; + } + $text .= "\treturn\n"; + $text .= "}\n"; +} + +if($errors) { + exit 1; +} + +print < "net.inet", + "net.inet.ipproto" => "net.inet", + "net.inet6.ipv6proto" => "net.inet6", + "net.inet6.ipv6" => "net.inet6.ip6", + "net.inet.icmpv6" => "net.inet6.icmp6", + "net.inet6.divert6" => "net.inet6.divert", + "net.inet6.tcp6" => "net.inet.tcp", + "net.inet6.udp6" => "net.inet.udp", + "mpls" => "net.mpls", + "swpenc" => "vm.swapencrypt" +); + +# Node mappings +my %node_map = ( + "net.inet.ip.ifq" => "net.ifq", + "net.inet.pfsync" => "net.pfsync", + "net.mpls.ifq" => "net.ifq" +); + +my $ctlname; +my %mib = (); +my %sysctl = (); +my $node; + +sub debug() { + print STDERR "$_[0]\n" if $debug; +} + +# Walk the MIB and build a sysctl name to OID mapping. +sub build_sysctl() { + my ($node, $name, $oid) = @_; + my %node = %{$node}; + my @oid = @{$oid}; + + foreach my $key (sort keys %node) { + my @node = @{$node{$key}}; + my $nodename = $name.($name ne '' ? '.' : '').$key; + my @nodeoid = (@oid, $node[0]); + if ($node[1] eq 'CTLTYPE_NODE') { + if (exists $node_map{$nodename}) { + $node = \%mib; + $ctlname = $node_map{$nodename}; + foreach my $part (split /\./, $ctlname) { + $node = \%{@{$$node{$part}}[2]}; + } + } else { + $node = $node[2]; + } + &build_sysctl($node, $nodename, \@nodeoid); + } elsif ($node[1] ne '') { + $sysctl{$nodename} = \@nodeoid; + } + } +} + +foreach my $ctl (@ctls) { + $ctls{$ctl} = $ctl; +} + +# Build MIB +foreach my $header (@headers) { + &debug("Processing $header..."); + open HEADER, "/usr/include/$header" || + print STDERR "Failed to open $header\n"; + while (
) { + if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ || + $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ || + $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) { + if ($1 eq 'CTL_NAMES') { + # Top level. + $node = \%mib; + } else { + # Node. + my $nodename = lc($2); + if ($header =~ /^netinet\//) { + $ctlname = "net.inet.$nodename"; + } elsif ($header =~ /^netinet6\//) { + $ctlname = "net.inet6.$nodename"; + } elsif ($header =~ /^net\//) { + $ctlname = "net.$nodename"; + } else { + $ctlname = "$nodename"; + $ctlname =~ s/^(fs|net|kern)_/$1\./; + } + if (exists $ctl_map{$ctlname}) { + $ctlname = $ctl_map{$ctlname}; + } + if (not exists $ctls{$ctlname}) { + &debug("Ignoring $ctlname..."); + next; + } + + # Walk down from the top of the MIB. + $node = \%mib; + foreach my $part (split /\./, $ctlname) { + if (not exists $$node{$part}) { + &debug("Missing node $part"); + $$node{$part} = [ 0, '', {} ]; + } + $node = \%{@{$$node{$part}}[2]}; + } + } + + # Populate current node with entries. + my $i = -1; + while (defined($_) && $_ !~ /^}/) { + $_ =
; + $i++ if $_ =~ /{.*}/; + next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/; + $$node{$1} = [ $i, $2, {} ]; + } + } + } + close HEADER; +} + +&build_sysctl(\%mib, "", []); + +print <){ + if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ + my $name = $1; + my $num = $2; + $name =~ y/a-z/A-Z/; + print " SYS_$name = $num;" + } +} + +print <){ + if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ + my $num = $1; + my $proto = $2; + my $name = "SYS_$3"; + $name =~ y/a-z/A-Z/; + + # There are multiple entries for enosys and nosys, so comment them out. + if($name =~ /^SYS_E?NOSYS$/){ + $name = "// $name"; + } + if($name eq 'SYS_SYS_EXIT'){ + $name = 'SYS_EXIT'; + } + + print " $name = $num; // $proto\n"; + } +} + +print <){ + if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ + my $num = $1; + my $proto = $2; + my $name = "SYS_$3"; + $name =~ y/a-z/A-Z/; + + # There are multiple entries for enosys and nosys, so comment them out. + if($name =~ /^SYS_E?NOSYS$/){ + $name = "// $name"; + } + if($name eq 'SYS_SYS_EXIT'){ + $name = 'SYS_EXIT'; + } + if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ + next + } + + print " $name = $num; // $proto\n"; + + # We keep Capsicum syscall numbers for FreeBSD + # 9-STABLE here because we are not sure whether they + # are mature and stable. + if($num == 513){ + print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; + print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; + print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; + print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; + } + } +} + +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; +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); + } + elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ + fmt($1, $prev+$2) + } +} + +print <){ + if($line =~ /^(.*)\\$/) { + # Handle continuation + $line = $1; + $_ =~ s/^\s+//; + $line .= $_; + } else { + # New line + $line = $_; + } + next if $line =~ /\\$/; + if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { + my $num = $1; + my $proto = $6; + my $compat = $8; + my $name = "$7_$9"; + + $name = "$7_$11" if $11 ne ''; + $name =~ y/a-z/A-Z/; + + if($compat eq '' || $compat eq '30' || $compat eq '50') { + print " $name = $num; // $proto\n"; + } + } +} + +print <){ + if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ + my $num = $1; + my $proto = $3; + my $name = $4; + $name =~ y/a-z/A-Z/; + + # There are multiple entries for enosys and nosys, so comment them out. + if($name =~ /^SYS_E?NOSYS$/){ + $name = "// $name"; + } + if($name eq 'SYS_SYS_EXIT'){ + $name = 'SYS_EXIT'; + } + + print " $name = $num; // $proto\n"; + } +} + +print < 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 00000000..35ed6643 --- /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 00000000..6442a993 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall.go @@ -0,0 +1,74 @@ +// 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 +} + +// 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 00000000..e9671764 --- /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 00000000..0d1771c3 --- /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 00000000..3195c8bf --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_386.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 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 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) + 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 00000000..7adb98de --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -0,0 +1,81 @@ +// 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 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) + 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 00000000..e47ffd73 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go @@ -0,0 +1,73 @@ +// 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 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) + 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 00000000..2560a959 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -0,0 +1,79 @@ +// 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 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) + 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 00000000..fbbe0dce --- /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_386.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go new file mode 100644 index 00000000..41c2e697 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go @@ -0,0 +1,63 @@ +// 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,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 = int32(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + 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) + 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_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go new file mode 100644 index 00000000..2ed92590 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go @@ -0,0 +1,63 @@ +// 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 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 + 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 00000000..ec56ed60 --- /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 00000000..6255d40f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -0,0 +1,63 @@ +// 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 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) + 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 00000000..8b395d59 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -0,0 +1,63 @@ +// 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 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 + 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 00000000..4e72d46a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -0,0 +1,63 @@ +// 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 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) + 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 00000000..88c8e042 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -0,0 +1,1097 @@ +// 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 +} + +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 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) +//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 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 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 00000000..45844015 --- /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 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) + 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) + +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 00000000..60698e44 --- /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 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 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 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 + 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 00000000..3b4da206 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -0,0 +1,252 @@ +// 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) + +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 00000000..42581156 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -0,0 +1,169 @@ +// 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 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 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 + 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) +} + +// 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 00000000..f23dd6c3 --- /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 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 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 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 + 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 00000000..2503b7f5 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -0,0 +1,98 @@ +// 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 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) +//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 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 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 + 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) +} 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 00000000..c4e945cd --- /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 00000000..1b0e1af1 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go @@ -0,0 +1,44 @@ +// 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 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) + 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 00000000..1b6dcbe3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go @@ -0,0 +1,44 @@ +// 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 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) + 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 00000000..87d1d6fe --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go @@ -0,0 +1,44 @@ +// 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 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) + 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 00000000..530792ea --- /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 00000000..246131d2 --- /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 00000000..9529b20e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go @@ -0,0 +1,44 @@ +// 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 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) + 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 00000000..fc640294 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go @@ -0,0 +1,44 @@ +// 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 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 + 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 00000000..eb489b15 --- /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 00000000..2e44630c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go @@ -0,0 +1,37 @@ +// 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 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 + 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 00000000..b46b2502 --- /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 00000000..11532618 --- /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 00000000..f3c971df --- /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 00000000..ae24557a --- /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 00000000..16378fa8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_linux.go @@ -0,0 +1,408 @@ +// 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 + +#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; +#else +typedef struct user_regs_struct PtraceRegs; +#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__ + // padding is not specified in linux/eventpoll.h but added to conform to the + // alignment requirements of EABI + 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 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 + 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 + +// 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_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 00000000..d15f93d1 --- /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 00000000..b66fe25f --- /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 00000000..6ad50eab --- /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 00000000..8e638883 --- /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 00000000..9594f938 --- /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 00000000..a410e88e --- /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 00000000..3189c6b3 --- /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_386.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_386.go new file mode 100644 index 00000000..2a329f06 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_386.go @@ -0,0 +1,1530 @@ +// mkerrors.sh -m32 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,dragonfly + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m32 _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 = 0xc0084279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4008426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80084267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8008427b + 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_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 = 0x8030720a + SIOCAIFADDR = 0x8040691a + SIOCALIFADDR = 0x8118691b + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDELRT = 0x8030720b + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8118691d + SIOCGDRVSPEC = 0xc01c697b + SIOCGETSGCNT = 0xc0147210 + SIOCGETVIFCNT = 0xc014720f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0086924 + SIOCGIFDATA = 0xc0206926 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMEDIA = 0xc0286938 + 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 = 0xc00c6978 + SIOCSDRVSPEC = 0x801c697b + 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 = 0x40087458 + 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 = 0x40087459 + 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_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go new file mode 100644 index 00000000..0feceee1 --- /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 00000000..7b95751c --- /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 00000000..e48e7799 --- /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 00000000..2afbe2d5 --- /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 00000000..d370be0e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -0,0 +1,1817 @@ +// 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_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_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 00000000..b83fb40b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -0,0 +1,1818 @@ +// 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_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_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 00000000..1cc76a78 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -0,0 +1,1742 @@ +// 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_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 00000000..47027b79 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -0,0 +1,1896 @@ +// 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_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 00000000..98056fe2 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -0,0 +1,1916 @@ +// 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_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 00000000..e5debb68 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -0,0 +1,1916 @@ +// 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_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 00000000..5b90d07e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -0,0 +1,1969 @@ +// 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_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 00000000..0861bd56 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -0,0 +1,1968 @@ +// 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_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_netbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go new file mode 100644 index 00000000..b4338d5f --- /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 00000000..4994437b --- /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 00000000..ac85ca64 --- /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 00000000..3322e998 --- /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 00000000..1758ecca --- /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 00000000..a08922b9 --- /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 00000000..a15aaf12 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -0,0 +1,1426 @@ +// 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)) + 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 00000000..74606b2f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -0,0 +1,1442 @@ +// 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)) + 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 00000000..640e8542 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -0,0 +1,1426 @@ +// 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)) + 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 00000000..933f67bb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -0,0 +1,1426 @@ +// 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)) + 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_386.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_386.go new file mode 100644 index 00000000..32e46af6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_386.go @@ -0,0 +1,1412 @@ +// mksyscall.pl -l32 -dragonfly syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_386.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,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)) + 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), 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 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) + 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 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, 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 +} 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 00000000..3fa6ff79 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -0,0 +1,1412 @@ +// 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)) + 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 00000000..1a0e528c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -0,0 +1,1664 @@ +// 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)) + 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 00000000..6e4cf145 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -0,0 +1,1664 @@ +// 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)) + 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 00000000..1872d323 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -0,0 +1,1664 @@ +// 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)) + 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 00000000..106cd592 --- /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 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 +} + +// 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 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) + 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 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 00000000..c1bae650 --- /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 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 +} + +// 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 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) + 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 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 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 00000000..3383f970 --- /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 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 +} + +// 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 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) + 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 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 00000000..fb2ff3aa --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -0,0 +1,1733 @@ +// 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 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 +} + +// 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 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) + 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 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 00000000..7eac55b5 --- /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 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 +} + +// 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 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) + 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 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 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 00000000..e8b61a6e --- /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 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 +} + +// 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 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) + 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 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 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 00000000..f8eaae9a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -0,0 +1,1802 @@ +// 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 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 +} + +// 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 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) + 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 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 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 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 +} 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 00000000..22d444fe --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -0,0 +1,1802 @@ +// 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 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 +} + +// 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 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) + 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 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 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 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 +} 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 00000000..00ca1f9c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -0,0 +1,1326 @@ +// 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)) + 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 00000000..03f31b97 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -0,0 +1,1326 @@ +// 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)) + 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 00000000..84dc61cf --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -0,0 +1,1326 @@ +// 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)) + 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 00000000..02b3528a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -0,0 +1,1386 @@ +// 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)) + 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 00000000..7dc2b7ea --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -0,0 +1,1386 @@ +// 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)) + 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 00000000..43264278 --- /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 00000000..83bb935b --- /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 00000000..2786773b --- /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 00000000..09de240c --- /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 00000000..b8c9aea8 --- /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 00000000..26677ebb --- /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_386.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_386.go new file mode 100644 index 00000000..785240a7 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_386.go @@ -0,0 +1,304 @@ +// mksysnum_dragonfly.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build 386,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_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go new file mode 100644 index 00000000..d6038fa9 --- /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 00000000..262a8453 --- /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 00000000..57a60ea1 --- /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 00000000..206b9f61 --- /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 00000000..ba952c67 --- /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 00000000..ddac31f5 --- /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 00000000..45ced17f --- /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 00000000..2e9514f2 --- /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 00000000..5ffe1c71 --- /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 00000000..d192b940 --- /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 00000000..e1b08f00 --- /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 00000000..45e63f51 --- /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_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go new file mode 100644 index 00000000..f60d8f98 --- /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 00000000..48a91d46 --- /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 00000000..612ba662 --- /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 00000000..3e8ce2a1 --- /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 00000000..bd28146d --- /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 00000000..c7086598 --- /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 00000000..2de1d44e --- /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 00000000..04465787 --- /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 00000000..66df363c --- /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 00000000..85d56eab --- /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_386.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_386.go new file mode 100644 index 00000000..b7e7ff08 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_386.go @@ -0,0 +1,437 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_dragonfly.go + +// +build 386,dragonfly + +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 { + 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 int32 + Bsize int32 + Iosize int32 + Blocks int32 + Bfree int32 + Bavail int32 + Files int32 + Ffree int32 + Fsid Fsid + Owner uint32 + Type int32 + Flags int32 + Syncwrites int32 + Asyncwrites int32 + Fstypename [16]int8 + Mntonname [80]int8 + Syncreads int32 + Asyncreads int32 + Spares1 int16 + Mntfromname [80]int8 + Spares2 int16 + Spare [2]int32 +} + +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 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 = 0x36 + 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 int32 + Udata *byte +} + +type FdSet struct { + Bits [32]uint32 +} + +const ( + SizeofIfMsghdr = 0x68 + SizeofIfData = 0x58 + 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 IfData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Pad_cgo_0 [2]byte + Mtu uint32 + Metric uint32 + Link_state uint32 + Baudrate uint64 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Hwassist uint32 + Unused uint32 + 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 uint32 + Rmx RtMetrics +} + +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 +} + +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_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go new file mode 100644 index 00000000..8a6f4e1c --- /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 00000000..8cf30947 --- /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 00000000..e5feb207 --- /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 00000000..5472b542 --- /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 00000000..cf5db0e1 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -0,0 +1,590 @@ +// +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 +} + +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 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 + 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_SYMLINK_NOFOLLOW = 0x100 + AT_REMOVEDIR = 0x200 +) + +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 00000000..ac27784a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -0,0 +1,608 @@ +// +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 +} + +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 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 + 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_SYMLINK_NOFOLLOW = 0x100 + AT_REMOVEDIR = 0x200 +) + +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 00000000..b318bb85 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -0,0 +1,579 @@ +// +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 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 + 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_SYMLINK_NOFOLLOW = 0x100 + AT_REMOVEDIR = 0x200 +) + +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 00000000..a159aada --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -0,0 +1,595 @@ +// +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 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 + 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 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + 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 00000000..0c5c9189 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -0,0 +1,599 @@ +// +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 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 + 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_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 00000000..7c0c8037 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -0,0 +1,599 @@ +// +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 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 + 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_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 00000000..b14cbfef --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -0,0 +1,605 @@ +// +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 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 + 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 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + 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 00000000..22c96a2f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -0,0 +1,605 @@ +// +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 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 + 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 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + 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_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go new file mode 100644 index 00000000..caf755fb --- /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 00000000..91b4a530 --- /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 00000000..c0758f9d --- /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 00000000..860a4697 --- /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 00000000..23c52727 --- /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 00000000..b3b928a5 --- /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 +} From 66084a79ce158ccfd5e35cd5454112c78613a517 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Jun 2016 17:25:22 -0700 Subject: [PATCH 079/357] replica: Only check current exists snapshot for backup --- replica/backup.go | 11 +++++++---- trash.yml | 3 +-- .../rancher/convoy/objectstore/deltablock.go | 10 +++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/replica/backup.go b/replica/backup.go index 2d44633c..abb61244 100644 --- a/replica/backup.go +++ b/replica/backup.go @@ -36,10 +36,13 @@ func NewBackup(backingFile *BackingFile) *Backup { func (rb *Backup) HasSnapshot(id, volumeID string) bool { //TODO Check current in the volume directory of volumeID - for _, file := range []string{id, id + ".meta"} { - if _, err := os.Stat(file); err != nil { - return false - } + if err := rb.assertOpen(id, volumeID); err != nil { + return false + } + + to := rb.findIndex(id) + if to < 0 { + return false } return true } diff --git a/trash.yml b/trash.yml index 13a9ce01..5eb4cf86 100644 --- a/trash.yml +++ b/trash.yml @@ -29,7 +29,7 @@ import: - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy - version: 2d75418d1f796c6b26e34f7fecf3c1e839a99479 + version: 79b2b778af1441227aa2ca707653c48cc2e8632b - package: github.com/mcuadros/go-version version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 - package: golang.org/x/sys/unix @@ -56,4 +56,3 @@ import: version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 - package: github.com/jmespath/go-jmespath version: c01cf91b011868172fdcd9f41838e80c9d716264 - diff --git a/vendor/github.com/rancher/convoy/objectstore/deltablock.go b/vendor/github.com/rancher/convoy/objectstore/deltablock.go index f9f6adec..d5150859 100644 --- a/vendor/github.com/rancher/convoy/objectstore/deltablock.go +++ b/vendor/github.com/rancher/convoy/objectstore/deltablock.go @@ -55,6 +55,11 @@ func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, lastBackupName := volume.LastBackupName + if err := deltaOps.OpenSnapshot(snapshot.Name, volume.Name); err != nil { + return "", err + } + defer deltaOps.CloseSnapshot(snapshot.Name, volume.Name) + var lastSnapshotName string var lastBackup *Backup if lastBackupName != "" { @@ -89,11 +94,6 @@ func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, LOG_FIELD_LAST_SNAPSHOT: lastSnapshotName, }).Debug("Generating snapshot changed blocks metadata") - if err := deltaOps.OpenSnapshot(snapshot.Name, volume.Name); err != nil { - return "", err - } - defer deltaOps.CloseSnapshot(snapshot.Name, volume.Name) - delta, err := deltaOps.CompareSnapshot(snapshot.Name, lastSnapshotName, volume.Name) if err != nil { return "", err From 99dc2240abe94f078f3a358beda8577d535ae7bd Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 21:45:23 -0700 Subject: [PATCH 080/357] controller: Add backup commands Make longhorn-backup a executable inside longhorn --- app/backup.go | 118 ++++++++++++++++++++++++ backup/import_objectstore.go | 2 +- backup/main.go | 26 +++--- main.go | 3 + replica/client/client.go | 98 ++++++++++++++++++++ replica/replica.go | 6 +- scripts/build | 1 - scripts/build-backup | 9 -- sync/agent/model.go | 1 + sync/agent/process.go | 101 +++++++++++++++++++++ sync/backup.go | 168 +++++++++++++++++++++++++++++++++++ 11 files changed, 508 insertions(+), 25 deletions(-) create mode 100644 app/backup.go delete mode 100755 scripts/build-backup create mode 100644 sync/backup.go diff --git a/app/backup.go b/app/backup.go new file mode 100644 index 00000000..4296f6d2 --- /dev/null +++ b/app/backup.go @@ -0,0 +1,118 @@ +package app + +import ( + "fmt" + + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" + "github.com/rancher/longhorn/sync" +) + +func BackupCmd() cli.Command { + return cli.Command{ + Name: "backups", + ShortName: "backup", + Subcommands: []cli.Command{ + BackupCreateCmd(), + BackupRestoreCmd(), + BackupRmCmd(), + }, + } +} + +func BackupCreateCmd() cli.Command { + return cli.Command{ + Name: "create", + Usage: "create a backup in objectstore: create --dest ", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "dest", + Usage: "destination of backup if driver supports, would be url like s3://bucket@region/path/ or vfs:///path/", + }, + }, + Action: func(c *cli.Context) { + if err := createBackup(c); err != nil { + logrus.Fatalf("Error running create backup command: %v", err) + } + }, + } +} + +func BackupRmCmd() cli.Command { + return cli.Command{ + Name: "rm", + Usage: "remove a backup in objectstore: rm ", + Action: func(c *cli.Context) { + if err := rmBackup(c); err != nil { + logrus.Fatalf("Error running rm backup command: %v", err) + } + }, + } +} + +func BackupRestoreCmd() cli.Command { + return cli.Command{ + Name: "restore", + Usage: "restore a backup to current volume: restore ", + Action: func(c *cli.Context) { + if err := restoreBackup(c); err != nil { + logrus.Fatalf("Error running restore backup command: %v", err) + } + }, + } +} + +func createBackup(c *cli.Context) error { + url := c.GlobalString("url") + task := sync.NewTask(url) + + dest := c.String("dest") + if dest == "" { + return fmt.Errorf("Missing required parameter --dest") + } + + snapshot := c.Args().First() + if snapshot == "" { + return fmt.Errorf("Missing required parameter snapshot") + } + + backup, err := task.CreateBackup(snapshot, dest) + if err != nil { + return err + } + fmt.Println(backup) + + return nil +} + +func rmBackup(c *cli.Context) error { + url := c.GlobalString("url") + task := sync.NewTask(url) + + backup := c.Args().First() + if backup == "" { + return fmt.Errorf("Missing required parameter backup") + } + + if err := task.RmBackup(backup); err != nil { + return err + } + + return nil +} + +func restoreBackup(c *cli.Context) error { + url := c.GlobalString("url") + task := sync.NewTask(url) + + backup := c.Args().First() + if backup == "" { + return fmt.Errorf("Missing required parameter backup") + } + + if err := task.RestoreBackup(backup); err != nil { + return err + } + + return nil +} diff --git a/backup/import_objectstore.go b/backup/import_objectstore.go index f41f3df4..66387825 100644 --- a/backup/import_objectstore.go +++ b/backup/import_objectstore.go @@ -1,4 +1,4 @@ -package main +package backup import ( // Involve S3 objecstore drivers for registeration diff --git a/backup/main.go b/backup/main.go index 62f381dd..09490018 100644 --- a/backup/main.go +++ b/backup/main.go @@ -1,10 +1,9 @@ -package main +package backup import ( "encoding/json" "fmt" "os" - "path" "runtime" "runtime/debug" "strings" @@ -113,9 +112,15 @@ func cleanup() { } } -func main() { +func Main() { defer cleanup() + dir, err := os.Getwd() + if err != nil { + log.Fatalf("Cannot get running directory: %s", err) + } + log.Debugf("Currently running at %v, assume as volume dir", dir) + app := cli.NewApp() app.Version = VERSION app.Commands = []cli.Command{ @@ -176,22 +181,17 @@ func doBackupCreate(c *cli.Context) error { return err } - volumePath, err := util.GetFlag(c, "volume", true, err) + volumeName, err := util.GetFlag(c, "volume", true, err) if err != nil { return err } - // Switch to one level upper than volume working directory - volumeName := path.Base(volumePath) - volumeDir := path.Dir(volumePath) - log.Info("volume dir, name", volumeDir, volumeName) - if volumeDir != "" { - if err := os.Chdir(volumeDir); err != nil { - return err - } + dir, err := os.Getwd() + if err != nil { + return err } - volumeInfo, err := replica.ReadInfo(volumeName) + volumeInfo, err := replica.ReadInfo(dir) if err != nil { return err } diff --git a/main.go b/main.go index d6c844ff..d9073875 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "github.com/codegangsta/cli" "github.com/docker/docker/pkg/reexec" "github.com/rancher/longhorn/app" + "github.com/rancher/longhorn/backup" "github.com/rancher/sparse-tools/cli/sfold" "github.com/rancher/sparse-tools/cli/ssync" ) @@ -16,6 +17,7 @@ import ( func main() { reexec.Register("ssync", ssync.Main) reexec.Register("sfold", sfold.Main) + reexec.Register("sbackup", backup.Main) if !reexec.Init() { longhornCli() @@ -57,6 +59,7 @@ func longhornCli() { app.LsReplicaCmd(), app.RmReplicaCmd(), app.SnapshotCmd(), + app.BackupCmd(), } if err := a.Run(os.Args); err != nil { diff --git a/replica/client/client.go b/replica/client/client.go index 4519f07c..85062572 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -222,6 +222,104 @@ func (c *ReplicaClient) SendFile(from, to, host string, port int) error { } } +func (c *ReplicaClient) CreateBackup(snapshot, dest, volume string) (string, error) { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "backup", + SrcFile: snapshot, + DestFile: dest, + Host: volume, + }, &running) + if err != nil { + return "", err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return "", err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return running.Output, nil + default: + return "", fmt.Errorf("ExitCode: %d", running.ExitCode) + } + } +} + +func (c *ReplicaClient) RmBackup(backup string) error { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "rmbackup", + SrcFile: backup, + }, &running) + if err != nil { + return err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return nil + default: + return fmt.Errorf("ExitCode: %d", running.ExitCode) + } + } +} + +func (c *ReplicaClient) RestoreBackup(backup, snapshotFile string) error { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "restore", + SrcFile: backup, + DestFile: snapshotFile, + }, &running) + if err != nil { + return err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return nil + default: + return fmt.Errorf("ExitCode: %d", running.ExitCode) + } + } +} func (c *ReplicaClient) get(url string, obj interface{}) error { if !strings.HasPrefix(url, "http") { url = c.address + url diff --git a/replica/replica.go b/replica/replica.go index 08ef1f8d..ef3d013f 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -136,6 +136,10 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF return r, r.writeVolumeMetaData(true, r.info.Rebuilding) } +func GenerateSnapshotDiskName(name string) string { + return fmt.Sprintf(diskName, name) +} + func (r *Replica) insertBackingFile() { if r.info.BackingFile == nil { return @@ -404,7 +408,7 @@ func (r *Replica) createDisk(name string) error { done := false oldHead := r.info.Head - newSnapName := fmt.Sprintf(diskName, name) + newSnapName := GenerateSnapshotDiskName(name) if oldHead == "" { newSnapName = "" diff --git a/scripts/build b/scripts/build index eba35192..0347cab2 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,3 @@ cd $(dirname $0) ./build-cli ./build-agent -./build-backup diff --git a/scripts/build-backup b/scripts/build-backup deleted file mode 100755 index a82e9946..00000000 --- a/scripts/build-backup +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -source $(dirname $0)/version - -cd $(dirname $0)/.. - -mkdir -p bin -go build -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn-backup ./backup diff --git a/sync/agent/model.go b/sync/agent/model.go index 565a9c91..1ea141af 100644 --- a/sync/agent/model.go +++ b/sync/agent/model.go @@ -14,6 +14,7 @@ type Process struct { Host string `json:"host"` Port int `json:"port"` ExitCode int `json:"exitCode"` + Output string `json:"output"` Created time.Time `json:"created"` } diff --git a/sync/agent/process.go b/sync/agent/process.go index 05c58f5c..2242faed 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -1,6 +1,7 @@ package agent import ( + "bytes" "errors" "fmt" "net/http" @@ -120,6 +121,12 @@ func (s *Server) launch(p *Process) error { return s.launchSync(p) case "fold": return s.launchFold(p) + case "backup": + return s.launchBackup(p) + case "rmbackup": + return s.launchRmBackup(p) + case "restore": + return s.launchRestore(p) } return fmt.Errorf("Unknown process type %s", p.ProcessType) } @@ -225,3 +232,97 @@ func (s *Server) nextPort() (int, error) { return 0, errors.New("Out of ports") } + +func (s *Server) launchBackup(p *Process) error { + buf := new(bytes.Buffer) + + cmd := reexec.Command("sbackup", "create", p.SrcFile, "--dest", p.DestFile, + "--volume", p.Host) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = buf + cmd.Stderr = os.Stderr + if err := cmd.Start(); err != nil { + return err + } + + logrus.Infof("Running %s %v", cmd.Path, cmd.Args) + err := cmd.Wait() + if err != nil { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + p.Output = buf.String() + logrus.Infof("Done running %s %v, returns %v", "sbackup", cmd.Args, p.Output) + return nil +} + +func (s *Server) launchRmBackup(p *Process) error { + cmd := reexec.Command("sbackup", "delete", p.SrcFile) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Start(); err != nil { + return err + } + + logrus.Infof("Running %s %v", cmd.Path, cmd.Args) + err := cmd.Wait() + if err != nil { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v", "sbackup", cmd.Args) + return nil +} + +func (s *Server) launchRestore(p *Process) error { + cmd := reexec.Command("sbackup", "restore", p.SrcFile, "--to", p.DestFile) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Start(); err != nil { + return err + } + + logrus.Infof("Running %s %v", cmd.Path, cmd.Args) + err := cmd.Wait() + if err != nil { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v", "sbackup", cmd.Args) + return nil +} diff --git a/sync/backup.go b/sync/backup.go new file mode 100644 index 00000000..91bc9a80 --- /dev/null +++ b/sync/backup.go @@ -0,0 +1,168 @@ +package sync + +import ( + "fmt" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/controller/rest" + "github.com/rancher/longhorn/replica" + replicaClient "github.com/rancher/longhorn/replica/client" + "github.com/rancher/longhorn/util" +) + +func (t *Task) CreateBackup(snapshot, dest string) (string, error) { + var replica *rest.Replica + + volume, err := t.client.GetVolume() + if err != nil { + return "", err + } + + replicas, err := t.client.ListReplicas() + if err != nil { + return "", err + } + + for _, r := range replicas { + if r.Mode == "RW" { + replica = &r + break + } + } + + if replica == nil { + return "", fmt.Errorf("Cannot find a suitable replica for backup") + } + + backup, err := t.createBackup(replica, snapshot, dest, volume.Name) + if err != nil { + return "", err + } + return backup, nil +} + +func (t *Task) createBackup(replicaInController *rest.Replica, snapshot, dest, volumeName string) (string, error) { + if replicaInController.Mode != "RW" { + return "", fmt.Errorf("Can only create backup from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) + if err != nil { + return "", err + } + + replica, err := repClient.GetReplica() + if err != nil { + return "", err + } + + snapshotName, index := getNameAndIndex(replica.Chain, snapshot) + switch { + case index < 0: + return "", fmt.Errorf("Snapshot %s not found on replica %s", snapshot, replicaInController.Address) + case index == 0: + return "", fmt.Errorf("Can not backup the head disk in the chain") + } + + logrus.Infof("Backing up %s on %s, to %s", snapshotName, replicaInController.Address, dest) + + backup, err := repClient.CreateBackup(snapshotName, dest, volumeName) + if err != nil { + logrus.Errorf("Failed backing up %s on %s to %s", snapshotName, replicaInController.Address, dest) + return "", err + } + return backup, nil +} + +func (t *Task) RmBackup(backup string) error { + var replica *rest.Replica + + replicas, err := t.client.ListReplicas() + if err != nil { + return err + } + + for _, r := range replicas { + if r.Mode == "RW" { + replica = &r + break + } + } + + if replica == nil { + return fmt.Errorf("Cannot find a suitable replica for remove backup") + } + + if err := t.rmBackup(replica, backup); err != nil { + return err + } + return nil +} + +func (t *Task) rmBackup(replicaInController *rest.Replica, backup string) error { + if replicaInController.Mode != "RW" { + return fmt.Errorf("Can only create backup from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) + if err != nil { + return err + } + + logrus.Infof("Removing backup %s on %s", backup, replicaInController.Address) + + if err := repClient.RmBackup(backup); err != nil { + logrus.Errorf("Failed removing backup %s on %s", backup, replicaInController.Address) + return err + } + return nil +} + +func (t *Task) RestoreBackup(backup string) error { + replicas, err := t.client.ListReplicas() + if err != nil { + return err + } + + for _, r := range replicas { + if ok, err := t.isRebuilding(&r); err != nil { + return err + } else if ok { + return fmt.Errorf("Can not restore from backup because %s is rebuilding", r.Address) + } + } + + // generate new snapshot and metafile as base for new volume + snapshotID := util.UUID() + snapshotFile := replica.GenerateSnapshotDiskName(snapshotID) + for _, replica := range replicas { + if err := t.restoreBackup(&replica, backup, snapshotFile); err != nil { + return err + } + } + + // call to controller to revert to sfile + if err := t.client.RevertSnapshot(snapshotID); err != nil { + return fmt.Errorf("Fail to revert to snapshot %v", snapshotID) + } + return nil +} + +func (t *Task) restoreBackup(replicaInController *rest.Replica, backup string, snapshotFile string) error { + if replicaInController.Mode != "RW" { + return fmt.Errorf("Can only create backup from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) + if err != nil { + return err + } + + logrus.Infof("Restoring backup %s on %s", backup, replicaInController.Address) + + if err := repClient.RestoreBackup(backup, snapshotFile); err != nil { + logrus.Errorf("Failed restoring backup %s on %s", backup, replicaInController.Address) + return err + } + return nil +} From 21892b455760d70b7294ac2dc0c7d81f4a799df2 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 21:45:23 -0700 Subject: [PATCH 081/357] Workaround live chain detection for revert to implement restore Won't be a permanent solution. --- controller/revert.go | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/controller/revert.go b/controller/revert.go index 4102d0c0..200e4e40 100644 --- a/controller/revert.go +++ b/controller/revert.go @@ -52,31 +52,34 @@ func (c *Controller) clientsAndSnapshot(name string) (map[string]*client.Replica return nil, "", err } - rep, err := repClient.GetReplica() + _, err = repClient.GetReplica() if err != nil { return nil, "", err } - found := "" - for _, snapshot := range rep.Chain { - if snapshot == name { - found = name - break + /* + found := "" + for _, snapshot := range rep.Chain { + if snapshot == name { + found = name + break + } + fullName := "volume-snap-" + name + ".img" + if snapshot == fullName { + found = fullName + break + } } - fullName := "volume-snap-" + name + ".img" - if snapshot == fullName { - found = fullName - break - } - } - if found == "" { - return nil, "", fmt.Errorf("Failed to find snapshot %s on %s", name, replica) - } + if found == "" { + return nil, "", fmt.Errorf("Failed to find snapshot %s on %s", name, replica) + } - name = found + name = found + */ clients[replica.Address] = repClient } + name = "volume-snap-" + name + ".img" return clients, name, nil } From f7b7165bf526267d7a073973239f96eb997132f1 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 30 May 2016 21:45:23 -0700 Subject: [PATCH 082/357] backup: integration test --- integration/core/test_cli.py | 59 ++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 6a1918ca..9f0e2f89 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -1,6 +1,7 @@ import time import random from os import path +import os import subprocess import pytest @@ -10,6 +11,8 @@ REPLICA = 'tcp://localhost:9502' REPLICA2 = 'tcp://localhost:9505' +BACKUP_DEST = '/tmp/longhorn-backup' + @pytest.fixture def controller_client(request): @@ -79,6 +82,14 @@ def bin(): return c +def setup_module(): + if os.path.exists(BACKUP_DEST): + subprocess.check_call(["rm", "-rf", BACKUP_DEST]) + + os.makedirs(BACKUP_DEST) + assert os.path.exists(BACKUP_DEST) + + def open_replica(client): replicas = client.list_replica() assert len(replicas) == 1 @@ -90,10 +101,10 @@ def open_replica(client): assert r.parent == '' assert r.head == '' - r = r.create(size=str(1024*4096)) + r = r.create(size=str(1024 * 4096)) assert r.state == 'closed' - assert r.size == str(1024*4096) + assert r.size == str(1024 * 4096) assert r.sectorSize == 512 assert r.parent == '' assert r.head == 'volume-head-000.img' @@ -353,3 +364,47 @@ def test_snapshot_last(bin, controller_client, replica_client, cmd = [bin, 'snapshot', 'rm', output] with pytest.raises(subprocess.CalledProcessError): subprocess.check_call(cmd) + + +def test_backup(bin, controller_client, replica_client, + replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + cmd = [bin, 'snapshot', 'create'] + output = subprocess.check_output(cmd).strip() + snapshot1 = replica_client.list_replica()[0].chain[1] + + assert snapshot1 == 'volume-snap-{}.img'.format(output) + + cmd = [bin, 'backup', 'create', snapshot1, + '--dest', "vfs://" + BACKUP_DEST] + backup1 = subprocess.check_output(cmd).strip() + + cmd = [bin, 'snapshot', 'create'] + output = subprocess.check_output(cmd).strip() + snapshot2 = replica_client.list_replica()[0].chain[1] + + assert snapshot2 == 'volume-snap-{}.img'.format(output) + + cmd = [bin, 'create', snapshot2, + '--dest', "vfs://" + BACKUP_DEST] + backup2 = subprocess.check_output(cmd).strip() + + cmd = [bin, 'restore', backup1] + subprocess.check_call(cmd) + + cmd = [bin, 'restore', backup2] + subprocess.check_call(cmd) + + cmd = [bin, 'rm', backup1] + subprocess.check_call(cmd) + cmd = [bin, 'rm', backup2] + subprocess.check_call(cmd) From 8027fe66c7b2a8710de785c0f437c07664048782 Mon Sep 17 00:00:00 2001 From: kirill Date: Wed, 1 Jun 2016 15:06:58 -0700 Subject: [PATCH 083/357] controller: implemented read/write timeouts - the timeouts are tracked per request once it has been sent to a replica - this is an isolated patch and does not require any stats support --- rpc/client.go | 45 ++++++++++++++++++++++++++++++++++++++------- rpc/types.go | 6 ++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/rpc/client.go b/rpc/client.go index 8b7e445c..7b4cc87d 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -4,10 +4,18 @@ import ( "errors" "io" "net" + "time" "github.com/Sirupsen/logrus" ) +var ( + opReadTimeout = 15 * time.Second // client read + opWriteTimeout = 15 * time.Second // client write + errReadTimeout = errors.New("read timeout") + errWriteTimeout = errors.New("write timeout") +) + type Client struct { end chan struct{} requests chan *Message @@ -50,13 +58,36 @@ func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { msg := Message{ - Type: op, - Offset: offset, - Data: buf, + Complete: make(chan struct{}, 1), + Type: op, + Offset: offset, + Data: buf, } - msg.Add(1) + + timeout := func(op uint32) <-chan time.Time { + switch op { + case TypeRead: + return time.After(opReadTimeout) + } + return time.After(opWriteTimeout) + }(msg.Type) + c.requests <- &msg - msg.Wait() + + select { + case <-msg.Complete: + case <-timeout: + switch msg.Type { + case TypeRead: + c.SetError(errReadTimeout) + logrus.Errorln("Read timeout: seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + + case TypeWrite: + c.SetError(errWriteTimeout) + logrus.Errorln("Write timeout: seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + } + // stats.Print()//flush automaticalyupon timeout + } if msg.Type == TypeError { return 0, errors.New(string(msg.Data)) @@ -98,7 +129,7 @@ func (c *Client) replyError(req *Message) { delete(c.messages, req.Seq) req.Type = TypeError req.Data = []byte(c.err.Error()) - req.Done() + req.Complete <- struct{}{} } func (c *Client) handleRequest(req *Message) { @@ -134,7 +165,7 @@ func (c *Client) handleResponse(resp *Message) { copy(req.Data, resp.Data) } req.Type = resp.Type - req.Done() + req.Complete <- struct{}{} } } diff --git a/rpc/types.go b/rpc/types.go index b21fbc62..2a693d27 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -1,7 +1,5 @@ package rpc -import "sync" - const ( TypeRead = iota TypeWrite @@ -9,13 +7,13 @@ const ( TypeError TypeEOF - messageSize = (32 + 32 + 32 + 64) / 8 + messageSize = (32 + 32 + 32 + 64) / 8 //TODO: unused? readBufferSize = 8096 writeBufferSize = 8096 ) type Message struct { - sync.WaitGroup + Complete chan struct{} Seq uint32 Type uint32 From 42d2ee57f057d678b6f02e7b5a4239455d449f38 Mon Sep 17 00:00:00 2001 From: kirill Date: Wed, 1 Jun 2016 15:07:36 -0700 Subject: [PATCH 084/357] controller: removed replica ping logic - mostly a revert of commit 90f7a6cedf0a3a245574ea0c6cf346926f934356 --- app/replica.go | 11 ++------ backend/remote/remote.go | 59 ++-------------------------------------- replica/rest/router.go | 4 --- 3 files changed, 4 insertions(+), 70 deletions(-) diff --git a/app/replica.go b/app/replica.go index fced7bf3..7aea9a1d 100644 --- a/app/replica.go +++ b/app/replica.go @@ -83,16 +83,9 @@ func startReplica(c *cli.Context) error { go func() { server := rest.NewServer(s) router := http.Handler(rest.NewRouter(server)) - loggingHander := handlers.LoggingHandler(os.Stdout, router) - wrappedRouter := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - if req.URL.Path == "/ping" { - router.ServeHTTP(rw, req) - } else { - loggingHander.ServeHTTP(rw, req) - } - }) + router = handlers.LoggingHandler(os.Stdout, router) logrus.Infof("Listening on control %s", controlAddress) - resp <- http.ListenAndServe(controlAddress, wrappedRouter) + resp <- http.ListenAndServe(controlAddress, router) }() go func() { diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 9f374c5d..ee84953a 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -3,7 +3,6 @@ package remote import ( "bytes" "encoding/json" - "errors" "fmt" "io" "net" @@ -19,11 +18,7 @@ import ( ) var ( - pingTimeout = 3 * time.Second - pingInveral = 2 * time.Second - timeout = 30 * time.Second - requestBuffer = 1024 - ErrPingTimeout = errors.New("Ping timeout") + timeout = 30 * time.Second ) func New() types.BackendFactory { @@ -36,14 +31,11 @@ type Factory struct { type Remote struct { types.ReaderWriterAt name string - pingURL string replicaURL string httpClient *http.Client - closeChan chan struct{} } func (r *Remote) Close() error { - r.closeChan <- struct{}{} logrus.Infof("Closing: %s", r.name) return r.doAction("close", "") } @@ -138,11 +130,9 @@ func (rf *Factory) Create(address string) (types.Backend, error) { r := &Remote{ name: address, replicaURL: fmt.Sprintf("http://%s/v1/replicas/1", controlAddress), - pingURL: fmt.Sprintf("http://%s/ping", controlAddress), httpClient: &http.Client{ Timeout: timeout, }, - closeChan: make(chan struct{}, 1), } replica, err := r.info() @@ -159,56 +149,11 @@ func (rf *Factory) Create(address string) (types.Backend, error) { return nil, err } - rpc := rpc.NewClient(conn) - r.ReaderWriterAt = rpc + r.ReaderWriterAt = rpc.NewClient(conn) if err := r.open(); err != nil { return nil, err } - go r.monitorPing(rpc) - return r, nil } - -func (r *Remote) monitorPing(client *rpc.Client) error { - ticker := time.NewTicker(pingInveral) - defer ticker.Stop() - - for { - select { - case <-r.closeChan: - return nil - case <-ticker.C: - if err := r.Ping(); err != nil { - logrus.Errorf("Failed to get ping response: %v", err) - client.SetError(err) - return err - } - } - } -} - -func (r *Remote) Ping() error { - ret := make(chan error, 1) - go func() { - resp, err := r.httpClient.Get(r.pingURL) - if err != nil { - ret <- err - return - } - defer resp.Body.Close() - if resp.StatusCode != 200 { - ret <- fmt.Errorf("Non-200 response %d from ping to %s", resp.StatusCode, r.name) - return - } - ret <- nil - }() - - select { - case err := <-ret: - return err - case <-time.After(pingTimeout): - return ErrPingTimeout - } -} diff --git a/replica/rest/router.go b/replica/rest/router.go index a4d2e44c..2d36728c 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -24,10 +24,6 @@ func NewRouter(s *Server) *mux.Router { router := mux.NewRouter().StrictSlash(true) f := rest.HandleError - router.Methods("GET").Path("/ping").Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - rw.Write([]byte("pong")) - })) - // API framework routes router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) From 7f57103ce365fbef2ff1c24d340e9ca8030214e4 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 3 Jun 2016 20:34:15 -0700 Subject: [PATCH 085/357] tcmu: Add check_config before add device (#119) A patch for tcmu-runner is needed. So add dependency to yasker/tcmu-runner. Basically tcmu-runner doesn't check if it's the device we want to handle before open uio device, which caused multiple handlers may contend for the same uio device(though only one of them should do so). The patch in tcmu-runner uses check_config to validate the device before actually open it. Also the handlers in longhorn need to make sure that it only handle it's own volume, which indicates in dev_config: longhorn// --- Dockerfile.dapper | 4 ++-- frontend/tcmu/cfunc.go | 26 +++++++++++++++---------- frontend/tcmu/main.go | 43 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 4dde82f6..915f0223 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -44,9 +44,9 @@ RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/ # Build TCMU RUN cd /usr/src && \ - git clone https://github.com/agrover/tcmu-runner.git && \ + git clone https://github.com/yasker/tcmu-runner.git && \ cd tcmu-runner && \ - git checkout 9b6d458cd3106ee75b1800cb2fbfb6ffe545b669 + git checkout 8a72eaefada2ad939eff5ac5628c8fdea8f69a19 RUN cd /usr/src/tcmu-runner && \ cmake . -Dwith-glfs=false && \ make && \ diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index 102f457d..f1120595 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -19,27 +19,33 @@ void errp(const char *fmt, ...) va_end(va); } -extern int shOpen(struct tcmu_device *dev); -extern void shClose(struct tcmu_device *dev); +extern bool devCheckConfig(const char *cfgString, char **reason); +extern int devOpen(struct tcmu_device *dev); +extern void devClose(struct tcmu_device *dev); -int sh_open_cgo(struct tcmu_device *dev) { - return shOpen(dev); +int dev_open_cgo(struct tcmu_device *dev) { + return devOpen(dev); } -void sh_close_cgo(struct tcmu_device *dev) { - shClose(dev); +void dev_close_cgo(struct tcmu_device *dev) { + devClose(dev); } -static struct tcmulib_handler sh_handler = { +bool dev_check_config_cgo(const char *cfgString, char **reason) { + return devCheckConfig(cfgString, reason); +} + +static struct tcmulib_handler lh_handler = { .name = "Longhorn TCMU handler", .subtype = "longhorn", .cfg_desc = "dev_config=longhorn//", - .added = sh_open_cgo, - .removed = sh_close_cgo, + .added = dev_open_cgo, + .removed = dev_close_cgo, + .check_config = dev_check_config_cgo, }; struct tcmulib_context *tcmu_init() { - return tcmulib_initialize(&sh_handler, 1, errp); + return tcmulib_initialize(&lh_handler, 1, errp); } bool tcmu_poll_master_fd(struct tcmulib_context *cxt) { diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index 5d60f1a5..4d7c3be8 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -44,8 +44,8 @@ type State struct { backend types.ReaderWriterAt } -//export shOpen -func shOpen(dev Device) int { +//export devOpen +func devOpen(dev Device) int { state := &State{ backend: backend, } @@ -80,7 +80,7 @@ func shOpen(dev Device) int { go state.HandleRequest(dev) - log.Debugf("Device %s added", state.volume) + log.Infof("Device %s added", state.volume) return 0 } @@ -175,9 +175,40 @@ func (s *State) handleCommand(dev Device, cmd Command) int { return C.TCMU_NOT_HANDLED } -//export shClose -func shClose(dev Device) { - log.Debugln("Device removed") +//export devClose +func devClose(dev Device) { + cfgString := C.GoString(C.tcmu_get_dev_cfgstring(dev)) + if cfgString == "" { + log.Errorln("Cannot find configuration string") + return + } + + id := strings.TrimPrefix(cfgString, "longhorn//") + if id != volume { + //Ignore close other devs + return + } + log.Infof("Device %s removed", volume) +} + +//export devCheckConfig +func devCheckConfig(cfg *C.char, reason **C.char) bool { + cfgString := C.GoString(cfg) + if cfgString == "" { + // Don't want deal with free or cause memory leak, so ignore + // reason + log.Errorln("Cannot find valid configuration string") + return false + } + + id := strings.TrimPrefix(cfgString, "longhorn//") + if id != volume { + //it's for others + *reason = C.CString("Not current volume") + log.Debugf("%s is not my volume", id) + return false + } + return true } func start(name string, rw types.ReaderWriterAt) error { From e6effc2feceb2c0bc01fd3dce07f04ada275f781 Mon Sep 17 00:00:00 2001 From: kirill Date: Fri, 3 Jun 2016 13:36:56 -0700 Subject: [PATCH 086/357] Revert "controller: removed replica ping logic" This reverts commit 42d2ee57f057d678b6f02e7b5a4239455d449f38. --- app/replica.go | 11 ++++++-- backend/remote/remote.go | 59 ++++++++++++++++++++++++++++++++++++++-- replica/rest/router.go | 4 +++ 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/app/replica.go b/app/replica.go index 7aea9a1d..fced7bf3 100644 --- a/app/replica.go +++ b/app/replica.go @@ -83,9 +83,16 @@ func startReplica(c *cli.Context) error { go func() { server := rest.NewServer(s) router := http.Handler(rest.NewRouter(server)) - router = handlers.LoggingHandler(os.Stdout, router) + loggingHander := handlers.LoggingHandler(os.Stdout, router) + wrappedRouter := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if req.URL.Path == "/ping" { + router.ServeHTTP(rw, req) + } else { + loggingHander.ServeHTTP(rw, req) + } + }) logrus.Infof("Listening on control %s", controlAddress) - resp <- http.ListenAndServe(controlAddress, router) + resp <- http.ListenAndServe(controlAddress, wrappedRouter) }() go func() { diff --git a/backend/remote/remote.go b/backend/remote/remote.go index ee84953a..9f374c5d 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -3,6 +3,7 @@ package remote import ( "bytes" "encoding/json" + "errors" "fmt" "io" "net" @@ -18,7 +19,11 @@ import ( ) var ( - timeout = 30 * time.Second + pingTimeout = 3 * time.Second + pingInveral = 2 * time.Second + timeout = 30 * time.Second + requestBuffer = 1024 + ErrPingTimeout = errors.New("Ping timeout") ) func New() types.BackendFactory { @@ -31,11 +36,14 @@ type Factory struct { type Remote struct { types.ReaderWriterAt name string + pingURL string replicaURL string httpClient *http.Client + closeChan chan struct{} } func (r *Remote) Close() error { + r.closeChan <- struct{}{} logrus.Infof("Closing: %s", r.name) return r.doAction("close", "") } @@ -130,9 +138,11 @@ func (rf *Factory) Create(address string) (types.Backend, error) { r := &Remote{ name: address, replicaURL: fmt.Sprintf("http://%s/v1/replicas/1", controlAddress), + pingURL: fmt.Sprintf("http://%s/ping", controlAddress), httpClient: &http.Client{ Timeout: timeout, }, + closeChan: make(chan struct{}, 1), } replica, err := r.info() @@ -149,11 +159,56 @@ func (rf *Factory) Create(address string) (types.Backend, error) { return nil, err } - r.ReaderWriterAt = rpc.NewClient(conn) + rpc := rpc.NewClient(conn) + r.ReaderWriterAt = rpc if err := r.open(); err != nil { return nil, err } + go r.monitorPing(rpc) + return r, nil } + +func (r *Remote) monitorPing(client *rpc.Client) error { + ticker := time.NewTicker(pingInveral) + defer ticker.Stop() + + for { + select { + case <-r.closeChan: + return nil + case <-ticker.C: + if err := r.Ping(); err != nil { + logrus.Errorf("Failed to get ping response: %v", err) + client.SetError(err) + return err + } + } + } +} + +func (r *Remote) Ping() error { + ret := make(chan error, 1) + go func() { + resp, err := r.httpClient.Get(r.pingURL) + if err != nil { + ret <- err + return + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + ret <- fmt.Errorf("Non-200 response %d from ping to %s", resp.StatusCode, r.name) + return + } + ret <- nil + }() + + select { + case err := <-ret: + return err + case <-time.After(pingTimeout): + return ErrPingTimeout + } +} diff --git a/replica/rest/router.go b/replica/rest/router.go index 24840c85..190911ac 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -33,6 +33,10 @@ func NewRouter(s *Server) *mux.Router { router := mux.NewRouter().StrictSlash(true) f := HandleError + router.Methods("GET").Path("/ping").Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + rw.Write([]byte("pong")) + })) + // API framework routes router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) From f137bc8f91978aa0317efa798efaf02deb984f9e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 3 Jun 2016 23:13:09 -0700 Subject: [PATCH 087/357] tcmu: Fix build (#125) --- Dockerfile.dapper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 915f0223..856cc100 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -44,9 +44,9 @@ RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/ # Build TCMU RUN cd /usr/src && \ - git clone https://github.com/yasker/tcmu-runner.git && \ + git clone https://github.com/agrover/tcmu-runner.git && \ cd tcmu-runner && \ - git checkout 8a72eaefada2ad939eff5ac5628c8fdea8f69a19 + git checkout 2c5b9bbf131c2c668ffb1cda712157d35c1865ba RUN cd /usr/src/tcmu-runner && \ cmake . -Dwith-glfs=false && \ make && \ From 1582e05bccac0bf3bcd268772b6e227925a3bb46 Mon Sep 17 00:00:00 2001 From: Kirill Date: Sat, 4 Jun 2016 16:38:40 -0700 Subject: [PATCH 088/357] controller: implemented ping retry count (#127) - pingRetries = 6 - retry on any ping error --- backend/remote/remote.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 9f374c5d..bb954c76 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -19,8 +19,10 @@ import ( ) var ( - pingTimeout = 3 * time.Second - pingInveral = 2 * time.Second + pingRetries = 6 + pingTimeout = 3 * time.Second + pingInveral = 2 * time.Second + timeout = 30 * time.Second requestBuffer = 1024 ErrPingTimeout = errors.New("Ping timeout") @@ -175,15 +177,23 @@ func (r *Remote) monitorPing(client *rpc.Client) error { ticker := time.NewTicker(pingInveral) defer ticker.Stop() + retry := 0 for { select { case <-r.closeChan: return nil case <-ticker.C: - if err := r.Ping(); err != nil { - logrus.Errorf("Failed to get ping response: %v", err) - client.SetError(err) - return err + if err := r.Ping(); err == nil { + retry = 0 // reset on success + } else { + if retry < pingRetries { + retry++ + logrus.Errorf("Ping retry %v on error: %v", retry, err) + } else { + logrus.Errorf("Failed to get ping response: %v", err) + client.SetError(err) + return err + } } } } From 86f29ca75c6433d440c3a674e9c57c6a6449880b Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 6 Jun 2016 23:59:54 -0700 Subject: [PATCH 089/357] Add rest frontend To provide another way to read/write data, so we can validate it through the integration tests --- app/controller_rest.go | 9 +++ frontend/rest/frontend.go | 61 ++++++++++++++++++++ frontend/rest/model.go | 109 +++++++++++++++++++++++++++++++++++ frontend/rest/router.go | 38 ++++++++++++ frontend/rest/server.go | 118 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 335 insertions(+) create mode 100644 app/controller_rest.go create mode 100644 frontend/rest/frontend.go create mode 100644 frontend/rest/model.go create mode 100644 frontend/rest/router.go create mode 100644 frontend/rest/server.go diff --git a/app/controller_rest.go b/app/controller_rest.go new file mode 100644 index 00000000..03a3b420 --- /dev/null +++ b/app/controller_rest.go @@ -0,0 +1,9 @@ +package app + +import ( + "github.com/rancher/longhorn/frontend/rest" +) + +func init() { + frontends["rest"] = rest.New() +} diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go new file mode 100644 index 00000000..d6d2e43a --- /dev/null +++ b/frontend/rest/frontend.go @@ -0,0 +1,61 @@ +package rest + +import ( + "net/http" + "os" + + "github.com/Sirupsen/logrus" + "github.com/gorilla/handlers" + "github.com/rancher/longhorn/types" +) + +var ( + log = logrus.WithFields(logrus.Fields{"pkg": "rest-frontend"}) +) + +type Device struct { + Name string + Size int64 + SectorSize int64 + backend types.ReaderWriterAt +} + +func New() types.Frontend { + return &Device{} +} + +func (d *Device) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { + d.Name = name + d.backend = rw + d.Size = size + d.SectorSize = sectorSize + + if err := d.start(); err != nil { + return err + } + + return nil +} + +func (d *Device) Shutdown() error { + return d.stop() +} + +func (d *Device) start() error { + listen := "localhost:9414" + server := NewServer(d) + router := http.Handler(NewRouter(server)) + router = handlers.LoggingHandler(os.Stdout, router) + router = handlers.ProxyHeaders(router) + + log.Infof("Rest Frontend listening on %s", listen) + + go func() { + http.ListenAndServe(listen, router) + }() + return nil +} + +func (d *Device) stop() error { + return nil +} diff --git a/frontend/rest/model.go b/frontend/rest/model.go new file mode 100644 index 00000000..3655c830 --- /dev/null +++ b/frontend/rest/model.go @@ -0,0 +1,109 @@ +package rest + +import ( + "encoding/base64" + + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +type Volume struct { + client.Resource + Name string `json:"name"` +} + +type ReadInput struct { + client.Resource + Offset int64 `json:"offset"` + Length int64 `json:"length"` +} + +type ReadOutput struct { + client.Resource + Data string `json:"data"` +} + +type WriteInput struct { + client.Resource + Offset int64 `json:"offset"` + Length int `json:"length"` + Data string `json:"data"` +} + +type WriteOutput struct { + client.Resource +} + +func NewVolume(context *api.ApiContext, name string) *Volume { + v := &Volume{ + Resource: client.Resource{ + Id: EncodeID(name), + Type: "volume", + Actions: map[string]string{}, + }, + Name: name, + } + + v.Actions["read"] = context.UrlBuilder.ActionLink(v.Resource, "read") + v.Actions["write"] = context.UrlBuilder.ActionLink(v.Resource, "write") + return v +} + +func DecodeID(id string) (string, error) { + b, err := DecodeData(id) + if err != nil { + return "", err + } + return string(b), nil +} + +func EncodeID(id string) string { + return EncodeData([]byte(id)) +} +func DecodeData(data string) ([]byte, error) { + b, err := base64.StdEncoding.DecodeString(data) + if err != nil { + return nil, err + } + return b, nil +} + +func EncodeData(data []byte) string { + return base64.StdEncoding.EncodeToString(data) +} + +func NewSchema() *client.Schemas { + schemas := &client.Schemas{} + + schemas.AddType("error", client.ServerApiError{}) + schemas.AddType("apiVersion", client.Resource{}) + schemas.AddType("schema", client.Schema{}) + schemas.AddType("readInput", ReadInput{}) + schemas.AddType("readOutput", ReadOutput{}) + schemas.AddType("writeInput", WriteInput{}) + schemas.AddType("writeOutput", WriteOutput{}) + + volumes := schemas.AddType("volume", Volume{}) + volumes.ResourceActions = map[string]client.Action{ + "read": client.Action{ + Input: "readInput", + Output: "readOutput", + }, + "write": client.Action{ + Input: "writeInput", + Output: "writeOutput", + }, + } + + return schemas +} + +type Server struct { + d *Device +} + +func NewServer(d *Device) *Server { + return &Server{ + d: d, + } +} diff --git a/frontend/rest/router.go b/frontend/rest/router.go new file mode 100644 index 00000000..e76868ed --- /dev/null +++ b/frontend/rest/router.go @@ -0,0 +1,38 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { + return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if err := t(rw, req); err != nil { + apiContext := api.GetApiContext(req) + apiContext.WriteErr(err) + } + })) +} + +func NewRouter(s *Server) *mux.Router { + schemas := NewSchema() + router := mux.NewRouter().StrictSlash(true) + f := HandleError + + // API framework routes + router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) + router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) + router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) + router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + + // Volume + router.Methods("GET").Path("/v1/volumes").Handler(f(schemas, s.ListVolumes)) + router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "read").Handler(f(schemas, s.ReadAt)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "write").Handler(f(schemas, s.WriteAt)) + + return router +} diff --git a/frontend/rest/server.go b/frontend/rest/server.go new file mode 100644 index 00000000..5a64dadc --- /dev/null +++ b/frontend/rest/server.go @@ -0,0 +1,118 @@ +package rest + +import ( + "fmt" + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func (s *Server) ListVolumes(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + apiContext.Write(&client.GenericCollection{ + Data: []interface{}{ + s.listVolumes(apiContext)[0], + }, + }) + return nil +} + +func (s *Server) GetVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + apiContext.Write(v) + return nil +} + +func (s *Server) ReadAt(rw http.ResponseWriter, req *http.Request) error { + var input ReadInput + + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + if err := apiContext.Read(&input); err != nil { + return err + } + + buf := make([]byte, input.Length) + _, err := s.d.backend.ReadAt(buf, input.Offset) + if err != nil { + log.Errorln("read failed: ", err.Error()) + return fmt.Errorf("read failed: %v", err.Error()) + } + + data := EncodeData(buf) + apiContext.Write(&ReadOutput{ + Resource: client.Resource{ + Type: "readOutput", + }, + Data: data, + }) + return nil +} + +func (s *Server) WriteAt(rw http.ResponseWriter, req *http.Request) error { + var input WriteInput + + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + if err := apiContext.Read(&input); err != nil { + return err + } + + buf, err := DecodeData(input.Data) + if err != nil { + return err + } + if len(buf) != input.Length { + return fmt.Errorf("Inconsistent length in request") + } + + if _, err := s.d.backend.WriteAt(buf, input.Offset); err != nil { + log.Errorln("write failed: ", err.Error()) + return err + } + apiContext.Write(&WriteOutput{ + Resource: client.Resource{ + Type: "writeOutput", + }, + }) + return nil +} + +func (s *Server) listVolumes(context *api.ApiContext) []*Volume { + return []*Volume{ + NewVolume(context, s.d.Name), + } +} + +func (s *Server) getVolume(context *api.ApiContext, id string) *Volume { + for _, v := range s.listVolumes(context) { + if v.Id == id { + return v + } + } + return nil +} From 1ef6eb8941fa85e25c1c8c81da056713e1748619 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 6 Jun 2016 23:59:55 -0700 Subject: [PATCH 090/357] integration test: Add restdev for end-to-end data path test_basic_ops.py shows how to use the API --- integration/data/cmd.py | 53 +++++++++++ integration/data/common.py | 140 +++++++++++++++++++++++++++++ integration/data/test_backup.py | 62 +++++++++++++ integration/data/test_basic_ops.py | 33 +++++++ integration/data/test_snapshot.py | 68 ++++++++++++++ integration/setup.py | 1 + integration/tox.ini | 4 +- scripts/integration-test | 2 +- 8 files changed, 360 insertions(+), 3 deletions(-) create mode 100644 integration/data/cmd.py create mode 100644 integration/data/common.py create mode 100644 integration/data/test_backup.py create mode 100644 integration/data/test_basic_ops.py create mode 100644 integration/data/test_snapshot.py diff --git a/integration/data/cmd.py b/integration/data/cmd.py new file mode 100644 index 00000000..16a34d80 --- /dev/null +++ b/integration/data/cmd.py @@ -0,0 +1,53 @@ +import subprocess +from os import path + +import pytest + + +def _file(f): + return path.join(_base(), '../../{}'.format(f)) + + +def _base(): + return path.dirname(__file__) + + +def _bin(): + c = _file('bin/longhorn') + assert path.exists(c) + return c + + +def snapshot_create(): + cmd = [_bin(), '--debug', 'snapshot', 'create'] + return subprocess.check_output(cmd).strip() + + +def snapshot_rm(name): + cmd = [_bin(), '--debug', 'snapshot', 'rm', name] + subprocess.check_call(cmd) + + +def snapshot_revert(name): + cmd = [_bin(), '--debug', 'snapshot', 'revert', name] + subprocess.check_call(cmd) + + +def snapshot_ls(): + cmd = [_bin(), '--debug', 'snapshot', 'ls'] + return subprocess.check_output(cmd) + + +def backup_create(snapshot, dest): + cmd = [_bin(), '--debug', 'backup', 'create', snapshot, '--dest', dest] + return subprocess.check_output(cmd).strip() + + +def backup_rm(backup): + cmd = [_bin(), '--debug', 'backup', 'rm', backup] + return subprocess.check_call(cmd) + + +def backup_restore(backup): + cmd = [_bin(), '--debug', 'backup', 'restore', backup] + return subprocess.check_output(cmd).strip() diff --git a/integration/data/common.py b/integration/data/common.py new file mode 100644 index 00000000..854d28af --- /dev/null +++ b/integration/data/common.py @@ -0,0 +1,140 @@ +import random +import string +import base64 +import subprocess + +import os +from os import path + +import pytest +import cattle + +REPLICA = 'tcp://localhost:9502' +REPLICA2 = 'tcp://localhost:9505' + +SIZE = 1024 * 4096 + +BACKUP_DEST = '/tmp/longhorn-backup' + + +@pytest.fixture() +def dev(request): + controller = controller_client(request) + replica = replica_client(request) + replica2 = replica2_client(request) + + open_replica(replica) + open_replica(replica2) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2 + ]) + assert v.replicaCount == 2 + d = get_restdev() + + return d + + +def controller_client(request): + url = 'http://localhost:9501/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup_controller(c)) + c = cleanup_controller(c) + assert c.list_volume()[0].replicaCount == 0 + return c + + +def cleanup_controller(client): + for r in client.list_replica(): + client.delete(r) + return client + + +def replica_client(request): + url = 'http://localhost:9502/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup_replica(c)) + return cleanup_replica(c) + + +def replica2_client(request): + url = 'http://localhost:9505/v1/schemas' + c = cattle.from_env(url=url) + request.addfinalizer(lambda: cleanup_replica(c)) + return cleanup_replica(c) + + +def cleanup_replica(client): + r = client.list_replica()[0] + if r.state == 'initial': + return client + if 'open' in r: + r = r.open() + client.delete(r) + r = client.reload(r) + assert r.state == 'initial' + return client + + +def open_replica(client, backing_file = None): + replicas = client.list_replica() + assert len(replicas) == 1 + + r = replicas[0] + assert r.state == 'initial' + assert r.size == '0' + assert r.sectorSize == 0 + assert r.parent == '' + assert r.head == '' + + r = r.create(size=str(1024 * 4096)) + + assert r.state == 'closed' + assert r.size == str(1024 * 4096) + assert r.sectorSize == 512 + assert r.parent == '' + assert r.head == 'volume-head-000.img' + + return r + + +def get_restdev(): + url = 'http://localhost:9414/v1/schemas' + c = cattle.from_env(url=url) + dev = c.list_volume()[0] + assert dev.name == "test-volume" + return dev + + +def write_dev(dev, offset, data): + l = len(data) + encoded_data = base64.encodestring(data) + dev.write(offset=offset, length=l, data=encoded_data) + + +def read_dev(dev, offset, length): + data = dev.read(offset=offset, length=length)["data"] + return base64.decodestring(data) + + +def random_string(length): + return ''.join(random.choice(string.lowercase) for x in range(length)) + + +def verify_data(dev, offset, data): + write_dev(dev, offset, data) + readed = read_dev(dev, offset, len(data)) + assert data == readed + + +def prepare_backup_dir(backup_dir): + if os.path.exists(backup_dir): + subprocess.check_call(["rm", "-rf", backup_dir]) + + os.makedirs(backup_dir) + assert os.path.exists(backup_dir) diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py new file mode 100644 index 00000000..02f16bd8 --- /dev/null +++ b/integration/data/test_backup.py @@ -0,0 +1,62 @@ +import subprocess + +import pytest + +import cmd +import common +from common import dev, SIZE, read_dev, write_dev + + +BACKUP_DIR = '/tmp/longhorn-backup' +BACKUP_DEST = 'vfs://' + BACKUP_DIR + + +def setup_module(): + common.prepare_backup_dir(BACKUP_DIR) + + +def test_backup_create_rm_restore(dev): + offset = 0 + length = 128 + + snap1_data = common.random_string(length) + common.verify_data(dev, offset, snap1_data) + snap1 = cmd.snapshot_create() + + backup1 = cmd.backup_create(snap1, BACKUP_DEST) + + snap2_data = common.random_string(length) + common.verify_data(dev, offset, snap2_data) + snap2 = cmd.snapshot_create() + + backup2 = cmd.backup_create(snap2, BACKUP_DEST) + + snap3_data = common.random_string(length) + common.verify_data(dev, offset, snap3_data) + snap3 = cmd.snapshot_create() + + backup3 = cmd.backup_create(snap3, BACKUP_DEST) + + res3 = cmd.backup_restore(backup3) + readed = read_dev(dev, offset, length) + assert readed == snap3_data + + cmd.backup_rm(backup3) + with pytest.raises(subprocess.CalledProcessError): + cmd.backup_restore(backup3) + + res1 = cmd.backup_restore(backup1) + readed = read_dev(dev, offset, length) + assert readed == snap1_data + + cmd.backup_rm(backup1) + with pytest.raises(subprocess.CalledProcessError): + cmd.backup_restore(backup1) + + res2 = cmd.backup_restore(backup2) + readed = read_dev(dev, offset, length) + assert readed == snap2_data + + cmd.backup_rm(backup2) + with pytest.raises(subprocess.CalledProcessError): + cmd.backup_restore(backup2) diff --git a/integration/data/test_basic_ops.py b/integration/data/test_basic_ops.py new file mode 100644 index 00000000..2117e1a6 --- /dev/null +++ b/integration/data/test_basic_ops.py @@ -0,0 +1,33 @@ +import random + +import pytest +import cattle + +import cmd +import common +from common import dev, SIZE, read_dev, write_dev + + +def test_basic_rw(dev): + for i in range(0, 10): + offset = random.randint(0, SIZE - 256) + length = random.randint(0, 256) + data = common.random_string(length) + common.verify_data(dev, offset, data) + + +# TODO BUG: https://github.com/rancher/longhorn/issues/131 +@pytest.mark.xfail(strict=True) +def test_beyond_bounary(dev): + with pytest.raises(cattle.ApiError) as err: + write_dev(dev, SIZE, "1") + assert 'EOF' in str(err.value) + with pytest.raises(cattle.ApiError) as err: + r = read_dev(dev, SIZE, 1) + assert 'EOF' in str(err.value) + + for i in range(0, 10): + offset = random.randint(0, SIZE - 256) + length = random.randint(0, 256) + data = common.random_string(length) + common.verify_data(dev, offset, data) diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py new file mode 100644 index 00000000..44212c97 --- /dev/null +++ b/integration/data/test_snapshot.py @@ -0,0 +1,68 @@ +import pytest + +import cmd +import common +from common import dev, SIZE, read_dev, write_dev + + +def test_snapshot_revert(dev): + offset = 0 + length = 128 + + snap1_data = common.random_string(length) + common.verify_data(dev, offset, snap1_data) + snap1 = cmd.snapshot_create() + + snap2_data = common.random_string(length) + common.verify_data(dev, offset, snap2_data) + snap2 = cmd.snapshot_create() + + snap3_data = common.random_string(length) + common.verify_data(dev, offset, snap3_data) + snap3 = cmd.snapshot_create() + + snapList = cmd.snapshot_ls() + assert snap1 in snapList + assert snap2 in snapList + assert snap3 in snapList + + cmd.snapshot_revert(snap2) + readed = read_dev(dev, offset, length) + assert readed == snap2_data + + cmd.snapshot_revert(snap1) + readed = read_dev(dev, offset, length) + assert readed == snap1_data + + +# TODO BUG: https://github.com/rancher/longhorn/issues/108 +@pytest.mark.xfail(strict=True) +def test_snapshot_rm(dev): + offset = 0 + length = 128 + + snap1_data = common.random_string(length) + common.verify_data(dev, offset, snap1_data) + snap1 = cmd.snapshot_create() + + snap2_data = common.random_string(length) + common.verify_data(dev, offset, snap2_data) + snap2 = cmd.snapshot_create() + + snap3_data = common.random_string(length) + common.verify_data(dev, offset, snap3_data) + snap3 = cmd.snapshot_create() + + snapList = cmd.snapshot_ls() + assert snap1 in snapList + assert snap2 in snapList + assert snap3 in snapList + + cmd.snapshot_rm(snap2) + + readed = read_dev(dev, offset, length) + assert readed == snap3_data + + cmd.snapshot_revert(snap1) + readed = read_dev(dev, offset, length) + assert readed == snap1_data diff --git a/integration/setup.py b/integration/setup.py index 3eed846a..fd7d0aa3 100644 --- a/integration/setup.py +++ b/integration/setup.py @@ -5,6 +5,7 @@ version='0.1', packages=[ 'core', + 'data', ], license='ASL 2.0', ) diff --git a/integration/tox.ini b/integration/tox.ini index 93f705f7..69fd8b6f 100644 --- a/integration/tox.ini +++ b/integration/tox.ini @@ -3,8 +3,8 @@ envlist=flake8, py27 [testenv] deps=-rrequirements.txt -changedir=core -commands=py.test --durations=20 {posargs} +changedir={toxinidir} +commands=py.test core data --durations=20 {posargs} [testenv:flake8] deps=-rrequirements.txt diff --git a/scripts/integration-test b/scripts/integration-test index 81540040..129cb90b 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -13,7 +13,7 @@ if [ ! -x ./bin/longhorn ]; then ./scripts/build fi -./bin/longhorn controller --enable-backend file test-volume & +./bin/longhorn controller --frontend rest --enable-backend file test-volume & ./bin/longhorn replica $temp & ./bin/longhorn replica --listen localhost:9505 $temp2 & cd integration From 9a242b6625497d071c106fce15a33d4c368da165 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 6 Jun 2016 23:59:55 -0700 Subject: [PATCH 091/357] integration: add backing file test --- Dockerfile.dapper | 3 +- integration/data/common.py | 74 ++++++++++++++++++++++++------- integration/data/test_backup.py | 40 ++++++++++++----- integration/data/test_snapshot.py | 23 +++++++++- scripts/integration-test | 18 +++++++- 5 files changed, 130 insertions(+), 28 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 856cc100..ab41d6e6 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -23,7 +23,8 @@ RUN apt-get update && \ linux-libc-dev \ pkg-config \ psmisc \ - python-tox + python-tox \ + qemu-utils # Install Go 1.6 RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz diff --git a/integration/data/common.py b/integration/data/common.py index 854d28af..43de5a4c 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -9,19 +9,37 @@ import pytest import cattle -REPLICA = 'tcp://localhost:9502' +REPLICA1 = 'tcp://localhost:9502' +REPLICA1_SCHEMA = 'http://localhost:9502/v1/schemas' REPLICA2 = 'tcp://localhost:9505' +REPLICA2_SCHEMA = 'http://localhost:9505/v1/schemas' + +BACKED_REPLICA1 = 'tcp://localhost:9602' +BACKED_REPLICA1_SCHEMA = 'http://localhost:9602/v1/schemas' +BACKED_REPLICA2 = 'tcp://localhost:9605' +BACKED_REPLICA2_SCHEMA = 'http://localhost:9605/v1/schemas' SIZE = 1024 * 4096 -BACKUP_DEST = '/tmp/longhorn-backup' +BACKUP_DIR = '/tmp/longhorn-backup' +BACKUP_DEST = 'vfs://' + BACKUP_DIR + +BACKING_FILE = 'backing_file.raw' + + +def _file(f): + return path.join(_base(), '../../{}'.format(f)) + + +def _base(): + return path.dirname(__file__) @pytest.fixture() def dev(request): controller = controller_client(request) - replica = replica_client(request) - replica2 = replica2_client(request) + replica = replica_client(request, REPLICA1_SCHEMA) + replica2 = replica_client(request, REPLICA2_SCHEMA) open_replica(replica) open_replica(replica2) @@ -31,7 +49,7 @@ def dev(request): v = controller.list_volume()[0] v = v.start(replicas=[ - REPLICA, + REPLICA1, REPLICA2 ]) assert v.replicaCount == 2 @@ -40,6 +58,30 @@ def dev(request): return d +@pytest.fixture() +def backing_dev(request): + prepare_backup_dir(BACKUP_DIR) + controller = controller_client(request) + replica = replica_client(request, BACKED_REPLICA1_SCHEMA) + replica2 = replica_client(request, BACKED_REPLICA2_SCHEMA) + + open_replica(replica) + open_replica(replica2) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + v = v.start(replicas=[ + BACKED_REPLICA1, + BACKED_REPLICA2 + ]) + assert v.replicaCount == 2 + d = get_restdev() + + return d + + def controller_client(request): url = 'http://localhost:9501/v1/schemas' c = cattle.from_env(url=url) @@ -55,15 +97,7 @@ def cleanup_controller(client): return client -def replica_client(request): - url = 'http://localhost:9502/v1/schemas' - c = cattle.from_env(url=url) - request.addfinalizer(lambda: cleanup_replica(c)) - return cleanup_replica(c) - - -def replica2_client(request): - url = 'http://localhost:9505/v1/schemas' +def replica_client(request, url): c = cattle.from_env(url=url) request.addfinalizer(lambda: cleanup_replica(c)) return cleanup_replica(c) @@ -81,7 +115,7 @@ def cleanup_replica(client): return client -def open_replica(client, backing_file = None): +def open_replica(client, backing_file=None): replicas = client.list_replica() assert len(replicas) == 1 @@ -138,3 +172,13 @@ def prepare_backup_dir(backup_dir): os.makedirs(backup_dir) assert os.path.exists(backup_dir) + + +def read_from_backing_file(offset, length): + p = _file(BACKING_FILE) + assert path.exists(p) + f = open(p, 'r') + f.seek(offset) + data = f.read(length) + f.close() + return data diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index 02f16bd8..451a76d3 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -4,18 +4,11 @@ import cmd import common -from common import dev, SIZE, read_dev, write_dev +from common import dev, backing_dev, read_dev, write_dev, \ + read_from_backing_file, BACKUP_DEST -BACKUP_DIR = '/tmp/longhorn-backup' -BACKUP_DEST = 'vfs://' + BACKUP_DIR - - -def setup_module(): - common.prepare_backup_dir(BACKUP_DIR) - - -def test_backup_create_rm_restore(dev): +def test_backup(dev): offset = 0 length = 128 @@ -60,3 +53,30 @@ def test_backup_create_rm_restore(dev): cmd.backup_rm(backup2) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup2) + + +def test_backup_with_backing_file(backing_dev): + dev = backing_dev + + offset = 0 + length = 256 + + snap0 = cmd.snapshot_create() + before = read_dev(dev, offset, length) + assert before != "" + + exists = read_from_backing_file(offset, length) + assert before == exists + + backup0 = cmd.backup_create(snap0, BACKUP_DEST) + + test_backup(dev) + + res0 = cmd.backup_restore(backup0) + after = read_dev(dev, offset, length) + assert before == after + + cmd.backup_rm(backup0) + with pytest.raises(subprocess.CalledProcessError): + cmd.backup_restore(backup0) + diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index 44212c97..93baccac 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -2,7 +2,8 @@ import cmd import common -from common import dev, SIZE, read_dev, write_dev +from common import dev, backing_dev, read_dev, write_dev, \ + read_from_backing_file def test_snapshot_revert(dev): @@ -66,3 +67,23 @@ def test_snapshot_rm(dev): cmd.snapshot_revert(snap1) readed = read_dev(dev, offset, length) assert readed == snap1_data + + +def test_snapshot_revert_with_backing_file(backing_dev): + dev = backing_dev + + offset = 0 + length = 256 + + snap0 = cmd.snapshot_create() + before = read_dev(dev, offset, length) + assert before != "" + + exists = read_from_backing_file(offset, length) + assert before == exists + + test_snapshot_revert(dev) + + cmd.snapshot_revert(snap0) + after = read_dev(dev, offset, length) + assert before == after diff --git a/scripts/integration-test b/scripts/integration-test index 129cb90b..e6d46133 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -5,7 +5,9 @@ killall longhorn ssync || true temp=$(mktemp -d) temp2=$(mktemp -d) -trap "rm -rf $temp $temp2" EXIT +temp3=$(mktemp -d) +temp4=$(mktemp -d) +trap "rm -rf $temp $temp2 $temp3 $temp4" EXIT cd $(dirname $0)/.. @@ -16,6 +18,20 @@ fi ./bin/longhorn controller --frontend rest --enable-backend file test-volume & ./bin/longhorn replica $temp & ./bin/longhorn replica --listen localhost:9505 $temp2 & + +# replica with 4MB backing file +backing_file=backing_file.raw +backing_qcow2=backing_file.qcow2 +cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $((1024 * 4096)) | head -n 1 > $backing_file +truncate -s 4M $backing_file + +qemu-img convert -f raw -O qcow2 $backing_file $backing_qcow2 +cp $backing_qcow2 $temp3 +cp $backing_qcow2 $temp4 + +./bin/longhorn replica --listen localhost:9602 --backing-file $backing_qcow2 $temp3 & +./bin/longhorn replica --listen localhost:9605 --backing-file $backing_qcow2 $temp4 & + cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; if [ -z "$NO_TEST" ]; then From 4318c56c605fd130121aac0944e3efca28df8b48 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 7 Jun 2016 10:55:21 -0700 Subject: [PATCH 092/357] integration: Fix flake8 --- integration/data/cmd.py | 2 -- integration/data/test_backup.py | 19 +++++++++---------- integration/data/test_basic_ops.py | 10 +++++----- integration/data/test_snapshot.py | 12 ++++++------ integration/tox.ini | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/integration/data/cmd.py b/integration/data/cmd.py index 16a34d80..69d82589 100644 --- a/integration/data/cmd.py +++ b/integration/data/cmd.py @@ -1,8 +1,6 @@ import subprocess from os import path -import pytest - def _file(f): return path.join(_base(), '../../{}'.format(f)) diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index 451a76d3..b4dd9f19 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -4,11 +4,11 @@ import cmd import common -from common import dev, backing_dev, read_dev, write_dev, \ - read_from_backing_file, BACKUP_DEST +from common import dev, backing_dev # NOQA +from common import read_dev, read_from_backing_file, BACKUP_DEST -def test_backup(dev): +def test_backup(dev): # NOQA offset = 0 length = 128 @@ -30,7 +30,7 @@ def test_backup(dev): backup3 = cmd.backup_create(snap3, BACKUP_DEST) - res3 = cmd.backup_restore(backup3) + cmd.backup_restore(backup3) readed = read_dev(dev, offset, length) assert readed == snap3_data @@ -38,7 +38,7 @@ def test_backup(dev): with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup3) - res1 = cmd.backup_restore(backup1) + cmd.backup_restore(backup1) readed = read_dev(dev, offset, length) assert readed == snap1_data @@ -46,7 +46,7 @@ def test_backup(dev): with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup1) - res2 = cmd.backup_restore(backup2) + cmd.backup_restore(backup2) readed = read_dev(dev, offset, length) assert readed == snap2_data @@ -55,8 +55,8 @@ def test_backup(dev): cmd.backup_restore(backup2) -def test_backup_with_backing_file(backing_dev): - dev = backing_dev +def test_backup_with_backing_file(backing_dev): # NOQA + dev = backing_dev # NOQA offset = 0 length = 256 @@ -72,11 +72,10 @@ def test_backup_with_backing_file(backing_dev): test_backup(dev) - res0 = cmd.backup_restore(backup0) + cmd.backup_restore(backup0) after = read_dev(dev, offset, length) assert before == after cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup0) - diff --git a/integration/data/test_basic_ops.py b/integration/data/test_basic_ops.py index 2117e1a6..bb7e2628 100644 --- a/integration/data/test_basic_ops.py +++ b/integration/data/test_basic_ops.py @@ -3,12 +3,12 @@ import pytest import cattle -import cmd import common -from common import dev, SIZE, read_dev, write_dev +from common import dev # NOQA +from common import SIZE, read_dev, write_dev -def test_basic_rw(dev): +def test_basic_rw(dev): # NOQA for i in range(0, 10): offset = random.randint(0, SIZE - 256) length = random.randint(0, 256) @@ -17,13 +17,13 @@ def test_basic_rw(dev): # TODO BUG: https://github.com/rancher/longhorn/issues/131 -@pytest.mark.xfail(strict=True) +@pytest.mark.xfail(strict=True) # NOQA def test_beyond_bounary(dev): with pytest.raises(cattle.ApiError) as err: write_dev(dev, SIZE, "1") assert 'EOF' in str(err.value) with pytest.raises(cattle.ApiError) as err: - r = read_dev(dev, SIZE, 1) + read_dev(dev, SIZE, 1) assert 'EOF' in str(err.value) for i in range(0, 10): diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index 93baccac..1fab4598 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -2,11 +2,11 @@ import cmd import common -from common import dev, backing_dev, read_dev, write_dev, \ - read_from_backing_file +from common import dev, backing_dev # NOQA +from common import read_dev, read_from_backing_file -def test_snapshot_revert(dev): +def test_snapshot_revert(dev): # NOQA offset = 0 length = 128 @@ -37,7 +37,7 @@ def test_snapshot_revert(dev): # TODO BUG: https://github.com/rancher/longhorn/issues/108 -@pytest.mark.xfail(strict=True) +@pytest.mark.xfail(strict=True) # NOQA def test_snapshot_rm(dev): offset = 0 length = 128 @@ -69,8 +69,8 @@ def test_snapshot_rm(dev): assert readed == snap1_data -def test_snapshot_revert_with_backing_file(backing_dev): - dev = backing_dev +def test_snapshot_revert_with_backing_file(backing_dev): # NOQA + dev = backing_dev # NOQA offset = 0 length = 256 diff --git a/integration/tox.ini b/integration/tox.ini index 69fd8b6f..d28d5d38 100644 --- a/integration/tox.ini +++ b/integration/tox.ini @@ -9,4 +9,4 @@ commands=py.test core data --durations=20 {posargs} [testenv:flake8] deps=-rrequirements.txt changedir={toxinidir} -commands=flake8 core +commands=flake8 core data From 896d2500cc923620baeb2294dc9cd59cbee13d3f Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Thu, 26 May 2016 16:53:14 -0700 Subject: [PATCH 093/357] agent snapshot and backup support Add a rest API to the controller-agent that exposes snapshot and backup functions. --- Dockerfile.dapper | 2 +- agent/controller/controller.go | 1 - agent/controller/rest/backup.go | 279 +++++++++++++++++++++++++ agent/controller/rest/model.go | 111 ++++++++++ agent/controller/rest/router.go | 63 ++++++ agent/controller/rest/snapshot.go | 146 +++++++++++++ agent/controller/rest/volume.go | 81 +++++++ agent/main.go | 28 ++- agent/replica/rest/backuptarget.go | 61 ++++++ agent/replica/rest/model.go | 34 +++ agent/replica/rest/router.go | 39 ++++ app/snapshot.go | 6 +- controller/client/controller_client.go | 27 ++- package/Dockerfile | 2 +- 14 files changed, 873 insertions(+), 7 deletions(-) create mode 100644 agent/controller/rest/backup.go create mode 100644 agent/controller/rest/model.go create mode 100644 agent/controller/rest/router.go create mode 100644 agent/controller/rest/snapshot.go create mode 100644 agent/controller/rest/volume.go create mode 100644 agent/replica/rest/backuptarget.go create mode 100644 agent/replica/rest/model.go create mode 100644 agent/replica/rest/router.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ab41d6e6..ed272455 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout 2316da98aa7a46ae55afeef2499364df83291190 && \ + git checkout cce4790c6391002b948e8cf500460b8efacefdfc && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow diff --git a/agent/controller/controller.go b/agent/controller/controller.go index e745f131..cfca7ca8 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -11,7 +11,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/go-rancher-metadata/metadata" - lclient "github.com/rancher/longhorn/controller/client" "github.com/rancher/longhorn/controller/rest" replicaClient "github.com/rancher/longhorn/replica/client" diff --git a/agent/controller/rest/backup.go b/agent/controller/rest/backup.go new file mode 100644 index 00000000..e0f5445a --- /dev/null +++ b/agent/controller/rest/backup.go @@ -0,0 +1,279 @@ +package rest + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "os" + "os/exec" + "sync" + + "github.com/Sirupsen/logrus" + "github.com/gorilla/mux" + + "github.com/rancher/go-rancher-metadata/metadata" + "github.com/rancher/go-rancher/api" + "github.com/rancher/longhorn/agent/controller" + "github.com/rancher/longhorn/agent/replica/rest" +) + +var restoreMutex = &sync.RWMutex{} +var restoreMap = make(map[string]*status) + +var backupMutex = &sync.RWMutex{} +var backupMap = make(map[string]*status) + +func (s *Server) CreateBackup(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Creating backup") + + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + snapshot, err := s.getSnapshot(apiContext, id) + if err != nil { + return err + } + + if snapshot == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var input backupInput + if err := apiContext.Read(&input); err != nil { + return err + } + + if input.UUID == "" { + rw.WriteHeader(http.StatusBadRequest) + return nil + } + + if err := prepareBackupTarget(input.BackupTarget); err != nil { + return err + } + + destination := fmt.Sprintf("vfs:///var/lib/rancher/longhorn/backups/%v/%v", input.BackupTarget.Name, input.BackupTarget.UUID) + status, err := backup(input.UUID, snapshot.Id, destination) + if err != nil { + return err + } + + return apiContext.WriteResource(status) +} + +func (s *Server) RemoveBackup(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + + var input locationInput + if err := apiContext.Read(&input); err != nil { + return err + } + logrus.Infof("Removing backup %#v", input) + + if input.Location == "" { + rw.WriteHeader(http.StatusBadRequest) + return nil + } + + if err := prepareBackupTarget(input.BackupTarget); err != nil { + return err + } + + exists, err := backupExists(input) + if err != nil { + return fmt.Errorf("Error while determining if backup exists: %v", err) + } + + if !exists { + rw.WriteHeader(http.StatusNoContent) + return nil + } + + cmd := exec.Command("longhorn", "backup", "rm", input.Location) + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + logrus.Infof("Running %v", cmd.Args) + if err := cmd.Run(); err != nil { + return err + } + + rw.WriteHeader(http.StatusNoContent) + return nil +} + +func (s *Server) RestoreFromBackup(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Restoring from backup") + + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + if id != "1" { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var input locationInput + if err := apiContext.Read(&input); err != nil { + return err + } + + if input.Location == "" || input.UUID == "" { + rw.WriteHeader(http.StatusBadRequest) + return nil + } + + if err := prepareBackupTarget(input.BackupTarget); err != nil { + return err + } + + restoreStatus, err := restore(input.UUID, input.Location) + if err != nil { + return err + } + + return apiContext.WriteResource(restoreStatus) +} + +func restore(uuid, location string) (*status, error) { + cmd := exec.Command("longhorn", "backup", "restore", location) + return doStatusBackedCommand(uuid, "restorestatus", cmd, restoreMap, restoreMutex) +} + +func backup(uuid, snapshot, destination string) (*status, error) { + cmd := exec.Command("longhorn", "backup", "create", snapshot, "--dest", destination) + return doStatusBackedCommand(uuid, "backupstatus", cmd, backupMap, backupMutex) +} + +func doStatusBackedCommand(id, resourceType string, command *exec.Cmd, statusMap map[string]*status, statusMutex *sync.RWMutex) (*status, error) { + output := new(bytes.Buffer) + command.Stdout = output + command.Stderr = os.Stderr + err := command.Start() + if err != nil { + return &status{}, err + } + + statusMutex.Lock() + defer statusMutex.Unlock() + status := newStatus(id, "running", "", resourceType) + statusMap[id] = status + + go func(id string, c *exec.Cmd) { + var message string + var state string + + err := c.Wait() + if err != nil { + state = "error" + message = fmt.Sprintf("Error: %v", err) + } else { + state = "done" + message = output.String() + } + + statusMutex.Lock() + defer statusMutex.Unlock() + status, ok := statusMap[id] + if !ok { + status = newStatus(id, "", "", resourceType) + } + + status.State = state + status.Message = message + restoreMap[id] = status + }(id, command) + + return status, nil +} + +func (s *Server) GetBackupStatus(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Getting backup status") + return getStatus(backupMap, backupMutex, rw, req) +} + +func (s *Server) GetRestoreStatus(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Getting restore status") + return getStatus(restoreMap, restoreMutex, rw, req) +} + +func getStatus(statusMap map[string]*status, statusMutex *sync.RWMutex, rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + statusMutex.RLock() + defer statusMutex.RUnlock() + + status, ok := statusMap[id] + if !ok { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + return apiContext.WriteResource(status) +} + +func backupExists(location locationInput) (bool, error) { + // TODO Properly implement once we have a way of knowing if a backup exists + return true, nil +} + +func prepareBackupTarget(target rest.BackupTarget) error { + replicas, err := replicRestEndpoints() + if err != nil { + return fmt.Errorf("Error getting replica endpoints: %v", err) + } + + b, err := json.Marshal(target) + if err != nil { + return err + } + + // This could be optimized with some goroutines and a waitgroup + for _, r := range replicas { + url := r + "/backuptargets" + resp, err := http.Post(url, "application/json", bytes.NewBuffer(b)) + if err != nil { + return err + } + + if resp.StatusCode >= 300 { + content, _ := ioutil.ReadAll(resp.Body) + resp.Body.Close() + return fmt.Errorf("Bad response preparing mount for %v: %v %v - %s", r, resp.StatusCode, resp.Status, content) + } + resp.Body.Close() + } + + return nil +} + +func replicRestEndpoints() ([]string, error) { + client, err := metadata.NewClientAndWait(controller.MetadataURL) + if err != nil { + return nil, err + } + service, err := client.GetSelfServiceByName("replica") + if err != nil { + return nil, err + } + + containers := map[string]metadata.Container{} + for _, container := range service.Containers { + if c, ok := containers[container.Name]; !ok { + containers[container.Name] = container + } else if container.CreateIndex > c.CreateIndex { + containers[container.Name] = container + } + } + + result := []string{} + for _, container := range containers { + endpoint := fmt.Sprintf("http://%s/v1", container.PrimaryIp) + result = append(result, endpoint) + } + + return result, nil +} diff --git a/agent/controller/rest/model.go b/agent/controller/rest/model.go new file mode 100644 index 00000000..16ff3d16 --- /dev/null +++ b/agent/controller/rest/model.go @@ -0,0 +1,111 @@ +package rest + +import ( + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" + rrest "github.com/rancher/longhorn/agent/replica/rest" +) + +type snapshot struct { + client.Resource + Name string `json:"name"` +} + +type snapshotCollection struct { + client.Collection + Data []snapshot `json:"data"` +} + +type status struct { + client.Resource + State string `json:"state,omitempty"` + Message string `json:"message,omitempty"` +} + +type backupInput struct { + UUID string `json:"uuid,omitempty"` + BackupTarget rrest.BackupTarget `json:"backupTarget,omitempty"` +} + +type locationInput struct { + UUID string `json:"uuid,omitempty"` + Location string `json:"location,omitempty"` + BackupTarget rrest.BackupTarget `json:"backupTarget,omitempty"` +} + +type revertInput struct { + Name string `json:"name,omitempty"` +} + +type volume struct { + client.Resource + Name string `json:"name,omitempty"` +} + +func newSnapshot(context *api.ApiContext, name string) *snapshot { + snapshot := &snapshot{ + Resource: client.Resource{ + Id: name, + Type: "snapshot", + Actions: map[string]string{}, + }, + Name: name, + } + + return snapshot +} + +func newStatus(id string, state, message, resourceType string) *status { + return &status{ + Resource: client.Resource{Id: id, Type: resourceType}, + State: state, + Message: message, + } +} + +func newSchema() *client.Schemas { + schemas := &client.Schemas{} + + schemas.AddType("error", client.ServerApiError{}) + schemas.AddType("apiVersion", client.Resource{}) + schemas.AddType("schema", client.Schema{}) + + schemas.AddType("revertToSnapshotInput", revertInput{}) + schemas.AddType("locationInput", locationInput{}) + schemas.AddType("backupInput", backupInput{}) + + volume := schemas.AddType("volume", volume{}) + volume.CollectionMethods = []string{"GET"} + volume.ResourceMethods = []string{"GET"} + volume.ResourceActions = map[string]client.Action{ + "reverttosnapshot": client.Action{ + Input: "revertToSnapshotInput", + Output: "volume", + }, + "restoreFromBackup": client.Action{ + Input: "locationInput", + Output: "restoreStatus", + }, + } + + snapshot := schemas.AddType("snapshot", snapshot{}) + snapshot.CollectionMethods = []string{"GET", "POST"} + snapshot.ResourceMethods = []string{"GET", "PUT", "DELETE"} + snapshot.ResourceActions = map[string]client.Action{ + "backup": client.Action{ + Input: "backupInput", + Output: "backupStatus", + }, + "removeBackup": client.Action{ + Input: "locationInput", + }, + } + + restoreStatus := schemas.AddType("restorestatus", status{}) + restoreStatus.ResourceMethods = []string{"GET"} + + backupStatus := schemas.AddType("backupstatus", status{}) + backupStatus.ResourceMethods = []string{"GET"} + + return schemas +} diff --git a/agent/controller/rest/router.go b/agent/controller/rest/router.go new file mode 100644 index 00000000..1cfed008 --- /dev/null +++ b/agent/controller/rest/router.go @@ -0,0 +1,63 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" + + lclient "github.com/rancher/longhorn/controller/client" +) + +func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { + return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if err := t(rw, req); err != nil { + apiContext := api.GetApiContext(req) + apiContext.WriteErr(err) + } + })) +} + +func NewRouter(s *Server) *mux.Router { + schemas := newSchema() + router := mux.NewRouter().StrictSlash(true) + f := HandleError + + // API framework routes + router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) + router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) + router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) + router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + + // Volume(s) + router.Methods("GET").Path("/v1/volumes").Handler(f(schemas, s.ListVolumes)) + router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "reverttosnapshot").Handler(f(schemas, s.RevertToSnapshot)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "restorefrombackup").Handler(f(schemas, s.RestoreFromBackup)) + + // Snapshots + router.Methods("GET").Path("/v1/snapshots").Handler(f(schemas, s.ListSnapshots)) + router.Methods("GET").Path("/v1/snapshots/{id}").Handler(f(schemas, s.GetSnapshot)) + router.Methods("POST").Path("/v1/snapshots").Handler(f(schemas, s.CreateSnapshot)) + router.Methods("DELETE").Path("/v1/snapshots/{id}").Handler(f(schemas, s.DeleteSnapshot)) + router.Methods("POST").Path("/v1/snapshots/{id}").Queries("action", "backup").Handler(f(schemas, s.CreateBackup)) + router.Methods("POST").Path("/v1/snapshots/{id}").Queries("action", "removebackup").Handler(f(schemas, s.RemoveBackup)) + + // Restore status + router.Methods("GET").Path("/v1/backupstatuses/{id}").Handler(f(schemas, s.GetBackupStatus)) + router.Methods("GET").Path("/v1/restorestatuses/{id}").Handler(f(schemas, s.GetRestoreStatus)) + + return router +} + +type Server struct { + controllerClient *lclient.ControllerClient +} + +func NewServer() *Server { + contollerClient := lclient.NewControllerClient("http://localhost:9501") + return &Server{ + controllerClient: contollerClient, + } +} diff --git a/agent/controller/rest/snapshot.go b/agent/controller/rest/snapshot.go new file mode 100644 index 00000000..9d30ffc9 --- /dev/null +++ b/agent/controller/rest/snapshot.go @@ -0,0 +1,146 @@ +package rest + +import ( + "bufio" + "fmt" + "net/http" + "os" + "os/exec" + + "github.com/gorilla/mux" + + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func (s *Server) ListSnapshots(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + snapshots, err := s.listSnapshot(apiContext) + if err != nil { + return err + } + apiContext.Write(&client.GenericCollection{ + Data: []interface{}{ + snapshots, + }, + }) + return nil +} + +func (s *Server) GetSnapshot(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + vars := mux.Vars(req) + id, ok := vars["id"] + if !ok { + return fmt.Errorf("Snapshot id not supplied.") + } + + snap, err := s.getSnapshot(apiContext, id) + if err != nil { + return err + } + + if snap == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + apiContext.Write(snap) + return nil +} + +func (s *Server) CreateSnapshot(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + var snapshot snapshot + if err := apiContext.Read(&snapshot); err != nil { + return err + } + + name, err := s.controllerClient.Snapshot(snapshot.Name) + if err != nil { + return err + } + + apiContext.Write(newSnapshot(apiContext, name)) + + return nil +} + +func (s *Server) DeleteSnapshot(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + vars := mux.Vars(req) + id, ok := vars["id"] + if !ok { + return fmt.Errorf("Snapshot id not supplied.") + } + + snapshot, err := s.getSnapshot(apiContext, id) + if err != nil { + return err + } + + if snapshot == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + cmd := exec.Command("longhorn", "snapshots", "rm", snapshot.Id) + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + if err := cmd.Run(); err != nil { + return err + } + + rw.WriteHeader(http.StatusNoContent) + return nil +} + +func (s *Server) listSnapshot(context *api.ApiContext) ([]*snapshot, error) { + cmd := exec.Command("longhorn", "snapshots") + cmd.Stderr = os.Stderr + output, err := cmd.StdoutPipe() + if err != nil { + return nil, err + } + + if err := cmd.Start(); err != nil { + return nil, err + } + + scanner := bufio.NewScanner(output) + first := true + snapshots := []*snapshot{} + for scanner.Scan() { + if first { + first = false + continue + } + + name := scanner.Text() + snap := newSnapshot(context, name) + snapshots = append(snapshots, snap) + } + + if err := cmd.Wait(); err != nil { + return nil, err + } + + if err := scanner.Err(); err != nil { + return nil, err + } + + return snapshots, nil +} + +func (s *Server) getSnapshot(context *api.ApiContext, id string) (*snapshot, error) { + snapshots, err := s.listSnapshot(context) + if err != nil { + return nil, err + } + for _, s := range snapshots { + if s.Id == id { + return s, nil + } + } + return nil, nil +} diff --git a/agent/controller/rest/volume.go b/agent/controller/rest/volume.go new file mode 100644 index 00000000..33e88305 --- /dev/null +++ b/agent/controller/rest/volume.go @@ -0,0 +1,81 @@ +package rest + +import ( + "net/http" + + "github.com/Sirupsen/logrus" + "github.com/gorilla/mux" + + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func (s *Server) ListVolumes(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Listing volumes") + + apiContext := api.GetApiContext(req) + + apiContext.Write(&client.GenericCollection{ + Data: []interface{}{ + s.getVolume(apiContext), + }, + }) + return nil +} + +func (s *Server) GetVolume(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Getting volumes") + + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + if id != "1" { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + v := s.getVolume(apiContext) + apiContext.Write(v) + return nil +} + +func (s *Server) RevertToSnapshot(rw http.ResponseWriter, req *http.Request) error { + logrus.Infof("Reverting to snapshot") + + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + if id != "1" { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var input revertInput + if err := apiContext.Read(&input); err != nil { + return err + } + + snap, err := s.getSnapshot(apiContext, input.Name) + if err != nil { + return err + } + + if snap == nil { + rw.WriteHeader(http.StatusBadRequest) + return nil + } + + _, err = s.controllerClient.RevertVolume(snap.Name) + if err != nil { + return err + } + + return s.GetVolume(rw, req) +} + +func (s *Server) getVolume(context *api.ApiContext) *volume { + return &volume{ + Resource: client.Resource{Id: "1"}, + Name: "volume", + } +} diff --git a/agent/main.go b/agent/main.go index c4f021b2..ef3dbfc7 100644 --- a/agent/main.go +++ b/agent/main.go @@ -6,8 +6,11 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/rancher/longhorn/agent/controller" + "github.com/rancher/longhorn/agent/controller/rest" + replica "github.com/rancher/longhorn/agent/replica/rest" "github.com/rancher/longhorn/agent/status" ) @@ -55,18 +58,41 @@ func runApp(context *cli.Context) error { if runController { go runPing(context) + go runControllerAPI(context) c := controller.New() defer c.Close() return c.Start() } else if runReplica { + go runReplicaAPI(context) return runPing(context) } return nil } -func runPing(context *cli.Context) error { +func runControllerAPI(context *cli.Context) { + server := rest.NewServer() + router := http.Handler(rest.NewRouter(server)) + + router = handlers.LoggingHandler(os.Stdout, router) + router = handlers.ProxyHeaders(router) + listen := "0.0.0.0:80" + logrus.Infof("Listening on %s", listen) + err := http.ListenAndServe(listen, router) + logrus.Fatalf("API returned with error: %v", err) +} +func runReplicaAPI(context *cli.Context) { + router := http.Handler(replica.NewRouter()) + router = handlers.LoggingHandler(os.Stdout, router) + router = handlers.ProxyHeaders(router) + listen := "0.0.0.0:80" + logrus.Infof("Listening on %s", listen) + err := http.ListenAndServe(listen, router) + logrus.Fatalf("API returned with error: %v", err) +} + +func runPing(context *cli.Context) error { controller := status.NewControllerStatus() replica, err := status.NewReplicaStatus() diff --git a/agent/replica/rest/backuptarget.go b/agent/replica/rest/backuptarget.go new file mode 100644 index 00000000..9488d17f --- /dev/null +++ b/agent/replica/rest/backuptarget.go @@ -0,0 +1,61 @@ +package rest + +import ( + "fmt" + "net/http" + "os" + "os/exec" + "strconv" + + "github.com/Sirupsen/logrus" + + "github.com/rancher/go-rancher/api" +) + +func (s *server) ConfigureBackupTarget(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + target := &BackupTarget{} + if err := apiContext.Read(target); err != nil { + return err + } + + if err := s.createNFSMount(target); err != nil { + return fmt.Errorf("Unable to create nfs mount for %#v. Error %v", target, err) + } + + return nil +} + +func (s *server) createNFSMount(target *BackupTarget) error { + mountDir := constructMountDir(target) + + grep := exec.Command("grep", mountDir, "/proc/mounts") + if err := grep.Run(); err == nil { + logrus.Infof("Found mount %v.", mountDir) + return nil + } + + if err := os.MkdirAll(mountDir, 0770); err != nil { + return err + } + + remoteTarget := fmt.Sprintf("%v:%v", target.NFSConfig.Server, target.NFSConfig.Share) + parentPid := strconv.Itoa(os.Getppid()) + + var mount *exec.Cmd + if target.NFSConfig.MountOptions == "" { + mount = exec.Command("nsenter", "-t", parentPid, "-n", "mount", "-t", "nfs", remoteTarget, mountDir) + } else { + mount = exec.Command("nsenter", "-t", parentPid, "-n", "mount", "-t", "nfs", "-o", target.NFSConfig.MountOptions, remoteTarget, mountDir) + } + + mount.Stdout = os.Stdout + mount.Stderr = os.Stderr + + logrus.Infof("Running %v", mount.Args) + return mount.Run() +} + +func constructMountDir(target *BackupTarget) string { + return fmt.Sprintf("/var/lib/rancher/longhorn/backups/%s/%s", target.Name, target.UUID) +} diff --git a/agent/replica/rest/model.go b/agent/replica/rest/model.go new file mode 100644 index 00000000..81c7b45b --- /dev/null +++ b/agent/replica/rest/model.go @@ -0,0 +1,34 @@ +package rest + +import ( + "github.com/rancher/go-rancher/client" +) + +type BackupTarget struct { + client.Resource + UUID string `json:"uuid,omitempty"` + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` + NFSConfig NFSConfig `json:"nfsConfig,omitempty"` +} + +type NFSConfig struct { + Server string `json:"server"` + Share string `json:"share"` + MountOptions string `json:"mountOptions"` +} + +func newSchema() *client.Schemas { + schemas := &client.Schemas{} + + schemas.AddType("error", client.ServerApiError{}) + schemas.AddType("apiVersion", client.Resource{}) + schemas.AddType("schema", client.Schema{}) + + target := schemas.AddType("backupTarget", BackupTarget{}) + target.CollectionMethods = []string{"POST", "GET"} + + schemas.AddType("nfsConfig", NFSConfig{}) + + return schemas +} diff --git a/agent/replica/rest/router.go b/agent/replica/rest/router.go new file mode 100644 index 00000000..930a6ef5 --- /dev/null +++ b/agent/replica/rest/router.go @@ -0,0 +1,39 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + + "github.com/rancher/go-rancher/api" + "github.com/rancher/go-rancher/client" +) + +func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { + return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if err := t(rw, req); err != nil { + apiContext := api.GetApiContext(req) + apiContext.WriteErr(err) + } + })) +} + +func NewRouter() *mux.Router { + s := &server{} + schemas := newSchema() + router := mux.NewRouter().StrictSlash(true) + f := HandleError + + // API framework routes + router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) + router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) + router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) + router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + + // Backup targets + router.Methods("POST").Path("/v1/backuptargets").Handler(f(schemas, s.ConfigureBackupTarget)) + + return router +} + +type server struct{} diff --git a/app/snapshot.go b/app/snapshot.go index 508ac7dc..77cba6eb 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -77,7 +77,11 @@ func SnapshotLsCmd() cli.Command { func createSnapshot(c *cli.Context) error { cli := getCli(c) - id, err := cli.Snapshot() + var name string + if len(c.Args()) > 0 { + name = c.Args()[0] + } + id, err := cli.Snapshot(name) if err != nil { return err } diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 377733df..76d2bde5 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -37,14 +37,37 @@ func (c *ControllerClient) Start(replicas ...string) error { }, nil) } -func (c *ControllerClient) Snapshot() (string, error) { +func (c *ControllerClient) RevertVolume(name string) (*rest.Volume, error) { + volume, err := c.GetVolume() + if err != nil { + return nil, err + } + + input := &rest.RevertInput{ + Name: name, + } + + output := &rest.Volume{} + + err = c.post(volume.Actions["revert"], input, output) + if err != nil { + return nil, err + } + + return output, err +} + +func (c *ControllerClient) Snapshot(name string) (string, error) { volume, err := c.GetVolume() if err != nil { return "", err } + input := &rest.SnapshotInput{ + Name: name, + } output := &rest.SnapshotOutput{} - err = c.post(volume.Actions["snapshot"], nil, output) + err = c.post(volume.Actions["snapshot"], input, output) if err != nil { return "", err } diff --git a/package/Dockerfile b/package/Dockerfile index c3f95e99..853b92a7 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y kmod curl +RUN apt-get update && apt-get install -y kmod curl nfs-common RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin From ac9c780a725ef8a57ba4376b7bc69aeca58bc138 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Jun 2016 18:17:24 -0700 Subject: [PATCH 094/357] replica: Add more backup reading test --- replica/backup_test.go | 83 ++++++++++++++++++++++++++++++----------- replica/replica_test.go | 13 +++++++ 2 files changed, 74 insertions(+), 22 deletions(-) diff --git a/replica/backup_test.go b/replica/backup_test.go index c8859c02..b12c5e66 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -61,7 +61,7 @@ func (s *TestSuite) TestBackupWithBackupsAndBacking(c *C) { defer f.Close() buf := make([]byte, 10*mb) - fill(buf, 10) + fill(buf, 9) _, err = f.Write(buf) c.Assert(err, IsNil) @@ -88,36 +88,37 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { defer r.Close() // Write layout as follows - // 0 1 2 3 4 5 6 7 8 9 mb - // 003 X X X X X X X X X X - // 002 X X X X - // 001 X X X X - // 000 X X + // 0 1 2 3 4 5 6 7 8 9 mb + // chain[0] head 4 4 4 4 4 4 4 4 4 4 + // chain[1] 003 3 3 3 3 + // chain[2] 002 2 2 2 2 + // chain[3] 001 1 1 + // chain[4] back 9 9 9 9 9 9 9 9 9 9 buf := make([]byte, 2*mb) fill(buf, 1) _, err = r.WriteAt(buf, mb) c.Assert(err, IsNil) - err = r.Snapshot("001") + c.Assert(err, IsNil) fill(buf, 2) _, err = r.WriteAt(buf, 0) c.Assert(err, IsNil) _, err = r.WriteAt(buf, 4*mb) c.Assert(err, IsNil) - err = r.Snapshot("002") + c.Assert(err, IsNil) fill(buf, 3) _, err = r.WriteAt(buf, 4*mb) c.Assert(err, IsNil) _, err = r.WriteAt(buf, 8*mb) c.Assert(err, IsNil) - err = r.Snapshot("003") + c.Assert(err, IsNil) buf = make([]byte, 10*mb) - fill(buf, 9) + fill(buf, 4) _, err = r.WriteAt(buf, 0) c.Assert(err, IsNil) @@ -125,9 +126,21 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { rb := NewBackup(nil) - // Test 002 -> "" + // Test 003 -> "" err = rb.OpenSnapshot(chain[1], volume) c.Assert(err, IsNil) + + // Test read 003 + expected := make([]byte, 10*mb) + readBuf := make([]byte, 10*mb) + fill(expected[:2*mb], 2) + fill(expected[2*mb:3*mb], 1) + fill(expected[4*mb:6*mb], 3) + fill(expected[8*mb:10*mb], 3) + err = rb.ReadSnapshot(chain[1], volume, 0, readBuf) + c.Assert(err, IsNil) + md5Equals(c, readBuf, expected) + mappings, err := rb.CompareSnapshot(chain[1], "", volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 4) @@ -141,19 +154,11 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(mappings.Mappings[3].Offset, Equals, int64(8*mb)) c.Assert(mappings.Mappings[3].Size, Equals, int64(2*mb)) - // Test read - expected := make([]byte, 2*mb) - fill(expected, 2) - readBuf := make([]byte, 2*mb) - err = rb.ReadSnapshot(chain[1], volume, 0, readBuf) - c.Assert(err, IsNil) - byteEquals(c, readBuf, expected) err = rb.CloseSnapshot(chain[1], volume) c.Assert(err, IsNil) - // Test 002 -> 001 + // Test 003 -> 002 err = rb.OpenSnapshot(chain[1], volume) - c.Assert(err, IsNil) mappings, err = rb.CompareSnapshot(chain[1], chain[2], volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 2) @@ -164,9 +169,20 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) err = rb.CloseSnapshot(chain[1], volume) - // Test 001 -> 000 + // Test 002 -> 001 err = rb.OpenSnapshot(chain[2], volume) c.Assert(err, IsNil) + + // Test read 002 + expected = make([]byte, 10*mb) + readBuf = make([]byte, 10*mb) + fill(expected[:2*mb], 2) + fill(expected[2*mb:3*mb], 1) + fill(expected[4*mb:6*mb], 2) + err = rb.ReadSnapshot(chain[2], volume, 0, readBuf) + c.Assert(err, IsNil) + md5Equals(c, readBuf, expected) + mappings, err = rb.CompareSnapshot(chain[2], chain[3], volume) c.Assert(err, IsNil) c.Assert(len(mappings.Mappings), Equals, 2) @@ -178,7 +194,7 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { err = rb.CloseSnapshot(chain[2], volume) c.Assert(err, IsNil) - // Test 001 -> "" + // Test 002 -> "" err = rb.OpenSnapshot(chain[2], volume) c.Assert(err, IsNil) mappings, err = rb.CompareSnapshot(chain[2], "", volume) @@ -193,4 +209,27 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(mappings.Mappings[2].Size, Equals, int64(2*mb)) err = rb.CloseSnapshot(chain[2], volume) c.Assert(err, IsNil) + + // Test 001 -> "" + err = rb.OpenSnapshot(chain[3], volume) + c.Assert(err, IsNil) + + // Test read 001 + expected = make([]byte, 10*mb) + readBuf = make([]byte, 10*mb) + fill(expected[mb:3*mb], 1) + err = rb.ReadSnapshot(chain[3], volume, 0, readBuf) + c.Assert(err, IsNil) + md5Equals(c, readBuf, expected) + + mappings, err = rb.CompareSnapshot(chain[3], "", volume) + c.Assert(err, IsNil) + c.Assert(len(mappings.Mappings), Equals, 2) + c.Assert(mappings.BlockSize, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[0].Offset, Equals, int64(0*mb)) + c.Assert(mappings.Mappings[0].Size, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Offset, Equals, int64(2*mb)) + c.Assert(mappings.Mappings[1].Size, Equals, int64(2*mb)) + err = rb.CloseSnapshot(chain[3], volume) + c.Assert(err, IsNil) } diff --git a/replica/replica_test.go b/replica/replica_test.go index 8422bb6a..aaead8ed 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -1,6 +1,7 @@ package replica import ( + "crypto/md5" "fmt" "io/ioutil" "os" @@ -208,6 +209,18 @@ func byteEquals(c *C, expected, obtained []byte) { } } +func md5Equals(c *C, expected, obtained []byte) { + c.Assert(len(expected), Equals, len(obtained)) + + expectedMd5 := md5.Sum(expected) + obtainedMd5 := md5.Sum(obtained) + for i := range expectedMd5 { + l := fmt.Sprintf("%d=%x", i, expectedMd5[i]) + r := fmt.Sprintf("%d=%x", i, obtainedMd5[i]) + c.Assert(r, Equals, l) + } +} + func fill(buf []byte, val byte) { for i := 0; i < len(buf); i++ { buf[i] = val From fe9c32ba6818f5ebc6ba5c3c152512a6185e40f0 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Jun 2016 18:17:24 -0700 Subject: [PATCH 095/357] replica: Fix CompareSnapshot with backing-file The backing-file will be at first of activeDiskData[], so if CompareSnapshot() is called without compareID, it should default to index 1 of activeDiskData[](first snapshot) rather than index 0(which is backing file). Otherwise it will result in all backing file get in the generated result. Also add backing file backup unit test. --- replica/backup.go | 5 ++++- replica/backup_test.go | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/replica/backup.go b/replica/backup.go index abb61244..5f6087c4 100644 --- a/replica/backup.go +++ b/replica/backup.go @@ -158,7 +158,10 @@ func (rb *Backup) CompareSnapshot(id, compareID, volumeID string) (*metadata.Map func (rb *Backup) findIndex(id string) int { if id == "" { - return 0 + if rb.backingFile == nil { + return 0 + } + return 1 } for i, disk := range rb.replica.activeDiskData { diff --git a/replica/backup_test.go b/replica/backup_test.go index b12c5e66..683a8aad 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -124,7 +124,7 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { chain, err := r.Chain() - rb := NewBackup(nil) + rb := NewBackup(backingFile) // Test 003 -> "" err = rb.OpenSnapshot(chain[1], volume) @@ -137,6 +137,10 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { fill(expected[2*mb:3*mb], 1) fill(expected[4*mb:6*mb], 3) fill(expected[8*mb:10*mb], 3) + if backingFile != nil { + fill(expected[3*mb:4*mb], 9) + fill(expected[6*mb:8*mb], 9) + } err = rb.ReadSnapshot(chain[1], volume, 0, readBuf) c.Assert(err, IsNil) md5Equals(c, readBuf, expected) @@ -179,6 +183,10 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { fill(expected[:2*mb], 2) fill(expected[2*mb:3*mb], 1) fill(expected[4*mb:6*mb], 2) + if backingFile != nil { + fill(expected[3*mb:4*mb], 9) + fill(expected[6*mb:10*mb], 9) + } err = rb.ReadSnapshot(chain[2], volume, 0, readBuf) c.Assert(err, IsNil) md5Equals(c, readBuf, expected) @@ -218,6 +226,10 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { expected = make([]byte, 10*mb) readBuf = make([]byte, 10*mb) fill(expected[mb:3*mb], 1) + if backingFile != nil { + fill(expected[:mb], 9) + fill(expected[3*mb:10*mb], 9) + } err = rb.ReadSnapshot(chain[3], volume, 0, readBuf) c.Assert(err, IsNil) md5Equals(c, readBuf, expected) From 056a6a0016e16bb2443239cbc16358018e44db52 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Jun 2016 18:17:24 -0700 Subject: [PATCH 096/357] replica: Don't remove backing-file when delete replica --- replica/replica.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/replica/replica.go b/replica/replica.go index ef3d013f..78dd0476 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -539,7 +539,9 @@ func (r *Replica) Delete() error { defer r.Unlock() for name := range r.diskData { - r.rmDisk(name) + if name != r.info.BackingFileName { + r.rmDisk(name) + } } os.Remove(path.Join(r.dir, volumeMetaData)) From 3bb8db7948a1f43206a0c60f492520384274c39f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Jun 2016 18:17:24 -0700 Subject: [PATCH 097/357] integration: Add more backup restore from backing-file test --- integration/data/test_backup.py | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index b4dd9f19..9a070923 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -79,3 +79,47 @@ def test_backup_with_backing_file(backing_dev): # NOQA cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup0) + + +def test_backup_hole_with_backing_file(backing_dev): # NOQA + dev = backing_dev # NOQA + + offset1 = 512 + length1 = 256 + + offset2 = 640 + length2 = 256 + + boundary_offset = 0 + boundary_length = 4100 # just pass 4096 into next 4k + + hole_offset = 2 * 1024 * 1024 + hole_length = 1024 + + snap1_data = common.random_string(length1) + common.verify_data(dev, offset1, snap1_data) + snap1 = cmd.snapshot_create() + + boundary_data_backup1 = read_dev(dev, boundary_offset, boundary_length) + hole_data_backup1 = read_dev(dev, hole_offset, hole_length) + backup1 = cmd.backup_create(snap1, BACKUP_DEST) + + snap2_data = common.random_string(length2) + common.verify_data(dev, offset2, snap2_data) + snap2 = cmd.snapshot_create() + + boundary_data_backup2 = read_dev(dev, boundary_offset, boundary_length) + hole_data_backup2 = read_dev(dev, hole_offset, hole_length) + backup2 = cmd.backup_create(snap2, BACKUP_DEST) + + cmd.backup_restore(backup1) + readed = read_dev(dev, boundary_offset, boundary_length) + assert readed == boundary_data_backup1 + readed = read_dev(dev, hole_offset, hole_length) + assert readed == hole_data_backup1 + + cmd.backup_restore(backup2) + readed = read_dev(dev, boundary_offset, boundary_length) + assert readed == boundary_data_backup2 + readed = read_dev(dev, hole_offset, hole_length) + assert readed == hole_data_backup2 From 4086a374ec321271181fef8f5c86f8f6df972244 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Jun 2016 18:17:24 -0700 Subject: [PATCH 098/357] backup: Fix backup with backing file Turns out volume metadata info doesn't contains information about backing file. Need to produce it on our own. --- backup/backing_disable.go | 16 ++++++++++++++++ backup/backing_qcow.go | 31 +++++++++++++++++++++++++++++++ backup/main.go | 20 ++++++++++++++++++-- replica/replica.go | 18 +++++++++++------- 4 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 backup/backing_disable.go create mode 100644 backup/backing_qcow.go diff --git a/backup/backing_disable.go b/backup/backing_disable.go new file mode 100644 index 00000000..7f65969d --- /dev/null +++ b/backup/backing_disable.go @@ -0,0 +1,16 @@ +// +build !qcow + +package backup + +import ( + "fmt" + + "github.com/rancher/longhorn/replica" +) + +func openBackingFile(file string) (*replica.BackingFile, error) { + if file == "" { + return nil, nil + } + return nil, fmt.Errorf("Backing file is not supported") +} diff --git a/backup/backing_qcow.go b/backup/backing_qcow.go new file mode 100644 index 00000000..25c765e9 --- /dev/null +++ b/backup/backing_qcow.go @@ -0,0 +1,31 @@ +// +build qcow + +package backup + +import ( + "github.com/rancher/longhorn/qcow" + "github.com/rancher/longhorn/replica" +) + +func openBackingFile(file string) (*replica.BackingFile, error) { + if file == "" { + return nil, nil + } + + f, err := qcow.Open(file) + if err != nil { + return nil, err + } + + size, err := f.Size() + if err != nil { + return nil, err + } + + return &replica.BackingFile{ + Name: file, + Disk: f, + Size: size, + SectorSize: 512, + }, nil +} diff --git a/backup/main.go b/backup/main.go index 09490018..00a9f8b8 100644 --- a/backup/main.go +++ b/backup/main.go @@ -115,6 +115,8 @@ func cleanup() { func Main() { defer cleanup() + logrus.SetLevel(logrus.DebugLevel) + logrus.SetOutput(os.Stderr) dir, err := os.Getwd() if err != nil { log.Fatalf("Cannot get running directory: %s", err) @@ -169,7 +171,10 @@ func cmdBackupCreate(c *cli.Context) { } func doBackupCreate(c *cli.Context) error { - var err error + var ( + err error + backingFile *replica.BackingFile + ) destURL, err := util.GetFlag(c, "dest", true, err) if err != nil { @@ -195,7 +200,18 @@ func doBackupCreate(c *cli.Context) error { if err != nil { return err } - replicaBackup := replica.NewBackup(volumeInfo.BackingFile) + if volumeInfo.BackingFileName != "" { + backingFileName := volumeInfo.BackingFileName + if _, err := os.Stat(backingFileName); err != nil { + return err + } + + backingFile, err = openBackingFile(backingFileName) + if err != nil { + return err + } + } + replicaBackup := replica.NewBackup(backingFile) volume := &objectstore.Volume{ Name: volumeName, diff --git a/replica/replica.go b/replica/replica.go index 78dd0476..8fc0ed87 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -40,13 +40,14 @@ type Replica struct { } type Info struct { - Size int64 - Head string - Dirty bool - Rebuilding bool - Parent string - SectorSize int64 - BackingFile *BackingFile `json:"-"` + Size int64 + Head string + Dirty bool + Rebuilding bool + Parent string + SectorSize int64 + BackingFileName string + BackingFile *BackingFile `json:"-"` } type disk struct { @@ -93,6 +94,9 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF r.info.Size = size r.info.SectorSize = sectorSize r.info.BackingFile = backingFile + if backingFile != nil { + r.info.BackingFileName = backingFile.Name + } r.volume.sectorSize = defaultSectorSize exists, err := r.readMetadata() From f1c9e6551b61af21188628184d2ede1cb33304d7 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 8 Jun 2016 19:20:08 -0700 Subject: [PATCH 099/357] RW timeout retry (#128) * controller: rpc client: conflated read & write timeout error into one * controller: implemented r/w timout retry - OpRetries = 4 - fixed golint warnings --- rpc/client.go | 93 ++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/rpc/client.go b/rpc/client.go index 7b4cc87d..506343e2 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -10,12 +10,15 @@ import ( ) var ( - opReadTimeout = 15 * time.Second // client read - opWriteTimeout = 15 * time.Second // client write - errReadTimeout = errors.New("read timeout") - errWriteTimeout = errors.New("write timeout") + //ErrRWTimeout r/w operation timeout + ErrRWTimeout = errors.New("r/w timeout") + + opRetries = 4 + opReadTimeout = 15 * time.Second // client read + opWriteTimeout = 15 * time.Second // client write ) +//Client replica client type Client struct { end chan struct{} requests chan *Message @@ -27,6 +30,7 @@ type Client struct { err error } +//NewClient replica client func NewClient(conn net.Conn) *Client { c := &Client{ wire: NewWire(conn), @@ -42,64 +46,71 @@ func NewClient(conn net.Conn) *Client { return c } +//WriteAt replica client func (c *Client) WriteAt(buf []byte, offset int64) (int, error) { return c.operation(TypeWrite, buf, offset) } +//SetError replica client transport error func (c *Client) SetError(err error) { c.responses <- &Message{ transportErr: err, } } +//ReadAt replica client func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { return c.operation(TypeRead, buf, offset) } func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { - msg := Message{ - Complete: make(chan struct{}, 1), - Type: op, - Offset: offset, - Data: buf, - } - - timeout := func(op uint32) <-chan time.Time { - switch op { - case TypeRead: - return time.After(opReadTimeout) - } - return time.After(opWriteTimeout) - }(msg.Type) - - c.requests <- &msg - - select { - case <-msg.Complete: - case <-timeout: - switch msg.Type { - case TypeRead: - c.SetError(errReadTimeout) - logrus.Errorln("Read timeout: seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") - - case TypeWrite: - c.SetError(errWriteTimeout) - logrus.Errorln("Write timeout: seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + retry := 0 + for { + msg := Message{ + Complete: make(chan struct{}, 1), + Type: op, + Offset: offset, + Data: buf, } - // stats.Print()//flush automaticalyupon timeout - } - if msg.Type == TypeError { - return 0, errors.New(string(msg.Data)) - } + timeout := func(op uint32) <-chan time.Time { + switch op { + case TypeRead: + return time.After(opReadTimeout) + } + return time.After(opWriteTimeout) + }(msg.Type) - if msg.Type == TypeEOF { - return len(msg.Data), io.EOF - } + c.requests <- &msg - return len(msg.Data), nil + select { + case <-msg.Complete: + if msg.Type == TypeError { + return 0, errors.New(string(msg.Data)) + } + if msg.Type == TypeEOF { + return len(msg.Data), io.EOF + } + return len(msg.Data), nil + case <-timeout: + switch msg.Type { + case TypeRead: + logrus.Errorln("Read timeout on replcia", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + case TypeWrite: + logrus.Errorln("Write timeout on replica", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + } + if retry < opRetries { + retry++ + logrus.Errorln("Retry ", retry, "on replica", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + } else { + c.SetError(ErrRWTimeout) + return 0, ErrRWTimeout + } + } + } } +//Close replica client func (c *Client) Close() { c.wire.Close() c.end <- struct{}{} From 11f48bfa490b3ab0ec953e4c9697d6c071b2ffc4 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 27 May 2016 20:43:06 -0700 Subject: [PATCH 100/357] controller: put stats instrumentation into the serially executed code to avoid posible contention - use replica remote address for operation target tracking - added operation status tracking --- controller/replicator.go | 1 + rpc/client.go | 8 + rpc/types.go | 4 + trash.yml | 2 +- .../rancher/sparse-tools/log/log.go | 2 +- .../rancher/sparse-tools/stats/stats.go | 276 ++++++++++++++++++ 6 files changed, 291 insertions(+), 2 deletions(-) create mode 100644 vendor/github.com/rancher/sparse-tools/stats/stats.go diff --git a/controller/replicator.go b/controller/replicator.go index e99bfc10..b5e014a0 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -92,6 +92,7 @@ func (r *replicator) ReadAt(buf []byte, off int64) (int, error) { } n, err := r.readers[index].ReadAt(buf, off) if err != nil { + logrus.Error("Replicator.ReadAt:", index, err) return n, &BackendError{ Errors: map[string]error{ r.readerIndex[index]: err, diff --git a/rpc/client.go b/rpc/client.go index 506343e2..baa75343 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -137,6 +137,7 @@ func (c *Client) nextSeq() uint32 { } func (c *Client) replyError(req *Message) { + stats.RemovePendingOp(req.ID, false) delete(c.messages, req.Seq) req.Type = TypeError req.Data = []byte(c.err.Error()) @@ -144,6 +145,12 @@ func (c *Client) replyError(req *Message) { } func (c *Client) handleRequest(req *Message) { + switch req.Type { + case TypeRead: + req.ID = stats.InsertPendingOp(time.Now(), c.wire.conn.RemoteAddr().String(), stats.OpRead, len(req.Data)) + case TypeWrite: + req.ID = stats.InsertPendingOp(time.Now(), c.wire.conn.RemoteAddr().String(), stats.OpWrite, len(req.Data)) + } if c.err != nil { c.replyError(req) return @@ -170,6 +177,7 @@ func (c *Client) handleResponse(resp *Message) { return } + stats.RemovePendingOp(req.ID, true) delete(c.messages, resp.Seq) // can probably optimize away this copy if len(resp.Data) > 0 { diff --git a/rpc/types.go b/rpc/types.go index 2a693d27..7e17a5b3 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -1,5 +1,7 @@ package rpc +import "github.com/rancher/sparse-tools/stats" + const ( TypeRead = iota TypeWrite @@ -20,4 +22,6 @@ type Message struct { Offset int64 Data []byte transportErr error + + ID stats.OpID //Seq and ID can apparently be collapsed into one (ID) } diff --git a/trash.yml b/trash.yml index 5eb4cf86..0d4f74fd 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 0f8c2192c58644b127721633789e8d637d712dfb + version: 54c31d18caa51a69bdbe26c30db6df2a02241fa5 - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/log/log.go b/vendor/github.com/rancher/sparse-tools/log/log.go index 4294889e..69be2fcc 100644 --- a/vendor/github.com/rancher/sparse-tools/log/log.go +++ b/vendor/github.com/rancher/sparse-tools/log/log.go @@ -21,7 +21,7 @@ const ( // crude global log level control: // log everything at this level and above var logMutex sync.RWMutex -var logLevel = LevelDebug +var logLevel = LevelInfo var logLevelStack []Level // LevelPush push current level down the stack and set diff --git a/vendor/github.com/rancher/sparse-tools/stats/stats.go b/vendor/github.com/rancher/sparse-tools/stats/stats.go new file mode 100644 index 00000000..efc564cb --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/stats/stats.go @@ -0,0 +1,276 @@ +package stats + +import ( + "fmt" + "time" + + "errors" + + "sync" + + "github.com/rancher/sparse-tools/log" +) + +const ( + defaultBufferSize = 100 * 1000 // sample buffer size (cyclic) +) + +//SampleOp operation +type SampleOp int + +const ( + // OpNone unitialized operation + OpNone SampleOp = iota + // OpRead read from replica + OpRead + // OpWrite write to replica + OpWrite + // OpPing ping replica + OpPing +) + +type dataPoint struct { + target int // index in targetIDs (e.g replica index) + op SampleOp + timestamp time.Time + duration time.Duration + size int // i/o operation size + status bool +} + +// Minimize space by storing targetID indices in the dataPoint +var ( + targetIDs = make([]string, 0, 128) + targetMap = make(map[string]int, 128) + targetMutex sync.RWMutex +) + +func targetIndex(targetID string) int { + targetMutex.RLock() + target, exists := targetMap[targetID] + targetMutex.RUnlock() + if exists { + return target + } + + // register the ID + targetMutex.Lock() + defer targetMutex.Unlock() + + target, exists = targetMap[targetID] + if exists { + return target + } + + target = len(targetMap) + targetMap[targetID] = target + targetIDs = append(targetIDs, targetID) + return target +} + +func targetID(i int) string { + targetMutex.RLock() + defer targetMutex.RUnlock() + return targetIDs[i] +} + +// String conversions +func (op SampleOp) String() string { + switch op { + case OpRead: + return "R" + case OpWrite: + return "W" + case OpPing: + return "P" + } + return "" +} + +func (sample dataPoint) String() string { + target := targetID(sample.target) + if sample.duration != time.Duration(0) { + if sample.status { + return fmt.Sprintf("%s: ->%s %v[%3dkB] %8dus", sample.timestamp.Format(time.StampMicro), target, sample.op, sample.size/1024, sample.duration.Nanoseconds()/1000) + } + return fmt.Sprintf("%s: ->%s %v[%3dkB] %8dus failed", sample.timestamp.Format(time.StampMicro), target, sample.op, sample.size/1024, sample.duration.Nanoseconds()/1000) + } + return fmt.Sprintf("%s: ->%s %v[%3dkB] pending", sample.timestamp.Format(time.StampMicro), target, sample.op, sample.size/1024) +} + +var ( + bufferSize = defaultBufferSize + cdata = make(chan dataPoint, defaultBufferSize) +) + +func initStats(size int) { + bufferSize = size + cdata = make(chan dataPoint, bufferSize) + log.Debug("Stats.init=", size) +} + +func init() { + initStats(bufferSize) +} + +func storeSample(sample dataPoint) { + //Maintain non-blocking state + for { + select { + case cdata <- sample: + return + default: + <-cdata + } + } +} + +// Sample to the cyclic buffer +func Sample(timestamp time.Time, duration time.Duration, targetID string, op SampleOp, size int, status bool) { + storeSample(dataPoint{targetIndex(targetID), op, timestamp, duration, size, status}) +} + +// Process unreported samples +func Process(processor func(dataPoint)) chan struct{} { + return ProcessLimited(0 /*no limit*/, processor) +} + +// ProcessLimited number of unreported samples is restricted by specified limit, the rest os droppped +func ProcessLimited(limit int, processor func(dataPoint)) chan struct{} { + // Fetch unreported window + done := make(chan struct{}) + dropCount := 0 + if limit > 0 { + count := len(cdata) + if count > limit { + // drop old samples to satisfy the limit + dropCount = count - limit + } + } + + go func(dropCount, limit int, pending []dataPoint, done chan struct{}) { + samples: + for count := 0; limit == 0 || count < limit; { + select { + case sample := <-cdata: + log.Debug("Stats.Processing=", sample) + if dropCount > 0 { + // skip old samples + dropCount-- + break + } + processor(sample) + count++ + default: + break samples + } + } + for _, sample := range pending { + log.Debug("Stats.Processing pending=", sample) + processor(sample) + } + close(done) + }(dropCount, limit, getPendingOps(), done) + + return done +} + +func printSample(sample dataPoint) { + fmt.Println(sample) +} + +// Print samples +func Print() chan struct{} { + return Process(printSample) +} + +// PrintLimited samples +func PrintLimited(limit int) chan struct{} { + return ProcessLimited(limit, printSample) +} + +// Test helper to exercise small buffer sizes +func resetStats(size int) { + log.Debug("Stats.reset") + initStats(size) +} + +//OpID pending operation id +type OpID int + +var ( + pendingOps = make([]dataPoint, 8, 128) + pendingOpsFreeSlot = make([]int, 0, 128) // stack of recently freed IDs + mutexPendingOps sync.Mutex +) + +//InsertPendingOp starts tracking of a pending operation +func InsertPendingOp(timestamp time.Time, targetID string, op SampleOp, size int) OpID { + mutexPendingOps.Lock() + defer mutexPendingOps.Unlock() + + var id int + if len(pendingOpsFreeSlot) > 0 { + //reuse recently freed id + id = pendingOpsFreeSlot[len(pendingOpsFreeSlot)-1] + pendingOpsFreeSlot = pendingOpsFreeSlot[:len(pendingOpsFreeSlot)-1] + } else { + id = pendingOpEmptySlot() + } + pendingOps[id] = dataPoint{targetIndex(targetID), op, timestamp, 0, size, false} + log.Debug("InsertPendingOp id=", id) + return OpID(id) +} + +//RemovePendingOp removes tracking of a completed operation +func RemovePendingOp(id OpID, status bool) error { + log.Debug("RemovePendingOp id=", id) + mutexPendingOps.Lock() + defer mutexPendingOps.Unlock() + + i := int(id) + if i < 0 || i >= len(pendingOps) { + errMsg := "RemovePendingOp: Invalid OpID" + log.Error(errMsg, i) + return errors.New(errMsg) + } + if pendingOps[i].op == OpNone { + errMsg := "RemovePendingOp: OpID already removed" + log.Error(errMsg, i) + return errors.New(errMsg) + } + + // Update the duration and store in the recent stats + pendingOps[i].duration = time.Now().Sub(pendingOps[i].timestamp) + pendingOps[i].status = status + storeSample(pendingOps[i]) + + //Remove from pending + pendingOps[i].op = OpNone + //Stack freed id for quick reuse + pendingOpsFreeSlot = append(pendingOpsFreeSlot, i) + return nil +} + +func pendingOpEmptySlot() int { + for i, op := range pendingOps { + if op.op == OpNone { + return i + } + } + pendingOps = append(pendingOps, dataPoint{}) + return len(pendingOps) - 1 +} + +func getPendingOps() []dataPoint { + mutexPendingOps.Lock() + defer mutexPendingOps.Unlock() + + ops := make([]dataPoint, 0, len(pendingOps)) + for _, op := range pendingOps { + if op.op != OpNone { + ops = append(ops, op) + } + } + return ops +} From 3f255bb9063ff21900e1745a7f20ab31ccadbb05 Mon Sep 17 00:00:00 2001 From: kirill Date: Wed, 1 Jun 2016 22:34:32 -0700 Subject: [PATCH 101/357] Controller: enabled automatic stats flush on timeout --- rpc/client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpc/client.go b/rpc/client.go index baa75343..7ee1b29d 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -7,6 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" + "github.com/rancher/sparse-tools/stats" ) var ( @@ -104,6 +105,7 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { logrus.Errorln("Retry ", retry, "on replica", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") } else { c.SetError(ErrRWTimeout) + stats.Print() //flush automatically upon timeout return 0, ErrRWTimeout } } From e27f89fc7457dd9ac17bf4032a07818b501370cb Mon Sep 17 00:00:00 2001 From: kirill Date: Thu, 2 Jun 2016 00:27:59 -0700 Subject: [PATCH 102/357] controller: added "stats" command to flush stats to controller stdout on demand --- app/stats.go | 20 ++++++++++++++++++++ controller/client/controller_client.go | 5 +++++ controller/rest/router.go | 3 +++ controller/rest/stats.go | 13 +++++++++++++ main.go | 1 + 5 files changed, 42 insertions(+) create mode 100644 app/stats.go create mode 100644 controller/rest/stats.go diff --git a/app/stats.go b/app/stats.go new file mode 100644 index 00000000..0e91fa05 --- /dev/null +++ b/app/stats.go @@ -0,0 +1,20 @@ +package app + +import ( + "github.com/Sirupsen/logrus" + "github.com/codegangsta/cli" +) + +func LsStats() cli.Command { + return cli.Command{ + Name: "ls-stats", + ShortName: "stats", + Action: func(c *cli.Context) { + controllerClient := getCli(c) + err := controllerClient.ListStats() + if err != nil { + logrus.Fatalln("Error running stats command:", err) + } + }, + } +} diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 76d2bde5..de03d4ee 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -86,6 +86,11 @@ func (c *ControllerClient) RevertSnapshot(snapshot string) error { }, nil) } +func (c *ControllerClient) ListStats() error { + err := c.post("/stats", nil, nil) + return err +} + func (c *ControllerClient) ListReplicas() ([]rest.Replica, error) { var resp rest.ReplicaCollection err := c.get("/replicas", &resp) diff --git a/controller/rest/router.go b/controller/rest/router.go index 129491a9..fde00924 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -32,5 +32,8 @@ func NewRouter(s *Server) *mux.Router { router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) router.Methods("PUT").Path("/v1/replicas/{id}").Handler(f(schemas, s.UpdateReplica)) + // Stats + router.Methods("POST").Path("/v1/stats").Handler(f(schemas, s.ListStats)) + return router } diff --git a/controller/rest/stats.go b/controller/rest/stats.go new file mode 100644 index 00000000..6046e203 --- /dev/null +++ b/controller/rest/stats.go @@ -0,0 +1,13 @@ +package rest + +import ( + "net/http" + + "github.com/rancher/sparse-tools/stats" +) + +//ListStats flushes stats accumulated since previous flush +func (s *Server) ListStats(rw http.ResponseWriter, req *http.Request) error { + stats.Print() + return nil +} diff --git a/main.go b/main.go index d9073875..bf4f609d 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,7 @@ func longhornCli() { app.RmReplicaCmd(), app.SnapshotCmd(), app.BackupCmd(), + app.LsStats(), } if err := a.Run(os.Args); err != nil { From 8eccd4cb1222129095c3b0310cf1abae3436278c Mon Sep 17 00:00:00 2001 From: kirill Date: Thu, 2 Jun 2016 16:47:10 -0700 Subject: [PATCH 103/357] controller: added "limit" option to ls-stats command --- app/stats.go | 8 +++++++- controller/client/controller_client.go | 4 ++-- controller/rest/model.go | 6 ++++++ controller/rest/stats.go | 8 +++++++- rpc/client.go | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/stats.go b/app/stats.go index 0e91fa05..66e534bc 100644 --- a/app/stats.go +++ b/app/stats.go @@ -9,9 +9,15 @@ func LsStats() cli.Command { return cli.Command{ Name: "ls-stats", ShortName: "stats", + Flags: []cli.Flag{ + cli.IntFlag{ + Name: "limit", + Value: 0, + }, + }, Action: func(c *cli.Context) { controllerClient := getCli(c) - err := controllerClient.ListStats() + err := controllerClient.ListStats(c.Int("limit")) if err != nil { logrus.Fatalln("Error running stats command:", err) } diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index de03d4ee..e8048e1e 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -86,8 +86,8 @@ func (c *ControllerClient) RevertSnapshot(snapshot string) error { }, nil) } -func (c *ControllerClient) ListStats() error { - err := c.post("/stats", nil, nil) +func (c *ControllerClient) ListStats(limit int) error { + err := c.post("/stats", &rest.StatsInput{Limit: limit}, nil) return err } diff --git a/controller/rest/model.go b/controller/rest/model.go index e218cfd6..3e99e2ee 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -50,6 +50,11 @@ type RevertInput struct { Name string `json:"name"` } +type StatsInput struct { + client.Resource + Limit int `json:"limit"` +} + func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { v := &Volume{ Resource: client.Resource{ @@ -104,6 +109,7 @@ func NewSchema() *client.Schemas { schemas.AddType("snapshotOutput", SnapshotOutput{}) schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("revertInput", RevertInput{}) + schemas.AddType("statsInput", StatsInput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} diff --git a/controller/rest/stats.go b/controller/rest/stats.go index 6046e203..ce2375d9 100644 --- a/controller/rest/stats.go +++ b/controller/rest/stats.go @@ -3,11 +3,17 @@ package rest import ( "net/http" + "github.com/rancher/go-rancher/api" "github.com/rancher/sparse-tools/stats" ) //ListStats flushes stats accumulated since previous flush func (s *Server) ListStats(rw http.ResponseWriter, req *http.Request) error { - stats.Print() + var input StatsInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil { + return err + } + stats.PrintLimited(input.Limit) return nil } diff --git a/rpc/client.go b/rpc/client.go index 7ee1b29d..7ab8c3ac 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -105,7 +105,7 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { logrus.Errorln("Retry ", retry, "on replica", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") } else { c.SetError(ErrRWTimeout) - stats.Print() //flush automatically upon timeout + stats.PrintLimited(1000) //flush automatically upon timeout return 0, ErrRWTimeout } } From dd1d673c78db00a89b8fc1999ec8e77b77c87a3b Mon Sep 17 00:00:00 2001 From: kirill Date: Tue, 7 Jun 2016 14:57:38 -0700 Subject: [PATCH 104/357] controller: added back the ping stats instrumentation and auto flush on retry/error - use replica data addr (and resolve it) for ping target tracking to match r/w ops --- backend/remote/remote.go | 16 ++++++++++++---- rpc/client.go | 25 ++++++++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index bb954c76..a8cf36b1 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -16,6 +16,7 @@ import ( "github.com/rancher/longhorn/rpc" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" + journal "github.com/rancher/sparse-tools/stats" ) var ( @@ -183,14 +184,16 @@ func (r *Remote) monitorPing(client *rpc.Client) error { case <-r.closeChan: return nil case <-ticker.C: - if err := r.Ping(); err == nil { + if err := r.Ping(client); err == nil { retry = 0 // reset on success } else { if retry < pingRetries { retry++ - logrus.Errorf("Ping retry %v on error: %v", retry, err) + logrus.Errorf("Ping retry %v on replica %v; error: %v", retry, r.replicaURL, err) + journal.PrintLimited(1000) //flush automatically upon retry } else { - logrus.Errorf("Failed to get ping response: %v", err) + logrus.Errorf("Failed to get ping response from replica %v; error: %v", r.replicaURL, err) + journal.PrintLimited(1000) //flush automatically upon error client.SetError(err) return err } @@ -199,8 +202,11 @@ func (r *Remote) monitorPing(client *rpc.Client) error { } } -func (r *Remote) Ping() error { +func (r *Remote) Ping(client *rpc.Client) error { ret := make(chan error, 1) + // use replica data addr for ping target tracking + opID := journal.InsertPendingOp(time.Now(), client.TargetID(), journal.OpPing, 0) + go func() { resp, err := r.httpClient.Get(r.pingURL) if err != nil { @@ -217,8 +223,10 @@ func (r *Remote) Ping() error { select { case err := <-ret: + journal.RemovePendingOp(opID, err == nil) return err case <-time.After(pingTimeout): + journal.RemovePendingOp(opID, false) return ErrPingTimeout } } diff --git a/rpc/client.go b/rpc/client.go index 7ab8c3ac..91068b91 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -7,7 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/sparse-tools/stats" + journal "github.com/rancher/sparse-tools/stats" ) var ( @@ -28,6 +28,7 @@ type Client struct { seq uint32 messages map[uint32]*Message wire *Wire + peerAddr string err error } @@ -35,6 +36,7 @@ type Client struct { func NewClient(conn net.Conn) *Client { c := &Client{ wire: NewWire(conn), + peerAddr: conn.RemoteAddr().String(), end: make(chan struct{}, 1024), requests: make(chan *Message, 1024), send: make(chan *Message, 1024), @@ -47,6 +49,11 @@ func NewClient(conn net.Conn) *Client { return c } +//TargetID operation target ID +func (c *Client) TargetID() string { + return c.peerAddr +} + //WriteAt replica client func (c *Client) WriteAt(buf []byte, offset int64) (int, error) { return c.operation(TypeWrite, buf, offset) @@ -96,16 +103,16 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { case <-timeout: switch msg.Type { case TypeRead: - logrus.Errorln("Read timeout on replcia", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + logrus.Errorln("Read timeout on replcia", c.TargetID(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") case TypeWrite: - logrus.Errorln("Write timeout on replica", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + logrus.Errorln("Write timeout on replica", c.TargetID(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") } if retry < opRetries { retry++ - logrus.Errorln("Retry ", retry, "on replica", c.wire.conn.RemoteAddr().String(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + logrus.Errorln("Retry ", retry, "on replica", c.TargetID(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") } else { c.SetError(ErrRWTimeout) - stats.PrintLimited(1000) //flush automatically upon timeout + journal.PrintLimited(1000) //flush automatically upon timeout return 0, ErrRWTimeout } } @@ -139,7 +146,7 @@ func (c *Client) nextSeq() uint32 { } func (c *Client) replyError(req *Message) { - stats.RemovePendingOp(req.ID, false) + journal.RemovePendingOp(req.ID, false) delete(c.messages, req.Seq) req.Type = TypeError req.Data = []byte(c.err.Error()) @@ -149,9 +156,9 @@ func (c *Client) replyError(req *Message) { func (c *Client) handleRequest(req *Message) { switch req.Type { case TypeRead: - req.ID = stats.InsertPendingOp(time.Now(), c.wire.conn.RemoteAddr().String(), stats.OpRead, len(req.Data)) + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpRead, len(req.Data)) case TypeWrite: - req.ID = stats.InsertPendingOp(time.Now(), c.wire.conn.RemoteAddr().String(), stats.OpWrite, len(req.Data)) + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpWrite, len(req.Data)) } if c.err != nil { c.replyError(req) @@ -179,7 +186,7 @@ func (c *Client) handleResponse(resp *Message) { return } - stats.RemovePendingOp(req.ID, true) + journal.RemovePendingOp(req.ID, true) delete(c.messages, resp.Seq) // can probably optimize away this copy if len(resp.Data) > 0 { From 08aa802b63c067adf9b2869095eb0fbb6d57dd1f Mon Sep 17 00:00:00 2001 From: kirill Date: Thu, 9 Jun 2016 11:26:47 -0700 Subject: [PATCH 105/357] controller: renamed stats command into journal - renamed relevant code entities --- app/stats.go | 10 +++++----- controller/client/controller_client.go | 4 ++-- controller/rest/model.go | 4 ++-- controller/rest/router.go | 4 ++-- controller/rest/stats.go | 10 +++++----- main.go | 2 +- rpc/types.go | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/stats.go b/app/stats.go index 66e534bc..a74d1b30 100644 --- a/app/stats.go +++ b/app/stats.go @@ -5,10 +5,10 @@ import ( "github.com/codegangsta/cli" ) -func LsStats() cli.Command { +// Journal flush operations since last flush +func Journal() cli.Command { return cli.Command{ - Name: "ls-stats", - ShortName: "stats", + Name: "journal", Flags: []cli.Flag{ cli.IntFlag{ Name: "limit", @@ -17,9 +17,9 @@ func LsStats() cli.Command { }, Action: func(c *cli.Context) { controllerClient := getCli(c) - err := controllerClient.ListStats(c.Int("limit")) + err := controllerClient.ListJournal(c.Int("limit")) if err != nil { - logrus.Fatalln("Error running stats command:", err) + logrus.Fatalln("Error running journal command:", err) } }, } diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index e8048e1e..a2603338 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -86,8 +86,8 @@ func (c *ControllerClient) RevertSnapshot(snapshot string) error { }, nil) } -func (c *ControllerClient) ListStats(limit int) error { - err := c.post("/stats", &rest.StatsInput{Limit: limit}, nil) +func (c *ControllerClient) ListJournal(limit int) error { + err := c.post("/journal", &rest.JournalInput{Limit: limit}, nil) return err } diff --git a/controller/rest/model.go b/controller/rest/model.go index 3e99e2ee..673049fe 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -50,7 +50,7 @@ type RevertInput struct { Name string `json:"name"` } -type StatsInput struct { +type JournalInput struct { client.Resource Limit int `json:"limit"` } @@ -109,7 +109,7 @@ func NewSchema() *client.Schemas { schemas.AddType("snapshotOutput", SnapshotOutput{}) schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("revertInput", RevertInput{}) - schemas.AddType("statsInput", StatsInput{}) + schemas.AddType("journalInput", JournalInput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} diff --git a/controller/rest/router.go b/controller/rest/router.go index fde00924..69a6e784 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -32,8 +32,8 @@ func NewRouter(s *Server) *mux.Router { router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) router.Methods("PUT").Path("/v1/replicas/{id}").Handler(f(schemas, s.UpdateReplica)) - // Stats - router.Methods("POST").Path("/v1/stats").Handler(f(schemas, s.ListStats)) + // Journal + router.Methods("POST").Path("/v1/journal").Handler(f(schemas, s.ListJournal)) return router } diff --git a/controller/rest/stats.go b/controller/rest/stats.go index ce2375d9..832189b6 100644 --- a/controller/rest/stats.go +++ b/controller/rest/stats.go @@ -4,16 +4,16 @@ import ( "net/http" "github.com/rancher/go-rancher/api" - "github.com/rancher/sparse-tools/stats" + journal "github.com/rancher/sparse-tools/stats" ) -//ListStats flushes stats accumulated since previous flush -func (s *Server) ListStats(rw http.ResponseWriter, req *http.Request) error { - var input StatsInput +//ListJournal flushes operation journal (replica read/write, ping, etc.) accumulated since previous flush +func (s *Server) ListJournal(rw http.ResponseWriter, req *http.Request) error { + var input JournalInput apiContext := api.GetApiContext(req) if err := apiContext.Read(&input); err != nil { return err } - stats.PrintLimited(input.Limit) + journal.PrintLimited(input.Limit) return nil } diff --git a/main.go b/main.go index bf4f609d..62ef74e1 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,7 @@ func longhornCli() { app.RmReplicaCmd(), app.SnapshotCmd(), app.BackupCmd(), - app.LsStats(), + app.Journal(), } if err := a.Run(os.Args); err != nil { diff --git a/rpc/types.go b/rpc/types.go index 7e17a5b3..9faf27fd 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -1,6 +1,6 @@ package rpc -import "github.com/rancher/sparse-tools/stats" +import journal "github.com/rancher/sparse-tools/stats" const ( TypeRead = iota @@ -23,5 +23,5 @@ type Message struct { Data []byte transportErr error - ID stats.OpID //Seq and ID can apparently be collapsed into one (ID) + ID journal.OpID //Seq and ID can apparently be collapsed into one (ID) } From 93e625cf4bd901884e8035f76cdfd9e7a01bebd7 Mon Sep 17 00:00:00 2001 From: kirill Date: Fri, 10 Jun 2016 14:44:04 -0700 Subject: [PATCH 106/357] controller: changed ping timeout to 20s with 6 retries --- backend/remote/remote.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index a8cf36b1..e08756c9 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -21,7 +21,7 @@ import ( var ( pingRetries = 6 - pingTimeout = 3 * time.Second + pingTimeout = 20 * time.Second pingInveral = 2 * time.Second timeout = 30 * time.Second From f47ca45d7cab145c0f612ad09ffdaa3c2c03e37b Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Fri, 10 Jun 2016 13:30:12 -0700 Subject: [PATCH 107/357] Start sync-agent using base-image for root volumes --- Dockerfile.dapper | 2 +- package/Dockerfile | 2 +- package/copy-binary | 2 +- package/launch-replica-with-vm-backing-file | 11 ----------- package/launch-with-vm-backing-file | 19 +++++++++++++++++++ 5 files changed, 22 insertions(+), 14 deletions(-) delete mode 100755 package/launch-replica-with-vm-backing-file create mode 100755 package/launch-with-vm-backing-file diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ed272455..8276b53c 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout cce4790c6391002b948e8cf500460b8efacefdfc && \ + git checkout 26608ec42be1801a6c7febfcb5ef19fff4c98284 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow diff --git a/package/Dockerfile b/package/Dockerfile index 853b92a7..64bdcf82 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -4,5 +4,5 @@ RUN apt-get update && apt-get install -y kmod curl nfs-common RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin -COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-replica-with-vm-backing-file /usr/bin/ +COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-with-vm-backing-file /usr/bin/ CMD ["longhorn"] diff --git a/package/copy-binary b/package/copy-binary index db9ec569..2065b9ec 100755 --- a/package/copy-binary +++ b/package/copy-binary @@ -1,3 +1,3 @@ #!/bin/bash -cp $(which longhorn) $(which launch-replica-with-vm-backing-file) /cmd +cp $(which longhorn) $(which launch-with-vm-backing-file) /cmd diff --git a/package/launch-replica-with-vm-backing-file b/package/launch-replica-with-vm-backing-file deleted file mode 100755 index 661b0b71..00000000 --- a/package/launch-replica-with-vm-backing-file +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -BASE_IMAGE_DIR_LIST=( `ls /base_image` ) -if [ ${#BASE_IMAGE_DIR_LIST[@]} -ne 1 ]; then - echo "/base_image directory must contain exactly one base image file" - exit 1 -fi -IMAGE_FILE="/base_image/${BASE_IMAGE_DIR_LIST[0]}" - - -/cmd/longhorn replica --backing-file ${IMAGE_FILE} "$@" \ No newline at end of file diff --git a/package/launch-with-vm-backing-file b/package/launch-with-vm-backing-file new file mode 100755 index 00000000..3035ae02 --- /dev/null +++ b/package/launch-with-vm-backing-file @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +BASE_IMAGE_DIR_LIST=( `ls /base_image` ) +if [ ${#BASE_IMAGE_DIR_LIST[@]} -ne 1 ]; then + echo "/base_image directory must contain exactly one base image file" + exit 1 +fi +IMAGE_FILE="/base_image/${BASE_IMAGE_DIR_LIST[0]}" + +COMMAND=$1 +shift +if [ "${COMMAND}" == "replica" ]; then + /cmd/longhorn ${COMMAND} --backing-file ${IMAGE_FILE} "$@" +elif [ "${COMMAND}" == "sync-agent" ]; then + /cmd/longhorn ${COMMAND} "$@" +else + echo "Bad command: ${COMMAND}" + exit 1 +fi From d682b3a9d32b2637d7addf389f89e435094693f4 Mon Sep 17 00:00:00 2001 From: kirill Date: Fri, 10 Jun 2016 16:22:03 -0700 Subject: [PATCH 108/357] reduced FDR journal to 4k --- trash.yml | 2 +- vendor/github.com/rancher/sparse-tools/stats/stats.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/trash.yml b/trash.yml index 0d4f74fd..a24ac9b3 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 54c31d18caa51a69bdbe26c30db6df2a02241fa5 + version: 3bd59725c7305b1c70a470aff82025f3167795ef - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/stats/stats.go b/vendor/github.com/rancher/sparse-tools/stats/stats.go index efc564cb..8f46039e 100644 --- a/vendor/github.com/rancher/sparse-tools/stats/stats.go +++ b/vendor/github.com/rancher/sparse-tools/stats/stats.go @@ -12,7 +12,7 @@ import ( ) const ( - defaultBufferSize = 100 * 1000 // sample buffer size (cyclic) + defaultBufferSize = 4 * 1000 // sample buffer size (cyclic) ) //SampleOp operation @@ -71,6 +71,9 @@ func targetIndex(targetID string) int { func targetID(i int) string { targetMutex.RLock() defer targetMutex.RUnlock() + if i < 0 || i >= len(targetIDs) { + return "" + } return targetIDs[i] } From b21ec954bf373e8ab21215338c00b0bfce4403e2 Mon Sep 17 00:00:00 2001 From: kirill Date: Fri, 10 Jun 2016 17:54:36 -0700 Subject: [PATCH 109/357] Replica: increased client timeout to 30s --- replica/client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replica/client/client.go b/replica/client/client.go index 85062572..51306ee9 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -53,7 +53,7 @@ func NewReplicaClient(address string) (*ReplicaClient, error) { syncAgent := strings.Replace(address, fmt.Sprintf(":%d", port), fmt.Sprintf(":%d", port+2), -1) - timeout := time.Duration(10 * time.Second) + timeout := time.Duration(30 * time.Second) client := &http.Client{ Timeout: timeout, } From d8866ca6badc048e1198cdba058ffc094cdae5b7 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Fri, 10 Jun 2016 18:08:34 -0700 Subject: [PATCH 110/357] udpate driver for iops fields --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 8276b53c..09c3c8d7 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout 26608ec42be1801a6c7febfcb5ef19fff4c98284 && \ + git checkout f472ce5e272fdcc8b04d4b6b194133b02f7ebb5c && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From c7f3c37ce56244a8f1d4a43e0bf5ca1f5962e95e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 111/357] replica: add r.diskPath() in place for path.Join(r.dir, name) --- replica/replica.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 8fc0ed87..3daa0b0f 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -144,6 +144,10 @@ func GenerateSnapshotDiskName(name string) string { return fmt.Sprintf(diskName, name) } +func (r *Replica) diskPath(name string) string { + return path.Join(r.dir, name) +} + func (r *Replica) insertBackingFile() { if r.info.BackingFile == nil { return @@ -278,7 +282,7 @@ func (r *Replica) encodeToFile(obj interface{}, file string) error { return nil } - f, err := os.Create(path.Join(r.dir, file+".tmp")) + f, err := os.Create(r.diskPath(file + ".tmp")) if err != nil { return err } @@ -292,7 +296,7 @@ func (r *Replica) encodeToFile(obj interface{}, file string) error { return err } - return os.Rename(path.Join(r.dir, file+".tmp"), path.Join(r.dir, file)) + return os.Rename(r.diskPath(file+".tmp"), r.diskPath(file)) } func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) (string, error) { @@ -310,7 +314,7 @@ func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) } func (r *Replica) openFile(name string, flag int) (types.DiffDisk, error) { - f, err := os.OpenFile(path.Join(r.dir, name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) + f, err := os.OpenFile(r.diskPath(name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) if err != nil { return nil, err } @@ -325,7 +329,7 @@ func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, e return nil, disk{}, err } - if _, err := os.Stat(path.Join(r.dir, newHeadName)); err == nil { + if _, err := os.Stat(r.diskPath(newHeadName)); err == nil { return nil, disk{}, fmt.Errorf("%s already exists", newHeadName) } @@ -333,7 +337,7 @@ func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, e if err != nil { return nil, disk{}, err } - if err := syscall.Truncate(path.Join(r.dir, newHeadName), r.info.Size); err != nil { + if err := syscall.Truncate(r.diskPath(newHeadName), r.info.Size); err != nil { return nil, disk{}, err } @@ -347,7 +351,7 @@ func (r *Replica) linkDisk(oldname, newname string) error { return nil } - dest := path.Join(r.dir, newname) + dest := r.diskPath(newname) if _, err := os.Stat(dest); err == nil { logrus.Infof("Old file %s exists, deleting", dest) if err := os.Remove(dest); err != nil { @@ -355,11 +359,11 @@ func (r *Replica) linkDisk(oldname, newname string) error { } } - if err := os.Link(path.Join(r.dir, oldname), dest); err != nil { + if err := os.Link(r.diskPath(oldname), dest); err != nil { return err } - return os.Link(path.Join(r.dir, oldname+metadataSuffix), path.Join(r.dir, newname+metadataSuffix)) + return os.Link(r.diskPath(oldname+metadataSuffix), r.diskPath(newname+metadataSuffix)) } func (r *Replica) rmDisk(name string) error { @@ -367,15 +371,15 @@ func (r *Replica) rmDisk(name string) error { return nil } - lastErr := os.Remove(path.Join(r.dir, name)) - if err := os.Remove(path.Join(r.dir, name+metadataSuffix)); err != nil { + lastErr := os.Remove(r.diskPath(name)) + if err := os.Remove(r.diskPath(name + metadataSuffix)); err != nil { lastErr = err } return lastErr } func (r *Replica) revertDisk(parent string) (*Replica, error) { - if _, err := os.Stat(path.Join(r.dir, parent)); err != nil { + if _, err := os.Stat(r.diskPath(parent)); err != nil { return nil, err } @@ -520,7 +524,7 @@ func (r *Replica) readDiskData(file string) error { } func (r *Replica) unmarshalFile(file string, obj interface{}) error { - p := path.Join(r.dir, file) + p := r.diskPath(file) f, err := os.Open(p) if err != nil { return err @@ -548,7 +552,7 @@ func (r *Replica) Delete() error { } } - os.Remove(path.Join(r.dir, volumeMetaData)) + os.Remove(r.diskPath(volumeMetaData)) return nil } From ea070ed2dc6794b13d43b2bca8ccb8c9d2bb16ee Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 112/357] replica: Change `snapshot rm` to no-op Only mark the diffdisk as removed, don't do anything else. We don't report the deleted snapshot to outside though. --- integration/core/test_cli.py | 6 ++--- integration/core/test_replica.py | 4 ++- replica/replica.go | 45 +++++++++++++++++++++++++++++--- replica/replica_test.go | 2 ++ replica/rest/model.go | 2 +- sync/sync.go | 12 ++++++--- 6 files changed, 58 insertions(+), 13 deletions(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 9f0e2f89..6e440373 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -361,9 +361,9 @@ def test_snapshot_last(bin, controller_client, replica_client, assert chain[0] == 'volume-head-001.img' assert chain[1] == 'volume-snap-{}.img'.format(output) - cmd = [bin, 'snapshot', 'rm', output] - with pytest.raises(subprocess.CalledProcessError): - subprocess.check_call(cmd) + # cmd = [bin, 'snapshot', 'rm', output] + # with pytest.raises(subprocess.CalledProcessError): + # subprocess.check_call(cmd) def test_backup(bin, controller_client, replica_client, diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index e61b7bf0..2c9778c8 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -167,7 +167,9 @@ def test_remove_disk(client): assert r.size == str(1024*4096) assert r.sectorSize == 512 assert r.head == 'volume-head-002.img' - assert r.parent == 'volume-snap-000.img' + # TODO Fix this after done + # assert r.parent == 'volume-snap-000.img' + assert r.parent == 'volume-snap-001.img' assert r.chain == ['volume-head-002.img', 'volume-snap-000.img'] diff --git a/replica/replica.go b/replica/replica.go index 3daa0b0f..19398818 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -51,8 +51,9 @@ type Info struct { } type disk struct { - name string - Parent string + name string + Parent string + Removed bool } type BackingFile struct { @@ -211,6 +212,7 @@ func (r *Replica) RemoveDiffDisk(name string) error { return fmt.Errorf("Can not delete the active differencing disk") } + /* don't update the chain, we just don't want to show it if err := r.relinkChild(index); err != nil { return err } @@ -225,8 +227,9 @@ func (r *Replica) RemoveDiffDisk(name string) error { r.activeDiskData = append(r.activeDiskData[:index], r.activeDiskData[index+1:]...) delete(r.diskData, name) + */ - if err := r.rmDisk(name); err != nil { + if err := r.markDiskAsRemoved(name); err != nil { // ignore error deleting files logrus.Errorf("Failed to delete %s: %v", name, err) } @@ -238,6 +241,24 @@ func (r *Replica) Info() Info { return r.info } +func (r *Replica) DisplayChain() ([]string, error) { + result := make([]string, 0, len(r.activeDiskData)) + + cur := r.info.Head + for cur != "" { + disk, ok := r.diskData[cur] + if !ok { + return nil, fmt.Errorf("Failed to find metadata for %s", cur) + } + if !disk.Removed { + result = append(result, cur) + } + cur = r.diskData[cur].Parent + } + + return result, nil +} + func (r *Replica) Chain() ([]string, error) { result := make([]string, 0, len(r.activeDiskData)) @@ -341,7 +362,7 @@ func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, e return nil, disk{}, err } - newDisk := disk{Parent: parent, name: newHeadName} + newDisk := disk{Parent: parent, name: newHeadName, Removed: false} err = r.encodeToFile(&newDisk, newHeadName+metadataSuffix) return f, newDisk, err } @@ -366,6 +387,22 @@ func (r *Replica) linkDisk(oldname, newname string) error { return os.Link(r.diskPath(oldname+metadataSuffix), r.diskPath(newname+metadataSuffix)) } +func (r *Replica) markDiskAsRemoved(name string) error { + disk, ok := r.diskData[name] + if !ok { + return fmt.Errorf("Cannot find disk %v", name) + } + if stat, err := os.Stat(r.diskPath(name)); err != nil || stat.IsDir() { + return fmt.Errorf("Cannot find disk file %v", name) + } + if stat, err := os.Stat(r.diskPath(name + metadataSuffix)); err != nil || stat.IsDir() { + return fmt.Errorf("Cannot find disk metafile %v", name+metadataSuffix) + } + disk.Removed = true + r.diskData[name] = disk + return r.encodeToFile(disk, name+metadataSuffix) +} + func (r *Replica) rmDisk(name string) error { if name == "" { return nil diff --git a/replica/replica_test.go b/replica/replica_test.go index aaead8ed..644c16ee 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -95,6 +95,7 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(chain[1], Equals, "volume-snap-000.img") } +/* Disable unit test until we implement this part correctly func (s *TestSuite) TestRemoveLast(c *C) { dir, err := ioutil.TempDir("", "replica") c.Assert(err, IsNil) @@ -168,6 +169,7 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") } +*/ func (s *TestSuite) TestRemoveFirst(c *C) { dir, err := ioutil.TempDir("", "replica") diff --git a/replica/rest/model.go b/replica/rest/model.go index a986c038..de9fc233 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -99,7 +99,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, r.Size = strconv.FormatInt(info.Size, 10) if rep != nil { - r.Chain, _ = rep.Chain() + r.Chain, _ = rep.DisplayChain() } return r diff --git a/sync/sync.go b/sync/sync.go index b1d83718..4f451fb0 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -35,11 +35,13 @@ func (t *Task) DeleteSnapshot(snapshot string) error { } } - for _, replica := range replicas { - if err := t.coalesceSnapshot(&replica, snapshot); err != nil { - return err + /* + for _, replica := range replicas { + if err := t.coalesceSnapshot(&replica, snapshot); err != nil { + return err + } } - } + */ for _, replica := range replicas { if err := t.rmDisk(&replica, snapshot); err != nil { @@ -61,6 +63,8 @@ func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string) error return err } + //TODO coalescing and backup need to check the location of snapshot, + //so needs index. should be replaced later. disk, _ := getNameAndIndex(replica.Chain, snapshot) return repClient.RemoveDisk(disk) } From 23a3de5622679f6510d4f5b42746d8ddc8afe1a5 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 113/357] replica: Implement children map for all disks Except backing-file and head disk. It will be the easy way to find out how many children one snapshot has. --- replica/replica.go | 47 +++- replica/replica_test.go | 41 +++ trash.yml | 2 + .../github.com/deckarep/golang-set/.gitignore | 22 ++ .../deckarep/golang-set/.travis.yml | 11 + vendor/github.com/deckarep/golang-set/LICENSE | 22 ++ .../github.com/deckarep/golang-set/README.md | 94 +++++++ vendor/github.com/deckarep/golang-set/set.go | 174 +++++++++++++ .../deckarep/golang-set/threadsafe.go | 204 +++++++++++++++ .../deckarep/golang-set/threadunsafe.go | 246 ++++++++++++++++++ 10 files changed, 861 insertions(+), 2 deletions(-) create mode 100644 vendor/github.com/deckarep/golang-set/.gitignore create mode 100644 vendor/github.com/deckarep/golang-set/.travis.yml create mode 100644 vendor/github.com/deckarep/golang-set/LICENSE create mode 100644 vendor/github.com/deckarep/golang-set/README.md create mode 100644 vendor/github.com/deckarep/golang-set/set.go create mode 100644 vendor/github.com/deckarep/golang-set/threadsafe.go create mode 100644 vendor/github.com/deckarep/golang-set/threadunsafe.go diff --git a/replica/replica.go b/replica/replica.go index 19398818..344d6401 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -13,6 +13,7 @@ import ( "syscall" "github.com/Sirupsen/logrus" + "github.com/deckarep/golang-set" "github.com/rancher/longhorn/types" ) @@ -35,6 +36,7 @@ type Replica struct { dir string info Info diskData map[string]disk + diskChildMap map[string]mapset.Set activeDiskData []disk readOnly bool } @@ -91,6 +93,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF dir: dir, activeDiskData: make([]disk, 1), diskData: map[string]disk{}, + diskChildMap: map[string]mapset.Set{}, } r.info.Size = size r.info.SectorSize = sectorSize @@ -437,12 +440,13 @@ func (r *Replica) revertDisk(parent string) (*Replica, error) { return nil, err } + // Need to execute before r.Reload() to update r.diskChildMap + r.rmDisk(oldHead) + rNew, err := r.Reload() if err != nil { return nil, err } - - r.rmDisk(oldHead) return rNew, nil } @@ -489,7 +493,10 @@ func (r *Replica) createDisk(name string) error { done = true r.diskData[newHeadDisk.name] = newHeadDisk if newHeadDisk.Parent != "" { + r.addChildDisk(newHeadDisk.Parent, newHeadDisk.name) + r.diskData[newHeadDisk.Parent] = r.diskData[oldHead] + r.updateChildDisk(oldHead, newHeadDisk.Parent) r.activeDiskData[len(r.activeDiskData)-1].name = newHeadDisk.Parent } delete(r.diskData, oldHead) @@ -501,7 +508,40 @@ func (r *Replica) createDisk(name string) error { return nil } +func (r *Replica) addChildDisk(parent, child string) { + children, exists := r.diskChildMap[parent] + if !exists { + children = mapset.NewSet() + } + children.Add(child) + r.diskChildMap[parent] = children +} + +func (r *Replica) rmChildDisk(parent, child string) { + children, exists := r.diskChildMap[parent] + if !exists { + return + } + if !children.Contains(child) { + return + } + children.Remove(child) + if children.Cardinality() == 0 { + delete(r.diskChildMap, parent) + return + } + r.diskChildMap[parent] = children +} + +func (r *Replica) updateChildDisk(oldName, newName string) { + parent := r.diskData[oldName].Parent + r.rmChildDisk(parent, oldName) + r.addChildDisk(parent, newName) +} + func (r *Replica) openFiles() error { + // We have live chain, which will be included here + // We also need to scan all other disks, and track them properly chain, err := r.Chain() if err != nil { return err @@ -557,6 +597,9 @@ func (r *Replica) readDiskData(file string) error { name := file[:len(file)-len(metadataSuffix)] data.name = name r.diskData[name] = data + if data.Parent != "" { + r.addChildDisk(data.Parent, data.name) + } return nil } diff --git a/replica/replica_test.go b/replica/replica_test.go index 644c16ee..dfcdbfbd 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -58,6 +58,14 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRevert(c *C) { @@ -93,6 +101,39 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(len(chain), Equals, 2) c.Assert(chain[0], Equals, "volume-head-003.img") c.Assert(chain[1], Equals, "volume-snap-000.img") + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-003.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) + c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) + c.Assert(r.diskChildMap["volume-head-003.img"], IsNil) + + err = r.Snapshot("003") + c.Assert(err, IsNil) + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-003.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildMap["volume-snap-003.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-003.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-003.img"].Cardinality(), Equals, 1) + + r, err = r.Revert("volume-snap-001.img") + c.Assert(err, IsNil) + + chain, err = r.Chain() + c.Assert(err, IsNil) + c.Assert(len(chain), Equals, 3) + c.Assert(chain[0], Equals, "volume-head-005.img") + c.Assert(chain[1], Equals, "volume-snap-001.img") + c.Assert(chain[2], Equals, "volume-snap-000.img") + + c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-005.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-snap-003.img"], IsNil) } /* Disable unit test until we implement this part correctly diff --git a/trash.yml b/trash.yml index a24ac9b3..da891276 100644 --- a/trash.yml +++ b/trash.yml @@ -56,3 +56,5 @@ import: version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 - package: github.com/jmespath/go-jmespath version: c01cf91b011868172fdcd9f41838e80c9d716264 +- package: github.com/deckarep/golang-set + version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 diff --git a/vendor/github.com/deckarep/golang-set/.gitignore b/vendor/github.com/deckarep/golang-set/.gitignore new file mode 100644 index 00000000..00268614 --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/.gitignore @@ -0,0 +1,22 @@ +# 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 diff --git a/vendor/github.com/deckarep/golang-set/.travis.yml b/vendor/github.com/deckarep/golang-set/.travis.yml new file mode 100644 index 00000000..48d5a91e --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/.travis.yml @@ -0,0 +1,11 @@ +language: go + +go: + - 1.2 + - 1.3 + - tip + +script: + - go test -race ./... + - go test -bench=. + diff --git a/vendor/github.com/deckarep/golang-set/LICENSE b/vendor/github.com/deckarep/golang-set/LICENSE new file mode 100644 index 00000000..b5768f89 --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/LICENSE @@ -0,0 +1,22 @@ +Open Source Initiative OSI - The MIT License (MIT):Licensing + +The MIT License (MIT) +Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) + +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/deckarep/golang-set/README.md b/vendor/github.com/deckarep/golang-set/README.md new file mode 100644 index 00000000..564d904f --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/README.md @@ -0,0 +1,94 @@ +[![Build Status](https://travis-ci.org/deckarep/golang-set.png?branch=master)](https://travis-ci.org/deckarep/golang-set) +[![GoDoc](https://godoc.org/github.com/deckarep/golang-set?status.png)](http://godoc.org/github.com/deckarep/golang-set) + +## golang-set + + +The missing set collection for the Go language. Until Go has sets built-in...use this. + +Coming from Python one of the things I miss is the superbly wonderful set collection. This is my attempt to mimic the primary features of the set from Python. +You can of course argue that there is no need for a set in Go, otherwise the creators would have added one to the standard library. To those I say simply ignore this repository +and carry-on and to the rest that find this useful please contribute in helping me make it better by: + +* Helping to make more idiomatic improvements to the code. +* Helping to increase the performance of it. ~~(So far, no attempt has been made, but since it uses a map internally, I expect it to be mostly performant.)~~ +* Helping to make the unit-tests more robust and kick-ass. +* Helping to fill in the [documentation.](http://godoc.org/github.com/deckarep/golang-set) +* Simply offering feedback and suggestions. (Positive, constructive feedback is appreciated.) + +I have to give some credit for helping seed the idea with this post on [stackoverflow.](http://programmers.stackexchange.com/questions/177428/sets-data-structure-in-golang) + +*Update* - as of 3/9/2014, you can use a compile-time generic version of this package in the [gen](http://clipperhouse.github.io/gen/) framework. This framework allows you to use the golang-set in a completely generic and type-safe way by allowing you to generate a supporting .go file based on your custom types. + +## Features (as of 9/22/2014) + +* a CartesianProduct() method has been added with unit-tests: [Read more about the cartesian product](http://en.wikipedia.org/wiki/Cartesian_product) + +## Features (as of 9/15/2014) + +* a PowerSet() method has been added with unit-tests: [Read more about the Power set](http://en.wikipedia.org/wiki/Power_set) + +## Features (as of 4/22/2014) + +* One common interface to both implementations +* Two set implementations to choose from + * a thread-safe implementation designed for concurrent use + * a non-thread-safe implementation designed for performance +* 75 benchmarks for both implementations +* 35 unit tests for both implementations +* 14 concurrent tests for the thread-safe implementation + + + +Please see the unit test file for additional usage examples. The Python set documentation will also do a better job than I can of explaining how a set typically [works.](http://docs.python.org/2/library/sets.html) Please keep in mind +however that the Python set is a built-in type and supports additional features and syntax that make it awesome. + +## Examples but not exhaustive: + +```go +requiredClasses := mapset.NewSet() +requiredClasses.Add("Cooking") +requiredClasses.Add("English") +requiredClasses.Add("Math") +requiredClasses.Add("Biology") + +scienceSlice := []interface{}{"Biology", "Chemistry"} +scienceClasses := mapset.NewSetFromSlice(scienceSlice) + +electiveClasses := mapset.NewSet() +electiveClasses.Add("Welding") +electiveClasses.Add("Music") +electiveClasses.Add("Automotive") + +bonusClasses := mapset.NewSet() +bonusClasses.Add("Go Programming") +bonusClasses.Add("Python Programming") + +//Show me all the available classes I can take +allClasses := requiredClasses.Union(scienceClasses).Union(electiveClasses).Union(bonusClasses) +fmt.Println(allClasses) //Set{Cooking, English, Math, Chemistry, Welding, Biology, Music, Automotive, Go Programming, Python Programming} + + +//Is cooking considered a science class? +fmt.Println(scienceClasses.Contains("Cooking")) //false + +//Show me all classes that are not science classes, since I hate science. +fmt.Println(allClasses.Difference(scienceClasses)) //Set{Music, Automotive, Go Programming, Python Programming, Cooking, English, Math, Welding} + +//Which science classes are also required classes? +fmt.Println(scienceClasses.Intersect(requiredClasses)) //Set{Biology} + +//How many bonus classes do you offer? +fmt.Println(bonusClasses.Cardinality()) //2 + +//Do you have the following classes? Welding, Automotive and English? +fmt.Println(allClasses.IsSuperset(mapset.NewSetFromSlice([]interface{}{"Welding", "Automotive", "English"}))) //true +``` + +Thanks! + +-Ralph + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/deckarep/golang-set/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + +[![Analytics](https://ga-beacon.appspot.com/UA-42584447-2/deckarep/golang-set)](https://github.com/igrigorik/ga-beacon) diff --git a/vendor/github.com/deckarep/golang-set/set.go b/vendor/github.com/deckarep/golang-set/set.go new file mode 100644 index 00000000..5d2b0725 --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/set.go @@ -0,0 +1,174 @@ +/* +Open Source Initiative OSI - The MIT License (MIT):Licensing + +The MIT License (MIT) +Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) + +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. +*/ + +// Package mapset implements a simple and generic set collection. +// Items stored within it are unordered and unique. It supports +// typical set operations: membership testing, intersection, union, +// difference, symmetric difference and cloning. +// +// Package mapset provides two implementations. The default +// implementation is safe for concurrent access. There is a non-threadsafe +// implementation which is slightly more performant. +package mapset + +type Set interface { + // Adds an element to the set. Returns whether + // the item was added. + Add(i interface{}) bool + + // Returns the number of elements in the set. + Cardinality() int + + // Removes all elements from the set, leaving + // the emtpy set. + Clear() + + // Returns a clone of the set using the same + // implementation, duplicating all keys. + Clone() Set + + // Returns whether the given items + // are all in the set. + Contains(i ...interface{}) bool + + // Returns the difference between this set + // and other. The returned set will contain + // all elements of this set that are not also + // elements of other. + // + // Note that the argument to Difference + // must be of the same type as the receiver + // of the method. Otherwise, Difference will + // panic. + Difference(other Set) Set + + // Determines if two sets are equal to each + // other. If they have the same cardinality + // and contain the same elements, they are + // considered equal. The order in which + // the elements were added is irrelevant. + // + // Note that the argument to Equal must be + // of the same type as the receiver of the + // method. Otherwise, Equal will panic. + Equal(other Set) bool + + // Returns a new set containing only the elements + // that exist only in both sets. + // + // Note that the argument to Intersect + // must be of the same type as the receiver + // of the method. Otherwise, Intersect will + // panic. + Intersect(other Set) Set + + // Determines if every element in the other set + // is in this set. + // + // Note that the argument to IsSubset + // must be of the same type as the receiver + // of the method. Otherwise, IsSubset will + // panic. + IsSubset(other Set) bool + + // Determines if every element in this set is in + // the other set. + // + // Note that the argument to IsSuperset + // must be of the same type as the receiver + // of the method. Otherwise, IsSuperset will + // panic. + IsSuperset(other Set) bool + + // Returns a channel of elements that you can + // range over. + Iter() <-chan interface{} + + // Remove a single element from the set. + Remove(i interface{}) + + // Provides a convenient string representation + // of the current state of the set. + String() string + + // Returns a new set with all elements which are + // in either this set or the other set but not in both. + // + // Note that the argument to SymmetricDifference + // must be of the same type as the receiver + // of the method. Otherwise, SymmetricDifference + // will panic. + SymmetricDifference(other Set) Set + + // Returns a new set with all elements in both sets. + // + // Note that the argument to Union must be of the + + // same type as the receiver of the method. + // Otherwise, IsSuperset will panic. + Union(other Set) Set + + // Returns all subsets of a given set (Power Set). + PowerSet() Set + + // Returns the Cartesian Product of two sets. + CartesianProduct(other Set) Set + + // Returns the members of the set as a slice. + ToSlice() []interface{} +} + +// Creates and returns a reference to an empty set. +func NewSet(s ...interface{}) Set { + set := newThreadSafeSet() + for _, item := range s { + set.Add(item) + } + return &set +} + +// Creates and returns a new set with the given elements +func NewSetWith(elts ...interface{}) Set { + return NewSetFromSlice(elts) +} + +// Creates and returns a reference to a set from an existing slice +func NewSetFromSlice(s []interface{}) Set { + a := NewSet(s...) + return a +} + +func NewThreadUnsafeSet() Set { + set := newThreadUnsafeSet() + return &set +} + +func NewThreadUnsafeSetFromSlice(s []interface{}) Set { + a := NewThreadUnsafeSet() + for _, item := range s { + a.Add(item) + } + return a +} diff --git a/vendor/github.com/deckarep/golang-set/threadsafe.go b/vendor/github.com/deckarep/golang-set/threadsafe.go new file mode 100644 index 00000000..9dca94af --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/threadsafe.go @@ -0,0 +1,204 @@ +/* +Open Source Initiative OSI - The MIT License (MIT):Licensing + +The MIT License (MIT) +Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) + +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. +*/ + +package mapset + +import "sync" + +type threadSafeSet struct { + s threadUnsafeSet + sync.RWMutex +} + +func newThreadSafeSet() threadSafeSet { + return threadSafeSet{s: newThreadUnsafeSet()} +} + +func (set *threadSafeSet) Add(i interface{}) bool { + set.Lock() + ret := set.s.Add(i) + set.Unlock() + return ret +} + +func (set *threadSafeSet) Contains(i ...interface{}) bool { + set.RLock() + ret := set.s.Contains(i...) + set.RUnlock() + return ret +} + +func (set *threadSafeSet) IsSubset(other Set) bool { + o := other.(*threadSafeSet) + + set.RLock() + o.RLock() + + ret := set.s.IsSubset(&o.s) + set.RUnlock() + o.RUnlock() + return ret +} + +func (set *threadSafeSet) IsSuperset(other Set) bool { + return other.IsSubset(set) +} + +func (set *threadSafeSet) Union(other Set) Set { + o := other.(*threadSafeSet) + + set.RLock() + o.RLock() + + unsafeUnion := set.s.Union(&o.s).(*threadUnsafeSet) + ret := &threadSafeSet{s: *unsafeUnion} + set.RUnlock() + o.RUnlock() + return ret +} + +func (set *threadSafeSet) Intersect(other Set) Set { + o := other.(*threadSafeSet) + + set.RLock() + o.RLock() + + unsafeIntersection := set.s.Intersect(&o.s).(*threadUnsafeSet) + ret := &threadSafeSet{s: *unsafeIntersection} + set.RUnlock() + o.RUnlock() + return ret +} + +func (set *threadSafeSet) Difference(other Set) Set { + o := other.(*threadSafeSet) + + set.RLock() + o.RLock() + + unsafeDifference := set.s.Difference(&o.s).(*threadUnsafeSet) + ret := &threadSafeSet{s: *unsafeDifference} + set.RUnlock() + o.RUnlock() + return ret +} + +func (set *threadSafeSet) SymmetricDifference(other Set) Set { + o := other.(*threadSafeSet) + + unsafeDifference := set.s.SymmetricDifference(&o.s).(*threadUnsafeSet) + return &threadSafeSet{s: *unsafeDifference} +} + +func (set *threadSafeSet) Clear() { + set.Lock() + set.s = newThreadUnsafeSet() + set.Unlock() +} + +func (set *threadSafeSet) Remove(i interface{}) { + set.Lock() + delete(set.s, i) + set.Unlock() +} + +func (set *threadSafeSet) Cardinality() int { + set.RLock() + defer set.RUnlock() + return len(set.s) +} + +func (set *threadSafeSet) Iter() <-chan interface{} { + ch := make(chan interface{}) + go func() { + set.RLock() + + for elem := range set.s { + ch <- elem + } + close(ch) + set.RUnlock() + }() + + return ch +} + +func (set *threadSafeSet) Equal(other Set) bool { + o := other.(*threadSafeSet) + + set.RLock() + o.RLock() + + ret := set.s.Equal(&o.s) + set.RUnlock() + o.RUnlock() + return ret +} + +func (set *threadSafeSet) Clone() Set { + set.RLock() + + unsafeClone := set.s.Clone().(*threadUnsafeSet) + ret := &threadSafeSet{s: *unsafeClone} + set.RUnlock() + return ret +} + +func (set *threadSafeSet) String() string { + set.RLock() + ret := set.s.String() + set.RUnlock() + return ret +} + +func (set *threadSafeSet) PowerSet() Set { + set.RLock() + ret := set.s.PowerSet() + set.RUnlock() + return ret +} + +func (set *threadSafeSet) CartesianProduct(other Set) Set { + o := other.(*threadSafeSet) + + set.RLock() + o.RLock() + + unsafeCartProduct := set.s.CartesianProduct(&o.s).(*threadUnsafeSet) + ret := &threadSafeSet{s: *unsafeCartProduct} + set.RUnlock() + o.RUnlock() + return ret +} + +func (set *threadSafeSet) ToSlice() []interface{} { + set.RLock() + keys := make([]interface{}, 0, set.Cardinality()) + for elem := range set.s { + keys = append(keys, elem) + } + set.RUnlock() + return keys +} diff --git a/vendor/github.com/deckarep/golang-set/threadunsafe.go b/vendor/github.com/deckarep/golang-set/threadunsafe.go new file mode 100644 index 00000000..124521e2 --- /dev/null +++ b/vendor/github.com/deckarep/golang-set/threadunsafe.go @@ -0,0 +1,246 @@ +/* +Open Source Initiative OSI - The MIT License (MIT):Licensing + +The MIT License (MIT) +Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) + +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. +*/ + +package mapset + +import ( + "fmt" + "reflect" + "strings" +) + +type threadUnsafeSet map[interface{}]struct{} + +type orderedPair struct { + first interface{} + second interface{} +} + +func newThreadUnsafeSet() threadUnsafeSet { + return make(threadUnsafeSet) +} + +func (pair *orderedPair) Equal(other orderedPair) bool { + if pair.first == other.first && + pair.second == other.second { + return true + } + + return false +} + +func (set *threadUnsafeSet) Add(i interface{}) bool { + _, found := (*set)[i] + (*set)[i] = struct{}{} + return !found //False if it existed already +} + +func (set *threadUnsafeSet) Contains(i ...interface{}) bool { + for _, val := range i { + if _, ok := (*set)[val]; !ok { + return false + } + } + return true +} + +func (set *threadUnsafeSet) IsSubset(other Set) bool { + _ = other.(*threadUnsafeSet) + for elem := range *set { + if !other.Contains(elem) { + return false + } + } + return true +} + +func (set *threadUnsafeSet) IsSuperset(other Set) bool { + return other.IsSubset(set) +} + +func (set *threadUnsafeSet) Union(other Set) Set { + o := other.(*threadUnsafeSet) + + unionedSet := newThreadUnsafeSet() + + for elem := range *set { + unionedSet.Add(elem) + } + for elem := range *o { + unionedSet.Add(elem) + } + return &unionedSet +} + +func (set *threadUnsafeSet) Intersect(other Set) Set { + o := other.(*threadUnsafeSet) + + intersection := newThreadUnsafeSet() + // loop over smaller set + if set.Cardinality() < other.Cardinality() { + for elem := range *set { + if other.Contains(elem) { + intersection.Add(elem) + } + } + } else { + for elem := range *o { + if set.Contains(elem) { + intersection.Add(elem) + } + } + } + return &intersection +} + +func (set *threadUnsafeSet) Difference(other Set) Set { + _ = other.(*threadUnsafeSet) + + difference := newThreadUnsafeSet() + for elem := range *set { + if !other.Contains(elem) { + difference.Add(elem) + } + } + return &difference +} + +func (set *threadUnsafeSet) SymmetricDifference(other Set) Set { + _ = other.(*threadUnsafeSet) + + aDiff := set.Difference(other) + bDiff := other.Difference(set) + return aDiff.Union(bDiff) +} + +func (set *threadUnsafeSet) Clear() { + *set = newThreadUnsafeSet() +} + +func (set *threadUnsafeSet) Remove(i interface{}) { + delete(*set, i) +} + +func (set *threadUnsafeSet) Cardinality() int { + return len(*set) +} + +func (set *threadUnsafeSet) Iter() <-chan interface{} { + ch := make(chan interface{}) + go func() { + for elem := range *set { + ch <- elem + } + close(ch) + }() + + return ch +} + +func (set *threadUnsafeSet) Equal(other Set) bool { + _ = other.(*threadUnsafeSet) + + if set.Cardinality() != other.Cardinality() { + return false + } + for elem := range *set { + if !other.Contains(elem) { + return false + } + } + return true +} + +func (set *threadUnsafeSet) Clone() Set { + clonedSet := newThreadUnsafeSet() + for elem := range *set { + clonedSet.Add(elem) + } + return &clonedSet +} + +func (set *threadUnsafeSet) String() string { + items := make([]string, 0, len(*set)) + + for elem := range *set { + items = append(items, fmt.Sprintf("%v", elem)) + } + return fmt.Sprintf("Set{%s}", strings.Join(items, ", ")) +} + +func (pair orderedPair) String() string { + return fmt.Sprintf("(%v, %v)", pair.first, pair.second) +} + +func (set *threadUnsafeSet) PowerSet() Set { + powSet := NewThreadUnsafeSet() + nullset := newThreadUnsafeSet() + powSet.Add(&nullset) + + for es := range *set { + u := newThreadUnsafeSet() + j := powSet.Iter() + for er := range j { + p := newThreadUnsafeSet() + if reflect.TypeOf(er).Name() == "" { + k := er.(*threadUnsafeSet) + for ek := range *(k) { + p.Add(ek) + } + } else { + p.Add(er) + } + p.Add(es) + u.Add(&p) + } + + powSet = powSet.Union(&u) + } + + return powSet +} + +func (set *threadUnsafeSet) CartesianProduct(other Set) Set { + o := other.(*threadUnsafeSet) + cartProduct := NewThreadUnsafeSet() + + for i := range *set { + for j := range *o { + elem := orderedPair{first: i, second: j} + cartProduct.Add(elem) + } + } + + return cartProduct +} + +func (set *threadUnsafeSet) ToSlice() []interface{} { + keys := make([]interface{}, 0, set.Cardinality()) + for elem := range *set { + keys = append(keys, elem) + } + + return keys +} From 6b77213da94867604dbd38c7f1ccaa4397ff82d8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 114/357] replica: if snapshot has no child, we can safely remove it if requested --- replica/replica.go | 22 ++++++++++++++-- replica/replica_test.go | 56 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 344d6401..953c9e79 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -206,6 +206,23 @@ func (r *Replica) RemoveDiffDisk(name string) error { r.Lock() defer r.Unlock() + if name == r.info.Head { + return fmt.Errorf("Can not delete the active differencing disk") + } + + // If snapshot has no child, then we can safely delete it + // And it's definitely not in the live chain + children := r.diskChildMap[name] + if children == nil { + r.updateChildDisk(name, "") + delete(r.diskData, name) + if err := r.rmDisk(name); err != nil { + return err + } + return nil + } + + /* don't update the chain, we just don't want to show it index := r.findDisk(name) if index <= 0 { return nil @@ -215,7 +232,6 @@ func (r *Replica) RemoveDiffDisk(name string) error { return fmt.Errorf("Can not delete the active differencing disk") } - /* don't update the chain, we just don't want to show it if err := r.relinkChild(index); err != nil { return err } @@ -536,7 +552,9 @@ func (r *Replica) rmChildDisk(parent, child string) { func (r *Replica) updateChildDisk(oldName, newName string) { parent := r.diskData[oldName].Parent r.rmChildDisk(parent, oldName) - r.addChildDisk(parent, newName) + if newName != "" { + r.addChildDisk(parent, newName) + } } func (r *Replica) openFiles() error { diff --git a/replica/replica_test.go b/replica/replica_test.go index dfcdbfbd..27e4bd0a 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -136,6 +136,62 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskChildMap["volume-snap-003.img"], IsNil) } +func (s *TestSuite) TestRemoveLeafNode(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot("000") + c.Assert(err, IsNil) + + err = r.Snapshot("001") + c.Assert(err, IsNil) + + err = r.Snapshot("002") + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 5) + c.Assert(len(r.volume.files), Equals, 5) + + c.Assert(r.info.Head, Equals, "volume-head-003.img") + c.Assert(r.activeDiskData[4].name, Equals, "volume-head-003.img") + c.Assert(r.activeDiskData[4].Parent, Equals, "volume-snap-002.img") + c.Assert(r.activeDiskData[3].name, Equals, "volume-snap-002.img") + c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + r, err = r.Revert("volume-snap-000.img") + c.Assert(err, IsNil) + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) + + err = r.RemoveDiffDisk("volume-snap-002.img") + c.Assert(err, IsNil) + + c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) + + err = r.RemoveDiffDisk("volume-snap-001.img") + c.Assert(err, IsNil) + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) +} + /* Disable unit test until we implement this part correctly func (s *TestSuite) TestRemoveLast(c *C) { dir, err := ioutil.TempDir("", "replica") From d3598e2ef1a788c856da403c6486cf52adf28afe Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 115/357] replica: Add PrepareRemoveDisk in API It will be used to to tell sync-agent what to do when remove snapshot. The removal of snapshot scenario can be fairly complex. Replica has all the knowledge to make the correct decision, but need sync-agent to do the job. --- integration/core/test_replica.py | 22 +++++++++++ replica/client/client.go | 13 +++++++ replica/replica.go | 66 ++++++++++++++++++++++++++++++++ replica/rest/model.go | 19 +++++++++ replica/rest/replica.go | 20 ++++++++++ replica/rest/router.go | 17 ++++---- replica/server.go | 12 ++++++ 7 files changed, 161 insertions(+), 8 deletions(-) diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index 2c9778c8..efbc31d2 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -161,6 +161,20 @@ def test_remove_disk(client): assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] + with pytest.raises(cattle.ApiError) as e: + r.prepareremovedisk(name='003') + assert "Can not find snapshot" in e + + with pytest.raises(cattle.ApiError) as e: + r.prepareremovedisk(name='volume-head-002.img') + assert "Can not delete the active" in e + + ops = r.prepareremovedisk(name='001')["operations"] + assert len(ops) == 1 + assert ops[0].action == "markasremoved" + assert ops[0].source == "volume-snap-001.img" + assert ops[0].target == "" + r = r.removedisk(name='volume-snap-001.img') assert r.state == 'dirty' assert not r.rebuilding @@ -185,6 +199,14 @@ def test_remove_last_disk(client): assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] + ops = r.prepareremovedisk(name='volume-snap-000.img')["operations"] + assert len(ops) == 2 + assert ops[0].action == "coalesce" + assert ops[0].source == "volume-snap-000.img" + assert ops[0].target == "volume-snap-001.img" + assert ops[1].action == "remove" + assert ops[1].source == "volume-snap-000.img" + r = r.removedisk(name='volume-snap-000.img') assert r.state == 'dirty' assert not r.rebuilding diff --git a/replica/client/client.go b/replica/client/client.go index 51306ee9..246b690e 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -119,6 +119,19 @@ func (c *ReplicaClient) RemoveDisk(disk string) error { }, nil) } +func (c *ReplicaClient) PrepareRemoveDisk(disk string) (rest.PrepareRemoveDiskOutput, error) { + var output rest.PrepareRemoveDiskOutput + r, err := c.GetReplica() + if err != nil { + return output, err + } + + err = c.post(r.Actions["prepareremovedisk"], &rest.PrepareRemoveDiskInput{ + Name: disk, + }, &output) + return output, err +} + func (c *ReplicaClient) OpenReplica() error { r, err := c.GetReplica() if err != nil { diff --git a/replica/replica.go b/replica/replica.go index 953c9e79..641f2fa7 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -65,6 +65,18 @@ type BackingFile struct { Disk types.DiffDisk } +type PrepareRemoveAction struct { + Action string `json:"action"` + Source string `json:"source"` + Target string `json:"target"` +} + +const ( + OpCoalesce = "coalesce" // Source is parent, target is child + OpRemove = "remove" + OpMarkAsRemoved = "markasremoved" +) + func ReadInfo(dir string) (Info, error) { var info Info err := (&Replica{dir: dir}).unmarshalFile(volumeMetaData, &info) @@ -256,6 +268,60 @@ func (r *Replica) RemoveDiffDisk(name string) error { return nil } +func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) { + r.Lock() + defer r.Unlock() + + action := []PrepareRemoveAction{} + disk := name + + if _, exists := r.diskData[disk]; !exists { + disk = GenerateSnapshotDiskName(name) + if _, exists := r.diskData[disk]; !exists { + return nil, fmt.Errorf("Can not find snapshot %v", disk) + } + } + + if disk == r.info.Head { + return nil, fmt.Errorf("Can not delete the active differencing disk") + } + + // 1) leaf node + children := r.diskChildMap[disk] + if children == nil { + action = append(action, PrepareRemoveAction{ + Action: OpRemove, + Source: disk, + }) + return action, nil + } + + // 2) has only one child and is not head + if children.Cardinality() == 1 { + child := (<-children.Iter()).(string) + if child != r.info.Head { + action = append(action, + PrepareRemoveAction{ + Action: OpCoalesce, + Source: disk, + Target: child, + }, + PrepareRemoveAction{ + Action: OpRemove, + Source: disk, + }) + return action, nil + } + } + + // 3) for other situation, we only mark it as removed + action = append(action, PrepareRemoveAction{ + Action: OpMarkAsRemoved, + Source: disk, + }) + return action, nil +} + func (r *Replica) Info() Info { return r.info } diff --git a/replica/rest/model.go b/replica/rest/model.go index de9fc233..6dc14e06 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -45,6 +45,16 @@ type RemoveDiskInput struct { Name string `json:"name"` } +type PrepareRemoveDiskInput struct { + client.Resource + Name string `json:"name"` +} + +type PrepareRemoveDiskOutput struct { + client.Resource + Operations []replica.PrepareRemoveAction `json:"operations"` +} + func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, rep *replica.Replica) *Replica { r := &Replica{ Resource: client.Resource{ @@ -68,10 +78,12 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["reload"] = true actions["removedisk"] = true actions["revert"] = true + actions["prepareremovedisk"] = true case replica.Closed: actions["open"] = true actions["removedisk"] = true actions["revert"] = true + actions["prepareremovedisk"] = true case replica.Dirty: actions["setrebuilding"] = true actions["close"] = true @@ -79,6 +91,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["reload"] = true actions["removedisk"] = true actions["revert"] = true + actions["prepareremovedisk"] = true case replica.Rebuilding: actions["snapshot"] = true actions["setrebuilding"] = true @@ -116,6 +129,8 @@ func NewSchema() *client.Schemas { schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("removediskInput", RemoveDiskInput{}) schemas.AddType("revertInput", RevertInput{}) + schemas.AddType("prepareRemoveDiskInput", PrepareRemoveDiskInput{}) + schemas.AddType("prepareRemoveDiskOutput", PrepareRemoveDiskOutput{}) replica := schemas.AddType("replica", Replica{}) replica.ResourceMethods = []string{"GET", "DELETE"} @@ -149,6 +164,10 @@ func NewSchema() *client.Schemas { Input: "revertInput", Output: "replica", }, + "prepareremovedisk": client.Action{ + Input: "prepareRemoveDiskInput", + Output: "prepareRemoveDiskOutput", + }, } return schemas diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 35a0f167..b514bc99 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -89,6 +89,26 @@ func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { return s.doOp(req, s.s.RemoveDiffDisk(input.Name)) } +func (s *Server) PrepareRemoveDisk(rw http.ResponseWriter, req *http.Request) error { + var input PrepareRemoveDiskInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil && err != io.EOF { + return err + } + operations, err := s.s.PrepareRemoveDisk(input.Name) + if err != nil { + return err + } + apiContext.Write(&PrepareRemoveDiskOutput{ + Resource: client.Resource{ + Id: input.Name, + Type: "prepareRemoveDiskOutput", + }, + Operations: operations, + }) + return nil +} + func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) error { var input SnapshotInput apiContext := api.GetApiContext(req) diff --git a/replica/rest/router.go b/replica/rest/router.go index 190911ac..677587b4 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -50,14 +50,15 @@ func NewRouter(s *Server) *mux.Router { // Actions actions := map[string]func(http.ResponseWriter, *http.Request) error{ - "reload": s.ReloadReplica, - "snapshot": s.SnapshotReplica, - "open": s.OpenReplica, - "close": s.CloseReplica, - "removedisk": s.RemoveDisk, - "setrebuilding": s.SetRebuilding, - "create": s.Create, - "revert": s.RevertReplica, + "reload": s.ReloadReplica, + "snapshot": s.SnapshotReplica, + "open": s.OpenReplica, + "close": s.CloseReplica, + "removedisk": s.RemoveDisk, + "setrebuilding": s.SetRebuilding, + "create": s.Create, + "revert": s.RevertReplica, + "prepareremovedisk": s.PrepareRemoveDisk, } for name, action := range actions { diff --git a/replica/server.go b/replica/server.go index 9b7e92e4..698b8e7e 100644 --- a/replica/server.go +++ b/replica/server.go @@ -189,6 +189,18 @@ func (s *Server) RemoveDiffDisk(name string) error { return s.r.RemoveDiffDisk(name) } +func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil, nil + } + + logrus.Infof("Prepare removing disk: %s", name) + return s.r.PrepareRemoveDisk(name) +} + func (s *Server) Delete() error { s.Lock() defer s.Unlock() From 87e336995746a268bd32f7175ee1bbaf2c0f6095 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 116/357] replica: Add MarkOnly option for RemoveDiskInput --- replica/client/client.go | 5 +++-- replica/replica.go | 11 +++++++++-- replica/replica_test.go | 6 +++--- replica/rest/model.go | 3 ++- replica/rest/replica.go | 2 +- replica/server.go | 6 +++--- sync/sync.go | 6 +++--- 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/replica/client/client.go b/replica/client/client.go index 246b690e..fbe47e52 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -108,14 +108,15 @@ func (c *ReplicaClient) SetRebuilding(rebuilding bool) error { }, nil) } -func (c *ReplicaClient) RemoveDisk(disk string) error { +func (c *ReplicaClient) RemoveDisk(disk string, markOnly bool) error { r, err := c.GetReplica() if err != nil { return err } return c.post(r.Actions["removedisk"], &rest.RemoveDiskInput{ - Name: disk, + Name: disk, + MarkOnly: markOnly, }, nil) } diff --git a/replica/replica.go b/replica/replica.go index 641f2fa7..d481e7dd 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -214,7 +214,7 @@ func (r *Replica) relinkChild(index int) error { return r.encodeToFile(*childData, childData.name+metadataSuffix) } -func (r *Replica) RemoveDiffDisk(name string) error { +func (r *Replica) RemoveDiffDisk(name string, markOnly bool) error { r.Lock() defer r.Unlock() @@ -222,6 +222,14 @@ func (r *Replica) RemoveDiffDisk(name string) error { return fmt.Errorf("Can not delete the active differencing disk") } + if markOnly { + if err := r.markDiskAsRemoved(name); err != nil { + // ignore error deleting files + logrus.Errorf("Failed to delete %s: %v", name, err) + } + return nil + } + // If snapshot has no child, then we can safely delete it // And it's definitely not in the live chain children := r.diskChildMap[name] @@ -264,7 +272,6 @@ func (r *Replica) RemoveDiffDisk(name string) error { // ignore error deleting files logrus.Errorf("Failed to delete %s: %v", name, err) } - return nil } diff --git a/replica/replica_test.go b/replica/replica_test.go index 27e4bd0a..c97c9601 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -179,12 +179,12 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) - err = r.RemoveDiffDisk("volume-snap-002.img") + err = r.RemoveDiffDisk("volume-snap-002.img", false) c.Assert(err, IsNil) c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) - err = r.RemoveDiffDisk("volume-snap-001.img") + err = r.RemoveDiffDisk("volume-snap-001.img", false) c.Assert(err, IsNil) c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) @@ -294,7 +294,7 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - err = r.RemoveDiffDisk("volume-head-002.img") + err = r.RemoveDiffDisk("volume-head-002.img", false) c.Assert(err, Not(IsNil)) } diff --git a/replica/rest/model.go b/replica/rest/model.go index 6dc14e06..4fd7ad98 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -42,7 +42,8 @@ type SnapshotInput struct { type RemoveDiskInput struct { client.Resource - Name string `json:"name"` + Name string `json:"name"` + MarkOnly bool `json:"markonly"` } type PrepareRemoveDiskInput struct { diff --git a/replica/rest/replica.go b/replica/rest/replica.go index b514bc99..9c24b1ff 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -86,7 +86,7 @@ func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { return err } - return s.doOp(req, s.s.RemoveDiffDisk(input.Name)) + return s.doOp(req, s.s.RemoveDiffDisk(input.Name, input.MarkOnly)) } func (s *Server) PrepareRemoveDisk(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/server.go b/replica/server.go index 698b8e7e..98de429b 100644 --- a/replica/server.go +++ b/replica/server.go @@ -177,7 +177,7 @@ func (s *Server) Snapshot(name string) error { return s.r.Snapshot(name) } -func (s *Server) RemoveDiffDisk(name string) error { +func (s *Server) RemoveDiffDisk(name string, markOnly bool) error { s.Lock() defer s.Unlock() @@ -185,8 +185,8 @@ func (s *Server) RemoveDiffDisk(name string) error { return nil } - logrus.Infof("Removing disk: %s", name) - return s.r.RemoveDiffDisk(name) + logrus.Infof("Removing disk: %s, markonly %v", name, markOnly) + return s.r.RemoveDiffDisk(name, markOnly) } func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) { diff --git a/sync/sync.go b/sync/sync.go index 4f451fb0..e750f26d 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -44,7 +44,7 @@ func (t *Task) DeleteSnapshot(snapshot string) error { */ for _, replica := range replicas { - if err := t.rmDisk(&replica, snapshot); err != nil { + if err := t.rmDisk(&replica, snapshot, false); err != nil { return err } } @@ -52,7 +52,7 @@ func (t *Task) DeleteSnapshot(snapshot string) error { return nil } -func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string) error { +func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string, markOnly bool) error { repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return err @@ -66,7 +66,7 @@ func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string) error //TODO coalescing and backup need to check the location of snapshot, //so needs index. should be replaced later. disk, _ := getNameAndIndex(replica.Chain, snapshot) - return repClient.RemoveDisk(disk) + return repClient.RemoveDisk(disk, false) } func getNameAndIndex(chain []string, snapshot string) (string, int) { From b4e4c94419091dfd4c4a0a9f7456e3bf6edc35c3 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 117/357] replica: process coalescing --- integration/core/test_replica.py | 4 +- integration/data/test_snapshot.py | 5 +-- replica/client/client.go | 33 ++++++++++++++++ replica/replica.go | 59 ++++++++++++++++++--------- replica/replica_test.go | 6 +-- sync/agent/process.go | 29 ++++++++++++++ sync/sync.go | 66 ++++++++++++++----------------- 7 files changed, 137 insertions(+), 65 deletions(-) diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index efbc31d2..04bc1b95 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -181,9 +181,7 @@ def test_remove_disk(client): assert r.size == str(1024*4096) assert r.sectorSize == 512 assert r.head == 'volume-head-002.img' - # TODO Fix this after done - # assert r.parent == 'volume-snap-000.img' - assert r.parent == 'volume-snap-001.img' + assert r.parent == 'volume-snap-000.img' assert r.chain == ['volume-head-002.img', 'volume-snap-000.img'] diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index 1fab4598..24757345 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -1,5 +1,3 @@ -import pytest - import cmd import common from common import dev, backing_dev # NOQA @@ -37,8 +35,7 @@ def test_snapshot_revert(dev): # NOQA # TODO BUG: https://github.com/rancher/longhorn/issues/108 -@pytest.mark.xfail(strict=True) # NOQA -def test_snapshot_rm(dev): +def test_snapshot_rm(dev): # NOQA offset = 0 length = 128 diff --git a/replica/client/client.go b/replica/client/client.go index fbe47e52..f6b63657 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -379,3 +379,36 @@ func (c *ReplicaClient) post(path string, req, resp interface{}) error { return json.NewDecoder(httpResp.Body).Decode(resp) } + +func (c *ReplicaClient) HardLink(from, to string) error { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "hardlink", + SrcFile: from, + DestFile: to, + }, &running) + if err != nil { + return err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return nil + default: + return fmt.Errorf("ExitCode: %d", running.ExitCode) + } + } +} diff --git a/replica/replica.go b/replica/replica.go index d481e7dd..aa7697f8 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -230,48 +230,60 @@ func (r *Replica) RemoveDiffDisk(name string, markOnly bool) error { return nil } + if err := r.removeDiskNode(name); err != nil { + return err + } + + if err := r.rmDisk(name); err != nil { + return err + } + + return nil +} + +func (r *Replica) removeDiskNode(name string) error { // If snapshot has no child, then we can safely delete it // And it's definitely not in the live chain children := r.diskChildMap[name] if children == nil { r.updateChildDisk(name, "") delete(r.diskData, name) - if err := r.rmDisk(name); err != nil { - return err - } return nil } - /* don't update the chain, we just don't want to show it + // If snapshot has more than one child, we cannot really delete it + // Caller should call with markOnly=true instead + if children.Cardinality() > 1 { + return fmt.Errorf("Cannot remove snapshot %v with %v children", + name, children.Cardinality()) + } + + // only one child from here + childIter := <-children.Iter() + child := childIter.(string) + r.updateChildDisk(name, child) + /* + if err := r.updateParentDisk(child, name); err != nil { + return err + } + */ + delete(r.diskData, name) + index := r.findDisk(name) if index <= 0 { return nil } - - if len(r.activeDiskData)-1 == index { - return fmt.Errorf("Can not delete the active differencing disk") - } - if err := r.relinkChild(index); err != nil { return err } - if err := r.volume.RemoveIndex(index); err != nil { return err } - if len(r.activeDiskData)-2 == index { r.info.Parent = r.diskData[r.info.Head].Parent } - r.activeDiskData = append(r.activeDiskData[:index], r.activeDiskData[index+1:]...) - delete(r.diskData, name) - */ - if err := r.markDiskAsRemoved(name); err != nil { - // ignore error deleting files - logrus.Errorf("Failed to delete %s: %v", name, err) - } return nil } @@ -630,6 +642,17 @@ func (r *Replica) updateChildDisk(oldName, newName string) { } } +func (r *Replica) updateParentDisk(name, oldParent string) error { + child := r.diskData[name] + if oldParent != "" { + child.Parent = r.diskData[oldParent].Parent + } else { + child.Parent = "" + } + r.diskData[name] = child + return r.encodeToFile(child, child.name+metadataSuffix) +} + func (r *Replica) openFiles() error { // We have live chain, which will be included here // We also need to scan all other disks, and track them properly diff --git a/replica/replica_test.go b/replica/replica_test.go index c97c9601..81cd9c55 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -192,7 +192,6 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) } -/* Disable unit test until we implement this part correctly func (s *TestSuite) TestRemoveLast(c *C) { dir, err := ioutil.TempDir("", "replica") c.Assert(err, IsNil) @@ -219,7 +218,7 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - err = r.RemoveDiffDisk("volume-snap-000.img") + err = r.RemoveDiffDisk("volume-snap-000.img", false) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) @@ -256,7 +255,7 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - err = r.RemoveDiffDisk("volume-snap-001.img") + err = r.RemoveDiffDisk("volume-snap-001.img", false) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) @@ -266,7 +265,6 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") } -*/ func (s *TestSuite) TestRemoveFirst(c *C) { dir, err := ioutil.TempDir("", "replica") diff --git a/sync/agent/process.go b/sync/agent/process.go index 2242faed..aa38a96f 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -127,6 +127,8 @@ func (s *Server) launch(p *Process) error { return s.launchRmBackup(p) case "restore": return s.launchRestore(p) + case "hardlink": + return s.launchHardLink(p) } return fmt.Errorf("Unknown process type %s", p.ProcessType) } @@ -326,3 +328,30 @@ func (s *Server) launchRestore(p *Process) error { logrus.Infof("Done running %s %v", "sbackup", cmd.Args) return nil } + +func (s *Server) launchHardLink(p *Process) error { + oldName := p.SrcFile + newName := p.DestFile + + if oldName == "" { + p.ExitCode = 0 + return nil + } + + if _, err := os.Stat(newName); err == nil { + logrus.Infof("Old file %s exists, deleting", newName) + if err := os.Remove(newName); err != nil { + p.ExitCode = 1 + return err + } + } + + if err := os.Link(oldName, newName); err != nil { + p.ExitCode = 1 + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v %v", "hardlink", oldName, newName) + return nil +} diff --git a/sync/sync.go b/sync/sync.go index e750f26d..e2f7441b 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -8,6 +8,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/controller/client" "github.com/rancher/longhorn/controller/rest" + "github.com/rancher/longhorn/replica" replicaClient "github.com/rancher/longhorn/replica/client" ) @@ -35,16 +36,8 @@ func (t *Task) DeleteSnapshot(snapshot string) error { } } - /* - for _, replica := range replicas { - if err := t.coalesceSnapshot(&replica, snapshot); err != nil { - return err - } - } - */ - for _, replica := range replicas { - if err := t.rmDisk(&replica, snapshot, false); err != nil { + if err := t.removeSnapshot(&replica, snapshot); err != nil { return err } } @@ -52,21 +45,13 @@ func (t *Task) DeleteSnapshot(snapshot string) error { return nil } -func (t *Task) rmDisk(replicaInController *rest.Replica, snapshot string, markOnly bool) error { +func (t *Task) rmDisk(replicaInController *rest.Replica, disk string, markOnly bool) error { repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return err } - replica, err := repClient.GetReplica() - if err != nil { - return err - } - - //TODO coalescing and backup need to check the location of snapshot, - //so needs index. should be replaced later. - disk, _ := getNameAndIndex(replica.Chain, snapshot) - return repClient.RemoveDisk(disk, false) + return repClient.RemoveDisk(disk, markOnly) } func getNameAndIndex(chain []string, snapshot string) (string, int) { @@ -97,7 +82,7 @@ func (t *Task) isRebuilding(replicaInController *rest.Replica) (bool, error) { return replica.Rebuilding, nil } -func (t *Task) coalesceSnapshot(replicaInController *rest.Replica, snapshot string) error { +func (t *Task) removeSnapshot(replicaInController *rest.Replica, snapshot string) error { if replicaInController.Mode != "RW" { return fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) } @@ -107,28 +92,37 @@ func (t *Task) coalesceSnapshot(replicaInController *rest.Replica, snapshot stri return err } - replica, err := repClient.GetReplica() + output, err := repClient.PrepareRemoveDisk(snapshot) if err != nil { return err } - _, index := getNameAndIndex(replica.Chain, snapshot) - - switch { - case index < 0: - return fmt.Errorf("Snapshot %s not found on replica %s", snapshot, replicaInController.Address) - case index == 0: - return fmt.Errorf("Can not remove the head disk in the chain") - case index >= len(replica.Chain)-1: - return fmt.Errorf("Can not remove the last disk in the chain") + for _, op := range output.Operations { + switch op.Action { + case replica.OpRemove: + logrus.Infof("Removing %s on %s", op.Source, replicaInController.Address) + if err := t.rmDisk(replicaInController, op.Source, false); err != nil { + return err + } + case replica.OpMarkAsRemoved: + logrus.Infof("Marking %v as removed on %v", op.Source, replicaInController.Address) + if err := t.rmDisk(replicaInController, op.Source, true); err != nil { + return err + } + case replica.OpCoalesce: + logrus.Infof("Coalescing %v to %v on %v", op.Target, op.Source, replicaInController.Address) + if err = repClient.Coalesce(op.Target, op.Source); err != nil { + logrus.Errorf("Failed to coalesce %s on %s: %v", snapshot, replicaInController.Address, err) + return err + } + logrus.Infof("Hard-link %v to %v on %v", op.Source, op.Target, replicaInController.Address) + if err = repClient.HardLink(op.Source, op.Target); err != nil { + logrus.Errorf("Failed to hard-link %v to %v on %v", op.Source, op.Target, replicaInController.Address) + return err + } + } } - logrus.Infof("Coalescing %s on %s", snapshot, replicaInController.Address) - err = repClient.Coalesce(replica.Chain[index], replica.Chain[index+1]) - if err != nil { - logrus.Errorf("Failed to coalesce %s on %s: %v", snapshot, replicaInController.Address, err) - return err - } return nil } From 396f15468d85e736e83fce6252fcdb65085ef1eb Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 118/357] replica: use same object instance for activeDiskData and diskData We don't want to maintain two sets of same data. We will regard diskData as the persistent one. --- integration/core/test_cli.py | 6 ++--- replica/backup.go | 3 +++ replica/replica.go | 46 +++++++++++++----------------------- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 6e440373..63580f9e 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -361,9 +361,9 @@ def test_snapshot_last(bin, controller_client, replica_client, assert chain[0] == 'volume-head-001.img' assert chain[1] == 'volume-snap-{}.img'.format(output) - # cmd = [bin, 'snapshot', 'rm', output] - # with pytest.raises(subprocess.CalledProcessError): - # subprocess.check_call(cmd) + # it will be marked as removed + cmd = [bin, 'snapshot', 'rm', output] + subprocess.check_call(cmd) def test_backup(bin, controller_client, replica_client, diff --git a/replica/backup.go b/replica/backup.go index 5f6087c4..5ee903e1 100644 --- a/replica/backup.go +++ b/replica/backup.go @@ -165,6 +165,9 @@ func (rb *Backup) findIndex(id string) int { } for i, disk := range rb.replica.activeDiskData { + if i == 0 { + continue + } if disk.name == id { return i } diff --git a/replica/replica.go b/replica/replica.go index aa7697f8..465436cb 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -35,9 +35,9 @@ type Replica struct { volume diffDisk dir string info Info - diskData map[string]disk + diskData map[string]*disk diskChildMap map[string]mapset.Set - activeDiskData []disk + activeDiskData []*disk readOnly bool } @@ -103,8 +103,8 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF r := &Replica{ dir: dir, - activeDiskData: make([]disk, 1), - diskData: map[string]disk{}, + activeDiskData: make([]*disk, 1), + diskData: make(map[string]*disk), diskChildMap: map[string]mapset.Set{}, } r.info.Size = size @@ -170,9 +170,9 @@ func (r *Replica) insertBackingFile() { } d := disk{name: r.info.BackingFile.Name} - r.activeDiskData = append([]disk{disk{}, d}, r.activeDiskData[1:]...) + r.activeDiskData = append([]*disk{&disk{}, &d}, r.activeDiskData[1:]...) r.volume.files = append([]types.DiffDisk{nil, r.info.BackingFile.Disk}, r.volume.files[1:]...) - r.diskData[d.name] = d + r.diskData[d.name] = &d } func (r *Replica) SetRebuilding(rebuilding bool) error { @@ -195,6 +195,9 @@ func (r *Replica) Reload() (*Replica, error) { func (r *Replica) findDisk(name string) int { for i, d := range r.activeDiskData { + if i == 0 { + continue + } if d.name == name { return i } @@ -202,18 +205,6 @@ func (r *Replica) findDisk(name string) int { return 0 } -func (r *Replica) relinkChild(index int) error { - childData := &r.activeDiskData[index+1] - if index == 1 { - childData.Parent = "" - } else { - childData.Parent = r.activeDiskData[index-1].name - } - - r.diskData[childData.name] = *childData - return r.encodeToFile(*childData, childData.name+metadataSuffix) -} - func (r *Replica) RemoveDiffDisk(name string, markOnly bool) error { r.Lock() defer r.Unlock() @@ -262,20 +253,15 @@ func (r *Replica) removeDiskNode(name string) error { childIter := <-children.Iter() child := childIter.(string) r.updateChildDisk(name, child) - /* - if err := r.updateParentDisk(child, name); err != nil { - return err - } - */ + if err := r.updateParentDisk(child, name); err != nil { + return err + } delete(r.diskData, name) index := r.findDisk(name) if index <= 0 { return nil } - if err := r.relinkChild(index); err != nil { - return err - } if err := r.volume.RemoveIndex(index); err != nil { return err } @@ -592,7 +578,7 @@ func (r *Replica) createDisk(name string) error { } done = true - r.diskData[newHeadDisk.name] = newHeadDisk + r.diskData[newHeadDisk.name] = &newHeadDisk if newHeadDisk.Parent != "" { r.addChildDisk(newHeadDisk.Parent, newHeadDisk.name) @@ -604,7 +590,7 @@ func (r *Replica) createDisk(name string) error { r.info = info r.volume.files = append(r.volume.files, f) - r.activeDiskData = append(r.activeDiskData, newHeadDisk) + r.activeDiskData = append(r.activeDiskData, &newHeadDisk) return nil } @@ -676,7 +662,7 @@ func (r *Replica) openFiles() error { } func (r *Replica) readMetadata() (bool, error) { - r.diskData = map[string]disk{} + r.diskData = make(map[string]*disk) files, err := ioutil.ReadDir(r.dir) if os.IsNotExist(err) { @@ -710,7 +696,7 @@ func (r *Replica) readDiskData(file string) error { name := file[:len(file)-len(metadataSuffix)] data.name = name - r.diskData[name] = data + r.diskData[name] = &data if data.Parent != "" { r.addChildDisk(data.Parent, data.name) } From 12b5cd7212d699637ceafc0ccd6489358182cd6e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 11 Jun 2016 11:03:16 -0700 Subject: [PATCH 119/357] replica: More test cases 1. More for diskdata 2. Test removal not in chain --- integration/core/test_replica.py | 2 + integration/data/test_snapshot.py | 2 +- replica/replica_test.go | 145 +++++++++++++++++++++++++++++- 3 files changed, 145 insertions(+), 4 deletions(-) diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index 04bc1b95..5974d58f 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -222,7 +222,9 @@ def test_reload(client): r = replicas[0] r = r.create(size=str(1024*4096)) r = r.open() + assert r.chain == ['volume-head-000.img'] r = r.snapshot(name='000') + assert r.chain == ['volume-head-001.img', 'volume-snap-000.img'] r = r.snapshot(name='001') assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index 24757345..9c2e367f 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -34,7 +34,7 @@ def test_snapshot_revert(dev): # NOQA assert readed == snap1_data -# TODO BUG: https://github.com/rancher/longhorn/issues/108 +# BUG: https://github.com/rancher/longhorn/issues/108 def test_snapshot_rm(dev): # NOQA offset = 0 length = 128 diff --git a/replica/replica_test.go b/replica/replica_test.go index 81cd9c55..be3e38a2 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -59,6 +59,11 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") + c.Assert(len(r.diskData), Equals, 3) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) @@ -102,23 +107,35 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(chain[0], Equals, "volume-head-003.img") c.Assert(chain[1], Equals, "volume-snap-000.img") + c.Assert(len(r.diskData), Equals, 3) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-head-003.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-003.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) c.Assert(r.diskChildMap["volume-head-003.img"], IsNil) err = r.Snapshot("003") c.Assert(err, IsNil) + + c.Assert(len(r.diskData), Equals, 4) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-003.img") + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-003.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) c.Assert(r.diskChildMap["volume-snap-003.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-003.img"].Contains("volume-head-004.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-003.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-snap-003.img"].Contains("volume-head-004.img"), Equals, true) r, err = r.Revert("volume-snap-001.img") c.Assert(err, IsNil) @@ -130,6 +147,12 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(chain[1], Equals, "volume-snap-001.img") c.Assert(chain[2], Equals, "volume-snap-000.img") + c.Assert(len(r.diskData), Equals, 4) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-head-005.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-005.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) @@ -167,9 +190,21 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") + c.Assert(len(r.diskData), Equals, 4) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(r.diskData["volume-head-003.img"].Parent, Equals, "volume-snap-002.img") + r, err = r.Revert("volume-snap-000.img") c.Assert(err, IsNil) + c.Assert(len(r.diskData), Equals, 4) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) @@ -182,11 +217,20 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { err = r.RemoveDiffDisk("volume-snap-002.img", false) c.Assert(err, IsNil) + c.Assert(len(r.diskData), Equals, 3) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) err = r.RemoveDiffDisk("volume-snap-001.img", false) c.Assert(err, IsNil) + c.Assert(len(r.diskData), Equals, 2) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) @@ -227,6 +271,15 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") + + c.Assert(len(r.diskData), Equals, 2) + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") + + c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRemoveMiddle(c *C) { @@ -264,6 +317,15 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") + + c.Assert(len(r.diskData), Equals, 2) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-000.img") + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-002.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRemoveFirst(c *C) { @@ -296,6 +358,83 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, Not(IsNil)) } +func (s *TestSuite) TestRemoveOutOfChain(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot("000") + c.Assert(err, IsNil) + + err = r.Snapshot("001") + c.Assert(err, IsNil) + + err = r.Snapshot("002") + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 5) + c.Assert(len(r.volume.files), Equals, 5) + + c.Assert(r.info.Head, Equals, "volume-head-003.img") + c.Assert(r.activeDiskData[4].name, Equals, "volume-head-003.img") + c.Assert(r.activeDiskData[4].Parent, Equals, "volume-snap-002.img") + c.Assert(r.activeDiskData[3].name, Equals, "volume-snap-002.img") + c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + r, err = r.Revert("volume-snap-000.img") + c.Assert(err, IsNil) + c.Assert(len(r.activeDiskData), Equals, 3) + c.Assert(len(r.volume.files), Equals, 3) + c.Assert(r.info.Head, Equals, "volume-head-004.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-head-004.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + c.Assert(len(r.diskData), Equals, 4) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) + + err = r.RemoveDiffDisk("volume-snap-001.img", false) + c.Assert(err, IsNil) + c.Assert(len(r.activeDiskData), Equals, 3) + c.Assert(len(r.volume.files), Equals, 3) + c.Assert(r.info.Head, Equals, "volume-head-004.img") + c.Assert(r.activeDiskData[2].name, Equals, "volume-head-004.img") + c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Parent, Equals, "") + + c.Assert(len(r.diskData), Equals, 3) + c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-000.img") + + c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) +} + func byteEquals(c *C, expected, obtained []byte) { c.Assert(len(expected), Equals, len(obtained)) From 05e4c8ddd7b4acc37702656bd18dccc9e320f744 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Sat, 11 Jun 2016 16:10:07 -0700 Subject: [PATCH 120/357] Upgrade driver for scheduling fix --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 09c3c8d7..9570d3a4 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout f472ce5e272fdcc8b04d4b6b194133b02f7ebb5c && \ + git checkout a169ebf258f1dbc75cea53515b9422ac7f477123 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From 9f9c5bc5fd1137aff8882064844cc646b1424145 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Sat, 11 Jun 2016 23:36:44 -0700 Subject: [PATCH 121/357] Ensure sync-agent up before adding replica --- agent/controller/controller.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/agent/controller/controller.go b/agent/controller/controller.go index cfca7ca8..a8de658b 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -3,6 +3,7 @@ package controller import ( "fmt" "io/ioutil" + "net" "net/http" "os" "os/exec" @@ -376,12 +377,27 @@ func (c *Controller) addReplicasInMetadata() error { return nil } +func (c *Controller) testSyncAgent(host string) error { + address := fmt.Sprintf("%v:%v", host, 9504) + conn, err := net.DialTimeout("tcp", address, time.Second*10) + if err != nil { + return err + } + conn.Close() + return nil +} + func (c *Controller) addReplica(r *replica) error { replica, err := r.client.GetReplica() if err != nil { return fmt.Errorf("Error getting replica %v before adding: %v", r.host, err) } + // Ensure sync-agent is up and running + if err := c.testSyncAgent(r.host); err != nil { + return fmt.Errorf("Error while testing sync agent connection: %v", err) + } + if _, ok := replica.Actions["create"]; ok { err := r.client.Create(r.size) if err != nil { From 11de5b7a7f200ac61f083d25ee1ebf995bbe7687 Mon Sep 17 00:00:00 2001 From: Kirill Date: Sun, 12 Jun 2016 15:06:52 -0700 Subject: [PATCH 122/357] Ssync: connection timeout=120s; fixed connection error handling (#154) - ssync might have reported success on connection failure --- trash.yml | 2 +- .../rancher/sparse-tools/cli/ssync/main.go | 2 +- .../rancher/sparse-tools/sparse/client.go | 35 +++++++++---------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/trash.yml b/trash.yml index da891276..5c442e28 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 3bd59725c7305b1c70a470aff82025f3167795ef + version: 5b2050007378c7c0ffb0734299c157a4e81916aa - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go b/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go index 5e75441a..31fe3451 100644 --- a/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go +++ b/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go @@ -16,7 +16,7 @@ func Main() { verbose := flag.Bool("verbose", false, "verbose mode") daemon := flag.Bool("daemon", false, "daemon mode (run on remote host)") port := flag.Int("port", 5000, "optional daemon port") - timeout := flag.Int("timeout", 60, "optional daemon/client timeout (seconds)") + timeout := flag.Int("timeout", 120, "optional daemon/client timeout (seconds)") host := flag.String("host", "", "remote host of (requires running daemon)") flag.Usage = func() { const usage = "sync []" diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client.go b/vendor/github.com/rancher/sparse-tools/sparse/client.go index 4f7bf6ad..e3fd6199 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/client.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/client.go @@ -9,18 +9,15 @@ import ( "bytes" "encoding/binary" + "encoding/gob" + "errors" + "fmt" + "time" fio "github.com/rancher/sparse-tools/directfio" "github.com/rancher/sparse-tools/log" ) -import "encoding/gob" - -import "errors" - -import "fmt" -import "time" - // HashCollsisionError indicates block hash collision type HashCollsisionError struct{} @@ -55,27 +52,27 @@ func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int return } -func syncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int, retry bool) (hashLocal []byte, err error) { - hashLocal = make([]byte, 0) // empty hash for errors +func syncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int, retry bool) ([]byte, error) { file, err := fio.OpenFile(localPath, os.O_RDONLY, 0) if err != nil { log.Error("Failed to open local source file:", localPath) - return + return nil, err } defer file.Close() - size, errSize := file.Seek(0, os.SEEK_END) - if errSize != nil { - log.Error("Failed to get size of local source file:", localPath, errSize) - return + size, err := file.Seek(0, os.SEEK_END) + if err != nil { + log.Error("Failed to get size of local source file:", localPath, err) + return nil, err } SetupFileIO(size%Blocks == 0) conn := connect(addr.Host, strconv.Itoa(int(addr.Port)), timeout) if nil == conn { - log.Error("Failed to connect to", addr) - return + err = fmt.Errorf("Failed to connect to %v", addr) + log.Error(err) + return nil, err } defer conn.Close() @@ -87,7 +84,9 @@ func syncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int binary.PutVarint(salt, time.Now().UnixNano()) status := sendSyncRequest(encoder, decoder, remotePath, size, salt) if !status { - return + err = fmt.Errorf("Sync request to %v failed", remotePath) + log.Error(err) + return nil, err } abortStream := make(chan error) @@ -98,7 +97,7 @@ func syncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int err = loadFileLayout(abortStream, file, layoutStream, errStream) if err != nil { log.Error("Failed to retrieve local file layout:", err) - return + return nil, err } fileStream := make(chan FileInterval, 128) From 90a6c1848d3163dbf2ed07a95be9acaca1ed9c63 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Sun, 12 Jun 2016 13:39:14 -0700 Subject: [PATCH 123/357] Update driver for better timeouts and other fixes --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 9570d3a4..3c63e42b 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout a169ebf258f1dbc75cea53515b9422ac7f477123 && \ + git checkout cf716e0855247fc9d41e8770d3e3044ba5973a99 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From 94cf252d8b3f821d89fe372fbf8d82be85919dc4 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 14 Jun 2016 11:32:56 -0700 Subject: [PATCH 124/357] Update driver for system container label --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 3c63e42b..ffc46132 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout cf716e0855247fc9d41e8770d3e3044ba5973a99 && \ + git checkout abf54f134cc5ca76afdce2d76110606690624b88 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From 210e65c4c90b1eeeed45c9259f6e7f7f0c4c68fb Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 14 Jun 2016 13:40:38 -0700 Subject: [PATCH 125/357] Check backup status before creating --- agent/controller/rest/backup.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/agent/controller/rest/backup.go b/agent/controller/rest/backup.go index e0f5445a..563a9e4e 100644 --- a/agent/controller/rest/backup.go +++ b/agent/controller/rest/backup.go @@ -19,6 +19,7 @@ import ( "github.com/rancher/longhorn/agent/replica/rest" ) +// TODO Add logic to purge old entries from these maps var restoreMutex = &sync.RWMutex{} var restoreMap = make(map[string]*status) @@ -51,6 +52,10 @@ func (s *Server) CreateBackup(rw http.ResponseWriter, req *http.Request) error { return nil } + if status := checkStatus(input.UUID, backupMap, backupMutex); status != nil { + return apiContext.WriteResource(status) + } + if err := prepareBackupTarget(input.BackupTarget); err != nil { return err } @@ -125,6 +130,10 @@ func (s *Server) RestoreFromBackup(rw http.ResponseWriter, req *http.Request) er return nil } + if status := checkStatus(input.UUID, restoreMap, restoreMutex); status != nil { + return apiContext.WriteResource(status) + } + if err := prepareBackupTarget(input.BackupTarget); err != nil { return err } @@ -199,6 +208,12 @@ func (s *Server) GetRestoreStatus(rw http.ResponseWriter, req *http.Request) err return getStatus(restoreMap, restoreMutex, rw, req) } +func checkStatus(id string, statusMap map[string]*status, statusMutex *sync.RWMutex) *status { + statusMutex.RLock() + defer statusMutex.RUnlock() + return statusMap[id] +} + func getStatus(statusMap map[string]*status, statusMutex *sync.RWMutex, rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) id := mux.Vars(req)["id"] From a455ac91ab0f7cbf2ba76d4dfefca61785e76669 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 14 Jun 2016 18:11:37 -0700 Subject: [PATCH 126/357] Fix restore failure --- Dockerfile.dapper | 2 +- agent/controller/rest/backup.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ffc46132..3977dae8 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout abf54f134cc5ca76afdce2d76110606690624b88 && \ + git checkout 5b3d6b4004481a8151c60bed7e6b1471a4960419 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow diff --git a/agent/controller/rest/backup.go b/agent/controller/rest/backup.go index 563a9e4e..c5f6c842 100644 --- a/agent/controller/rest/backup.go +++ b/agent/controller/rest/backup.go @@ -53,6 +53,7 @@ func (s *Server) CreateBackup(rw http.ResponseWriter, req *http.Request) error { } if status := checkStatus(input.UUID, backupMap, backupMutex); status != nil { + logrus.Infof("Found status %v for id %v for backup request.", status, input.UUID) return apiContext.WriteResource(status) } @@ -131,6 +132,7 @@ func (s *Server) RestoreFromBackup(rw http.ResponseWriter, req *http.Request) er } if status := checkStatus(input.UUID, restoreMap, restoreMutex); status != nil { + logrus.Infof("Found status %v for id %v for restore request.", status, input.UUID) return apiContext.WriteResource(status) } @@ -148,11 +150,13 @@ func (s *Server) RestoreFromBackup(rw http.ResponseWriter, req *http.Request) er func restore(uuid, location string) (*status, error) { cmd := exec.Command("longhorn", "backup", "restore", location) + logrus.Infof("Running restore command: %v", cmd.Args) return doStatusBackedCommand(uuid, "restorestatus", cmd, restoreMap, restoreMutex) } func backup(uuid, snapshot, destination string) (*status, error) { cmd := exec.Command("longhorn", "backup", "create", snapshot, "--dest", destination) + logrus.Infof("Running backup command: %v", cmd.Args) return doStatusBackedCommand(uuid, "backupstatus", cmd, backupMap, backupMutex) } @@ -176,9 +180,11 @@ func doStatusBackedCommand(id, resourceType string, command *exec.Cmd, statusMap err := c.Wait() if err != nil { + logrus.Errorf("Error running command %v: %v", command.Args, err) state = "error" message = fmt.Sprintf("Error: %v", err) } else { + logrus.Infof("Command %v completed successfuly.", command.Args) state = "done" message = output.String() } @@ -192,7 +198,7 @@ func doStatusBackedCommand(id, resourceType string, command *exec.Cmd, statusMap status.State = state status.Message = message - restoreMap[id] = status + statusMap[id] = status }(id, command) return status, nil From ed3f96e0a9dc6a8815be5798b8c6184b50ac0905 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 15 Jun 2016 11:33:42 -0700 Subject: [PATCH 127/357] cli: Fix command not found and usage error return 0 This marks several cli error in integration test --- integration/core/test_cli.py | 10 +++++----- integration/data/common.py | 1 + main.go | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 63580f9e..482281f4 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -394,17 +394,17 @@ def test_backup(bin, controller_client, replica_client, assert snapshot2 == 'volume-snap-{}.img'.format(output) - cmd = [bin, 'create', snapshot2, + cmd = [bin, 'backup', 'create', snapshot2, '--dest', "vfs://" + BACKUP_DEST] backup2 = subprocess.check_output(cmd).strip() - cmd = [bin, 'restore', backup1] + cmd = [bin, 'backup', 'restore', backup1] subprocess.check_call(cmd) - cmd = [bin, 'restore', backup2] + cmd = [bin, 'backup', 'restore', backup2] subprocess.check_call(cmd) - cmd = [bin, 'rm', backup1] + cmd = [bin, 'backup', 'rm', backup1] subprocess.check_call(cmd) - cmd = [bin, 'rm', backup2] + cmd = [bin, 'backup', 'rm', backup2] subprocess.check_call(cmd) diff --git a/integration/data/common.py b/integration/data/common.py index 43de5a4c..ba4e9fb1 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -37,6 +37,7 @@ def _base(): @pytest.fixture() def dev(request): + prepare_backup_dir(BACKUP_DIR) controller = controller_client(request) replica = replica_client(request, REPLICA1_SCHEMA) replica2 = replica_client(request, REPLICA2_SCHEMA) diff --git a/main.go b/main.go index 62ef74e1..24d82c28 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "os" "runtime/pprof" @@ -24,6 +25,14 @@ func main() { } } +func cmdNotFound(c *cli.Context, command string) { + panic(fmt.Errorf("Unrecognized command: %s", command)) +} + +func onUsageError(c *cli.Context, err error, isSubcommand bool) error { + panic(fmt.Errorf("Usage error, please check your command")) +} + func longhornCli() { pprofFile := os.Getenv("PPROFILE") if pprofFile != "" { @@ -62,6 +71,8 @@ func longhornCli() { app.BackupCmd(), app.Journal(), } + a.CommandNotFound = cmdNotFound + a.OnUsageError = onUsageError if err := a.Run(os.Args); err != nil { logrus.Fatal(err) From 0ac82f02dd1d4088e90d557213847836fa430e16 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 15 Jun 2016 11:53:02 -0700 Subject: [PATCH 128/357] sync agent: transfer the error message from sbackup to caller --- replica/client/client.go | 9 ++++++--- sync/agent/process.go | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/replica/client/client.go b/replica/client/client.go index f6b63657..0e632972 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -265,7 +265,8 @@ func (c *ReplicaClient) CreateBackup(snapshot, dest, volume string) (string, err case 0: return running.Output, nil default: - return "", fmt.Errorf("ExitCode: %d", running.ExitCode) + return "", fmt.Errorf("ExitCode: %d, output: %v", + running.ExitCode, running.Output) } } } @@ -297,7 +298,8 @@ func (c *ReplicaClient) RmBackup(backup string) error { case 0: return nil default: - return fmt.Errorf("ExitCode: %d", running.ExitCode) + return fmt.Errorf("ExitCode: %d, output: %v", + running.ExitCode, running.Output) } } } @@ -330,7 +332,8 @@ func (c *ReplicaClient) RestoreBackup(backup, snapshotFile string) error { case 0: return nil default: - return fmt.Errorf("ExitCode: %d", running.ExitCode) + return fmt.Errorf("ExitCode: %d, output: %v", + running.ExitCode, running.Output) } } } diff --git a/sync/agent/process.go b/sync/agent/process.go index aa38a96f..3c41c9b3 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -244,13 +244,16 @@ func (s *Server) launchBackup(p *Process) error { Pdeathsig: syscall.SIGKILL, } cmd.Stdout = buf - cmd.Stderr = os.Stderr + cmd.Stderr = os.Stdout if err := cmd.Start(); err != nil { return err } logrus.Infof("Running %s %v", cmd.Path, cmd.Args) err := cmd.Wait() + + p.Output = buf.String() + fmt.Fprintf(os.Stdout, p.Output) if err != nil { logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) p.ExitCode = 1 @@ -264,24 +267,28 @@ func (s *Server) launchBackup(p *Process) error { } p.ExitCode = 0 - p.Output = buf.String() logrus.Infof("Done running %s %v, returns %v", "sbackup", cmd.Args, p.Output) return nil } func (s *Server) launchRmBackup(p *Process) error { + buf := new(bytes.Buffer) + cmd := reexec.Command("sbackup", "delete", p.SrcFile) cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr + cmd.Stdout = buf + cmd.Stderr = os.Stdout if err := cmd.Start(); err != nil { return err } logrus.Infof("Running %s %v", cmd.Path, cmd.Args) err := cmd.Wait() + + p.Output = buf.String() + fmt.Fprintf(os.Stdout, p.Output) if err != nil { logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) p.ExitCode = 1 @@ -300,11 +307,13 @@ func (s *Server) launchRmBackup(p *Process) error { } func (s *Server) launchRestore(p *Process) error { + buf := new(bytes.Buffer) + cmd := reexec.Command("sbackup", "restore", p.SrcFile, "--to", p.DestFile) cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } - cmd.Stdout = os.Stdout + cmd.Stdout = buf cmd.Stderr = os.Stderr if err := cmd.Start(); err != nil { return err @@ -312,6 +321,9 @@ func (s *Server) launchRestore(p *Process) error { logrus.Infof("Running %s %v", cmd.Path, cmd.Args) err := cmd.Wait() + + p.Output = buf.String() + fmt.Fprintf(os.Stdout, p.Output) if err != nil { logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) p.ExitCode = 1 From 6db8252f71a2ec3f3f9fc92cabc24a6e9ceff1e4 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 15 Jun 2016 13:49:51 -0700 Subject: [PATCH 129/357] backup: Don't clean up directory above base directory --- integration/core/test_cli.py | 2 ++ trash.yml | 2 +- vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 482281f4..8bd09f5d 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -408,3 +408,5 @@ def test_backup(bin, controller_client, replica_client, subprocess.check_call(cmd) cmd = [bin, 'backup', 'rm', backup2] subprocess.check_call(cmd) + + assert os.path.exists(BACKUP_DEST) diff --git a/trash.yml b/trash.yml index 5c442e28..332ca570 100644 --- a/trash.yml +++ b/trash.yml @@ -29,7 +29,7 @@ import: - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy - version: 79b2b778af1441227aa2ca707653c48cc2e8632b + version: e06007546b98d850817b1daaf7196c00571ffa52 - package: github.com/mcuadros/go-version version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 - package: golang.org/x/sys/unix diff --git a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go b/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go index 7ca4d337..7a8a299b 100644 --- a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go +++ b/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go @@ -103,6 +103,10 @@ func (v *VfsObjectStoreDriver) Remove(names ...string) error { dir := v.updatePath(name) for i := 0; i < MAX_CLEANUP_LEVEL; i++ { dir = filepath.Dir(dir) + // Don't clean above OBJECTSTORE_BASE + if strings.HasSuffix(dir, objectstore.OBJECTSTORE_BASE) { + break + } // If directory is not empty, then we don't need to continue if err := os.Remove(dir); err != nil { break From 9eefd14be8fd8cc964afbe543066368c29387d80 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 15 Jun 2016 11:33:04 -0700 Subject: [PATCH 130/357] sync: Introduce `longhorn backup inspect` --- app/backup.go | 31 +++++++ backup/main.go | 43 ++-------- integration/core/test_cli.py | 41 +++++++++- integration/data/cmd.py | 6 ++ integration/data/test_backup.py | 35 ++++++++ replica/client/client.go | 34 ++++++++ sync/agent/process.go | 37 +++++++++ sync/backup.go | 48 ++++++++++- vendor/github.com/rancher/convoy/api/const.go | 10 +++ .../github.com/rancher/convoy/api/request.go | 62 ++++++++++++++ .../github.com/rancher/convoy/api/response.go | 82 +++++++++++++++++++ 11 files changed, 390 insertions(+), 39 deletions(-) create mode 100644 vendor/github.com/rancher/convoy/api/const.go create mode 100644 vendor/github.com/rancher/convoy/api/request.go create mode 100644 vendor/github.com/rancher/convoy/api/response.go diff --git a/app/backup.go b/app/backup.go index 4296f6d2..036fe8b6 100644 --- a/app/backup.go +++ b/app/backup.go @@ -16,6 +16,7 @@ func BackupCmd() cli.Command { BackupCreateCmd(), BackupRestoreCmd(), BackupRmCmd(), + BackupInspectCmd(), }, } } @@ -62,6 +63,18 @@ func BackupRestoreCmd() cli.Command { } } +func BackupInspectCmd() cli.Command { + return cli.Command{ + Name: "inspect", + Usage: "inspect a backup: inspect ", + Action: func(c *cli.Context) { + if err := inspectBackup(c); err != nil { + logrus.Fatalf("Error running inspect backup command: %v", err) + } + }, + } +} + func createBackup(c *cli.Context) error { url := c.GlobalString("url") task := sync.NewTask(url) @@ -116,3 +129,21 @@ func restoreBackup(c *cli.Context) error { return nil } + +func inspectBackup(c *cli.Context) error { + url := c.GlobalString("url") + task := sync.NewTask(url) + + backup := c.Args().First() + if backup == "" { + return fmt.Errorf("Missing required parameter backup") + } + + output, err := task.InspectBackup(backup) + if err != nil { + return err + } + fmt.Println(output) + + return nil +} diff --git a/backup/main.go b/backup/main.go index 00a9f8b8..dc5f2d91 100644 --- a/backup/main.go +++ b/backup/main.go @@ -4,13 +4,11 @@ import ( "encoding/json" "fmt" "os" - "runtime" - "runtime/debug" - "strings" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/rancher/convoy/api" "github.com/rancher/convoy/objectstore" "github.com/rancher/convoy/util" "github.com/rancher/longhorn/replica" @@ -77,37 +75,9 @@ var ( } ) -// ResponseLogAndError would log the error before call ResponseError() -func ResponseLogAndError(v interface{}) { - if e, ok := v.(*logrus.Entry); ok { - e.Error(e.Message) - oldFormatter := e.Logger.Formatter - logrus.SetFormatter(&logrus.JSONFormatter{}) - s, err := e.String() - logrus.SetFormatter(oldFormatter) - if err != nil { - fmt.Println(err.Error()) - return - } - // Cosmetic since " would be escaped - fmt.Println(strings.Replace(s, "\"", "'", -1)) - } else { - e, isErr := v.(error) - _, isRuntimeErr := e.(runtime.Error) - if isErr && !isRuntimeErr { - logrus.Errorf(fmt.Sprint(e)) - fmt.Println(fmt.Sprint(e)) - } else { - logrus.Errorf("Caught FATAL error: %s", v) - debug.PrintStack() - fmt.Printf("Caught FATAL error: %s\n", v) - } - } -} - func cleanup() { if r := recover(); r != nil { - ResponseLogAndError(r) + api.ResponseLogAndError(r) os.Exit(1) } } @@ -341,9 +311,12 @@ func doBackupInspect(c *cli.Context) error { info, err := objectstore.GetBackupInfo(backupURL) if err != nil { - return nil + return err } - fmt.Println(info) - + data, err := api.ResponseOutput(info) + if err != nil { + return err + } + fmt.Println(string(data)) return nil } diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 8bd09f5d..72bfc415 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -3,6 +3,7 @@ from os import path import os import subprocess +import json import pytest import cattle @@ -13,6 +14,9 @@ BACKUP_DEST = '/tmp/longhorn-backup' +VOLUME_NAME = 'test-volume' +VOLUME_SIZE = str(4 * 1024 * 1024) # 4M + @pytest.fixture def controller_client(request): @@ -366,8 +370,8 @@ def test_snapshot_last(bin, controller_client, replica_client, subprocess.check_call(cmd) -def test_backup(bin, controller_client, replica_client, - replica_client2): +def test_backup_core(bin, controller_client, replica_client, + replica_client2): open_replica(replica_client) open_replica(replica_client2) @@ -398,6 +402,28 @@ def test_backup(bin, controller_client, replica_client, '--dest', "vfs://" + BACKUP_DEST] backup2 = subprocess.check_output(cmd).strip() + cmd = [bin, 'backup', 'inspect', backup1] + data = subprocess.check_output(cmd) + backup1_info = json.loads(data) + assert backup1_info["BackupURL"] == backup1 + assert backup1_info["VolumeName"] == VOLUME_NAME + assert backup1_info["VolumeSize"] == VOLUME_SIZE + assert backup1_info["SnapshotName"] == snapshot1 + + cmd = [bin, 'backup', 'inspect', backup2] + data = subprocess.check_output(cmd) + backup2_info = json.loads(data) + assert backup2_info["BackupURL"] == backup2 + assert backup2_info["VolumeName"] == VOLUME_NAME + assert backup2_info["VolumeSize"] == VOLUME_SIZE + assert backup2_info["SnapshotName"] == snapshot2 + + cmd = [bin, 'backup', 'inspect', + "vfs:///tmp/longhorn-backup?backup=backup-1234&volume=test-volume"] + with pytest.raises(subprocess.CalledProcessError) as e: + subprocess.check_call(cmd) + assert 'cannot find' in str(e.value) + cmd = [bin, 'backup', 'restore', backup1] subprocess.check_call(cmd) @@ -410,3 +436,14 @@ def test_backup(bin, controller_client, replica_client, subprocess.check_call(cmd) assert os.path.exists(BACKUP_DEST) + + cmd = [bin, 'backup', 'inspect', + "vfs:///tmp/longhorn-backup?backup=backup-1234&volume=test-volume"] + with pytest.raises(subprocess.CalledProcessError) as e: + subprocess.check_call(cmd) + assert 'cannot find' in str(e.value) + + cmd = [bin, 'backup', 'inspect', "xxx"] + with pytest.raises(subprocess.CalledProcessError) as e: + subprocess.check_call(cmd) + assert 'not supported' in str(e.value) diff --git a/integration/data/cmd.py b/integration/data/cmd.py index 69d82589..6c5f2d94 100644 --- a/integration/data/cmd.py +++ b/integration/data/cmd.py @@ -1,3 +1,4 @@ +import json import subprocess from os import path @@ -49,3 +50,8 @@ def backup_rm(backup): def backup_restore(backup): cmd = [_bin(), '--debug', 'backup', 'restore', backup] return subprocess.check_output(cmd).strip() + + +def backup_inspect(backup): + cmd = [_bin(), '--debug', 'backup', 'inspect', backup] + return json.loads(subprocess.check_output(cmd)) diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index 9a070923..0c544dcc 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -7,6 +7,9 @@ from common import dev, backing_dev # NOQA from common import read_dev, read_from_backing_file, BACKUP_DEST +VOLUME_NAME = 'test-volume' +VOLUME_SIZE = str(4 * 1024 * 1024) # 4M + def test_backup(dev): # NOQA offset = 0 @@ -17,18 +20,33 @@ def test_backup(dev): # NOQA snap1 = cmd.snapshot_create() backup1 = cmd.backup_create(snap1, BACKUP_DEST) + backup1_info = cmd.backup_inspect(backup1) + assert backup1_info["BackupURL"] == backup1 + assert backup1_info["VolumeName"] == VOLUME_NAME + assert backup1_info["VolumeSize"] == VOLUME_SIZE + assert snap1 in backup1_info["SnapshotName"] snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2 = cmd.snapshot_create() backup2 = cmd.backup_create(snap2, BACKUP_DEST) + backup2_info = cmd.backup_inspect(backup2) + assert backup2_info["BackupURL"] == backup2 + assert backup2_info["VolumeName"] == VOLUME_NAME + assert backup2_info["VolumeSize"] == VOLUME_SIZE + assert snap2 in backup2_info["SnapshotName"] snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3 = cmd.snapshot_create() backup3 = cmd.backup_create(snap3, BACKUP_DEST) + backup3_info = cmd.backup_inspect(backup3) + assert backup3_info["BackupURL"] == backup3 + assert backup3_info["VolumeName"] == VOLUME_NAME + assert backup3_info["VolumeSize"] == VOLUME_SIZE + assert snap3 in backup3_info["SnapshotName"] cmd.backup_restore(backup3) readed = read_dev(dev, offset, length) @@ -37,6 +55,9 @@ def test_backup(dev): # NOQA cmd.backup_rm(backup3) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup3) + with pytest.raises(subprocess.CalledProcessError) as e: + cmd.backup_inspect(backup3) + assert 'cannot find' in str(e.value) cmd.backup_restore(backup1) readed = read_dev(dev, offset, length) @@ -45,6 +66,9 @@ def test_backup(dev): # NOQA cmd.backup_rm(backup1) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup1) + with pytest.raises(subprocess.CalledProcessError) as e: + cmd.backup_inspect(backup1) + assert 'cannot find' in str(e.value) cmd.backup_restore(backup2) readed = read_dev(dev, offset, length) @@ -53,6 +77,9 @@ def test_backup(dev): # NOQA cmd.backup_rm(backup2) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup2) + with pytest.raises(subprocess.CalledProcessError) as e: + cmd.backup_inspect(backup2) + assert 'cannot find' in str(e.value) def test_backup_with_backing_file(backing_dev): # NOQA @@ -69,6 +96,11 @@ def test_backup_with_backing_file(backing_dev): # NOQA assert before == exists backup0 = cmd.backup_create(snap0, BACKUP_DEST) + backup0_info = cmd.backup_inspect(backup0) + assert backup0_info["BackupURL"] == backup0 + assert backup0_info["VolumeName"] == VOLUME_NAME + assert backup0_info["VolumeSize"] == VOLUME_SIZE + assert snap0 in backup0_info["SnapshotName"] test_backup(dev) @@ -79,6 +111,9 @@ def test_backup_with_backing_file(backing_dev): # NOQA cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup0) + with pytest.raises(subprocess.CalledProcessError) as e: + cmd.backup_inspect(backup0) + assert 'cannot find' in str(e.value) def test_backup_hole_with_backing_file(backing_dev): # NOQA diff --git a/replica/client/client.go b/replica/client/client.go index 0e632972..dc6224fc 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -337,6 +337,40 @@ func (c *ReplicaClient) RestoreBackup(backup, snapshotFile string) error { } } } + +func (c *ReplicaClient) InspectBackup(backup string) (string, error) { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "inspectbackup", + SrcFile: backup, + }, &running) + if err != nil { + return "", err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return "", err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return running.Output, nil + default: + return "", fmt.Errorf("ExitCode: %d, output: %v", + running.ExitCode, running.Output) + } + } +} + func (c *ReplicaClient) get(url string, obj interface{}) error { if !strings.HasPrefix(url, "http") { url = c.address + url diff --git a/sync/agent/process.go b/sync/agent/process.go index 3c41c9b3..80241531 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -127,6 +127,8 @@ func (s *Server) launch(p *Process) error { return s.launchRmBackup(p) case "restore": return s.launchRestore(p) + case "inspectbackup": + return s.launchInspectBackup(p) case "hardlink": return s.launchHardLink(p) } @@ -367,3 +369,38 @@ func (s *Server) launchHardLink(p *Process) error { logrus.Infof("Done running %s %v %v", "hardlink", oldName, newName) return nil } + +func (s *Server) launchInspectBackup(p *Process) error { + buf := new(bytes.Buffer) + + cmd := reexec.Command("sbackup", "inspect", p.SrcFile) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = buf + cmd.Stderr = os.Stderr + if err := cmd.Start(); err != nil { + return err + } + + logrus.Infof("Running %s %v", cmd.Path, cmd.Args) + err := cmd.Wait() + + p.Output = buf.String() + fmt.Fprintf(os.Stdout, p.Output) + if err != nil { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v", "sbackup", cmd.Args) + return nil +} diff --git a/sync/backup.go b/sync/backup.go index 91bc9a80..4c32506e 100644 --- a/sync/backup.go +++ b/sync/backup.go @@ -101,7 +101,7 @@ func (t *Task) RmBackup(backup string) error { func (t *Task) rmBackup(replicaInController *rest.Replica, backup string) error { if replicaInController.Mode != "RW" { - return fmt.Errorf("Can only create backup from replica in mode RW, got %s", replicaInController.Mode) + return fmt.Errorf("Can only remove backup from replica in mode RW, got %s", replicaInController.Mode) } repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) @@ -150,7 +150,7 @@ func (t *Task) RestoreBackup(backup string) error { func (t *Task) restoreBackup(replicaInController *rest.Replica, backup string, snapshotFile string) error { if replicaInController.Mode != "RW" { - return fmt.Errorf("Can only create backup from replica in mode RW, got %s", replicaInController.Mode) + return fmt.Errorf("Can only restore backup from replica in mode RW, got %s", replicaInController.Mode) } repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) @@ -166,3 +166,47 @@ func (t *Task) restoreBackup(replicaInController *rest.Replica, backup string, s } return nil } + +func (t *Task) InspectBackup(backup string) (string, error) { + var replica *rest.Replica + + replicas, err := t.client.ListReplicas() + if err != nil { + return "", err + } + + for _, r := range replicas { + if r.Mode == "RW" { + replica = &r + break + } + } + + if replica == nil { + return "", fmt.Errorf("Cannot find a suitable replica for inspect backup") + } + + result, err := t.inspectBackup(replica, backup) + if err != nil { + return "", err + } + return result, nil +} + +func (t *Task) inspectBackup(replicaInController *rest.Replica, backup string) (string, error) { + if replicaInController.Mode != "RW" { + return "", fmt.Errorf("Can only inspect backup from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) + if err != nil { + return "", err + } + + result, err := repClient.InspectBackup(backup) + if err != nil { + logrus.Errorf("Failed inspect backup %s on %s", backup, replicaInController.Address) + return "", err + } + return result, nil +} diff --git a/vendor/github.com/rancher/convoy/api/const.go b/vendor/github.com/rancher/convoy/api/const.go new file mode 100644 index 00000000..a1eb5e5b --- /dev/null +++ b/vendor/github.com/rancher/convoy/api/const.go @@ -0,0 +1,10 @@ +package api + +const ( + // API_VERSION is the API version of Convoy daemon + API_VERSION = "1" + + KEY_NAME = "name" + KEY_BACKUP_URL = "backup" + KEY_DEST_URL = "dest" +) diff --git a/vendor/github.com/rancher/convoy/api/request.go b/vendor/github.com/rancher/convoy/api/request.go new file mode 100644 index 00000000..0c5cd866 --- /dev/null +++ b/vendor/github.com/rancher/convoy/api/request.go @@ -0,0 +1,62 @@ +package api + +type VolumeMountRequest struct { + VolumeName string + MountPoint string + Verbose bool +} + +type VolumeUmountRequest struct { + VolumeName string +} + +type VolumeCreateRequest struct { + Name string + DriverName string + Size int64 + BackupURL string + DriverVolumeID string + Type string + IOPS int64 + PrepareForVM bool + Verbose bool +} + +type VolumeDeleteRequest struct { + VolumeName string + ReferenceOnly bool +} + +type VolumeInspectRequest struct { + VolumeName string +} + +type SnapshotCreateRequest struct { + Name string + VolumeName string + Verbose bool +} + +type SnapshotDeleteRequest struct { + SnapshotName string +} + +type SnapshotInspectRequest struct { + SnapshotName string +} + +type BackupListRequest struct { + URL string + VolumeName string + SnapshotName string +} + +type BackupCreateRequest struct { + URL string + SnapshotName string + Verbose bool +} + +type BackupDeleteRequest struct { + URL string +} diff --git a/vendor/github.com/rancher/convoy/api/response.go b/vendor/github.com/rancher/convoy/api/response.go new file mode 100644 index 00000000..11ddf6b3 --- /dev/null +++ b/vendor/github.com/rancher/convoy/api/response.go @@ -0,0 +1,82 @@ +package api + +import ( + "encoding/json" + "fmt" + "github.com/Sirupsen/logrus" + "runtime" + "runtime/debug" + "strings" +) + +type ErrorResponse struct { + Error string +} + +type VolumeResponse struct { + Name string + Driver string + MountPoint string + CreatedTime string + DriverInfo map[string]string + Snapshots map[string]SnapshotResponse +} + +type SnapshotResponse struct { + Name string + VolumeName string `json:",omitempty"` + VolumeCreatedAt string `json:",omitempty"` + CreatedTime string + DriverInfo map[string]string +} + +type BackupURLResponse struct { + URL string +} + +// ResponseError would generate a error information in JSON format for output +func ResponseError(format string, a ...interface{}) { + response := ErrorResponse{Error: fmt.Sprintf(format, a...)} + j, err := json.MarshalIndent(&response, "", "\t") + if err != nil { + panic(fmt.Sprintf("Failed to generate response for error:", err)) + } + fmt.Println(string(j[:])) +} + +// ResponseLogAndError would log the error before call ResponseError() +func ResponseLogAndError(v interface{}) { + if e, ok := v.(*logrus.Entry); ok { + e.Error(e.Message) + oldFormatter := e.Logger.Formatter + logrus.SetFormatter(&logrus.JSONFormatter{}) + s, err := e.String() + logrus.SetFormatter(oldFormatter) + if err != nil { + ResponseError(err.Error()) + return + } + // Cosmetic since " would be escaped + ResponseError(strings.Replace(s, "\"", "'", -1)) + } else { + e, isErr := v.(error) + _, isRuntimeErr := e.(runtime.Error) + if isErr && !isRuntimeErr { + logrus.Errorf(fmt.Sprint(e)) + ResponseError(fmt.Sprint(e)) + } else { + logrus.Errorf("Caught FATAL error: %s", v) + debug.PrintStack() + ResponseError("Caught FATAL error: %s", v) + } + } +} + +// ResponseOutput would generate a JSON format byte array of object for output +func ResponseOutput(v interface{}) ([]byte, error) { + j, err := json.MarshalIndent(v, "", "\t") + if err != nil { + return nil, err + } + return j, nil +} From 92710affdc4861aad40c90249128ef6cb4a122f6 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Wed, 15 Jun 2016 15:29:34 -0700 Subject: [PATCH 131/357] Check if backup exists before deleting it --- agent/controller/rest/backup.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/agent/controller/rest/backup.go b/agent/controller/rest/backup.go index c5f6c842..cd210ed9 100644 --- a/agent/controller/rest/backup.go +++ b/agent/controller/rest/backup.go @@ -17,6 +17,7 @@ import ( "github.com/rancher/go-rancher/api" "github.com/rancher/longhorn/agent/controller" "github.com/rancher/longhorn/agent/replica/rest" + "regexp" ) // TODO Add logic to purge old entries from these maps @@ -26,6 +27,8 @@ var restoreMap = make(map[string]*status) var backupMutex = &sync.RWMutex{} var backupMap = make(map[string]*status) +var doesntExistRegex = regexp.MustCompile("cannot find.*in objectstore") + func (s *Server) CreateBackup(rw http.ResponseWriter, req *http.Request) error { logrus.Infof("Creating backup") @@ -94,6 +97,7 @@ func (s *Server) RemoveBackup(rw http.ResponseWriter, req *http.Request) error { } if !exists { + logrus.Infof("Backup [%v] doesn't exist. Nothing to remove.", input.Location) rw.WriteHeader(http.StatusNoContent) return nil } @@ -236,8 +240,21 @@ func getStatus(statusMap map[string]*status, statusMutex *sync.RWMutex, rw http. return apiContext.WriteResource(status) } -func backupExists(location locationInput) (bool, error) { - // TODO Properly implement once we have a way of knowing if a backup exists +func backupExists(input locationInput) (bool, error) { + cmd := exec.Command("longhorn", "backup", "inspect", input.Location) + stderr := new(bytes.Buffer) + cmd.Stderr = stderr + cmd.Stdout = os.Stdout + logrus.Infof("Running %v", cmd.Args) + if err := cmd.Run(); err != nil { + errOutput := stderr.String() + if doesntExistRegex.MatchString(errOutput) { + return false, nil + } + logrus.Errorf("Backup inspect error output: %v", errOutput) + return false, err + } + return true, nil } From e4b517375a3d8620e6f6f36c125ffc7ee7a268c3 Mon Sep 17 00:00:00 2001 From: kirill Date: Thu, 16 Jun 2016 14:14:41 -0700 Subject: [PATCH 132/357] controller: handle read/write beyond volume boundaries - the condition is handled inside the controller to prevent replicas from being kicked out - issue #131 - enabled corresponding test --- controller/control.go | 10 ++++++++++ integration/data/test_basic_ops.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/controller/control.go b/controller/control.go index 8e7b06af..c96e42b9 100644 --- a/controller/control.go +++ b/controller/control.go @@ -234,6 +234,11 @@ func (c *Controller) Start(addresses ...string) error { func (c *Controller) WriteAt(b []byte, off int64) (int, error) { c.RLock() + if off < 0 || off+int64(len(b)) > c.size { + err := fmt.Errorf("EOF: Write of %v bytes at offset %v is beyond volume size %v", len(b), off, c.size) + c.RUnlock() + return 0, err + } n, err := c.backend.WriteAt(b, off) c.RUnlock() if err != nil { @@ -244,6 +249,11 @@ func (c *Controller) WriteAt(b []byte, off int64) (int, error) { func (c *Controller) ReadAt(b []byte, off int64) (int, error) { c.RLock() + if off < 0 || off+int64(len(b)) > c.size { + err := fmt.Errorf("EOF: Read of %v bytes at offset %v is beyond volume size %v", len(b), off, c.size) + c.RUnlock() + return 0, err + } n, err := c.backend.ReadAt(b, off) c.RUnlock() if err != nil { diff --git a/integration/data/test_basic_ops.py b/integration/data/test_basic_ops.py index bb7e2628..ac7b3c5d 100644 --- a/integration/data/test_basic_ops.py +++ b/integration/data/test_basic_ops.py @@ -16,9 +16,13 @@ def test_basic_rw(dev): # NOQA common.verify_data(dev, offset, data) -# TODO BUG: https://github.com/rancher/longhorn/issues/131 -@pytest.mark.xfail(strict=True) # NOQA -def test_beyond_bounary(dev): +# See also BUG: https://github.com/rancher/longhorn/issues/131 +def test_beyond_boundary(dev): # NOQA + # check write at the boundary + data = common.random_string(128) + common.verify_data(dev, SIZE - 128, data) + + # out of bounds with pytest.raises(cattle.ApiError) as err: write_dev(dev, SIZE, "1") assert 'EOF' in str(err.value) @@ -26,6 +30,7 @@ def test_beyond_bounary(dev): read_dev(dev, SIZE, 1) assert 'EOF' in str(err.value) + # normal writes to verify controller/replica survival for i in range(0, 10): offset = random.randint(0, SIZE - 256) length = random.randint(0, 256) From 8a3f49dcb550a385f552957351e323368ae668ec Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Jun 2016 10:54:00 -0700 Subject: [PATCH 133/357] vendor: Update version of syscall package --- trash.yml | 2 +- .../golang.org/x/sys/unix/asm_dragonfly_386.s | 29 - .../golang.org/x/sys/unix/asm_linux_s390x.s | 28 + .../golang.org/x/sys/unix/bluetooth_linux.go | 35 + vendor/golang.org/x/sys/unix/mkall.sh | 17 +- vendor/golang.org/x/sys/unix/mkpost.go | 62 + vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 2 +- vendor/golang.org/x/sys/unix/syscall.go | 2 + .../x/sys/unix/syscall_darwin_386.go | 2 - .../x/sys/unix/syscall_darwin_amd64.go | 2 - .../x/sys/unix/syscall_darwin_arm.go | 2 - .../x/sys/unix/syscall_darwin_arm64.go | 2 - .../x/sys/unix/syscall_dragonfly_386.go | 63 - .../x/sys/unix/syscall_dragonfly_amd64.go | 2 - .../x/sys/unix/syscall_freebsd_386.go | 2 - .../x/sys/unix/syscall_freebsd_amd64.go | 2 - .../x/sys/unix/syscall_freebsd_arm.go | 2 - vendor/golang.org/x/sys/unix/syscall_linux.go | 30 +- .../x/sys/unix/syscall_linux_386.go | 13 +- .../x/sys/unix/syscall_linux_amd64.go | 13 +- .../x/sys/unix/syscall_linux_arm.go | 11 + .../x/sys/unix/syscall_linux_arm64.go | 27 +- .../x/sys/unix/syscall_linux_mips64x.go | 13 +- .../x/sys/unix/syscall_linux_ppc64x.go | 41 +- .../x/sys/unix/syscall_linux_s390x.go | 329 +++ .../x/sys/unix/syscall_netbsd_386.go | 2 - .../x/sys/unix/syscall_netbsd_amd64.go | 2 - .../x/sys/unix/syscall_netbsd_arm.go | 2 - .../x/sys/unix/syscall_openbsd_386.go | 2 - .../x/sys/unix/syscall_openbsd_amd64.go | 2 - .../x/sys/unix/syscall_solaris_amd64.go | 2 - vendor/golang.org/x/sys/unix/types_linux.go | 44 +- .../x/sys/unix/zerrors_dragonfly_386.go | 1530 ------------- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 1 + .../x/sys/unix/zerrors_linux_arm64.go | 1 + .../x/sys/unix/zerrors_linux_mips64.go | 1 + .../x/sys/unix/zerrors_linux_mips64le.go | 1 + .../x/sys/unix/zerrors_linux_ppc64.go | 1 + .../x/sys/unix/zerrors_linux_ppc64le.go | 1 + .../x/sys/unix/zerrors_linux_s390x.go | 2027 +++++++++++++++++ .../x/sys/unix/zsyscall_darwin_386.go | 1 + .../x/sys/unix/zsyscall_darwin_amd64.go | 1 + .../x/sys/unix/zsyscall_darwin_arm.go | 1 + .../x/sys/unix/zsyscall_darwin_arm64.go | 1 + .../x/sys/unix/zsyscall_dragonfly_amd64.go | 1 + .../x/sys/unix/zsyscall_freebsd_386.go | 1 + .../x/sys/unix/zsyscall_freebsd_amd64.go | 1 + .../x/sys/unix/zsyscall_freebsd_arm.go | 1 + .../x/sys/unix/zsyscall_linux_386.go | 78 +- .../x/sys/unix/zsyscall_linux_amd64.go | 78 +- .../x/sys/unix/zsyscall_linux_arm.go | 78 +- .../x/sys/unix/zsyscall_linux_arm64.go | 57 +- .../x/sys/unix/zsyscall_linux_mips64.go | 78 +- .../x/sys/unix/zsyscall_linux_mips64le.go | 78 +- .../x/sys/unix/zsyscall_linux_ppc64.go | 119 +- .../x/sys/unix/zsyscall_linux_ppc64le.go | 119 +- ...agonfly_386.go => zsyscall_linux_s390x.go} | 1139 +++++---- .../x/sys/unix/zsyscall_netbsd_386.go | 1 + .../x/sys/unix/zsyscall_netbsd_amd64.go | 1 + .../x/sys/unix/zsyscall_netbsd_arm.go | 1 + .../x/sys/unix/zsyscall_openbsd_386.go | 1 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 1 + .../x/sys/unix/zsysnum_dragonfly_386.go | 304 --- .../x/sys/unix/zsysnum_linux_s390x.go | 328 +++ .../x/sys/unix/ztypes_dragonfly_386.go | 437 ---- .../golang.org/x/sys/unix/ztypes_linux_386.go | 39 +- .../x/sys/unix/ztypes_linux_amd64.go | 39 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 30 +- .../x/sys/unix/ztypes_linux_arm64.go | 29 + .../x/sys/unix/ztypes_linux_mips64.go | 28 + .../x/sys/unix/ztypes_linux_mips64le.go | 28 + .../x/sys/unix/ztypes_linux_ppc64.go | 35 +- .../x/sys/unix/ztypes_linux_ppc64le.go | 35 +- .../x/sys/unix/ztypes_linux_s390x.go | 649 ++++++ 76 files changed, 5075 insertions(+), 3099 deletions(-) delete mode 100644 vendor/golang.org/x/sys/unix/asm_dragonfly_386.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_s390x.s create mode 100644 vendor/golang.org/x/sys/unix/bluetooth_linux.go create mode 100644 vendor/golang.org/x/sys/unix/mkpost.go delete mode 100644 vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_s390x.go delete mode 100644 vendor/golang.org/x/sys/unix/zerrors_dragonfly_386.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go rename vendor/golang.org/x/sys/unix/{zsyscall_dragonfly_386.go => zsyscall_linux_s390x.go} (57%) delete mode 100644 vendor/golang.org/x/sys/unix/zsysnum_dragonfly_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go delete mode 100644 vendor/golang.org/x/sys/unix/ztypes_dragonfly_386.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go diff --git a/trash.yml b/trash.yml index 332ca570..76022611 100644 --- a/trash.yml +++ b/trash.yml @@ -33,7 +33,7 @@ import: - package: github.com/mcuadros/go-version version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 - package: golang.org/x/sys/unix - version: 7a56174f0086b32866ebd746a794417edbc678a1 + version: 62bee037599929a6e9146f29d10dd5208c43507d - package: github.com/aws/aws-sdk-go/aws version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc - package: github.com/aws/aws-sdk-go/private/endpoints diff --git a/vendor/golang.org/x/sys/unix/asm_dragonfly_386.s b/vendor/golang.org/x/sys/unix/asm_dragonfly_386.s deleted file mode 100644 index 7e55e0d3..00000000 --- a/vendor/golang.org/x/sys/unix/asm_dragonfly_386.s +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !gccgo - -#include "textflag.h" - -// -// System call support for 386, FreeBSD -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-32 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-44 - JMP syscall·Syscall6(SB) - -TEXT ·Syscall9(SB),NOSPLIT,$0-56 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-32 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 - JMP 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 00000000..11889859 --- /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/bluetooth_linux.go b/vendor/golang.org/x/sys/unix/bluetooth_linux.go new file mode 100644 index 00000000..6e322969 --- /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/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh index de95a4bb..3e224c57 100755 --- a/vendor/golang.org/x/sys/unix/mkall.sh +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -161,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" ;; @@ -194,7 +194,7 @@ linux_arm64) exit 1 fi mksysnum="./mksysnum_linux.pl $unistd_h" - # 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" ;; @@ -212,6 +212,17 @@ linux_ppc64le) 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" @@ -269,6 +280,6 @@ esac if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi if [ -n "$mktypes" ]; then echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go"; - echo "$mktypes types_$GOOS.go | gofmt >>ztypes_$GOOSARCH.go"; + echo "$mktypes types_$GOOS.go | go run mkpost.go >>ztypes_$GOOSARCH.go"; fi ) | $run 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 00000000..ed50d902 --- /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/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index 70af5a72..f1493a3e 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -62,7 +62,7 @@ func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { h := (*Cmsghdr)(unsafe.Pointer(&b[0])) - if h.Len < SizeofCmsghdr || int(h.Len) > len(b) { + if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { return nil, nil, EINVAL } return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil diff --git a/vendor/golang.org/x/sys/unix/syscall.go b/vendor/golang.org/x/sys/unix/syscall.go index 6442a993..a0bcf842 100644 --- a/vendor/golang.org/x/sys/unix/syscall.go +++ b/vendor/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/vendor/golang.org/x/sys/unix/syscall_darwin_386.go b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go index 3195c8bf..c172a3da 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go @@ -21,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/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go index 7adb98de..fc1e5a4a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -23,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) diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go index e47ffd73..d286cf40 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go @@ -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) diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go index 2560a959..c33905cd 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -21,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/vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go deleted file mode 100644 index 41c2e697..00000000 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build 386,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 = int32(nsec / 1e9) - ts.Nsec = int32(nsec % 1e9) - 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) - 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_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go index 2ed92590..da7cb798 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go @@ -21,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/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go index 6255d40f..6a0cd804 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -21,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/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go index 8b395d59..e142540e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -21,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/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go index 4e72d46a..5504cb12 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -21,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/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 88c8e042..6d10c9cf 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -36,10 +36,10 @@ 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) +//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) + return Linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0) } func Mkdir(path string, mode uint32) (err error) { @@ -60,6 +60,15 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) return openat(dirfd, path, flags|O_LARGEFILE, mode) } +//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) + +func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + if len(fds) == 0 { + return ppoll(nil, 0, timeout, sigmask) + } + return ppoll(&fds[0], len(fds), timeout, sigmask) +} + //sys readlinkat(dirfd int, path string, buf []byte) (n int, err error) func Readlink(path string, buf []byte) (n int, err error) { @@ -394,6 +403,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: @@ -859,7 +881,6 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri //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) @@ -894,7 +915,6 @@ func Getpgrp() (pid int) { //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 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) @@ -1032,8 +1052,6 @@ func Munmap(b []byte) (err error) { // Newfstatat // Nfsservctl // Personality -// Poll -// Ppoll // Pselect6 // Ptrace // Putpmsg diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index 45844015..2b881b97 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -24,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) @@ -93,6 +91,8 @@ func Pipe2(p []int, flags int) (err error) { //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) @@ -388,3 +388,12 @@ func (msghdr *Msghdr) SetControllen(length int) { func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } + +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + if len(fds) == 0 { + return poll(nil, 0, timeout) + } + return poll(&fds[0], len(fds), timeout) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 60698e44..18911c2d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -9,6 +9,7 @@ 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) @@ -25,6 +26,7 @@ import "syscall" //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 @@ -96,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 @@ -146,3 +146,12 @@ func (msghdr *Msghdr) SetControllen(length int) { func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint64(length) } + +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + if len(fds) == 0 { + return poll(nil, 0, timeout) + } + return poll(&fds[0], len(fds), timeout) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index 3b4da206..71d87022 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -108,6 +108,8 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { // 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 @@ -250,3 +252,12 @@ func (msghdr *Msghdr) SetControllen(length int) { func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } + +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + if len(fds) == 0 { + return poll(nil, 0, timeout) + } + return poll(&fds[0], len(fds), timeout) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index 42581156..4b6ff2a8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -8,6 +8,7 @@ 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) @@ -79,8 +80,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 @@ -152,6 +151,18 @@ 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. @@ -167,3 +178,15 @@ const ( SYS_EPOLL_CREATE = 1042 SYS_EPOLL_WAIT = 1069 ) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + var ts *Timespec + if timeout >= 0 { + ts = new(Timespec) + *ts = NsecToTimespec(int64(timeout) * 1e6) + } + if len(fds) == 0 { + return ppoll(nil, 0, ts, nil) + } + return ppoll(&fds[0], len(fds), ts, nil) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index f23dd6c3..440f54ee 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -14,6 +14,7 @@ package unix // 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) @@ -24,6 +25,7 @@ const _SYS_getdents = SYS_GETDENTS //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 @@ -85,8 +87,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 @@ -204,3 +204,12 @@ func (msghdr *Msghdr) SetControllen(length int) { func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint64(length) } + +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + if len(fds) == 0 { + return poll(nil, 0, timeout) + } + return poll(&fds[0], len(fds), timeout) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 2503b7f5..60770f62 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -7,6 +7,8 @@ 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) @@ -16,11 +18,13 @@ package unix //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 @@ -72,8 +76,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 @@ -96,3 +98,38 @@ func (msghdr *Msghdr) SetControllen(length int) { 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 +} + +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + if len(fds) == 0 { + return poll(nil, 0, timeout) + } + return poll(&fds[0], len(fds), timeout) +} 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 00000000..81c5f473 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -0,0 +1,329 @@ +// 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 +} + +//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) + +func Poll(fds []PollFd, timeout int) (n int, err error) { + if len(fds) == 0 { + return poll(nil, 0, timeout) + } + return poll(&fds[0], len(fds), timeout) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go index 1b0e1af1..afaca098 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go @@ -16,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/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go index 1b6dcbe3..a6ff04ce 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go @@ -16,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/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go index 87d1d6fe..68a6969b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go @@ -16,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/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go index 9529b20e..a66ddc59 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go @@ -16,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/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go index fc640294..0776c1fa 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go @@ -16,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/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go index 2e44630c..5aff62c3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go @@ -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/vendor/golang.org/x/sys/unix/types_linux.go b/vendor/golang.org/x/sys/unix/types_linux.go index 16378fa8..7dea79a8 100644 --- a/vendor/golang.org/x/sys/unix/types_linux.go +++ b/vendor/golang.org/x/sys/unix/types_linux.go @@ -24,6 +24,7 @@ package unix #include #include #include +#include #include #include #include @@ -55,6 +56,8 @@ package unix #include #include #include +#include +#include #ifdef TCSETS2 // On systems that have "struct termios2" use this as type Termios. @@ -100,17 +103,31 @@ typedef struct user_pt_regs PtraceRegs; 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; @@ -196,6 +213,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 @@ -235,6 +254,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 @@ -385,6 +405,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 @@ -400,9 +427,24 @@ 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 ) +type PollFd C.struct_pollfd + +const ( + POLLIN = C.POLLIN + POLLPRI = C.POLLPRI + POLLOUT = C.POLLOUT + POLLRDHUP = C.POLLRDHUP + POLLERR = C.POLLERR + POLLHUP = C.POLLHUP + POLLNVAL = C.POLLNVAL +) + +type Sigset_t C.sigset_t + // Terminal handling type Termios C.termios_t diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_386.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_386.go deleted file mode 100644 index 2a329f06..00000000 --- a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_386.go +++ /dev/null @@ -1,1530 +0,0 @@ -// mkerrors.sh -m32 -// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -// +build 386,dragonfly - -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs -- -m32 _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 = 0xc0084279 - BIOCGETIF = 0x4020426b - BIOCGHDRCMPLT = 0x40044274 - BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4008426e - BIOCGSEESENT = 0x40044276 - BIOCGSTATS = 0x4008426f - BIOCIMMEDIATE = 0x80044270 - BIOCLOCK = 0x2000427a - BIOCPROMISC = 0x20004269 - BIOCSBLEN = 0xc0044266 - BIOCSDLT = 0x80044278 - BIOCSETF = 0x80084267 - BIOCSETIF = 0x8020426c - BIOCSETWF = 0x8008427b - 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_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 = 0x8030720a - SIOCAIFADDR = 0x8040691a - SIOCALIFADDR = 0x8118691b - SIOCATMARK = 0x40047307 - SIOCDELMULTI = 0x80206932 - SIOCDELRT = 0x8030720b - SIOCDIFADDR = 0x80206919 - SIOCDIFPHYADDR = 0x80206949 - SIOCDLIFADDR = 0x8118691d - SIOCGDRVSPEC = 0xc01c697b - SIOCGETSGCNT = 0xc0147210 - SIOCGETVIFCNT = 0xc014720f - SIOCGHIWAT = 0x40047301 - SIOCGIFADDR = 0xc0206921 - SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020691f - SIOCGIFCONF = 0xc0086924 - SIOCGIFDATA = 0xc0206926 - SIOCGIFDSTADDR = 0xc0206922 - SIOCGIFFLAGS = 0xc0206911 - SIOCGIFGENERIC = 0xc020693a - SIOCGIFGMEMB = 0xc024698a - SIOCGIFINDEX = 0xc0206920 - SIOCGIFMEDIA = 0xc0286938 - 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 = 0xc00c6978 - SIOCSDRVSPEC = 0x801c697b - 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 = 0x40087458 - 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 = 0x40087459 - 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_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index d370be0e..8f920124 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -216,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 @@ -826,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 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index b83fb40b..49b6c354 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -216,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 @@ -826,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 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 1cc76a78..f036758f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -212,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 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 47027b79..16dcbc9c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -222,6 +222,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 98056fe2..36535b24 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -221,6 +221,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index e5debb68..112f05de 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -221,6 +221,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 5b90d07e..8b42ca2f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -223,6 +223,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 0861bd56..e8d12b5d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -222,6 +222,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 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 00000000..329f25e7 --- /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/zsyscall_darwin_386.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go index a15aaf12..031034a3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 74606b2f..ee96f78b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go index 640e8542..e52cd0d5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 933f67bb..9863ef99 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index 3fa6ff79..78de48dc 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index 1a0e528c..fade994d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 6e4cf145..c28281e8 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index 1872d323..a18ba5c8 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 106cd592..1f7a7566 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1582,6 +1566,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 { @@ -1636,3 +1647,14 @@ func Utime(path string, buf *Utimbuf) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + 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 index c1bae650..b4e24fc0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1226,6 +1210,23 @@ func Dup2(oldfd int, newfd int) (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 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 { @@ -1391,6 +1392,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 { @@ -1830,3 +1841,14 @@ func pipe2(p *[2]_C_int, flags int) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + 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 index 3383f970..20bf33ce 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1649,6 +1633,33 @@ func Gettimeofday(tv *Timeval) (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 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 { @@ -1737,3 +1748,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + 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 index fb2ff3aa..c7286db4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1216,6 +1200,23 @@ func Munlockall() (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_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 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 7eac55b5..b709ed2f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1216,6 +1200,23 @@ func Munlockall() (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 Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -1314,6 +1315,16 @@ func Listen(s int, n int) (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 { @@ -1779,3 +1790,14 @@ func stat(path string, st *stat_t) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + 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 index e8b61a6e..5cb1c567 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1216,6 +1200,23 @@ func Munlockall() (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 Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { @@ -1314,6 +1315,16 @@ func Listen(s int, n int) (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 { @@ -1779,3 +1790,14 @@ func stat(path string, st *stat_t) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + 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 index f8eaae9a..873bb18f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1216,6 +1200,33 @@ func Munlockall() (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 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 { @@ -1298,6 +1309,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 { @@ -1360,6 +1382,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 { @@ -1800,3 +1832,34 @@ func Utime(path string, buf *Utimbuf) (err error) { } 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 poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + 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 index 22d444fe..bf08835c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -14,7 +14,7 @@ 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) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { @@ -53,6 +53,17 @@ 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 ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 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 readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -370,23 +381,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 @@ -746,16 +740,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) @@ -1216,6 +1200,33 @@ func Munlockall() (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 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 { @@ -1298,6 +1309,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 { @@ -1360,6 +1382,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 { @@ -1800,3 +1832,34 @@ func Utime(path string, buf *Utimbuf) (err error) { } 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 poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go similarity index 57% rename from vendor/golang.org/x/sys/unix/zsyscall_dragonfly_386.go rename to vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 32e46af6..dbaa53b9 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -1,7 +1,7 @@ -// mksyscall.pl -l32 -dragonfly syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_386.go +// mksyscall.pl syscall_linux.go syscall_linux_s390x.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT -// +build 386,dragonfly +// +build s390x,linux package unix @@ -14,9 +14,20 @@ 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) +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) } @@ -25,8 +36,15 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { // 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) +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) } @@ -35,9 +53,9 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { // 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) +func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0) + n = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -46,9 +64,21 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err // 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) +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) } @@ -57,8 +87,20 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { // 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)) +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) } @@ -67,8 +109,14 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { // 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)) +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) } @@ -77,9 +125,14 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { // 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) +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) } @@ -88,8 +141,14 @@ func socket(domain int, typ int, proto int) (fd int, err error) { // 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) +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) } @@ -98,8 +157,8 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen // 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) +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) } @@ -108,8 +167,15 @@ func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) // 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))) +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) } @@ -118,8 +184,9 @@ func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { // 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))) +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) } @@ -128,8 +195,8 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { // 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) +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) } @@ -138,8 +205,14 @@ func Shutdown(s int, how int) (err error) { // 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) +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) } @@ -148,15 +221,26 @@ func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { // 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) +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 } - 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) + 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) } @@ -165,14 +249,14 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl // 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) +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return } - _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) } @@ -181,9 +265,9 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( // 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) +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) } @@ -192,9 +276,14 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { // 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) +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) } @@ -203,9 +292,14 @@ 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 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) +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) } @@ -214,14 +308,8 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne // 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)) +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) } @@ -230,14 +318,8 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) // 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)) +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -246,8 +328,9 @@ func utimes(path string, timeval *[2]Timeval) (err error) { // 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) +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) } @@ -256,9 +339,8 @@ func futimes(fd int, timeval *[2]Timeval) (err error) { // 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) +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) } @@ -267,10 +349,9 @@ 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 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) } @@ -279,15 +360,9 @@ 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 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) } @@ -296,15 +371,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 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) } @@ -313,13 +381,20 @@ func extpwrite(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 Access(path string, mode uint32) (err error) { +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 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, 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) @@ -329,8 +404,8 @@ func Access(path string, mode uint32) (err error) { // 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) +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) } @@ -339,14 +414,8 @@ func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { // 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)) +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -355,14 +424,8 @@ func Chdir(path string) (err error) { // 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)) +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } @@ -371,13 +434,13 @@ func Chflags(path string, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chmod(path string, mode uint32) (err error) { +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + _, _, 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) @@ -387,13 +450,13 @@ func Chmod(path string, mode uint32) (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) { +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 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + _, _, 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) @@ -403,14 +466,9 @@ func Chown(path string, uid int, gid int) (err error) { // 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)) +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) } @@ -419,8 +477,8 @@ func Chroot(path string) (err error) { // 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) +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -429,9 +487,8 @@ func Close(fd int) (err error) { // 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) +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { err = errnoErr(e1) } @@ -440,8 +497,8 @@ func Dup(fd int) (nfd int, err error) { // 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) +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -450,15 +507,26 @@ func Dup2(from int, to int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Exit(code int) { - Syscall(SYS_EXIT, uintptr(code), 0, 0) +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 Fchdir(fd int) (err error) { - _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) +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) } @@ -467,28 +535,25 @@ func Fchdir(fd int) (err error) { // 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) - } +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 Fchmod(fd int, mode uint32) (err error) { - _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) - if e1 != 0 { - err = errnoErr(e1) - } +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 Fchown(fd int, uid int, gid int) (err error) { - _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) +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) } @@ -497,8 +562,8 @@ func Fchown(fd int, uid int, gid int) (err error) { // 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) +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) } @@ -507,9 +572,35 @@ func Flock(fd int, how int) (err error) { // 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) +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) } @@ -518,8 +609,15 @@ 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) +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) } @@ -528,8 +626,9 @@ 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) +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) } @@ -538,8 +637,9 @@ func Fstatfs(fd int, stat *Statfs_t) (err error) { // 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) +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) } @@ -548,8 +648,8 @@ 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) +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) if e1 != 0 { err = errnoErr(e1) } @@ -558,14 +658,14 @@ func Ftruncate(fd int, length int64) (err error) { // 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) { +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 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -575,41 +675,85 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { // 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) +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 Getegid() (egid int) { - r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) - egid = int(r0) +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 Geteuid() (uid int) { - r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) - uid = int(r0) +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 Getgid() (gid int) { - r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) - gid = int(r0) +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 Getpgid(pid int) (pgid int, err error) { - r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) - pgid = int(r0) +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) } @@ -618,33 +762,57 @@ func Getpgid(pid int) (pgid int, err error) { // 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) +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 Getpid() (pid int) { - r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) - pid = 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) + } 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) +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 Getpriority(which int, who int) (prio int, err error) { - r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) - prio = int(r0) +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) } @@ -653,8 +821,20 @@ func Getpriority(which int, who int) (prio int, err error) { // 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) +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) } @@ -663,8 +843,14 @@ func Getrlimit(which int, lim *Rlimit) (err error) { // 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) +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) } @@ -673,9 +859,14 @@ func Getrusage(who int, rusage *Rusage) (err error) { // 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) +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) } @@ -684,8 +875,8 @@ 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) +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) if e1 != 0 { err = errnoErr(e1) } @@ -694,24 +885,29 @@ func Gettimeofday(tv *Timeval) (err error) { // 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) +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 Issetugid() (tainted bool) { - r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) - tainted = bool(r0 != 0) +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 Kill(pid int, signum syscall.Signal) (err error) { - _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) if e1 != 0 { err = errnoErr(e1) } @@ -720,9 +916,8 @@ func Kill(pid int, signum syscall.Signal) (err error) { // 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) +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) } @@ -731,14 +926,26 @@ func Kqueue() (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Lchown(path string, uid int, gid int) (err error) { +func Setxattr(path string, attr string, data []byte, flags 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)) + 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) } @@ -747,20 +954,36 @@ func Lchown(path string, uid int, gid int) (err error) { // 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 +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) } - var _p1 *byte - _p1, err = BytePtrFromString(link) - if err != nil { - return + 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) } - _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) + 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) } @@ -769,8 +992,9 @@ func Link(path string, link string) (err error) { // 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) +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) } @@ -779,13 +1003,31 @@ func Listen(s int, backlog int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Lstat(path string, stat *Stat_t) (err error) { +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(path) + _p0, err = BytePtrFromString(target) if err != nil { return } - _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -795,14 +1037,56 @@ func Lstat(path string, stat *Stat_t) (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)) +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) } @@ -811,14 +1095,9 @@ func Mkdir(path string, mode uint32) (err error) { // 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)) +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) } @@ -827,14 +1106,8 @@ func Mkfifo(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)) +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) if e1 != 0 { err = errnoErr(e1) } @@ -843,14 +1116,14 @@ func Mknod(path string, mode uint32, dev int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mlock(b []byte) (err error) { +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_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) if e1 != 0 { err = errnoErr(e1) } @@ -859,8 +1132,14 @@ func Mlock(b []byte) (err error) { // 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) +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) } @@ -869,14 +1148,14 @@ func Mlockall(flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mprotect(b []byte, prot int) (err error) { +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_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) if e1 != 0 { err = errnoErr(e1) } @@ -901,8 +1180,8 @@ func Munlock(b []byte) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Munlockall() (err error) { - _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -911,8 +1190,8 @@ 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) +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -921,15 +1200,8 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // 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) +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) if e1 != 0 { err = errnoErr(e1) } @@ -938,15 +1210,15 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { // 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 +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 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) - use(unsafe.Pointer(_p0)) - val = int(r0) + 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) } @@ -955,15 +1227,8 @@ func Pathconf(path string, name int) (val int, 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 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) } @@ -972,21 +1237,8 @@ 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]) - } 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) +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) } @@ -995,20 +1247,8 @@ func Readlink(path string, buf []byte) (n int, err error) { // 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)) +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) } @@ -1017,14 +1257,8 @@ func Rename(from string, to string) (err error) { // 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)) +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) } @@ -1033,14 +1267,8 @@ func Revoke(path string) (err error) { // 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)) +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1049,29 +1277,32 @@ 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)) - if e1 != 0 { - err = errnoErr(e1) - } +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 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) - } +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 Setegid(egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) +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) } @@ -1080,8 +1311,17 @@ func Setegid(egid int) (err error) { // 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) +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) } @@ -1090,8 +1330,14 @@ func Seteuid(euid int) (err error) { // 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) +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) } @@ -1100,13 +1346,13 @@ func Setgid(gid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setlogin(name string) (err error) { +func Lstat(path string, stat *Stat_t) (err error) { var _p0 *byte - _p0, err = BytePtrFromString(name) + _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1116,8 +1362,8 @@ func Setlogin(name string) (err error) { // 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) +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1126,8 +1372,15 @@ func Setpgid(pid int, pgid int) (err error) { // 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)) +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) } @@ -1136,8 +1389,15 @@ 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 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) } @@ -1146,8 +1406,9 @@ 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) +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) } @@ -1156,8 +1417,9 @@ func Setreuid(ruid int, euid int) (err error) { // 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 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) } @@ -1166,8 +1428,9 @@ 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 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) } @@ -1176,8 +1439,8 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // 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) +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1186,9 +1449,8 @@ func Setrlimit(which int, lim *Rlimit) (err error) { // 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) +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1197,8 +1459,8 @@ func Setsid() (pid int, err error) { // 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) +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1207,8 +1469,8 @@ func Settimeofday(tp *Timeval) (err error) { // 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) +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) } @@ -1217,14 +1479,8 @@ func Setuid(uid int) (err error) { // 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)) +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) } @@ -1233,14 +1489,8 @@ func Stat(path string, stat *Stat_t) (err error) { // 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)) +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) } @@ -1249,20 +1499,8 @@ func Statfs(path string, stat *Statfs_t) (err error) { // 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)) +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1271,8 +1509,9 @@ func Symlink(path string, link string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Sync() (err error) { - _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) +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) } @@ -1281,13 +1520,13 @@ func Sync() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Truncate(path string, length int64) (err error) { +func Stat(path string, stat *Stat_t) (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) + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1297,21 +1536,13 @@ func Truncate(path string, length int64) (err error) { // 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) { +func Statfs(path string, buf *Statfs_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1321,14 +1552,8 @@ func Undelete(path string) (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)) +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) } @@ -1337,13 +1562,13 @@ func Unlink(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Unmount(path string, flags int) (err error) { +func Truncate(path string, length int64) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1353,15 +1578,19 @@ func Unmount(path string, flags int) (err error) { // 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) +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) } - r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) - n = int(r0) + 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) } @@ -1370,9 +1599,8 @@ 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) - ret = uintptr(r0) +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1381,8 +1609,14 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( // 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) +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) } @@ -1391,9 +1625,8 @@ func munmap(addr uintptr, length uintptr) (err error) { // 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) +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) } @@ -1402,8 +1635,8 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) { // 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)) +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) n = int(r0) if e1 != 0 { err = errnoErr(e1) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 00ca1f9c..b16e1d0e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index 03f31b97..b63667da 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 84dc61cf..b0d19038 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 02b3528a..f91a5b85 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -222,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/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 7dc2b7ea..2e8d59d7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -222,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/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_386.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_386.go deleted file mode 100644 index 785240a7..00000000 --- a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_386.go +++ /dev/null @@ -1,304 +0,0 @@ -// mksysnum_dragonfly.pl -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT - -// +build 386,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_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go new file mode 100644 index 00000000..42d4f5cd --- /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/ztypes_dragonfly_386.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_386.go deleted file mode 100644 index b7e7ff08..00000000 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_386.go +++ /dev/null @@ -1,437 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_dragonfly.go - -// +build 386,dragonfly - -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 { - 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 int32 - Bsize int32 - Iosize int32 - Blocks int32 - Bfree int32 - Bavail int32 - Files int32 - Ffree int32 - Fsid Fsid - Owner uint32 - Type int32 - Flags int32 - Syncwrites int32 - Asyncwrites int32 - Fstypename [16]int8 - Mntonname [80]int8 - Syncreads int32 - Asyncreads int32 - Spares1 int16 - Mntfromname [80]int8 - Spares2 int16 - Spare [2]int32 -} - -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 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 = 0x36 - 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 int32 - Udata *byte -} - -type FdSet struct { - Bits [32]uint32 -} - -const ( - SizeofIfMsghdr = 0x68 - SizeofIfData = 0x58 - 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 IfData struct { - Type uint8 - Physical uint8 - Addrlen uint8 - Hdrlen uint8 - Recvquota uint8 - Xmitquota uint8 - Pad_cgo_0 [2]byte - Mtu uint32 - Metric uint32 - Link_state uint32 - Baudrate uint64 - Ipackets uint32 - Ierrors uint32 - Opackets uint32 - Oerrors uint32 - Collisions uint32 - Ibytes uint32 - Obytes uint32 - Imcasts uint32 - Omcasts uint32 - Iqdrops uint32 - Noproto uint32 - Hwassist uint32 - Unused uint32 - 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 uint32 - Rmx RtMetrics -} - -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 -} - -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_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index cf5db0e1..f3ddf534 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -151,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 @@ -188,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 @@ -310,6 +325,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -574,10 +590,31 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 - AT_SYMLINK_NOFOLLOW = 0x100 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 ) +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag 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 index ac27784a..a923bef3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -153,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 @@ -190,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 @@ -314,6 +329,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -592,10 +608,31 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 - AT_SYMLINK_NOFOLLOW = 0x100 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 ) +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag 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 index b318bb85..817ac9c2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -192,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 @@ -314,6 +320,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -563,10 +570,31 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 - AT_SYMLINK_NOFOLLOW = 0x100 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 ) +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag 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 index a159aada..e786addf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -200,6 +200,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -324,6 +330,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -573,6 +580,7 @@ type Ustat_t struct { type EpollEvent struct { Events uint32 + PadFd int32 Fd int32 Pad int32 } @@ -580,9 +588,30 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 AT_SYMLINK_NOFOLLOW = 0x100 ) +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag 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 index 0c5c9189..b29894de 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -200,6 +200,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -323,6 +329,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -585,9 +592,30 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 AT_SYMLINK_NOFOLLOW = 0x100 ) +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 7c0c8037..d9af71b6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -200,6 +200,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -323,6 +329,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -585,9 +592,30 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 AT_SYMLINK_NOFOLLOW = 0x100 ) +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index b14cbfef..4218170a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -201,6 +201,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -325,6 +331,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -582,17 +589,39 @@ type Ustat_t struct { } type EpollEvent struct { - Events uint32 - Fd int32 - Pad int32 + 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 PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag 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 index 22c96a2f..7db4c78c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -201,6 +201,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -325,6 +331,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -582,17 +589,39 @@ type Ustat_t struct { } type EpollEvent struct { - Events uint32 - Fd int32 - Pad int32 + 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 PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + type Termios struct { Iflag uint32 Oflag 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 00000000..76ee57cb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -0,0 +1,649 @@ +// +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 PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLIN = 0x1 + POLLPRI = 0x2 + POLLOUT = 0x4 + POLLRDHUP = 0x2000 + POLLERR = 0x8 + POLLHUP = 0x10 + POLLNVAL = 0x20 +) + +type Sigset_t struct { + X__val [16]uint64 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} From ef988a636f4a4e0a87fff92b86f54e7fee892444 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 16 Jun 2016 15:56:27 -0700 Subject: [PATCH 134/357] tcmu: clear context when tcmu shutdown called We're not going to accept any device add/remove event after start up. The case of frontend shutdown/start during processing running will be address in another way. --- frontend/tcmu/cfunc.go | 21 --------------------- frontend/tcmu/main.go | 10 +++------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index f1120595..d338a48d 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -48,27 +48,6 @@ struct tcmulib_context *tcmu_init() { return tcmulib_initialize(&lh_handler, 1, errp); } -bool tcmu_poll_master_fd(struct tcmulib_context *cxt) { - int ret; - struct pollfd pfd; - - pfd.fd = tcmulib_get_master_fd(cxt); - pfd.events = POLLIN; - pfd.revents = 0; - - ret = poll(&pfd, 1, -1); - if (ret < 0) { - errp("poll error out with %d", ret); - return false; - } - - if (pfd.revents) { - tcmulib_master_fd_ready(cxt); - return true; - } - return false; -} - int tcmu_wait_for_next_command(struct tcmu_device *dev) { struct pollfd pfd; diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index 4d7c3be8..bb768835 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -220,13 +220,9 @@ func start(name string, rw types.ReaderWriterAt) error { if cxt == nil { return errors.New("TCMU ctx is nil") } - - go func() { - for { - result := C.tcmu_poll_master_fd(cxt) - log.Debugln("Poll master fd one more time, last result ", result) - } - }() + // We don't want to poll main fd because devOpen() will be + // called once for tcmu_init(). We don't need to listen to + // further events for now. } return nil From 5aec63ed66d7de634a4787d03c6ad223ad723050 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Jun 2016 21:58:28 -0700 Subject: [PATCH 135/357] tcmu: Write polling command in Go --- frontend/tcmu/cfunc.go | 16 ------------- frontend/tcmu/main.go | 54 +++++++++++++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/frontend/tcmu/cfunc.go b/frontend/tcmu/cfunc.go index d338a48d..c08cf451 100644 --- a/frontend/tcmu/cfunc.go +++ b/frontend/tcmu/cfunc.go @@ -48,22 +48,6 @@ struct tcmulib_context *tcmu_init() { return tcmulib_initialize(&lh_handler, 1, errp); } -int tcmu_wait_for_next_command(struct tcmu_device *dev) { - struct pollfd pfd; - - pfd.fd = tcmu_get_dev_fd(dev); - pfd.events = POLLIN; - pfd.revents = 0; - - poll(&pfd, 1, -1); - - if (pfd.revents != 0 && pfd.revents != POLLIN) { - errp("poll received unexpected revent: 0x%x\n", pfd.revents); - return -1; - } - return 0; -} - uint8_t tcmucmd_get_cdb_at(struct tcmulib_cmd *cmd, int index) { return cmd->cdb[index]; } diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index bb768835..f8b5afad 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -24,6 +24,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" + "golang.org/x/sys/unix" ) var ( @@ -33,6 +34,8 @@ var ( backend types.ReaderWriterAt cxt *C.struct_tcmulib_context volume string + + done chan struct{} ) type State struct { @@ -85,18 +88,51 @@ func devOpen(dev Device) int { } func (s *State) HandleRequest(dev Device) { - for true { - C.tcmulib_processing_start(dev) - cmd := C.tcmulib_get_next_command(dev) - for cmd != nil { - go s.processCommand(dev, cmd) - cmd = C.tcmulib_get_next_command(dev) + ch := make(chan bool) + finished := false + go s.waitForNextCommand(dev, ch) + for !finished { + select { + case <-done: + log.Errorln("Handle request finished") + finished = true + case success := <-ch: + if !success { + log.Errorln("Fail to wait for next command") + finished = true + break + } + C.tcmulib_processing_start(dev) + cmd := C.tcmulib_get_next_command(dev) + for cmd != nil { + go s.processCommand(dev, cmd) + cmd = C.tcmulib_get_next_command(dev) + } + } + } +} + +func (s *State) waitForNextCommand(dev Device, ch chan bool) { + for { + pfd := []unix.PollFd{ + { + Fd: int32(C.tcmu_get_dev_fd(dev)), + Events: unix.POLLIN, + Revents: 0, + }, + } + _, err := unix.Poll(pfd, -1) + if err != nil { + log.Errorln("Poll command failed: ", err) + ch <- false + break } - ret := C.tcmu_wait_for_next_command(dev) - if ret != 0 { - log.Errorln("Fail to wait for next command", ret) + if pfd[0].Revents != 0 && pfd[0].Revents != unix.POLLIN { + log.Errorln("Poll received unexpect event: ", pfd[0].Revents) + ch <- false break } + ch <- true } } From 68add700cd946fc72024c395b9afe8ab7d48787e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 20 Jun 2016 14:33:40 -0700 Subject: [PATCH 136/357] tcmu: Properly shutdown will clean context 1. We need to clean up all the remaining device properly(close/unmap fd) to make sure that uio_release won't happen after TCMU device teardown. Otherwise it will be reference after free error. This result in a TCMU change. 2. All polling process needs to be stopped before fd closed. Close fd won't result in polling stop. 3. First part of teardown(shutdown the TCM loop frontend and the block device) need to be separate from second part(shutdown TCMU backend). The first part will result in flush data into disk, which cannot work if device has been already freed. --- Dockerfile.dapper | 4 ++-- frontend/tcmu/frontend.go | 48 +++++++++++++++++++++++++++++++-------- frontend/tcmu/main.go | 44 +++++++++++++++++++++++++++++++---- 3 files changed, 81 insertions(+), 15 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 3977dae8..d3a8ef41 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -45,9 +45,9 @@ RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/ # Build TCMU RUN cd /usr/src && \ - git clone https://github.com/agrover/tcmu-runner.git && \ + git clone https://github.com/yasker/tcmu-runner.git && \ cd tcmu-runner && \ - git checkout 2c5b9bbf131c2c668ffb1cda712157d35c1865ba + git checkout ce3050a2b15830bafed0b21f488f2d26a86efb74 RUN cd /usr/src/tcmu-runner && \ cmake . -Dwith-glfs=false && \ make && \ diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index ea548d30..d7fa75d7 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -187,14 +187,28 @@ func TeardownTcmu(volume string) error { var err error for i := 1; i <= teardownAttempts; i++ { logrus.Info("Starting TCMU teardown.") - err := teardown(volume) - if err == nil { - logrus.Info("TCMU teardown successful.") - break - } else if i < teardownAttempts { - logrus.Infof("Error occurred during TCMU teardown. Attempting again after %v second sleep. Error: %v", teardownRetryWait, err) - time.Sleep(time.Second * teardownRetryWait) + if err := teardown(volume); err != nil { + if i < teardownAttempts { + logrus.Infof("Error occurred during TCMU teardown. Attempting again after %v second sleep. Error: %v", teardownRetryWait, err) + time.Sleep(time.Second * teardownRetryWait) + continue + } else { + break + } + } + stop() + if err := finishTeardown(volume); err != nil { + if i < teardownAttempts { + logrus.Infof("Error occurred during TCMU teardown. Attempting again after %v second sleep. Error: %v", teardownRetryWait, err) + time.Sleep(time.Second * teardownRetryWait) + continue + } else { + break + } + } + logrus.Info("TCMU teardown successful.") + break } return err } @@ -210,14 +224,12 @@ func teardown(volume string) error { /sys/kernel/config/target/loopback/naa./tpgt_1/lun/lun_0 /sys/kernel/config/target/loopback/naa./tpgt_1 /sys/kernel/config/target/loopback/naa. - /sys/kernel/config/target/core/user_42/ */ pathsToRemove := []string{ path.Join(lunPath, volume), lunPath, tpgtPath, path.Dir(tpgtPath), - path.Join(configDir, volume), } for _, p := range pathsToRemove { @@ -238,6 +250,24 @@ func teardown(volume string) error { return nil } +func finishTeardown(volume string) error { + /* + We're removing: + /sys/kernel/config/target/core/user_42/ + */ + pathsToRemove := []string{ + path.Join(configDir, volume), + } + + for _, p := range pathsToRemove { + err := remove(p) + if err != nil { + return err + } + } + + return nil +} func removeAsync(path string, done chan<- error) { logrus.Infof("Removing: %s", path) if err := os.Remove(path); err != nil && !os.IsNotExist(err) { diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index f8b5afad..f0c9875f 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -5,6 +5,7 @@ package tcmu #include #include +#include #include #include #include @@ -28,14 +29,16 @@ import ( ) var ( - log = logrus.WithFields(logrus.Fields{"pkg": "main"}) + log = logrus.WithFields(logrus.Fields{"pkg": "tcmu"}) // this is super dirty backend types.ReaderWriterAt cxt *C.struct_tcmulib_context volume string - done chan struct{} + done chan struct{} + devFd int32 + pipeFds []int ) type State struct { @@ -80,6 +83,7 @@ func devOpen(dev Device) int { return -C.EINVAL } state.volume = id + devFd = int32(C.tcmu_get_dev_fd(dev)) go state.HandleRequest(dev) @@ -98,7 +102,6 @@ func (s *State) HandleRequest(dev Device) { finished = true case success := <-ch: if !success { - log.Errorln("Fail to wait for next command") finished = true break } @@ -116,7 +119,12 @@ func (s *State) waitForNextCommand(dev Device, ch chan bool) { for { pfd := []unix.PollFd{ { - Fd: int32(C.tcmu_get_dev_fd(dev)), + Fd: devFd, + Events: unix.POLLIN, + Revents: 0, + }, + { + Fd: int32(pipeFds[0]), Events: unix.POLLIN, Revents: 0, }, @@ -127,6 +135,11 @@ func (s *State) waitForNextCommand(dev Device, ch chan bool) { ch <- false break } + if pfd[1].Revents == unix.POLLIN { + log.Infoln("Poll command receive finish signal") + ch <- false + break + } if pfd[0].Revents != 0 && pfd[0].Revents != unix.POLLIN { log.Errorln("Poll received unexpect event: ", pfd[0].Revents) ch <- false @@ -249,9 +262,14 @@ func devCheckConfig(cfg *C.char, reason **C.char) bool { func start(name string, rw types.ReaderWriterAt) error { if cxt == nil { + done = make(chan struct{}) // this is super dirty backend = rw volume = name + pipeFds = make([]int, 2) + if err := unix.Pipe(pipeFds); err != nil { + return err + } cxt = C.tcmu_init() if cxt == nil { return errors.New("TCMU ctx is nil") @@ -263,3 +281,21 @@ func start(name string, rw types.ReaderWriterAt) error { return nil } + +func stop() { + if cxt != nil { + // notify HandleRequest() that we're done + if _, err := unix.Write(pipeFds[1], []byte{0}); err != nil { + log.Errorln("Fail to notify poll for finishing: ", err) + } + close(done) + C.tcmulib_close(cxt) + if err := unix.Close(pipeFds[0]); err != nil { + log.Errorln("Fail to close pipeFds[0]: ", err) + } + if err := unix.Close(pipeFds[1]); err != nil { + log.Errorln("Fail to close pipeFds[1]: ", err) + } + cxt = nil + } +} From 0f5735e28d53c4d8f75ec9b70a131120b6a9ac8f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 20 Jun 2016 17:00:17 -0700 Subject: [PATCH 137/357] app: Remove excess amount of log for health check (#183) #121 They floods the real useful logs. --- app/controller.go | 6 +++++- app/replica.go | 15 +++++---------- util/util.go | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/controller.go b/app/controller.go index 81531381..c6305982 100644 --- a/app/controller.go +++ b/app/controller.go @@ -16,6 +16,7 @@ import ( "github.com/rancher/longhorn/controller" "github.com/rancher/longhorn/controller/rest" "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" ) var ( @@ -86,7 +87,10 @@ func startController(c *cli.Context) error { server := rest.NewServer(control) router := http.Handler(rest.NewRouter(server)) - router = handlers.LoggingHandler(os.Stdout, router) + router = util.FilteredLoggingHandler(map[string]struct{}{ + "/v1/volumes": struct{}{}, + "/v1/replicas": struct{}{}, + }, os.Stdout, router) router = handlers.ProxyHeaders(router) if len(replicas) > 0 { diff --git a/app/replica.go b/app/replica.go index fced7bf3..878e50ee 100644 --- a/app/replica.go +++ b/app/replica.go @@ -11,7 +11,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/docker/go-units" - "github.com/gorilla/handlers" "github.com/rancher/longhorn/replica" "github.com/rancher/longhorn/replica/rest" "github.com/rancher/longhorn/replica/rpc" @@ -83,16 +82,12 @@ func startReplica(c *cli.Context) error { go func() { server := rest.NewServer(s) router := http.Handler(rest.NewRouter(server)) - loggingHander := handlers.LoggingHandler(os.Stdout, router) - wrappedRouter := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - if req.URL.Path == "/ping" { - router.ServeHTTP(rw, req) - } else { - loggingHander.ServeHTTP(rw, req) - } - }) + router = util.FilteredLoggingHandler(map[string]struct{}{ + "/ping": struct{}{}, + "/v1/replicas/1": struct{}{}, + }, os.Stdout, router) logrus.Infof("Listening on control %s", controlAddress) - resp <- http.ListenAndServe(controlAddress, wrappedRouter) + resp <- http.ListenAndServe(controlAddress, router) }() go func() { diff --git a/util/util.go b/util/util.go index 757fed66..4ca0e5bd 100644 --- a/util/util.go +++ b/util/util.go @@ -2,9 +2,12 @@ package util import ( "fmt" + "io" + "net/http" "regexp" "strconv" + "github.com/gorilla/handlers" "github.com/satori/go.uuid" ) @@ -48,3 +51,28 @@ func Contains(arr []string, val string) bool { } return false } + +type filteredLoggingHandler struct { + filteredPaths map[string]struct{} + handler http.Handler + loggingHandler http.Handler +} + +func FilteredLoggingHandler(filteredPaths map[string]struct{}, writer io.Writer, router http.Handler) http.Handler { + return filteredLoggingHandler{ + filteredPaths: filteredPaths, + handler: router, + loggingHandler: handlers.LoggingHandler(writer, router), + } +} + +func (h filteredLoggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + switch req.Method { + case "GET": + if _, exists := h.filteredPaths[req.URL.Path]; exists { + h.handler.ServeHTTP(w, req) + return + } + } + h.loggingHandler.ServeHTTP(w, req) +} From 53d353dfba762a9893d01ed3969f65c7542f2f4c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 21 Jun 2016 15:14:00 -0700 Subject: [PATCH 138/357] replica: Remove `MarkAsRemoved` option replica will do it for every disk to be removed --- integration/core/test_replica.py | 5 +---- replica/client/client.go | 5 ++--- replica/replica.go | 26 ++++++++------------------ replica/replica_test.go | 12 ++++++------ replica/rest/model.go | 3 +-- replica/rest/replica.go | 2 +- replica/server.go | 6 +++--- sync/sync.go | 11 +++-------- 8 files changed, 25 insertions(+), 45 deletions(-) diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index 5974d58f..0552e534 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -170,10 +170,7 @@ def test_remove_disk(client): assert "Can not delete the active" in e ops = r.prepareremovedisk(name='001')["operations"] - assert len(ops) == 1 - assert ops[0].action == "markasremoved" - assert ops[0].source == "volume-snap-001.img" - assert ops[0].target == "" + assert len(ops) == 0 r = r.removedisk(name='volume-snap-001.img') assert r.state == 'dirty' diff --git a/replica/client/client.go b/replica/client/client.go index dc6224fc..c55957f8 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -108,15 +108,14 @@ func (c *ReplicaClient) SetRebuilding(rebuilding bool) error { }, nil) } -func (c *ReplicaClient) RemoveDisk(disk string, markOnly bool) error { +func (c *ReplicaClient) RemoveDisk(disk string) error { r, err := c.GetReplica() if err != nil { return err } return c.post(r.Actions["removedisk"], &rest.RemoveDiskInput{ - Name: disk, - MarkOnly: markOnly, + Name: disk, }, nil) } diff --git a/replica/replica.go b/replica/replica.go index 465436cb..445daa9d 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -72,9 +72,8 @@ type PrepareRemoveAction struct { } const ( - OpCoalesce = "coalesce" // Source is parent, target is child - OpRemove = "remove" - OpMarkAsRemoved = "markasremoved" + OpCoalesce = "coalesce" // Source is parent, target is child + OpRemove = "remove" ) func ReadInfo(dir string) (Info, error) { @@ -205,7 +204,7 @@ func (r *Replica) findDisk(name string) int { return 0 } -func (r *Replica) RemoveDiffDisk(name string, markOnly bool) error { +func (r *Replica) RemoveDiffDisk(name string) error { r.Lock() defer r.Unlock() @@ -213,14 +212,6 @@ func (r *Replica) RemoveDiffDisk(name string, markOnly bool) error { return fmt.Errorf("Can not delete the active differencing disk") } - if markOnly { - if err := r.markDiskAsRemoved(name); err != nil { - // ignore error deleting files - logrus.Errorf("Failed to delete %s: %v", name, err) - } - return nil - } - if err := r.removeDiskNode(name); err != nil { return err } @@ -243,7 +234,6 @@ func (r *Replica) removeDiskNode(name string) error { } // If snapshot has more than one child, we cannot really delete it - // Caller should call with markOnly=true instead if children.Cardinality() > 1 { return fmt.Errorf("Cannot remove snapshot %v with %v children", name, children.Cardinality()) @@ -291,6 +281,11 @@ func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) return nil, fmt.Errorf("Can not delete the active differencing disk") } + logrus.Infof("Mark disk %v as removed", disk) + if err := r.markDiskAsRemoved(disk); err != nil { + return nil, fmt.Errorf("Fail to mark disk %v as removed: %v", disk, err) + } + // 1) leaf node children := r.diskChildMap[disk] if children == nil { @@ -319,11 +314,6 @@ func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) } } - // 3) for other situation, we only mark it as removed - action = append(action, PrepareRemoveAction{ - Action: OpMarkAsRemoved, - Source: disk, - }) return action, nil } diff --git a/replica/replica_test.go b/replica/replica_test.go index be3e38a2..65c572e9 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -214,7 +214,7 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) - err = r.RemoveDiffDisk("volume-snap-002.img", false) + err = r.RemoveDiffDisk("volume-snap-002.img") c.Assert(err, IsNil) c.Assert(len(r.diskData), Equals, 3) @@ -224,7 +224,7 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) - err = r.RemoveDiffDisk("volume-snap-001.img", false) + err = r.RemoveDiffDisk("volume-snap-001.img") c.Assert(err, IsNil) c.Assert(len(r.diskData), Equals, 2) @@ -262,7 +262,7 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - err = r.RemoveDiffDisk("volume-snap-000.img", false) + err = r.RemoveDiffDisk("volume-snap-000.img") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) @@ -308,7 +308,7 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - err = r.RemoveDiffDisk("volume-snap-001.img", false) + err = r.RemoveDiffDisk("volume-snap-001.img") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) @@ -354,7 +354,7 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - err = r.RemoveDiffDisk("volume-head-002.img", false) + err = r.RemoveDiffDisk("volume-head-002.img") c.Assert(err, Not(IsNil)) } @@ -413,7 +413,7 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) - err = r.RemoveDiffDisk("volume-snap-001.img", false) + err = r.RemoveDiffDisk("volume-snap-001.img") c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) diff --git a/replica/rest/model.go b/replica/rest/model.go index 4fd7ad98..6dc14e06 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -42,8 +42,7 @@ type SnapshotInput struct { type RemoveDiskInput struct { client.Resource - Name string `json:"name"` - MarkOnly bool `json:"markonly"` + Name string `json:"name"` } type PrepareRemoveDiskInput struct { diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 9c24b1ff..b514bc99 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -86,7 +86,7 @@ func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { return err } - return s.doOp(req, s.s.RemoveDiffDisk(input.Name, input.MarkOnly)) + return s.doOp(req, s.s.RemoveDiffDisk(input.Name)) } func (s *Server) PrepareRemoveDisk(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/server.go b/replica/server.go index 98de429b..698b8e7e 100644 --- a/replica/server.go +++ b/replica/server.go @@ -177,7 +177,7 @@ func (s *Server) Snapshot(name string) error { return s.r.Snapshot(name) } -func (s *Server) RemoveDiffDisk(name string, markOnly bool) error { +func (s *Server) RemoveDiffDisk(name string) error { s.Lock() defer s.Unlock() @@ -185,8 +185,8 @@ func (s *Server) RemoveDiffDisk(name string, markOnly bool) error { return nil } - logrus.Infof("Removing disk: %s, markonly %v", name, markOnly) - return s.r.RemoveDiffDisk(name, markOnly) + logrus.Infof("Removing disk: %s", name) + return s.r.RemoveDiffDisk(name) } func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) { diff --git a/sync/sync.go b/sync/sync.go index e2f7441b..a7ffa1e7 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -45,13 +45,13 @@ func (t *Task) DeleteSnapshot(snapshot string) error { return nil } -func (t *Task) rmDisk(replicaInController *rest.Replica, disk string, markOnly bool) error { +func (t *Task) rmDisk(replicaInController *rest.Replica, disk string) error { repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return err } - return repClient.RemoveDisk(disk, markOnly) + return repClient.RemoveDisk(disk) } func getNameAndIndex(chain []string, snapshot string) (string, int) { @@ -101,12 +101,7 @@ func (t *Task) removeSnapshot(replicaInController *rest.Replica, snapshot string switch op.Action { case replica.OpRemove: logrus.Infof("Removing %s on %s", op.Source, replicaInController.Address) - if err := t.rmDisk(replicaInController, op.Source, false); err != nil { - return err - } - case replica.OpMarkAsRemoved: - logrus.Infof("Marking %v as removed on %v", op.Source, replicaInController.Address) - if err := t.rmDisk(replicaInController, op.Source, true); err != nil { + if err := t.rmDisk(replicaInController, op.Source); err != nil { return err } case replica.OpCoalesce: From e70551c633562209d516d967d09a53284270817c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 21 Jun 2016 16:50:40 -0700 Subject: [PATCH 139/357] replica: When removing an snapshot, check if it's parent is removable as well #184 --- integration/data/test_snapshot.py | 45 +++++++++++++++ replica/replica.go | 86 +++++++++++++++++---------- replica/replica_test.go | 96 +++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+), 29 deletions(-) diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index 9c2e367f..42daab97 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -84,3 +84,48 @@ def test_snapshot_revert_with_backing_file(backing_dev): # NOQA cmd.snapshot_revert(snap0) after = read_dev(dev, offset, length) assert before == after + + +def test_snapshot_rm_rolling(dev): # NOQA + offset = 0 + length = 128 + + snap1_data = common.random_string(length) + common.verify_data(dev, offset, snap1_data) + snap1 = cmd.snapshot_create() + + snapList = cmd.snapshot_ls() + assert snap1 in snapList + + cmd.snapshot_rm(snap1) + + snap2_data = common.random_string(length) + common.verify_data(dev, offset, snap2_data) + snap2 = cmd.snapshot_create() + + snapList = cmd.snapshot_ls() + assert snap1 not in snapList + assert snap2 in snapList + + # this should trigger real deletion of snap1 + cmd.snapshot_rm(snap2) + + snap3_data = common.random_string(length) + common.verify_data(dev, offset, snap3_data) + snap3 = cmd.snapshot_create() + + snap4_data = common.random_string(length) + common.verify_data(dev, offset, snap4_data) + snap4 = cmd.snapshot_create() + + snapList = cmd.snapshot_ls() + assert snap1 not in snapList + assert snap2 not in snapList + assert snap3 in snapList + assert snap4 in snapList + + # this should trigger real deletion of snap2 and snap3 + cmd.snapshot_rm(snap3) + + readed = read_dev(dev, offset, length) + assert readed == snap4_data diff --git a/replica/replica.go b/replica/replica.go index 445daa9d..ecbc1e8a 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -267,12 +267,13 @@ func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) r.Lock() defer r.Unlock() - action := []PrepareRemoveAction{} disk := name - if _, exists := r.diskData[disk]; !exists { + data, exists := r.diskData[disk] + if !exists { disk = GenerateSnapshotDiskName(name) - if _, exists := r.diskData[disk]; !exists { + data, exists = r.diskData[disk] + if !exists { return nil, fmt.Errorf("Can not find snapshot %v", disk) } } @@ -286,35 +287,62 @@ func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) return nil, fmt.Errorf("Fail to mark disk %v as removed: %v", disk, err) } - // 1) leaf node - children := r.diskChildMap[disk] - if children == nil { - action = append(action, PrepareRemoveAction{ - Action: OpRemove, - Source: disk, - }) - return action, nil - } - - // 2) has only one child and is not head - if children.Cardinality() == 1 { - child := (<-children.Iter()).(string) - if child != r.info.Head { - action = append(action, - PrepareRemoveAction{ - Action: OpCoalesce, - Source: disk, - Target: child, - }, - PrepareRemoveAction{ - Action: OpRemove, - Source: disk, - }) - return action, nil + targetDisks := []string{} + if data.Parent != "" { + parentData, exists := r.diskData[data.Parent] + if !exists { + return nil, fmt.Errorf("Can not find snapshot %v's parent %v", disk, data.Parent) + } + if parentData.Removed { + targetDisks = append(targetDisks, parentData.name) + } + } + targetDisks = append(targetDisks, disk) + actions, err := r.processPrepareRemoveDisks(targetDisks) + if err != nil { + return nil, err + } + return actions, nil +} + +func (r *Replica) processPrepareRemoveDisks(disks []string) ([]PrepareRemoveAction, error) { + actions := []PrepareRemoveAction{} + + for _, disk := range disks { + if _, exists := r.diskData[disk]; !exists { + return nil, fmt.Errorf("Wrong disk %v doesn't exist", disk) + } + + children := r.diskChildMap[disk] + // 1) leaf node + if children == nil { + actions = append(actions, PrepareRemoveAction{ + Action: OpRemove, + Source: disk, + }) + continue + } + + // 2) has only one child and is not head + if children.Cardinality() == 1 { + child := (<-children.Iter()).(string) + if child != r.info.Head { + actions = append(actions, + PrepareRemoveAction{ + Action: OpCoalesce, + Source: disk, + Target: child, + }, + PrepareRemoveAction{ + Action: OpRemove, + Source: disk, + }) + continue + } } } - return action, nil + return actions, nil } func (r *Replica) Info() Info { diff --git a/replica/replica_test.go b/replica/replica_test.go index 65c572e9..cf8bbdf2 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -435,6 +435,102 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) } +func (s *TestSuite) TestPrepareRemove(c *C) { + dir, err := ioutil.TempDir("", "replica") + c.Assert(err, IsNil) + defer os.RemoveAll(dir) + + r, err := New(9, 3, dir, nil) + c.Assert(err, IsNil) + defer r.Close() + + err = r.Snapshot("000") + c.Assert(err, IsNil) + + err = r.Snapshot("001") + c.Assert(err, IsNil) + + c.Assert(len(r.activeDiskData), Equals, 4) + c.Assert(len(r.volume.files), Equals, 4) + + /* + volume-snap-000.img + volume-snap-001.img + volume-head-002.img + */ + + actions, err := r.PrepareRemoveDisk("001") + c.Assert(err, IsNil) + c.Assert(actions, HasLen, 0) + c.Assert(r.activeDiskData[2].Removed, Equals, true) + + actions, err = r.PrepareRemoveDisk("volume-snap-000.img") + c.Assert(err, IsNil) + c.Assert(actions, HasLen, 2) + c.Assert(actions[0].Action, Equals, OpCoalesce) + c.Assert(actions[0].Source, Equals, "volume-snap-000.img") + c.Assert(actions[0].Target, Equals, "volume-snap-001.img") + c.Assert(actions[1].Action, Equals, OpRemove) + c.Assert(actions[1].Source, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Removed, Equals, true) + + err = r.Snapshot("002") + c.Assert(err, IsNil) + + /* + volume-snap-000.img (r) + volume-snap-001.img (r) + volume-snap-002.img + volume-head-003.img + */ + + c.Assert(len(r.activeDiskData), Equals, 5) + c.Assert(len(r.volume.files), Equals, 5) + + /* https://github.com/rancher/longhorn/issues/184 */ + actions, err = r.PrepareRemoveDisk("002") + c.Assert(err, IsNil) + c.Assert(actions, HasLen, 2) + c.Assert(actions[0].Action, Equals, OpCoalesce) + c.Assert(actions[0].Source, Equals, "volume-snap-001.img") + c.Assert(actions[0].Target, Equals, "volume-snap-002.img") + c.Assert(actions[1].Action, Equals, OpRemove) + c.Assert(actions[1].Source, Equals, "volume-snap-001.img") + + err = r.Snapshot("003") + c.Assert(err, IsNil) + + err = r.Snapshot("004") + c.Assert(err, IsNil) + + /* + volume-snap-000.img (r) + volume-snap-001.img (r) + volume-snap-002.img (r) + volume-snap-003.img + volume-snap-004.img + volume-head-005.img + */ + + c.Assert(len(r.activeDiskData), Equals, 7) + c.Assert(len(r.volume.files), Equals, 7) + + actions, err = r.PrepareRemoveDisk("003") + c.Assert(err, IsNil) + c.Assert(actions, HasLen, 4) + c.Assert(actions[0].Action, Equals, OpCoalesce) + c.Assert(actions[0].Source, Equals, "volume-snap-002.img") + c.Assert(actions[0].Target, Equals, "volume-snap-003.img") + c.Assert(actions[1].Action, Equals, OpRemove) + c.Assert(actions[1].Source, Equals, "volume-snap-002.img") + c.Assert(actions[2].Action, Equals, OpCoalesce) + c.Assert(actions[2].Source, Equals, "volume-snap-003.img") + c.Assert(actions[2].Target, Equals, "volume-snap-004.img") + c.Assert(actions[3].Action, Equals, OpRemove) + c.Assert(actions[3].Source, Equals, "volume-snap-003.img") + c.Assert(r.activeDiskData[4].Removed, Equals, true) +} + func byteEquals(c *C, expected, obtained []byte) { c.Assert(len(expected), Equals, len(obtained)) From 2dbd1eea37b086fea648c7fecbe8057a3c031fdb Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 22 Jun 2016 13:44:03 -0700 Subject: [PATCH 140/357] Update tcmu-runner dependency (#187) --- Dockerfile.dapper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index d3a8ef41..c74b75cc 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -45,9 +45,9 @@ RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/ # Build TCMU RUN cd /usr/src && \ - git clone https://github.com/yasker/tcmu-runner.git && \ + git clone https://github.com/open-iscsi/tcmu-runner.git && \ cd tcmu-runner && \ - git checkout ce3050a2b15830bafed0b21f488f2d26a86efb74 + git checkout f34b67c65b7844a6d3fcb24c2feaf7db90a889cd RUN cd /usr/src/tcmu-runner && \ cmake . -Dwith-glfs=false && \ make && \ From b6c5212e109dc6b902f832d8c95ee24f07965cfb Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 22 Jun 2016 16:13:56 -0700 Subject: [PATCH 141/357] package: launch script for simple version longhorn (#191) It will start an single replica longhorn system, running with TCMU frontend inside container. The volume size is 1Gb by default. It can be run with: docker run -it --privileged -v /dev:/host/dev -v /volume/ rancher/longhorn bash -c "launch-simple-longhorn volume_name" --- package/Dockerfile | 2 +- package/launch-simple-longhorn | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 package/launch-simple-longhorn diff --git a/package/Dockerfile b/package/Dockerfile index 64bdcf82..4f2b81ed 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -4,5 +4,5 @@ RUN apt-get update && apt-get install -y kmod curl nfs-common RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin -COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-with-vm-backing-file /usr/bin/ +COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/bin/ CMD ["longhorn"] diff --git a/package/launch-simple-longhorn b/package/launch-simple-longhorn new file mode 100755 index 00000000..e8f1c3f8 --- /dev/null +++ b/package/launch-simple-longhorn @@ -0,0 +1,17 @@ +set -x +modprobe configfs +modprobe target_core_user +mount -t configfs none /sys/kernel/config +mount --rbind /host/dev /dev + +if [ -z $1 ] +then + echo Need a volume name as first parameter + exit -1 +fi + +volume=$1 + +longhorn replica --size 1g --listen localhost:9502 /volume/ & +sleep 1 +exec longhorn --debug controller --frontend tcmu --replica tcp://localhost:9502 $volume From 1c5d3aacfa205691907d54d54152ec90ac762528 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Mon, 27 Jun 2016 17:16:44 -0700 Subject: [PATCH 142/357] Update volume driver Remove timeout on mkfs command --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index c74b75cc..a9a95f05 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN GOPATH=/tmp/docker-longhorn-driver && \ cd $GOPATH/src/github.com/rancher && \ git clone https://github.com/rancher/docker-longhorn-driver.git && \ cd docker-longhorn-driver && \ - git checkout 5b3d6b4004481a8151c60bed7e6b1471a4960419 && \ + git checkout ea7bf49977adb179a2d767f8a5dcf3ec380a34a2 && \ go build -o /usr/local/bin/docker-longhorn-driver # Install libqcow From 84e5aa2254c6a99c3feaec56d31a12f99981b33f Mon Sep 17 00:00:00 2001 From: jimengliu Date: Wed, 6 Jul 2016 14:54:55 -0700 Subject: [PATCH 143/357] Update vendor to latest sparse-tool commit (#197) --- trash.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trash.yml b/trash.yml index 76022611..9932723f 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 5b2050007378c7c0ffb0734299c157a4e81916aa + version: 8cc5ab1cdb90bbda9b3b8574a9b7f583b6091864 - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy From 266263cd79310de29cbda2d6216d532a32670ab1 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 8 Jul 2016 20:17:36 -0700 Subject: [PATCH 144/357] sync: Separate prepare and process remove disk (#198) We need to separate prepare and process because prepareRemoveSnapshot() will mark the snapshot as removed, and if it's blocked by sfold process, user will see different list of snapshots of two replicas --- sync/sync.go | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/sync/sync.go b/sync/sync.go index a7ffa1e7..f6fc1be3 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -23,6 +23,8 @@ func NewTask(controller string) *Task { } func (t *Task) DeleteSnapshot(snapshot string) error { + var err error + replicas, err := t.client.ListReplicas() if err != nil { return err @@ -36,8 +38,16 @@ func (t *Task) DeleteSnapshot(snapshot string) error { } } + ops := make(map[string][]replica.PrepareRemoveAction) + for _, replica := range replicas { + ops[replica.Address], err = t.prepareRemoveSnapshot(&replica, snapshot) + if err != nil { + return err + } + } + for _, replica := range replicas { - if err := t.removeSnapshot(&replica, snapshot); err != nil { + if err := t.processRemoveSnapshot(&replica, snapshot, ops[replica.Address]); err != nil { return err } } @@ -82,22 +92,39 @@ func (t *Task) isRebuilding(replicaInController *rest.Replica) (bool, error) { return replica.Rebuilding, nil } -func (t *Task) removeSnapshot(replicaInController *rest.Replica, snapshot string) error { +func (t *Task) prepareRemoveSnapshot(replicaInController *rest.Replica, snapshot string) ([]replica.PrepareRemoveAction, error) { if replicaInController.Mode != "RW" { - return fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) + return nil, fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) } repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { - return err + return nil, err } output, err := repClient.PrepareRemoveDisk(snapshot) + if err != nil { + return nil, err + } + + return output.Operations, nil +} + +func (t *Task) processRemoveSnapshot(replicaInController *rest.Replica, snapshot string, ops []replica.PrepareRemoveAction) error { + if len(ops) == 0 { + return nil + } + + if replicaInController.Mode != "RW" { + return fmt.Errorf("Can only removed snapshot from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) if err != nil { return err } - for _, op := range output.Operations { + for _, op := range ops { switch op.Action { case replica.OpRemove: logrus.Infof("Removing %s on %s", op.Source, replicaInController.Address) From 39f7d2919c8d98f45d72fcead6c43d570ccead20 Mon Sep 17 00:00:00 2001 From: jimengliu Date: Mon, 11 Jul 2016 11:08:57 -0700 Subject: [PATCH 145/357] Update vendor to latest sparse-tool commit (#199) --- trash.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trash.yml b/trash.yml index 9932723f..3e65c78b 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 8cc5ab1cdb90bbda9b3b8574a9b7f583b6091864 + version: 2ff044e474e8a863a337ebbee10a3c1413fb1dcb - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy From cfe065dae6c226498b19349f4d1bb70dcf3ee1ac Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Tue, 12 Jul 2016 12:54:36 -0400 Subject: [PATCH 146/357] Update share-mnt to v0.1.2 (#200) --- package/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Dockerfile b/package/Dockerfile index 4f2b81ed..167917f8 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get install -y kmod curl nfs-common -RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.0.3/share-mnt && \ +RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.1.2/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/bin/ From 8f513e13ea67c565ae51540c1b8ba420756f85a1 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:17:32 -0700 Subject: [PATCH 147/357] restdev: Update method to `readat` and `writeat` --- frontend/rest/model.go | 8 ++++---- frontend/rest/router.go | 4 ++-- integration/data/common.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/rest/model.go b/frontend/rest/model.go index 3655c830..d6899b5b 100644 --- a/frontend/rest/model.go +++ b/frontend/rest/model.go @@ -44,8 +44,8 @@ func NewVolume(context *api.ApiContext, name string) *Volume { Name: name, } - v.Actions["read"] = context.UrlBuilder.ActionLink(v.Resource, "read") - v.Actions["write"] = context.UrlBuilder.ActionLink(v.Resource, "write") + v.Actions["readat"] = context.UrlBuilder.ActionLink(v.Resource, "readat") + v.Actions["writeat"] = context.UrlBuilder.ActionLink(v.Resource, "writeat") return v } @@ -85,11 +85,11 @@ func NewSchema() *client.Schemas { volumes := schemas.AddType("volume", Volume{}) volumes.ResourceActions = map[string]client.Action{ - "read": client.Action{ + "readat": client.Action{ Input: "readInput", Output: "readOutput", }, - "write": client.Action{ + "writeat": client.Action{ Input: "writeInput", Output: "writeOutput", }, diff --git a/frontend/rest/router.go b/frontend/rest/router.go index e76868ed..b8d589c4 100644 --- a/frontend/rest/router.go +++ b/frontend/rest/router.go @@ -31,8 +31,8 @@ func NewRouter(s *Server) *mux.Router { // Volume router.Methods("GET").Path("/v1/volumes").Handler(f(schemas, s.ListVolumes)) router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) - router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "read").Handler(f(schemas, s.ReadAt)) - router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "write").Handler(f(schemas, s.WriteAt)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "readat").Handler(f(schemas, s.ReadAt)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "writeat").Handler(f(schemas, s.WriteAt)) return router } diff --git a/integration/data/common.py b/integration/data/common.py index ba4e9fb1..361bb3ed 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -149,11 +149,11 @@ def get_restdev(): def write_dev(dev, offset, data): l = len(data) encoded_data = base64.encodestring(data) - dev.write(offset=offset, length=l, data=encoded_data) + dev.writeat(offset=offset, length=l, data=encoded_data) def read_dev(dev, offset, length): - data = dev.read(offset=offset, length=length)["data"] + data = dev.readat(offset=offset, length=length)["data"] return base64.decodestring(data) From c52c5baa4f665369cfe2035da55ac1313befb675 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:17:32 -0700 Subject: [PATCH 148/357] restdev: restdev class for test --- integration/data/common.py | 17 ++++++----------- integration/data/frontend.py | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 integration/data/frontend.py diff --git a/integration/data/common.py b/integration/data/common.py index 361bb3ed..d7d05f2d 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -1,6 +1,5 @@ import random import string -import base64 import subprocess import os @@ -9,6 +8,9 @@ import pytest import cattle +from frontend import restdev + + REPLICA1 = 'tcp://localhost:9502' REPLICA1_SCHEMA = 'http://localhost:9502/v1/schemas' REPLICA2 = 'tcp://localhost:9505' @@ -139,22 +141,15 @@ def open_replica(client, backing_file=None): def get_restdev(): - url = 'http://localhost:9414/v1/schemas' - c = cattle.from_env(url=url) - dev = c.list_volume()[0] - assert dev.name == "test-volume" - return dev + return restdev("test-volume") def write_dev(dev, offset, data): - l = len(data) - encoded_data = base64.encodestring(data) - dev.writeat(offset=offset, length=l, data=encoded_data) + return dev.writeat(offset, data) def read_dev(dev, offset, length): - data = dev.readat(offset=offset, length=length)["data"] - return base64.decodestring(data) + return dev.readat(offset, length) def random_string(length): diff --git a/integration/data/frontend.py b/integration/data/frontend.py new file mode 100644 index 00000000..c1942d90 --- /dev/null +++ b/integration/data/frontend.py @@ -0,0 +1,22 @@ +import base64 + +import cattle + + +class restdev: + + def __init__(self, volume): + url = 'http://localhost:9414/v1/schemas' + c = cattle.from_env(url=url) + dev = c.list_volume()[0] + assert dev.name == volume + self.dev = dev + + def readat(self, offset, length): + data = self.dev.readat(offset=offset, length=length)["data"] + return base64.decodestring(data) + + def writeat(self, offset, data): + l = len(data) + encoded_data = base64.encodestring(data) + return self.dev.writeat(offset=offset, length=l, data=encoded_data) From b4522e15337f9d41a155b1ef0750af3d9092036f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:17:32 -0700 Subject: [PATCH 149/357] test: Add full disk validation for backup/restore --- integration/data/common.py | 7 ++++++- integration/data/test_backup.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/integration/data/common.py b/integration/data/common.py index d7d05f2d..18ce5c33 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -1,6 +1,7 @@ import random import string import subprocess +import hashlib import os from os import path @@ -21,7 +22,7 @@ BACKED_REPLICA2 = 'tcp://localhost:9605' BACKED_REPLICA2_SCHEMA = 'http://localhost:9605/v1/schemas' -SIZE = 1024 * 4096 +SIZE = 4 * 1024 * 1024 BACKUP_DIR = '/tmp/longhorn-backup' BACKUP_DEST = 'vfs://' + BACKUP_DIR @@ -178,3 +179,7 @@ def read_from_backing_file(offset, length): data = f.read(length) f.close() return data + + +def checksum_dev(dev): + return hashlib.sha512(dev.readat(0, SIZE)).hexdigest() diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index 0c544dcc..f94dc87b 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -17,6 +17,7 @@ def test_backup(dev): # NOQA snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) + snap1_checksum = common.checksum_dev(dev) snap1 = cmd.snapshot_create() backup1 = cmd.backup_create(snap1, BACKUP_DEST) @@ -28,6 +29,7 @@ def test_backup(dev): # NOQA snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) + snap2_checksum = common.checksum_dev(dev) snap2 = cmd.snapshot_create() backup2 = cmd.backup_create(snap2, BACKUP_DEST) @@ -39,6 +41,7 @@ def test_backup(dev): # NOQA snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) + snap3_checksum = common.checksum_dev(dev) snap3 = cmd.snapshot_create() backup3 = cmd.backup_create(snap3, BACKUP_DEST) @@ -51,6 +54,8 @@ def test_backup(dev): # NOQA cmd.backup_restore(backup3) readed = read_dev(dev, offset, length) assert readed == snap3_data + c = common.checksum_dev(dev) + assert c == snap3_checksum cmd.backup_rm(backup3) with pytest.raises(subprocess.CalledProcessError): @@ -62,6 +67,8 @@ def test_backup(dev): # NOQA cmd.backup_restore(backup1) readed = read_dev(dev, offset, length) assert readed == snap1_data + c = common.checksum_dev(dev) + assert c == snap1_checksum cmd.backup_rm(backup1) with pytest.raises(subprocess.CalledProcessError): @@ -73,6 +80,8 @@ def test_backup(dev): # NOQA cmd.backup_restore(backup2) readed = read_dev(dev, offset, length) assert readed == snap2_data + c = common.checksum_dev(dev) + assert c == snap2_checksum cmd.backup_rm(backup2) with pytest.raises(subprocess.CalledProcessError): @@ -91,6 +100,7 @@ def test_backup_with_backing_file(backing_dev): # NOQA snap0 = cmd.snapshot_create() before = read_dev(dev, offset, length) assert before != "" + snap0_checksum = common.checksum_dev(dev) exists = read_from_backing_file(offset, length) assert before == exists @@ -107,6 +117,8 @@ def test_backup_with_backing_file(backing_dev): # NOQA cmd.backup_restore(backup0) after = read_dev(dev, offset, length) assert before == after + c = common.checksum_dev(dev) + assert c == snap0_checksum cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): @@ -133,6 +145,7 @@ def test_backup_hole_with_backing_file(backing_dev): # NOQA snap1_data = common.random_string(length1) common.verify_data(dev, offset1, snap1_data) + snap1_checksum = common.checksum_dev(dev) snap1 = cmd.snapshot_create() boundary_data_backup1 = read_dev(dev, boundary_offset, boundary_length) @@ -141,6 +154,7 @@ def test_backup_hole_with_backing_file(backing_dev): # NOQA snap2_data = common.random_string(length2) common.verify_data(dev, offset2, snap2_data) + snap2_checksum = common.checksum_dev(dev) snap2 = cmd.snapshot_create() boundary_data_backup2 = read_dev(dev, boundary_offset, boundary_length) @@ -152,9 +166,13 @@ def test_backup_hole_with_backing_file(backing_dev): # NOQA assert readed == boundary_data_backup1 readed = read_dev(dev, hole_offset, hole_length) assert readed == hole_data_backup1 + c = common.checksum_dev(dev) + assert c == snap1_checksum cmd.backup_restore(backup2) readed = read_dev(dev, boundary_offset, boundary_length) assert readed == boundary_data_backup2 readed = read_dev(dev, hole_offset, hole_length) assert readed == hole_data_backup2 + c = common.checksum_dev(dev) + assert c == snap2_checksum From c753ea6d8238306ea0d06ead5c5d8e8e8123410a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:17:32 -0700 Subject: [PATCH 150/357] Update convoy objectstore and trash --- trash.yml | 2 +- .../github.com/rancher/convoy/api/response.go | 3 ++- .../convoy/convoydriver/convoydriver.go | 3 ++- .../rancher/convoy/logging/logging.go | 1 + .../rancher/convoy/objectstore/config.go | 3 ++- .../rancher/convoy/objectstore/deltablock.go | 27 ++++++++++++++++--- .../rancher/convoy/objectstore/driver.go | 3 ++- .../rancher/convoy/objectstore/objectstore.go | 3 ++- .../rancher/convoy/objectstore/singlefile.go | 3 ++- vendor/github.com/rancher/convoy/s3/s3.go | 5 ++-- .../rancher/convoy/s3/s3_service.go | 3 ++- vendor/github.com/rancher/convoy/util/util.go | 27 +++++++++++++++++++ .../rancher/convoy/vfs/vfs_objectstore.go | 7 ++--- 13 files changed, 73 insertions(+), 17 deletions(-) diff --git a/trash.yml b/trash.yml index 76022611..cb6a1bec 100644 --- a/trash.yml +++ b/trash.yml @@ -29,7 +29,7 @@ import: - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy - version: e06007546b98d850817b1daaf7196c00571ffa52 + version: 9e0fd9a3a77dc4b8ee7eab859a420b7764729271 - package: github.com/mcuadros/go-version version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 - package: golang.org/x/sys/unix diff --git a/vendor/github.com/rancher/convoy/api/response.go b/vendor/github.com/rancher/convoy/api/response.go index 11ddf6b3..964a4f58 100644 --- a/vendor/github.com/rancher/convoy/api/response.go +++ b/vendor/github.com/rancher/convoy/api/response.go @@ -3,10 +3,11 @@ package api import ( "encoding/json" "fmt" - "github.com/Sirupsen/logrus" "runtime" "runtime/debug" "strings" + + "github.com/Sirupsen/logrus" ) type ErrorResponse struct { diff --git a/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go b/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go index 16c864c5..dd14d0d1 100644 --- a/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go +++ b/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go @@ -2,8 +2,9 @@ package convoydriver import ( "fmt" - "github.com/Sirupsen/logrus" "path/filepath" + + "github.com/Sirupsen/logrus" ) /* diff --git a/vendor/github.com/rancher/convoy/logging/logging.go b/vendor/github.com/rancher/convoy/logging/logging.go index cd7c812d..f3a02792 100644 --- a/vendor/github.com/rancher/convoy/logging/logging.go +++ b/vendor/github.com/rancher/convoy/logging/logging.go @@ -2,6 +2,7 @@ package logging import ( "fmt" + "github.com/Sirupsen/logrus" ) diff --git a/vendor/github.com/rancher/convoy/objectstore/config.go b/vendor/github.com/rancher/convoy/objectstore/config.go index 59eff438..0b39b854 100644 --- a/vendor/github.com/rancher/convoy/objectstore/config.go +++ b/vendor/github.com/rancher/convoy/objectstore/config.go @@ -4,9 +4,10 @@ import ( "bytes" "encoding/json" "fmt" + "path/filepath" + "github.com/Sirupsen/logrus" "github.com/rancher/convoy/util" - "path/filepath" . "github.com/rancher/convoy/logging" ) diff --git a/vendor/github.com/rancher/convoy/objectstore/deltablock.go b/vendor/github.com/rancher/convoy/objectstore/deltablock.go index d5150859..936b9774 100644 --- a/vendor/github.com/rancher/convoy/objectstore/deltablock.go +++ b/vendor/github.com/rancher/convoy/objectstore/deltablock.go @@ -2,13 +2,14 @@ package objectstore import ( "fmt" - "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/metadata" - "github.com/rancher/convoy/util" "io" "os" "path/filepath" + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/metadata" + "github.com/rancher/convoy/util" + . "github.com/rancher/convoy/logging" ) @@ -239,19 +240,29 @@ func RestoreDeltaBlockBackup(backupURL, volDevName string) error { return err } - if _, err := loadVolume(srcVolumeName, bsDriver); err != nil { + vol, err := loadVolume(srcVolumeName, bsDriver) + if err != nil { return generateError(logrus.Fields{ LOG_FIELD_VOLUME: srcVolumeName, LOG_FIELD_BACKUP_URL: backupURL, }, "Volume doesn't exist in objectstore: %v", err) } + if vol.Size == 0 || vol.Size%DEFAULT_BLOCK_SIZE != 0 { + return fmt.Errorf("Read invalid volume size %v", vol.Size) + } + volDev, err := os.Create(volDevName) if err != nil { return err } defer volDev.Close() + stat, err := volDev.Stat() + if err != nil { + return err + } + backup, err := loadBackup(srcBackupName, srcVolumeName, bsDriver) if err != nil { return err @@ -287,6 +298,14 @@ func RestoreDeltaBlockBackup(backupURL, volDevName string) error { } } + // We want to truncate regular files, but not device + if stat.Mode()&os.ModeType == 0 { + log.Debugf("Truncate %v to size %v", volDevName, vol.Size) + if err := volDev.Truncate(vol.Size); err != nil { + return err + } + } + return nil } diff --git a/vendor/github.com/rancher/convoy/objectstore/driver.go b/vendor/github.com/rancher/convoy/objectstore/driver.go index b9de7be8..6d7428e2 100644 --- a/vendor/github.com/rancher/convoy/objectstore/driver.go +++ b/vendor/github.com/rancher/convoy/objectstore/driver.go @@ -2,10 +2,11 @@ package objectstore import ( "fmt" - "github.com/Sirupsen/logrus" "io" "net/url" + "github.com/Sirupsen/logrus" + . "github.com/rancher/convoy/logging" ) diff --git a/vendor/github.com/rancher/convoy/objectstore/objectstore.go b/vendor/github.com/rancher/convoy/objectstore/objectstore.go index a745ae61..d3c5e376 100644 --- a/vendor/github.com/rancher/convoy/objectstore/objectstore.go +++ b/vendor/github.com/rancher/convoy/objectstore/objectstore.go @@ -2,9 +2,10 @@ package objectstore import ( "fmt" - "github.com/rancher/convoy/util" "net/url" "strconv" + + "github.com/rancher/convoy/util" ) type Volume struct { diff --git a/vendor/github.com/rancher/convoy/objectstore/singlefile.go b/vendor/github.com/rancher/convoy/objectstore/singlefile.go index 0ecda0b5..ac070123 100644 --- a/vendor/github.com/rancher/convoy/objectstore/singlefile.go +++ b/vendor/github.com/rancher/convoy/objectstore/singlefile.go @@ -2,9 +2,10 @@ package objectstore import ( "fmt" + "path/filepath" + "github.com/Sirupsen/logrus" "github.com/rancher/convoy/util" - "path/filepath" . "github.com/rancher/convoy/logging" ) diff --git a/vendor/github.com/rancher/convoy/s3/s3.go b/vendor/github.com/rancher/convoy/s3/s3.go index 6af0931e..99795b88 100644 --- a/vendor/github.com/rancher/convoy/s3/s3.go +++ b/vendor/github.com/rancher/convoy/s3/s3.go @@ -2,13 +2,14 @@ package s3 import ( "fmt" - "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/objectstore" "io" "net/url" "os" "path/filepath" "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/objectstore" ) var ( diff --git a/vendor/github.com/rancher/convoy/s3/s3_service.go b/vendor/github.com/rancher/convoy/s3/s3_service.go index 4107c8ff..00e495e7 100644 --- a/vendor/github.com/rancher/convoy/s3/s3_service.go +++ b/vendor/github.com/rancher/convoy/s3/s3_service.go @@ -2,11 +2,12 @@ package s3 import ( "fmt" + "io" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" - "io" ) type S3Service struct { diff --git a/vendor/github.com/rancher/convoy/util/util.go b/vendor/github.com/rancher/convoy/util/util.go index 9e1cacd0..f6eeecf9 100644 --- a/vendor/github.com/rancher/convoy/util/util.go +++ b/vendor/github.com/rancher/convoy/util/util.go @@ -208,6 +208,33 @@ func DetachLoopbackDevice(file, dev string) error { return nil } +func ListLoopbackDevice(file string) ([]string, error) { + params := []string{"-O", "NAME", "-n", "-j"} + params = append(params, file) + out, err := Execute("losetup", params) + if err != nil { + return nil, err + } + out = strings.TrimSpace(out) + if len(out) == 0 { + return []string{}, nil + } + return strings.Split(out, "\n"), nil +} + +func DetachAnyLoopbackDevice(file string) error { + devices, err := ListLoopbackDevice(file) + if err != nil { + return err + } + for _, dev := range devices { + if err := DetachLoopbackDevice(file, dev); err != nil { + return err + } + } + return nil +} + func ValidateName(name string) bool { validName := regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`) return validName.MatchString(name) diff --git a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go b/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go index 7a8a299b..4f23d900 100644 --- a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go +++ b/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go @@ -2,14 +2,15 @@ package vfs import ( "fmt" - "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/objectstore" - "github.com/rancher/convoy/util" "io" "net/url" "os" "path/filepath" "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/convoy/objectstore" + "github.com/rancher/convoy/util" ) var ( From c148619ff7050eefdd475d045aef2c66a6b7c28f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 151/357] fuse: Add fuse frontend --- Dockerfile.dapper | 3 +- app/controller_fusedev.go | 9 + frontend/fusedev/frontend.go | 31 + frontend/fusedev/fuse.go | 265 +++++++ package/Dockerfile | 2 +- trash.yml | 2 + vendor/github.com/hanwen/go-fuse/.gitignore | 14 + vendor/github.com/hanwen/go-fuse/CONTRIBUTING | 22 + vendor/github.com/hanwen/go-fuse/LICENSE | 30 + vendor/github.com/hanwen/go-fuse/README | 150 ++++ vendor/github.com/hanwen/go-fuse/all.bash | 33 + .../github.com/hanwen/go-fuse/fuse/.gitignore | 1 + vendor/github.com/hanwen/go-fuse/fuse/api.go | 131 ++++ vendor/github.com/hanwen/go-fuse/fuse/attr.go | 75 ++ .../hanwen/go-fuse/fuse/attr_darwin.go | 22 + .../hanwen/go-fuse/fuse/attr_linux.go | 23 + .../hanwen/go-fuse/fuse/bufferpool.go | 95 +++ .../hanwen/go-fuse/fuse/constants.go | 31 + .../hanwen/go-fuse/fuse/constants_freebsd.go | 5 + .../hanwen/go-fuse/fuse/constants_linux.go | 8 + .../hanwen/go-fuse/fuse/defaultraw.go | 148 ++++ .../hanwen/go-fuse/fuse/direntry.go | 98 +++ .../hanwen/go-fuse/fuse/lockingfs.go | 206 +++++ vendor/github.com/hanwen/go-fuse/fuse/misc.go | 84 ++ .../hanwen/go-fuse/fuse/mount_darwin.go | 145 ++++ .../hanwen/go-fuse/fuse/mount_linux.go | 152 ++++ .../hanwen/go-fuse/fuse/nodefs/api.go | 181 +++++ .../hanwen/go-fuse/fuse/nodefs/defaultfile.go | 70 ++ .../hanwen/go-fuse/fuse/nodefs/defaultnode.go | 165 ++++ .../hanwen/go-fuse/fuse/nodefs/dir.go | 114 +++ .../hanwen/go-fuse/fuse/nodefs/files.go | 249 ++++++ .../go-fuse/fuse/nodefs/files_darwin.go | 99 +++ .../hanwen/go-fuse/fuse/nodefs/files_linux.go | 45 ++ .../hanwen/go-fuse/fuse/nodefs/fsconnector.go | 419 ++++++++++ .../hanwen/go-fuse/fuse/nodefs/fsmount.go | 154 ++++ .../hanwen/go-fuse/fuse/nodefs/fsops.go | 465 +++++++++++ .../hanwen/go-fuse/fuse/nodefs/fuse.go | 15 + .../hanwen/go-fuse/fuse/nodefs/handle.go | 147 ++++ .../hanwen/go-fuse/fuse/nodefs/inode.go | 285 +++++++ .../hanwen/go-fuse/fuse/nodefs/lockingfile.go | 99 +++ .../hanwen/go-fuse/fuse/nodefs/memnode.go | 228 ++++++ .../hanwen/go-fuse/fuse/nodefs/nodefs.go | 9 + .../hanwen/go-fuse/fuse/nodefs/print.go | 14 + .../go-fuse/fuse/nodefs/syscall_linux.go | 16 + .../github.com/hanwen/go-fuse/fuse/opcode.go | 642 +++++++++++++++ .../hanwen/go-fuse/fuse/pathfs/api.go | 78 ++ .../hanwen/go-fuse/fuse/pathfs/copy.go | 57 ++ .../hanwen/go-fuse/fuse/pathfs/default.go | 118 +++ .../hanwen/go-fuse/fuse/pathfs/locking.go | 163 ++++ .../hanwen/go-fuse/fuse/pathfs/loopback.go | 162 ++++ .../go-fuse/fuse/pathfs/loopback_darwin.go | 59 ++ .../go-fuse/fuse/pathfs/loopback_linux.go | 79 ++ .../hanwen/go-fuse/fuse/pathfs/pathfs.go | 737 ++++++++++++++++++ .../hanwen/go-fuse/fuse/pathfs/prefixfs.go | 128 +++ .../hanwen/go-fuse/fuse/pathfs/readonlyfs.go | 119 +++ .../go-fuse/fuse/pathfs/syscall_linux.go | 140 ++++ .../github.com/hanwen/go-fuse/fuse/print.go | 246 ++++++ .../hanwen/go-fuse/fuse/print_darwin.go | 50 ++ .../hanwen/go-fuse/fuse/print_linux.go | 58 ++ vendor/github.com/hanwen/go-fuse/fuse/read.go | 71 ++ .../github.com/hanwen/go-fuse/fuse/request.go | 213 +++++ .../hanwen/go-fuse/fuse/request_darwin.go | 9 + .../hanwen/go-fuse/fuse/request_linux.go | 9 + .../github.com/hanwen/go-fuse/fuse/server.go | 519 ++++++++++++ .../hanwen/go-fuse/fuse/server_darwin.go | 28 + .../hanwen/go-fuse/fuse/server_linux.go | 38 + .../hanwen/go-fuse/fuse/splice_darwin.go | 13 + .../hanwen/go-fuse/fuse/splice_linux.go | 93 +++ .../hanwen/go-fuse/fuse/syscall_darwin.go | 135 ++++ .../hanwen/go-fuse/fuse/syscall_linux.go | 45 ++ .../hanwen/go-fuse/fuse/typeprint.go | 5 + .../github.com/hanwen/go-fuse/fuse/types.go | 431 ++++++++++ .../hanwen/go-fuse/fuse/types_darwin.go | 131 ++++ .../hanwen/go-fuse/fuse/types_linux.go | 98 +++ .../github.com/hanwen/go-fuse/fuse/upgrade.go | 320 ++++++++ .../github.com/hanwen/go-fuse/splice/copy.go | 66 ++ .../github.com/hanwen/go-fuse/splice/pair.go | 64 ++ .../hanwen/go-fuse/splice/pair_darwin.go | 18 + .../hanwen/go-fuse/splice/pair_linux.go | 33 + .../github.com/hanwen/go-fuse/splice/pool.go | 115 +++ .../hanwen/go-fuse/splice/splice.go | 86 ++ 81 files changed, 9933 insertions(+), 2 deletions(-) create mode 100644 app/controller_fusedev.go create mode 100644 frontend/fusedev/frontend.go create mode 100644 frontend/fusedev/fuse.go create mode 100644 vendor/github.com/hanwen/go-fuse/.gitignore create mode 100644 vendor/github.com/hanwen/go-fuse/CONTRIBUTING create mode 100644 vendor/github.com/hanwen/go-fuse/LICENSE create mode 100644 vendor/github.com/hanwen/go-fuse/README create mode 100755 vendor/github.com/hanwen/go-fuse/all.bash create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/.gitignore create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/api.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/attr.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/constants.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/direntry.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/misc.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/opcode.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/print.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/print_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/read.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/request.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/request_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/server.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/server_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/typeprint.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/types.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/types_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/fuse/upgrade.go create mode 100644 vendor/github.com/hanwen/go-fuse/splice/copy.go create mode 100644 vendor/github.com/hanwen/go-fuse/splice/pair.go create mode 100644 vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go create mode 100644 vendor/github.com/hanwen/go-fuse/splice/pair_linux.go create mode 100644 vendor/github.com/hanwen/go-fuse/splice/pool.go create mode 100644 vendor/github.com/hanwen/go-fuse/splice/splice.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index a9a95f05..587f2871 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -24,7 +24,8 @@ RUN apt-get update && \ pkg-config \ psmisc \ python-tox \ - qemu-utils + qemu-utils \ + fuse # Install Go 1.6 RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz diff --git a/app/controller_fusedev.go b/app/controller_fusedev.go new file mode 100644 index 00000000..711f05b9 --- /dev/null +++ b/app/controller_fusedev.go @@ -0,0 +1,9 @@ +package app + +import ( + "github.com/rancher/longhorn/frontend/fusedev" +) + +func init() { + frontends["fuse"] = fusedev.New() +} diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go new file mode 100644 index 00000000..5e58b023 --- /dev/null +++ b/frontend/fusedev/frontend.go @@ -0,0 +1,31 @@ +package fusedev + +import ( + "github.com/rancher/longhorn/types" +) + +func New() types.Frontend { + return &Fuse{} +} + +type Fuse struct { + fs *FuseFs +} + +func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { + log.Infof("Activate FUSE frontend for %v, size %v, sector size %v", name, size, sectorSize) + fs, err := start(name, size, sectorSize, rw) + if err != nil { + return err + } + f.fs = fs + return nil +} + +func (f *Fuse) Shutdown() error { + if f.fs == nil { + return nil + } + log.Infof("Shutdown FUSE frontend for %v", f.fs.Volume) + return f.fs.Stop() +} diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go new file mode 100644 index 00000000..0cac440c --- /dev/null +++ b/frontend/fusedev/fuse.go @@ -0,0 +1,265 @@ +package fusedev + +import ( + "fmt" + "os" + "path/filepath" + "time" + + "github.com/Sirupsen/logrus" + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" + "github.com/hanwen/go-fuse/fuse/pathfs" + "github.com/rancher/convoy/util" + "golang.org/x/sys/unix" + + "github.com/rancher/longhorn/types" +) + +type FuseFs struct { + pathfs.FileSystem + Volume string + file *FuseFile + lodev string + dev string +} + +type FuseFile struct { + nodefs.File + Backend types.ReaderWriterAt + Size int64 + SectorSize int64 +} + +const ( + ImageSuffix = ".img" + DevPath = "/dev/longhorn/" + MountBase = "/tmp/longhorn-fuse-mount" +) + +var ( + log = logrus.WithFields(logrus.Fields{"pkg": "fusedev"}) +) + +func start(name string, size, sectorSize int64, rw types.ReaderWriterAt) (*FuseFs, error) { + fs := &FuseFs{ + FileSystem: pathfs.NewDefaultFileSystem(), + Volume: name, + file: &FuseFile{ + File: nodefs.NewDefaultFile(), + Backend: rw, + Size: size, + SectorSize: sectorSize, + }, + } + newFs := pathfs.NewPathNodeFs(fs, nil) + + server, _, err := nodefs.MountRoot(fs.GetMountDir(), newFs.Root(), nil) + /* + conn := nodefs.NewFileSystemConnector(newFs.Root(), nil) + opts := &fuse.MountOptions{ + MaxBackground: 12, + Options: []string{"direct_io"}, + } + server, err := fuse.NewServer(conn.RawFS(), fs.GetMountDir(), opts) + */ + if err != nil { + return nil, err + } + // This will be stopped when umount happens + go server.Serve() + + if err := fs.createDev(); err != nil { + return nil, err + } + return fs, nil + +} + +func (fs *FuseFs) Stop() error { + if err := fs.removeDev(); err != nil { + return err + } + if err := fs.umountFuse(); err != nil { + return err + } + return nil +} + +func (fs *FuseFs) createDev() error { + if err := os.MkdirAll(DevPath, 0700); err != nil { + log.Fatalln("Cannot create directory ", DevPath) + } + + dev := filepath.Join(DevPath, fs.Volume) + + if _, err := os.Stat(dev); err == nil { + return fmt.Errorf("Device %s already exists, can not create", dev) + } + + found := false + path := fs.getImageFileFullPath() + for i := 0; i < 30; i++ { + var err error + matches, err := filepath.Glob(path) + if len(matches) > 0 && err == nil { + found = true + break + } + + logrus.Infof("Waiting for %s", path) + time.Sleep(1 * time.Second) + } + + if !found { + return fmt.Errorf("Fail to wait for %v", path) + } + + logrus.Infof("Attaching loopback device %s", fs.lodev) + lodev, err := util.AttachLoopbackDevice(path, false) + if err != nil { + return err + } + + stat := unix.Stat_t{} + if err := unix.Stat(lodev, &stat); err != nil { + return err + } + major := int(stat.Rdev / 256) + minor := int(stat.Rdev % 256) + logrus.Infof("Creating device %s %d:%d", dev, major, minor) + if err := mknod(dev, major, minor); err != nil { + return err + } + fs.lodev = lodev + fs.dev = dev + return nil +} + +func (fs *FuseFs) removeDev() error { + if fs.dev == "" { + return nil + } + + logrus.Infof("Removing device %s", fs.dev) + if _, err := os.Stat(fs.dev); err == nil { + if err := remove(fs.dev); err != nil { + return err + } + } + fs.dev = "" + + logrus.Infof("Detaching loopback device %s", fs.lodev) + if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), fs.lodev); err != nil { + return err + } + fs.lodev = "" + return nil +} + +func (fs *FuseFs) umountFuse() error { + if err := unix.Unmount(fs.GetMountDir(), 0); err != nil { + return err + } + return nil +} + +func (fs *FuseFs) GetMountDir() string { + d := filepath.Join(MountBase, fs.Volume) + if err := os.MkdirAll(d, 0700); err != nil { + log.Fatal("Cannot create directory ", d) + } + return d +} + +func (fs *FuseFs) getImageFileName() string { + return fs.Volume + ImageSuffix +} + +func (fs *FuseFs) getImageFileFullPath() string { + return filepath.Join(fs.GetMountDir(), fs.getImageFileName()) +} + +func (fs *FuseFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + switch name { + case fs.getImageFileName(): + return &fuse.Attr{ + Mode: fuse.S_IFREG | 0644, Size: uint64(fs.file.Size), + }, fuse.OK + case "": + return &fuse.Attr{ + Mode: fuse.S_IFDIR | 0755, + }, fuse.OK + } + return nil, fuse.ENOENT +} + +func (fs *FuseFs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { + if name == "" { + return []fuse.DirEntry{{Name: fs.getImageFileName(), Mode: fuse.S_IFREG}}, fuse.OK + } + return nil, fuse.ENOENT +} + +func (fs *FuseFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) { + if name != fs.getImageFileName() { + return nil, fuse.ENOENT + } + return fs.file, fuse.OK +} + +func (f *FuseFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) { + l := int64(len(dest)) + if off+l > f.Size { + l = f.Size - off + } + _, err := f.Backend.ReadAt(dest[:l], off) + if err != nil { + log.Errorln("read failed: ", err.Error()) + return nil, fuse.EIO + } + return fuse.ReadResultData(dest[:l]), fuse.OK +} + +func (f *FuseFile) Write(data []byte, off int64) (uint32, fuse.Status) { + l := int64(len(data)) + if off+l > f.Size { + l = f.Size - off + } + + written, err := f.Backend.WriteAt(data[:l], off) + if err != nil { + log.Errorln("write failed: ", err.Error()) + return 0, fuse.EIO + } + return uint32(written), fuse.OK +} + +func mknod(device string, major, minor int) error { + var fileMode os.FileMode = 0600 + fileMode |= unix.S_IFBLK + dev := int((major << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)) + + return unix.Mknod(device, uint32(fileMode), dev) +} + +func removeAsync(path string, done chan<- error) { + logrus.Infof("Removing: %s", path) + if err := os.Remove(path); err != nil && !os.IsNotExist(err) { + logrus.Errorf("Unable to remove: %v", path) + done <- err + } + logrus.Debugf("Removed: %s", path) + done <- nil +} + +func remove(path string) error { + done := make(chan error) + go removeAsync(path, done) + select { + case err := <-done: + return err + case <-time.After(30 * time.Second): + return fmt.Errorf("Timeout trying to delete %s.", path) + } +} diff --git a/package/Dockerfile b/package/Dockerfile index 167917f8..add6a6d4 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y kmod curl nfs-common +RUN apt-get update && apt-get install -y kmod curl nfs-common fuse RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.1.2/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin diff --git a/trash.yml b/trash.yml index 7b6fa9f5..3ea29425 100644 --- a/trash.yml +++ b/trash.yml @@ -58,3 +58,5 @@ import: version: c01cf91b011868172fdcd9f41838e80c9d716264 - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 +- package: github.com/hanwen/go-fuse + version: bd746dd8bcc8c059a9d953a786a6156eb83f398e diff --git a/vendor/github.com/hanwen/go-fuse/.gitignore b/vendor/github.com/hanwen/go-fuse/.gitignore new file mode 100644 index 00000000..a18633a4 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/.gitignore @@ -0,0 +1,14 @@ +*~ +*.6 +8.out +.nfs* +_* +6.out +#* +example/hello/hello +example/unionfs/unionfs +example/autounionfs/autounionfs +example/loopback/loopback +example/multizip/multizip +example/bulkstat/bulkstat +example/zipfs/zipfs diff --git a/vendor/github.com/hanwen/go-fuse/CONTRIBUTING b/vendor/github.com/hanwen/go-fuse/CONTRIBUTING new file mode 100644 index 00000000..16a740c7 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/CONTRIBUTING @@ -0,0 +1,22 @@ + +Before sending a patch or Pull request, please fill out a Google CLA, using the following form: + + https://cla.developers.google.com/clas + +For complex changes, please use Gerrit: + +* Connect your github account with gerrithub, at + + https://review.gerrithub.io/static/intro.html + +* The signup will setup your SSH keys from Github. + +* Create your change as a commit + +* Add an ID to the commit message: + + echo "Change-Id: I"$(head -c 20 /dev/urandom | sha1sum | awk '{print $1}') + +* Push the change for review, + + git push ssh://$USER@review.gerrithub.io:29418/hanwen/go-fuse HEAD:refs/for/master diff --git a/vendor/github.com/hanwen/go-fuse/LICENSE b/vendor/github.com/hanwen/go-fuse/LICENSE new file mode 100644 index 00000000..d3fb2062 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/LICENSE @@ -0,0 +1,30 @@ +// New BSD License +// +// Copyright (c) 2010 Ivan Krasin (imkrasin@gmail.com). 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 Ivan Krasin 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/hanwen/go-fuse/README b/vendor/github.com/hanwen/go-fuse/README new file mode 100644 index 00000000..2576329b --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/README @@ -0,0 +1,150 @@ + +GO-FUSE: native bindings for the FUSE kernel module. + + +HIGHLIGHTS + +* High speed: as fast as libfuse using the gc compiler for single +threaded loads. + +* Supports in-process mounting of different FileSystems onto +subdirectories of the FUSE mount. + +* Supports 3 interfaces for writing filesystems: + - PathFileSystem: define filesystems in terms path names. + - NodeFileSystem: define filesystems in terms of inodes. + - RawFileSystem: define filesystems in terms of FUSE's raw + wire protocol. + +* Both NodeFileSystem and PathFileSystem support manipulation of true + hardlinks. + +* Includes two fleshed out examples, zipfs and unionfs. + + +EXAMPLES + +* examples/hello/hello.go contains a 60-line "hello world" filesystem + +* zipfs/zipfs.go contains a small and simple read-only filesystem for + zip and tar files. The corresponding command is in example/zipfs/ + For example, + + mkdir /tmp/mountpoint + example/zipfs/zipfs /tmp/mountpoint file.zip & + ls /tmp/mountpoint + fusermount -u /tmp/mountpoint + +* zipfs/multizipfs.go shows how to use in-process mounts to + combine multiple Go-FUSE filesystems into a larger filesystem. + +* fuse/loopback.go mounts another piece of the filesystem. + Functionally, it is similar to a symlink. A binary to run is in + example/loopback/ . For example + + mkdir /tmp/mountpoint + example/loopback/loopback -debug /tmp/mountpoint /some/other/directory & + ls /tmp/mountpoint + fusermount -u /tmp/mountpoint + +* unionfs/unionfs.go: implements a union mount using 1 R/W branch, and + multiple R/O branches. + + mkdir -p /tmp/mountpoint /tmp/writable + example/unionfs/unionfs /tmp/mountpoint /tmp/writable /usr & + ls /tmp/mountpoint + ls -l /tmp/mountpoint/bin/vi + rm /tmp/mountpoint/bin/vi + ls -l /tmp/mountpoint/bin/vi + cat /tmp/writable/*DELETION*/* + +* union/autounionfs.go: creates UnionFs mounts automatically based on + existence of READONLY symlinks. + + +Tested on: + +- x86 32bits (Fedora 14). +- x86 64bits (Ubuntu Lucid). + + +BENCHMARKS + +We use threaded stats over a read-only filesystem for benchmarking. +Automated code is under benchmark/ directory. A simple C version of +the same FS gives a FUSE baseline + +Data points (Go-FUSE version May 2012), 1000 files, high level +interface, all kernel caching turned off, median stat time: + +platform libfuse Go-FUSE difference (%) + +Lenovo T60/Fedora16 (1cpu) 349us 355us 2% slower +Lenovo T400/Lucid (1cpu) 138us 140us 5% slower +Dell T3500/Lucid (1cpu) 72us 76us 5% slower + +On T60, for each file we have +- Client side latency is 360us +- 106us of this is server side latency (4.5x lookup 23us, 1x getattr 4us) +- 16.5us is due to latency measurements. +- 3us is due to garbage collection. + + + +MACOS SUPPORT + +go-fuse works somewhat on OSX. Known limitations: + +* All of the limitations of OSXFUSE, including lack of support for + NOTIFY. + +* OSX issues STATFS calls continuously (leading to performance + concerns). + +* OSX has trouble with concurrent reads from the FUSE device, leading + to performance concerns. + +* A bunch of tests under fuse/test/ fail, and the functionality they + test for OSX is likely broken. + + +CREDITS + +* Inspired by Taru Karttunen's package, https://bitbucket.org/taruti/go-extra. + +* Originally based on Ivan Krasin's https://github.com/krasin/go-fuse-zip + + +BUGS + +Yes, probably. Report them through +https://github.com/hanwen/go-fuse/issues + + +DISCLAIMER + +This is not an official Google product. + + +KNOWN PROBLEMS + +Grep source code for TODO. Major topics: + +* Support for umask in Create + +* Missing support for network FS file locking: FUSE_GETLK, FUSE_SETLK, + FUSE_SETLKW + +* Missing support for FUSE_INTERRUPT, CUSE, BMAP, POLL, IOCTL + +* In the path API, renames are racy; See also: + + http://sourceforge.net/mailarchive/message.php?msg_id=27550667 + + Don't use the path API if you care about correctness. + + +LICENSE + +Like Go, this library is distributed under the new BSD license. See +accompanying LICENSE file. diff --git a/vendor/github.com/hanwen/go-fuse/all.bash b/vendor/github.com/hanwen/go-fuse/all.bash new file mode 100755 index 00000000..e7331f62 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/all.bash @@ -0,0 +1,33 @@ +#!/bin/sh +set -eu + +for target in "clean" "install" ; do + for d in fuse fuse/nodefs fuse/pathfs fuse/test zipfs unionfs \ + example/hello example/loopback example/zipfs \ + example/multizip example/unionfs example/memfs \ + example/autounionfs ; \ + do + if test "${target}" = "install" && test "${d}" = "fuse/test"; then + continue + fi + echo "go ${target} github.com/hanwen/go-fuse/${d}" + go ${target} github.com/hanwen/go-fuse/${d} + done +done + +for d in fuse zipfs unionfs fuse/test +do + ( + cd $d + echo "go test github.com/hanwen/go-fuse/$d" + go test github.com/hanwen/go-fuse/$d + echo "go test -race github.com/hanwen/go-fuse/$d" + go test -race github.com/hanwen/go-fuse/$d + ) +done + +make -C benchmark +for d in benchmark +do + go test github.com/hanwen/go-fuse/benchmark -test.bench '.*' -test.cpu 1,2 +done diff --git a/vendor/github.com/hanwen/go-fuse/fuse/.gitignore b/vendor/github.com/hanwen/go-fuse/fuse/.gitignore new file mode 100644 index 00000000..13df9161 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/.gitignore @@ -0,0 +1 @@ +version.gen.go diff --git a/vendor/github.com/hanwen/go-fuse/fuse/api.go b/vendor/github.com/hanwen/go-fuse/fuse/api.go new file mode 100644 index 00000000..ea850931 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/api.go @@ -0,0 +1,131 @@ +// The fuse package provides APIs to implement filesystems in +// userspace. Typically, each call of the API happens in its own +// goroutine, so take care to make the file system thread-safe. + +package fuse + +// Types for users to implement. + +// The result of Read is an array of bytes, but for performance +// reasons, we can also return data as a file-descriptor/offset/size +// tuple. If the backing store for a file is another filesystem, this +// reduces the amount of copying between the kernel and the FUSE +// server. The ReadResult interface captures both cases. +type ReadResult interface { + // Returns the raw bytes for the read, possibly using the + // passed buffer. The buffer should be larger than the return + // value from Size. + Bytes(buf []byte) ([]byte, Status) + + // Size returns how many bytes this return value takes at most. + Size() int + + // Done() is called after sending the data to the kernel. + Done() +} + +type MountOptions struct { + AllowOther bool + + // Options are passed as -o string to fusermount. + Options []string + + // Default is _DEFAULT_BACKGROUND_TASKS, 12. This numbers + // controls the allowed number of requests that relate to + // async I/O. Concurrency for synchronous I/O is not limited. + MaxBackground int + + // Write size to use. If 0, use default. This number is + // capped at the kernel maximum. + MaxWrite int + + // If IgnoreSecurityLabels is set, all security related xattr + // requests will return NO_DATA without passing through the + // user defined filesystem. You should only set this if you + // file system implements extended attributes, and you are not + // interested in security labels. + IgnoreSecurityLabels bool // ignoring labels should be provided as a fusermount mount option. + + // If given, use this buffer pool instead of the global one. + Buffers BufferPool + + // If RememberInodes is set, we will never forget inodes. + // This may be useful for NFS. + RememberInodes bool + + // Values shown in "df -T" and friends + // First column, "Filesystem" + FsName string + // Second column, "Type", will be shown as "fuse." + Name + Name string + + // If set, wrap the file system in a single-threaded locking wrapper. + SingleThreaded bool +} + +// RawFileSystem is an interface close to the FUSE wire protocol. +// +// Unless you really know what you are doing, you should not implement +// this, but rather the FileSystem interface; the details of getting +// interactions with open files, renames, and threading right etc. are +// somewhat tricky and not very interesting. +// +// A null implementation is provided by NewDefaultRawFileSystem. +type RawFileSystem interface { + String() string + + // If called, provide debug output through the log package. + SetDebug(debug bool) + + Lookup(header *InHeader, name string, out *EntryOut) (status Status) + Forget(nodeid, nlookup uint64) + + // Attributes. + GetAttr(input *GetAttrIn, out *AttrOut) (code Status) + SetAttr(input *SetAttrIn, out *AttrOut) (code Status) + + // Modifying structure. + Mknod(input *MknodIn, name string, out *EntryOut) (code Status) + Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) + Unlink(header *InHeader, name string) (code Status) + Rmdir(header *InHeader, name string) (code Status) + Rename(input *RenameIn, oldName string, newName string) (code Status) + Link(input *LinkIn, filename string, out *EntryOut) (code Status) + + Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) + Readlink(header *InHeader) (out []byte, code Status) + Access(input *AccessIn) (code Status) + + // Extended attributes. + GetXAttrSize(header *InHeader, attr string) (sz int, code Status) + GetXAttrData(header *InHeader, attr string) (data []byte, code Status) + ListXAttr(header *InHeader) (attributes []byte, code Status) + SetXAttr(input *SetXAttrIn, attr string, data []byte) Status + RemoveXAttr(header *InHeader, attr string) (code Status) + + // File handling. + Create(input *CreateIn, name string, out *CreateOut) (code Status) + Open(input *OpenIn, out *OpenOut) (status Status) + Read(input *ReadIn, buf []byte) (ReadResult, Status) + + Release(input *ReleaseIn) + Write(input *WriteIn, data []byte) (written uint32, code Status) + Flush(input *FlushIn) Status + Fsync(input *FsyncIn) (code Status) + Fallocate(input *FallocateIn) (code Status) + + // Directory handling + OpenDir(input *OpenIn, out *OpenOut) (status Status) + ReadDir(input *ReadIn, out *DirEntryList) Status + ReadDirPlus(input *ReadIn, out *DirEntryList) Status + ReleaseDir(input *ReleaseIn) + FsyncDir(input *FsyncIn) (code Status) + + // + StatFs(input *InHeader, out *StatfsOut) (code Status) + + // This is called on processing the first request. The + // filesystem implementation can use the server argument to + // talk back to the kernel (through notify methods). + Init(*Server) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/attr.go b/vendor/github.com/hanwen/go-fuse/fuse/attr.go new file mode 100644 index 00000000..7211accb --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/attr.go @@ -0,0 +1,75 @@ +package fuse + +import ( + "os" + "syscall" + "time" +) + +func (a *Attr) IsFifo() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFIFO } + +// IsChar reports whether the FileInfo describes a character special file. +func (a *Attr) IsChar() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFCHR } + +// IsDir reports whether the FileInfo describes a directory. +func (a *Attr) IsDir() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFDIR } + +// IsBlock reports whether the FileInfo describes a block special file. +func (a *Attr) IsBlock() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFBLK } + +// IsRegular reports whether the FileInfo describes a regular file. +func (a *Attr) IsRegular() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFREG } + +// IsSymlink reports whether the FileInfo describes a symbolic link. +func (a *Attr) IsSymlink() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFLNK } + +// IsSocket reports whether the FileInfo describes a socket. +func (a *Attr) IsSocket() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFSOCK } + +func (a *Attr) SetTimes(access *time.Time, mod *time.Time, chstatus *time.Time) { + if access != nil { + a.Atime = uint64(access.Unix()) + a.Atimensec = uint32(access.Nanosecond()) + } + if mod != nil { + a.Mtime = uint64(mod.Unix()) + a.Mtimensec = uint32(mod.Nanosecond()) + } + if chstatus != nil { + a.Ctime = uint64(chstatus.Unix()) + a.Ctimensec = uint32(chstatus.Nanosecond()) + } +} + +func (a *Attr) ChangeTime() time.Time { + return time.Unix(int64(a.Ctime), int64(a.Ctimensec)) +} + +func (a *Attr) AccessTime() time.Time { + return time.Unix(int64(a.Atime), int64(a.Atimensec)) +} + +func (a *Attr) ModTime() time.Time { + return time.Unix(int64(a.Mtime), int64(a.Mtimensec)) +} + +func ToStatT(f os.FileInfo) *syscall.Stat_t { + s, _ := f.Sys().(*syscall.Stat_t) + if s != nil { + return s + } + return nil +} + +func ToAttr(f os.FileInfo) *Attr { + if f == nil { + return nil + } + s := ToStatT(f) + if s != nil { + a := &Attr{} + a.FromStat(s) + return a + } + return nil +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go new file mode 100644 index 00000000..af3ef871 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go @@ -0,0 +1,22 @@ +package fuse + +import ( + "syscall" +) + +func (a *Attr) FromStat(s *syscall.Stat_t) { + a.Ino = uint64(s.Ino) + a.Size = uint64(s.Size) + a.Blocks = uint64(s.Blocks) + a.Atime = uint64(s.Atimespec.Sec) + a.Atimensec = uint32(s.Atimespec.Nsec) + a.Mtime = uint64(s.Mtimespec.Sec) + a.Mtimensec = uint32(s.Mtimespec.Nsec) + a.Ctime = uint64(s.Ctimespec.Sec) + a.Ctimensec = uint32(s.Ctimespec.Nsec) + a.Mode = uint32(s.Mode) + a.Nlink = uint32(s.Nlink) + a.Uid = uint32(s.Uid) + a.Gid = uint32(s.Gid) + a.Rdev = uint32(s.Rdev) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go new file mode 100644 index 00000000..37823699 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go @@ -0,0 +1,23 @@ +package fuse + +import ( + "syscall" +) + +func (a *Attr) FromStat(s *syscall.Stat_t) { + a.Ino = uint64(s.Ino) + a.Size = uint64(s.Size) + a.Blocks = uint64(s.Blocks) + a.Atime = uint64(s.Atim.Sec) + a.Atimensec = uint32(s.Atim.Nsec) + a.Mtime = uint64(s.Mtim.Sec) + a.Mtimensec = uint32(s.Mtim.Nsec) + a.Ctime = uint64(s.Ctim.Sec) + a.Ctimensec = uint32(s.Ctim.Nsec) + a.Mode = s.Mode + a.Nlink = uint32(s.Nlink) + a.Uid = uint32(s.Uid) + a.Gid = uint32(s.Gid) + a.Rdev = uint32(s.Rdev) + a.Blksize = uint32(s.Blksize) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go b/vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go new file mode 100644 index 00000000..7ed06c16 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go @@ -0,0 +1,95 @@ +package fuse + +import ( + "sync" +) + +var paranoia bool + +// BufferPool implements explicit memory management. It is used for +// minimizing the GC overhead of communicating with the kernel. +type BufferPool interface { + // AllocBuffer creates a buffer of at least the given size. After use, + // it should be deallocated with FreeBuffer(). + AllocBuffer(size uint32) []byte + + // FreeBuffer takes back a buffer if it was allocated through + // AllocBuffer. It is not an error to call FreeBuffer() on a slice + // obtained elsewhere. + FreeBuffer(slice []byte) +} + +type gcBufferPool struct { +} + +// NewGcBufferPool is a fallback to the standard allocation routines. +func NewGcBufferPool() BufferPool { + return &gcBufferPool{} +} + +func (p *gcBufferPool) AllocBuffer(size uint32) []byte { + return make([]byte, size) +} + +func (p *gcBufferPool) FreeBuffer(slice []byte) { +} + +type bufferPoolImpl struct { + lock sync.Mutex + + // For each page size multiple a list of slice pointers. + buffersBySize []*sync.Pool +} + +// NewBufferPool returns a BufferPool implementation that that returns +// slices with capacity of a multiple of PAGESIZE, which have possibly +// been used, and may contain random contents. When using +// NewBufferPool, file system handlers may not hang on to passed-in +// buffers beyond the handler's return. +func NewBufferPool() BufferPool { + bp := new(bufferPoolImpl) + return bp +} + +func (p *bufferPoolImpl) getPool(pageCount int) *sync.Pool { + p.lock.Lock() + for len(p.buffersBySize) < pageCount+1 { + p.buffersBySize = append(p.buffersBySize, nil) + } + if p.buffersBySize[pageCount] == nil { + p.buffersBySize[pageCount] = &sync.Pool{ + New: func() interface{} { return make([]byte, PAGESIZE*pageCount) }, + } + } + pool := p.buffersBySize[pageCount] + p.lock.Unlock() + return pool +} + +func (p *bufferPoolImpl) AllocBuffer(size uint32) []byte { + sz := int(size) + if sz < PAGESIZE { + sz = PAGESIZE + } + + if sz%PAGESIZE != 0 { + sz += PAGESIZE + } + pages := sz / PAGESIZE + + b := p.getPool(pages).Get().([]byte) + return b[:size] +} + +func (p *bufferPoolImpl) FreeBuffer(slice []byte) { + if slice == nil { + return + } + if cap(slice)%PAGESIZE != 0 || cap(slice) == 0 { + return + } + pages := cap(slice) / PAGESIZE + slice = slice[:cap(slice)] + + p.getPool(pages).Put(slice) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/constants.go b/vendor/github.com/hanwen/go-fuse/fuse/constants.go new file mode 100644 index 00000000..5aeaf1f3 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/constants.go @@ -0,0 +1,31 @@ +package fuse + +import ( + "os" + "syscall" +) + +const ( + FUSE_ROOT_ID = 1 + + FUSE_UNKNOWN_INO = 0xffffffff + + CUSE_UNRESTRICTED_IOCTL = (1 << 0) + + FUSE_LK_FLOCK = (1 << 0) + + FUSE_IOCTL_MAX_IOV = 256 + + FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0) + + CUSE_INIT_INFO_MAX = 4096 + + S_IFDIR = syscall.S_IFDIR + S_IFREG = syscall.S_IFREG + S_IFLNK = syscall.S_IFLNK + S_IFIFO = syscall.S_IFIFO + + CUSE_INIT = 4096 + + O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC) +) diff --git a/vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go b/vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go new file mode 100644 index 00000000..ae8233a8 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go @@ -0,0 +1,5 @@ +package fuse + +// arbitrary values +const syscall_O_LARGEFILE = 1 << 29 +const syscall_O_NOATIME = 1 << 30 diff --git a/vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go new file mode 100644 index 00000000..6c516762 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go @@ -0,0 +1,8 @@ +package fuse + +import ( + "syscall" +) + +const syscall_O_LARGEFILE = syscall.O_LARGEFILE +const syscall_O_NOATIME = syscall.O_NOATIME diff --git a/vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go b/vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go new file mode 100644 index 00000000..8fc71cf6 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go @@ -0,0 +1,148 @@ +package fuse + +import ( + "os" +) + +// NewDefaultRawFileSystem returns ENOSYS (not implemented) for all +// operations. +func NewDefaultRawFileSystem() RawFileSystem { + return (*defaultRawFileSystem)(nil) +} + +type defaultRawFileSystem struct{} + +func (fs *defaultRawFileSystem) Init(*Server) { +} + +func (fs *defaultRawFileSystem) String() string { + return os.Args[0] +} + +func (fs *defaultRawFileSystem) SetDebug(dbg bool) { +} + +func (fs *defaultRawFileSystem) StatFs(header *InHeader, out *StatfsOut) Status { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Lookup(header *InHeader, name string, out *EntryOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Forget(nodeID, nlookup uint64) { +} + +func (fs *defaultRawFileSystem) GetAttr(input *GetAttrIn, out *AttrOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Open(input *OpenIn, out *OpenOut) (status Status) { + return OK +} + +func (fs *defaultRawFileSystem) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { + return nil, ENOSYS +} + +func (fs *defaultRawFileSystem) Mknod(input *MknodIn, name string, out *EntryOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Unlink(header *InHeader, name string) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Rename(input *RenameIn, oldName string, newName string) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Link(input *LinkIn, name string, out *EntryOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) GetXAttrSize(header *InHeader, attr string) (size int, code Status) { + return 0, ENOSYS +} + +func (fs *defaultRawFileSystem) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { + return nil, ENOSYS +} + +func (fs *defaultRawFileSystem) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status { + return ENOSYS +} + +func (fs *defaultRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { + return nil, ENOSYS +} + +func (fs *defaultRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Access(input *AccessIn) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Create(input *CreateIn, name string, out *CreateOut) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) OpenDir(input *OpenIn, out *OpenOut) (status Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Read(input *ReadIn, buf []byte) (ReadResult, Status) { + return nil, ENOSYS +} + +func (fs *defaultRawFileSystem) Release(input *ReleaseIn) { +} + +func (fs *defaultRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { + return 0, ENOSYS +} + +func (fs *defaultRawFileSystem) Flush(input *FlushIn) Status { + return OK +} + +func (fs *defaultRawFileSystem) Fsync(input *FsyncIn) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) ReadDir(input *ReadIn, l *DirEntryList) Status { + return ENOSYS +} + +func (fs *defaultRawFileSystem) ReadDirPlus(input *ReadIn, l *DirEntryList) Status { + return ENOSYS +} + +func (fs *defaultRawFileSystem) ReleaseDir(input *ReleaseIn) { +} + +func (fs *defaultRawFileSystem) FsyncDir(input *FsyncIn) (code Status) { + return ENOSYS +} + +func (fs *defaultRawFileSystem) Fallocate(in *FallocateIn) (code Status) { + return ENOSYS +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/direntry.go b/vendor/github.com/hanwen/go-fuse/fuse/direntry.go new file mode 100644 index 00000000..34fbacf5 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/direntry.go @@ -0,0 +1,98 @@ +package fuse + +// all of the code for DirEntryList. + +import ( + "fmt" + "unsafe" +) + +var eightPadding [8]byte + +const direntSize = int(unsafe.Sizeof(_Dirent{})) + +// DirEntry is a type for PathFileSystem and NodeFileSystem to return +// directory contents in. +type DirEntry struct { + // Mode is the file's mode. Only the high bits (eg. S_IFDIR) + // are considered. + Mode uint32 + + // Name is the basename of the file in the directory. + Name string +} + +func (d DirEntry) String() string { + return fmt.Sprintf("%o: %q", d.Mode, d.Name) +} + +// DirEntryList holds the return value for READDIR and READDIRPLUS +// opcodes. +type DirEntryList struct { + buf []byte + size int + offset uint64 +} + +// NewDirEntryList creates a DirEntryList with the given data buffer +// and offset. +func NewDirEntryList(data []byte, off uint64) *DirEntryList { + return &DirEntryList{ + buf: data[:0], + size: len(data), + offset: off, + } +} + +// AddDirEntry tries to add an entry, and reports whether it +// succeeded. +func (l *DirEntryList) AddDirEntry(e DirEntry) (bool, uint64) { + return l.Add(0, e.Name, uint64(FUSE_UNKNOWN_INO), e.Mode) +} + +// Add adds a direntry to the DirEntryList, returning whether it +// succeeded. +func (l *DirEntryList) Add(prefix int, name string, inode uint64, mode uint32) (bool, uint64) { + padding := (8 - len(name)&7) & 7 + delta := padding + direntSize + len(name) + prefix + oldLen := len(l.buf) + newLen := delta + oldLen + + if newLen > l.size { + return false, l.offset + } + l.buf = l.buf[:newLen] + oldLen += prefix + dirent := (*_Dirent)(unsafe.Pointer(&l.buf[oldLen])) + dirent.Off = l.offset + 1 + dirent.Ino = inode + dirent.NameLen = uint32(len(name)) + dirent.Typ = (mode & 0170000) >> 12 + oldLen += direntSize + copy(l.buf[oldLen:], name) + oldLen += len(name) + + if padding > 0 { + copy(l.buf[oldLen:], eightPadding[:padding]) + } + + l.offset = dirent.Off + return true, l.offset +} + +// AddDirLookupEntry is used for ReadDirPlus. It serializes a DirEntry +// and returns the space for entry. If no space is left, returns a nil +// pointer. +func (l *DirEntryList) AddDirLookupEntry(e DirEntry) (*EntryOut, uint64) { + lastStart := len(l.buf) + ok, off := l.Add(int(unsafe.Sizeof(EntryOut{})), e.Name, + uint64(FUSE_UNKNOWN_INO), e.Mode) + if !ok { + return nil, off + } + return (*EntryOut)(unsafe.Pointer(&l.buf[lastStart])), off +} + +func (l *DirEntryList) bytes() []byte { + return l.buf +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go b/vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go new file mode 100644 index 00000000..2c3bd8d3 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go @@ -0,0 +1,206 @@ +package fuse + +import ( + "fmt" + "sync" +) + +//////////////////////////////////////////////////////////////// +// Locking raw FS. + +type lockingRawFileSystem struct { + RawFS RawFileSystem + lock sync.Mutex +} + +// Returns a Wrap +func NewLockingRawFileSystem(fs RawFileSystem) RawFileSystem { + return &lockingRawFileSystem{ + RawFS: fs, + } +} + +func (fs *lockingRawFileSystem) FS() RawFileSystem { + return fs.RawFS +} + +func (fs *lockingRawFileSystem) locked() func() { + fs.lock.Lock() + return func() { fs.lock.Unlock() } +} + +func (fs *lockingRawFileSystem) Lookup(header *InHeader, name string, out *EntryOut) (code Status) { + defer fs.locked()() + return fs.RawFS.Lookup(header, name, out) +} + +func (fs *lockingRawFileSystem) SetDebug(dbg bool) { + defer fs.locked()() + fs.RawFS.SetDebug(dbg) +} + +func (fs *lockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) { + defer fs.locked()() + fs.RawFS.Forget(nodeID, nlookup) +} + +func (fs *lockingRawFileSystem) GetAttr(input *GetAttrIn, out *AttrOut) (code Status) { + defer fs.locked()() + return fs.RawFS.GetAttr(input, out) +} + +func (fs *lockingRawFileSystem) Open(input *OpenIn, out *OpenOut) (status Status) { + + defer fs.locked()() + return fs.RawFS.Open(input, out) +} + +func (fs *lockingRawFileSystem) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) { + defer fs.locked()() + return fs.RawFS.SetAttr(input, out) +} + +func (fs *lockingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { + defer fs.locked()() + return fs.RawFS.Readlink(header) +} + +func (fs *lockingRawFileSystem) Mknod(input *MknodIn, name string, out *EntryOut) (code Status) { + defer fs.locked()() + return fs.RawFS.Mknod(input, name, out) +} + +func (fs *lockingRawFileSystem) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) { + defer fs.locked()() + return fs.RawFS.Mkdir(input, name, out) +} + +func (fs *lockingRawFileSystem) Unlink(header *InHeader, name string) (code Status) { + defer fs.locked()() + return fs.RawFS.Unlink(header, name) +} + +func (fs *lockingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { + defer fs.locked()() + return fs.RawFS.Rmdir(header, name) +} + +func (fs *lockingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) { + defer fs.locked()() + return fs.RawFS.Symlink(header, pointedTo, linkName, out) +} + +func (fs *lockingRawFileSystem) Rename(input *RenameIn, oldName string, newName string) (code Status) { + defer fs.locked()() + return fs.RawFS.Rename(input, oldName, newName) +} + +func (fs *lockingRawFileSystem) Link(input *LinkIn, name string, out *EntryOut) (code Status) { + defer fs.locked()() + return fs.RawFS.Link(input, name, out) +} + +func (fs *lockingRawFileSystem) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status { + defer fs.locked()() + return fs.RawFS.SetXAttr(input, attr, data) +} + +func (fs *lockingRawFileSystem) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { + defer fs.locked()() + return fs.RawFS.GetXAttrData(header, attr) +} + +func (fs *lockingRawFileSystem) GetXAttrSize(header *InHeader, attr string) (sz int, code Status) { + defer fs.locked()() + return fs.RawFS.GetXAttrSize(header, attr) +} + +func (fs *lockingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { + defer fs.locked()() + return fs.RawFS.ListXAttr(header) +} + +func (fs *lockingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { + defer fs.locked()() + return fs.RawFS.RemoveXAttr(header, attr) +} + +func (fs *lockingRawFileSystem) Access(input *AccessIn) (code Status) { + defer fs.locked()() + return fs.RawFS.Access(input) +} + +func (fs *lockingRawFileSystem) Create(input *CreateIn, name string, out *CreateOut) (code Status) { + defer fs.locked()() + return fs.RawFS.Create(input, name, out) +} + +func (fs *lockingRawFileSystem) OpenDir(input *OpenIn, out *OpenOut) (status Status) { + defer fs.locked()() + return fs.RawFS.OpenDir(input, out) +} + +func (fs *lockingRawFileSystem) Release(input *ReleaseIn) { + defer fs.locked()() + fs.RawFS.Release(input) +} + +func (fs *lockingRawFileSystem) ReleaseDir(input *ReleaseIn) { + defer fs.locked()() + fs.RawFS.ReleaseDir(input) +} + +func (fs *lockingRawFileSystem) Read(input *ReadIn, buf []byte) (ReadResult, Status) { + defer fs.locked()() + return fs.RawFS.Read(input, buf) +} + +func (fs *lockingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { + defer fs.locked()() + return fs.RawFS.Write(input, data) +} + +func (fs *lockingRawFileSystem) Flush(input *FlushIn) Status { + defer fs.locked()() + return fs.RawFS.Flush(input) +} + +func (fs *lockingRawFileSystem) Fsync(input *FsyncIn) (code Status) { + defer fs.locked()() + return fs.RawFS.Fsync(input) +} + +func (fs *lockingRawFileSystem) ReadDir(input *ReadIn, out *DirEntryList) Status { + defer fs.locked()() + return fs.RawFS.ReadDir(input, out) +} + +func (fs *lockingRawFileSystem) ReadDirPlus(input *ReadIn, out *DirEntryList) Status { + defer fs.locked()() + return fs.RawFS.ReadDirPlus(input, out) +} + +func (fs *lockingRawFileSystem) FsyncDir(input *FsyncIn) (code Status) { + defer fs.locked()() + return fs.RawFS.FsyncDir(input) +} + +func (fs *lockingRawFileSystem) Init(s *Server) { + defer fs.locked()() + fs.RawFS.Init(s) +} + +func (fs *lockingRawFileSystem) StatFs(header *InHeader, out *StatfsOut) (code Status) { + defer fs.locked()() + return fs.RawFS.StatFs(header, out) +} + +func (fs *lockingRawFileSystem) Fallocate(in *FallocateIn) (code Status) { + defer fs.locked()() + return fs.RawFS.Fallocate(in) +} + +func (fs *lockingRawFileSystem) String() string { + defer fs.locked()() + return fmt.Sprintf("Locked(%s)", fs.RawFS.String()) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/misc.go b/vendor/github.com/hanwen/go-fuse/fuse/misc.go new file mode 100644 index 00000000..4e2879b8 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/misc.go @@ -0,0 +1,84 @@ +// Random odds and ends. + +package fuse + +import ( + "fmt" + "log" + "os" + "reflect" + "syscall" + "unsafe" +) + +func (code Status) String() string { + if code <= 0 { + return []string{ + "OK", + "NOTIFY_POLL", + "NOTIFY_INVAL_INODE", + "NOTIFY_INVAL_ENTRY", + "NOTIFY_INVAL_STORE", + "NOTIFY_INVAL_RETRIEVE", + "NOTIFY_INVAL_DELETE", + }[-code] + } + return fmt.Sprintf("%d=%v", int(code), syscall.Errno(code)) +} + +func (code Status) Ok() bool { + return code == OK +} + +// ToStatus extracts an errno number from Go error objects. If it +// fails, it logs an error and returns ENOSYS. +func ToStatus(err error) Status { + switch err { + case nil: + return OK + case os.ErrPermission: + return EPERM + case os.ErrExist: + return Status(syscall.EEXIST) + case os.ErrNotExist: + return ENOENT + case os.ErrInvalid: + return EINVAL + } + + switch t := err.(type) { + case syscall.Errno: + return Status(t) + case *os.SyscallError: + return Status(t.Err.(syscall.Errno)) + case *os.PathError: + return ToStatus(t.Err) + case *os.LinkError: + return ToStatus(t.Err) + } + log.Println("can't convert error type:", err) + return ENOSYS +} + +func toSlice(dest *[]byte, ptr unsafe.Pointer, byteCount uintptr) { + h := (*reflect.SliceHeader)(unsafe.Pointer(dest)) + *h = reflect.SliceHeader{ + Data: uintptr(ptr), + Len: int(byteCount), + Cap: int(byteCount), + } +} + +func CurrentOwner() *Owner { + return &Owner{ + Uid: uint32(os.Getuid()), + Gid: uint32(os.Getgid()), + } +} + +func init() { + p := syscall.Getpagesize() + if p != PAGESIZE { + log.Panicf("page size incorrect: %d", p) + } +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go new file mode 100644 index 00000000..ceee372a --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go @@ -0,0 +1,145 @@ +// 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. + +// TODO: Rewrite using package syscall not cgo + +package fuse + +/* + +// 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. + +#include +#include +#include +#include +#include +#include +#include +#include + +#define nil ((void*)0) + +static int +mountfuse(char *mtpt, char **err) +{ + int i, pid, fd, r; + char buf[200]; + struct vfsconf vfs; + char *f; + + if(getvfsbyname("osxfusefs", &vfs) < 0){ + if(access(f="/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", 0) < 0){ + *err = strdup("cannot find load_fusefs"); + return -1; + } + if((r=system(f)) < 0){ + snprintf(buf, sizeof buf, "%s: %s", f, strerror(errno)); + *err = strdup(buf); + return -1; + } + if(r != 0){ + snprintf(buf, sizeof buf, "load_fusefs failed: exit %d", r); + *err = strdup(buf); + return -1; + } + if(getvfsbyname("osxfusefs", &vfs) < 0){ + snprintf(buf, sizeof buf, "getvfsbyname osxfusefs: %s", strerror(errno)); + *err = strdup(buf); + return -1; + } + } + + // Look for available FUSE device. + for(i=0;; i++){ + snprintf(buf, sizeof buf, "/dev/osxfuse%d", i); + if(access(buf, 0) < 0){ + *err = strdup("no available fuse devices"); + return -1; + } + if((fd = open(buf, O_RDWR)) >= 0) + break; + } + + pid = fork(); + if(pid < 0) + return -1; + if(pid == 0){ + snprintf(buf, sizeof buf, "%d", fd); + setenv("MOUNT_FUSEFS_CALL_BY_LIB", "", 1); + // Different versions of MacFUSE put the + // mount_fusefs binary in different places. + // Try all. + // Leopard location + setenv("MOUNT_FUSEFS_DAEMON_PATH", "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", 1); + execl("/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", "mount_osxfusefs", "-o", "iosize=4096", buf, mtpt, nil); + fprintf(stderr, "exec mount_osxfusefs: %s\n", strerror(errno)); + _exit(1); + } + return fd; +} + +*/ +import "C" +import ( + "fmt" + "log" + "os/exec" + "syscall" + "unsafe" +) + +func mount(dir string, options string) (int, error) { + errp := (**C.char)(C.malloc(16)) + *errp = nil + defer C.free(unsafe.Pointer(errp)) + cdir := C.CString(dir) + defer C.free(unsafe.Pointer(cdir)) + fd := C.mountfuse(cdir, errp) + if *errp != nil { + return -1, mountError(C.GoString(*errp)) + } + return int(fd), nil +} + +type mountError string + +func (m mountError) Error() string { + return string(m) +} + +func unmount(mountPoint string) error { + if err := syscall.Unmount(mountPoint, 0); err != nil { + return fmt.Errorf("umount(%q): %v", mountPoint, err) + } + return nil +} + +var umountBinary string + +func init() { + var err error + umountBinary, err = exec.LookPath("umount") + if err != nil { + log.Fatalf("Could not find umount binary: %v", err) + } +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go new file mode 100644 index 00000000..a33bb38a --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go @@ -0,0 +1,152 @@ +package fuse + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "path" + "path/filepath" + "syscall" + "unsafe" +) + +func unixgramSocketpair() (l, r *os.File, err error) { + fd, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_SEQPACKET, 0) + if err != nil { + return nil, nil, os.NewSyscallError("socketpair", + err.(syscall.Errno)) + } + l = os.NewFile(uintptr(fd[0]), "socketpair-half1") + r = os.NewFile(uintptr(fd[1]), "socketpair-half2") + return +} + +// Create a FUSE FS on the specified mount point. The returned +// mount point is always absolute. +func mount(mountPoint string, options string) (fd int, err error) { + local, remote, err := unixgramSocketpair() + if err != nil { + return + } + + defer local.Close() + defer remote.Close() + + bin, err := fusermountBinary() + if err != nil { + return 0, err + } + + cmd := []string{bin, mountPoint} + if options != "" { + cmd = append(cmd, "-o") + cmd = append(cmd, options) + } + proc, err := os.StartProcess(bin, + cmd, + &os.ProcAttr{ + Env: []string{"_FUSE_COMMFD=3"}, + Files: []*os.File{os.Stdin, os.Stdout, os.Stderr, remote}}) + + if err != nil { + return + } + + w, err := proc.Wait() + if err != nil { + return + } + if !w.Success() { + err = fmt.Errorf("fusermount exited with code %v\n", w.Sys()) + return + } + + return getConnection(local) +} + +func privilegedUnmount(mountPoint string) error { + dir, _ := filepath.Split(mountPoint) + bin, err := umountBinary() + if err != nil { + return err + } + + proc, err := os.StartProcess(bin, + []string{bin, mountPoint}, + &os.ProcAttr{Dir: dir, Files: []*os.File{nil, nil, os.Stderr}}) + if err != nil { + return err + } + w, err := proc.Wait() + if !w.Success() { + return fmt.Errorf("umount exited with code %v\n", w.Sys()) + } + return err +} + +func unmount(mountPoint string) (err error) { + if os.Geteuid() == 0 { + return privilegedUnmount(mountPoint) + } + bin, err := fusermountBinary() + if err != nil { + return err + } + errBuf := bytes.Buffer{} + cmd := exec.Command(bin, "-u", mountPoint) + cmd.Stderr = &errBuf + err = cmd.Run() + if errBuf.Len() > 0 { + return fmt.Errorf("%s (code %v)\n", + errBuf.String(), err) + } + return err +} + +func getConnection(local *os.File) (int, error) { + var data [4]byte + control := make([]byte, 4*256) + + // n, oobn, recvflags, from, errno - todo: error checking. + _, oobn, _, _, + err := syscall.Recvmsg( + int(local.Fd()), data[:], control[:], 0) + if err != nil { + return 0, err + } + + message := *(*syscall.Cmsghdr)(unsafe.Pointer(&control[0])) + fd := *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&control[0])) + syscall.SizeofCmsghdr)) + + if message.Type != 1 { + return 0, fmt.Errorf("getConnection: recvmsg returned wrong control type: %d", message.Type) + } + if oobn <= syscall.SizeofCmsghdr { + return 0, fmt.Errorf("getConnection: too short control message. Length: %d", oobn) + } + if fd < 0 { + return 0, fmt.Errorf("getConnection: fd < 0: %d", fd) + } + return int(fd), nil +} + +// lookPathFallback - search binary in PATH and, if that fails, +// in fallbackDir. This is useful if PATH is possible empty. +func lookPathFallback(file string, fallbackDir string) (string, error) { + binPath, err := exec.LookPath(file) + if err == nil { + return binPath, nil + } + + abs := path.Join(fallbackDir, file) + return exec.LookPath(abs) +} + +func fusermountBinary() (string, error) { + return lookPathFallback("fusermount", "/bin") +} + +func umountBinary() (string, error) { + return lookPathFallback("umount", "/bin") +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go new file mode 100644 index 00000000..05148256 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go @@ -0,0 +1,181 @@ +// The nodefs package offers a high level API that resembles the +// kernel's idea of what an FS looks like. File systems can have +// multiple hard-links to one file, for example. It is also suited if +// the data to represent fits in memory: you can construct the +// complete file system tree at mount time +package nodefs + +import ( + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +// The Node interface implements the user-defined file system +// functionality +type Node interface { + // Inode and SetInode are basic getter/setters. They are + // called by the FileSystemConnector. You get them for free by + // embedding the result of NewDefaultNode() in your node + // struct. + Inode() *Inode + SetInode(node *Inode) + + // OnMount is called on the root node just after a mount is + // executed, either when the actual root is mounted, or when a + // filesystem is mounted in-process. The passed-in + // FileSystemConnector gives access to Notify methods and + // Debug settings. + OnMount(conn *FileSystemConnector) + + // OnUnmount is executed just before a submount is removed, + // and when the process receives a forget for the FUSE root + // node. + OnUnmount() + + // Lookup finds a child node to this node; it is only called + // for directory Nodes. + Lookup(out *fuse.Attr, name string, context *fuse.Context) (*Inode, fuse.Status) + + // Deletable() should return true if this node may be discarded once + // the kernel forgets its reference. + // If it returns false, OnForget will never get called for this node. This + // is appropriate if the filesystem has no persistent backing store + // (in-memory filesystems) where discarding the node loses the stored data. + // Deletable will be called from within the treeLock critical section, so you + // cannot look at other nodes. + Deletable() bool + + // OnForget is called when the kernel forgets its reference to this node and + // sends a FORGET request. It should perform cleanup and free memory as + // appropriate for the filesystem. + // OnForget is not called if the node is a directory and has children. + // This is called from within a treeLock critical section. + OnForget() + + // Misc. + Access(mode uint32, context *fuse.Context) (code fuse.Status) + Readlink(c *fuse.Context) ([]byte, fuse.Status) + + // Namespace operations; these are only called on directory Nodes. + + // Mknod should create the node, add it to the receiver's + // inode, and return it + Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) + + // Mkdir should create the directory Inode, add it to the + // receiver's Inode, and return it + Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) + Unlink(name string, context *fuse.Context) (code fuse.Status) + Rmdir(name string, context *fuse.Context) (code fuse.Status) + + // Symlink should create a child inode to the receiver, and + // return it. + Symlink(name string, content string, context *fuse.Context) (*Inode, fuse.Status) + Rename(oldName string, newParent Node, newName string, context *fuse.Context) (code fuse.Status) + + // Link should return the Inode of the resulting link. In + // a POSIX conformant file system, this should add 'existing' + // to the receiver, and return the Inode corresponding to + // 'existing'. + Link(name string, existing Node, context *fuse.Context) (newNode *Inode, code fuse.Status) + + // Create should return an open file, and the Inode for that file. + Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, child *Inode, code fuse.Status) + + // Open opens a file, and returns a File which is associated + // with a file handle. It is OK to return (nil, OK) here. In + // that case, the Node should implement Read or Write + // directly. + Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) + OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) + Read(file File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) + Write(file File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) + + // XAttrs + GetXAttr(attribute string, context *fuse.Context) (data []byte, code fuse.Status) + RemoveXAttr(attr string, context *fuse.Context) fuse.Status + SetXAttr(attr string, data []byte, flags int, context *fuse.Context) fuse.Status + ListXAttr(context *fuse.Context) (attrs []string, code fuse.Status) + + // Attributes + GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) + Chmod(file File, perms uint32, context *fuse.Context) (code fuse.Status) + Chown(file File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) + Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) + Utimens(file File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) + Fallocate(file File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) + + StatFs() *fuse.StatfsOut +} + +// A File object is returned from FileSystem.Open and +// FileSystem.Create. Include the NewDefaultFile return value into +// the struct to inherit a null implementation. +type File interface { + // Called upon registering the filehandle in the inode. + SetInode(*Inode) + + // The String method is for debug printing. + String() string + + // Wrappers around other File implementations, should return + // the inner file here. + InnerFile() File + + Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) + Write(data []byte, off int64) (written uint32, code fuse.Status) + + // Flush is called for close() call on a file descriptor. In + // case of duplicated descriptor, it may be called more than + // once for a file. + Flush() fuse.Status + + // This is called to before the file handle is forgotten. This + // method has no return value, so nothing can synchronizes on + // the call. Any cleanup that requires specific synchronization or + // could fail with I/O errors should happen in Flush instead. + Release() + Fsync(flags int) (code fuse.Status) + + // The methods below may be called on closed files, due to + // concurrency. In that case, you should return EBADF. + Truncate(size uint64) fuse.Status + GetAttr(out *fuse.Attr) fuse.Status + Chown(uid uint32, gid uint32) fuse.Status + Chmod(perms uint32) fuse.Status + Utimens(atime *time.Time, mtime *time.Time) fuse.Status + Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) +} + +// Wrap a File return in this to set FUSE flags. Also used internally +// to store open file data. +type WithFlags struct { + File + + // For debugging. + Description string + + // Put FOPEN_* flags here. + FuseFlags uint32 + + // O_RDWR, O_TRUNCATE, etc. + OpenFlags uint32 +} + +// Options contains time out options for a node FileSystem. The +// default copied from libfuse and set in NewMountOptions() is +// (1s,1s,0s). +type Options struct { + EntryTimeout time.Duration + AttrTimeout time.Duration + NegativeTimeout time.Duration + + // If set, replace all uids with given UID. + // NewFileSystemOptions() will set this to the daemon's + // uid/gid. + *fuse.Owner + + // This option exists for compatibility and is ignored. + PortableInodes bool +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go new file mode 100644 index 00000000..c3b0b127 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go @@ -0,0 +1,70 @@ +package nodefs + +import ( + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +type defaultFile struct{} + +// NewDefaultFile returns a File instance that returns ENOSYS for +// every operation. +func NewDefaultFile() File { + return (*defaultFile)(nil) +} + +func (f *defaultFile) SetInode(*Inode) { +} + +func (f *defaultFile) InnerFile() File { + return nil +} + +func (f *defaultFile) String() string { + return "defaultFile" +} + +func (f *defaultFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { + return nil, fuse.ENOSYS +} + +func (f *defaultFile) Write(data []byte, off int64) (uint32, fuse.Status) { + return 0, fuse.ENOSYS +} + +func (f *defaultFile) Flush() fuse.Status { + return fuse.OK +} + +func (f *defaultFile) Release() { + +} + +func (f *defaultFile) GetAttr(*fuse.Attr) fuse.Status { + return fuse.ENOSYS +} + +func (f *defaultFile) Fsync(flags int) (code fuse.Status) { + return fuse.ENOSYS +} + +func (f *defaultFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { + return fuse.ENOSYS +} + +func (f *defaultFile) Truncate(size uint64) fuse.Status { + return fuse.ENOSYS +} + +func (f *defaultFile) Chown(uid uint32, gid uint32) fuse.Status { + return fuse.ENOSYS +} + +func (f *defaultFile) Chmod(perms uint32) fuse.Status { + return fuse.ENOSYS +} + +func (f *defaultFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { + return fuse.ENOSYS +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go new file mode 100644 index 00000000..f4474dd5 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go @@ -0,0 +1,165 @@ +package nodefs + +import ( + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +// NewDefaultNode returns an implementation of Node that returns +// ENOSYS for all operations. +func NewDefaultNode() Node { + return &defaultNode{} +} + +type defaultNode struct { + inode *Inode +} + +func (fs *defaultNode) OnUnmount() { +} + +func (fs *defaultNode) OnMount(conn *FileSystemConnector) { +} + +func (n *defaultNode) StatFs() *fuse.StatfsOut { + return nil +} + +func (n *defaultNode) SetInode(node *Inode) { + n.inode = node +} + +func (n *defaultNode) Deletable() bool { + return true +} + +func (n *defaultNode) Inode() *Inode { + return n.inode +} + +func (n *defaultNode) OnForget() { +} + +func (n *defaultNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (node *Inode, code fuse.Status) { + return nil, fuse.ENOENT +} + +func (n *defaultNode) Access(mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Readlink(c *fuse.Context) ([]byte, fuse.Status) { + return nil, fuse.ENOSYS +} + +func (n *defaultNode) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) { + return nil, fuse.ENOSYS +} +func (n *defaultNode) Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) { + return nil, fuse.ENOSYS +} +func (n *defaultNode) Unlink(name string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} +func (n *defaultNode) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} +func (n *defaultNode) Symlink(name string, content string, context *fuse.Context) (newNode *Inode, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (n *defaultNode) Rename(oldName string, newParent Node, newName string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Link(name string, existing Node, context *fuse.Context) (newNode *Inode, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (n *defaultNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, newNode *Inode, code fuse.Status) { + return nil, nil, fuse.ENOSYS +} + +func (n *defaultNode) Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (n *defaultNode) Flush(file File, openFlags uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { + ch := n.Inode().Children() + s := make([]fuse.DirEntry, 0, len(ch)) + for name, child := range ch { + if child.mountPoint != nil { + continue + } + var a fuse.Attr + code := child.Node().GetAttr(&a, nil, context) + if code.Ok() { + s = append(s, fuse.DirEntry{Name: name, Mode: a.Mode}) + } + } + return s, fuse.OK +} + +func (n *defaultNode) GetXAttr(attribute string, context *fuse.Context) (data []byte, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (n *defaultNode) RemoveXAttr(attr string, context *fuse.Context) fuse.Status { + return fuse.ENOSYS +} + +func (n *defaultNode) SetXAttr(attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + return fuse.ENOSYS +} + +func (n *defaultNode) ListXAttr(context *fuse.Context) (attrs []string, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (n *defaultNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) { + if n.Inode().IsDir() { + out.Mode = fuse.S_IFDIR | 0755 + } else { + out.Mode = fuse.S_IFREG | 0644 + } + return fuse.OK +} + +func (n *defaultNode) Chmod(file File, perms uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Chown(file File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Utimens(file File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Fallocate(file File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (n *defaultNode) Read(file File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) { + if file != nil { + return file.Read(dest, off) + } + return nil, fuse.ENOSYS +} + +func (n *defaultNode) Write(file File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { + if file != nil { + return file.Write(data, off) + } + return 0, fuse.ENOSYS +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go new file mode 100644 index 00000000..2f12fb19 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go @@ -0,0 +1,114 @@ +package nodefs + +import ( + "log" + "sync" + + "github.com/hanwen/go-fuse/fuse" +) + +type connectorDir struct { + node Node + rawFS fuse.RawFileSystem + + // Protect stream and lastOffset. These are written in case + // there is a seek on the directory. + mu sync.Mutex + stream []fuse.DirEntry + + // lastOffset stores the last offset for a readdir. This lets + // readdir pick up changes to the directory made after opening + // it. + lastOffset uint64 +} + +func (d *connectorDir) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) (code fuse.Status) { + d.mu.Lock() + defer d.mu.Unlock() + + if d.stream == nil { + return fuse.OK + } + // rewinddir() should be as if reopening directory. + // TODO - test this. + if d.lastOffset > 0 && input.Offset == 0 { + d.stream, code = d.node.OpenDir((*fuse.Context)(&input.Context)) + if !code.Ok() { + return code + } + } + + if input.Offset > uint64(len(d.stream)) { + // This shouldn't happen, but let's not crash. + return fuse.EINVAL + } + + todo := d.stream[input.Offset:] + for _, e := range todo { + if e.Name == "" { + log.Printf("got empty directory entry, mode %o.", e.Mode) + continue + } + ok, off := out.AddDirEntry(e) + d.lastOffset = off + if !ok { + break + } + } + return fuse.OK +} + +func (d *connectorDir) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) (code fuse.Status) { + d.mu.Lock() + defer d.mu.Unlock() + + if d.stream == nil { + return fuse.OK + } + + // rewinddir() should be as if reopening directory. + if d.lastOffset > 0 && input.Offset == 0 { + d.stream, code = d.node.OpenDir((*fuse.Context)(&input.Context)) + if !code.Ok() { + return code + } + } + + if input.Offset > uint64(len(d.stream)) { + // This shouldn't happen, but let's not crash. + return fuse.EINVAL + } + todo := d.stream[input.Offset:] + for _, e := range todo { + if e.Name == "" { + log.Printf("got empty directory entry, mode %o.", e.Mode) + continue + } + + // we have to be sure entry will fit if we try to add + // it, or we'll mess up the lookup counts. + entryDest, off := out.AddDirLookupEntry(e) + if entryDest == nil { + break + } + entryDest.Ino = uint64(fuse.FUSE_UNKNOWN_INO) + + // No need to fill attributes for . and .. + if e.Name == "." || e.Name == ".." { + continue + } + + // Clear entryDest before use it, some fields can be corrupted if does not set all fields in rawFS.Lookup + *entryDest = fuse.EntryOut{} + + d.rawFS.Lookup(&input.InHeader, e.Name, entryDest) + d.lastOffset = off + } + return fuse.OK + +} + +type rawDir interface { + ReadDir(out *fuse.DirEntryList, input *fuse.ReadIn, c *fuse.Context) fuse.Status + ReadDirPlus(out *fuse.DirEntryList, input *fuse.ReadIn, c *fuse.Context) fuse.Status +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go new file mode 100644 index 00000000..004406b3 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go @@ -0,0 +1,249 @@ +package nodefs + +import ( + "fmt" + "os" + "sync" + "syscall" + + "github.com/hanwen/go-fuse/fuse" +) + +// DataFile is for implementing read-only filesystems. This +// assumes we already have the data in memory. +type dataFile struct { + data []byte + + File +} + +func (f *dataFile) String() string { + l := len(f.data) + if l > 10 { + l = 10 + } + + return fmt.Sprintf("dataFile(%x)", f.data[:l]) +} + +func (f *dataFile) GetAttr(out *fuse.Attr) fuse.Status { + out.Mode = fuse.S_IFREG | 0644 + out.Size = uint64(len(f.data)) + return fuse.OK +} + +func NewDataFile(data []byte) File { + f := new(dataFile) + f.data = data + f.File = NewDefaultFile() + return f +} + +func (f *dataFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { + end := int(off) + int(len(buf)) + if end > len(f.data) { + end = len(f.data) + } + + return fuse.ReadResultData(f.data[off:end]), fuse.OK +} + +type devNullFile struct { + File +} + +// NewDevNullFile returns a file that accepts any write, and always +// returns EOF for reads. +func NewDevNullFile() File { + return &devNullFile{ + File: NewDefaultFile(), + } +} + +func (f *devNullFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { + return fuse.OK +} + +func (f *devNullFile) String() string { + return "devNullFile" +} + +func (f *devNullFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { + return fuse.ReadResultData(nil), fuse.OK +} + +func (f *devNullFile) Write(content []byte, off int64) (uint32, fuse.Status) { + return uint32(len(content)), fuse.OK +} + +func (f *devNullFile) Flush() fuse.Status { + return fuse.OK +} + +func (f *devNullFile) Fsync(flags int) (code fuse.Status) { + return fuse.OK +} + +func (f *devNullFile) Truncate(size uint64) (code fuse.Status) { + return fuse.OK +} + +//////////////// + +// LoopbackFile delegates all operations back to an underlying os.File. +func NewLoopbackFile(f *os.File) File { + return &loopbackFile{File: f} +} + +type loopbackFile struct { + File *os.File + + // os.File is not threadsafe. Although fd themselves are + // constant during the lifetime of an open file, the OS may + // reuse the fd number after it is closed. When open races + // with another close, they may lead to confusion as which + // file gets written in the end. + lock sync.Mutex +} + +func (f *loopbackFile) InnerFile() File { + return nil +} + +func (f *loopbackFile) SetInode(n *Inode) { +} + +func (f *loopbackFile) String() string { + return fmt.Sprintf("loopbackFile(%s)", f.File.Name()) +} + +func (f *loopbackFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { + f.lock.Lock() + // This is not racy by virtue of the kernel properly + // synchronizing the open/write/close. + r := fuse.ReadResultFd(f.File.Fd(), off, len(buf)) + f.lock.Unlock() + return r, fuse.OK +} + +func (f *loopbackFile) Write(data []byte, off int64) (uint32, fuse.Status) { + f.lock.Lock() + n, err := f.File.WriteAt(data, off) + f.lock.Unlock() + return uint32(n), fuse.ToStatus(err) +} + +func (f *loopbackFile) Release() { + f.lock.Lock() + f.File.Close() + f.lock.Unlock() +} + +func (f *loopbackFile) Flush() fuse.Status { + f.lock.Lock() + + // Since Flush() may be called for each dup'd fd, we don't + // want to really close the file, we just want to flush. This + // is achieved by closing a dup'd fd. + newFd, err := syscall.Dup(int(f.File.Fd())) + f.lock.Unlock() + + if err != nil { + return fuse.ToStatus(err) + } + err = syscall.Close(newFd) + return fuse.ToStatus(err) +} + +func (f *loopbackFile) Fsync(flags int) (code fuse.Status) { + f.lock.Lock() + r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd()))) + f.lock.Unlock() + + return r +} + +func (f *loopbackFile) Truncate(size uint64) fuse.Status { + f.lock.Lock() + r := fuse.ToStatus(syscall.Ftruncate(int(f.File.Fd()), int64(size))) + f.lock.Unlock() + + return r +} + +func (f *loopbackFile) Chmod(mode uint32) fuse.Status { + f.lock.Lock() + r := fuse.ToStatus(f.File.Chmod(os.FileMode(mode))) + f.lock.Unlock() + + return r +} + +func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status { + f.lock.Lock() + r := fuse.ToStatus(f.File.Chown(int(uid), int(gid))) + f.lock.Unlock() + + return r +} + +func (f *loopbackFile) GetAttr(a *fuse.Attr) fuse.Status { + st := syscall.Stat_t{} + f.lock.Lock() + err := syscall.Fstat(int(f.File.Fd()), &st) + f.lock.Unlock() + if err != nil { + return fuse.ToStatus(err) + } + a.FromStat(&st) + + return fuse.OK +} + +// Utimens implemented in files_linux.go + +// Allocate implemented in files_linux.go + +//////////////////////////////////////////////////////////////// + +// NewReadOnlyFile wraps a File so all read/write operations are +// denied. +func NewReadOnlyFile(f File) File { + return &readOnlyFile{File: f} +} + +type readOnlyFile struct { + File +} + +func (f *readOnlyFile) InnerFile() File { + return f.File +} + +func (f *readOnlyFile) String() string { + return fmt.Sprintf("readOnlyFile(%s)", f.File.String()) +} + +func (f *readOnlyFile) Write(data []byte, off int64) (uint32, fuse.Status) { + return 0, fuse.EPERM +} + +func (f *readOnlyFile) Fsync(flag int) (code fuse.Status) { + return fuse.OK +} + +func (f *readOnlyFile) Truncate(size uint64) fuse.Status { + return fuse.EPERM +} + +func (f *readOnlyFile) Chmod(mode uint32) fuse.Status { + return fuse.EPERM +} + +func (f *readOnlyFile) Chown(uid uint32, gid uint32) fuse.Status { + return fuse.EPERM +} + +func (f *readOnlyFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { + return fuse.EPERM +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go new file mode 100644 index 00000000..01ab0af3 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go @@ -0,0 +1,99 @@ +package nodefs + +import ( + "syscall" + "time" + "unsafe" + + "github.com/hanwen/go-fuse/fuse" +) + +func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { + // TODO: Handle `mode` parameter. + + // From `man fcntl` on OSX: + // The F_PREALLOCATE command operates on the following structure: + // + // typedef struct fstore { + // u_int32_t fst_flags; /* IN: flags word */ + // int fst_posmode; /* IN: indicates offset field */ + // off_t fst_offset; /* IN: start of the region */ + // off_t fst_length; /* IN: size of the region */ + // off_t fst_bytesalloc; /* OUT: number of bytes allocated */ + // } fstore_t; + // + // The flags (fst_flags) for the F_PREALLOCATE command are as follows: + // + // F_ALLOCATECONTIG Allocate contiguous space. + // + // F_ALLOCATEALL Allocate all requested space or no space at all. + // + // The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field. The modes are as fol- + // lows: + // + // F_PEOFPOSMODE Allocate from the physical end of file. + // + // F_VOLPOSMODE Allocate from the volume offset. + + k := struct { + Flags uint32 // u_int32_t + Posmode int64 // int + Offset int64 // off_t + Length int64 // off_t + Bytesalloc int64 // off_t + }{ + 0, + 0, + int64(off), + int64(sz), + 0, + } + + // Linux version for reference: + // err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz)) + + f.lock.Lock() + _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.File.Fd(), uintptr(syscall.F_PREALLOCATE), uintptr(unsafe.Pointer(&k))) + f.lock.Unlock() + if errno != 0 { + return fuse.ToStatus(errno) + } + return fuse.OK +} + +const _UTIME_NOW = ((1 << 30) - 1) +const _UTIME_OMIT = ((1 << 30) - 2) + +// timeToTimeval - Convert time.Time to syscall.Timeval +// +// Note: This does not use syscall.NsecToTimespec because +// that does not work properly for times before 1970, +// see https://github.com/golang/go/issues/12777 +func timeToTimeval(t *time.Time) syscall.Timeval { + var tv syscall.Timeval + tv.Usec = int32(t.Nanosecond() / 1000) + tv.Sec = t.Unix() + return tv +} + +// OSX does not have the utimensat syscall neded to implement this properly. +// We do our best to emulate it using futimes. +func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status { + tv := make([]syscall.Timeval, 2) + if a == nil { + tv[0].Usec = _UTIME_OMIT + } else { + tv[0] = timeToTimeval(a) + } + + if m == nil { + tv[1].Usec = _UTIME_OMIT + } else { + tv[1] = timeToTimeval(m) + } + + f.lock.Lock() + err := syscall.Futimes(int(f.File.Fd()), tv) + f.lock.Unlock() + return fuse.ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go new file mode 100644 index 00000000..ac4f7c5e --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go @@ -0,0 +1,45 @@ +package nodefs + +import ( + "syscall" + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { + f.lock.Lock() + err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz)) + f.lock.Unlock() + if err != nil { + return fuse.ToStatus(err) + } + return fuse.OK +} + +const _UTIME_NOW = ((1 << 30) - 1) +const _UTIME_OMIT = ((1 << 30) - 2) + +// Utimens - file handle based version of loopbackFileSystem.Utimens() +func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status { + var ts [2]syscall.Timespec + + if a == nil { + ts[0].Nsec = _UTIME_OMIT + } else { + ts[0] = syscall.NsecToTimespec(a.UnixNano()) + ts[0].Nsec = 0 + } + + if m == nil { + ts[1].Nsec = _UTIME_OMIT + } else { + ts[1] = syscall.NsecToTimespec(a.UnixNano()) + ts[1].Nsec = 0 + } + + f.lock.Lock() + err := futimens(int(f.File.Fd()), &ts) + f.lock.Unlock() + return fuse.ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go new file mode 100644 index 00000000..a0e4e645 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go @@ -0,0 +1,419 @@ +package nodefs + +// This file contains the internal logic of the +// FileSystemConnector. The functions for satisfying the raw interface +// are in fsops.go + +import ( + "log" + "path/filepath" + "strings" + "time" + "unsafe" + + "github.com/hanwen/go-fuse/fuse" +) + +// Tests should set to true. +var paranoia = false + +// FilesystemConnector translates the raw FUSE protocol (serialized +// structs of uint32/uint64) to operations on Go objects representing +// files and directories. +type FileSystemConnector struct { + debug bool + + // Callbacks for talking back to the kernel. + server *fuse.Server + + // Translate between uint64 handles and *Inode. + inodeMap handleMap + + // The root of the FUSE file system. + rootNode *Inode +} + +// NewOptions generates FUSE options that correspond to libfuse's +// defaults. +func NewOptions() *Options { + return &Options{ + NegativeTimeout: 0, + AttrTimeout: time.Second, + EntryTimeout: time.Second, + Owner: fuse.CurrentOwner(), + } +} + +// NewFileSystemConnector creates a FileSystemConnector with the given +// options. +func NewFileSystemConnector(root Node, opts *Options) (c *FileSystemConnector) { + c = new(FileSystemConnector) + if opts == nil { + opts = NewOptions() + } + c.inodeMap = newPortableHandleMap() + c.rootNode = newInode(true, root) + + c.verify() + c.mountRoot(opts) + + // FUSE does not issue a LOOKUP for 1 (obviously), but it does + // issue a forget. This lookupUpdate is to make the counts match. + c.lookupUpdate(c.rootNode) + + return c +} + +// Server returns the fuse.Server that talking to the kernel. +func (c *FileSystemConnector) Server() *fuse.Server { + return c.server +} + +// SetDebug toggles printing of debug information. +func (c *FileSystemConnector) SetDebug(debug bool) { + c.debug = debug +} + +// This verifies invariants of the data structure. This routine +// acquires tree locks as it walks the inode tree. +func (c *FileSystemConnector) verify() { + if !paranoia { + return + } + root := c.rootNode + root.verify(c.rootNode.mountPoint) +} + +// childLookup fills entry information for a newly created child inode +func (c *rawBridge) childLookup(out *fuse.EntryOut, n *Inode, context *fuse.Context) { + n.Node().GetAttr((*fuse.Attr)(&out.Attr), nil, context) + n.mount.fillEntry(out) + out.NodeId, out.Generation = c.fsConn().lookupUpdate(n) + if out.Ino == 0 { + out.Ino = out.NodeId + } + if out.Nlink == 0 { + // With Nlink == 0, newer kernels will refuse link + // operations. + out.Nlink = 1 + } +} + +func (c *rawBridge) toInode(nodeid uint64) *Inode { + if nodeid == fuse.FUSE_ROOT_ID { + return c.rootNode + } + i := (*Inode)(unsafe.Pointer(c.inodeMap.Decode(nodeid))) + return i +} + +// Must run outside treeLock. Returns the nodeId and generation. +func (c *FileSystemConnector) lookupUpdate(node *Inode) (id, generation uint64) { + id, generation = c.inodeMap.Register(&node.handled) + c.verify() + return +} + +// forgetUpdate decrements the reference counter for "nodeID" by "forgetCount". +// Must run outside treeLock. +func (c *FileSystemConnector) forgetUpdate(nodeID uint64, forgetCount int) { + if nodeID == fuse.FUSE_ROOT_ID { + c.rootNode.Node().OnUnmount() + + // We never got a lookup for root, so don't try to + // forget root. + return + } + + // Prevent concurrent modification of the tree while we are processing + // the FORGET + node := (*Inode)(unsafe.Pointer(c.inodeMap.Decode(nodeID))) + node.mount.treeLock.Lock() + defer node.mount.treeLock.Unlock() + + if forgotten, _ := c.inodeMap.Forget(nodeID, forgetCount); forgotten { + if len(node.children) > 0 || !node.Node().Deletable() || + node == c.rootNode || node.mountPoint != nil { + // We cannot forget a directory that still has children as these + // would become unreachable. + return + } + // We have to remove ourself from all parents. + // Create a copy of node.parents so we can safely iterate over it + // while modifying the original. + parents := make(map[parentData]struct{}, len(node.parents)) + for k, v := range node.parents { + parents[k] = v + } + + for p := range parents { + // This also modifies node.parents + p.parent.rmChild(p.name) + } + + node.fsInode.OnForget() + } + // TODO - try to drop children even forget was not successful. + c.verify() +} + +// InodeCount returns the number of inodes registered with the kernel. +func (c *FileSystemConnector) InodeHandleCount() int { + return c.inodeMap.Count() +} + +// Finds a node within the currently known inodes, returns the last +// known node and the remaining unknown path components. If parent is +// nil, start from FUSE mountpoint. +func (c *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []string) { + if parent == nil { + parent = c.rootNode + } + if fullPath == "" { + return parent, nil + } + + sep := string(filepath.Separator) + fullPath = strings.TrimLeft(filepath.Clean(fullPath), sep) + comps := strings.Split(fullPath, sep) + + node := parent + if node.mountPoint == nil { + node.mount.treeLock.RLock() + defer node.mount.treeLock.RUnlock() + } + + for i, component := range comps { + if len(component) == 0 { + continue + } + + if node.mountPoint != nil { + node.mount.treeLock.RLock() + defer node.mount.treeLock.RUnlock() + } + + next := node.children[component] + if next == nil { + return node, comps[i:] + } + node = next + } + + return node, nil +} + +// Follows the path from the given parent, doing lookups as +// necesary. The path should be '/' separated without leading slash. +func (c *FileSystemConnector) LookupNode(parent *Inode, path string) *Inode { + if path == "" { + return parent + } + + components := strings.Split(path, "/") + for _, r := range components { + var a fuse.Attr + // This will not affect inode ID lookup counts, which + // are only update in response to kernel requests. + var dummy fuse.InHeader + child, _ := c.internalLookup(&a, parent, r, &dummy) + if child == nil { + return nil + } + + parent = child + } + + return parent +} + +func (c *FileSystemConnector) mountRoot(opts *Options) { + c.rootNode.mountFs(opts) + c.rootNode.mount.connector = c + c.rootNode.Node().OnMount(c) + c.verify() +} + +// Mount() generates a synthetic directory node, and mounts the file +// system there. If opts is nil, the mount options of the root file +// system are inherited. The encompassing filesystem should pretend +// the mount point does not exist. +// +// It returns ENOENT if the directory containing the mount point does +// not exist, and EBUSY if the intended mount point already exists. +func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts *Options) fuse.Status { + node, code := c.lockMount(parent, name, root, opts) + if !code.Ok() { + return code + } + + node.Node().OnMount(c) + return code +} + +func (c *FileSystemConnector) lockMount(parent *Inode, name string, root Node, opts *Options) (*Inode, fuse.Status) { + defer c.verify() + parent.mount.treeLock.Lock() + defer parent.mount.treeLock.Unlock() + node := parent.children[name] + if node != nil { + return nil, fuse.EBUSY + } + + node = newInode(true, root) + if opts == nil { + opts = c.rootNode.mountPoint.options + } + + node.mountFs(opts) + node.mount.connector = c + parent.addChild(name, node) + + node.mountPoint.parentInode = parent + if c.debug { + log.Printf("Mount %T on subdir %s, parent %d", node, + name, c.inodeMap.Handle(&parent.handled)) + } + return node, fuse.OK +} + +// Unmount() tries to unmount the given inode. It returns EINVAL if the +// path does not exist, or is not a mount point, and EBUSY if there +// are open files or submounts below this node. +func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status { + // TODO - racy. + if node.mountPoint == nil { + log.Println("not a mountpoint:", c.inodeMap.Handle(&node.handled)) + return fuse.EINVAL + } + + nodeID := c.inodeMap.Handle(&node.handled) + + // Must lock parent to update tree structure. + parentNode := node.mountPoint.parentInode + parentNode.mount.treeLock.Lock() + defer parentNode.mount.treeLock.Unlock() + + mount := node.mountPoint + name := node.mountPoint.mountName() + if mount.openFiles.Count() > 0 { + return fuse.EBUSY + } + + node.mount.treeLock.Lock() + defer node.mount.treeLock.Unlock() + + if mount.mountInode != node { + log.Panicf("got two different mount inodes %v vs %v", + c.inodeMap.Handle(&mount.mountInode.handled), + c.inodeMap.Handle(&node.handled)) + } + + if !node.canUnmount() { + return fuse.EBUSY + } + + delete(parentNode.children, name) + node.Node().OnUnmount() + + parentId := c.inodeMap.Handle(&parentNode.handled) + if parentNode == c.rootNode { + // TODO - test coverage. Currently covered by zipfs/multizip_test.go + parentId = fuse.FUSE_ROOT_ID + } + + // We have to wait until the kernel has forgotten the + // mountpoint, so the write to node.mountPoint is no longer + // racy. + mount.treeLock.Unlock() + parentNode.mount.treeLock.Unlock() + code := c.server.DeleteNotify(parentId, nodeID, name) + + if code.Ok() { + delay := 100 * time.Microsecond + + for { + // This operation is rare, so we kludge it to avoid + // contention. + time.Sleep(delay) + delay = delay * 2 + if !c.inodeMap.Has(nodeID) { + break + } + + if delay >= time.Second { + // We limit the wait at one second. If + // it takes longer, something else is + // amiss, and we would be waiting forever. + log.Println("kernel did not issue FORGET for node on Unmount.") + break + } + } + + } + + parentNode.mount.treeLock.Lock() + mount.treeLock.Lock() + mount.mountInode = nil + node.mountPoint = nil + + return fuse.OK +} + +// FileNotify notifies the kernel that data and metadata of this inode +// has changed. After this call completes, the kernel will issue a +// new GetAttr requests for metadata and new Read calls for content. +// Use negative offset for metadata-only invalidation, and zero-length +// for invalidating all content. +func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) fuse.Status { + var nId uint64 + if node == c.rootNode { + nId = fuse.FUSE_ROOT_ID + } else { + nId = c.inodeMap.Handle(&node.handled) + } + + if nId == 0 { + return fuse.OK + } + return c.server.InodeNotify(nId, off, length) +} + +// EntryNotify makes the kernel forget the entry data from the given +// name from a directory. After this call, the kernel will issue a +// new lookup request for the given name when necessary. No filesystem +// related locks should be held when calling this. +func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status { + var nId uint64 + if node == c.rootNode { + nId = fuse.FUSE_ROOT_ID + } else { + nId = c.inodeMap.Handle(&node.handled) + } + + if nId == 0 { + return fuse.OK + } + return c.server.EntryNotify(nId, name) +} + +// DeleteNotify signals to the kernel that the named entry in dir for +// the child disappeared. No filesystem related locks should be held +// when calling this. +func (c *FileSystemConnector) DeleteNotify(dir *Inode, child *Inode, name string) fuse.Status { + var nId uint64 + + if dir == c.rootNode { + nId = fuse.FUSE_ROOT_ID + } else { + nId = c.inodeMap.Handle(&dir.handled) + } + + if nId == 0 { + return fuse.OK + } + + chId := c.inodeMap.Handle(&child.handled) + + return c.server.DeleteNotify(nId, chId, name) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go new file mode 100644 index 00000000..eaf4f6bb --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go @@ -0,0 +1,154 @@ +package nodefs + +import ( + "log" + "sync" + "unsafe" + + "github.com/hanwen/go-fuse/fuse" +) + +// openedFile stores either an open dir or an open file. +type openedFile struct { + handled + + WithFlags + + dir *connectorDir +} + +type fileSystemMount struct { + // Node that we were mounted on. + mountInode *Inode + + // Parent to the mountInode. + parentInode *Inode + + // Options for the mount. + options *Options + + // Protects the "children" and "parents" hashmaps of the inodes + // within the mount. + // treeLock should be acquired before openFilesLock. + // + // If multiple treeLocks must be acquired, the treeLocks + // closer to the root must be acquired first. + treeLock sync.RWMutex + + // Manage filehandles of open files. + openFiles handleMap + + Debug bool + + connector *FileSystemConnector +} + +// Must called with lock for parent held. +func (m *fileSystemMount) mountName() string { + for k, v := range m.parentInode.children { + if m.mountInode == v { + return k + } + } + panic("not found") +} + +func (m *fileSystemMount) setOwner(attr *fuse.Attr) { + if m.options.Owner != nil { + attr.Owner = *(*fuse.Owner)(m.options.Owner) + } +} + +func (m *fileSystemMount) fillEntry(out *fuse.EntryOut) { + splitDuration(m.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec) + splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) + m.setOwner(&out.Attr) + if out.Mode&fuse.S_IFDIR == 0 && out.Nlink == 0 { + out.Nlink = 1 + } +} + +func (m *fileSystemMount) fillAttr(out *fuse.AttrOut, nodeId uint64) { + splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) + m.setOwner(&out.Attr) + if out.Ino == 0 { + out.Ino = nodeId + } +} + +func (m *fileSystemMount) getOpenedFile(h uint64) *openedFile { + var b *openedFile + if h != 0 { + b = (*openedFile)(unsafe.Pointer(m.openFiles.Decode(h))) + } + + if b != nil && m.connector.debug && b.WithFlags.Description != "" { + log.Printf("File %d = %q", h, b.WithFlags.Description) + } + return b +} + +func (m *fileSystemMount) unregisterFileHandle(handle uint64, node *Inode) *openedFile { + _, obj := m.openFiles.Forget(handle, 1) + opened := (*openedFile)(unsafe.Pointer(obj)) + node.openFilesMutex.Lock() + idx := -1 + for i, v := range node.openFiles { + if v == opened { + idx = i + break + } + } + + l := len(node.openFiles) + if idx == l-1 { + node.openFiles[idx] = nil + } else { + node.openFiles[idx] = node.openFiles[l-1] + } + node.openFiles = node.openFiles[:l-1] + node.openFilesMutex.Unlock() + + return opened +} + +func (m *fileSystemMount) registerFileHandle(node *Inode, dir *connectorDir, f File, flags uint32) (uint64, *openedFile) { + node.openFilesMutex.Lock() + b := &openedFile{ + dir: dir, + WithFlags: WithFlags{ + File: f, + OpenFlags: flags, + }, + } + + for { + withFlags, ok := f.(*WithFlags) + if !ok { + break + } + + b.WithFlags.File = withFlags.File + b.WithFlags.FuseFlags |= withFlags.FuseFlags + b.WithFlags.Description += withFlags.Description + f = withFlags.File + } + + if b.WithFlags.File != nil { + b.WithFlags.File.SetInode(node) + } + node.openFiles = append(node.openFiles, b) + handle, _ := m.openFiles.Register(&b.handled) + node.openFilesMutex.Unlock() + return handle, b +} + +// Creates a return entry for a non-existent path. +func (m *fileSystemMount) negativeEntry(out *fuse.EntryOut) bool { + if m.options.NegativeTimeout > 0.0 { + out.NodeId = 0 + splitDuration(m.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec) + return true + } + return false +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go new file mode 100644 index 00000000..757d6272 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go @@ -0,0 +1,465 @@ +package nodefs + +// This file contains FileSystemConnector's implementation of +// RawFileSystem + +import ( + "bytes" + "fmt" + "log" + "strings" + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +// Returns the RawFileSystem so it can be mounted. +func (c *FileSystemConnector) RawFS() fuse.RawFileSystem { + return (*rawBridge)(c) +} + +type rawBridge FileSystemConnector + +func (c *rawBridge) Fsync(input *fuse.FsyncIn) fuse.Status { + node := c.toInode(input.NodeId) + opened := node.mount.getOpenedFile(input.Fh) + + if opened != nil { + return opened.WithFlags.File.Fsync(int(input.FsyncFlags)) + } + + return fuse.ENOSYS +} + +func (c *rawBridge) SetDebug(debug bool) { + c.fsConn().SetDebug(debug) +} + +func (c *rawBridge) FsyncDir(input *fuse.FsyncIn) fuse.Status { + return fuse.ENOSYS +} + +func (c *rawBridge) fsConn() *FileSystemConnector { + return (*FileSystemConnector)(c) +} + +func (c *rawBridge) String() string { + if c.rootNode == nil || c.rootNode.mount == nil { + return "go-fuse:unmounted" + } + + name := fmt.Sprintf("%T", c.rootNode.Node()) + name = strings.TrimLeft(name, "*") + return name +} + +func (c *rawBridge) Init(s *fuse.Server) { + c.server = s +} + +func (c *FileSystemConnector) lookupMountUpdate(out *fuse.Attr, mount *fileSystemMount) (node *Inode, code fuse.Status) { + code = mount.mountInode.Node().GetAttr(out, nil, nil) + if !code.Ok() { + log.Println("Root getattr should not return error", code) + out.Mode = fuse.S_IFDIR | 0755 + return mount.mountInode, fuse.OK + } + + return mount.mountInode, fuse.OK +} + +// internalLookup executes a lookup without affecting NodeId reference counts. +func (c *FileSystemConnector) internalLookup(out *fuse.Attr, parent *Inode, name string, header *fuse.InHeader) (node *Inode, code fuse.Status) { + + // We may already know the child because it was created using Create or Mkdir, + // from an earlier lookup, or because the nodes were created in advance + // (in-memory filesystems). + child := parent.GetChild(name) + + if child != nil && child.mountPoint != nil { + return c.lookupMountUpdate(out, child.mountPoint) + } + + if child != nil { + parent = nil + } + if child != nil { + code = child.fsInode.GetAttr(out, nil, &header.Context) + } else { + child, code = parent.fsInode.Lookup(out, name, &header.Context) + } + + return child, code +} + +func (c *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOut) (code fuse.Status) { + parent := c.toInode(header.NodeId) + if !parent.IsDir() { + log.Printf("Lookup %q called on non-Directory node %d", name, header.NodeId) + return fuse.ENOTDIR + } + outAttr := (*fuse.Attr)(&out.Attr) + child, code := c.fsConn().internalLookup(outAttr, parent, name, header) + if code == fuse.ENOENT && parent.mount.negativeEntry(out) { + return fuse.OK + } + if !code.Ok() { + return code + } + if child == nil { + log.Println("Lookup returned fuse.OK with nil child", name) + } + + child.mount.fillEntry(out) + out.NodeId, out.Generation = c.fsConn().lookupUpdate(child) + if out.Ino == 0 { + out.Ino = out.NodeId + } + + return fuse.OK +} + +func (c *rawBridge) Forget(nodeID, nlookup uint64) { + c.fsConn().forgetUpdate(nodeID, int(nlookup)) +} + +func (c *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) { + node := c.toInode(input.NodeId) + + var f File + if input.Flags()&fuse.FUSE_GETATTR_FH != 0 { + if opened := node.mount.getOpenedFile(input.Fh()); opened != nil { + f = opened.WithFlags.File + } + } + + dest := (*fuse.Attr)(&out.Attr) + code = node.fsInode.GetAttr(dest, f, &input.Context) + if !code.Ok() { + return code + } + + node.mount.fillAttr(out, input.NodeId) + return fuse.OK +} + +func (c *rawBridge) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) (code fuse.Status) { + node := c.toInode(input.NodeId) + stream, err := node.fsInode.OpenDir(&input.Context) + if err != fuse.OK { + return err + } + stream = append(stream, node.getMountDirEntries()...) + de := &connectorDir{ + node: node.Node(), + stream: append(stream, + fuse.DirEntry{Mode: fuse.S_IFDIR, Name: "."}, + fuse.DirEntry{Mode: fuse.S_IFDIR, Name: ".."}), + rawFS: c, + } + h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags) + out.OpenFlags = opened.FuseFlags + out.Fh = h + return fuse.OK +} + +func (c *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status { + node := c.toInode(input.NodeId) + opened := node.mount.getOpenedFile(input.Fh) + return opened.dir.ReadDir(input, out) +} + +func (c *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status { + node := c.toInode(input.NodeId) + opened := node.mount.getOpenedFile(input.Fh) + return opened.dir.ReadDirPlus(input, out) +} + +func (c *rawBridge) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) { + node := c.toInode(input.NodeId) + f, code := node.fsInode.Open(input.Flags, &input.Context) + if !code.Ok() || f == nil { + return code + } + h, opened := node.mount.registerFileHandle(node, nil, f, input.Flags) + out.OpenFlags = opened.FuseFlags + out.Fh = h + return fuse.OK +} + +func (c *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) { + node := c.toInode(input.NodeId) + + var f File + if input.Valid&fuse.FATTR_FH != 0 { + opened := node.mount.getOpenedFile(input.Fh) + f = opened.WithFlags.File + } + + if code.Ok() && input.Valid&fuse.FATTR_MODE != 0 { + permissions := uint32(07777) & input.Mode + code = node.fsInode.Chmod(f, permissions, &input.Context) + } + if code.Ok() && (input.Valid&(fuse.FATTR_UID|fuse.FATTR_GID) != 0) { + var uid uint32 = ^uint32(0) // means "do not change" in chown(2) + var gid uint32 = ^uint32(0) + if input.Valid&fuse.FATTR_UID != 0 { + uid = input.Uid + } + if input.Valid&fuse.FATTR_GID != 0 { + gid = input.Gid + } + code = node.fsInode.Chown(f, uid, gid, &input.Context) + } + if code.Ok() && input.Valid&fuse.FATTR_SIZE != 0 { + code = node.fsInode.Truncate(f, input.Size, &input.Context) + } + if code.Ok() && (input.Valid&(fuse.FATTR_ATIME|fuse.FATTR_MTIME|fuse.FATTR_ATIME_NOW|fuse.FATTR_MTIME_NOW) != 0) { + now := time.Now() + var atime *time.Time + var mtime *time.Time + + if input.Valid&fuse.FATTR_ATIME != 0 { + if input.Valid&fuse.FATTR_ATIME_NOW != 0 { + atime = &now + } else { + t := time.Unix(int64(input.Atime), int64(input.Atimensec)) + atime = &t + } + } + + if input.Valid&fuse.FATTR_MTIME != 0 { + if input.Valid&fuse.FATTR_MTIME_NOW != 0 { + mtime = &now + } else { + t := time.Unix(int64(input.Mtime), int64(input.Mtimensec)) + mtime = &t + } + } + + code = node.fsInode.Utimens(f, atime, mtime, &input.Context) + } + + if !code.Ok() { + return code + } + + // Must call GetAttr(); the filesystem may override some of + // the changes we effect here. + attr := (*fuse.Attr)(&out.Attr) + code = node.fsInode.GetAttr(attr, nil, &input.Context) + if code.Ok() { + node.mount.fillAttr(out, input.NodeId) + } + return code +} + +func (c *rawBridge) Fallocate(input *fuse.FallocateIn) (code fuse.Status) { + n := c.toInode(input.NodeId) + opened := n.mount.getOpenedFile(input.Fh) + + return n.fsInode.Fallocate(opened, input.Offset, input.Length, input.Mode, &input.Context) +} + +func (c *rawBridge) Readlink(header *fuse.InHeader) (out []byte, code fuse.Status) { + n := c.toInode(header.NodeId) + return n.fsInode.Readlink(&header.Context) +} + +func (c *rawBridge) Mknod(input *fuse.MknodIn, name string, out *fuse.EntryOut) (code fuse.Status) { + parent := c.toInode(input.NodeId) + + child, code := parent.fsInode.Mknod(name, input.Mode, uint32(input.Rdev), &input.Context) + if code.Ok() { + c.childLookup(out, child, &input.Context) + code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &input.Context) + } + return code +} + +func (c *rawBridge) Mkdir(input *fuse.MkdirIn, name string, out *fuse.EntryOut) (code fuse.Status) { + parent := c.toInode(input.NodeId) + + child, code := parent.fsInode.Mkdir(name, input.Mode, &input.Context) + if code.Ok() { + c.childLookup(out, child, &input.Context) + code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &input.Context) + } + return code +} + +func (c *rawBridge) Unlink(header *fuse.InHeader, name string) (code fuse.Status) { + parent := c.toInode(header.NodeId) + return parent.fsInode.Unlink(name, &header.Context) +} + +func (c *rawBridge) Rmdir(header *fuse.InHeader, name string) (code fuse.Status) { + parent := c.toInode(header.NodeId) + return parent.fsInode.Rmdir(name, &header.Context) +} + +func (c *rawBridge) Symlink(header *fuse.InHeader, pointedTo string, linkName string, out *fuse.EntryOut) (code fuse.Status) { + parent := c.toInode(header.NodeId) + + child, code := parent.fsInode.Symlink(linkName, pointedTo, &header.Context) + if code.Ok() { + c.childLookup(out, child, &header.Context) + code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &header.Context) + } + return code +} + +func (c *rawBridge) Rename(input *fuse.RenameIn, oldName string, newName string) (code fuse.Status) { + oldParent := c.toInode(input.NodeId) + + child := oldParent.GetChild(oldName) + if child == nil { + return fuse.ENOENT + } + if child.mountPoint != nil { + return fuse.EBUSY + } + + newParent := c.toInode(input.Newdir) + if oldParent.mount != newParent.mount { + return fuse.EXDEV + } + + return oldParent.fsInode.Rename(oldName, newParent.fsInode, newName, &input.Context) +} + +func (c *rawBridge) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (code fuse.Status) { + existing := c.toInode(input.Oldnodeid) + parent := c.toInode(input.NodeId) + + if existing.mount != parent.mount { + return fuse.EXDEV + } + + child, code := parent.fsInode.Link(name, existing.fsInode, &input.Context) + if code.Ok() { + c.childLookup(out, child, &input.Context) + code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &input.Context) + } + + return code +} + +func (c *rawBridge) Access(input *fuse.AccessIn) (code fuse.Status) { + n := c.toInode(input.NodeId) + return n.fsInode.Access(input.Mask, &input.Context) +} + +func (c *rawBridge) Create(input *fuse.CreateIn, name string, out *fuse.CreateOut) (code fuse.Status) { + parent := c.toInode(input.NodeId) + f, child, code := parent.fsInode.Create(name, uint32(input.Flags), input.Mode, &input.Context) + if !code.Ok() { + return code + } + + c.childLookup(&out.EntryOut, child, &input.Context) + handle, opened := parent.mount.registerFileHandle(child, nil, f, input.Flags) + + out.OpenOut.OpenFlags = opened.FuseFlags + out.OpenOut.Fh = handle + return code +} + +func (c *rawBridge) Release(input *fuse.ReleaseIn) { + if input.Fh != 0 { + node := c.toInode(input.NodeId) + opened := node.mount.unregisterFileHandle(input.Fh, node) + opened.WithFlags.File.Release() + } +} + +func (c *rawBridge) ReleaseDir(input *fuse.ReleaseIn) { + if input.Fh != 0 { + node := c.toInode(input.NodeId) + node.mount.unregisterFileHandle(input.Fh, node) + } +} + +func (c *rawBridge) GetXAttrSize(header *fuse.InHeader, attribute string) (sz int, code fuse.Status) { + node := c.toInode(header.NodeId) + data, errno := node.fsInode.GetXAttr(attribute, &header.Context) + return len(data), errno +} + +func (c *rawBridge) GetXAttrData(header *fuse.InHeader, attribute string) (data []byte, code fuse.Status) { + node := c.toInode(header.NodeId) + return node.fsInode.GetXAttr(attribute, &header.Context) +} + +func (c *rawBridge) RemoveXAttr(header *fuse.InHeader, attr string) fuse.Status { + node := c.toInode(header.NodeId) + return node.fsInode.RemoveXAttr(attr, &header.Context) +} + +func (c *rawBridge) SetXAttr(input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status { + node := c.toInode(input.NodeId) + return node.fsInode.SetXAttr(attr, data, int(input.Flags), &input.Context) +} + +func (c *rawBridge) ListXAttr(header *fuse.InHeader) (data []byte, code fuse.Status) { + node := c.toInode(header.NodeId) + attrs, code := node.fsInode.ListXAttr(&header.Context) + if code != fuse.OK { + return nil, code + } + + b := bytes.NewBuffer([]byte{}) + for _, v := range attrs { + b.Write([]byte(v)) + b.WriteByte(0) + } + + return b.Bytes(), code +} + +//////////////// +// files. + +func (c *rawBridge) Write(input *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) { + node := c.toInode(input.NodeId) + opened := node.mount.getOpenedFile(input.Fh) + + var f File + if opened != nil { + f = opened.WithFlags.File + } + + return node.Node().Write(f, data, int64(input.Offset), &input.Context) +} + +func (c *rawBridge) Read(input *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status) { + node := c.toInode(input.NodeId) + opened := node.mount.getOpenedFile(input.Fh) + + var f File + if opened != nil { + f = opened.WithFlags.File + } + + return node.Node().Read(f, buf, int64(input.Offset), &input.Context) +} + +func (c *rawBridge) StatFs(header *fuse.InHeader, out *fuse.StatfsOut) fuse.Status { + node := c.toInode(header.NodeId) + s := node.Node().StatFs() + if s == nil { + return fuse.ENOSYS + } + *out = *s + return fuse.OK +} + +func (c *rawBridge) Flush(input *fuse.FlushIn) fuse.Status { + node := c.toInode(input.NodeId) + opened := node.mount.getOpenedFile(input.Fh) + + if opened != nil { + return opened.WithFlags.File.Flush() + } + return fuse.OK +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go new file mode 100644 index 00000000..6845e8fd --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go @@ -0,0 +1,15 @@ +package nodefs + +import ( + "github.com/hanwen/go-fuse/fuse" +) + +// Mounts a filesystem with the given root node on the given directory +func MountRoot(mountpoint string, root Node, opts *Options) (*fuse.Server, *FileSystemConnector, error) { + conn := NewFileSystemConnector(root, opts) + s, err := fuse.NewServer(conn.RawFS(), mountpoint, nil) + if err != nil { + return nil, nil, err + } + return s, conn, nil +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go new file mode 100644 index 00000000..3f35c9e4 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go @@ -0,0 +1,147 @@ +package nodefs + +import ( + "log" + "sync" +) + +// HandleMap translates objects in Go space to 64-bit handles that can +// be given out to -say- the linux kernel as NodeIds. +// +// The 32 bits version of this is a threadsafe wrapper around a map. +// +// To use it, include "handled" as first member of the structure +// you wish to export. +// +// This structure is thread-safe. +type handleMap interface { + // Register stores "obj" and returns a unique (NodeId, generation) tuple. + Register(obj *handled) (handle, generation uint64) + Count() int + // Decode retrieves a stored object from its 64-bit handle. + Decode(uint64) *handled + // Forget decrements the reference counter for "handle" by "count" and drops + // the object if the refcount reaches zero. + // Returns a boolean whether the object was dropped and the object itself. + Forget(handle uint64, count int) (bool, *handled) + // Handle gets the object's NodeId. + Handle(obj *handled) uint64 + // Has checks if NodeId is stored. + Has(uint64) bool +} + +type handled struct { + check uint32 + handle uint64 + count int +} + +func (h *handled) verify() { + if h.count < 0 { + log.Panicf("negative lookup count %d", h.count) + } + if (h.count == 0) != (h.handle == 0) { + log.Panicf("registration mismatch: lookup %d id %d", h.count, h.handle) + } +} + +const _ALREADY_MSG = "Object already has a handle" + +//////////////////////////////////////////////////////////////// +// portable version using 32 bit integers. + +type portableHandleMap struct { + sync.RWMutex + // The generation counter is incremented each time a NodeId is reused, + // hence the (NodeId, Generation) tuple is always unique. + generation uint64 + // Number of currently used handles + used int + // Array of Go objects indexed by NodeId + handles []*handled + // Free slots in the "handles" array + freeIds []uint64 +} + +func newPortableHandleMap() *portableHandleMap { + return &portableHandleMap{ + // Avoid handing out ID 0 and 1. + handles: []*handled{nil, nil}, + } +} + +func (m *portableHandleMap) Register(obj *handled) (handle, generation uint64) { + m.Lock() + if obj.count == 0 { + if obj.check != 0 { + panic(_ALREADY_MSG) + } + + if len(m.freeIds) == 0 { + handle = uint64(len(m.handles)) + m.handles = append(m.handles, obj) + } else { + handle = m.freeIds[len(m.freeIds)-1] + m.freeIds = m.freeIds[:len(m.freeIds)-1] + m.generation++ + m.handles[handle] = obj + } + m.used++ + obj.handle = handle + } else { + handle = obj.handle + } + obj.count++ + generation = m.generation + m.Unlock() + return +} + +func (m *portableHandleMap) Handle(obj *handled) (h uint64) { + m.RLock() + if obj.count == 0 { + h = 0 + } else { + h = obj.handle + } + m.RUnlock() + return h +} + +func (m *portableHandleMap) Count() int { + m.RLock() + c := m.used + m.RUnlock() + return c +} + +func (m *portableHandleMap) Decode(h uint64) *handled { + m.RLock() + v := m.handles[h] + m.RUnlock() + return v +} + +func (m *portableHandleMap) Forget(h uint64, count int) (forgotten bool, obj *handled) { + m.Lock() + obj = m.handles[h] + obj.count -= count + if obj.count < 0 { + log.Panicf("underflow: handle %d, count %d, object %d", h, count, obj.count) + } else if obj.count == 0 { + m.handles[h] = nil + m.freeIds = append(m.freeIds, h) + m.used-- + forgotten = true + obj.handle = 0 + } + m.Unlock() + return forgotten, obj +} + +func (m *portableHandleMap) Has(h uint64) bool { + m.RLock() + ok := m.handles[h] != nil + m.RUnlock() + return ok +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go new file mode 100644 index 00000000..cfffc095 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go @@ -0,0 +1,285 @@ +package nodefs + +import ( + "log" + "sync" + + "github.com/hanwen/go-fuse/fuse" +) + +type parentData struct { + parent *Inode + name string +} + +// An Inode reflects the kernel's idea of the inode. Inodes have IDs +// that are communicated to the kernel, and they have a tree +// structure: a directory Inode may contain named children. Each +// Inode object is paired with a Node object, which file system +// implementers should supply. +type Inode struct { + handled handled + + // Generation number of the inode. Each (re)use of an inode + // should have a unique generation number. + generation uint64 + + // Number of open files and its protection. + openFilesMutex sync.Mutex + openFiles []*openedFile + + fsInode Node + + // Each inode belongs to exactly one fileSystemMount. This + // pointer is constant during the lifetime, except upon + // Unmount() when it is set to nil. + mount *fileSystemMount + + // All data below is protected by treeLock. + children map[string]*Inode + // Due to hard links, an Inode can have many parents. + parents map[parentData]struct{} + + // Non-nil if this inode is a mountpoint, ie. the Root of a + // NodeFileSystem. + mountPoint *fileSystemMount +} + +func newInode(isDir bool, fsNode Node) *Inode { + me := new(Inode) + me.parents = map[parentData]struct{}{} + if isDir { + me.children = make(map[string]*Inode, initDirSize) + } + me.fsInode = fsNode + me.fsInode.SetInode(me) + return me +} + +// public methods. + +// Returns any open file, preferably a r/w one. +func (n *Inode) AnyFile() (file File) { + n.openFilesMutex.Lock() + for _, f := range n.openFiles { + if file == nil || f.WithFlags.OpenFlags&fuse.O_ANYWRITE != 0 { + file = f.WithFlags.File + } + } + n.openFilesMutex.Unlock() + + return file +} + +// Children returns all children of this inode. +func (n *Inode) Children() (out map[string]*Inode) { + n.mount.treeLock.RLock() + out = make(map[string]*Inode, len(n.children)) + for k, v := range n.children { + out[k] = v + } + n.mount.treeLock.RUnlock() + + return out +} + +// Parent returns a random parent and the name this inode has under this parent. +// This function can be used to walk up the directory tree. It will not cross +// sub-mounts. +func (n *Inode) Parent() (parent *Inode, name string) { + if n.mountPoint != nil { + return nil, "" + } + for k := range n.parents { + return k.parent, k.name + } + return nil, "" +} + +// FsChildren returns all the children from the same filesystem. It +// will skip mountpoints. +func (n *Inode) FsChildren() (out map[string]*Inode) { + n.mount.treeLock.RLock() + out = map[string]*Inode{} + for k, v := range n.children { + if v.mount == n.mount { + out[k] = v + } + } + n.mount.treeLock.RUnlock() + + return out +} + +// Node returns the file-system specific node. +func (n *Inode) Node() Node { + return n.fsInode +} + +// Files() returns an opens file that have bits in common with the +// give mask. Use mask==0 to return all files. +func (n *Inode) Files(mask uint32) (files []WithFlags) { + n.openFilesMutex.Lock() + for _, f := range n.openFiles { + if mask == 0 || f.WithFlags.OpenFlags&mask != 0 { + files = append(files, f.WithFlags) + } + } + n.openFilesMutex.Unlock() + return files +} + +// IsDir returns true if this is a directory. +func (n *Inode) IsDir() bool { + return n.children != nil +} + +// NewChild adds a new child inode to this inode. +func (n *Inode) NewChild(name string, isDir bool, fsi Node) *Inode { + ch := newInode(isDir, fsi) + ch.mount = n.mount + n.AddChild(name, ch) + return ch +} + +// GetChild returns a child inode with the given name, or nil if it +// does not exist. +func (n *Inode) GetChild(name string) (child *Inode) { + n.mount.treeLock.RLock() + child = n.children[name] + n.mount.treeLock.RUnlock() + + return child +} + +// AddChild adds a child inode. The parent inode must be a directory +// node. +func (n *Inode) AddChild(name string, child *Inode) { + if child == nil { + log.Panicf("adding nil child as %q", name) + } + n.mount.treeLock.Lock() + n.addChild(name, child) + n.mount.treeLock.Unlock() +} + +// TreeWatcher is an additional interface that Nodes can implement. +// If they do, the OnAdd and OnRemove are called for operations on the +// file system tree. These functions run under a lock, so they should +// not do blocking operations. +type TreeWatcher interface { + OnAdd(parent *Inode, name string) + OnRemove(parent *Inode, name string) +} + +// RmChild removes an inode by name, and returns it. It returns nil if +// child does not exist. +func (n *Inode) RmChild(name string) (ch *Inode) { + n.mount.treeLock.Lock() + ch = n.rmChild(name) + n.mount.treeLock.Unlock() + return +} + +////////////////////////////////////////////////////////////// +// private + +// addChild adds "child" to our children under name "name". +// Must be called with treeLock for the mount held. +func (n *Inode) addChild(name string, child *Inode) { + if paranoia { + ch := n.children[name] + if ch != nil { + log.Panicf("Already have an Inode with same name: %v: %v", name, ch) + } + } + n.children[name] = child + child.parents[parentData{n, name}] = struct{}{} + if w, ok := child.Node().(TreeWatcher); ok && child.mountPoint == nil { + w.OnAdd(n, name) + } +} + +// rmChild throws out child "name". This means (1) deleting "name" from our +// "children" map and (2) deleting ourself from the child's "parents" map. +// Must be called with treeLock for the mount held. +func (n *Inode) rmChild(name string) *Inode { + ch := n.children[name] + if ch != nil { + delete(n.children, name) + delete(ch.parents, parentData{n, name}) + if w, ok := ch.Node().(TreeWatcher); ok && ch.mountPoint == nil { + w.OnRemove(n, name) + } + } + return ch +} + +// Can only be called on untouched root inodes. +func (n *Inode) mountFs(opts *Options) { + n.mountPoint = &fileSystemMount{ + openFiles: newPortableHandleMap(), + mountInode: n, + options: opts, + } + n.mount = n.mountPoint +} + +// Must be called with treeLock held. +func (n *Inode) canUnmount() bool { + for _, v := range n.children { + if v.mountPoint != nil { + // This access may be out of date, but it is no + // problem to err on the safe side. + return false + } + if !v.canUnmount() { + return false + } + } + + n.openFilesMutex.Lock() + ok := len(n.openFiles) == 0 + n.openFilesMutex.Unlock() + return ok +} + +func (n *Inode) getMountDirEntries() (out []fuse.DirEntry) { + n.mount.treeLock.RLock() + for k, v := range n.children { + if v.mountPoint != nil { + out = append(out, fuse.DirEntry{ + Name: k, + Mode: fuse.S_IFDIR, + }) + } + } + n.mount.treeLock.RUnlock() + + return out +} + +const initDirSize = 20 + +func (n *Inode) verify(cur *fileSystemMount) { + n.handled.verify() + if n.mountPoint != nil { + if n != n.mountPoint.mountInode { + log.Panicf("mountpoint mismatch %v %v", n, n.mountPoint.mountInode) + } + cur = n.mountPoint + + cur.treeLock.Lock() + defer cur.treeLock.Unlock() + } + if n.mount != cur { + log.Panicf("n.mount not set correctly %v %v", n.mount, cur) + } + + for nm, ch := range n.children { + if ch == nil { + log.Panicf("Found nil child: %q", nm) + } + ch.verify(cur) + } +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go new file mode 100644 index 00000000..051188cf --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go @@ -0,0 +1,99 @@ +package nodefs + +import ( + "fmt" + "sync" + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +type lockingFile struct { + mu *sync.Mutex + file File +} + +// NewLockingFile serializes operations an existing File. +func NewLockingFile(mu *sync.Mutex, f File) File { + return &lockingFile{ + mu: mu, + file: f, + } +} + +func (f *lockingFile) SetInode(*Inode) { +} + +func (f *lockingFile) InnerFile() File { + return f.file +} + +func (f *lockingFile) String() string { + return fmt.Sprintf("lockingFile(%s)", f.file.String()) +} + +func (f *lockingFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Read(buf, off) +} + +func (f *lockingFile) Write(data []byte, off int64) (uint32, fuse.Status) { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Write(data, off) +} + +func (f *lockingFile) Flush() fuse.Status { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Flush() +} + +func (f *lockingFile) Release() { + f.mu.Lock() + defer f.mu.Unlock() + f.file.Release() +} + +func (f *lockingFile) GetAttr(a *fuse.Attr) fuse.Status { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.GetAttr(a) +} + +func (f *lockingFile) Fsync(flags int) (code fuse.Status) { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Fsync(flags) +} + +func (f *lockingFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Utimens(atime, mtime) +} + +func (f *lockingFile) Truncate(size uint64) fuse.Status { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Truncate(size) +} + +func (f *lockingFile) Chown(uid uint32, gid uint32) fuse.Status { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Chown(uid, gid) +} + +func (f *lockingFile) Chmod(perms uint32) fuse.Status { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Chmod(perms) +} + +func (f *lockingFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { + f.mu.Lock() + defer f.mu.Unlock() + return f.file.Allocate(off, size, mode) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go new file mode 100644 index 00000000..79f719f4 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go @@ -0,0 +1,228 @@ +package nodefs + +import ( + "fmt" + "os" + "sync" + "syscall" + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +// NewMemNodeFSRoot creates an in-memory node-based filesystem. Files +// are written into a backing store under the given prefix. +func NewMemNodeFSRoot(prefix string) Node { + fs := &memNodeFs{ + backingStorePrefix: prefix, + } + fs.root = fs.newNode() + return fs.root +} + +type memNodeFs struct { + backingStorePrefix string + root *memNode + + mutex sync.Mutex + nextFree int +} + +func (fs *memNodeFs) String() string { + return fmt.Sprintf("MemNodeFs(%s)", fs.backingStorePrefix) +} + +func (fs *memNodeFs) Root() Node { + return fs.root +} + +func (fs *memNodeFs) SetDebug(bool) { +} + +func (fs *memNodeFs) OnMount(*FileSystemConnector) { +} + +func (fs *memNodeFs) OnUnmount() { +} + +func (fs *memNodeFs) newNode() *memNode { + fs.mutex.Lock() + id := fs.nextFree + fs.nextFree++ + fs.mutex.Unlock() + n := &memNode{ + Node: NewDefaultNode(), + fs: fs, + id: id, + } + now := time.Now() + n.info.SetTimes(&now, &now, &now) + n.info.Mode = fuse.S_IFDIR | 0777 + return n +} + +func (fs *memNodeFs) Filename(n *Inode) string { + mn := n.Node().(*memNode) + return mn.filename() +} + +type memNode struct { + Node + fs *memNodeFs + id int + + link string + info fuse.Attr +} + +func (n *memNode) filename() string { + return fmt.Sprintf("%s%d", n.fs.backingStorePrefix, n.id) +} + +func (n *memNode) Deletable() bool { + return false +} + +func (n *memNode) Readlink(c *fuse.Context) ([]byte, fuse.Status) { + return []byte(n.link), fuse.OK +} + +func (n *memNode) StatFs() *fuse.StatfsOut { + return &fuse.StatfsOut{} +} + +func (n *memNode) Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) { + ch := n.fs.newNode() + ch.info.Mode = mode | fuse.S_IFDIR + n.Inode().NewChild(name, true, ch) + return ch.Inode(), fuse.OK +} + +func (n *memNode) Unlink(name string, context *fuse.Context) (code fuse.Status) { + ch := n.Inode().RmChild(name) + if ch == nil { + return fuse.ENOENT + } + return fuse.OK +} + +func (n *memNode) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + return n.Unlink(name, context) +} + +func (n *memNode) Symlink(name string, content string, context *fuse.Context) (newNode *Inode, code fuse.Status) { + ch := n.fs.newNode() + ch.info.Mode = fuse.S_IFLNK | 0777 + ch.link = content + n.Inode().NewChild(name, false, ch) + return ch.Inode(), fuse.OK +} + +func (n *memNode) Rename(oldName string, newParent Node, newName string, context *fuse.Context) (code fuse.Status) { + ch := n.Inode().RmChild(oldName) + newParent.Inode().RmChild(newName) + newParent.Inode().AddChild(newName, ch) + return fuse.OK +} + +func (n *memNode) Link(name string, existing Node, context *fuse.Context) (*Inode, fuse.Status) { + n.Inode().AddChild(name, existing.Inode()) + return existing.Inode(), fuse.OK +} + +func (n *memNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, node *Inode, code fuse.Status) { + ch := n.fs.newNode() + ch.info.Mode = mode | fuse.S_IFREG + + f, err := os.Create(ch.filename()) + if err != nil { + return nil, nil, fuse.ToStatus(err) + } + n.Inode().NewChild(name, false, ch) + return ch.newFile(f), ch.Inode(), fuse.OK +} + +type memNodeFile struct { + File + node *memNode +} + +func (n *memNodeFile) String() string { + return fmt.Sprintf("memNodeFile(%s)", n.File.String()) +} + +func (n *memNodeFile) InnerFile() File { + return n.File +} + +func (n *memNodeFile) Flush() fuse.Status { + code := n.File.Flush() + + if !code.Ok() { + return code + } + + st := syscall.Stat_t{} + err := syscall.Stat(n.node.filename(), &st) + n.node.info.Size = uint64(st.Size) + n.node.info.Blocks = uint64(st.Blocks) + return fuse.ToStatus(err) +} + +func (n *memNode) newFile(f *os.File) File { + return &memNodeFile{ + File: NewLoopbackFile(f), + node: n, + } +} + +func (n *memNode) Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) { + f, err := os.OpenFile(n.filename(), int(flags), 0666) + if err != nil { + return nil, fuse.ToStatus(err) + } + + return n.newFile(f), fuse.OK +} + +func (n *memNode) GetAttr(fi *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) { + *fi = n.info + return fuse.OK +} + +func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) { + if file != nil { + code = file.Truncate(size) + } else { + err := os.Truncate(n.filename(), int64(size)) + code = fuse.ToStatus(err) + } + if code.Ok() { + now := time.Now() + n.info.SetTimes(nil, nil, &now) + // TODO - should update mtime too? + n.info.Size = size + } + return code +} + +func (n *memNode) Utimens(file File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) { + c := time.Now() + n.info.SetTimes(atime, mtime, &c) + return fuse.OK +} + +func (n *memNode) Chmod(file File, perms uint32, context *fuse.Context) (code fuse.Status) { + n.info.Mode = (n.info.Mode &^ 07777) | perms + now := time.Now() + n.info.SetTimes(nil, nil, &now) + return fuse.OK +} + +func (n *memNode) Chown(file File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + n.info.Uid = uid + n.info.Gid = gid + now := time.Now() + n.info.SetTimes(nil, nil, &now) + return fuse.OK +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go new file mode 100644 index 00000000..dfadb418 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go @@ -0,0 +1,9 @@ +package nodefs + +import "time" + +func splitDuration(dt time.Duration, secs *uint64, nsecs *uint32) { + ns := int64(dt) + *nsecs = uint32(ns % 1e9) + *secs = uint64(ns / 1e9) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go new file mode 100644 index 00000000..46f37e89 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go @@ -0,0 +1,14 @@ +package nodefs + +import ( + "fmt" + + "github.com/hanwen/go-fuse/fuse" +) + +// String provides a debug string for the given file. +func (f *WithFlags) String() string { + return fmt.Sprintf("File %s (%s) %s %s", + f.File, f.Description, fuse.FlagString(fuse.OpenFlagNames, int64(f.OpenFlags), "O_RDONLY"), + fuse.FlagString(fuse.FuseOpenFlagNames, int64(f.FuseFlags), "")) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go new file mode 100644 index 00000000..c2cca285 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go @@ -0,0 +1,16 @@ +package nodefs + +import ( + "syscall" + "unsafe" +) + +// futimens - futimens(3) calls utimensat(2) with "pathname" set to null and +// "flags" set to zero +func futimens(fd int, times *[2]syscall.Timespec) (err error) { + _, _, e1 := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(fd), 0, uintptr(unsafe.Pointer(times)), uintptr(0), 0, 0) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/opcode.go b/vendor/github.com/hanwen/go-fuse/fuse/opcode.go new file mode 100644 index 00000000..d24730b6 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/opcode.go @@ -0,0 +1,642 @@ +package fuse + +import ( + "bytes" + "log" + "reflect" + "runtime" + "unsafe" +) + +const ( + _OP_LOOKUP = int32(1) + _OP_FORGET = int32(2) + _OP_GETATTR = int32(3) + _OP_SETATTR = int32(4) + _OP_READLINK = int32(5) + _OP_SYMLINK = int32(6) + _OP_MKNOD = int32(8) + _OP_MKDIR = int32(9) + _OP_UNLINK = int32(10) + _OP_RMDIR = int32(11) + _OP_RENAME = int32(12) + _OP_LINK = int32(13) + _OP_OPEN = int32(14) + _OP_READ = int32(15) + _OP_WRITE = int32(16) + _OP_STATFS = int32(17) + _OP_RELEASE = int32(18) + _OP_FSYNC = int32(20) + _OP_SETXATTR = int32(21) + _OP_GETXATTR = int32(22) + _OP_LISTXATTR = int32(23) + _OP_REMOVEXATTR = int32(24) + _OP_FLUSH = int32(25) + _OP_INIT = int32(26) + _OP_OPENDIR = int32(27) + _OP_READDIR = int32(28) + _OP_RELEASEDIR = int32(29) + _OP_FSYNCDIR = int32(30) + _OP_GETLK = int32(31) + _OP_SETLK = int32(32) + _OP_SETLKW = int32(33) + _OP_ACCESS = int32(34) + _OP_CREATE = int32(35) + _OP_INTERRUPT = int32(36) + _OP_BMAP = int32(37) + _OP_DESTROY = int32(38) + _OP_IOCTL = int32(39) + _OP_POLL = int32(40) + _OP_NOTIFY_REPLY = int32(41) + _OP_BATCH_FORGET = int32(42) + _OP_FALLOCATE = int32(43) // protocol version 19. + _OP_READDIRPLUS = int32(44) // protocol version 21. + _OP_FUSE_RENAME2 = int32(45) // protocol version 23. + + // The following entries don't have to be compatible across Go-FUSE versions. + _OP_NOTIFY_ENTRY = int32(100) + _OP_NOTIFY_INODE = int32(101) + _OP_NOTIFY_DELETE = int32(102) // protocol version 18 + + _OPCODE_COUNT = int32(103) +) + +//////////////////////////////////////////////////////////////// + +func doInit(server *Server, req *request) { + input := (*InitIn)(req.inData) + if input.Major != _FUSE_KERNEL_VERSION { + log.Printf("Major versions does not match. Given %d, want %d\n", input.Major, _FUSE_KERNEL_VERSION) + req.status = EIO + return + } + if input.Minor < _MINIMUM_MINOR_VERSION { + log.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, _MINIMUM_MINOR_VERSION) + req.status = EIO + return + } + + server.reqMu.Lock() + server.kernelSettings = *input + server.kernelSettings.Flags = input.Flags & (CAP_ASYNC_READ | CAP_BIG_WRITES | CAP_FILE_OPS | + CAP_AUTO_INVAL_DATA | CAP_READDIRPLUS | CAP_NO_OPEN_SUPPORT) + + if input.Minor >= 13 { + server.setSplice() + } + server.reqMu.Unlock() + + out := &InitOut{ + Major: _FUSE_KERNEL_VERSION, + Minor: _OUR_MINOR_VERSION, + MaxReadAhead: input.MaxReadAhead, + Flags: server.kernelSettings.Flags, + MaxWrite: uint32(server.opts.MaxWrite), + CongestionThreshold: uint16(server.opts.MaxBackground * 3 / 4), + MaxBackground: uint16(server.opts.MaxBackground), + } + if out.Minor > input.Minor { + out.Minor = input.Minor + } + + if out.Minor <= 22 { + tweaked := *req.handler + + // v8-v22 don't have TimeGran and further fields. + tweaked.OutputSize = 24 + req.handler = &tweaked + } + + req.outData = unsafe.Pointer(out) + req.status = OK +} + +func doOpen(server *Server, req *request) { + out := (*OpenOut)(req.outData) + status := server.fileSystem.Open((*OpenIn)(req.inData), out) + req.status = status + if status != OK { + return + } +} + +func doCreate(server *Server, req *request) { + out := (*CreateOut)(req.outData) + status := server.fileSystem.Create((*CreateIn)(req.inData), req.filenames[0], out) + req.status = status +} + +func doReadDir(server *Server, req *request) { + in := (*ReadIn)(req.inData) + buf := server.allocOut(req, in.Size) + out := NewDirEntryList(buf, uint64(in.Offset)) + + code := server.fileSystem.ReadDir(in, out) + req.flatData = out.bytes() + req.status = code +} + +func doReadDirPlus(server *Server, req *request) { + in := (*ReadIn)(req.inData) + buf := server.allocOut(req, in.Size) + out := NewDirEntryList(buf, uint64(in.Offset)) + + code := server.fileSystem.ReadDirPlus(in, out) + req.flatData = out.bytes() + req.status = code +} + +func doOpenDir(server *Server, req *request) { + out := (*OpenOut)(req.outData) + status := server.fileSystem.OpenDir((*OpenIn)(req.inData), out) + req.status = status +} + +func doSetattr(server *Server, req *request) { + out := (*AttrOut)(req.outData) + req.status = server.fileSystem.SetAttr((*SetAttrIn)(req.inData), out) +} + +func doWrite(server *Server, req *request) { + n, status := server.fileSystem.Write((*WriteIn)(req.inData), req.arg) + o := (*WriteOut)(req.outData) + o.Size = n + req.status = status +} + +const _SECURITY_CAPABILITY = "security.capability" +const _SECURITY_ACL = "system.posix_acl_access" +const _SECURITY_ACL_DEFAULT = "system.posix_acl_default" + +func doGetXAttr(server *Server, req *request) { + if server.opts.IgnoreSecurityLabels && req.inHeader.Opcode == _OP_GETXATTR { + fn := req.filenames[0] + if fn == _SECURITY_CAPABILITY || fn == _SECURITY_ACL_DEFAULT || + fn == _SECURITY_ACL { + req.status = ENODATA + return + } + } + + input := (*GetXAttrIn)(req.inData) + + if input.Size == 0 { + out := (*GetXAttrOut)(req.outData) + switch req.inHeader.Opcode { + case _OP_GETXATTR: + sz, code := server.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0]) + if code.Ok() { + out.Size = uint32(sz) + } + req.status = code + return + case _OP_LISTXATTR: + data, code := server.fileSystem.ListXAttr(req.inHeader) + if code.Ok() { + out.Size = uint32(len(data)) + } + req.status = code + return + } + } + + req.outData = nil + var data []byte + switch req.inHeader.Opcode { + case _OP_GETXATTR: + data, req.status = server.fileSystem.GetXAttrData(req.inHeader, req.filenames[0]) + case _OP_LISTXATTR: + data, req.status = server.fileSystem.ListXAttr(req.inHeader) + default: + log.Panicf("xattr opcode %v", req.inHeader.Opcode) + req.status = ENOSYS + } + + if len(data) > int(input.Size) { + req.status = ERANGE + } + + if !req.status.Ok() { + return + } + + req.flatData = data +} + +func doGetAttr(server *Server, req *request) { + out := (*AttrOut)(req.outData) + s := server.fileSystem.GetAttr((*GetAttrIn)(req.inData), out) + req.status = s +} + +// doForget - forget one NodeId +func doForget(server *Server, req *request) { + if !server.opts.RememberInodes { + server.fileSystem.Forget(req.inHeader.NodeId, (*ForgetIn)(req.inData).Nlookup) + } +} + +// doBatchForget - forget a list of NodeIds +func doBatchForget(server *Server, req *request) { + in := (*_BatchForgetIn)(req.inData) + wantBytes := uintptr(in.Count) * unsafe.Sizeof(_ForgetOne{}) + if uintptr(len(req.arg)) < wantBytes { + // We have no return value to complain, so log an error. + log.Printf("Too few bytes for batch forget. Got %d bytes, want %d (%d entries)", + len(req.arg), wantBytes, in.Count) + } + + h := &reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(&req.arg[0])), + Len: int(in.Count), + Cap: int(in.Count), + } + + forgets := *(*[]_ForgetOne)(unsafe.Pointer(h)) + for i, f := range forgets { + if server.debug { + log.Printf("doBatchForget: forgetting %d of %d: NodeId: %d, Nlookup: %d", i+1, len(forgets), f.NodeId, f.Nlookup) + } + server.fileSystem.Forget(f.NodeId, f.Nlookup) + } +} + +func doReadlink(server *Server, req *request) { + req.flatData, req.status = server.fileSystem.Readlink(req.inHeader) +} + +func doLookup(server *Server, req *request) { + out := (*EntryOut)(req.outData) + s := server.fileSystem.Lookup(req.inHeader, req.filenames[0], out) + req.status = s + req.outData = unsafe.Pointer(out) +} + +func doMknod(server *Server, req *request) { + out := (*EntryOut)(req.outData) + + req.status = server.fileSystem.Mknod((*MknodIn)(req.inData), req.filenames[0], out) +} + +func doMkdir(server *Server, req *request) { + out := (*EntryOut)(req.outData) + req.status = server.fileSystem.Mkdir((*MkdirIn)(req.inData), req.filenames[0], out) +} + +func doUnlink(server *Server, req *request) { + req.status = server.fileSystem.Unlink(req.inHeader, req.filenames[0]) +} + +func doRmdir(server *Server, req *request) { + req.status = server.fileSystem.Rmdir(req.inHeader, req.filenames[0]) +} + +func doLink(server *Server, req *request) { + out := (*EntryOut)(req.outData) + req.status = server.fileSystem.Link((*LinkIn)(req.inData), req.filenames[0], out) +} + +func doRead(server *Server, req *request) { + in := (*ReadIn)(req.inData) + buf := server.allocOut(req, in.Size) + + req.readResult, req.status = server.fileSystem.Read(in, buf) + if fd, ok := req.readResult.(*readResultFd); ok { + req.fdData = fd + req.flatData = nil + } else if req.readResult != nil && req.status.Ok() { + req.flatData, req.status = req.readResult.Bytes(buf) + } +} + +func doFlush(server *Server, req *request) { + req.status = server.fileSystem.Flush((*FlushIn)(req.inData)) +} + +func doRelease(server *Server, req *request) { + server.fileSystem.Release((*ReleaseIn)(req.inData)) +} + +func doFsync(server *Server, req *request) { + req.status = server.fileSystem.Fsync((*FsyncIn)(req.inData)) +} + +func doReleaseDir(server *Server, req *request) { + server.fileSystem.ReleaseDir((*ReleaseIn)(req.inData)) +} + +func doFsyncDir(server *Server, req *request) { + req.status = server.fileSystem.FsyncDir((*FsyncIn)(req.inData)) +} + +func doSetXAttr(server *Server, req *request) { + splits := bytes.SplitN(req.arg, []byte{0}, 2) + req.status = server.fileSystem.SetXAttr((*SetXAttrIn)(req.inData), string(splits[0]), splits[1]) +} + +func doRemoveXAttr(server *Server, req *request) { + req.status = server.fileSystem.RemoveXAttr(req.inHeader, req.filenames[0]) +} + +func doAccess(server *Server, req *request) { + req.status = server.fileSystem.Access((*AccessIn)(req.inData)) +} + +func doSymlink(server *Server, req *request) { + out := (*EntryOut)(req.outData) + req.status = server.fileSystem.Symlink(req.inHeader, req.filenames[1], req.filenames[0], out) +} + +func doRename(server *Server, req *request) { + req.status = server.fileSystem.Rename((*RenameIn)(req.inData), req.filenames[0], req.filenames[1]) +} + +func doStatFs(server *Server, req *request) { + out := (*StatfsOut)(req.outData) + req.status = server.fileSystem.StatFs(req.inHeader, out) + if req.status == ENOSYS && runtime.GOOS == "darwin" { + // OSX FUSE requires Statfs to be implemented for the + // mount to succeed. + *out = StatfsOut{} + req.status = OK + } +} + +func doIoctl(server *Server, req *request) { + req.status = ENOSYS +} + +func doDestroy(server *Server, req *request) { + req.status = OK +} + +func doFallocate(server *Server, req *request) { + req.status = server.fileSystem.Fallocate((*FallocateIn)(req.inData)) +} + +//////////////////////////////////////////////////////////////// + +type operationFunc func(*Server, *request) +type castPointerFunc func(unsafe.Pointer) interface{} + +type operationHandler struct { + Name string + Func operationFunc + InputSize uintptr + OutputSize uintptr + DecodeIn castPointerFunc + DecodeOut castPointerFunc + FileNames int + FileNameOut bool +} + +var operationHandlers []*operationHandler + +func operationName(op int32) string { + h := getHandler(op) + if h == nil { + return "unknown" + } + return h.Name +} + +func getHandler(o int32) *operationHandler { + if o >= _OPCODE_COUNT { + return nil + } + return operationHandlers[o] +} + +func init() { + operationHandlers = make([]*operationHandler, _OPCODE_COUNT) + for i := range operationHandlers { + operationHandlers[i] = &operationHandler{Name: "UNKNOWN"} + } + + fileOps := []int32{_OP_READLINK, _OP_NOTIFY_ENTRY, _OP_NOTIFY_DELETE} + for _, op := range fileOps { + operationHandlers[op].FileNameOut = true + } + + for op, sz := range map[int32]uintptr{ + _OP_FORGET: unsafe.Sizeof(ForgetIn{}), + _OP_BATCH_FORGET: unsafe.Sizeof(_BatchForgetIn{}), + _OP_GETATTR: unsafe.Sizeof(GetAttrIn{}), + _OP_SETATTR: unsafe.Sizeof(SetAttrIn{}), + _OP_MKNOD: unsafe.Sizeof(MknodIn{}), + _OP_MKDIR: unsafe.Sizeof(MkdirIn{}), + _OP_RENAME: unsafe.Sizeof(RenameIn{}), + _OP_LINK: unsafe.Sizeof(LinkIn{}), + _OP_OPEN: unsafe.Sizeof(OpenIn{}), + _OP_READ: unsafe.Sizeof(ReadIn{}), + _OP_WRITE: unsafe.Sizeof(WriteIn{}), + _OP_RELEASE: unsafe.Sizeof(ReleaseIn{}), + _OP_FSYNC: unsafe.Sizeof(FsyncIn{}), + _OP_SETXATTR: unsafe.Sizeof(SetXAttrIn{}), + _OP_GETXATTR: unsafe.Sizeof(GetXAttrIn{}), + _OP_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}), + _OP_FLUSH: unsafe.Sizeof(FlushIn{}), + _OP_INIT: unsafe.Sizeof(InitIn{}), + _OP_OPENDIR: unsafe.Sizeof(OpenIn{}), + _OP_READDIR: unsafe.Sizeof(ReadIn{}), + _OP_RELEASEDIR: unsafe.Sizeof(ReleaseIn{}), + _OP_FSYNCDIR: unsafe.Sizeof(FsyncIn{}), + _OP_ACCESS: unsafe.Sizeof(AccessIn{}), + _OP_CREATE: unsafe.Sizeof(CreateIn{}), + _OP_INTERRUPT: unsafe.Sizeof(InterruptIn{}), + _OP_BMAP: unsafe.Sizeof(_BmapIn{}), + _OP_IOCTL: unsafe.Sizeof(_IoctlIn{}), + _OP_POLL: unsafe.Sizeof(_PollIn{}), + _OP_FALLOCATE: unsafe.Sizeof(FallocateIn{}), + _OP_READDIRPLUS: unsafe.Sizeof(ReadIn{}), + } { + operationHandlers[op].InputSize = sz + } + + for op, sz := range map[int32]uintptr{ + _OP_LOOKUP: unsafe.Sizeof(EntryOut{}), + _OP_GETATTR: unsafe.Sizeof(AttrOut{}), + _OP_SETATTR: unsafe.Sizeof(AttrOut{}), + _OP_SYMLINK: unsafe.Sizeof(EntryOut{}), + _OP_MKNOD: unsafe.Sizeof(EntryOut{}), + _OP_MKDIR: unsafe.Sizeof(EntryOut{}), + _OP_LINK: unsafe.Sizeof(EntryOut{}), + _OP_OPEN: unsafe.Sizeof(OpenOut{}), + _OP_WRITE: unsafe.Sizeof(WriteOut{}), + _OP_STATFS: unsafe.Sizeof(StatfsOut{}), + _OP_GETXATTR: unsafe.Sizeof(GetXAttrOut{}), + _OP_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}), + _OP_INIT: unsafe.Sizeof(InitOut{}), + _OP_OPENDIR: unsafe.Sizeof(OpenOut{}), + _OP_CREATE: unsafe.Sizeof(CreateOut{}), + _OP_BMAP: unsafe.Sizeof(_BmapOut{}), + _OP_IOCTL: unsafe.Sizeof(_IoctlOut{}), + _OP_POLL: unsafe.Sizeof(_PollOut{}), + _OP_NOTIFY_ENTRY: unsafe.Sizeof(NotifyInvalEntryOut{}), + _OP_NOTIFY_INODE: unsafe.Sizeof(NotifyInvalInodeOut{}), + _OP_NOTIFY_DELETE: unsafe.Sizeof(NotifyInvalDeleteOut{}), + } { + operationHandlers[op].OutputSize = sz + } + + for op, v := range map[int32]string{ + _OP_LOOKUP: "LOOKUP", + _OP_FORGET: "FORGET", + _OP_BATCH_FORGET: "BATCH_FORGET", + _OP_GETATTR: "GETATTR", + _OP_SETATTR: "SETATTR", + _OP_READLINK: "READLINK", + _OP_SYMLINK: "SYMLINK", + _OP_MKNOD: "MKNOD", + _OP_MKDIR: "MKDIR", + _OP_UNLINK: "UNLINK", + _OP_RMDIR: "RMDIR", + _OP_RENAME: "RENAME", + _OP_LINK: "LINK", + _OP_OPEN: "OPEN", + _OP_READ: "READ", + _OP_WRITE: "WRITE", + _OP_STATFS: "STATFS", + _OP_RELEASE: "RELEASE", + _OP_FSYNC: "FSYNC", + _OP_SETXATTR: "SETXATTR", + _OP_GETXATTR: "GETXATTR", + _OP_LISTXATTR: "LISTXATTR", + _OP_REMOVEXATTR: "REMOVEXATTR", + _OP_FLUSH: "FLUSH", + _OP_INIT: "INIT", + _OP_OPENDIR: "OPENDIR", + _OP_READDIR: "READDIR", + _OP_RELEASEDIR: "RELEASEDIR", + _OP_FSYNCDIR: "FSYNCDIR", + _OP_GETLK: "GETLK", + _OP_SETLK: "SETLK", + _OP_SETLKW: "SETLKW", + _OP_ACCESS: "ACCESS", + _OP_CREATE: "CREATE", + _OP_INTERRUPT: "INTERRUPT", + _OP_BMAP: "BMAP", + _OP_DESTROY: "DESTROY", + _OP_IOCTL: "IOCTL", + _OP_POLL: "POLL", + _OP_NOTIFY_ENTRY: "NOTIFY_ENTRY", + _OP_NOTIFY_INODE: "NOTIFY_INODE", + _OP_NOTIFY_DELETE: "NOTIFY_DELETE", + _OP_FALLOCATE: "FALLOCATE", + _OP_READDIRPLUS: "READDIRPLUS", + } { + operationHandlers[op].Name = v + } + + for op, v := range map[int32]operationFunc{ + _OP_OPEN: doOpen, + _OP_READDIR: doReadDir, + _OP_WRITE: doWrite, + _OP_OPENDIR: doOpenDir, + _OP_CREATE: doCreate, + _OP_SETATTR: doSetattr, + _OP_GETXATTR: doGetXAttr, + _OP_LISTXATTR: doGetXAttr, + _OP_GETATTR: doGetAttr, + _OP_FORGET: doForget, + _OP_BATCH_FORGET: doBatchForget, + _OP_READLINK: doReadlink, + _OP_INIT: doInit, + _OP_LOOKUP: doLookup, + _OP_MKNOD: doMknod, + _OP_MKDIR: doMkdir, + _OP_UNLINK: doUnlink, + _OP_RMDIR: doRmdir, + _OP_LINK: doLink, + _OP_READ: doRead, + _OP_FLUSH: doFlush, + _OP_RELEASE: doRelease, + _OP_FSYNC: doFsync, + _OP_RELEASEDIR: doReleaseDir, + _OP_FSYNCDIR: doFsyncDir, + _OP_SETXATTR: doSetXAttr, + _OP_REMOVEXATTR: doRemoveXAttr, + _OP_ACCESS: doAccess, + _OP_SYMLINK: doSymlink, + _OP_RENAME: doRename, + _OP_STATFS: doStatFs, + _OP_IOCTL: doIoctl, + _OP_DESTROY: doDestroy, + _OP_FALLOCATE: doFallocate, + _OP_READDIRPLUS: doReadDirPlus, + } { + operationHandlers[op].Func = v + } + + // Outputs. + for op, f := range map[int32]castPointerFunc{ + _OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, + _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*OpenOut)(ptr) }, + _OP_OPENDIR: func(ptr unsafe.Pointer) interface{} { return (*OpenOut)(ptr) }, + _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, + _OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateOut)(ptr) }, + _OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, + _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, + _OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitOut)(ptr) }, + _OP_MKDIR: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, + _OP_NOTIFY_ENTRY: func(ptr unsafe.Pointer) interface{} { return (*NotifyInvalEntryOut)(ptr) }, + _OP_NOTIFY_INODE: func(ptr unsafe.Pointer) interface{} { return (*NotifyInvalInodeOut)(ptr) }, + _OP_NOTIFY_DELETE: func(ptr unsafe.Pointer) interface{} { return (*NotifyInvalDeleteOut)(ptr) }, + _OP_STATFS: func(ptr unsafe.Pointer) interface{} { return (*StatfsOut)(ptr) }, + } { + operationHandlers[op].DecodeOut = f + } + + // Inputs. + for op, f := range map[int32]castPointerFunc{ + _OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*FlushIn)(ptr) }, + _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*GetAttrIn)(ptr) }, + _OP_GETXATTR: func(ptr unsafe.Pointer) interface{} { return (*GetXAttrIn)(ptr) }, + _OP_LISTXATTR: func(ptr unsafe.Pointer) interface{} { return (*GetXAttrIn)(ptr) }, + _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*SetAttrIn)(ptr) }, + _OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitIn)(ptr) }, + _OP_IOCTL: func(ptr unsafe.Pointer) interface{} { return (*_IoctlIn)(ptr) }, + _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*OpenIn)(ptr) }, + _OP_MKNOD: func(ptr unsafe.Pointer) interface{} { return (*MknodIn)(ptr) }, + _OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateIn)(ptr) }, + _OP_READ: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, + _OP_READDIR: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, + _OP_ACCESS: func(ptr unsafe.Pointer) interface{} { return (*AccessIn)(ptr) }, + _OP_FORGET: func(ptr unsafe.Pointer) interface{} { return (*ForgetIn)(ptr) }, + _OP_BATCH_FORGET: func(ptr unsafe.Pointer) interface{} { return (*_BatchForgetIn)(ptr) }, + _OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*LinkIn)(ptr) }, + _OP_MKDIR: func(ptr unsafe.Pointer) interface{} { return (*MkdirIn)(ptr) }, + _OP_RELEASE: func(ptr unsafe.Pointer) interface{} { return (*ReleaseIn)(ptr) }, + _OP_RELEASEDIR: func(ptr unsafe.Pointer) interface{} { return (*ReleaseIn)(ptr) }, + _OP_FALLOCATE: func(ptr unsafe.Pointer) interface{} { return (*FallocateIn)(ptr) }, + _OP_READDIRPLUS: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, + _OP_RENAME: func(ptr unsafe.Pointer) interface{} { return (*RenameIn)(ptr) }, + } { + operationHandlers[op].DecodeIn = f + } + + // File name args. + for op, count := range map[int32]int{ + _OP_CREATE: 1, + _OP_GETXATTR: 1, + _OP_LINK: 1, + _OP_LOOKUP: 1, + _OP_MKDIR: 1, + _OP_MKNOD: 1, + _OP_REMOVEXATTR: 1, + _OP_RENAME: 2, + _OP_RMDIR: 1, + _OP_SYMLINK: 2, + _OP_UNLINK: 1, + } { + operationHandlers[op].FileNames = count + } + + var r request + sizeOfOutHeader := unsafe.Sizeof(OutHeader{}) + for code, h := range operationHandlers { + if h.OutputSize+sizeOfOutHeader > unsafe.Sizeof(r.outBuf) { + log.Panicf("request output buffer too small: code %v, sz %d + %d %v", code, h.OutputSize, sizeOfOutHeader, h) + } + } +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go new file mode 100644 index 00000000..56184ba6 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go @@ -0,0 +1,78 @@ +package pathfs + +import ( + "time" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +// A filesystem API that uses paths rather than inodes. A minimal +// file system should have at least a functional GetAttr method. +// Typically, each call happens in its own goroutine, so take care to +// make the file system thread-safe. +// +// NewDefaultFileSystem provides a null implementation of required +// methods. +type FileSystem interface { + // Used for pretty printing. + String() string + + // If called, provide debug output through the log package. + SetDebug(debug bool) + + // Attributes. This function is the main entry point, through + // which FUSE discovers which files and directories exist. + // + // If the filesystem wants to implement hard-links, it should + // return consistent non-zero FileInfo.Ino data. Using + // hardlinks incurs a performance hit. + GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) + + // These should update the file's ctime too. + Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) + Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) + Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) + + Truncate(name string, size uint64, context *fuse.Context) (code fuse.Status) + + Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) + + // Tree structure + Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) + Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status + Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status + Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) + Rmdir(name string, context *fuse.Context) (code fuse.Status) + Unlink(name string, context *fuse.Context) (code fuse.Status) + + // Extended attributes. + GetXAttr(name string, attribute string, context *fuse.Context) (data []byte, code fuse.Status) + ListXAttr(name string, context *fuse.Context) (attributes []string, code fuse.Status) + RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status + SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status + + // Called after mount. + OnMount(nodeFs *PathNodeFs) + OnUnmount() + + // File handling. If opening for writing, the file's mtime + // should be updated too. + Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) + Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) + + // Directory handling + OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, code fuse.Status) + + // Symlinks. + Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) + Readlink(name string, context *fuse.Context) (string, fuse.Status) + + StatFs(name string) *fuse.StatfsOut +} + +type PathNodeFsOptions struct { + // If ClientInodes is set, use Inode returned from GetAttr to + // find hard-linked files. + ClientInodes bool +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go new file mode 100644 index 00000000..3897fee4 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go @@ -0,0 +1,57 @@ +package pathfs + +import ( + "os" + + "github.com/hanwen/go-fuse/fuse" +) + +func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.Context) fuse.Status { + src, code := srcFs.Open(srcFile, uint32(os.O_RDONLY), context) + if !code.Ok() { + return code + } + defer src.Release() + defer src.Flush() + + attr, code := srcFs.GetAttr(srcFile, context) + if !code.Ok() { + return code + } + + dst, code := destFs.Create(destFile, uint32(os.O_WRONLY|os.O_CREATE|os.O_TRUNC), attr.Mode, context) + if !code.Ok() { + return code + } + defer dst.Release() + defer dst.Flush() + + buf := make([]byte, 128*(1<<10)) + off := int64(0) + for { + res, code := src.Read(buf, off) + if !code.Ok() { + return code + } + data, code := res.Bytes(buf) + if !code.Ok() { + return code + } + + if len(data) == 0 { + break + } + n, code := dst.Write(data, off) + if !code.Ok() { + return code + } + if int(n) < len(data) { + return fuse.EIO + } + if len(data) < len(buf) { + break + } + off += int64(len(data)) + } + return fuse.OK +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go new file mode 100644 index 00000000..62e11893 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go @@ -0,0 +1,118 @@ +package pathfs + +import ( + "time" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +// NewDefaultFileSystem creates a filesystem that responds ENOSYS for +// all methods +func NewDefaultFileSystem() FileSystem { + return (*defaultFileSystem)(nil) +} + +// defaultFileSystem implements a FileSystem that returns ENOSYS for every operation. +type defaultFileSystem struct{} + +func (fs *defaultFileSystem) SetDebug(debug bool) {} + +// defaultFileSystem +func (fs *defaultFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + return nil, fuse.ENOSYS +} + +func (fs *defaultFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { + return nil, fuse.ENOSYS +} + +func (fs *defaultFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { + return nil, fuse.ENOSYS +} + +func (fs *defaultFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { + return "", fuse.ENOSYS +} + +func (fs *defaultFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (fs *defaultFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { + return nil, fuse.ENOSYS +} + +func (fs *defaultFileSystem) OnMount(nodeFs *PathNodeFs) { +} + +func (fs *defaultFileSystem) OnUnmount() { +} + +func (fs *defaultFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + return nil, fuse.ENOSYS +} + +func (fs *defaultFileSystem) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) { + return fuse.ENOSYS +} + +func (fs *defaultFileSystem) String() string { + return "defaultFileSystem" +} + +func (fs *defaultFileSystem) StatFs(name string) *fuse.StatfsOut { + return nil +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go new file mode 100644 index 00000000..93bef52f --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go @@ -0,0 +1,163 @@ +package pathfs + +import ( + "sync" + "time" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +type lockingFileSystem struct { + // Should be public so people reusing can access the wrapped + // FS. + FS FileSystem + lock sync.Mutex +} + +// NewLockingFileSystem is a wrapper that makes a FileSystem +// threadsafe by serializing each operation. +func NewLockingFileSystem(pfs FileSystem) FileSystem { + l := new(lockingFileSystem) + l.FS = pfs + return l +} + +func (fs *lockingFileSystem) String() string { + defer fs.locked()() + return fs.FS.String() +} + +func (fs *lockingFileSystem) SetDebug(debug bool) { + defer fs.locked()() + fs.FS.SetDebug(debug) +} + +func (fs *lockingFileSystem) StatFs(name string) *fuse.StatfsOut { + defer fs.locked()() + return fs.FS.StatFs(name) +} + +func (fs *lockingFileSystem) locked() func() { + fs.lock.Lock() + return func() { fs.lock.Unlock() } +} + +func (fs *lockingFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + defer fs.locked()() + return fs.FS.GetAttr(name, context) +} + +func (fs *lockingFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { + defer fs.locked()() + return fs.FS.Readlink(name, context) +} + +func (fs *lockingFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { + defer fs.locked()() + return fs.FS.Mknod(name, mode, dev, context) +} + +func (fs *lockingFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { + defer fs.locked()() + return fs.FS.Mkdir(name, mode, context) +} + +func (fs *lockingFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Unlink(name, context) +} + +func (fs *lockingFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Rmdir(name, context) +} + +func (fs *lockingFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Symlink(value, linkName, context) +} + +func (fs *lockingFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Rename(oldName, newName, context) +} + +func (fs *lockingFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Link(oldName, newName, context) +} + +func (fs *lockingFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Chmod(name, mode, context) +} + +func (fs *lockingFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Chown(name, uid, gid, context) +} + +func (fs *lockingFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Truncate(name, offset, context) +} + +func (fs *lockingFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + file, code = fs.FS.Open(name, flags, context) + file = nodefs.NewLockingFile(&fs.lock, file) + return +} + +func (fs *lockingFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { + defer fs.locked()() + return fs.FS.OpenDir(name, context) +} + +func (fs *lockingFileSystem) OnMount(nodeFs *PathNodeFs) { + defer fs.locked()() + fs.FS.OnMount(nodeFs) +} + +func (fs *lockingFileSystem) OnUnmount() { + defer fs.locked()() + fs.FS.OnUnmount() +} + +func (fs *lockingFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Access(name, mode, context) +} + +func (fs *lockingFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + defer fs.locked()() + file, code = fs.FS.Create(name, flags, mode, context) + + file = nodefs.NewLockingFile(&fs.lock, file) + return file, code +} + +func (fs *lockingFileSystem) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) { + defer fs.locked()() + return fs.FS.Utimens(name, Atime, Mtime, context) +} + +func (fs *lockingFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { + defer fs.locked()() + return fs.FS.GetXAttr(name, attr, context) +} + +func (fs *lockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + defer fs.locked()() + return fs.FS.SetXAttr(name, attr, data, flags, context) +} + +func (fs *lockingFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { + defer fs.locked()() + return fs.FS.ListXAttr(name, context) +} + +func (fs *lockingFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { + defer fs.locked()() + return fs.FS.RemoveXAttr(name, attr, context) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go new file mode 100644 index 00000000..68fd9f13 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go @@ -0,0 +1,162 @@ +package pathfs + +import ( + "io" + "log" + "os" + "path/filepath" + "syscall" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +type loopbackFileSystem struct { + // TODO - this should need default fill in. + FileSystem + Root string +} + +// A FUSE filesystem that shunts all request to an underlying file +// system. Its main purpose is to provide test coverage without +// having to build a synthetic filesystem. +func NewLoopbackFileSystem(root string) FileSystem { + return &loopbackFileSystem{ + FileSystem: NewDefaultFileSystem(), + Root: root, + } +} + +func (fs *loopbackFileSystem) OnMount(nodeFs *PathNodeFs) { +} + +func (fs *loopbackFileSystem) OnUnmount() {} + +func (fs *loopbackFileSystem) GetPath(relPath string) string { + return filepath.Join(fs.Root, relPath) +} + +func (fs *loopbackFileSystem) GetAttr(name string, context *fuse.Context) (a *fuse.Attr, code fuse.Status) { + fullPath := fs.GetPath(name) + var err error = nil + st := syscall.Stat_t{} + if name == "" { + // When GetAttr is called for the toplevel directory, we always want + // to look through symlinks. + err = syscall.Stat(fullPath, &st) + } else { + err = syscall.Lstat(fullPath, &st) + } + + if err != nil { + return nil, fuse.ToStatus(err) + } + a = &fuse.Attr{} + a.FromStat(&st) + return a, fuse.OK +} + +func (fs *loopbackFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { + // What other ways beyond O_RDONLY are there to open + // directories? + f, err := os.Open(fs.GetPath(name)) + if err != nil { + return nil, fuse.ToStatus(err) + } + want := 500 + output := make([]fuse.DirEntry, 0, want) + for { + infos, err := f.Readdir(want) + for i := range infos { + // workaround forhttps://code.google.com/p/go/issues/detail?id=5960 + if infos[i] == nil { + continue + } + n := infos[i].Name() + d := fuse.DirEntry{ + Name: n, + } + if s := fuse.ToStatT(infos[i]); s != nil { + d.Mode = uint32(s.Mode) + } else { + log.Printf("ReadDir entry %q for %q has no stat info", n, name) + } + output = append(output, d) + } + if len(infos) < want || err == io.EOF { + break + } + if err != nil { + log.Println("Readdir() returned err:", err) + break + } + } + f.Close() + + return output, fuse.OK +} + +func (fs *loopbackFileSystem) Open(name string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) { + f, err := os.OpenFile(fs.GetPath(name), int(flags), 0) + if err != nil { + return nil, fuse.ToStatus(err) + } + return nodefs.NewLoopbackFile(f), fuse.OK +} + +func (fs *loopbackFileSystem) Chmod(path string, mode uint32, context *fuse.Context) (code fuse.Status) { + err := os.Chmod(fs.GetPath(path), os.FileMode(mode)) + return fuse.ToStatus(err) +} + +func (fs *loopbackFileSystem) Chown(path string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(os.Chown(fs.GetPath(path), int(uid), int(gid))) +} + +func (fs *loopbackFileSystem) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(os.Truncate(fs.GetPath(path), int64(offset))) +} + +func (fs *loopbackFileSystem) Readlink(name string, context *fuse.Context) (out string, code fuse.Status) { + f, err := os.Readlink(fs.GetPath(name)) + return f, fuse.ToStatus(err) +} + +func (fs *loopbackFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(syscall.Mknod(fs.GetPath(name), mode, int(dev))) +} + +func (fs *loopbackFileSystem) Mkdir(path string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(os.Mkdir(fs.GetPath(path), os.FileMode(mode))) +} + +// Don't use os.Remove, it removes twice (unlink followed by rmdir). +func (fs *loopbackFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(syscall.Unlink(fs.GetPath(name))) +} + +func (fs *loopbackFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(syscall.Rmdir(fs.GetPath(name))) +} + +func (fs *loopbackFileSystem) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(os.Symlink(pointedTo, fs.GetPath(linkName))) +} + +func (fs *loopbackFileSystem) Rename(oldPath string, newPath string, context *fuse.Context) (codee fuse.Status) { + err := os.Rename(fs.GetPath(oldPath), fs.GetPath(newPath)) + return fuse.ToStatus(err) +} + +func (fs *loopbackFileSystem) Link(orig string, newName string, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(os.Link(fs.GetPath(orig), fs.GetPath(newName))) +} + +func (fs *loopbackFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.ToStatus(syscall.Access(fs.GetPath(name), mode)) +} + +func (fs *loopbackFileSystem) Create(path string, flags uint32, mode uint32, context *fuse.Context) (fuseFile nodefs.File, code fuse.Status) { + f, err := os.OpenFile(fs.GetPath(path), int(flags)|os.O_CREATE, os.FileMode(mode)) + return nodefs.NewLoopbackFile(f), fuse.ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go new file mode 100644 index 00000000..16e53b86 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go @@ -0,0 +1,59 @@ +package pathfs + +import ( + "syscall" + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut { + s := syscall.Statfs_t{} + err := syscall.Statfs(fs.GetPath(name), &s) + if err == nil { + return &fuse.StatfsOut{ + Blocks: s.Blocks, + Bsize: uint32(s.Bsize), + Bfree: s.Bfree, + Bavail: s.Bavail, + Files: s.Files, + Ffree: s.Ffree, + } + } + return nil +} + +const _UTIME_NOW = ((1 << 30) - 1) +const _UTIME_OMIT = ((1 << 30) - 2) + +// timeToTimeval - Convert time.Time to syscall.Timeval +// +// Note: This does not use syscall.NsecToTimespec because +// that does not work properly for times before 1970, +// see https://github.com/golang/go/issues/12777 +func timeToTimeval(t *time.Time) syscall.Timeval { + var tv syscall.Timeval + tv.Usec = int32(t.Nanosecond() / 1000) + tv.Sec = t.Unix() + return tv +} + +// OSX does not have the utimensat syscall neded to implement this properly. +// We do our best to emulate it using futimes. +func (fs *loopbackFileSystem) Utimens(path string, a *time.Time, m *time.Time, context *fuse.Context) fuse.Status { + tv := make([]syscall.Timeval, 2) + if a == nil { + tv[0].Usec = _UTIME_OMIT + } else { + tv[0] = timeToTimeval(a) + } + + if m == nil { + tv[1].Usec = _UTIME_OMIT + } else { + tv[1] = timeToTimeval(m) + } + + err := syscall.Utimes(path, tv) + return fuse.ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go new file mode 100644 index 00000000..20bab223 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go @@ -0,0 +1,79 @@ +package pathfs + +import ( + "fmt" + "syscall" + "time" + + "github.com/hanwen/go-fuse/fuse" +) + +func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut { + s := syscall.Statfs_t{} + err := syscall.Statfs(fs.GetPath(name), &s) + if err == nil { + return &fuse.StatfsOut{ + Blocks: s.Blocks, + Bsize: uint32(s.Bsize), + Bfree: s.Bfree, + Bavail: s.Bavail, + Files: s.Files, + Ffree: s.Ffree, + Frsize: uint32(s.Frsize), + NameLen: uint32(s.Namelen), + } + } + return nil +} + +func (fs *loopbackFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { + data, err := listXAttr(fs.GetPath(name)) + + return data, fuse.ToStatus(err) +} + +func (fs *loopbackFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { + err := sysRemovexattr(fs.GetPath(name), attr) + return fuse.ToStatus(err) +} + +func (fs *loopbackFileSystem) String() string { + return fmt.Sprintf("LoopbackFs(%s)", fs.Root) +} + +func (fs *loopbackFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { + data := make([]byte, 1024) + data, err := getXAttr(fs.GetPath(name), attr, data) + + return data, fuse.ToStatus(err) +} + +func (fs *loopbackFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + err := syscall.Setxattr(fs.GetPath(name), attr, data, flags) + return fuse.ToStatus(err) +} + +const _UTIME_NOW = ((1 << 30) - 1) +const _UTIME_OMIT = ((1 << 30) - 2) + +// Utimens - path based version of loopbackFile.Utimens() +func (fs *loopbackFileSystem) Utimens(path string, a *time.Time, m *time.Time, context *fuse.Context) (code fuse.Status) { + var ts [2]syscall.Timespec + + if a == nil { + ts[0].Nsec = _UTIME_OMIT + } else { + ts[0] = syscall.NsecToTimespec(a.UnixNano()) + ts[0].Nsec = 0 + } + + if m == nil { + ts[1].Nsec = _UTIME_OMIT + } else { + ts[1] = syscall.NsecToTimespec(m.UnixNano()) + ts[1].Nsec = 0 + } + + err := sysUtimensat(0, fs.GetPath(path), &ts, _AT_SYMLINK_NOFOLLOW) + return fuse.ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go new file mode 100644 index 00000000..ff24d562 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go @@ -0,0 +1,737 @@ +package pathfs + +import ( + "fmt" + "log" + "path/filepath" + "strings" + "sync" + "time" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +// refCountedInode is used in clientInodeMap. The reference count is used to decide +// if the entry in clientInodeMap can be dropped. +type refCountedInode struct { + node *pathInode + refCount int +} + +// PathNodeFs is the file system that can translate an inode back to a +// path. The path name is then used to call into an object that has +// the FileSystem interface. +// +// Lookups (ie. FileSystem.GetAttr) may return a inode number in its +// return value. The inode number ("clientInode") is used to indicate +// linked files. +type PathNodeFs struct { + debug bool + fs FileSystem + root *pathInode + connector *nodefs.FileSystemConnector + + // protects clientInodeMap + pathLock sync.RWMutex + + // This map lists all the parent links known for a given inode number. + clientInodeMap map[uint64]*refCountedInode + + options *PathNodeFsOptions +} + +// SetDebug toggles debug information: it will log path names for +// each operation processed. +func (fs *PathNodeFs) SetDebug(dbg bool) { + fs.debug = dbg +} + +// Mount mounts a another node filesystem with the given root on the +// path. The last component of the path should not exist yet. +func (fs *PathNodeFs) Mount(path string, root nodefs.Node, opts *nodefs.Options) fuse.Status { + dir, name := filepath.Split(path) + if dir != "" { + dir = filepath.Clean(dir) + } + parent := fs.LookupNode(dir) + if parent == nil { + return fuse.ENOENT + } + return fs.connector.Mount(parent, name, root, opts) +} + +// ForgetClientInodes forgets all known information on client inodes. +func (fs *PathNodeFs) ForgetClientInodes() { + if !fs.options.ClientInodes { + return + } + fs.pathLock.Lock() + fs.clientInodeMap = map[uint64]*refCountedInode{} + fs.root.forgetClientInodes() + fs.pathLock.Unlock() +} + +// Rereads all inode numbers for all known files. +func (fs *PathNodeFs) RereadClientInodes() { + if !fs.options.ClientInodes { + return + } + fs.ForgetClientInodes() + fs.root.updateClientInodes() +} + +// UnmountNode unmounts the node filesystem with the given root. +func (fs *PathNodeFs) UnmountNode(node *nodefs.Inode) fuse.Status { + return fs.connector.Unmount(node) +} + +// UnmountNode unmounts the node filesystem with the given root. +func (fs *PathNodeFs) Unmount(path string) fuse.Status { + node := fs.Node(path) + if node == nil { + return fuse.ENOENT + } + return fs.connector.Unmount(node) +} + +// String returns a name for this file system +func (fs *PathNodeFs) String() string { + name := fs.fs.String() + if name == "defaultFileSystem" { + name = fmt.Sprintf("%T", fs.fs) + name = strings.TrimLeft(name, "*") + } + return name +} + +// Connector returns the FileSystemConnector (the bridge to the raw +// protocol) for this PathNodeFs. +func (fs *PathNodeFs) Connector() *nodefs.FileSystemConnector { + return fs.connector +} + +// Node looks up the Inode that corresponds to the given path name, or +// returns nil if not found. +func (fs *PathNodeFs) Node(name string) *nodefs.Inode { + n, rest := fs.LastNode(name) + if len(rest) > 0 { + return nil + } + return n +} + +// Like Node, but use Lookup to discover inodes we may not have yet. +func (fs *PathNodeFs) LookupNode(name string) *nodefs.Inode { + return fs.connector.LookupNode(fs.Root().Inode(), name) +} + +// Path constructs a path for the given Inode. If the file system +// implements hard links through client-inode numbers, the path may +// not be unique. +func (fs *PathNodeFs) Path(node *nodefs.Inode) string { + pNode := node.Node().(*pathInode) + return pNode.GetPath() +} + +// LastNode finds the deepest inode known corresponding to a path. The +// unknown part of the filename is also returned. +func (fs *PathNodeFs) LastNode(name string) (*nodefs.Inode, []string) { + return fs.connector.Node(fs.Root().Inode(), name) +} + +// FileNotify notifies that file contents were changed within the +// given range. Use negative offset for metadata-only invalidation, +// and zero-length for invalidating all content. +func (fs *PathNodeFs) FileNotify(path string, off int64, length int64) fuse.Status { + node, r := fs.connector.Node(fs.root.Inode(), path) + if len(r) > 0 { + return fuse.ENOENT + } + return fs.connector.FileNotify(node, off, length) +} + +// EntryNotify makes the kernel forget the entry data from the given +// name from a directory. After this call, the kernel will issue a +// new lookup request for the given name when necessary. +func (fs *PathNodeFs) EntryNotify(dir string, name string) fuse.Status { + node, rest := fs.connector.Node(fs.root.Inode(), dir) + if len(rest) > 0 { + return fuse.ENOENT + } + return fs.connector.EntryNotify(node, name) +} + +// Notify ensures that the path name is invalidates: if the inode is +// known, it issues an file content Notify, if not, an entry notify +// for the path is issued. The latter will clear out non-existence +// cache entries. +func (fs *PathNodeFs) Notify(path string) fuse.Status { + node, rest := fs.connector.Node(fs.root.Inode(), path) + if len(rest) > 0 { + return fs.connector.EntryNotify(node, rest[0]) + } + return fs.connector.FileNotify(node, 0, 0) +} + +// AllFiles returns all open files for the inode corresponding with +// the given mask. +func (fs *PathNodeFs) AllFiles(name string, mask uint32) []nodefs.WithFlags { + n := fs.Node(name) + if n == nil { + return nil + } + return n.Files(mask) +} + +// NewPathNodeFs returns a file system that translates from inodes to +// path names. +func NewPathNodeFs(fs FileSystem, opts *PathNodeFsOptions) *PathNodeFs { + root := &pathInode{} + root.fs = fs + + if opts == nil { + opts = &PathNodeFsOptions{} + } + + pfs := &PathNodeFs{ + fs: fs, + root: root, + clientInodeMap: map[uint64]*refCountedInode{}, + options: opts, + } + root.pathFs = pfs + return pfs +} + +// Root returns the root node for the path filesystem. +func (fs *PathNodeFs) Root() nodefs.Node { + return fs.root +} + +// This is a combination of dentry (entry in the file/directory and +// the inode). This structure is used to implement glue for FSes where +// there is a one-to-one mapping of paths and inodes. +type pathInode struct { + pathFs *PathNodeFs + fs FileSystem + + // This is to correctly resolve hardlinks of the underlying + // real filesystem. + clientInode uint64 + inode *nodefs.Inode +} + +func (n *pathInode) OnMount(conn *nodefs.FileSystemConnector) { + n.pathFs.connector = conn + n.pathFs.fs.OnMount(n.pathFs) +} + +func (n *pathInode) OnUnmount() { +} + +// Drop all known client inodes. Must have the treeLock. +func (n *pathInode) forgetClientInodes() { + n.clientInode = 0 + for _, ch := range n.Inode().FsChildren() { + ch.Node().(*pathInode).forgetClientInodes() + } +} + +func (fs *pathInode) Deletable() bool { + return true +} + +func (n *pathInode) Inode() *nodefs.Inode { + return n.inode +} + +func (n *pathInode) SetInode(node *nodefs.Inode) { + n.inode = node +} + +// Reread all client nodes below this node. Must run outside the treeLock. +func (n *pathInode) updateClientInodes() { + n.GetAttr(&fuse.Attr{}, nil, nil) + for _, ch := range n.Inode().FsChildren() { + ch.Node().(*pathInode).updateClientInodes() + } +} + +// GetPath returns the path relative to the mount governing this +// inode. It returns nil for mount if the file was deleted or the +// filesystem unmounted. +func (n *pathInode) GetPath() string { + if n == n.pathFs.root { + return "" + } + + pathLen := 1 + + // The simple solution is to collect names, and reverse join + // them, them, but since this is a hot path, we take some + // effort to avoid allocations. + + n.pathFs.pathLock.RLock() + walkUp := n.Inode() + + // TODO - guess depth? + segments := make([]string, 0, 10) + for { + parent, name := walkUp.Parent() + if parent == nil { + break + } + segments = append(segments, name) + pathLen += len(name) + 1 + walkUp = parent + } + pathLen-- + + pathBytes := make([]byte, 0, pathLen) + for i := len(segments) - 1; i >= 0; i-- { + pathBytes = append(pathBytes, segments[i]...) + if i > 0 { + pathBytes = append(pathBytes, '/') + } + } + n.pathFs.pathLock.RUnlock() + + path := string(pathBytes) + if n.pathFs.debug { + log.Printf("Inode = %q (%s)", path, n.fs.String()) + } + + if walkUp != n.pathFs.root.Inode() { + // This might happen if the node has been removed from + // the tree using unlink, but we are forced to run + // some file system operation, because the file is + // still opened. + + // TODO - add a deterministic disambiguating suffix. + return ".deleted" + } + + return path +} + +func (n *pathInode) OnAdd(parent *nodefs.Inode, name string) { + // TODO it would be logical to increment the clientInodeMap reference count + // here. However, as the inode number is loaded lazily, we cannot do it + // yet. +} + +func (n *pathInode) rmChild(name string) *pathInode { + childInode := n.Inode().RmChild(name) + if childInode == nil { + return nil + } + return childInode.Node().(*pathInode) +} + +func (n *pathInode) OnRemove(parent *nodefs.Inode, name string) { + if n.clientInode == 0 || !n.pathFs.options.ClientInodes || n.Inode().IsDir() { + return + } + + n.pathFs.pathLock.Lock() + r := n.pathFs.clientInodeMap[n.clientInode] + if r != nil { + r.refCount-- + if r.refCount == 0 { + delete(n.pathFs.clientInodeMap, n.clientInode) + } + } + n.pathFs.pathLock.Unlock() +} + +// setClientInode sets the inode number if has not been set yet. +// This function exists to allow lazy-loading of the inode number. +func (n *pathInode) setClientInode(ino uint64) { + if ino == 0 || n.clientInode != 0 || !n.pathFs.options.ClientInodes || n.Inode().IsDir() { + return + } + n.pathFs.pathLock.Lock() + defer n.pathFs.pathLock.Unlock() + n.clientInode = ino + n.pathFs.clientInodeMap[ino] = &refCountedInode{node: n, refCount: 1} +} + +func (n *pathInode) OnForget() { + if n.clientInode == 0 || !n.pathFs.options.ClientInodes || n.Inode().IsDir() { + return + } + n.pathFs.pathLock.Lock() + delete(n.pathFs.clientInodeMap, n.clientInode) + n.pathFs.pathLock.Unlock() +} + +//////////////////////////////////////////////////////////////// +// FS operations + +func (n *pathInode) StatFs() *fuse.StatfsOut { + return n.fs.StatFs(n.GetPath()) +} + +func (n *pathInode) Readlink(c *fuse.Context) ([]byte, fuse.Status) { + path := n.GetPath() + + val, err := n.fs.Readlink(path, c) + return []byte(val), err +} + +func (n *pathInode) Access(mode uint32, context *fuse.Context) (code fuse.Status) { + p := n.GetPath() + return n.fs.Access(p, mode, context) +} + +func (n *pathInode) GetXAttr(attribute string, context *fuse.Context) (data []byte, code fuse.Status) { + return n.fs.GetXAttr(n.GetPath(), attribute, context) +} + +func (n *pathInode) RemoveXAttr(attr string, context *fuse.Context) fuse.Status { + p := n.GetPath() + return n.fs.RemoveXAttr(p, attr, context) +} + +func (n *pathInode) SetXAttr(attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + return n.fs.SetXAttr(n.GetPath(), attr, data, flags, context) +} + +func (n *pathInode) ListXAttr(context *fuse.Context) (attrs []string, code fuse.Status) { + return n.fs.ListXAttr(n.GetPath(), context) +} + +func (n *pathInode) Flush(file nodefs.File, openFlags uint32, context *fuse.Context) (code fuse.Status) { + return file.Flush() +} + +func (n *pathInode) OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { + return n.fs.OpenDir(n.GetPath(), context) +} + +func (n *pathInode) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (*nodefs.Inode, fuse.Status) { + fullPath := filepath.Join(n.GetPath(), name) + code := n.fs.Mknod(fullPath, mode, dev, context) + var child *nodefs.Inode + if code.Ok() { + pNode := n.createChild(name, false) + child = pNode.Inode() + } + return child, code +} + +func (n *pathInode) Mkdir(name string, mode uint32, context *fuse.Context) (*nodefs.Inode, fuse.Status) { + fullPath := filepath.Join(n.GetPath(), name) + code := n.fs.Mkdir(fullPath, mode, context) + var child *nodefs.Inode + if code.Ok() { + pNode := n.createChild(name, true) + child = pNode.Inode() + } + return child, code +} + +func (n *pathInode) Unlink(name string, context *fuse.Context) (code fuse.Status) { + code = n.fs.Unlink(filepath.Join(n.GetPath(), name), context) + if code.Ok() { + n.Inode().RmChild(name) + } + return code +} + +func (n *pathInode) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + code = n.fs.Rmdir(filepath.Join(n.GetPath(), name), context) + if code.Ok() { + n.Inode().RmChild(name) + } + return code +} + +func (n *pathInode) Symlink(name string, content string, context *fuse.Context) (*nodefs.Inode, fuse.Status) { + fullPath := filepath.Join(n.GetPath(), name) + code := n.fs.Symlink(content, fullPath, context) + var child *nodefs.Inode + if code.Ok() { + pNode := n.createChild(name, false) + child = pNode.Inode() + } + return child, code +} + +func (n *pathInode) Rename(oldName string, newParent nodefs.Node, newName string, context *fuse.Context) (code fuse.Status) { + p := newParent.(*pathInode) + oldPath := filepath.Join(n.GetPath(), oldName) + newPath := filepath.Join(p.GetPath(), newName) + code = n.fs.Rename(oldPath, newPath, context) + if code.Ok() { + // The rename may have overwritten another file, remove it from the tree + p.Inode().RmChild(newName) + ch := n.Inode().RmChild(oldName) + if ch != nil { + // oldName may have been forgotten in the meantime. + p.Inode().AddChild(newName, ch) + } + } + return code +} + +func (n *pathInode) Link(name string, existingFsnode nodefs.Node, context *fuse.Context) (*nodefs.Inode, fuse.Status) { + if !n.pathFs.options.ClientInodes { + return nil, fuse.ENOSYS + } + + newPath := filepath.Join(n.GetPath(), name) + existing := existingFsnode.(*pathInode) + oldPath := existing.GetPath() + code := n.fs.Link(oldPath, newPath, context) + + var a *fuse.Attr + if code.Ok() { + a, code = n.fs.GetAttr(newPath, context) + } + + var child *nodefs.Inode + if code.Ok() { + if existing.clientInode != 0 && existing.clientInode == a.Ino { + child = existing.Inode() + n.Inode().AddChild(name, existing.Inode()) + } else { + pNode := n.createChild(name, false) + child = pNode.Inode() + pNode.clientInode = a.Ino + } + } + return child, code +} + +func (n *pathInode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, *nodefs.Inode, fuse.Status) { + var child *nodefs.Inode + fullPath := filepath.Join(n.GetPath(), name) + file, code := n.fs.Create(fullPath, flags, mode, context) + if code.Ok() { + pNode := n.createChild(name, false) + child = pNode.Inode() + } + return file, child, code +} + +func (n *pathInode) createChild(name string, isDir bool) *pathInode { + i := &pathInode{ + fs: n.fs, + pathFs: n.pathFs, + } + + n.Inode().NewChild(name, isDir, i) + + return i +} + +func (n *pathInode) Open(flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + p := n.GetPath() + file, code = n.fs.Open(p, flags, context) + if n.pathFs.debug { + file = &nodefs.WithFlags{ + File: file, + Description: n.GetPath(), + } + } + return +} + +func (n *pathInode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (node *nodefs.Inode, code fuse.Status) { + fullPath := filepath.Join(n.GetPath(), name) + fi, code := n.fs.GetAttr(fullPath, context) + if code.Ok() { + node = n.findChild(fi, name, fullPath).Inode() + *out = *fi + } + + return node, code +} + +func (n *pathInode) findChild(fi *fuse.Attr, name string, fullPath string) (out *pathInode) { + if fi.Ino > 0 { + n.pathFs.pathLock.RLock() + r := n.pathFs.clientInodeMap[fi.Ino] + if r != nil { + out = r.node + r.refCount++ + if fi.Nlink == 1 { + log.Printf("Found linked inode, but Nlink == 1, ino=%d, fullPath=%q", fi.Ino, fullPath) + } + } + n.pathFs.pathLock.RUnlock() + } + + if out == nil { + out = n.createChild(name, fi.IsDir()) + out.setClientInode(fi.Ino) + } else { + n.Inode().AddChild(name, out.Inode()) + } + return out +} + +func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) { + var fi *fuse.Attr + if file == nil { + // Linux currently (tested on v4.4) does not pass a file descriptor for + // fstat. To be able to stat a deleted file we have to find ourselves + // an open fd. + file = n.Inode().AnyFile() + } + + if file != nil { + code = file.GetAttr(out) + } + + if file == nil || code == fuse.ENOSYS || code == fuse.EBADF { + fi, code = n.fs.GetAttr(n.GetPath(), context) + } + + if fi != nil { + n.setClientInode(fi.Ino) + } + + if fi != nil && !fi.IsDir() && fi.Nlink == 0 { + fi.Nlink = 1 + } + + if fi != nil { + *out = *fi + } + return code +} + +func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context) (code fuse.Status) { + // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor + // to FUSE for fchmod. We still check because that may change in the future. + if file != nil { + code = file.Chmod(perms) + if code != fuse.ENOSYS { + return code + } + } + + files := n.Inode().Files(fuse.O_ANYWRITE) + for _, f := range files { + // TODO - pass context + code = f.Chmod(perms) + if code.Ok() { + return + } + } + + if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { + code = n.fs.Chmod(n.GetPath(), perms, context) + } + return code +} + +func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor + // to FUSE for fchown. We still check because it may change in the future. + if file != nil { + code = file.Chown(uid, gid) + if code != fuse.ENOSYS { + return code + } + } + + files := n.Inode().Files(fuse.O_ANYWRITE) + for _, f := range files { + // TODO - pass context + code = f.Chown(uid, gid) + if code.Ok() { + return code + } + } + if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { + // TODO - can we get just FATTR_GID but not FATTR_UID ? + code = n.fs.Chown(n.GetPath(), uid, gid, context) + } + return code +} + +func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Context) (code fuse.Status) { + // A file descriptor was passed in AND the filesystem implements the + // operation on the file handle. This the common case for ftruncate. + if file != nil { + code = file.Truncate(size) + if code != fuse.ENOSYS { + return code + } + } + + files := n.Inode().Files(fuse.O_ANYWRITE) + for _, f := range files { + // TODO - pass context + code = f.Truncate(size) + if code.Ok() { + return code + } + } + if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { + code = n.fs.Truncate(n.GetPath(), size, context) + } + return code +} + +func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) { + // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor + // to FUSE for futimens. We still check because it may change in the future. + if file != nil { + code = file.Utimens(atime, mtime) + if code != fuse.ENOSYS { + return code + } + } + + files := n.Inode().Files(fuse.O_ANYWRITE) + for _, f := range files { + // TODO - pass context + code = f.Utimens(atime, mtime) + if code.Ok() { + return code + } + } + if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { + code = n.fs.Utimens(n.GetPath(), atime, mtime, context) + } + return code +} + +func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) { + if file != nil { + code = file.Allocate(off, size, mode) + if code.Ok() { + return code + } + } + + files := n.Inode().Files(fuse.O_ANYWRITE) + for _, f := range files { + // TODO - pass context + code = f.Allocate(off, size, mode) + if code.Ok() { + return code + } + } + + return code +} + +func (n *pathInode) Read(file nodefs.File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) { + if file != nil { + return file.Read(dest, off) + } + return nil, fuse.ENOSYS +} + +func (n *pathInode) Write(file nodefs.File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { + if file != nil { + return file.Write(data, off) + } + return 0, fuse.ENOSYS +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go new file mode 100644 index 00000000..9b575c04 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go @@ -0,0 +1,128 @@ +package pathfs + +import ( + "fmt" + "path/filepath" + "time" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +// PrefixFileSystem adds a path prefix to incoming calls. +type prefixFileSystem struct { + FileSystem FileSystem + Prefix string +} + +func NewPrefixFileSystem(fs FileSystem, prefix string) FileSystem { + return &prefixFileSystem{fs, prefix} +} + +func (fs *prefixFileSystem) SetDebug(debug bool) { + fs.FileSystem.SetDebug(debug) +} + +func (fs *prefixFileSystem) prefixed(n string) string { + return filepath.Join(fs.Prefix, n) +} + +func (fs *prefixFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + return fs.FileSystem.GetAttr(fs.prefixed(name), context) +} + +func (fs *prefixFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { + return fs.FileSystem.Readlink(fs.prefixed(name), context) +} + +func (fs *prefixFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { + return fs.FileSystem.Mknod(fs.prefixed(name), mode, dev, context) +} + +func (fs *prefixFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { + return fs.FileSystem.Mkdir(fs.prefixed(name), mode, context) +} + +func (fs *prefixFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Unlink(fs.prefixed(name), context) +} + +func (fs *prefixFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Rmdir(fs.prefixed(name), context) +} + +func (fs *prefixFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Symlink(value, fs.prefixed(linkName), context) +} + +func (fs *prefixFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Rename(fs.prefixed(oldName), fs.prefixed(newName), context) +} + +func (fs *prefixFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Link(fs.prefixed(oldName), fs.prefixed(newName), context) +} + +func (fs *prefixFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Chmod(fs.prefixed(name), mode, context) +} + +func (fs *prefixFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Chown(fs.prefixed(name), uid, gid, context) +} + +func (fs *prefixFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Truncate(fs.prefixed(name), offset, context) +} + +func (fs *prefixFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + return fs.FileSystem.Open(fs.prefixed(name), flags, context) +} + +func (fs *prefixFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { + return fs.FileSystem.OpenDir(fs.prefixed(name), context) +} + +func (fs *prefixFileSystem) OnMount(nodeFs *PathNodeFs) { + fs.FileSystem.OnMount(nodeFs) +} + +func (fs *prefixFileSystem) OnUnmount() { + fs.FileSystem.OnUnmount() +} + +func (fs *prefixFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Access(fs.prefixed(name), mode, context) +} + +func (fs *prefixFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + return fs.FileSystem.Create(fs.prefixed(name), flags, mode, context) +} + +func (fs *prefixFileSystem) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Utimens(fs.prefixed(name), Atime, Mtime, context) +} + +func (fs *prefixFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { + return fs.FileSystem.GetXAttr(fs.prefixed(name), attr, context) +} + +func (fs *prefixFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + return fs.FileSystem.SetXAttr(fs.prefixed(name), attr, data, flags, context) +} + +func (fs *prefixFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { + return fs.FileSystem.ListXAttr(fs.prefixed(name), context) +} + +func (fs *prefixFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { + return fs.FileSystem.RemoveXAttr(fs.prefixed(name), attr, context) +} + +func (fs *prefixFileSystem) String() string { + return fmt.Sprintf("prefixFileSystem(%s,%s)", fs.FileSystem.String(), fs.Prefix) +} + +func (fs *prefixFileSystem) StatFs(name string) *fuse.StatfsOut { + return fs.FileSystem.StatFs(fs.prefixed(name)) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go new file mode 100644 index 00000000..ea3dddfe --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go @@ -0,0 +1,119 @@ +package pathfs + +import ( + "fmt" + "time" + + "github.com/hanwen/go-fuse/fuse" + "github.com/hanwen/go-fuse/fuse/nodefs" +) + +// NewReadonlyFileSystem returns a wrapper that only exposes read-only +// operations. +func NewReadonlyFileSystem(fs FileSystem) FileSystem { + return &readonlyFileSystem{fs} +} + +type readonlyFileSystem struct { + FileSystem +} + +func (fs *readonlyFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + return fs.FileSystem.GetAttr(name, context) +} + +func (fs *readonlyFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { + return fs.FileSystem.Readlink(name, context) +} + +func (fs *readonlyFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + if flags&fuse.O_ANYWRITE != 0 { + return nil, fuse.EPERM + } + file, code = fs.FileSystem.Open(name, flags, context) + return nodefs.NewReadOnlyFile(file), code +} + +func (fs *readonlyFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { + return fs.FileSystem.OpenDir(name, context) +} + +func (fs *readonlyFileSystem) OnMount(nodeFs *PathNodeFs) { + fs.FileSystem.OnMount(nodeFs) +} + +func (fs *readonlyFileSystem) OnUnmount() { + fs.FileSystem.OnUnmount() +} + +func (fs *readonlyFileSystem) String() string { + return fmt.Sprintf("readonlyFileSystem(%v)", fs.FileSystem) +} + +func (fs *readonlyFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { + return fs.FileSystem.Access(name, mode, context) +} + +func (fs *readonlyFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { + return nil, fuse.EPERM +} + +func (fs *readonlyFileSystem) Utimens(name string, atime *time.Time, ctime *time.Time, context *fuse.Context) (code fuse.Status) { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { + return fs.FileSystem.GetXAttr(name, attr, context) +} + +func (fs *readonlyFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { + return fuse.EPERM +} + +func (fs *readonlyFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { + return fs.FileSystem.ListXAttr(name, context) +} + +func (fs *readonlyFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { + return fuse.EPERM +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go new file mode 100644 index 00000000..62a05ec5 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go @@ -0,0 +1,140 @@ +package pathfs + +import ( + "bytes" + "syscall" + "unsafe" +) + +var _zero uintptr + +func getXAttr(path string, attr string, dest []byte) (value []byte, err error) { + sz, err := sysGetxattr(path, attr, dest) + for sz > cap(dest) && err == nil { + dest = make([]byte, sz) + sz, err = sysGetxattr(path, attr, dest) + } + + if err != nil { + return nil, err + } + + return dest[:sz], err +} + +func listXAttr(path string) (attributes []string, err error) { + dest := make([]byte, 0) + sz, err := sysListxattr(path, dest) + if err != nil { + return nil, err + } + + for sz > cap(dest) && err == nil { + dest = make([]byte, sz) + sz, err = sysListxattr(path, dest) + } + + if sz == 0 { + return nil, err + } + + // -1 to drop the final empty slice. + dest = dest[:sz-1] + attributesBytes := bytes.Split(dest, []byte{0}) + attributes = make([]string, len(attributesBytes)) + for i, v := range attributesBytes { + attributes[i] = string(v) + } + return attributes, err +} + +// Below is cut & paste from std lib syscall, so gccgo 4.8.1 can +// compile this too. +func sysGetxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.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 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + sz = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func sysRemovexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = e1 + } + return +} + +func sysListxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = syscall.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.Syscall(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + sz = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func sysSetxattr(path string, attr string, val []byte, flag int) error { + return syscall.Setxattr(path, attr, val, flag) +} + +const _AT_SYMLINK_NOFOLLOW = 0x100 + +// Linux kernel syscall utimensat(2) +// +// Needed to implement SetAttr on symlinks correctly as only utimensat provides +// AT_SYMLINK_NOFOLLOW. +func sysUtimensat(dirfd int, pathname string, times *[2]syscall.Timespec, flags int) (err error) { + + // Null-terminated version of pathname + p0, err := syscall.BytePtrFromString(pathname) + if err != nil { + return err + } + + _, _, e1 := syscall.Syscall6(syscall.SYS_UTIMENSAT, + uintptr(dirfd), uintptr(unsafe.Pointer(p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/print.go b/vendor/github.com/hanwen/go-fuse/fuse/print.go new file mode 100644 index 00000000..29e12b0b --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/print.go @@ -0,0 +1,246 @@ +package fuse + +import ( + "fmt" + "os" + "strings" + "syscall" +) + +var initFlagNames map[int64]string +var releaseFlagNames map[int64]string +var OpenFlagNames map[int64]string +var FuseOpenFlagNames map[int64]string +var accessFlagName map[int64]string +var writeFlagNames map[int64]string +var readFlagNames map[int64]string + +func init() { + writeFlagNames = map[int64]string{ + WRITE_CACHE: "CACHE", + WRITE_LOCKOWNER: "LOCKOWNER", + } + readFlagNames = map[int64]string{ + READ_LOCKOWNER: "LOCKOWNER", + } + initFlagNames = map[int64]string{ + CAP_ASYNC_READ: "ASYNC_READ", + CAP_POSIX_LOCKS: "POSIX_LOCKS", + CAP_FILE_OPS: "FILE_OPS", + CAP_ATOMIC_O_TRUNC: "ATOMIC_O_TRUNC", + CAP_EXPORT_SUPPORT: "EXPORT_SUPPORT", + CAP_BIG_WRITES: "BIG_WRITES", + CAP_DONT_MASK: "DONT_MASK", + CAP_SPLICE_WRITE: "SPLICE_WRITE", + CAP_SPLICE_MOVE: "SPLICE_MOVE", + CAP_SPLICE_READ: "SPLICE_READ", + CAP_FLOCK_LOCKS: "FLOCK_LOCKS", + CAP_IOCTL_DIR: "IOCTL_DIR", + CAP_AUTO_INVAL_DATA: "AUTO_INVAL_DATA", + CAP_READDIRPLUS: "READDIRPLUS", + CAP_READDIRPLUS_AUTO: "READDIRPLUS_AUTO", + CAP_ASYNC_DIO: "ASYNC_DIO", + CAP_WRITEBACK_CACHE: "WRITEBACK_CACHE", + CAP_NO_OPEN_SUPPORT: "NO_OPEN_SUPPORT", + } + releaseFlagNames = map[int64]string{ + RELEASE_FLUSH: "FLUSH", + } + OpenFlagNames = map[int64]string{ + int64(os.O_WRONLY): "WRONLY", + int64(os.O_RDWR): "RDWR", + int64(os.O_APPEND): "APPEND", + int64(syscall.O_ASYNC): "ASYNC", + int64(os.O_CREATE): "CREAT", + int64(os.O_EXCL): "EXCL", + int64(syscall.O_NOCTTY): "NOCTTY", + int64(syscall.O_NONBLOCK): "NONBLOCK", + int64(os.O_SYNC): "SYNC", + int64(os.O_TRUNC): "TRUNC", + + int64(syscall.O_CLOEXEC): "CLOEXEC", + int64(syscall.O_DIRECTORY): "DIRECTORY", + } + FuseOpenFlagNames = map[int64]string{ + FOPEN_DIRECT_IO: "DIRECT", + FOPEN_KEEP_CACHE: "CACHE", + FOPEN_NONSEEKABLE: "NONSEEK", + } + accessFlagName = map[int64]string{ + X_OK: "x", + W_OK: "w", + R_OK: "r", + } + +} + +func FlagString(names map[int64]string, fl int64, def string) string { + s := []string{} + for k, v := range names { + if fl&k != 0 { + s = append(s, v) + fl ^= k + } + } + if len(s) == 0 && def != "" { + s = []string{def} + } + if fl != 0 { + s = append(s, fmt.Sprintf("0x%x", fl)) + } + + return strings.Join(s, ",") +} + +func (me *ForgetIn) string() string { + return fmt.Sprintf("{Nlookup=%d}", me.Nlookup) +} + +func (me *_BatchForgetIn) string() string { + return fmt.Sprintf("{Count=%d}", me.Count) +} + +func (me *MkdirIn) string() string { + return fmt.Sprintf("{0%o (0%o)}", me.Mode, me.Umask) +} + +func (me *RenameIn) string() string { + return fmt.Sprintf("{%d}", me.Newdir) +} + +func (me *SetAttrIn) string() string { + s := []string{} + if me.Valid&FATTR_MODE != 0 { + s = append(s, fmt.Sprintf("mode 0%o", me.Mode)) + } + if me.Valid&FATTR_UID != 0 { + s = append(s, fmt.Sprintf("uid %d", me.Uid)) + } + if me.Valid&FATTR_GID != 0 { + s = append(s, fmt.Sprintf("uid %d", me.Gid)) + } + if me.Valid&FATTR_SIZE != 0 { + s = append(s, fmt.Sprintf("size %d", me.Size)) + } + if me.Valid&FATTR_ATIME != 0 { + s = append(s, fmt.Sprintf("atime %d.%09d", me.Atime, me.Atimensec)) + } + if me.Valid&FATTR_MTIME != 0 { + s = append(s, fmt.Sprintf("mtime %d.%09d", me.Mtime, me.Mtimensec)) + } + if me.Valid&FATTR_FH != 0 { + s = append(s, fmt.Sprintf("fh %d", me.Fh)) + } + // TODO - FATTR_ATIME_NOW = (1 << 7), FATTR_MTIME_NOW = (1 << 8), FATTR_LOCKOWNER = (1 << 9) + return fmt.Sprintf("{%s}", strings.Join(s, ", ")) +} + +func (me *ReleaseIn) string() string { + return fmt.Sprintf("{Fh %d %s %s L%d}", + me.Fh, FlagString(OpenFlagNames, int64(me.Flags), ""), + FlagString(releaseFlagNames, int64(me.ReleaseFlags), ""), + me.LockOwner) +} + +func (me *OpenIn) string() string { + return fmt.Sprintf("{%s}", FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY")) +} + +func (me *OpenOut) string() string { + return fmt.Sprintf("{Fh %d %s}", me.Fh, + FlagString(FuseOpenFlagNames, int64(me.OpenFlags), "")) +} + +func (me *InitIn) string() string { + return fmt.Sprintf("{%d.%d Ra 0x%x %s}", + me.Major, me.Minor, me.MaxReadAhead, + FlagString(initFlagNames, int64(me.Flags), "")) +} + +func (me *InitOut) string() string { + return fmt.Sprintf("{%d.%d Ra 0x%x %s %d/%d Wr 0x%x Tg 0x%x}", + me.Major, me.Minor, me.MaxReadAhead, + FlagString(initFlagNames, int64(me.Flags), ""), + me.CongestionThreshold, me.MaxBackground, me.MaxWrite, + me.TimeGran) +} + +func (s *FsyncIn) string() string { + return fmt.Sprintf("{Fh %d Flags %x}", s.Fh, s.FsyncFlags) +} + +func (me *SetXAttrIn) string() string { + return fmt.Sprintf("{sz %d f%o}", me.Size, me.Flags) +} + +func (me *GetXAttrIn) string() string { + return fmt.Sprintf("{sz %d}", me.Size) +} + +func (me *GetXAttrOut) string() string { + return fmt.Sprintf("{sz %d}", me.Size) +} + +func (me *AccessIn) string() string { + return fmt.Sprintf("{%s}", FlagString(accessFlagName, int64(me.Mask), "")) +} + +func (me *FlushIn) string() string { + return fmt.Sprintf("{Fh %d}", me.Fh) +} + +func (me *AttrOut) string() string { + return fmt.Sprintf( + "{A%d.%09d %v}", + me.AttrValid, me.AttrValidNsec, &me.Attr) +} + +// Returned by LOOKUP +func (me *EntryOut) string() string { + return fmt.Sprintf("{NodeId: %d Generation=%d EntryValid=%d.%03d AttrValid=%d.%03d Attr=%v}", + me.NodeId, me.Generation, me.EntryValid, me.EntryValidNsec/1000000, + me.AttrValid, me.AttrValidNsec/1000000, &me.Attr) +} + +func (me *CreateOut) string() string { + return fmt.Sprintf("{NodeId: %d Generation=%d %v %v}", me.NodeId, me.Generation, &me.EntryOut, &me.OpenOut) +} + +func (me *StatfsOut) string() string { + return fmt.Sprintf( + "{blocks (%d,%d)/%d files %d/%d bs%d nl%d frs%d}", + me.Bfree, me.Bavail, me.Blocks, me.Ffree, me.Files, + me.Bsize, me.NameLen, me.Frsize) +} + +func (o *NotifyInvalEntryOut) string() string { + return fmt.Sprintf("{parent %d sz %d}", o.Parent, o.NameLen) +} + +func (o *NotifyInvalInodeOut) string() string { + return fmt.Sprintf("{ino %d off %d sz %d}", o.Ino, o.Off, o.Length) +} + +func (o *NotifyInvalDeleteOut) string() string { + return fmt.Sprintf("{parent %d ch %d sz %d}", o.Parent, o.Child, o.NameLen) +} + +func (f *FallocateIn) string() string { + return fmt.Sprintf("{Fh %d off %d sz %d mod 0%o}", + f.Fh, f.Offset, f.Length, f.Mode) +} + +func (f *LinkIn) string() string { + return fmt.Sprintf("{Oldnodeid: %d}", f.Oldnodeid) +} + +// Print pretty prints FUSE data types for kernel communication +func Print(obj interface{}) string { + t, ok := obj.(interface { + string() string + }) + if ok { + return t.string() + } + return fmt.Sprintf("%T: %v", obj, obj) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go new file mode 100644 index 00000000..16a9d6e3 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go @@ -0,0 +1,50 @@ +package fuse + +import ( + "fmt" +) + +func init() { + initFlagNames[CAP_XTIMES] = "XTIMES" + initFlagNames[CAP_VOL_RENAME] = "VOL_RENAME" + initFlagNames[CAP_CASE_INSENSITIVE] = "CASE_INSENSITIVE" +} + +func (a *Attr) string() string { + return fmt.Sprintf( + "{M0%o SZ=%d L=%d "+ + "%d:%d "+ + "%d %d:%d "+ + "A %d.%09d "+ + "M %d.%09d "+ + "C %d.%09d}", + a.Mode, a.Size, a.Nlink, + a.Uid, a.Gid, + a.Blocks, + a.Rdev, a.Ino, a.Atime, a.Atimensec, a.Mtime, a.Mtimensec, + a.Ctime, a.Ctimensec) +} + +func (me *CreateIn) string() string { + return fmt.Sprintf( + "{0%o [%s]}", me.Mode, + FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY")) +} + +func (me *GetAttrIn) string() string { return "" } + +func (me *MknodIn) string() string { + return fmt.Sprintf("{0%o, %d}", me.Mode, me.Rdev) +} + +func (me *ReadIn) string() string { + return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", + me.Fh, me.Offset, me.Size, + FlagString(readFlagNames, int64(me.ReadFlags), "")) +} + +func (me *WriteIn) string() string { + return fmt.Sprintf("{Fh %d off %d sz %d %s}", + me.Fh, me.Offset, me.Size, + FlagString(writeFlagNames, int64(me.WriteFlags), "")) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/print_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/print_linux.go new file mode 100644 index 00000000..2b9f26f6 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/print_linux.go @@ -0,0 +1,58 @@ +package fuse + +import ( + "fmt" + "syscall" +) + +func init() { + OpenFlagNames[syscall.O_DIRECT] = "DIRECT" + OpenFlagNames[syscall.O_LARGEFILE] = "LARGEFILE" + OpenFlagNames[syscall_O_NOATIME] = "NOATIME" + +} + +func (a *Attr) string() string { + return fmt.Sprintf( + "{M0%o SZ=%d L=%d "+ + "%d:%d "+ + "B%d*%d i%d:%d "+ + "A %d.%09d "+ + "M %d.%09d "+ + "C %d.%09d}", + a.Mode, a.Size, a.Nlink, + a.Uid, a.Gid, + a.Blocks, a.Blksize, + a.Rdev, a.Ino, a.Atime, a.Atimensec, a.Mtime, a.Mtimensec, + a.Ctime, a.Ctimensec) +} + +func (me *CreateIn) string() string { + return fmt.Sprintf( + "{0%o [%s] (0%o)}", me.Mode, + FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY"), me.Umask) +} + +func (me *GetAttrIn) string() string { + return fmt.Sprintf("{Fh %d}", me.Fh_) +} + +func (me *MknodIn) string() string { + return fmt.Sprintf("{0%o (0%o), %d}", me.Mode, me.Umask, me.Rdev) +} + +func (me *ReadIn) string() string { + return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", + me.Fh, me.Offset, me.Size, + FlagString(readFlagNames, int64(me.ReadFlags), ""), + me.LockOwner, + FlagString(OpenFlagNames, int64(me.Flags), "RDONLY")) +} + +func (me *WriteIn) string() string { + return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", + me.Fh, me.Offset, me.Size, + FlagString(writeFlagNames, int64(me.WriteFlags), ""), + me.LockOwner, + FlagString(OpenFlagNames, int64(me.Flags), "RDONLY")) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/read.go b/vendor/github.com/hanwen/go-fuse/fuse/read.go new file mode 100644 index 00000000..60304b5e --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/read.go @@ -0,0 +1,71 @@ +package fuse + +import ( + "io" + "syscall" +) + +// ReadResultData is the read return for returning bytes directly. +type readResultData struct { + // Raw bytes for the read. + Data []byte +} + +func (r *readResultData) Size() int { + return len(r.Data) +} + +func (r *readResultData) Done() { +} + +func (r *readResultData) Bytes(buf []byte) ([]byte, Status) { + return r.Data, OK +} + +func ReadResultData(b []byte) ReadResult { + return &readResultData{b} +} + +func ReadResultFd(fd uintptr, off int64, sz int) ReadResult { + return &readResultFd{fd, off, sz} +} + +// ReadResultFd is the read return for zero-copy file data. +type readResultFd struct { + // Splice from the following file. + Fd uintptr + + // Offset within Fd, or -1 to use current offset. + Off int64 + + // Size of data to be loaded. Actual data available may be + // less at the EOF. + Sz int +} + +// Reads raw bytes from file descriptor if necessary, using the passed +// buffer as storage. +func (r *readResultFd) Bytes(buf []byte) ([]byte, Status) { + sz := r.Sz + if len(buf) < sz { + sz = len(buf) + } + + n, err := syscall.Pread(int(r.Fd), buf[:sz], r.Off) + if err == io.EOF { + err = nil + } + + if n < 0 { + n = 0 + } + + return buf[:n], ToStatus(err) +} + +func (r *readResultFd) Size() int { + return r.Sz +} + +func (r *readResultFd) Done() { +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/request.go b/vendor/github.com/hanwen/go-fuse/fuse/request.go new file mode 100644 index 00000000..c9768aca --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/request.go @@ -0,0 +1,213 @@ +package fuse + +import ( + "bytes" + "fmt" + "log" + "strings" + "time" + "unsafe" +) + +var sizeOfOutHeader = unsafe.Sizeof(OutHeader{}) +var zeroOutBuf [outputHeaderSize]byte + +type request struct { + inputBuf []byte + + // These split up inputBuf. + inHeader *InHeader // generic header + inData unsafe.Pointer // per op data + arg []byte // flat data. + + filenames []string // filename arguments + + // Unstructured data, a pointer to the relevant XxxxOut struct. + outData unsafe.Pointer + status Status + flatData []byte + fdData *readResultFd + + // In case of read, keep read result here so we can call + // Done() on it. + readResult ReadResult + + // Start timestamp for timing info. + startTime time.Time + + // All information pertaining to opcode of this request. + handler *operationHandler + + // Request storage. For large inputs and outputs, use data + // obtained through bufferpool. + bufferPoolInputBuf []byte + bufferPoolOutputBuf []byte + + // For small pieces of data, we use the following inlines + // arrays: + // + // Output header and structured data. + outBuf [outputHeaderSize]byte + + // Input, if small enough to fit here. + smallInputBuf [128]byte + + context Context +} + +func (r *request) clear() { + r.inputBuf = nil + r.inHeader = nil + r.inData = nil + r.arg = nil + r.filenames = nil + r.outData = nil + r.status = OK + r.flatData = nil + r.fdData = nil + r.startTime = time.Time{} + r.handler = nil + r.readResult = nil +} + +func (r *request) InputDebug() string { + val := " " + if r.handler.DecodeIn != nil { + val = fmt.Sprintf(" data: %v ", Print(r.handler.DecodeIn(r.inData))) + } + + names := "" + if r.filenames != nil { + names = fmt.Sprintf("names: %v", r.filenames) + } + + if len(r.arg) > 0 { + names += fmt.Sprintf(" %d bytes", len(r.arg)) + } + + return fmt.Sprintf("Dispatch %d: %s, NodeId: %v.%v%v", + r.inHeader.Unique, operationName(r.inHeader.Opcode), + r.inHeader.NodeId, val, names) +} + +func (r *request) OutputDebug() string { + var dataStr string + if r.handler.DecodeOut != nil && r.outData != nil { + dataStr = Print(r.handler.DecodeOut(r.outData)) + } + + max := 1024 + if len(dataStr) > max { + dataStr = dataStr[:max] + fmt.Sprintf(" ...trimmed") + } + + flatStr := "" + if r.flatDataSize() > 0 { + if r.handler.FileNameOut { + s := strings.TrimRight(string(r.flatData), "\x00") + flatStr = fmt.Sprintf(" %q", s) + } else { + spl := "" + if r.fdData != nil { + spl = " (fd data)" + } + flatStr = fmt.Sprintf(" %d bytes data%s\n", r.flatDataSize(), spl) + } + } + + return fmt.Sprintf("Serialize %d: %s code: %v value: %v%v", + r.inHeader.Unique, operationName(r.inHeader.Opcode), r.status, + dataStr, flatStr) +} + +// setInput returns true if it takes ownership of the argument, false if not. +func (r *request) setInput(input []byte) bool { + if len(input) < len(r.smallInputBuf) { + copy(r.smallInputBuf[:], input) + r.inputBuf = r.smallInputBuf[:len(input)] + return false + } + r.inputBuf = input + r.bufferPoolInputBuf = input[:cap(input)] + + return true +} + +func (r *request) parse() { + inHSize := int(unsafe.Sizeof(InHeader{})) + if len(r.inputBuf) < inHSize { + log.Printf("Short read for input header: %v", r.inputBuf) + return + } + + r.inHeader = (*InHeader)(unsafe.Pointer(&r.inputBuf[0])) + r.arg = r.inputBuf[:] + + r.handler = getHandler(r.inHeader.Opcode) + if r.handler == nil { + log.Printf("Unknown opcode %d", r.inHeader.Opcode) + r.status = ENOSYS + return + } + + if len(r.arg) < int(r.handler.InputSize) { + log.Printf("Short read for %v: %v", operationName(r.inHeader.Opcode), r.arg) + r.status = EIO + return + } + + if r.handler.InputSize > 0 { + r.inData = unsafe.Pointer(&r.arg[0]) + r.arg = r.arg[r.handler.InputSize:] + } else { + r.arg = r.arg[inHSize:] + } + + count := r.handler.FileNames + if count > 0 { + if count == 1 { + r.filenames = []string{string(r.arg[:len(r.arg)-1])} + } else { + names := bytes.SplitN(r.arg[:len(r.arg)-1], []byte{0}, count) + r.filenames = make([]string, len(names)) + for i, n := range names { + r.filenames[i] = string(n) + } + if len(names) != count { + log.Println("filename argument mismatch", names, count) + r.status = EIO + } + } + } + + copy(r.outBuf[:r.handler.OutputSize+sizeOfOutHeader], + zeroOutBuf[:r.handler.OutputSize+sizeOfOutHeader]) + r.outData = unsafe.Pointer(&r.outBuf[sizeOfOutHeader]) +} + +func (r *request) serializeHeader(dataSize int) (header []byte) { + dataLength := r.handler.OutputSize + if r.outData == nil || r.status > OK { + dataLength = 0 + } + + sizeOfOutHeader := unsafe.Sizeof(OutHeader{}) + header = r.outBuf[:sizeOfOutHeader+dataLength] + o := (*OutHeader)(unsafe.Pointer(&header[0])) + o.Unique = r.inHeader.Unique + o.Status = int32(-r.status) + o.Length = uint32( + int(sizeOfOutHeader) + int(dataLength) + dataSize) + + var asSlice []byte + toSlice(&asSlice, r.outData, dataLength) + copy(header[sizeOfOutHeader:], asSlice) + return header +} + +func (r *request) flatDataSize() int { + if r.fdData != nil { + return r.fdData.Size() + } + return len(r.flatData) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go new file mode 100644 index 00000000..c9202379 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go @@ -0,0 +1,9 @@ +package fuse + +const outputHeaderSize = 200 + +const ( + _FUSE_KERNEL_VERSION = 7 + _MINIMUM_MINOR_VERSION = 8 + _OUR_MINOR_VERSION = 8 +) diff --git a/vendor/github.com/hanwen/go-fuse/fuse/request_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/request_linux.go new file mode 100644 index 00000000..b7d62652 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/request_linux.go @@ -0,0 +1,9 @@ +package fuse + +const outputHeaderSize = 160 + +const ( + _FUSE_KERNEL_VERSION = 7 + _MINIMUM_MINOR_VERSION = 12 + _OUR_MINOR_VERSION = 23 +) diff --git a/vendor/github.com/hanwen/go-fuse/fuse/server.go b/vendor/github.com/hanwen/go-fuse/fuse/server.go new file mode 100644 index 00000000..cc597c3e --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/server.go @@ -0,0 +1,519 @@ +package fuse + +import ( + "fmt" + "log" + "os" + "path/filepath" + "runtime" + "strings" + "sync" + "syscall" + "time" + "unsafe" +) + +const ( + // The kernel caps writes at 128k. + MAX_KERNEL_WRITE = 128 * 1024 +) + +// Server contains the logic for reading from the FUSE device and +// translating it to RawFileSystem interface calls. +type Server struct { + // Empty if unmounted. + mountPoint string + fileSystem RawFileSystem + + // writeMu serializes close and notify writes + writeMu sync.Mutex + + // I/O with kernel and daemon. + mountFd int + + // Dump debug info onto stdout. + debug bool + + latencies LatencyMap + + opts *MountOptions + + started chan struct{} + + // Pool for request structs. + reqPool sync.Pool + + // Pool for raw requests data + readPool sync.Pool + reqMu sync.Mutex + reqReaders int + kernelSettings InitIn + + singleReader bool + canSplice bool + loops sync.WaitGroup +} + +func (ms *Server) SetDebug(dbg bool) { + ms.debug = dbg +} + +// KernelSettings returns the Init message from the kernel, so +// filesystems can adapt to availability of features of the kernel +// driver. +func (ms *Server) KernelSettings() InitIn { + ms.reqMu.Lock() + s := ms.kernelSettings + ms.reqMu.Unlock() + + return s +} + +const _MAX_NAME_LEN = 20 + +// This type may be provided for recording latencies of each FUSE +// operation. +type LatencyMap interface { + Add(name string, dt time.Duration) +} + +// RecordLatencies switches on collection of timing for each request +// coming from the kernel.P assing a nil argument switches off the +func (ms *Server) RecordLatencies(l LatencyMap) { + ms.latencies = l +} + +// Unmount calls fusermount -u on the mount. This has the effect of +// shutting down the filesystem. After the Server is unmounted, it +// should be discarded. +func (ms *Server) Unmount() (err error) { + if ms.mountPoint == "" { + return nil + } + delay := time.Duration(0) + for try := 0; try < 5; try++ { + err = unmount(ms.mountPoint) + if err == nil { + break + } + + // Sleep for a bit. This is not pretty, but there is + // no way we can be certain that the kernel thinks all + // open files have already been closed. + delay = 2*delay + 5*time.Millisecond + time.Sleep(delay) + } + if err != nil { + return + } + // Wait for event loops to exit. + ms.loops.Wait() + ms.mountPoint = "" + return err +} + +// NewServer creates a server and attaches it to the given directory. +func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server, error) { + if opts == nil { + opts = &MountOptions{ + MaxBackground: _DEFAULT_BACKGROUND_TASKS, + } + } + o := *opts + if o.SingleThreaded { + fs = NewLockingRawFileSystem(fs) + } + + if o.Buffers == nil { + o.Buffers = defaultBufferPool + } + if o.MaxWrite < 0 { + o.MaxWrite = 0 + } + if o.MaxWrite == 0 { + o.MaxWrite = 1 << 16 + } + if o.MaxWrite > MAX_KERNEL_WRITE { + o.MaxWrite = MAX_KERNEL_WRITE + } + opts = &o + ms := &Server{ + fileSystem: fs, + started: make(chan struct{}), + opts: &o, + // OSX has races when multiple routines read from the + // FUSE device: on unmount, sometime some reads do not + // error-out, meaning that unmount will hang. + singleReader: runtime.GOOS == "darwin", + } + ms.reqPool.New = func() interface{} { return new(request) } + ms.readPool.New = func() interface{} { return make([]byte, o.MaxWrite+PAGESIZE) } + optStrs := opts.Options + if opts.AllowOther { + optStrs = append(optStrs, "allow_other") + } + + name := opts.Name + if name == "" { + name = ms.fileSystem.String() + l := len(name) + if l > _MAX_NAME_LEN { + l = _MAX_NAME_LEN + } + name = strings.Replace(name[:l], ",", ";", -1) + } + optStrs = append(optStrs, "subtype="+name) + + fsname := opts.FsName + if len(fsname) > 0 { + optStrs = append(optStrs, "fsname="+fsname) + } + + mountPoint = filepath.Clean(mountPoint) + if !filepath.IsAbs(mountPoint) { + cwd, err := os.Getwd() + if err != nil { + return nil, err + } + mountPoint = filepath.Clean(filepath.Join(cwd, mountPoint)) + } + fd, err := mount(mountPoint, strings.Join(optStrs, ",")) + if err != nil { + return nil, err + } + + ms.fileSystem.Init(ms) + ms.mountPoint = mountPoint + ms.mountFd = fd + return ms, nil +} + +// DebugData returns internal status information for debugging +// purposes. +func (ms *Server) DebugData() string { + var r int + ms.reqMu.Lock() + r = ms.reqReaders + ms.reqMu.Unlock() + + return fmt.Sprintf("readers: %d", r) +} + +// What is a good number? Maybe the number of CPUs? +const _MAX_READERS = 2 + +// handleEINTR retries the given function until it doesn't return syscall.EINTR. +// This is similar to the HANDLE_EINTR() macro from Chromium ( see +// https://code.google.com/p/chromium/codesearch#chromium/src/base/posix/eintr_wrapper.h +// ) and the TEMP_FAILURE_RETRY() from glibc (see +// https://www.gnu.org/software/libc/manual/html_node/Interrupted-Primitives.html +// ). +// +// Don't use handleEINTR() with syscall.Close(); see +// https://code.google.com/p/chromium/issues/detail?id=269623 . +func handleEINTR(fn func() error) (err error) { + for { + err = fn() + if err != syscall.EINTR { + break + } + } + return +} + +// Returns a new request, or error. In case exitIdle is given, returns +// nil, OK if we have too many readers already. +func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) { + ms.reqMu.Lock() + if ms.reqReaders > _MAX_READERS { + ms.reqMu.Unlock() + return nil, OK + } + req = ms.reqPool.Get().(*request) + dest := ms.readPool.Get().([]byte) + ms.reqReaders++ + ms.reqMu.Unlock() + + var n int + err := handleEINTR(func() error { + var err error + n, err = syscall.Read(ms.mountFd, dest) + return err + }) + if err != nil { + code = ToStatus(err) + ms.reqPool.Put(req) + ms.reqMu.Lock() + ms.reqReaders-- + ms.reqMu.Unlock() + return nil, code + } + + if ms.latencies != nil { + req.startTime = time.Now() + } + gobbled := req.setInput(dest[:n]) + + ms.reqMu.Lock() + if !gobbled { + ms.readPool.Put(dest) + dest = nil + } + ms.reqReaders-- + if !ms.singleReader && ms.reqReaders <= 0 { + ms.loops.Add(1) + go ms.loop(true) + } + ms.reqMu.Unlock() + + return req, OK +} + +// returnRequest returns a request to the pool of unused requests. +func (ms *Server) returnRequest(req *request) { + ms.recordStats(req) + + if req.bufferPoolOutputBuf != nil { + ms.opts.Buffers.FreeBuffer(req.bufferPoolOutputBuf) + req.bufferPoolOutputBuf = nil + } + + req.clear() + ms.reqMu.Lock() + if req.bufferPoolInputBuf != nil { + ms.readPool.Put(req.bufferPoolInputBuf) + req.bufferPoolInputBuf = nil + } + ms.reqPool.Put(req) + ms.reqMu.Unlock() +} + +func (ms *Server) recordStats(req *request) { + if ms.latencies != nil { + dt := time.Now().Sub(req.startTime) + opname := operationName(req.inHeader.Opcode) + ms.latencies.Add(opname, dt) + } +} + +// Serve initiates the FUSE loop. Normally, callers should run Serve() +// and wait for it to exit, but tests will want to run this in a +// goroutine. +// +// Each filesystem operation executes in a separate goroutine. +func (ms *Server) Serve() { + ms.loops.Add(1) + ms.loop(false) + ms.loops.Wait() + + ms.writeMu.Lock() + syscall.Close(ms.mountFd) + ms.writeMu.Unlock() +} + +func (ms *Server) loop(exitIdle bool) { + defer ms.loops.Done() +exit: + for { + req, errNo := ms.readRequest(exitIdle) + switch errNo { + case OK: + if req == nil { + break exit + } + case ENOENT: + continue + case ENODEV: + // unmount + break exit + default: // some other error? + log.Printf("Failed to read from fuse conn: %v", errNo) + break exit + } + + if ms.singleReader { + go ms.handleRequest(req) + } else { + ms.handleRequest(req) + } + } +} + +func (ms *Server) handleRequest(req *request) { + req.parse() + if req.handler == nil { + req.status = ENOSYS + } + + if req.status.Ok() && ms.debug { + log.Println(req.InputDebug()) + } + + if req.status.Ok() && req.handler.Func == nil { + log.Printf("Unimplemented opcode %v", operationName(req.inHeader.Opcode)) + req.status = ENOSYS + } + + if req.status.Ok() { + req.handler.Func(ms, req) + } + + errNo := ms.write(req) + if errNo != 0 { + log.Printf("writer: Write/Writev failed, err: %v. opcode: %v", + errNo, operationName(req.inHeader.Opcode)) + } + ms.returnRequest(req) +} + +func (ms *Server) allocOut(req *request, size uint32) []byte { + if cap(req.bufferPoolOutputBuf) >= int(size) { + req.bufferPoolOutputBuf = req.bufferPoolOutputBuf[:size] + return req.bufferPoolOutputBuf + } + if req.bufferPoolOutputBuf != nil { + ms.opts.Buffers.FreeBuffer(req.bufferPoolOutputBuf) + } + req.bufferPoolOutputBuf = ms.opts.Buffers.AllocBuffer(size) + return req.bufferPoolOutputBuf +} + +func (ms *Server) write(req *request) Status { + // Forget does not wait for reply. + if req.inHeader.Opcode == _OP_FORGET || req.inHeader.Opcode == _OP_BATCH_FORGET { + return OK + } + + header := req.serializeHeader(req.flatDataSize()) + if ms.debug { + log.Println(req.OutputDebug()) + } + + if header == nil { + return OK + } + + s := ms.systemWrite(req, header) + if req.inHeader.Opcode == _OP_INIT { + close(ms.started) + } + return s +} + +// InodeNotify invalidates the information associated with the inode +// (ie. data cache, attributes, etc.) +func (ms *Server) InodeNotify(node uint64, off int64, length int64) Status { + entry := &NotifyInvalInodeOut{ + Ino: node, + Off: off, + Length: length, + } + req := request{ + inHeader: &InHeader{ + Opcode: _OP_NOTIFY_INODE, + }, + handler: operationHandlers[_OP_NOTIFY_INODE], + status: NOTIFY_INVAL_INODE, + } + req.outData = unsafe.Pointer(entry) + + // Protect against concurrent close. + ms.writeMu.Lock() + result := ms.write(&req) + ms.writeMu.Unlock() + + if ms.debug { + log.Println("Response: INODE_NOTIFY", result) + } + return result +} + +// DeleteNotify notifies the kernel that an entry is removed from a +// directory. In many cases, this is equivalent to EntryNotify, +// except when the directory is in use, eg. as working directory of +// some process. You should not hold any FUSE filesystem locks, as that +// can lead to deadlock. +func (ms *Server) DeleteNotify(parent uint64, child uint64, name string) Status { + if ms.kernelSettings.Minor < 18 { + return ms.EntryNotify(parent, name) + } + + req := request{ + inHeader: &InHeader{ + Opcode: _OP_NOTIFY_DELETE, + }, + handler: operationHandlers[_OP_NOTIFY_DELETE], + status: NOTIFY_INVAL_DELETE, + } + entry := &NotifyInvalDeleteOut{ + Parent: parent, + Child: child, + NameLen: uint32(len(name)), + } + + // Many versions of FUSE generate stacktraces if the + // terminating null byte is missing. + nameBytes := make([]byte, len(name)+1) + copy(nameBytes, name) + nameBytes[len(nameBytes)-1] = '\000' + req.outData = unsafe.Pointer(entry) + req.flatData = nameBytes + + // Protect against concurrent close. + ms.writeMu.Lock() + result := ms.write(&req) + ms.writeMu.Unlock() + + if ms.debug { + log.Printf("Response: DELETE_NOTIFY: %v", result) + } + return result +} + +// EntryNotify should be used if the existence status of an entry +// within a directory changes. You should not hold any FUSE filesystem +// locks, as that can lead to deadlock. +func (ms *Server) EntryNotify(parent uint64, name string) Status { + req := request{ + inHeader: &InHeader{ + Opcode: _OP_NOTIFY_ENTRY, + }, + handler: operationHandlers[_OP_NOTIFY_ENTRY], + status: NOTIFY_INVAL_ENTRY, + } + entry := &NotifyInvalEntryOut{ + Parent: parent, + NameLen: uint32(len(name)), + } + + // Many versions of FUSE generate stacktraces if the + // terminating null byte is missing. + nameBytes := make([]byte, len(name)+1) + copy(nameBytes, name) + nameBytes[len(nameBytes)-1] = '\000' + req.outData = unsafe.Pointer(entry) + req.flatData = nameBytes + + // Protect against concurrent close. + ms.writeMu.Lock() + result := ms.write(&req) + ms.writeMu.Unlock() + + if ms.debug { + log.Printf("Response: ENTRY_NOTIFY: %v", result) + } + return result +} + +var defaultBufferPool BufferPool + +func init() { + defaultBufferPool = NewBufferPool() +} + +// WaitMount waits for the first request to be served. Use this to +// avoid racing between accessing the (empty) mountpoint, and the OS +// trying to setup the user-space mount. +func (ms *Server) WaitMount() { + <-ms.started +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go new file mode 100644 index 00000000..043e51c4 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go @@ -0,0 +1,28 @@ +package fuse + +import ( + "syscall" +) + +func (ms *Server) systemWrite(req *request, header []byte) Status { + if req.flatDataSize() == 0 { + err := handleEINTR(func() error { + _, err := syscall.Write(ms.mountFd, header) + return err + }) + return ToStatus(err) + } + + if req.fdData != nil { + sz := req.flatDataSize() + buf := ms.allocOut(req, uint32(sz)) + req.flatData, req.status = req.fdData.Bytes(buf) + header = req.serializeHeader(len(req.flatData)) + } + + _, err := writev(int(ms.mountFd), [][]byte{header, req.flatData}) + if req.readResult != nil { + req.readResult.Done() + } + return ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/server_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/server_linux.go new file mode 100644 index 00000000..b3fe8dde --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/server_linux.go @@ -0,0 +1,38 @@ +package fuse + +import ( + "log" + "syscall" +) + +func (ms *Server) systemWrite(req *request, header []byte) Status { + if req.flatDataSize() == 0 { + err := handleEINTR(func() error { + _, err := syscall.Write(ms.mountFd, header) + return err + }) + return ToStatus(err) + } + + if req.fdData != nil { + if ms.canSplice { + err := ms.trySplice(header, req, req.fdData) + if err == nil { + req.readResult.Done() + return OK + } + log.Println("trySplice:", err) + } + + sz := req.flatDataSize() + buf := ms.allocOut(req, uint32(sz)) + req.flatData, req.status = req.fdData.Bytes(buf) + header = req.serializeHeader(len(req.flatData)) + } + + _, err := writev(ms.mountFd, [][]byte{header, req.flatData}) + if req.readResult != nil { + req.readResult.Done() + } + return ToStatus(err) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go new file mode 100644 index 00000000..b5a8d5f6 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go @@ -0,0 +1,13 @@ +package fuse + +import ( + "fmt" +) + +func (s *Server) setSplice() { + panic("darwin has no splice.") +} + +func (ms *Server) trySplice(header []byte, req *request, fdData *readResultFd) error { + return fmt.Errorf("unimplemented") +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go new file mode 100644 index 00000000..3fd6dd9f --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go @@ -0,0 +1,93 @@ +package fuse + +import ( + "fmt" + "os" + + "github.com/hanwen/go-fuse/splice" +) + +func (s *Server) setSplice() { + s.canSplice = splice.Resizable() +} + +// trySplice: Zero-copy read from fdData.Fd into /dev/fuse +// +// This is a four-step process: +// +// 1) Splice data form fdData.Fd into the "pair1" pipe buffer --> pair1: [payload] +// Now we know the actual payload length and can +// construct the reply header +// 2) Write header into the "pair2" pipe buffer --> pair2: [header] +// 4) Splice data from "pair1" into "pair2" --> pair2: [header][payload] +// 3) Splice the data from "pair2" into /dev/fuse +// +// This dance is neccessary because header and payload cannot be split across +// two splices and we cannot seek in a pipe buffer. +func (ms *Server) trySplice(header []byte, req *request, fdData *readResultFd) error { + var err error + + // Get a pair of connected pipes + pair1, err := splice.Get() + if err != nil { + return err + } + defer splice.Done(pair1) + + // Grow buffer pipe to requested size + one extra page + // Without the extra page the kernel will block once the pipe is almost full + pair1Sz := fdData.Size() + os.Getpagesize() + if err := pair1.Grow(pair1Sz); err != nil { + return err + } + + // Read data from file + payloadLen, err := pair1.LoadFromAt(fdData.Fd, fdData.Size(), fdData.Off) + + if err != nil { + // TODO - extract the data from splice. + return err + } + + // Get another pair of connected pipes + pair2, err := splice.Get() + if err != nil { + return err + } + defer splice.Done(pair2) + + // Grow pipe to header + actually read size + one extra page + // Without the extra page the kernel will block once the pipe is almost full + header = req.serializeHeader(payloadLen) + total := len(header) + payloadLen + pair2Sz := total + os.Getpagesize() + if err := pair2.Grow(pair2Sz); err != nil { + return err + } + + // Write header into pair2 + n, err := pair2.Write(header) + if err != nil { + return err + } + if n != len(header) { + return fmt.Errorf("Short write into splice: wrote %d, want %d", n, len(header)) + } + + // Write data into pair2 + n, err = pair2.LoadFrom(pair1.ReadFd(), payloadLen) + if err != nil { + return err + } + if n != payloadLen { + return fmt.Errorf("Short splice: wrote %d, want %d", n, payloadLen) + } + + // Write header + data to /dev/fuse + _, err = pair2.WriteTo(uintptr(ms.mountFd), total) + if err != nil { + return err + } + + return nil +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go new file mode 100644 index 00000000..aaf157f0 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go @@ -0,0 +1,135 @@ +package fuse + +import ( + "bytes" + "os" + "syscall" + "unsafe" +) + +// TODO - move these into Go's syscall package. + +func sys_writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, err error) { + n1, _, e1 := syscall.Syscall( + syscall.SYS_WRITEV, + uintptr(fd), uintptr(unsafe.Pointer(iovecs)), uintptr(cnt)) + n = int(n1) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} + +func writev(fd int, packet [][]byte) (n int, err error) { + iovecs := make([]syscall.Iovec, 0, len(packet)) + + for _, v := range packet { + if len(v) == 0 { + continue + } + vec := syscall.Iovec{ + Base: &v[0], + } + vec.SetLen(len(v)) + iovecs = append(iovecs, vec) + } + + sysErr := handleEINTR(func() error { + var err error + n, err = sys_writev(fd, &iovecs[0], len(iovecs)) + return err + }) + if sysErr != nil { + err = os.NewSyscallError("writev", sysErr) + } + return n, err +} + +func getxattr(path string, attr string, dest []byte) (sz int, errno int) { + pathBs := syscall.StringBytePtr(path) + attrBs := syscall.StringBytePtr(attr) + size, _, errNo := syscall.Syscall6( + syscall.SYS_GETXATTR, + uintptr(unsafe.Pointer(pathBs)), + uintptr(unsafe.Pointer(attrBs)), + uintptr(unsafe.Pointer(&dest[0])), + uintptr(len(dest)), + 0, 0) + return int(size), int(errNo) +} + +func GetXAttr(path string, attr string, dest []byte) (value []byte, errno int) { + sz, errno := getxattr(path, attr, dest) + + for sz > cap(dest) && errno == 0 { + dest = make([]byte, sz) + sz, errno = getxattr(path, attr, dest) + } + + if errno != 0 { + return nil, errno + } + + return dest[:sz], errno +} + +func listxattr(path string, dest []byte) (sz int, errno int) { + pathbs := syscall.StringBytePtr(path) + var destPointer unsafe.Pointer + if len(dest) > 0 { + destPointer = unsafe.Pointer(&dest[0]) + } + size, _, errNo := syscall.Syscall( + syscall.SYS_LISTXATTR, + uintptr(unsafe.Pointer(pathbs)), + uintptr(destPointer), + uintptr(len(dest))) + + return int(size), int(errNo) +} + +func ListXAttr(path string) (attributes []string, errno int) { + dest := make([]byte, 0) + sz, errno := listxattr(path, dest) + if errno != 0 { + return nil, errno + } + + for sz > cap(dest) && errno == 0 { + dest = make([]byte, sz) + sz, errno = listxattr(path, dest) + } + + // -1 to drop the final empty slice. + dest = dest[:sz-1] + attributesBytes := bytes.Split(dest, []byte{0}) + attributes = make([]string, len(attributesBytes)) + for i, v := range attributesBytes { + attributes[i] = string(v) + } + return attributes, errno +} + +func Setxattr(path string, attr string, data []byte, flags int) (errno int) { + pathbs := syscall.StringBytePtr(path) + attrbs := syscall.StringBytePtr(attr) + _, _, errNo := syscall.Syscall6( + syscall.SYS_SETXATTR, + uintptr(unsafe.Pointer(pathbs)), + uintptr(unsafe.Pointer(attrbs)), + uintptr(unsafe.Pointer(&data[0])), + uintptr(len(data)), + uintptr(flags), 0) + + return int(errNo) +} + +func Removexattr(path string, attr string) (errno int) { + pathbs := syscall.StringBytePtr(path) + attrbs := syscall.StringBytePtr(attr) + _, _, errNo := syscall.Syscall( + syscall.SYS_REMOVEXATTR, + uintptr(unsafe.Pointer(pathbs)), + uintptr(unsafe.Pointer(attrbs)), 0) + return int(errNo) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go new file mode 100644 index 00000000..69aafb2b --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go @@ -0,0 +1,45 @@ +package fuse + +import ( + "os" + "syscall" + "unsafe" +) + +// TODO - move these into Go's syscall package. + +func sys_writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, err error) { + n1, _, e1 := syscall.Syscall( + syscall.SYS_WRITEV, + uintptr(fd), uintptr(unsafe.Pointer(iovecs)), uintptr(cnt)) + n = int(n1) + if e1 != 0 { + err = syscall.Errno(e1) + } + return n, err +} + +func writev(fd int, packet [][]byte) (n int, err error) { + iovecs := make([]syscall.Iovec, 0, len(packet)) + + for _, v := range packet { + if len(v) == 0 { + continue + } + vec := syscall.Iovec{ + Base: &v[0], + } + vec.SetLen(len(v)) + iovecs = append(iovecs, vec) + } + + sysErr := handleEINTR(func() error { + var err error + n, err = sys_writev(fd, &iovecs[0], len(iovecs)) + return err + }) + if sysErr != nil { + err = os.NewSyscallError("writev", sysErr) + } + return n, err +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/typeprint.go b/vendor/github.com/hanwen/go-fuse/fuse/typeprint.go new file mode 100644 index 00000000..fd68a65e --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/typeprint.go @@ -0,0 +1,5 @@ +package fuse + +func (a *Attr) String() string { + return Print((*Attr)(a)) +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/types.go b/vendor/github.com/hanwen/go-fuse/fuse/types.go new file mode 100644 index 00000000..73b65ba7 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/types.go @@ -0,0 +1,431 @@ +package fuse + +import ( + "syscall" +) + +const PAGESIZE = 4096 + +const ( + _DEFAULT_BACKGROUND_TASKS = 12 +) + +// Status is the errno number that a FUSE call returns to the kernel. +type Status int32 + +const ( + OK = Status(0) + EACCES = Status(syscall.EACCES) + EBUSY = Status(syscall.EBUSY) + EINVAL = Status(syscall.EINVAL) + EIO = Status(syscall.EIO) + ENOENT = Status(syscall.ENOENT) + ENOSYS = Status(syscall.ENOSYS) + ENODATA = Status(syscall.ENODATA) + ENOTDIR = Status(syscall.ENOTDIR) + EPERM = Status(syscall.EPERM) + ERANGE = Status(syscall.ERANGE) + EXDEV = Status(syscall.EXDEV) + EBADF = Status(syscall.EBADF) + ENODEV = Status(syscall.ENODEV) + EROFS = Status(syscall.EROFS) +) + +type ForgetIn struct { + InHeader + + Nlookup uint64 +} + +// batch forget is handled internally. +type _ForgetOne struct { + NodeId uint64 + Nlookup uint64 +} + +// batch forget is handled internally. +type _BatchForgetIn struct { + InHeader + Count uint32 + Dummy uint32 +} + +type MkdirIn struct { + InHeader + Mode uint32 + Umask uint32 +} + +type RenameIn struct { + InHeader + Newdir uint64 +} + +type Rename2In struct { + InHeader + Newdir uint64 + Flags uint32 + Padding uint32 +} + +type LinkIn struct { + InHeader + Oldnodeid uint64 +} + +type Owner struct { + Uid uint32 + Gid uint32 +} + +const ( // SetAttrIn.Valid + FATTR_MODE = (1 << 0) + FATTR_UID = (1 << 1) + FATTR_GID = (1 << 2) + FATTR_SIZE = (1 << 3) + FATTR_ATIME = (1 << 4) + FATTR_MTIME = (1 << 5) + FATTR_FH = (1 << 6) + FATTR_ATIME_NOW = (1 << 7) + FATTR_MTIME_NOW = (1 << 8) + FATTR_LOCKOWNER = (1 << 9) + FATTR_CTIME = (1 << 10) +) + +type SetAttrInCommon struct { + InHeader + + Valid uint32 + Padding uint32 + Fh uint64 + Size uint64 + LockOwner uint64 + Atime uint64 + Mtime uint64 + Ctime uint64 + Atimensec uint32 + Mtimensec uint32 + Ctimensec uint32 + Mode uint32 + Unused4 uint32 + Owner + Unused5 uint32 +} + +const RELEASE_FLUSH = (1 << 0) + +type ReleaseIn struct { + InHeader + Fh uint64 + Flags uint32 + ReleaseFlags uint32 + LockOwner uint64 +} + +type OpenIn struct { + InHeader + Flags uint32 + Mode uint32 +} + +const ( + // OpenOut.Flags + FOPEN_DIRECT_IO = (1 << 0) + FOPEN_KEEP_CACHE = (1 << 1) + FOPEN_NONSEEKABLE = (1 << 2) +) + +type OpenOut struct { + Fh uint64 + OpenFlags uint32 + Padding uint32 +} + +// To be set in InitIn/InitOut.Flags. +const ( + CAP_ASYNC_READ = (1 << 0) + CAP_POSIX_LOCKS = (1 << 1) + CAP_FILE_OPS = (1 << 2) + CAP_ATOMIC_O_TRUNC = (1 << 3) + CAP_EXPORT_SUPPORT = (1 << 4) + CAP_BIG_WRITES = (1 << 5) + CAP_DONT_MASK = (1 << 6) + CAP_SPLICE_WRITE = (1 << 7) + CAP_SPLICE_MOVE = (1 << 8) + CAP_SPLICE_READ = (1 << 9) + CAP_FLOCK_LOCKS = (1 << 10) + CAP_IOCTL_DIR = (1 << 11) + CAP_AUTO_INVAL_DATA = (1 << 12) + CAP_READDIRPLUS = (1 << 13) + CAP_READDIRPLUS_AUTO = (1 << 14) + CAP_ASYNC_DIO = (1 << 15) + CAP_WRITEBACK_CACHE = (1 << 16) + CAP_NO_OPEN_SUPPORT = (1 << 17) +) + +type InitIn struct { + InHeader + + Major uint32 + Minor uint32 + MaxReadAhead uint32 + Flags uint32 +} + +type InitOut struct { + Major uint32 + Minor uint32 + MaxReadAhead uint32 + Flags uint32 + MaxBackground uint16 + CongestionThreshold uint16 + MaxWrite uint32 + TimeGran uint32 + Unused [9]uint32 +} + +type _CuseInitIn struct { + InHeader + Major uint32 + Minor uint32 + Unused uint32 + Flags uint32 +} + +type _CuseInitOut struct { + Major uint32 + Minor uint32 + Unused uint32 + Flags uint32 + MaxRead uint32 + MaxWrite uint32 + DevMajor uint32 + DevMinor uint32 + Spare [10]uint32 +} + +type InterruptIn struct { + InHeader + Unique uint64 +} + +type _BmapIn struct { + InHeader + Block uint64 + Blocksize uint32 + Padding uint32 +} + +type _BmapOut struct { + Block uint64 +} + +const ( + FUSE_IOCTL_COMPAT = (1 << 0) + FUSE_IOCTL_UNRESTRICTED = (1 << 1) + FUSE_IOCTL_RETRY = (1 << 2) +) + +type _IoctlIn struct { + InHeader + Fh uint64 + Flags uint32 + Cmd uint32 + Arg uint64 + InSize uint32 + OutSize uint32 +} + +type _IoctlOut struct { + Result int32 + Flags uint32 + InIovs uint32 + OutIovs uint32 +} + +type _PollIn struct { + InHeader + Fh uint64 + Kh uint64 + Flags uint32 + Padding uint32 +} + +type _PollOut struct { + Revents uint32 + Padding uint32 +} + +type _NotifyPollWakeupOut struct { + Kh uint64 +} + +type WriteOut struct { + Size uint32 + Padding uint32 +} + +type GetXAttrOut struct { + Size uint32 + Padding uint32 +} + +type _FileLock struct { + Start uint64 + End uint64 + Typ uint32 + Pid uint32 +} + +type _LkIn struct { + InHeader + Fh uint64 + Owner uint64 + Lk _FileLock + LkFlags uint32 + Padding uint32 +} + +type _LkOut struct { + Lk _FileLock +} + +// For AccessIn.Mask. +const ( + X_OK = 1 + W_OK = 2 + R_OK = 4 + F_OK = 0 +) + +type AccessIn struct { + InHeader + Mask uint32 + Padding uint32 +} + +type FsyncIn struct { + InHeader + Fh uint64 + FsyncFlags uint32 + Padding uint32 +} + +type OutHeader struct { + Length uint32 + Status int32 + Unique uint64 +} + +type NotifyInvalInodeOut struct { + Ino uint64 + Off int64 + Length int64 +} + +type NotifyInvalEntryOut struct { + Parent uint64 + NameLen uint32 + Padding uint32 +} + +type NotifyInvalDeleteOut struct { + Parent uint64 + Child uint64 + NameLen uint32 + Padding uint32 +} + +const ( + NOTIFY_POLL = -1 + NOTIFY_INVAL_INODE = -2 + NOTIFY_INVAL_ENTRY = -3 + NOTIFY_STORE = -4 + NOTIFY_RETRIEVE = -5 + NOTIFY_INVAL_DELETE = -6 + NOTIFY_CODE_MAX = -6 +) + +type FlushIn struct { + InHeader + Fh uint64 + Unused uint32 + Padding uint32 + LockOwner uint64 +} + +type EntryOut struct { + NodeId uint64 + Generation uint64 + EntryValid uint64 + AttrValid uint64 + EntryValidNsec uint32 + AttrValidNsec uint32 + Attr +} + +type AttrOut struct { + AttrValid uint64 + AttrValidNsec uint32 + Dummy uint32 + Attr +} + +type CreateOut struct { + EntryOut + OpenOut +} + +type Context struct { + Owner + Pid uint32 +} + +type InHeader struct { + Length uint32 + Opcode int32 + Unique uint64 + NodeId uint64 + Context + Padding uint32 +} + +type StatfsOut struct { + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Bsize uint32 + NameLen uint32 + Frsize uint32 + Padding uint32 + Spare [6]uint32 +} + +// _Dirent is what we send to the kernel, but we offer DirEntry and +// DirEntryList to the user. +type _Dirent struct { + Ino uint64 + Off uint64 + NameLen uint32 + Typ uint32 +} + +const ( + READ_LOCKOWNER = (1 << 1) +) + +const ( + WRITE_CACHE = (1 << 0) + WRITE_LOCKOWNER = (1 << 1) +) + +type FallocateIn struct { + InHeader + Fh uint64 + Offset uint64 + Length uint64 + Mode uint32 + Padding uint32 +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go new file mode 100644 index 00000000..162244fd --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go @@ -0,0 +1,131 @@ +package fuse + +type Attr struct { + Ino uint64 + Size uint64 + Blocks uint64 + Atime uint64 + Mtime uint64 + Ctime uint64 + Crtime_ uint64 // OS X + Atimensec uint32 + Mtimensec uint32 + Ctimensec uint32 + Crtimensec_ uint32 // OS X + Mode uint32 + Nlink uint32 + Owner + Rdev uint32 + Flags_ uint32 // OS X +} + +const ( + FATTR_CRTIME = (1 << 28) + FATTR_CHGTIME = (1 << 29) + FATTR_BKUPTIME = (1 << 30) + FATTR_FLAGS = (1 << 31) +) + +type SetAttrIn struct { + SetAttrInCommon + + // OS X only + Bkuptime_ uint64 + Chgtime_ uint64 + Crtime uint64 + BkuptimeNsec uint32 + ChgtimeNsec uint32 + CrtimeNsec uint32 + Flags_ uint32 // see chflags(2) +} + +const ( + FOPEN_PURGE_ATTR = (1 << 30) + FOPEN_PURGE_UBC = (1 << 31) +) + +// compat with linux. +const ( + // Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set. + FUSE_GETATTR_FH = (1 << 0) +) + +type GetAttrIn struct { + InHeader +} + +func (g *GetAttrIn) Flags() uint32 { + return 0 +} + +func (g *GetAttrIn) Fh() uint64 { + return 0 +} + +// Uses OpenIn struct for create. +type CreateIn struct { + InHeader + + Flags uint32 + Mode uint32 +} + +type MknodIn struct { + InHeader + + Mode uint32 + Rdev uint32 +} + +type ReadIn struct { + InHeader + + Fh uint64 + Offset uint64 + Size uint32 + ReadFlags uint32 +} + +type WriteIn struct { + InHeader + Fh uint64 + Offset uint64 + Size uint32 + WriteFlags uint32 +} + +type SetXAttrIn struct { + InHeader + Size uint32 + Flags uint32 + Position uint32 + Padding uint32 +} + +type GetXAttrIn struct { + InHeader + Size uint32 + Padding uint32 + Position uint32 + Padding2 uint32 +} + +const ( + CAP_CASE_INSENSITIVE = (1 << 29) + CAP_VOL_RENAME = (1 << 30) + CAP_XTIMES = (1 << 31) +) + +type GetxtimesOut struct { + Bkuptime uint64 + Crtime uint64 + Bkuptimensec uint32 + Crtimensec uint32 +} + +type ExchangeIn struct { + InHeader + Olddir uint64 + Newdir uint64 + Options uint64 +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/types_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/types_linux.go new file mode 100644 index 00000000..33e4252a --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/types_linux.go @@ -0,0 +1,98 @@ +package fuse + +type Attr struct { + Ino uint64 + Size uint64 + Blocks uint64 + Atime uint64 + Mtime uint64 + Ctime uint64 + Atimensec uint32 + Mtimensec uint32 + Ctimensec uint32 + Mode uint32 + Nlink uint32 + Owner + Rdev uint32 + Blksize uint32 + Padding uint32 +} + +type SetAttrIn struct { + SetAttrInCommon +} + +const ( + // Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set. + FUSE_GETATTR_FH = (1 << 0) +) + +type GetAttrIn struct { + InHeader + + Flags_ uint32 + Dummy uint32 + Fh_ uint64 +} + +// Flags accesses the flags. This is a method, because OSXFuse does not +// have GetAttrIn flags. +func (g *GetAttrIn) Flags() uint32 { + return g.Flags_ +} + +// Fh accesses the file handle. This is a method, because OSXFuse does not +// have GetAttrIn flags. +func (g *GetAttrIn) Fh() uint64 { + return g.Fh_ +} + +type CreateIn struct { + InHeader + Flags uint32 + Mode uint32 + Umask uint32 + Pading uint32 +} + +type MknodIn struct { + InHeader + Mode uint32 + Rdev uint32 + Umask uint32 + Padding uint32 +} + +type ReadIn struct { + InHeader + Fh uint64 + Offset uint64 + Size uint32 + ReadFlags uint32 + LockOwner uint64 + Flags uint32 + Padding uint32 +} + +type WriteIn struct { + InHeader + Fh uint64 + Offset uint64 + Size uint32 + WriteFlags uint32 + LockOwner uint64 + Flags uint32 + Padding uint32 +} + +type SetXAttrIn struct { + InHeader + Size uint32 + Flags uint32 +} + +type GetXAttrIn struct { + InHeader + Size uint32 + Padding uint32 +} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/upgrade.go b/vendor/github.com/hanwen/go-fuse/fuse/upgrade.go new file mode 100644 index 00000000..fce8ee90 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/fuse/upgrade.go @@ -0,0 +1,320 @@ +package fuse + +import ( + "fmt" +) + +// NewRawFileSystem adds the methods missing for implementing a +// RawFileSystem to any object. +func NewRawFileSystem(fs interface{}) RawFileSystem { + return &wrappingFS{fs} +} + +type wrappingFS struct { + fs interface{} +} + +func (fs *wrappingFS) Init(srv *Server) { + if s, ok := fs.fs.(interface { + Init(*Server) + }); ok { + s.Init(srv) + } +} + +func (fs *wrappingFS) String() string { + return fmt.Sprintf("%v", fs.fs) +} + +func (fs *wrappingFS) SetDebug(dbg bool) { + if s, ok := fs.fs.(interface { + SetDebug(bool) + }); ok { + s.SetDebug(dbg) + } +} + +func (fs *wrappingFS) StatFs(header *InHeader, out *StatfsOut) Status { + if s, ok := fs.fs.(interface { + StatFs(header *InHeader, out *StatfsOut) Status + }); ok { + return s.StatFs(header, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Lookup(header *InHeader, name string, out *EntryOut) (code Status) { + if s, ok := fs.fs.(interface { + Lookup(header *InHeader, name string, out *EntryOut) (code Status) + }); ok { + return s.Lookup(header, name, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Forget(nodeID, nlookup uint64) { + if s, ok := fs.fs.(interface { + Forget(nodeID, nlookup uint64) + }); ok { + s.Forget(nodeID, nlookup) + } +} + +func (fs *wrappingFS) GetAttr(input *GetAttrIn, out *AttrOut) (code Status) { + if s, ok := fs.fs.(interface { + GetAttr(input *GetAttrIn, out *AttrOut) (code Status) + }); ok { + return s.GetAttr(input, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Open(input *OpenIn, out *OpenOut) (status Status) { + if s, ok := fs.fs.(interface { + Open(input *OpenIn, out *OpenOut) (status Status) + }); ok { + return s.Open(input, out) + } + return ENOSYS +} + +func (fs *wrappingFS) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) { + if s, ok := fs.fs.(interface { + SetAttr(input *SetAttrIn, out *AttrOut) (code Status) + }); ok { + return s.SetAttr(input, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Readlink(header *InHeader) (out []byte, code Status) { + if s, ok := fs.fs.(interface { + Readlink(header *InHeader) (out []byte, code Status) + }); ok { + return s.Readlink(header) + } + return nil, ENOSYS +} + +func (fs *wrappingFS) Mknod(input *MknodIn, name string, out *EntryOut) (code Status) { + if s, ok := fs.fs.(interface { + Mknod(input *MknodIn, name string, out *EntryOut) (code Status) + }); ok { + return s.Mknod(input, name, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) { + if s, ok := fs.fs.(interface { + Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) + }); ok { + return s.Mkdir(input, name, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Unlink(header *InHeader, name string) (code Status) { + if s, ok := fs.fs.(interface { + Unlink(header *InHeader, name string) (code Status) + }); ok { + return s.Unlink(header, name) + } + return ENOSYS +} + +func (fs *wrappingFS) Rmdir(header *InHeader, name string) (code Status) { + if s, ok := fs.fs.(interface { + Rmdir(header *InHeader, name string) (code Status) + }); ok { + return s.Rmdir(header, name) + } + return ENOSYS +} + +func (fs *wrappingFS) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) { + if s, ok := fs.fs.(interface { + Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) + }); ok { + return s.Symlink(header, pointedTo, linkName, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Rename(input *RenameIn, oldName string, newName string) (code Status) { + if s, ok := fs.fs.(interface { + Rename(input *RenameIn, oldName string, newName string) (code Status) + }); ok { + return s.Rename(input, oldName, newName) + } + return ENOSYS +} + +func (fs *wrappingFS) Link(input *LinkIn, name string, out *EntryOut) (code Status) { + if s, ok := fs.fs.(interface { + Link(input *LinkIn, name string, out *EntryOut) (code Status) + }); ok { + return s.Link(input, name, out) + } + return ENOSYS +} + +func (fs *wrappingFS) GetXAttrSize(header *InHeader, attr string) (size int, code Status) { + if s, ok := fs.fs.(interface { + GetXAttrSize(header *InHeader, attr string) (size int, code Status) + }); ok { + return s.GetXAttrSize(header, attr) + } + return 0, ENOSYS +} + +func (fs *wrappingFS) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { + if s, ok := fs.fs.(interface { + GetXAttrData(header *InHeader, attr string) (data []byte, code Status) + }); ok { + return s.GetXAttrData(header, attr) + } + return nil, ENOSYS +} + +func (fs *wrappingFS) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status { + if s, ok := fs.fs.(interface { + SetXAttr(input *SetXAttrIn, attr string, data []byte) Status + }); ok { + return s.SetXAttr(input, attr, data) + } + return ENOSYS +} + +func (fs *wrappingFS) ListXAttr(header *InHeader) (data []byte, code Status) { + if s, ok := fs.fs.(interface { + ListXAttr(header *InHeader) (data []byte, code Status) + }); ok { + return s.ListXAttr(header) + } + return nil, ENOSYS +} + +func (fs *wrappingFS) RemoveXAttr(header *InHeader, attr string) Status { + if s, ok := fs.fs.(interface { + RemoveXAttr(header *InHeader, attr string) Status + }); ok { + return s.RemoveXAttr(header, attr) + } + return ENOSYS +} + +func (fs *wrappingFS) Access(input *AccessIn) (code Status) { + if s, ok := fs.fs.(interface { + Access(input *AccessIn) (code Status) + }); ok { + return s.Access(input) + } + return ENOSYS +} + +func (fs *wrappingFS) Create(input *CreateIn, name string, out *CreateOut) (code Status) { + if s, ok := fs.fs.(interface { + Create(input *CreateIn, name string, out *CreateOut) (code Status) + }); ok { + return s.Create(input, name, out) + } + return ENOSYS +} + +func (fs *wrappingFS) OpenDir(input *OpenIn, out *OpenOut) (status Status) { + if s, ok := fs.fs.(interface { + OpenDir(input *OpenIn, out *OpenOut) (status Status) + }); ok { + return s.OpenDir(input, out) + } + return ENOSYS +} + +func (fs *wrappingFS) Read(input *ReadIn, buf []byte) (ReadResult, Status) { + if s, ok := fs.fs.(interface { + Read(input *ReadIn, buf []byte) (ReadResult, Status) + }); ok { + return s.Read(input, buf) + } + return nil, ENOSYS +} + +func (fs *wrappingFS) Release(input *ReleaseIn) { + if s, ok := fs.fs.(interface { + Release(input *ReleaseIn) + }); ok { + s.Release(input) + } +} + +func (fs *wrappingFS) Write(input *WriteIn, data []byte) (written uint32, code Status) { + if s, ok := fs.fs.(interface { + Write(input *WriteIn, data []byte) (written uint32, code Status) + }); ok { + return s.Write(input, data) + } + return 0, ENOSYS +} + +func (fs *wrappingFS) Flush(input *FlushIn) Status { + if s, ok := fs.fs.(interface { + Flush(input *FlushIn) Status + }); ok { + return s.Flush(input) + } + return OK +} + +func (fs *wrappingFS) Fsync(input *FsyncIn) (code Status) { + if s, ok := fs.fs.(interface { + Fsync(input *FsyncIn) (code Status) + }); ok { + return s.Fsync(input) + } + return ENOSYS +} + +func (fs *wrappingFS) ReadDir(input *ReadIn, l *DirEntryList) Status { + if s, ok := fs.fs.(interface { + ReadDir(input *ReadIn, l *DirEntryList) Status + }); ok { + return s.ReadDir(input, l) + } + return ENOSYS +} + +func (fs *wrappingFS) ReadDirPlus(input *ReadIn, l *DirEntryList) Status { + if s, ok := fs.fs.(interface { + ReadDirPlus(input *ReadIn, l *DirEntryList) Status + }); ok { + return s.ReadDirPlus(input, l) + } + return ENOSYS +} + +func (fs *wrappingFS) ReleaseDir(input *ReleaseIn) { + if s, ok := fs.fs.(interface { + ReleaseDir(input *ReleaseIn) + }); ok { + s.ReleaseDir(input) + } +} + +func (fs *wrappingFS) FsyncDir(input *FsyncIn) (code Status) { + if s, ok := fs.fs.(interface { + FsyncDir(input *FsyncIn) (code Status) + }); ok { + return s.FsyncDir(input) + } + return ENOSYS +} + +func (fs *wrappingFS) Fallocate(in *FallocateIn) (code Status) { + if s, ok := fs.fs.(interface { + Fallocate(in *FallocateIn) (code Status) + }); ok { + return s.Fallocate(in) + } + return ENOSYS +} diff --git a/vendor/github.com/hanwen/go-fuse/splice/copy.go b/vendor/github.com/hanwen/go-fuse/splice/copy.go new file mode 100644 index 00000000..b34e79be --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/splice/copy.go @@ -0,0 +1,66 @@ +package splice + +import ( + "io" + "os" +) + +func SpliceCopy(dst *os.File, src *os.File, p *Pair) (int64, error) { + total := int64(0) + + for { + n, err := p.LoadFrom(src.Fd(), p.size) + if err != nil { + return total, err + } + if n == 0 { + break + } + m, err := p.WriteTo(dst.Fd(), n) + total += int64(m) + if err != nil { + return total, err + } + if m < n { + return total, err + } + if int(n) < p.size { + break + } + } + + return total, nil +} + +// Argument ordering follows io.Copy. +func CopyFile(dstName string, srcName string, mode int) error { + src, err := os.Open(srcName) + if err != nil { + return err + } + defer src.Close() + + dst, err := os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(mode)) + if err != nil { + return err + } + defer dst.Close() + + return CopyFds(dst, src) +} + +func CopyFds(dst *os.File, src *os.File) (err error) { + p, err := splicePool.get() + if p != nil { + p.Grow(256 * 1024) + _, err := SpliceCopy(dst, src, p) + splicePool.done(p) + return err + } else { + _, err = io.Copy(dst, src) + } + if err == io.EOF { + err = nil + } + return err +} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pair.go b/vendor/github.com/hanwen/go-fuse/splice/pair.go new file mode 100644 index 00000000..1fb7b286 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/splice/pair.go @@ -0,0 +1,64 @@ +package splice + +import ( + "fmt" + "os" +) + +type Pair struct { + r, w *os.File + size int +} + +func (p *Pair) MaxGrow() { + for p.Grow(2*p.size) == nil { + } +} + +func (p *Pair) Grow(n int) error { + if n <= p.size { + return nil + } + if !resizable { + return fmt.Errorf("splice: want %d bytes, but not resizable", n) + } + if n > maxPipeSize { + return fmt.Errorf("splice: want %d bytes, max pipe size %d", n, maxPipeSize) + } + + newsize, errNo := fcntl(p.r.Fd(), F_SETPIPE_SZ, n) + if errNo != 0 { + return fmt.Errorf("splice: fcntl returned %v", errNo) + } + p.size = newsize + return nil +} + +func (p *Pair) Cap() int { + return p.size +} + +func (p *Pair) Close() error { + err1 := p.r.Close() + err2 := p.w.Close() + if err1 != nil { + return err1 + } + return err2 +} + +func (p *Pair) Read(d []byte) (n int, err error) { + return p.r.Read(d) +} + +func (p *Pair) ReadFd() uintptr { + return p.r.Fd() +} + +func (p *Pair) WriteFd() uintptr { + return p.w.Fd() +} + +func (p *Pair) Write(d []byte) (n int, err error) { + return p.w.Write(d) +} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go b/vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go new file mode 100644 index 00000000..8cd7f278 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go @@ -0,0 +1,18 @@ +package splice + +import () + +func (p *Pair) LoadFromAt(fd uintptr, sz int, off int64) (int, error) { + panic("not implemented") + return 0, nil +} + +func (p *Pair) LoadFrom(fd uintptr, sz int) (int, error) { + panic("not implemented") + return 0, nil +} + +func (p *Pair) WriteTo(fd uintptr, n int) (int, error) { + panic("not implemented") + return 0, nil +} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pair_linux.go b/vendor/github.com/hanwen/go-fuse/splice/pair_linux.go new file mode 100644 index 00000000..5e27d1f0 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/splice/pair_linux.go @@ -0,0 +1,33 @@ +package splice + +import ( + "fmt" + "os" + "syscall" +) + +func (p *Pair) LoadFromAt(fd uintptr, sz int, off int64) (int, error) { + n, err := syscall.Splice(int(fd), &off, int(p.w.Fd()), nil, sz, 0) + return int(n), err +} + +func (p *Pair) LoadFrom(fd uintptr, sz int) (int, error) { + if sz > p.size { + return 0, fmt.Errorf("LoadFrom: not enough space %d, %d", + sz, p.size) + } + + n, err := syscall.Splice(int(fd), nil, int(p.w.Fd()), nil, sz, 0) + if err != nil { + err = os.NewSyscallError("Splice load from", err) + } + return int(n), err +} + +func (p *Pair) WriteTo(fd uintptr, n int) (int, error) { + m, err := syscall.Splice(int(p.r.Fd()), nil, int(fd), nil, int(n), 0) + if err != nil { + err = os.NewSyscallError("Splice write", err) + } + return int(m), err +} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pool.go b/vendor/github.com/hanwen/go-fuse/splice/pool.go new file mode 100644 index 00000000..28c3911f --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/splice/pool.go @@ -0,0 +1,115 @@ +package splice + +import ( + "io" + "sync" +) + +var splicePool *pairPool + +type pairPool struct { + sync.Mutex + unused []*Pair + usedCount int +} + +func ClearSplicePool() { + splicePool.clear() +} + +func Get() (*Pair, error) { + return splicePool.get() +} + +func Total() int { + return splicePool.total() +} + +func Used() int { + return splicePool.used() +} + +// Return pipe pair to pool +func Done(p *Pair) { + splicePool.done(p) +} + +// Closes and discards pipe pair. +func Drop(p *Pair) { + splicePool.drop(p) +} + +func newSplicePairPool() *pairPool { + return &pairPool{} +} + +func (me *pairPool) clear() { + me.Lock() + for _, p := range me.unused { + p.Close() + } + me.unused = me.unused[:0] + me.Unlock() +} + +func (me *pairPool) used() (n int) { + me.Lock() + n = me.usedCount + me.Unlock() + + return n +} + +func (me *pairPool) total() int { + me.Lock() + n := me.usedCount + len(me.unused) + me.Unlock() + return n +} + +func (me *pairPool) drop(p *Pair) { + p.Close() + me.Lock() + me.usedCount-- + me.Unlock() +} + +func (me *pairPool) get() (p *Pair, err error) { + me.Lock() + defer me.Unlock() + + me.usedCount++ + l := len(me.unused) + if l > 0 { + p := me.unused[l-1] + me.unused = me.unused[:l-1] + return p, nil + } + + return newSplicePair() +} + +var discardBuffer [32 * 1024]byte + +func DiscardAll(r io.Reader) { + buf := discardBuffer[:] + for { + n, _ := r.Read(buf) + if n < len(buf) { + break + } + } +} + +func (me *pairPool) done(p *Pair) { + DiscardAll(p.r) + + me.Lock() + me.usedCount-- + me.unused = append(me.unused, p) + me.Unlock() +} + +func init() { + splicePool = newSplicePairPool() +} diff --git a/vendor/github.com/hanwen/go-fuse/splice/splice.go b/vendor/github.com/hanwen/go-fuse/splice/splice.go new file mode 100644 index 00000000..f415e786 --- /dev/null +++ b/vendor/github.com/hanwen/go-fuse/splice/splice.go @@ -0,0 +1,86 @@ +package splice + +// Routines for efficient file to file copying. + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "syscall" +) + +var maxPipeSize int +var resizable bool + +func Resizable() bool { + return resizable +} + +func MaxPipeSize() int { + return maxPipeSize +} + +// From manpage on ubuntu Lucid: +// +// Since Linux 2.6.11, the pipe capacity is 65536 bytes. +const DefaultPipeSize = 16 * 4096 + +func init() { + content, err := ioutil.ReadFile("/proc/sys/fs/pipe-max-size") + if err != nil { + maxPipeSize = DefaultPipeSize + } else { + fmt.Sscan(string(content), &maxPipeSize) + } + + r, w, err := os.Pipe() + if err != nil { + log.Panicf("cannot create pipe: %v", err) + } + sz, errNo := fcntl(r.Fd(), F_GETPIPE_SZ, 0) + resizable = (errNo == 0) + _, errNo = fcntl(r.Fd(), F_SETPIPE_SZ, 2*sz) + resizable = resizable && (errNo == 0) + r.Close() + w.Close() +} + +// copy & paste from syscall. +func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) { + r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), uintptr(arg)) + val = int(r0) + errno = syscall.Errno(e1) + return +} + +const F_SETPIPE_SZ = 1031 +const F_GETPIPE_SZ = 1032 + +func newSplicePair() (p *Pair, err error) { + p = &Pair{} + p.r, p.w, err = os.Pipe() + if err != nil { + return nil, err + } + + errNo := syscall.Errno(0) + for _, f := range []*os.File{p.r, p.w} { + _, errNo = fcntl(f.Fd(), syscall.F_SETFL, syscall.O_NONBLOCK) + if errNo != 0 { + p.Close() + return nil, os.NewSyscallError("fcntl setfl", errNo) + } + } + + p.size, errNo = fcntl(p.r.Fd(), F_GETPIPE_SZ, 0) + if errNo == syscall.EINVAL { + p.size = DefaultPipeSize + return p, nil + } + if errNo != 0 { + p.Close() + return nil, os.NewSyscallError("fcntl getsize", errNo) + } + return p, nil +} From a6a89b540483a48acdd6db1b901d15481be5ec90 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 152/357] fuse: When Activate was called twice, reinitialize the frontend It's possible that backend changed. We didn't enforce frontend to shutdown when no backend exists. Should do that in the future. --- frontend/fusedev/frontend.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index 5e58b023..9b8cf607 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -13,6 +13,12 @@ type Fuse struct { } func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { + if f.fs != nil { + log.Infof("FUSE frontend already activated for %v, shut it down first", name) + if err := f.Shutdown(); err != nil { + return err + } + } log.Infof("Activate FUSE frontend for %v, size %v, sector size %v", name, size, sectorSize) fs, err := start(name, size, sectorSize, rw) if err != nil { @@ -27,5 +33,9 @@ func (f *Fuse) Shutdown() error { return nil } log.Infof("Shutdown FUSE frontend for %v", f.fs.Volume) - return f.fs.Stop() + if err := f.fs.Stop(); err != nil { + return err + } + f.fs = nil + return nil } From 69778a3a98de15cad374fd70927f60543dab5fba Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 153/357] fuse: complete teardown based on system info --- frontend/fusedev/frontend.go | 21 ++----- frontend/fusedev/fuse.go | 116 ++++++++++++++++++++++------------- 2 files changed, 81 insertions(+), 56 deletions(-) diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index 9b8cf607..f975512d 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -13,29 +13,20 @@ type Fuse struct { } func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { - if f.fs != nil { - log.Infof("FUSE frontend already activated for %v, shut it down first", name) - if err := f.Shutdown(); err != nil { - return err - } + f.fs = newFuseFs(name, size, sectorSize, rw) + if err := f.Shutdown(); err != nil { + return err } + log.Infof("Activate FUSE frontend for %v, size %v, sector size %v", name, size, sectorSize) - fs, err := start(name, size, sectorSize, rw) - if err != nil { + if err := f.fs.Start(); err != nil { return err } - f.fs = fs return nil } func (f *Fuse) Shutdown() error { - if f.fs == nil { - return nil - } log.Infof("Shutdown FUSE frontend for %v", f.fs.Volume) - if err := f.fs.Stop(); err != nil { - return err - } - f.fs = nil + f.fs.Stop() return nil } diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 0cac440c..2837a7a9 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -20,8 +20,6 @@ type FuseFs struct { pathfs.FileSystem Volume string file *FuseFile - lodev string - dev string } type FuseFile struct { @@ -41,8 +39,8 @@ var ( log = logrus.WithFields(logrus.Fields{"pkg": "fusedev"}) ) -func start(name string, size, sectorSize int64, rw types.ReaderWriterAt) (*FuseFs, error) { - fs := &FuseFs{ +func newFuseFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *FuseFs { + return &FuseFs{ FileSystem: pathfs.NewDefaultFileSystem(), Volume: name, file: &FuseFile{ @@ -52,9 +50,17 @@ func start(name string, size, sectorSize int64, rw types.ReaderWriterAt) (*FuseF SectorSize: sectorSize, }, } + +} + +func (fs *FuseFs) Start() error { newFs := pathfs.NewPathNodeFs(fs, nil) - server, _, err := nodefs.MountRoot(fs.GetMountDir(), newFs.Root(), nil) + mountDir := fs.GetMountDir() + if err := os.MkdirAll(mountDir, 0700); err != nil { + log.Fatal("Cannot create directory ", mountDir) + } + server, _, err := nodefs.MountRoot(mountDir, newFs.Root(), nil) /* conn := nodefs.NewFileSystemConnector(newFs.Root(), nil) opts := &fuse.MountOptions{ @@ -64,26 +70,44 @@ func start(name string, size, sectorSize int64, rw types.ReaderWriterAt) (*FuseF server, err := fuse.NewServer(conn.RawFS(), fs.GetMountDir(), opts) */ if err != nil { - return nil, err + return err } // This will be stopped when umount happens go server.Serve() if err := fs.createDev(); err != nil { - return nil, err + return err } - return fs, nil + return nil +} +func (fs *FuseFs) Stop() { + fs.removeDev() + fs.umountFuse() } -func (fs *FuseFs) Stop() error { - if err := fs.removeDev(); err != nil { - return err +func (fs *FuseFs) getDev() string { + return filepath.Join(DevPath, fs.Volume) +} + +func (fs *FuseFs) getLoopbackDev() (string, error) { + devs, err := fs.getLoopbackDevs() + if err != nil { + return "", err } - if err := fs.umountFuse(); err != nil { - return err + if len(devs) != 1 { + return "", fmt.Errorf("Found more than one loopback devices %v", devs) } - return nil + return devs[0], nil +} + +func (fs *FuseFs) getLoopbackDevs() ([]string, error) { + filePath := fs.getImageFileFullPath() + devs, err := util.ListLoopbackDevice(filePath) + if err != nil { + return nil, err + } + return devs, nil } func (fs *FuseFs) createDev() error { @@ -91,7 +115,7 @@ func (fs *FuseFs) createDev() error { log.Fatalln("Cannot create directory ", DevPath) } - dev := filepath.Join(DevPath, fs.Volume) + dev := fs.getDev() if _, err := os.Stat(dev); err == nil { return fmt.Errorf("Device %s already exists, can not create", dev) @@ -115,11 +139,16 @@ func (fs *FuseFs) createDev() error { return fmt.Errorf("Fail to wait for %v", path) } - logrus.Infof("Attaching loopback device %s", fs.lodev) - lodev, err := util.AttachLoopbackDevice(path, false) + logrus.Infof("Attaching loopback device") + _, err := util.AttachLoopbackDevice(path, false) if err != nil { return err } + lodev, err := fs.getLoopbackDev() + if err != nil { + return err + } + logrus.Infof("Attached loopback device %v", lodev) stat := unix.Stat_t{} if err := unix.Stat(lodev, &stat); err != nil { @@ -131,45 +160,50 @@ func (fs *FuseFs) createDev() error { if err := mknod(dev, major, minor); err != nil { return err } - fs.lodev = lodev - fs.dev = dev return nil } -func (fs *FuseFs) removeDev() error { - if fs.dev == "" { - return nil +func (fs *FuseFs) removeDev() { + dev := fs.getDev() + logrus.Infof("Removing device %s", dev) + if _, err := os.Stat(dev); err == nil { + if err := remove(dev); err != nil { + logrus.Errorf("Failed to removing device %s, %v", dev, err) + } } - logrus.Infof("Removing device %s", fs.dev) - if _, err := os.Stat(fs.dev); err == nil { - if err := remove(fs.dev); err != nil { - return err + lodevs, err := fs.getLoopbackDevs() + if err != nil { + logrus.Errorf("Failed to get loopback device %v", err) + } + for _, lodev := range lodevs { + logrus.Infof("Detaching loopback device %s", lodev) + if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { + logrus.Errorf("Fail to detach loopback device %s: %v", lodev, err) } } - fs.dev = "" +} - logrus.Infof("Detaching loopback device %s", fs.lodev) - if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), fs.lodev); err != nil { - return err +func (fs *FuseFs) umountFuse() { + if fs.isMounted() { + dir := fs.GetMountDir() + logrus.Infof("Umounting %s", dir) + if err := unix.Unmount(dir, 0); err != nil { + logrus.Fatalf("Fail to umounting %s: %v", dir, err) + } } - fs.lodev = "" - return nil } -func (fs *FuseFs) umountFuse() error { - if err := unix.Unmount(fs.GetMountDir(), 0); err != nil { - return err +func (fs *FuseFs) isMounted() bool { + path := fs.GetMountDir() + if _, err := util.Execute("findmnt", []string{path}); err != nil { + return false } - return nil + return true } func (fs *FuseFs) GetMountDir() string { - d := filepath.Join(MountBase, fs.Volume) - if err := os.MkdirAll(d, 0700); err != nil { - log.Fatal("Cannot create directory ", d) - } - return d + return filepath.Join(MountBase, fs.Volume) } func (fs *FuseFs) getImageFileName() string { From 6fdafb67fcf04d75bf5bbf8a69ee30d79976c1b0 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 154/357] fuse: Check for loopback device status before continuing teardown If device is being used, `losetup -d` won't return error. Need to check it and return error instead. Also shutdown device can return error for fuse now. --- frontend/fusedev/frontend.go | 3 +-- frontend/fusedev/fuse.go | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index f975512d..47e06887 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -27,6 +27,5 @@ func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWrit func (f *Fuse) Shutdown() error { log.Infof("Shutdown FUSE frontend for %v", f.fs.Volume) - f.fs.Stop() - return nil + return f.fs.Stop() } diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 2837a7a9..086410bd 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -81,9 +81,14 @@ func (fs *FuseFs) Start() error { return nil } -func (fs *FuseFs) Stop() { - fs.removeDev() - fs.umountFuse() +func (fs *FuseFs) Stop() error { + if err := fs.removeDev(); err != nil { + return err + } + if err := fs.umountFuse(); err != nil { + return err + } + return nil } func (fs *FuseFs) getDev() string { @@ -163,35 +168,44 @@ func (fs *FuseFs) createDev() error { return nil } -func (fs *FuseFs) removeDev() { +func (fs *FuseFs) removeDev() error { dev := fs.getDev() logrus.Infof("Removing device %s", dev) if _, err := os.Stat(dev); err == nil { if err := remove(dev); err != nil { - logrus.Errorf("Failed to removing device %s, %v", dev, err) + return fmt.Errorf("Failed to removing device %s, %v", dev, err) } } lodevs, err := fs.getLoopbackDevs() if err != nil { - logrus.Errorf("Failed to get loopback device %v", err) + return fmt.Errorf("Failed to get loopback device %v", err) } for _, lodev := range lodevs { logrus.Infof("Detaching loopback device %s", lodev) if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { - logrus.Errorf("Fail to detach loopback device %s: %v", lodev, err) + return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) + } + devs, err := util.ListLoopbackDevice(fs.getImageFileFullPath()) + if err != nil { + return err + } + if len(devs) != 0 { + return fmt.Errorf("Loopback device busy, cannot detach device, devices %v remains", devs) } } + return nil } -func (fs *FuseFs) umountFuse() { +func (fs *FuseFs) umountFuse() error { if fs.isMounted() { dir := fs.GetMountDir() logrus.Infof("Umounting %s", dir) if err := unix.Unmount(dir, 0); err != nil { - logrus.Fatalf("Fail to umounting %s: %v", dir, err) + return fmt.Errorf("Fail to umounting %s: %v", dir, err) } } + return nil } func (fs *FuseFs) isMounted() bool { From 7a77d845592ed32aca3490f9acef0d56520c8de2 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 155/357] package: Change simple longhorn frontend to fuse --- package/launch-simple-longhorn | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package/launch-simple-longhorn b/package/launch-simple-longhorn index e8f1c3f8..51acd290 100755 --- a/package/launch-simple-longhorn +++ b/package/launch-simple-longhorn @@ -1,7 +1,4 @@ set -x -modprobe configfs -modprobe target_core_user -mount -t configfs none /sys/kernel/config mount --rbind /host/dev /dev if [ -z $1 ] @@ -14,4 +11,4 @@ volume=$1 longhorn replica --size 1g --listen localhost:9502 /volume/ & sleep 1 -exec longhorn --debug controller --frontend tcmu --replica tcp://localhost:9502 $volume +exec longhorn --debug controller --frontend fuse --replica tcp://localhost:9502 $volume From 8817ea6960965144114b553ecb05c78bad70b862 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 156/357] test: Update integration test with restdev to use fusedev --- integration/data/common.py | 14 ++++++++++---- integration/data/frontend.py | 22 ++++++++++++++++++++++ scripts/integration-test | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index 18ce5c33..a1aa12a2 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -9,7 +9,7 @@ import pytest import cattle -from frontend import restdev +from frontend import restdev, fusedev REPLICA1 = 'tcp://localhost:9502' @@ -29,6 +29,8 @@ BACKING_FILE = 'backing_file.raw' +VOLUME_NAME = 'test-volume' + def _file(f): return path.join(_base(), '../../{}'.format(f)) @@ -57,7 +59,7 @@ def dev(request): REPLICA2 ]) assert v.replicaCount == 2 - d = get_restdev() + d = get_fusedev() return d @@ -81,7 +83,7 @@ def backing_dev(request): BACKED_REPLICA2 ]) assert v.replicaCount == 2 - d = get_restdev() + d = get_fusedev() return d @@ -142,7 +144,11 @@ def open_replica(client, backing_file=None): def get_restdev(): - return restdev("test-volume") + return restdev(VOLUME_NAME) + + +def get_fusedev(): + return fusedev(VOLUME_NAME) def write_dev(dev, offset, data): diff --git a/integration/data/frontend.py b/integration/data/frontend.py index c1942d90..4eac688f 100644 --- a/integration/data/frontend.py +++ b/integration/data/frontend.py @@ -1,8 +1,12 @@ import base64 +from os import path import cattle +LONGHORN_DEV_DIR = '/dev/longhorn' + + class restdev: def __init__(self, volume): @@ -20,3 +24,21 @@ def writeat(self, offset, data): l = len(data) encoded_data = base64.encodestring(data) return self.dev.writeat(offset=offset, length=l, data=encoded_data) + + +class fusedev: + + def __init__(self, volume): + self.dev = path.join(LONGHORN_DEV_DIR, volume) + + def readat(self, offset, length): + with open(self.dev, 'r') as f: + f.seek(offset) + ret = f.read(length) + return ret + + def writeat(self, offset, data): + with open(self.dev, 'r+b') as f: + f.seek(offset) + ret = f.write(data) + return ret diff --git a/scripts/integration-test b/scripts/integration-test index e6d46133..5302b058 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -15,7 +15,7 @@ if [ ! -x ./bin/longhorn ]; then ./scripts/build fi -./bin/longhorn controller --frontend rest --enable-backend file test-volume & +./bin/longhorn controller --frontend fuse --enable-backend file test-volume & ./bin/longhorn replica $temp & ./bin/longhorn replica --listen localhost:9505 $temp2 & From 21ac2c60ebf163bbdc86249737212f14d1d68a38 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 157/357] test: Make sure longhorn setup correctly before continue --- scripts/integration-test | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/integration-test b/scripts/integration-test index 5302b058..60111995 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -16,8 +16,11 @@ if [ ! -x ./bin/longhorn ]; then fi ./bin/longhorn controller --frontend fuse --enable-backend file test-volume & +controller_pid=$! ./bin/longhorn replica $temp & +replica1_pid=$! ./bin/longhorn replica --listen localhost:9505 $temp2 & +replica2_pid=$! # replica with 4MB backing file backing_file=backing_file.raw @@ -30,7 +33,16 @@ cp $backing_qcow2 $temp3 cp $backing_qcow2 $temp4 ./bin/longhorn replica --listen localhost:9602 --backing-file $backing_qcow2 $temp3 & +backing_replica1_pid=$! ./bin/longhorn replica --listen localhost:9605 --backing-file $backing_qcow2 $temp4 & +backing_replica2_pid=$! + +# make sure everything is running before continue integration test +ps $controller_pid +ps $replica1_pid +ps $replica2_pid +ps $backing_replica1_pid +ps $backing_replica2_pid cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; From e164c0f7e245ea70e46489237d5e1d3faf9332c8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 158/357] test: Make sure previous longhorn process stopped before running --- scripts/integration-test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/integration-test b/scripts/integration-test index 60111995..9b2b0fd0 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -3,6 +3,24 @@ set -e killall longhorn ssync || true +running="" +for i in `seq 10` +do + running=`ps aux|grep longhorn|grep -v grep || true` + if [ -z "$running" ] + then + break + fi + echo Wait one more second for longhorn process to stop + sleep 1 +done +if [ "$running" ] +then + echo Failed to wait for longhorn process stop + echo $running + exit -1 +fi + temp=$(mktemp -d) temp2=$(mktemp -d) temp3=$(mktemp -d) From ab13155016e924881f3f74f9b02874fbf059907f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 18:37:54 -0700 Subject: [PATCH 159/357] test: Fix test_beyond_boundary for fuse --- integration/data/test_basic_ops.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/integration/data/test_basic_ops.py b/integration/data/test_basic_ops.py index ac7b3c5d..75a2a4a9 100644 --- a/integration/data/test_basic_ops.py +++ b/integration/data/test_basic_ops.py @@ -1,7 +1,6 @@ import random import pytest -import cattle import common from common import dev # NOQA @@ -23,12 +22,10 @@ def test_beyond_boundary(dev): # NOQA common.verify_data(dev, SIZE - 128, data) # out of bounds - with pytest.raises(cattle.ApiError) as err: + with pytest.raises(IOError) as err: write_dev(dev, SIZE, "1") - assert 'EOF' in str(err.value) - with pytest.raises(cattle.ApiError) as err: - read_dev(dev, SIZE, 1) - assert 'EOF' in str(err.value) + assert 'No space left' in str(err.value) + assert len(read_dev(dev, SIZE, 1)) == 0 # normal writes to verify controller/replica survival for i in range(0, 10): From 6b8e11af1916251eb839cdcf785e4e894841d408 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 20:54:45 -0700 Subject: [PATCH 160/357] build: make integration test for fuse run in the container --- Dockerfile.dapper | 3 +-- scripts/integration-test | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 587f2871..575a4eb1 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -5,8 +5,7 @@ ENV PATH /go/bin:$PATH ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_ENV TAG REPO ENV DAPPER_OUTPUT bin -ENV DAPPER_RUN_ARGS --privileged -ENV DAPPER_RUN_ARGS --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec +ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec -v /dev:/host/dev ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} diff --git a/scripts/integration-test b/scripts/integration-test index 9b2b0fd0..fdfd5b88 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -33,6 +33,12 @@ if [ ! -x ./bin/longhorn ]; then ./scripts/build fi + +if [ -d '/host/dev' ] +then + mount --rbind /host/dev /dev +fi + ./bin/longhorn controller --frontend fuse --enable-backend file test-volume & controller_pid=$! ./bin/longhorn replica $temp & From bbe080f0f082e7f210896ad0eb7dec33079a812a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 13 Jul 2016 22:09:05 -0700 Subject: [PATCH 161/357] test: Clean up the running process after test exit --- scripts/integration-test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/integration-test b/scripts/integration-test index fdfd5b88..a28c834f 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -68,6 +68,8 @@ ps $replica2_pid ps $backing_replica1_pid ps $backing_replica2_pid +trap "kill $controller_pid $replica1_pid $replica2_pid $backing_replica1_pid $backing_replica2_pid" EXIT + cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; if [ -z "$NO_TEST" ]; then From 3fee26143c9a67be9aeef6507df6bed2cde1a056 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sun, 17 Jul 2016 23:45:11 -0700 Subject: [PATCH 162/357] replica: Fix NPE when removing replica Read/write shouldn't happen after replica volume deleted, but it shouldn't result in NPE as well. --- replica/server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/replica/server.go b/replica/server.go index 698b8e7e..54e6b9fe 100644 --- a/replica/server.go +++ b/replica/server.go @@ -238,14 +238,22 @@ func (s *Server) Close() error { func (s *Server) WriteAt(buf []byte, offset int64) (int, error) { s.RLock() + defer s.RUnlock() + + if s.r == nil { + return 0, fmt.Errorf("Volume no longer exist") + } i, err := s.r.WriteAt(buf, offset) - s.RUnlock() return i, err } func (s *Server) ReadAt(buf []byte, offset int64) (int, error) { s.RLock() + defer s.RUnlock() + + if s.r == nil { + return 0, fmt.Errorf("Volume no longer exist") + } i, err := s.r.ReadAt(buf, offset) - s.RUnlock() return i, err } From fd88e4506a6c2658db1b12c6140fa367ce32a7b7 Mon Sep 17 00:00:00 2001 From: jimengliu Date: Mon, 18 Jul 2016 22:58:43 -0700 Subject: [PATCH 163/357] ssync: move dstFile from client cmdline to server cmdline (#206) --- replica/client/client.go | 6 +- replica/directio.go | 19 - replica/replica.go | 9 +- sync/agent/process.go | 4 +- sync/sync.go | 12 +- trash.yml | 2 +- .../github.com/rancher/sparse-tools/README.md | 4 +- .../rancher/sparse-tools/cli/sfold/main.go | 7 +- .../rancher/sparse-tools/cli/ssync/main.go | 87 +-- .../sparse-tools/directfio/directfio.go | 71 --- .../rancher/sparse-tools/log/log.go | 99 --- .../rancher/sparse-tools/sparse/client.go | 591 ++++++------------ .../rancher/sparse-tools/sparse/failpoint.go | 2 +- .../rancher/sparse-tools/sparse/fiemap.go | 116 ++++ .../rancher/sparse-tools/sparse/file.go | 353 ++++++----- .../rancher/sparse-tools/sparse/layout.go | 127 +--- .../sparse-tools/sparse/rest/handlers.go | 182 ++++++ .../sparse-tools/sparse/rest/router.go | 19 + .../sparse-tools/sparse/rest/server.go | 24 + .../rancher/sparse-tools/sparse/server.go | 421 ------------- .../rancher/sparse-tools/sparse/sfold.go | 76 +-- .../rancher/sparse-tools/stats/stats.go | 2 +- .../github.com/rancher/sparse-tools/trash.yml | 13 +- 23 files changed, 839 insertions(+), 1407 deletions(-) delete mode 100644 replica/directio.go delete mode 100644 vendor/github.com/rancher/sparse-tools/directfio/directfio.go delete mode 100644 vendor/github.com/rancher/sparse-tools/log/log.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/fiemap.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/rest/router.go create mode 100644 vendor/github.com/rancher/sparse-tools/sparse/rest/server.go delete mode 100644 vendor/github.com/rancher/sparse-tools/sparse/server.go diff --git a/replica/client/client.go b/replica/client/client.go index c55957f8..5a80de75 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -155,10 +155,11 @@ func (c *ReplicaClient) ReloadReplica() (rest.Replica, error) { return replica, err } -func (c *ReplicaClient) LaunchReceiver() (string, int, error) { +func (c *ReplicaClient) LaunchReceiver(toFilePath string) (string, int, error) { var running agent.Process err := c.post(c.syncAgent+"/processes", &agent.Process{ ProcessType: "sync", + DestFile: toFilePath, }, &running) if err != nil { return "", 0, err @@ -200,13 +201,12 @@ func (c *ReplicaClient) Coalesce(from, to string) error { } } -func (c *ReplicaClient) SendFile(from, to, host string, port int) error { +func (c *ReplicaClient) SendFile(from, host string, port int) error { var running agent.Process err := c.post(c.syncAgent+"/processes", &agent.Process{ ProcessType: "sync", Host: host, SrcFile: from, - DestFile: to, Port: port, }, &running) if err != nil { diff --git a/replica/directio.go b/replica/directio.go deleted file mode 100644 index 514760a4..00000000 --- a/replica/directio.go +++ /dev/null @@ -1,19 +0,0 @@ -package replica - -import ( - "os" - - "github.com/rancher/sparse-tools/directfio" -) - -type directFile struct { - *os.File -} - -func (d *directFile) ReadAt(buf []byte, offset int64) (int, error) { - return directfio.ReadAt(d.File, buf, offset) -} - -func (d *directFile) WriteAt(buf []byte, offset int64) (int, error) { - return directfio.WriteAt(d.File, buf, offset) -} diff --git a/replica/replica.go b/replica/replica.go index ecbc1e8a..7a2094a8 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -15,6 +15,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/deckarep/golang-set" "github.com/rancher/longhorn/types" + "github.com/rancher/sparse-tools/sparse" ) const ( @@ -443,13 +444,7 @@ func (r *Replica) nextFile(parsePattern *regexp.Regexp, pattern, parent string) } func (r *Replica) openFile(name string, flag int) (types.DiffDisk, error) { - f, err := os.OpenFile(r.diskPath(name), syscall.O_DIRECT|os.O_RDWR|os.O_CREATE|flag, 0666) - if err != nil { - return nil, err - } - return &directFile{ - File: f, - }, nil + return sparse.NewDirectFileIoProcessor(r.diskPath(name), os.O_RDWR|flag, 06666, true) } func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, error) { diff --git a/sync/agent/process.go b/sync/agent/process.go index 80241531..67387339 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -182,11 +182,11 @@ func (s *Server) launchSync(p *Process) error { } if p.SrcFile == "" { args = append(args, "-daemon") - } else { - args = append(args, p.SrcFile) if p.DestFile != "" { args = append(args, p.DestFile) } + } else { + args = append(args, p.SrcFile) } cmd := reexec.Command(args...) diff --git a/sync/sync.go b/sync/sync.go index f6fc1be3..1b96b22f 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -318,17 +318,17 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl } func (t *Task) syncFile(from, to string, fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { - host, port, err := toClient.LaunchReceiver() - if err != nil { - return err - } - if to == "" { to = from } + host, port, err := toClient.LaunchReceiver(to) + if err != nil { + return err + } + logrus.Infof("Synchronizing %s to %s@%s:%d", from, to, host, port) - err = fromClient.SendFile(from, to, host, port) + err = fromClient.SendFile(from, host, port) if err != nil { logrus.Infof("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err) } else { diff --git a/trash.yml b/trash.yml index 7b6fa9f5..f2253193 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 2ff044e474e8a863a337ebbee10a3c1413fb1dcb + version: 9cac891ad8a2029146df905ae09622eb1de8b19c - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/README.md b/vendor/github.com/rancher/sparse-tools/README.md index b23dc001..0bb7ce54 100644 --- a/vendor/github.com/rancher/sparse-tools/README.md +++ b/vendor/github.com/rancher/sparse-tools/README.md @@ -1,5 +1,5 @@ -# alphorn -sparse storage slab synchronization, etc. +# sparse-tools +sparse-tools for longhorn storage synchronization. ## Building diff --git a/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go b/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go index 9f695f2f..f1ff3b6b 100644 --- a/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go +++ b/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go @@ -5,12 +5,12 @@ import ( "fmt" "os" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" "github.com/rancher/sparse-tools/sparse" ) func Main() { - defaultNonVerboseLogLevel := log.LevelWarn // set if -verbose is false + defaultNonVerboseLogLevel := log.DebugLevel // set if -verbose is false // Command line parsing verbose := flag.Bool("verbose", false, "verbose mode") flag.Usage = func() { @@ -41,8 +41,7 @@ Examples: if *verbose { fmt.Fprintf(os.Stderr, "Folding %s to %s...\n", srcPath, dstPath) } else { - log.LevelPush(defaultNonVerboseLogLevel) - defer log.LevelPop() + log.SetLevel(defaultNonVerboseLogLevel) } err := sparse.FoldFile(srcPath, dstPath) diff --git a/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go b/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go index 31fe3451..95ecfc05 100644 --- a/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go +++ b/vendor/github.com/rancher/sparse-tools/cli/ssync/main.go @@ -2,84 +2,59 @@ package ssync import ( "flag" - "fmt" - "os" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" "github.com/rancher/sparse-tools/sparse" + "github.com/rancher/sparse-tools/sparse/rest" +) + +const ( + usage = ` +Usage of Ssync is: +sync [] +Examples: +sync -daemon filePath +sync -host remoteHostName filePath` ) func Main() { - defaultVerboseLogLevel := log.LevelInfo // set if -verbose - defaultNonVerboseLogLevel := log.LevelWarn // set if -verbose=false // Command line parsing verbose := flag.Bool("verbose", false, "verbose mode") daemon := flag.Bool("daemon", false, "daemon mode (run on remote host)") - port := flag.Int("port", 5000, "optional daemon port") + port := flag.String("port", "5000", "optional daemon port") timeout := flag.Int("timeout", 120, "optional daemon/client timeout (seconds)") host := flag.String("host", "", "remote host of (requires running daemon)") - flag.Usage = func() { - const usage = "sync []" - const examples = ` -Examples: - sync -daemon - sync -host remote.net file.data` - fmt.Fprintf(os.Stderr, "\nUsage of %s:\n", os.Args[0]) - fmt.Fprintln(os.Stderr, usage) - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, examples) - } + flag.Parse() + if *verbose { + log.SetLevel(log.DebugLevel) + } + args := flag.Args() if *daemon { - // Daemon mode - endpoint := sparse.TCPEndPoint{Host: "" /*bind to all*/, Port: int16(*port)} - if *verbose { - log.LevelPush(defaultVerboseLogLevel) - defer log.LevelPop() - fmt.Fprintln(os.Stderr, "Listening on", endpoint, "...") - } else { - log.LevelPush(defaultNonVerboseLogLevel) - defer log.LevelPop() + if len(args) < 1 { + log.Error(usage) + log.Fatal("missing file path") } + dstPath := args[0] - sparse.Server(endpoint, *timeout) + err := rest.Server(*port, dstPath) + if err != nil { + log.Fatalf("Ssync server failed, err: %s", err) + } } else { - // "local to remote"" file sync mode if len(args) < 1 { - cmdError("missing file path") + log.Error(usage) + log.Fatal("missing file path") } srcPath := args[0] - dstPath := srcPath - if len(args) == 2 { - dstPath = args[1] - } else if len(args) > 2 { - cmdError("too many arguments") - } + log.Infof("Syncing %s to %s:%s...\n", srcPath, *host, *port) - endpoint := sparse.TCPEndPoint{Host: *host, Port: int16(*port)} - if *verbose { - log.LevelPush(defaultVerboseLogLevel) - defer log.LevelPop() - fmt.Fprintf(os.Stderr, "Syncing %s to %s@%s:%d...\n", srcPath, dstPath, endpoint.Host, endpoint.Port) - } else { - log.LevelPush(defaultNonVerboseLogLevel) - defer log.LevelPop() - } - - _, err := sparse.SyncFile(srcPath, endpoint, dstPath, *timeout) + err := sparse.SyncFile(srcPath, *host+":"+*port, *timeout) if err != nil { - log.Info("ssync: error:", err, "exit code 1") - os.Exit(1) + log.Fatalf("Ssync client failed, error: %s", err) } - log.Info("ssync: exit code 0") + log.Info("Ssync client: exit code 0") } } - -func cmdError(msg string) { - fmt.Fprintln(os.Stderr, "Error:", msg) - flag.Usage() - log.Info("ssync: exit code 2") - os.Exit(2) -} diff --git a/vendor/github.com/rancher/sparse-tools/directfio/directfio.go b/vendor/github.com/rancher/sparse-tools/directfio/directfio.go deleted file mode 100644 index d01d6175..00000000 --- a/vendor/github.com/rancher/sparse-tools/directfio/directfio.go +++ /dev/null @@ -1,71 +0,0 @@ -package directfio - -import ( - "os" - "syscall" - "unsafe" -) - -const ( - // what to align the block buffer to - alignment = 4096 - - // BlockSize sic - BlockSize = alignment -) - -// OpenFile open file for direct i/o (syscall.O_DIRECT) -// Use AllocateAligned to avoid extra data fuffer copy -func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { - - return os.OpenFile(name, syscall.O_DIRECT|flag, perm) -} - -// ReadAt read into unaligned data buffer via direct I/O -// Use AllocateAligned to avoid extra data fuffer copy -func ReadAt(file *os.File, data []byte, offset int64) (int, error) { - if alignmentShift(data) == 0 { - return file.ReadAt(data, offset) - } - buf := AllocateAligned(len(data)) - n, err := file.ReadAt(buf, offset) - copy(data, buf) - return n, err -} - -// WriteAt write from unaligned data buffer via direct I/O -// Use AllocateAligned to avoid extra data fuffer copy -func WriteAt(file *os.File, data []byte, offset int64) (int, error) { - if alignmentShift(data) == 0 { - return file.WriteAt(data, offset) - } - // Write unaligned - buf := AllocateAligned(len(data)) - copy(buf, data) - n, err := file.WriteAt(buf, offset) - return n, err -} - -// AllocateAligned returns []byte of size aligned to alignment -func AllocateAligned(size int) []byte { - block := make([]byte, size+alignment) - shift := alignmentShift(block) - offset := 0 - if shift != 0 { - offset = alignment - shift - } - block = block[offset:size] - shift = alignmentShift(block) - if shift != 0 { - panic("Alignment failure") - } - return block -} - -// alignmentShift returns alignment of the block in memory -func alignmentShift(block []byte) int { - if len(block) == 0 { - return 0 - } - return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(alignment-1)) -} diff --git a/vendor/github.com/rancher/sparse-tools/log/log.go b/vendor/github.com/rancher/sparse-tools/log/log.go deleted file mode 100644 index 69be2fcc..00000000 --- a/vendor/github.com/rancher/sparse-tools/log/log.go +++ /dev/null @@ -1,99 +0,0 @@ -package log - -import ( - syslog "log" - "sync" -) - -// Level of logging -type Level int - -// Levels -const ( - LevelTrace Level = 1 + iota - LevelDebug - LevelInfo - LevelWarn - LevelError - LevelFatal -) - -// crude global log level control: -// log everything at this level and above -var logMutex sync.RWMutex -var logLevel = LevelInfo -var logLevelStack []Level - -// LevelPush push current level down the stack and set -func LevelPush(level Level) { - logMutex.Lock() - defer logMutex.Unlock() - - logLevelStack = append(logLevelStack, level) - logLevel = level -} - -// LevelPop pop current level from the stack -func LevelPop() { - logMutex.Lock() - defer logMutex.Unlock() - - len := len(logLevelStack) - logLevel, logLevelStack = logLevelStack[len-1], logLevelStack[:len-1] -} - -// Trace log if trace is greater than current log level -// The finest granularity -func Trace(msg ...interface{}) { - logMutex.RLock() - defer logMutex.RUnlock() - - if LevelTrace >= logLevel { - syslog.Println("D:", msg) - } -} - -// Debug log if debug is greater than current log level -func Debug(msg ...interface{}) { - logMutex.RLock() - defer logMutex.RUnlock() - - if LevelDebug >= logLevel { - syslog.Println("D:", msg) - } -} - -// Info log if info is greater than current log level -func Info(msg ...interface{}) { - logMutex.RLock() - defer logMutex.RUnlock() - - if LevelInfo >= logLevel { - syslog.Println("I:", msg) - } -} - -// Warn log if warn is greater than current log level -func Warn(msg ...interface{}) { - logMutex.RLock() - defer logMutex.RUnlock() - - if LevelWarn >= logLevel { - syslog.Println("W:", msg) - } -} - -// Error log if error is greater than current log level -func Error(msg ...interface{}) { - logMutex.RLock() - defer logMutex.RUnlock() - - if LevelError >= logLevel { - syslog.Println("E:", msg) - } -} - -// Fatal log unconditionally and panic -func Fatal(msg ...interface{}) { - syslog.Fatalln("F:", msg) -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client.go b/vendor/github.com/rancher/sparse-tools/sparse/client.go index e3fd6199..05055da7 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/client.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/client.go @@ -1,472 +1,289 @@ package sparse import ( - "crypto/sha1" - "net" - "os" - "strconv" - "bytes" - - "encoding/binary" - "encoding/gob" - "errors" + "encoding/json" "fmt" + "io/ioutil" + "net/http" + "os" + "strconv" "time" - fio "github.com/rancher/sparse-tools/directfio" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" ) -// HashCollsisionError indicates block hash collision -type HashCollsisionError struct{} - -func (e *HashCollsisionError) Error() string { - return "file hash divergence: storage error or block hash collision" -} +const ( + httpClientTimeout = 5 + numBlocksInBatch = 32 +) -// TCPEndPoint tcp connection address -type TCPEndPoint struct { - Host string - Port int16 +type syncClient struct { + remote string + timeout int + filePath string + fileSize int64 + fileIo FileIoProcessor } const connectionRetries = 5 -const verboseClient = true // SyncFile synchronizes local file to remote host -func SyncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int) (hashLocal []byte, err error) { - for retries := 1; retries >= 0; retries-- { - hashLocal, err = syncFile(localPath, addr, remotePath, timeout, retries > 0) - if err != nil { - if _, ok := err.(*HashCollsisionError); ok { - // retry on HahsCollisionError - log.Warn("SSync: retrying on chunk hash collision...") - continue - } else { - log.Error("SSync error:", err) - } - } - break - } - return -} - -func syncFile(localPath string, addr TCPEndPoint, remotePath string, timeout int, retry bool) ([]byte, error) { - file, err := fio.OpenFile(localPath, os.O_RDONLY, 0) +func SyncFile(localPath string, remote string, timeout int) error { + fileInfo, err := os.Stat(localPath) if err != nil { - log.Error("Failed to open local source file:", localPath) - return nil, err + log.Errorf("Failed to get size of source file: %s, err: %s", localPath, err) + return err } - defer file.Close() + fileSize := fileInfo.Size() + directIO := (fileSize%Blocks == 0) + log.Infof("source file size: %d, setting up directIo: %v", fileSize, directIO) - size, err := file.Seek(0, os.SEEK_END) + var fileIo FileIoProcessor + if directIO { + fileIo, err = NewDirectFileIoProcessor(localPath, os.O_RDONLY, 0) + } else { + fileIo, err = NewBufferedFileIoProcessor(localPath, os.O_RDONLY, 0) + } if err != nil { - log.Error("Failed to get size of local source file:", localPath, err) - return nil, err + log.Error("Failed to open local source file:", localPath) + return err } + defer fileIo.Close() - SetupFileIO(size%Blocks == 0) - - conn := connect(addr.Host, strconv.Itoa(int(addr.Port)), timeout) - if nil == conn { - err = fmt.Errorf("Failed to connect to %v", addr) - log.Error(err) - return nil, err - } - defer conn.Close() - - encoder := gob.NewEncoder(conn) - decoder := gob.NewDecoder(conn) - - // Use unix time as hash salt - salt := make([]byte, binary.MaxVarintLen64) - binary.PutVarint(salt, time.Now().UnixNano()) - status := sendSyncRequest(encoder, decoder, remotePath, size, salt) - if !status { - err = fmt.Errorf("Sync request to %v failed", remotePath) - log.Error(err) - return nil, err - } + client := &syncClient{remote, timeout, localPath, fileSize, fileIo} - abortStream := make(chan error) - layoutStream := make(chan FileInterval, 128) - errStream := make(chan error) + defer client.closeServer() // kill the server no matter success or not, best effort - // Initiate interval loading... - err = loadFileLayout(abortStream, file, layoutStream, errStream) + err = client.syncFileContent(fileIo, fileSize) if err != nil { - log.Error("Failed to retrieve local file layout:", err) - return nil, err + log.Errorf("syncFileContent failed: %s", err) + return err } - fileStream := make(chan FileInterval, 128) - unorderedStream := make(chan HashedDataInterval, 128) - orderedStream := make(chan HashedDataInterval, 128) - - go IntervalSplitter(layoutStream, fileStream) - FileReaderGroup(fileReaders, salt, fileStream, localPath, unorderedStream) - go OrderIntervals("src:", unorderedStream, orderedStream) - - // Get remote file intervals and their hashes - netInStream := make(chan HashedInterval, 128) - netInStreamDone := make(chan bool) - go netDstReceiver(decoder, netInStream, netInStreamDone) - - return processDiff(salt, abortStream, errStream, encoder, decoder, orderedStream, netInStream, netInStreamDone, retry) + return err } -func connect(host, port string, timeout int) net.Conn { - // connect to this socket - endpoint := host + ":" + port - raddr, err := net.ResolveTCPAddr("tcp", endpoint) +func (client *syncClient) syncFileContent(file FileIoProcessor, fileSize int64) error { + exts, err := GetFiemapExtents(file) if err != nil { - log.Fatal("Connection address resolution error:", err) - } - timeStart := time.Now() - timeStop := timeStart.Add(time.Duration(timeout) * time.Second) - for timeNow := timeStart; timeNow.Before(timeStop); timeNow = time.Now() { - conn, err := net.DialTCP("tcp", nil, raddr) - if err == nil { - return conn - } - log.Warn("Failed connection to", endpoint, "Retrying...") - if timeNow != timeStart { - // only sleep after the second attempt to speedup tests - time.Sleep(1 * time.Second) - } + return err } - return nil -} -func sendSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64, salt []byte) bool { - err := encoder.Encode(requestHeader{requestMagic, syncRequestCode}) - if err != nil { - log.Fatal("Client protocol encoder error:", err) - return false - } - err = encoder.Encode(path) + err = client.openServer() if err != nil { - log.Fatal("Client protocol encoder error:", err) - return false - } - err = encoder.Encode(size) - if err != nil { - log.Fatal("Client protocol encoder error:", err) - return false - } - err = encoder.Encode(salt) - if err != nil { - log.Fatal("Client protocol encoder error:", err) - return false + return fmt.Errorf("openServer failed, err: %s", err) } - var ack bool - err = decoder.Decode(&ack) - if err != nil { - log.Fatal("Client protocol decoder error:", err) - return false - } + var lastIntervalEnd int64 + var holeInterval Interval - return ack -} + for _, e := range exts { + interval := Interval{int64(e.Logical), int64(e.Logical + e.Length)} -// Get remote hashed intervals -func netDstReceiver(decoder *gob.Decoder, netInStream chan<- HashedInterval, netInStreamDone chan<- bool) { - status := true - for { - if verboseClient { - log.Debug("Client.netDstReceiver decoding...") - } - var r HashedInterval - err := decoder.Decode(&r) - if err != nil { - log.Fatal("Cient protocol error:", err) - status = false - break - } - // interval := r.Interval - if r.Kind == SparseIgnore { - if verboseClient { - log.Debug("Client.netDstReceiver got ") + // report hole + if lastIntervalEnd < interval.Begin { + holeInterval = Interval{lastIntervalEnd, interval.Begin} + err := client.syncHoleInterval(holeInterval) + if err != nil { + return fmt.Errorf("syncHoleInterval %s failed, err: %s", holeInterval, err) } - break } - if verboseClient { - switch r.Kind { - case SparseData: - log.Debug("Client.netDstReceiver got data", r.FileInterval, "hash[", len(r.Hash), "]") - case SparseHole: - log.Debug("Client.netDstReceiver got hole", r.FileInterval) - } + lastIntervalEnd = interval.End + + // report data + err := client.syncDataInterval(file, interval) + if err != nil { + return fmt.Errorf("syncDataInterval %s failed, err: %s", interval, err) } - netInStream <- r - } - close(netInStream) - netInStreamDone <- status -} -// file reading chunk -type fileChunk struct { - eof bool // end of stream: stop reader - header FileInterval -} + if e.Flags&FIEMAP_EXTENT_LAST != 0 { -// network transfer chunk -type diffChunk struct { - status bool // read file or network send error yield false - header DataInterval -} + // report last hole + if lastIntervalEnd < fileSize { + holeInterval := Interval{lastIntervalEnd, fileSize} -func processDiff(salt []byte, abortStream chan<- error, errStream <-chan error, encoder *gob.Encoder, decoder *gob.Decoder, local <-chan HashedDataInterval, remote <-chan HashedInterval, netInStreamDone <-chan bool, retry bool) (hashLocal []byte, err error) { - // Local: __ _* - // Remote: *_ ** - hashLocal = make([]byte, 0) // empty hash for errors - const concurrentReaders = 4 - netStream := make(chan diffChunk, 128) - netStatus := make(chan netXferStatus) - go networkSender(netStream, encoder, netStatus) - fileHasher := sha1.New() - fileHasher.Write(salt) - - lrange := <-local - rrange := <-remote - for lrange.Len() != 0 { - if rrange.Len() == 0 { - // Copy local tail - if verboseClient { - logData("LHASH", lrange.Data) + // syncing hole interval + err = client.syncHoleInterval(holeInterval) + if err != nil { + return fmt.Errorf("syncHoleInterval %s failed, err: %s", holeInterval, err) + } } - hashFileData(fileHasher, lrange.Len(), lrange.Data) - processFileInterval(lrange, HashedInterval{FileInterval{SparseHole, lrange.Interval}, make([]byte, 0)}, netStream) - lrange = <-local - continue } - // Diff - if verboseClient { - log.Debug("Diff:", lrange.HashedInterval, rrange) - } - if lrange.Begin == rrange.Begin { - if lrange.End > rrange.End { - data := lrange.Data - if len(data) > 0 { - data = lrange.Data[:rrange.Len()] - } - subrange := HashedDataInterval{HashedInterval{FileInterval{lrange.Kind, rrange.Interval}, lrange.Hash}, data} - if verboseClient { - logData("LHASH", subrange.Data) - } + } - hashFileData(fileHasher, subrange.Len(), subrange.Data) - processFileInterval(subrange, rrange, netStream) - if len(data) > 0 { - lrange.Data = lrange.Data[subrange.Len():] - } - lrange.Begin = rrange.End - rrange = <-remote - continue - } else if lrange.End < rrange.End { - if verboseClient { - logData("LHASH", lrange.Data) - } + // special case, the whole file is a hole + if len(exts) == 0 && fileSize != 0 { + holeInterval = Interval{0, fileSize} + log.Infof("The file is a hole: %s", holeInterval) - hashFileData(fileHasher, lrange.Len(), lrange.Data) - processFileInterval(lrange, HashedInterval{FileInterval{rrange.Kind, lrange.Interval}, make([]byte, 0)}, netStream) - rrange.Begin = lrange.End - lrange = <-local - continue - } - if verboseClient { - logData("LHASH", lrange.Data) - } - hashFileData(fileHasher, lrange.Len(), lrange.Data) - processFileInterval(lrange, rrange, netStream) - lrange = <-local - rrange = <-remote - } else { - // Should never happen - log.Fatal("processDiff internal error") - return + // syncing hole interval + err := client.syncHoleInterval(holeInterval) + if err != nil { + return fmt.Errorf("syncHoleInterval %s failed, err: %s", holeInterval, err) } } - log.Info("Finished processing file diff") - status := true - err = <-errStream - if err != nil { - log.Error("Sync client file load aborted:", err) - status = false - } - // make sure we finished consuming dst hashes - status = <-netInStreamDone && status // netDstReceiver finished - log.Info("Finished consuming remote file hashes, status=", status) - - // Send end of transmission - netStream <- diffChunk{true, DataInterval{FileInterval{SparseIgnore, Interval{0, 0}}, make([]byte, 0)}} - - // get network sender status - net := <-netStatus - log.Info("Finished sending file diff of", net.byteCount, "(bytes), status=", net.status) - if !net.status { - err = errors.New("netwoek transfer failure") - return - } + return nil +} - var statusRemote bool - err = decoder.Decode(&statusRemote) - if err != nil { - log.Fatal("Cient protocol remote status error:", err) - return - } - if !statusRemote { - err = errors.New("failure on remote sync site") - return +func (client *syncClient) sendHTTPRequest(method string, action string, interval Interval, data []byte) (*http.Response, error) { + httpClient := &http.Client{Timeout: time.Duration(httpClientTimeout * time.Second)} + + url := fmt.Sprintf("http://%s/v1-ssync/%s", client.remote, action) + + var req *http.Request + var err error + if data != nil { + req, err = http.NewRequest(method, url, bytes.NewBuffer(data)) + } else { + req, err = http.NewRequest(method, url, nil) } - var hashRemote []byte - err = decoder.Decode(&hashRemote) if err != nil { - log.Fatal("Cient protocol remote hash error:", err) - return + return nil, err } - // Compare file hashes - hashLocal = fileHasher.Sum(nil) - if isHashDifferent(hashLocal, hashRemote) || FailPointFileHashMatch() { - log.Warn("hashLocal =", hashLocal) - log.Warn("hashRemote=", hashRemote) - err = &HashCollsisionError{} - } else { - retry = false // success, don't retry anymore - } + req.Header.Add("Accept", "application/json") + + q := req.URL.Query() + q.Add("begin", strconv.FormatInt(interval.Begin, 10)) + q.Add("end", strconv.FormatInt(interval.End, 10)) + req.URL.RawQuery = q.Encode() + + log.Debugf("method: %s, url with query string: %s, data len: %d", method, req.URL.String(), len(data)) + + return httpClient.Do(req) +} - // Final retry negotiation - { - err1 := encoder.Encode(retry) - if err1 != nil { - log.Fatal("Cient protocol remote retry error:", err) +func (client *syncClient) openServer() error { + var err error + var resp *http.Response + + timeStart := time.Now() + timeStop := timeStart.Add(time.Duration(client.timeout) * time.Second) + for timeNow := timeStart; timeNow.Before(timeStop); timeNow = time.Now() { + resp, err = client.sendHTTPRequest("GET", "open", Interval{0, client.fileSize}, nil) + if err == nil { + break } - err1 = decoder.Decode(&statusRemote) - if err1 != nil { - log.Fatal("Cient protocol remote retry status error:", err) + log.Warnf("Failed to open server: %s, Retrying...", client.remote) + if timeNow != timeStart { + // only sleep after the second attempt to speedup tests + time.Sleep(1 * time.Second) } } - return + + if err != nil { + return fmt.Errorf("open failed, err: %s", err) + } + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("resp.StatusCode(%d) != http.StatusOK", resp.StatusCode) + } + resp.Body.Close() + + return nil } -func isHashDifferent(a, b []byte) bool { - return !bytes.Equal(a, b) +func (client *syncClient) closeServer() { + client.sendHTTPRequest("POST", "close", Interval{0, 0}, nil) } -func processFileInterval(local HashedDataInterval, remote HashedInterval, netStream chan<- diffChunk) { - if local.Interval != remote.Interval { - log.Fatal("Sync.processFileInterval range internal error:", local.FileInterval, remote.FileInterval) +func (client *syncClient) syncHoleInterval(holeInterval Interval) error { + resp, err := client.sendHTTPRequest("POST", "sendHole", holeInterval, nil) + if err != nil { + return fmt.Errorf("sendHole failed, err: %s", err) } - if local.Kind != remote.Kind { - // Different intreval types, send the diff - if local.Kind == SparseData && int64(len(local.Data)) != local.FileInterval.Len() { - log.Fatal("Sync.processFileInterval data internal error:", local.FileInterval.Len(), len(local.Data)) - } - netStream <- diffChunk{true, DataInterval{local.FileInterval, local.Data}} - return + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("resp.StatusCode(%d) != http.StatusOK", resp.StatusCode) } + resp.Body.Close() - // The interval types are the same - if SparseHole == local.Kind { - // Process hole, no syncronization is required - local.Kind = SparseIgnore - netStream <- diffChunk{true, DataInterval{local.FileInterval, local.Data}} - return - } + return nil +} - if local.Kind != SparseData { - log.Fatal("Sync.processFileInterval kind internal error:", local.FileInterval) +func (client *syncClient) getServerChecksum(checksumInterval Interval) ([]byte, error) { + resp, err := client.sendHTTPRequest("GET", "getChecksum", checksumInterval, nil) + if err != nil { + return nil, fmt.Errorf("getChecksum failed, err: %s", err) } - // Data file interval - if isHashDifferent(local.Hash, remote.Hash) { - if int64(len(local.Data)) != local.FileInterval.Len() { - log.Fatal("Sync.processFileInterval internal error:", local.FileInterval.Len(), len(local.Data)) - } - netStream <- diffChunk{true, DataInterval{local.FileInterval, local.Data}} - return + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("resp.StatusCode(%d) != http.StatusOK", resp.StatusCode) } + defer resp.Body.Close() - // No diff, just communicate we processed it - //TODO: this apparently can be avoided but requires revision of the protocol - local.Kind = SparseIgnore - netStream <- diffChunk{true, DataInterval{local.FileInterval, make([]byte, 0)}} + return ioutil.ReadAll(resp.Body) } -// prints chan codes and lengths to trace -// - sequence and interleaving of chan processing -// - how much of the chan buffer is used -const traceChannelLoad = false +func (client *syncClient) writeData(dataInterval Interval, data []byte) error { + resp, err := client.sendHTTPRequest("POST", "writeData", dataInterval, data) + if err != nil { + return fmt.Errorf("writeData failed, err: %s", err) + } + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("resp.StatusCode(%d) != http.StatusOK", resp.StatusCode) + } + resp.Body.Close() -type netXferStatus struct { - status bool - byteCount int64 + return nil } -func networkSender(netStream <-chan diffChunk, encoder *gob.Encoder, netStatus chan<- netXferStatus) { - status := true - byteCount := int64(0) - for { - chunk := <-netStream - if 0 == chunk.header.Len() { - // eof: last 0 len header - if verboseClient { - log.Debug("Client.networkSender ") - } - err := encoder.Encode(chunk.header.FileInterval) - if err != nil { - log.Fatal("Client protocol encoder error:", err) - status = false - } - break - } +func (client *syncClient) syncDataInterval(file FileIoProcessor, dataInterval Interval) error { + batch := numBlocksInBatch * Blocks - if !status { - // network error - continue // discard the chunk - } - if !chunk.status { - // read error - status = false - continue // discard the chunk + // Process data in chunks + for offset := dataInterval.Begin; offset < dataInterval.End; { + size := batch + if offset+size > dataInterval.End { + size = dataInterval.End - offset } + batchInterval := Interval{offset, offset + size} - if traceChannelLoad { - fmt.Fprint(os.Stderr, len(netStream), "n") - } + /* + sync the batch data interval: - // Encode and send data to the network - if verboseClient { - log.Debug("Client.networkSender sending:", chunk.header.FileInterval) - } - err := encoder.Encode(chunk.header.FileInterval) + 1. ask server for checksum + 2. if server send back non-zero length checksum, then calculate local checksum and compare + 3. if server checksum sent back is zero length or comparison results differences, send data + */ + body, err := client.getServerChecksum(batchInterval) if err != nil { - log.Fatal("Client protocol encoder error:", err) - status = false - continue - } - if len(chunk.header.Data) == 0 { - continue + log.Errorf("getServerChecksum batchInterval:%s failed, err: %s", batchInterval, err) + return err } - if verboseClient { - log.Debug("Client.networkSender sending data") + var serverCheckSum []byte + if err := json.Unmarshal(body, &serverCheckSum); err != nil { + log.Errorf("json.Unmarshal serverCheckSum failed, err: %s", err) + return err } - if int64(len(chunk.header.Data)) != chunk.header.FileInterval.Len() { - log.Fatal("Client.networkSender sending data internal error:", chunk.header.FileInterval.Len(), len(chunk.header.Data)) - } - err = encoder.Encode(chunk.header.Data) - if err != nil { - log.Fatal("Client protocol encoder error:", err) - status = false - continue + + serverNeedData := true + if len(serverCheckSum) != 0 { + // calculate local checksum for the data batch interval + localCheckSum, err := HashDataInterval(file, batchInterval) + if err != nil { + log.Errorf("HashDataInterval locally: %s failed, err: %s", batchInterval, err) + return err + } + + // compare server checksum with localCheckSum + serverNeedData = !bytes.Equal(serverCheckSum, localCheckSum) } - byteCount += int64(len(chunk.header.Data)) - if traceChannelLoad { - fmt.Fprint(os.Stderr, "N\n") + if serverNeedData { + dataBuffer, err := ReadDataInterval(file, batchInterval) + if err != nil { + log.Errorf("ReadDataInterval for batchInterval: %s failed, err: %s", batchInterval, err) + return err + } + + // send data buffer + log.Debugf("sending dataBuffer size: %d", len(dataBuffer)) + err = client.writeData(batchInterval, dataBuffer) + if err != nil { + log.Errorf("writeData for batchInterval: %s failed, err: %s", batchInterval, err) + return err + } } + offset += batchInterval.Len() } - netStatus <- netXferStatus{status, byteCount} + return nil } diff --git a/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go b/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go index 4d6a2ef4..41cf3762 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/failpoint.go @@ -3,7 +3,7 @@ package sparse import ( "sync" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" ) var failFileHashMatch = false diff --git a/vendor/github.com/rancher/sparse-tools/sparse/fiemap.go b/vendor/github.com/rancher/sparse-tools/sparse/fiemap.go new file mode 100644 index 00000000..3df4af4b --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/fiemap.go @@ -0,0 +1,116 @@ +package sparse + +import ( + "os" + "syscall" + "unsafe" +) + +const ( + FiemapSize = 32 // sizeof(struct fiemap) + ExtentSize = 56 // sizeof(struct Extent) + + // FS_IOC_FIEMAP is defined in : + FS_IOC_FIEMAP = 3223348747 + + // FIEMAP_MAX_OFFSET Defined in : + FIEMAP_MAX_OFFSET = ^uint64(0) + FIEMAP_FLAG_SYNC = 0x0001 // sync file data before map + FIEMAP_FLAG_XATTR = 0x0002 // map extended attribute tree + FIEMAP_FLAG_CACHE = 0x0004 // request caching of the extents + FIEMAP_FLAGS_COMPAT = (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) + FIEMAP_EXTENT_LAST = 0x0001 // Last extent in file. + FIEMAP_EXTENT_UNKNOWN = 0x0002 // Data location unknown. + FIEMAP_EXTENT_DELALLOC = 0x0004 // Location still pending. Sets EXTENT_UNKNOWN. + FIEMAP_EXTENT_ENCODED = 0x0008 // Data can not be read while fs is unmounted + FIEMAP_EXTENT_DATA_ENCRYPTED = 0x0080 // Data is encrypted by fs. Sets EXTENT_NO_BYPASS. + FIEMAP_EXTENT_NOT_ALIGNED = 0x0100 // Extent offsets may not be block aligned. + FIEMAP_EXTENT_DATA_INLINE = 0x0200 // Data mixed with metadata. Sets EXTENT_NOT_ALIGNED. + FIEMAP_EXTENT_DATA_TAIL = 0x0400 // Multiple files in block. Sets EXTENT_NOT_ALIGNED. + FIEMAP_EXTENT_UNWRITTEN = 0x0800 // Space allocated, but no data (i.e. zero). + FIEMAP_EXTENT_MERGED = 0x1000 // File does not natively support extents. Result merged for efficiency. + FIEMAP_EXTENT_SHARED = 0x2000 // Space shared with other files. + + // FALLOC_FL_KEEP_SIZE Defined in : + FALLOC_FL_KEEP_SIZE = 0x01 // default is extend size + FALLOC_FL_PUNCH_HOLE = 0x02 // de-allocates range + FALLOC_FL_NO_HIDE_STAE = 0x04 // reserved codepoint +) + +// based on struct fiemap from +type fiemap struct { + Start uint64 // logical offset (inclusive) at which to start mapping (in) + Length uint64 // logical length of mapping which userspace wants (in) + Flags uint32 // FIEMAP_FLAG_* flags for request (in/out) + MappedExtents uint32 // number of extents that were mapped (out) + ExtentCount uint32 // size of fm_extents array (in) + Reserved uint32 + // Extents [0]Extent // array of mapped extents (out) +} + +// Extent : based on struct fiemap_extent from +type Extent struct { + Logical uint64 // logical offset in bytes for the start of the extent from the beginning of the file + Physical uint64 // physical offset in bytes for the start of the extent from the beginning of the disk + Length uint64 // length in bytes for this extent + Reserved64 [2]uint64 + Flags uint32 // FIEMAP_EXTENT_* flags for this extent + Reserved [3]uint32 +} + +// FiemapFile creates a new type by wrapping up os.File +type FiemapFile struct { + *os.File +} + +// NewFiemapFile : return a new FibmapFile +func NewFiemapFile(f *os.File) FiemapFile { + return FiemapFile{f} +} + +// Fiemap : call FIEMAP ioctl +func (f FiemapFile) Fiemap(size uint32) (uint32, []Extent, syscall.Errno) { + extents := make([]Extent, size+1) + ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&extents[0])) + (ExtentSize - FiemapSize)) + + t := (*fiemap)(ptr) + t.Start = 0 + t.Length = FIEMAP_MAX_OFFSET + t.Flags = FIEMAP_FLAG_SYNC + t.ExtentCount = size + + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FS_IOC_FIEMAP, uintptr(ptr)) + + if size == 0 { + return t.MappedExtents, nil, err + } + return t.MappedExtents, extents[1 : 1+t.MappedExtents], err +} + +func (f FiemapFile) FiemapRegion(numExts uint32, start uint64, length uint64) (uint32, []Extent, syscall.Errno) { + extents := make([]Extent, numExts+1) + ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&extents[0])) + (ExtentSize - FiemapSize)) + + t := (*fiemap)(ptr) + t.Start = start + t.Length = length + t.Flags = FIEMAP_FLAG_SYNC + t.ExtentCount = numExts + + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FS_IOC_FIEMAP, uintptr(ptr)) + + if numExts == 0 { + return t.MappedExtents, nil, err + } + return t.MappedExtents, extents[1 : 1+t.MappedExtents], err +} + +// Fallocate : allocate using fallocate +func (f FiemapFile) Fallocate(offset int64, length int64) error { + return syscall.Fallocate(int(f.Fd()), 0, offset, length) +} + +// PunchHole : punch hole using fallocate +func (f FiemapFile) PunchHole(offset int64, length int64) error { + return syscall.Fallocate(int(f.Fd()), FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE, offset, length) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/file.go b/vendor/github.com/rancher/sparse-tools/sparse/file.go index 12514e3a..50ddb3d9 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/file.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/file.go @@ -1,227 +1,222 @@ package sparse import ( - "crypto/sha1" + "crypto/sha512" + "fmt" + "io" "os" + "syscall" + "unsafe" - "fmt" + log "github.com/Sirupsen/logrus" +) - "sync" +type FileIoProcessor interface { + // File I/O methods for direct or bufferend I/O + ReadAt(data []byte, offset int64) (int, error) + WriteAt(data []byte, offset int64) (int, error) + GetFile() *os.File + Close() error + Sync() error + Truncate(size int64) error + Seek(offset int64, whence int) (ret int64, err error) + Name() string + Stat() (os.FileInfo, error) +} - fio "github.com/rancher/sparse-tools/directfio" - "github.com/rancher/sparse-tools/log" -) +type BufferedFileIoProcessor struct { + *os.File +} -// File I/O methods for direct or bufferend I/O -var fileOpen func(name string, flag int, perm os.FileMode) (*os.File, error) -var fileReadAt func(file *os.File, data []byte, offset int64) (int, error) -var fileWriteAt func(file *os.File, data []byte, offset int64) (int, error) +func NewBufferedFileIoProcessor(name string, flag int, perm os.FileMode, isCreate ...bool) (*BufferedFileIoProcessor, error) { + file, err := os.OpenFile(name, flag, perm) -func fileBufferedOpen(name string, flag int, perm os.FileMode) (*os.File, error) { - return os.OpenFile(name, flag, perm) + // if file does not exist, we need to create it if asked to + if err != nil && len(isCreate) > 0 && isCreate[0] { + file, err = os.Create(name) + } + if err != nil { + return nil, err + } + + return &BufferedFileIoProcessor{file}, nil } -func fileBufferedReadAt(file *os.File, data []byte, offset int64) (int, error) { - return file.ReadAt(data, offset) + +func NewBufferedFileIoProcessorByFP(fp *os.File) *BufferedFileIoProcessor { + return &BufferedFileIoProcessor{fp} } -func fileBufferedWriteAt(file *os.File, data []byte, offset int64) (int, error) { - return file.WriteAt(data, offset) + +func (file *BufferedFileIoProcessor) GetFile() *os.File { + return file.File } -// SetupFileIO Sets up direct file I/O or buffered for small unaligned files -func SetupFileIO(direct bool) { - if direct { - fileOpen = fio.OpenFile - fileReadAt = fio.ReadAt - fileWriteAt = fio.WriteAt - log.Info("Mode: directfio") - } else { - fileOpen = fileBufferedOpen - fileReadAt = fileBufferedReadAt - fileWriteAt = fileBufferedWriteAt - log.Info("Mode: buffered") - } +func (file *BufferedFileIoProcessor) Close() error { + file.File.Sync() + return file.File.Close() } -func loadFileLayout(abortStream <-chan error, file *os.File, layoutStream chan<- FileInterval, errStream chan<- error) error { - size, err := file.Seek(0, os.SEEK_END) - if err != nil { - return err - } - go RetrieveLayoutStream(abortStream, file, Interval{0, size}, layoutStream, errStream) - return nil +type DirectFileIoProcessor struct { + *os.File } -// IntervalSplitter limits file intervals to predefined batch size -func IntervalSplitter(spltterStream <-chan FileInterval, fileStream chan<- FileInterval) { - const batch = 32 * Blocks - for r := range spltterStream { - if verboseServer { - log.Debug("Interval Splitter:", r) - } - switch r.Kind { - case SparseHole: - // Process hole - fileStream <- r - case SparseData: - // Process data in chunks - for offset := r.Begin; offset < r.End; { - size := batch - if offset+size > r.End { - size = r.End - offset - } - interval := Interval{offset, offset + size} - if size == batch && interval.End%batch != 0 { - interval.End = interval.End / batch * batch - } - log.Debug("Interval Splitter data:", interval) - fileStream <- FileInterval{SparseData, interval} - offset += interval.Len() - } - } +const ( + // what to align the block buffer to + alignment = 4096 + + // BlockSize sic + BlockSize = alignment +) + +func NewDirectFileIoProcessor(name string, flag int, perm os.FileMode, isCreate ...bool) (*DirectFileIoProcessor, error) { + file, err := os.OpenFile(name, syscall.O_DIRECT|flag, perm) + + // if failed open existing and isCreate flag is true, we need to create it if asked to + if err != nil && len(isCreate) > 0 && isCreate[0] { + file, err = os.OpenFile(name, os.O_CREATE|syscall.O_DIRECT|flag, perm) } - close(fileStream) + if err != nil { + return nil, err + } + + return &DirectFileIoProcessor{file}, nil } -// HashedInterval FileInterval plus its data hash (to be sent to the client) -type HashedInterval struct { - FileInterval - Hash []byte +func NewDirectFileIoProcessorByFP(fp *os.File) *DirectFileIoProcessor { + return &DirectFileIoProcessor{fp} } -func (i HashedInterval) String() string { - if len(i.Hash) > 0 { - return fmt.Sprintf("%v #%2x%2x %2x%2x", i.FileInterval, i.Hash[0], i.Hash[1], i.Hash[2], i.Hash[3]) +// ReadAt read into unaligned data buffer via direct I/O +// Use AllocateAligned to avoid extra data fuffer copy +func (file *DirectFileIoProcessor) ReadAt(data []byte, offset int64) (int, error) { + if alignmentShift(data) == 0 { + return file.File.ReadAt(data, offset) } - return fmt.Sprintf("%v # ", i.FileInterval) + buf := AllocateAligned(len(data)) + n, err := file.File.ReadAt(buf, offset) + copy(data, buf) + return n, err } -// HashedDataInterval FileInterval plus its hash and data -type HashedDataInterval struct { - HashedInterval - Data []byte +// WriteAt write from unaligned data buffer via direct I/O +// Use AllocateAligned to avoid extra data fuffer copy +func (file *DirectFileIoProcessor) WriteAt(data []byte, offset int64) (int, error) { + if alignmentShift(data) == 0 { + return file.File.WriteAt(data, offset) + } + // Write unaligned + buf := AllocateAligned(len(data)) + copy(buf, data) + n, err := file.File.WriteAt(buf, offset) + return n, err } -// DataInterval FileInterval plus its data -type DataInterval struct { - FileInterval - Data []byte +func (file *DirectFileIoProcessor) GetFile() *os.File { + return file.File } -// FileReaderGroup starts specified number of readers -func FileReaderGroup(count int, salt []byte, fileStream <-chan FileInterval, path string, unorderedStream chan<- HashedDataInterval) { - var wgroup sync.WaitGroup - wgroup.Add(count) - for i := 0; i < count; i++ { - go FileReader(salt, fileStream, path, &wgroup, unorderedStream) +// AllocateAligned returns []byte of size aligned to alignment +func AllocateAligned(size int) []byte { + block := make([]byte, size+alignment) + shift := alignmentShift(block) + offset := 0 + if shift != 0 { + offset = alignment - shift + } + block = block[offset : size+offset] + shift = alignmentShift(block) + if shift != 0 { + panic("Alignment failure") } - go func() { - wgroup.Wait() // all the readers join here - close(unorderedStream) - }() + return block } -// FileWriterGroup starts specified number of writers -func FileWriterGroup(count int, fileStream <-chan DataInterval, path string) *sync.WaitGroup { - var wgroup sync.WaitGroup - wgroup.Add(count) - for i := 0; i < count; i++ { - go FileWriter(fileStream, path, &wgroup) +// alignmentShift returns alignment of the block in memory +func alignmentShift(block []byte) int { + if len(block) == 0 { + return 0 } - return &wgroup + return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(alignment-1)) } -// FileReader supports concurrent file reading -// multiple readres are allowed -func FileReader(salt []byte, fileStream <-chan FileInterval, path string, wgroup *sync.WaitGroup, unorderedStream chan<- HashedDataInterval) { - // open file - file, err := fileOpen(path, os.O_RDONLY, 0) +func ReadDataInterval(file FileIoProcessor, dataInterval Interval) ([]byte, error) { + data := make([]byte, dataInterval.Len()) + n, err := file.ReadAt(data, dataInterval.Begin) if err != nil { - log.Fatal("Failed to open file for reading:", string(path), err) - } - defer file.Close() - - for r := range fileStream { - switch r.Kind { - case SparseHole: - // Process hole - var hash, data []byte - unorderedStream <- HashedDataInterval{HashedInterval{r, hash}, data} - - case SparseData: - // Read file data - data := make([]byte, r.Len()) - status := true - n, err := fileReadAt(file, data, r.Begin) - if err != nil { - status = false - log.Error("File read error", status) - } else if int64(n) != r.Len() { - status = false - log.Error("File read underrun") - } - hasher := sha1.New() - hasher.Write(salt) - hasher.Write(data) - hash := hasher.Sum(nil) - unorderedStream <- HashedDataInterval{HashedInterval{r, hash}, data} + if err == io.EOF { + log.Debugf("have read at the end of file, total read: %d", n) + } else { + errStr := fmt.Sprintf("File to read interval:%s, error: %s", dataInterval, err) + log.Error(errStr) + return nil, fmt.Errorf(errStr) } } - wgroup.Done() // indicate to other readers we are done + return data[:n], nil } -// FileWriter supports concurrent file reading -// add this writer to wgroup before invoking -func FileWriter(fileStream <-chan DataInterval, path string, wgroup *sync.WaitGroup) { - // open file - file, err := fileOpen(path, os.O_WRONLY, 0) +func WriteDataInterval(file FileIoProcessor, dataInterval Interval, data []byte) error { + _, err := file.WriteAt(data, dataInterval.Begin) if err != nil { - log.Fatal("Failed to open file for wroting:", string(path), err) - } - defer file.Close() - - for r := range fileStream { - switch r.Kind { - case SparseHole: - log.Debug("trimming...") - err := PunchHole(file, r.Interval) - if err != nil { - log.Fatal("Failed to trim file") - } - - case SparseData: - log.Debug("writing data...") - _, err = fileWriteAt(file, r.Data, r.Begin) - if err != nil { - log.Fatal("Failed to write file") - } - } + errStr := fmt.Sprintf("Failed to write file interval:%s, error: %s", dataInterval, err) + log.Error(errStr) + return fmt.Errorf(errStr) } - wgroup.Done() + return nil } -// OrderIntervals puts back "out of order" read results -func OrderIntervals(prefix string, unorderedStream <-chan HashedDataInterval, orderedStream chan<- HashedDataInterval) { - pos := int64(0) - m := make(map[int64]HashedDataInterval) // out of order completions - for r := range unorderedStream { - if pos == r.Begin { - // Handle "in order" range - log.Debug(prefix, r) - orderedStream <- r - pos = r.End - } else { - // push "out of order"" range - m[r.Begin] = r - } +func HashDataInterval(file FileIoProcessor, dataInterval Interval) ([]byte, error) { + data, err := ReadDataInterval(file, dataInterval) + if err != nil { + return nil, err + } + sum := sha512.Sum512(data) + return sum[:], nil +} - // check the "out of order" stash for "in order" - for pop, existsNext := m[pos]; len(m) > 0 && existsNext; pop, existsNext = m[pos] { - // pop in order range - log.Debug(prefix, pop) - orderedStream <- pop - delete(m, pos) - pos = pop.End +func GetFiemapExtents(file FileIoProcessor) ([]Extent, error) { + fileInfo, err := file.Stat() + if err != nil { + return nil, err + } + return GetFiemapRegionExts(file, Interval{0, fileInfo.Size()}) +} + +func GetFiemapRegionExts(file FileIoProcessor, interval Interval) ([]Extent, error) { + var exts []Extent + fiemap := NewFiemapFile(file.GetFile()) + + // first call of Fiemap with 0 extent count will actually return total mapped ext counts + // we can use that to allocate extent struct slice to get details of each extent + extCount, _, errno := fiemap.FiemapRegion(0, uint64(interval.Begin), uint64(interval.End-interval.Begin)) + if errno != 0 { + log.Error("failed to call fiemap.Fiemap(0)") + return exts, fmt.Errorf(errno.Error()) + } + + if extCount == 0 { + return exts, nil + } + + _, exts, errno = fiemap.FiemapRegion(extCount, uint64(interval.Begin), uint64(interval.End-interval.Begin)) + if errno != 0 { + log.Error("failed to call fiemap.Fiemap(extCount)") + return exts, fmt.Errorf(errno.Error()) + } + + // The exts returned by File System should be ordered + var lastExtStart uint64 + for i, ext := range exts { + + // if lastExtStart is initialized and this ext start is less than last ext start + if i != 0 && ext.Logical < lastExtStart { + return exts, fmt.Errorf("The exts returned by fiemap are not ordered") } + lastExtStart = ext.Logical } - close(orderedStream) + + // last ext should have the FIEMAP_EXTENT_LAST set, otherwise we don't get all exts + if exts[len(exts)-1].Flags&FIEMAP_EXTENT_LAST == 0 { + return exts, fmt.Errorf("The exts returned by fiemap are not complete") + } + + return exts, nil } diff --git a/vendor/github.com/rancher/sparse-tools/sparse/layout.go b/vendor/github.com/rancher/sparse-tools/sparse/layout.go index 8adc55ab..9f33c736 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/layout.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/layout.go @@ -1,13 +1,11 @@ package sparse import ( - "os" - "syscall" - + "bytes" "fmt" + "os" - "github.com/frostschutz/go-fibmap" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" ) // Interval [Begin, End) is non-inclusive at the End @@ -57,8 +55,8 @@ func (i FileInterval) String() string { return fmt.Sprintf("%s%v", kind, i.Interval) } -// Storage block size in bytes const ( + // Blocks : block size in bytes Blocks int64 = 4 << 10 // 4k ) @@ -87,6 +85,20 @@ const ( fallocFlPunchHole uint32 = 2 ) +func MakeData(interval FileInterval) []byte { + data := make([]byte, interval.Len()) + if SparseData == interval.Kind { + for i := range data { + data[i] = byte(interval.Begin/Blocks + 1) + } + } + return data +} + +func isHashDifferent(a, b []byte) bool { + return !bytes.Equal(a, b) +} + // RetrieveLayoutStream streams sparse file data/hole layout // Based on fiemap // To abort: abortStream <- error @@ -109,7 +121,8 @@ func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, l } for more := true; more && chunk.Len() > 0; { - ext, errno := fibmap.Fiemap(file.Fd(), uint64(chunk.Begin), uint64(chunk.Len()), 1024) + fiemap := NewFiemapFile(file) + _, ext, errno := fiemap.Fiemap(uint32(chunk.Len())) if errno != 0 { close(layoutStream) errStream <- &os.PathError{Op: "Fiemap", Path: file.Name(), Err: errno} @@ -123,7 +136,7 @@ func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, l for _, e := range ext { interval := Interval{int64(e.Logical), int64(e.Logical + e.Length)} log.Debug("Extent:", interval, e.Flags) - if e.Flags&fibmap.FIEMAP_EXTENT_LAST != 0 { + if e.Flags&FIEMAP_EXTENT_LAST != 0 { more = false } if intervalLast.End < interval.Begin { @@ -164,97 +177,6 @@ func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, l return } -// RetrieveLayoutStream0 streams sparse file data/hole layout -// Deprecated; Based on file.seek; use RetrieveLayoutStream instead -// To abort: abortStream <- error -// Check status: err := <- errStream -// Usage: go RetrieveLayoutStream(...) -func RetrieveLayoutStream0(abortStream <-chan error, file *os.File, r Interval, layoutStream chan<- FileInterval, errStream chan<- error) { - curr := r.Begin - - // Data or hole? - offsetData, errData := file.Seek(curr, seekData) - offsetHole, errHole := file.Seek(curr, seekHole) - var interval FileInterval - if errData != nil { - // Hole only - interval = FileInterval{SparseHole, Interval{curr, r.End}} - if interval.Len() > 0 { - layoutStream <- interval - } - close(layoutStream) - errStream <- nil - return - } else if errHole != nil { - // Data only - interval = FileInterval{SparseData, Interval{curr, r.End}} - if interval.Len() > 0 { - layoutStream <- interval - } - close(layoutStream) - errStream <- nil - return - } - - if offsetData < offsetHole { - interval = FileInterval{SparseData, Interval{curr, offsetHole}} - curr = offsetHole - } else { - interval = FileInterval{SparseHole, Interval{curr, offsetData}} - curr = offsetData - } - if interval.Len() > 0 { - layoutStream <- interval - } - - for curr < r.End { - // Check abort condition - select { - case err := <-abortStream: - close(layoutStream) - errStream <- err - return - default: - } - - var whence int - if SparseData == interval.Kind { - whence = seekData - } else { - whence = seekHole - } - - // Note: file.Seek masks syscall.ENXIO hence syscall is used instead - next, errno := syscall.Seek(int(file.Fd()), curr, whence) - if errno != nil { - switch errno { - case syscall.ENXIO: - // no more intervals - next = r.End // close the last interval - default: - // mimic standard "os"" package error handler - close(layoutStream) - errStream <- &os.PathError{Op: "seek", Path: file.Name(), Err: errno} - return - } - } - if SparseData == interval.Kind { - // End of data, handle the last hole if any - interval = FileInterval{SparseHole, Interval{curr, next}} - } else { - // End of hole, handle the last data if any - interval = FileInterval{SparseData, Interval{curr, next}} - } - curr = next - if interval.Len() > 0 { - layoutStream <- interval - } - } - close(layoutStream) - errStream <- nil - return -} - // RetrieveLayout retrieves sparse file hole and data layout func RetrieveLayout(file *os.File, r Interval) ([]FileInterval, error) { layout := make([]FileInterval, 0, 1024) @@ -268,10 +190,3 @@ func RetrieveLayout(file *os.File, r Interval) ([]FileInterval, error) { } return layout, <-errStream } - -// PunchHole in a sparse file, preserve file size -func PunchHole(file *os.File, hole Interval) error { - fd := int(file.Fd()) - mode := fallocFlPunchHole | fallocFlKeepSize - return syscall.Fallocate(fd, mode, hole.Begin, hole.Len()) -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go b/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go new file mode 100644 index 00000000..652a919c --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go @@ -0,0 +1,182 @@ +package rest + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "os" + "strconv" + + log "github.com/Sirupsen/logrus" + "github.com/rancher/sparse-tools/sparse" +) + +func (server *SyncServer) getQueryInterval(request *http.Request) (sparse.Interval, error) { + var interval sparse.Interval + var err error + + queryParams := request.URL.Query() + beginStr := queryParams.Get("begin") // only one value for key begin + endStr := queryParams.Get("end") // only one value for key end + if beginStr == "" || endStr == "" { + err = fmt.Errorf("queryParams begin or end not exist") + return interval, err + } + + begin, err := strconv.ParseInt(beginStr, 10, 64) + if err != nil { + err = fmt.Errorf("strconv.ParseInt(begin) error: %s", err) + return interval, err + } + end, err := strconv.ParseInt(endStr, 10, 64) + if err != nil { + err = fmt.Errorf("strconv.ParseInt(end) error: %s", err) + return interval, err + } + + return sparse.Interval{begin, end}, err +} + +func (server *SyncServer) open(writer http.ResponseWriter, request *http.Request) { + err := server.doOpen(request) + if err != nil { + log.Errorf("open failed, err: %s", err) + http.Error(writer, err.Error(), http.StatusInternalServerError) + return + } + log.Infof("Ssync server opened and ready") +} + +func (server *SyncServer) doOpen(request *http.Request) error { + // get file size + interval, err := server.getQueryInterval(request) + if err != nil { + return fmt.Errorf("server.getQueryInterval failed, err: %s", err) + } + + // if file size is multiple of 4k, then directIo + directIo := (interval.End%sparse.Blocks == 0) + log.Infof("open: receiving fileSize: %d, setting up directIo: %v", interval.End, directIo) + + var fileIo sparse.FileIoProcessor + if directIo { + fileIo, err = sparse.NewDirectFileIoProcessor(server.filePath, os.O_RDWR, 0666, true) + } else { + fileIo, err = sparse.NewBufferedFileIoProcessor(server.filePath, os.O_RDWR, 0666, true) + } + if err != nil { + return fmt.Errorf("open: Failed to open/create local source file, path: %s, err: %s", server.filePath, err) + } + + err = fileIo.Truncate(interval.End) + if err != nil { + return fmt.Errorf("open: Failed to Truncate local source file, path: %s, err: %s", server.filePath, err) + } + + // initialize the server file object + server.fileIo = fileIo + + return nil +} + +func (server *SyncServer) close(writer http.ResponseWriter, request *http.Request) { + if f, ok := writer.(http.Flusher); ok { + f.Flush() + } + + server.fileIo.Close() + log.Infof("Ssync server exit(0)") + os.Exit(0) +} + +func (server *SyncServer) sendHole(writer http.ResponseWriter, request *http.Request) { + err := server.doSendHole(request) + if err != nil { + log.Errorf("sendHole failed, err: %s", err) + http.Error(writer, err.Error(), http.StatusInternalServerError) + } +} + +func (server *SyncServer) doSendHole(request *http.Request) error { + remoteHoleInterval, err := server.getQueryInterval(request) + if err != nil { + return fmt.Errorf("server.getQueryInterval failed, err: %s", err) + } + + fiemap := sparse.NewFiemapFile(server.fileIo.GetFile()) + err = fiemap.PunchHole(remoteHoleInterval.Begin, remoteHoleInterval.Len()) + if err != nil { + return fmt.Errorf("PunchHole: %s error: %s", remoteHoleInterval, err) + } + + return nil +} + +func (server *SyncServer) getChecksum(writer http.ResponseWriter, request *http.Request) { + err := server.doGetChecksum(writer, request) + if err != nil { + log.Errorf("getChecksum failed, err: %s", err) + http.Error(writer, err.Error(), http.StatusInternalServerError) + } +} + +func (server *SyncServer) doGetChecksum(writer http.ResponseWriter, request *http.Request) error { + remoteDataInterval, err := server.getQueryInterval(request) + if err != nil { + return fmt.Errorf("server.getQueryInterval failed, err: %s", err) + } + + var checksum []byte + + // For the region to have valid data, it can only has one extent covering the whole region + exts, err := sparse.GetFiemapRegionExts(server.fileIo, remoteDataInterval) + if len(exts) == 1 && int64(exts[0].Logical) <= remoteDataInterval.Begin && + int64(exts[0].Logical+exts[0].Length) >= remoteDataInterval.End { + + checksum, err = sparse.HashDataInterval(server.fileIo, remoteDataInterval) + if err != nil { + return fmt.Errorf("HashDataInterval locally: %s failed, err: %s", remoteDataInterval, err) + } + } + + outgoingJSON, err := json.Marshal(checksum) + if err != nil { + return fmt.Errorf("json.Marshal(checksum) failed, err: %s", err) + } + + writer.Header().Set("Content-Type", "application/json") + fmt.Fprint(writer, string(outgoingJSON)) + + return nil +} + +func (server *SyncServer) writeData(writer http.ResponseWriter, request *http.Request) { + err := server.doWriteData(request) + if err != nil { + log.Errorf("writeData failed, err: %s", err) + http.Error(writer, err.Error(), http.StatusInternalServerError) + } +} + +func (server *SyncServer) doWriteData(request *http.Request) error { + remoteDataInterval, err := server.getQueryInterval(request) + if err != nil { + return fmt.Errorf("server.getQueryInterval failed, err: %s", err) + } + log.Debugf("writeData: interval: %s", remoteDataInterval) + + data, err := ioutil.ReadAll(io.LimitReader(request.Body, remoteDataInterval.End-remoteDataInterval.Begin)) + if err != nil { + return fmt.Errorf("ioutil.ReadAll(io.LimitReader(r.Body, end-begin)) error: %s", err) + } + + // Write file with received data into the range + err = sparse.WriteDataInterval(server.fileIo, remoteDataInterval, data) + if err != nil { + return fmt.Errorf("WriteDataInterval to file error: %s", err) + } + + return nil +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/rest/router.go b/vendor/github.com/rancher/sparse-tools/sparse/rest/router.go new file mode 100644 index 00000000..262395a9 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/rest/router.go @@ -0,0 +1,19 @@ +package rest + +import "github.com/gorilla/mux" + +//NewRouter creates and configures a mux router +func NewRouter(server *SyncServer) *mux.Router { + + // API framework routes + router := mux.NewRouter().StrictSlash(true) + + // Application + router.HandleFunc("/v1-ssync/getChecksum", server.getChecksum).Methods("GET") + router.HandleFunc("/v1-ssync/open", server.open).Methods("GET") + router.HandleFunc("/v1-ssync/close", server.close).Methods("POST") + router.HandleFunc("/v1-ssync/sendHole", server.sendHole).Methods("POST") + router.HandleFunc("/v1-ssync/writeData", server.writeData).Methods("POST") + + return router +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/rest/server.go b/vendor/github.com/rancher/sparse-tools/sparse/rest/server.go new file mode 100644 index 00000000..e710f0e5 --- /dev/null +++ b/vendor/github.com/rancher/sparse-tools/sparse/rest/server.go @@ -0,0 +1,24 @@ +package rest + +import ( + "net/http" + + log "github.com/Sirupsen/logrus" + "github.com/rancher/sparse-tools/sparse" +) + +type SyncServer struct { + filePath string + fileIo sparse.FileIoProcessor +} + +// TestServer daemon serves only one connection for each test then exits +func TestServer(port string, filePath string, timeout int) { + Server(port, filePath) +} + +func Server(port string, filePath string) error { + log.Infof("Creating Ssync service") + router := NewRouter(&SyncServer{filePath: filePath}) + return http.ListenAndServe(":"+port, router) +} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/server.go b/vendor/github.com/rancher/sparse-tools/sparse/server.go deleted file mode 100644 index aa265229..00000000 --- a/vendor/github.com/rancher/sparse-tools/sparse/server.go +++ /dev/null @@ -1,421 +0,0 @@ -package sparse - -import ( - "crypto/sha1" - "encoding/binary" - "encoding/gob" - "hash" - "net" - "os" - "strconv" - "time" - - "github.com/rancher/sparse-tools/log" -) - -// Server daemon -func Server(addr TCPEndPoint, timeout int) { - server(addr, true /*serve single connection for now*/, timeout) -} - -// TestServer daemon serves only one connection for each test then exits -func TestServer(addr TCPEndPoint, timeout int) { - server(addr, true, timeout) -} - -const fileReaders = 1 -const fileWriters = 1 -const verboseServer = true - -func server(addr TCPEndPoint, serveOnce /*test flag*/ bool, timeout int) { - serverConnectionTimeout := time.Duration(timeout) * time.Second - // listen on all interfaces - EndPoint := addr.Host + ":" + strconv.Itoa(int(addr.Port)) - laddr, err := net.ResolveTCPAddr("tcp", EndPoint) - if err != nil { - log.Fatal("Connection listener address resolution error:", err) - } - ln, err := net.ListenTCP("tcp", laddr) - if err != nil { - log.Fatal("Connection listener error:", err) - } - defer ln.Close() - ln.SetDeadline(time.Now().Add(serverConnectionTimeout)) - log.Info("Sync server is up...") - - for { - conn, err := ln.AcceptTCP() - if err != nil { - log.Fatal("Connection accept error:", err) - } - - if serveOnce { - // This is to avoid server listening port conflicts while running tests - // exit after single connection request - if serveConnection(conn) { - break // no retries - } - log.Warn("Server: waiting for client sync retry...") - } else { - go serveConnection(conn) - } - } - log.Info("Sync server exit.") -} - -type requestCode int - -const ( - requestMagic requestCode = 31415926 - syncRequestCode requestCode = 1 -) - -type requestHeader struct { - Magic requestCode - Code requestCode -} - -// returns true if no retry is necessary -func serveConnection(conn net.Conn) bool { - defer conn.Close() - - decoder := gob.NewDecoder(conn) - var request requestHeader - err := decoder.Decode(&request) - if err != nil { - log.Fatal("Protocol decoder error:", err) - return true - } - if requestMagic != request.Magic { - log.Error("Bad request") - return true - } - - switch request.Code { - case syncRequestCode: - var path string - err := decoder.Decode(&path) - if err != nil { - log.Fatal("Protocol decoder error:", err) - return true - } - var size int64 - err = decoder.Decode(&size) - if err != nil { - log.Fatal("Protocol decoder error:", err) - return true - } - var salt []byte - err = decoder.Decode(&salt) - if err != nil { - log.Fatal("Protocol decoder error:", err) - return true - } - encoder := gob.NewEncoder(conn) - return serveSyncRequest(encoder, decoder, path, size, salt) - } - return true -} - -// returns true if no retry is necessary -func serveSyncRequest(encoder *gob.Encoder, decoder *gob.Decoder, path string, size int64, salt []byte) bool { - directFileIO := size%Blocks == 0 - SetupFileIO(directFileIO) - - // Open destination file - file, err := fileOpen(path, os.O_RDWR, 0666) - if err != nil { - file, err = os.Create(path) - if err != nil { - log.Error("Failed to create file:", string(path), err) - encoder.Encode(false) // NACK request - return true - } - } - // Setup close sequence - if directFileIO { - defer file.Sync() - } - defer file.Close() - - // Resize the file - if err = file.Truncate(size); err != nil { - log.Error("Failed to resize file:", string(path), err) - encoder.Encode(false) // NACK request - return true - } - - // open file - fileRO, err := fileOpen(path, os.O_RDONLY, 0) - if err != nil { - log.Error("Failed to open file for reading:", string(path), err) - encoder.Encode(false) // NACK request - return true - } - defer fileRO.Close() - - abortStream := make(chan error) - layoutStream := make(chan FileInterval, 128) - errStream := make(chan error) - - fileStream := make(chan FileInterval, 128) - unorderedStream := make(chan HashedDataInterval, 128) - orderedStream := make(chan HashedDataInterval, 128) - netOutStream := make(chan HashedInterval, 128) - netOutDoneStream := make(chan bool) - - netInStream := make(chan DataInterval, 128) - fileWriteStream := make(chan DataInterval, 128) - deltaReceiverDoneDone := make(chan bool) - checksumStream := make(chan DataInterval, 128) - resultStream := make(chan []byte) - - // Initiate interval loading... - err = loadFileLayout(abortStream, fileRO, layoutStream, errStream) - if err != nil { - encoder.Encode(false) // NACK request - return true - } - encoder.Encode(true) // ACK request - - go IntervalSplitter(layoutStream, fileStream) - FileReaderGroup(fileReaders, salt, fileStream, path, unorderedStream) - go OrderIntervals("dst:", unorderedStream, orderedStream) - go Tee(orderedStream, netOutStream, checksumStream) - - // Send layout along with data hashes - go netSender(netOutStream, encoder, netOutDoneStream) - - // Start receiving deltas, write those and compute file hash - fileWritten := FileWriterGroup(fileWriters, fileWriteStream, path) - go netReceiver(decoder, file, netInStream, fileWriteStream, deltaReceiverDoneDone) // receiver and checker - go Validator(salt, checksumStream, netInStream, resultStream) - - // Block till completion - status := true - err = <-errStream // Done with file loadaing, possibly aborted on error - if err != nil { - log.Error("Sync server file load aborted:", err) - status = false - } - status = <-netOutDoneStream && status // done sending dst hashes - status = <-deltaReceiverDoneDone && status // done writing dst file - fileWritten.Wait() // wait for write stream completion - hash := <-resultStream // done processing diffs - - // reply to client with status - log.Info("Sync sending server status=", status) - err = encoder.Encode(status) - if err != nil { - log.Fatal("Protocol encoder error:", err) - return true - } - // reply with local hash - err = encoder.Encode(hash) - if err != nil { - log.Fatal("Protocol encoder error:", err) - return true - } - - var retry bool - err = decoder.Decode(&retry) - if err != nil { - log.Fatal("Protocol retry decoder error:", err) - return true - } - encoder.Encode(true) // ACK retry - if err != nil { - log.Fatal("Protocol retry encoder error:", err) - return true - } - return !retry // don't terminate server if retry expected -} - -// Tee ordered intervals into the network and checksum checker -func Tee(orderedStream <-chan HashedDataInterval, netOutStream chan<- HashedInterval, checksumStream chan<- DataInterval) { - for r := range orderedStream { - netOutStream <- HashedInterval{r.FileInterval, r.Hash} - checksumStream <- DataInterval{r.FileInterval, r.Data} - } - close(netOutStream) - close(checksumStream) -} - -func netSender(netOutStream <-chan HashedInterval, encoder *gob.Encoder, netOutDoneStream chan<- bool) { - for r := range netOutStream { - if verboseServer { - log.Debug("Server.netSender: sending", r.FileInterval) - } - err := encoder.Encode(r) - if err != nil { - log.Fatal("Protocol encoder error:", err) - netOutDoneStream <- false - return - } - } - - rEOF := HashedInterval{FileInterval{SparseIgnore, Interval{}}, make([]byte, 0)} - if rEOF.Len() != 0 { - log.Fatal("Server.netSender internal error") - } - // err := encoder.Encode(HashedInterval{FileInterval{}, make([]byte, 0)}) - err := encoder.Encode(rEOF) - if err != nil { - log.Fatal("Protocol encoder error:", err) - netOutDoneStream <- false - return - } - if verboseServer { - log.Debug("Server.netSender: finished sending hashes") - } - netOutDoneStream <- true -} - -func netReceiver(decoder *gob.Decoder, file *os.File, netInStream chan<- DataInterval, fileStream chan<- DataInterval, deltaReceiverDone chan<- bool) { - // receive & process data diff - status := true - for status { - var delta FileInterval - err := decoder.Decode(&delta) - if err != nil { - log.Fatal("Protocol decoder error:", err) - status = false - break - } - log.Debug("receiving delta [", delta, "]") - if 0 == delta.Len() { - log.Debug("received end of transimission marker") - break // end of diff - } - switch delta.Kind { - case SparseData: - // Receive data - var data []byte - err = decoder.Decode(&data) - if err != nil { - log.Fatal("Protocol data decoder error:", err) - status = false - break - } - if int64(len(data)) != delta.Len() { - log.Fatal("Failed to receive data, expected=", delta.Len(), "received=", len(data)) - status = false - break - } - // Push for writing and vaildator processing - fileStream <- DataInterval{delta, data} - netInStream <- DataInterval{delta, data} - - case SparseHole: - // Push for writing and vaildator processing - fileStream <- DataInterval{delta, make([]byte, 0)} - netInStream <- DataInterval{delta, make([]byte, 0)} - - case SparseIgnore: - // Push for vaildator processing - netInStream <- DataInterval{delta, make([]byte, 0)} - log.Debug("ignoring...") - } - } - - log.Debug("Server.netReceiver done, sync") - close(netInStream) - close(fileStream) - deltaReceiverDone <- status -} - -func logData(prefix string, data []byte) { - size := len(data) - if size > 0 { - log.Debug("\t", prefix, "of", size, "bytes", data[0], "...") - } else { - log.Debug("\t", prefix, "of", size, "bytes") - } -} - -func hashFileData(fileHasher hash.Hash, dataLen int64, data []byte) { - // Hash hole length or data if any - if len(data) == 0 { - // hash hole - hole := make([]byte, 8) - binary.PutVarint(hole, dataLen) - fileHasher.Write(hole) - - } else { - fileHasher.Write(data) - } -} - -// Validator merges source and diff data; produces hash of the destination file -func Validator(salt []byte, checksumStream, netInStream <-chan DataInterval, resultStream chan<- []byte) { - fileHasher := sha1.New() - //TODO: error handling - fileHasher.Write(salt) - r := <-checksumStream // original dst file data - q := <-netInStream // diff data - for q.Len() != 0 || r.Len() != 0 { - if r.Len() == 0 /*end of dst file*/ { - // Hash diff data - if verboseServer { - logData("RHASH", q.Data) - } - hashFileData(fileHasher, q.Len(), q.Data) - q = <-netInStream - } else if q.Len() == 0 /*end of diff file*/ { - // Hash original data - if verboseServer { - logData("RHASH", r.Data) - } - hashFileData(fileHasher, r.Len(), r.Data) - r = <-checksumStream - } else { - qi := q.Interval - ri := r.Interval - if qi.Begin == ri.Begin { - if qi.End > ri.End { - log.Fatal("Server.Validator internal error, diff=", q.FileInterval, "local=", r.FileInterval) - } else if qi.End < ri.End { - // Hash diff data - if verboseServer { - log.Debug("Server.Validator: hashing diff", q.FileInterval, r.FileInterval) - } - if verboseServer { - logData("RHASH", q.Data) - } - hashFileData(fileHasher, q.Len(), q.Data) - r.Begin = q.End - q = <-netInStream - } else { - if q.Kind == SparseIgnore { - // Hash original data - if verboseServer { - log.Debug("Server.Validator: hashing original", r.FileInterval) - } - if verboseServer { - logData("RHASH", r.Data) - } - hashFileData(fileHasher, r.Len(), r.Data) - } else { - // Hash diff data - if verboseServer { - log.Debug("Server.Validator: hashing diff", q.FileInterval) - } - if verboseServer { - logData("RHASH", q.Data) - } - hashFileData(fileHasher, q.Len(), q.Data) - } - q = <-netInStream - r = <-checksumStream - } - } else { - log.Fatal("Server.Validator internal error, diff=", q.FileInterval, "local=", r.FileInterval) - } - } - } - - if verboseServer { - log.Debug("Server.Validator: finished") - } - resultStream <- fileHasher.Sum(nil) -} diff --git a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go index 2af5d3b9..d54ac12e 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go @@ -4,8 +4,11 @@ import ( "os" "syscall" - fio "github.com/rancher/sparse-tools/directfio" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" +) + +const ( + batchBlockCount = 32 ) // FoldFile folds child snapshot data into its parent @@ -31,67 +34,64 @@ func FoldFile(childFileName, parentFileName string) error { } // open child and parent files - childFile, err := fio.OpenFile(childFileName, os.O_RDONLY, 0) + childFileIo, err := NewDirectFileIoProcessor(childFileName, os.O_RDONLY, 0) if err != nil { panic("Failed to open childFile, error: " + err.Error()) } - defer childFile.Close() + defer childFileIo.Close() - parentFile, err := fio.OpenFile(parentFileName, os.O_WRONLY, 0) + parentFileIo, err := NewDirectFileIoProcessor(parentFileName, os.O_WRONLY, 0) if err != nil { panic("Failed to open parentFile, error: " + err.Error()) } - defer parentFile.Close() + defer parentFileIo.Close() - return coalesce(parentFile, childFile) + return coalesce(parentFileIo, childFileIo) } -func coalesce(parentFile *os.File, childFile *os.File) error { - blockSize, err := getFileSystemBlockSize(childFile) +func coalesce(parentFileIo FileIoProcessor, childFileIo FileIoProcessor) error { + blockSize, err := getFileSystemBlockSize(childFileIo) if err != nil { panic("can't get FS block size, error: " + err.Error()) } var data, hole int64 for { - data, err = syscall.Seek(int(childFile.Fd()), hole, seekData) - if err != nil { - // reaches EOF - errno := err.(syscall.Errno) - if errno == syscall.ENXIO { - break - } else { - // unexpected errors - log.Fatal("Failed to syscall.Seek SEEK_DATA") - return err - } + data, _ = childFileIo.Seek(hole, seekData) + if data < hole { + break } - hole, err = syscall.Seek(int(childFile.Fd()), data, seekHole) + hole, err = childFileIo.Seek(data, seekHole) if err != nil { - log.Fatal("Failed to syscall.Seek SEEK_HOLE") + log.Error("Failed to syscall.Seek SEEK_HOLE") return err } // now we have a data start offset and length(hole - data) - // let's read from child and write to parent file block by block - _, err = parentFile.Seek(data, os.SEEK_SET) + // let's read from child and write to parent file. We read/write up to + // 32 blocks in a batch + _, err = parentFileIo.Seek(data, os.SEEK_SET) if err != nil { - log.Fatal("Failed to os.Seek os.SEEK_SET") + log.Error("Failed to os.Seek os.SEEK_SET") return err } - offset := data - buffer := fio.AllocateAligned(blockSize) - for offset != hole { - // read a block from child, maybe use bufio or Reader stream - n, err := fio.ReadAt(childFile, buffer, offset) - if n != len(buffer) || err != nil { - log.Fatal("Failed to read from childFile") + batch := batchBlockCount * blockSize + buffer := AllocateAligned(batch) + for offset := data; offset < hole; { + size := batch + if offset+int64(size) > hole { + size = int(hole - offset) + } + // read a batch from child + n, err := childFileIo.ReadAt(buffer[:size], offset) + if err != nil { + log.Error("Failed to read from childFile") return err } - // write a block to parent - n, err = fio.WriteAt(parentFile, buffer, offset) - if n != len(buffer) || err != nil { - log.Fatal("Failed to write to parentFile") + // write a batch to parent + n, err = parentFileIo.WriteAt(buffer[:size], offset) + if err != nil { + log.Error("Failed to write to parentFile") return err } offset += int64(n) @@ -102,8 +102,8 @@ func coalesce(parentFile *os.File, childFile *os.File) error { } // get the file system block size -func getFileSystemBlockSize(f *os.File) (int, error) { +func getFileSystemBlockSize(fileIo FileIoProcessor) (int, error) { var stat syscall.Stat_t - err := syscall.Stat(f.Name(), &stat) + err := syscall.Stat(fileIo.Name(), &stat) return int(stat.Blksize), err } diff --git a/vendor/github.com/rancher/sparse-tools/stats/stats.go b/vendor/github.com/rancher/sparse-tools/stats/stats.go index 8f46039e..c26b08e4 100644 --- a/vendor/github.com/rancher/sparse-tools/stats/stats.go +++ b/vendor/github.com/rancher/sparse-tools/stats/stats.go @@ -8,7 +8,7 @@ import ( "sync" - "github.com/rancher/sparse-tools/log" + log "github.com/Sirupsen/logrus" ) const ( diff --git a/vendor/github.com/rancher/sparse-tools/trash.yml b/vendor/github.com/rancher/sparse-tools/trash.yml index fe3b6b25..f5359bdd 100644 --- a/vendor/github.com/rancher/sparse-tools/trash.yml +++ b/vendor/github.com/rancher/sparse-tools/trash.yml @@ -1,4 +1,9 @@ -import: -- package: github.com/frostschutz/go-fibmap - version: 5fc9f8c1ed479f20414771a17b9686ee77029676 - repo: https://github.com/rancher/go-fibmap.git +# trash.conf + +# package +github.com/rancher/sparse-tools + +github.com/Sirupsen/logrus v0.10.0-19-gf3cfb45 +github.com/gorilla/context v1.1-4-gaed02d1 +github.com/gorilla/mux v1.1-13-g9fa818a +golang.org/x/sys a408501 From 58ac3a3757584be4957dedcf19c3eda831295b37 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 20 Jul 2016 14:28:00 -0700 Subject: [PATCH 164/357] fuse: Temporarily run in pid=host, to make the thing work in Ubuntu 16.04 We can get rid of this after kernel get rid of restriction of pid namespace for fuse(#204) Also disable killing process part of integration test script for now, otherwise we may kill longhorn in another namespace. --- Dockerfile.dapper | 2 +- scripts/integration-test | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 575a4eb1..412db0e5 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -5,7 +5,7 @@ ENV PATH /go/bin:$PATH ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_ENV TAG REPO ENV DAPPER_OUTPUT bin -ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec -v /dev:/host/dev +ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec -v /dev:/host/dev --pid host ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} diff --git a/scripts/integration-test b/scripts/integration-test index a28c834f..9738d39a 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -1,25 +1,27 @@ #!/bin/bash set -e -killall longhorn ssync || true - -running="" -for i in `seq 10` -do - running=`ps aux|grep longhorn|grep -v grep || true` - if [ -z "$running" ] - then - break - fi - echo Wait one more second for longhorn process to stop - sleep 1 -done -if [ "$running" ] -then - echo Failed to wait for longhorn process stop - echo $running - exit -1 -fi +# Don't want to kill longhorn in another namespace for now +# +#killall longhorn ssync || true +# +#running="" +#for i in `seq 10` +#do +# running=`ps aux|grep longhorn|grep -v grep || true` +# if [ -z "$running" ] +# then +# break +# fi +# echo Wait one more second for longhorn process to stop +# sleep 1 +#done +#if [ "$running" ] +#then +# echo Failed to wait for longhorn process stop +# echo $running +# exit -1 +#fi temp=$(mktemp -d) temp2=$(mktemp -d) From 97c2cc3be1559a2cc1a26aaa12ca791b070a9e63 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 20 Jul 2016 20:05:34 -0700 Subject: [PATCH 165/357] rpc: Fix larger req.Data buffer than resp.Data size copy() will result in only part of req.Data replaced, at least when error happenes. --- rpc/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/rpc/client.go b/rpc/client.go index 91068b91..bbfe2b89 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -191,6 +191,7 @@ func (c *Client) handleResponse(resp *Message) { // can probably optimize away this copy if len(resp.Data) > 0 { copy(req.Data, resp.Data) + req.Data = req.Data[:len(resp.Data)] } req.Type = resp.Type req.Complete <- struct{}{} From 476ed45e909558f6a751d9f4cbb4e6cae269a5db Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 21 Jul 2016 17:35:00 -0700 Subject: [PATCH 166/357] test: Fix order of teardown Seems py.test finalizer is in FILO order, so it's better to make sure controller disconnect first before replicas, otherwise longhorn daemon will reports error on disconnected replicas. It's shown in the test. --- integration/data/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index a1aa12a2..3ea8ce41 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -43,9 +43,9 @@ def _base(): @pytest.fixture() def dev(request): prepare_backup_dir(BACKUP_DIR) - controller = controller_client(request) replica = replica_client(request, REPLICA1_SCHEMA) replica2 = replica_client(request, REPLICA2_SCHEMA) + controller = controller_client(request) open_replica(replica) open_replica(replica2) @@ -67,9 +67,9 @@ def dev(request): @pytest.fixture() def backing_dev(request): prepare_backup_dir(BACKUP_DIR) - controller = controller_client(request) replica = replica_client(request, BACKED_REPLICA1_SCHEMA) replica2 = replica_client(request, BACKED_REPLICA2_SCHEMA) + controller = controller_client(request) open_replica(replica) open_replica(replica2) From 748be6a8464dd1fd1cfda4816d1a77140f4ea320 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 22 Jul 2016 17:47:39 -0700 Subject: [PATCH 167/357] fuse: Retry if loopback device wasn't detached immediately (#208) Wait for 1s * 5 times maximum. --- frontend/fusedev/fuse.go | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 086410bd..4ed919a1 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -33,6 +33,9 @@ const ( ImageSuffix = ".img" DevPath = "/dev/longhorn/" MountBase = "/tmp/longhorn-fuse-mount" + + RetryCounts = 5 + RetryInterval = 1 * time.Second ) var ( @@ -50,7 +53,6 @@ func newFuseFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *Fu SectorSize: sectorSize, }, } - } func (fs *FuseFs) Start() error { @@ -183,14 +185,27 @@ func (fs *FuseFs) removeDev() error { } for _, lodev := range lodevs { logrus.Infof("Detaching loopback device %s", lodev) - if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { - return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) - } - devs, err := util.ListLoopbackDevice(fs.getImageFileFullPath()) - if err != nil { - return err + detached := false + devs := []string{} + for i := 0; i < RetryCounts; i++ { + var err error + + if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { + return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) + } + + devs, err = util.ListLoopbackDevice(fs.getImageFileFullPath()) + if err != nil { + return err + } + if len(devs) == 0 { + detached = true + break + } + logrus.Infof("Waitting for detaching loopback device", devs) + time.Sleep(RetryInterval) } - if len(devs) != 0 { + if !detached { return fmt.Errorf("Loopback device busy, cannot detach device, devices %v remains", devs) } } From fe7a46628c55645065bd6d70eb0c4733c81b3d3c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 27 Jul 2016 17:57:01 -0700 Subject: [PATCH 168/357] fuse: Don't put detach in the retry loop (#209) It may result in detaching a non-existing loopback device thus error out. --- frontend/fusedev/fuse.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 4ed919a1..2220dda2 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -185,15 +185,14 @@ func (fs *FuseFs) removeDev() error { } for _, lodev := range lodevs { logrus.Infof("Detaching loopback device %s", lodev) + if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { + return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) + } + detached := false devs := []string{} for i := 0; i < RetryCounts; i++ { var err error - - if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { - return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) - } - devs, err = util.ListLoopbackDevice(fs.getImageFileFullPath()) if err != nil { return err From 5bc135eda47dd8e764c6926193e3cee4bbd713ce Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 30 Jul 2016 17:17:15 -0700 Subject: [PATCH 169/357] rest: Fix test_beyond_boundary --- integration/data/frontend.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/integration/data/frontend.py b/integration/data/frontend.py index 4eac688f..74ccce1d 100644 --- a/integration/data/frontend.py +++ b/integration/data/frontend.py @@ -17,13 +17,24 @@ def __init__(self, volume): self.dev = dev def readat(self, offset, length): - data = self.dev.readat(offset=offset, length=length)["data"] + try: + data = self.dev.readat(offset=offset, length=length)["data"] + except cattle.ApiError as e: + if 'EOF' in str(e): + return [] + raise e return base64.decodestring(data) def writeat(self, offset, data): l = len(data) encoded_data = base64.encodestring(data) - return self.dev.writeat(offset=offset, length=l, data=encoded_data) + try: + ret = self.dev.writeat(offset=offset, length=l, data=encoded_data) + except cattle.ApiError as e: + if 'EOF' in str(e): + raise IOError('No space left on the disk') + raise e + return ret class fusedev: From 89c3f543586fb9fb95a0e44b0add4ad011e9111c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Sat, 30 Jul 2016 16:06:06 -0700 Subject: [PATCH 170/357] Revert back test frontend to rest, and update simple-longhorn back to TCMU Switch back from FUSE till direct-io(#207) is finished --- integration/data/common.py | 4 ++-- package/launch-simple-longhorn | 2 +- scripts/integration-test | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index 3ea8ce41..9c66d806 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -59,7 +59,7 @@ def dev(request): REPLICA2 ]) assert v.replicaCount == 2 - d = get_fusedev() + d = get_restdev() return d @@ -83,7 +83,7 @@ def backing_dev(request): BACKED_REPLICA2 ]) assert v.replicaCount == 2 - d = get_fusedev() + d = get_restdev() return d diff --git a/package/launch-simple-longhorn b/package/launch-simple-longhorn index 51acd290..ecefca31 100755 --- a/package/launch-simple-longhorn +++ b/package/launch-simple-longhorn @@ -11,4 +11,4 @@ volume=$1 longhorn replica --size 1g --listen localhost:9502 /volume/ & sleep 1 -exec longhorn --debug controller --frontend fuse --replica tcp://localhost:9502 $volume +exec longhorn --debug controller --frontend tcmu --replica tcp://localhost:9502 $volume diff --git a/scripts/integration-test b/scripts/integration-test index 9738d39a..f42c7f57 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -41,7 +41,7 @@ then mount --rbind /host/dev /dev fi -./bin/longhorn controller --frontend fuse --enable-backend file test-volume & +./bin/longhorn controller --frontend rest --enable-backend file test-volume & controller_pid=$! ./bin/longhorn replica $temp & replica1_pid=$! From 69a4565b47e81a7ef43049d9afb7aa31c37cdad6 Mon Sep 17 00:00:00 2001 From: jimengliu Date: Wed, 3 Aug 2016 16:50:57 -0700 Subject: [PATCH 171/357] update vendor sparse changes (#212) --- trash.yml | 2 +- .../rancher/sparse-tools/sparse/client.go | 17 +++++----- .../rancher/sparse-tools/sparse/file.go | 6 +++- .../sparse-tools/sparse/rest/handlers.go | 4 +-- .../rancher/sparse-tools/sparse/sfold.go | 33 +++++++++---------- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/trash.yml b/trash.yml index 05e39a41..7b11c1c6 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 9cac891ad8a2029146df905ae09622eb1de8b19c + version: 02cb785a2eb87b76ec55269346357131944830cd - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/sparse/client.go b/vendor/github.com/rancher/sparse-tools/sparse/client.go index 05055da7..152bf6ce 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/client.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/client.go @@ -257,11 +257,18 @@ func (client *syncClient) syncDataInterval(file FileIoProcessor, dataInterval In } serverNeedData := true + + // read data either for checksum, sending, or both + dataBuffer, err := ReadDataInterval(file, batchInterval) + if err != nil { + log.Errorf("ReadDataInterval for batchInterval: %s failed, err: %s", batchInterval, err) + return err + } if len(serverCheckSum) != 0 { // calculate local checksum for the data batch interval - localCheckSum, err := HashDataInterval(file, batchInterval) + localCheckSum, err := HashData(dataBuffer) if err != nil { - log.Errorf("HashDataInterval locally: %s failed, err: %s", batchInterval, err) + log.Errorf("HashData locally: %s failed, err: %s", batchInterval, err) return err } @@ -269,12 +276,6 @@ func (client *syncClient) syncDataInterval(file FileIoProcessor, dataInterval In serverNeedData = !bytes.Equal(serverCheckSum, localCheckSum) } if serverNeedData { - dataBuffer, err := ReadDataInterval(file, batchInterval) - if err != nil { - log.Errorf("ReadDataInterval for batchInterval: %s failed, err: %s", batchInterval, err) - return err - } - // send data buffer log.Debugf("sending dataBuffer size: %d", len(dataBuffer)) err = client.writeData(batchInterval, dataBuffer) diff --git a/vendor/github.com/rancher/sparse-tools/sparse/file.go b/vendor/github.com/rancher/sparse-tools/sparse/file.go index 50ddb3d9..1d037e2b 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/file.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/file.go @@ -163,11 +163,15 @@ func WriteDataInterval(file FileIoProcessor, dataInterval Interval, data []byte) return nil } -func HashDataInterval(file FileIoProcessor, dataInterval Interval) ([]byte, error) { +func HashFileInterval(file FileIoProcessor, dataInterval Interval) ([]byte, error) { data, err := ReadDataInterval(file, dataInterval) if err != nil { return nil, err } + return HashData(data) +} + +func HashData(data []byte) ([]byte, error) { sum := sha512.Sum512(data) return sum[:], nil } diff --git a/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go b/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go index 652a919c..8c61963d 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/rest/handlers.go @@ -135,9 +135,9 @@ func (server *SyncServer) doGetChecksum(writer http.ResponseWriter, request *htt if len(exts) == 1 && int64(exts[0].Logical) <= remoteDataInterval.Begin && int64(exts[0].Logical+exts[0].Length) >= remoteDataInterval.End { - checksum, err = sparse.HashDataInterval(server.fileIo, remoteDataInterval) + checksum, err = sparse.HashFileInterval(server.fileIo, remoteDataInterval) if err != nil { - return fmt.Errorf("HashDataInterval locally: %s failed, err: %s", remoteDataInterval, err) + return fmt.Errorf("HashFileInterval locally: %s failed, err: %s", remoteDataInterval, err) } } diff --git a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go index d54ac12e..4fb10beb 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go @@ -54,44 +54,41 @@ func coalesce(parentFileIo FileIoProcessor, childFileIo FileIoProcessor) error { if err != nil { panic("can't get FS block size, error: " + err.Error()) } - var data, hole int64 - for { - data, _ = childFileIo.Seek(hole, seekData) - if data < hole { - break - } - hole, err = childFileIo.Seek(data, seekHole) - if err != nil { - log.Error("Failed to syscall.Seek SEEK_HOLE") - return err - } + exts, err := GetFiemapExtents(childFileIo) + if err != nil { + log.Errorf("Failed to GetFiemapExtents of childFile filename: %v", childFileIo.Name()) + return err + } + for _, e := range exts { + dataBegin := int64(e.Logical) + dataEnd := int64(e.Logical + e.Length) // now we have a data start offset and length(hole - data) // let's read from child and write to parent file. We read/write up to // 32 blocks in a batch - _, err = parentFileIo.Seek(data, os.SEEK_SET) + _, err = parentFileIo.Seek(dataBegin, os.SEEK_SET) if err != nil { - log.Error("Failed to os.Seek os.SEEK_SET") + log.Errorf("Failed to os.Seek os.SEEK_SET parentFile filename: %v, at: %v", parentFileIo.Name(), dataBegin) return err } batch := batchBlockCount * blockSize buffer := AllocateAligned(batch) - for offset := data; offset < hole; { + for offset := dataBegin; offset < dataEnd; { size := batch - if offset+int64(size) > hole { - size = int(hole - offset) + if offset+int64(size) > dataEnd { + size = int(dataEnd - offset) } // read a batch from child n, err := childFileIo.ReadAt(buffer[:size], offset) if err != nil { - log.Error("Failed to read from childFile") + log.Errorf("Failed to read childFile filename: %v, size: %v, at: %v", childFileIo.Name(), size, offset) return err } // write a batch to parent n, err = parentFileIo.WriteAt(buffer[:size], offset) if err != nil { - log.Error("Failed to write to parentFile") + log.Errorf("Failed to write to parentFile filename: %v, size: %v, at: %v", parentFileIo.Name(), size, offset) return err } offset += int64(n) From a5e92c7ce6d51c35301fe1e65765e9a3b58dc04b Mon Sep 17 00:00:00 2001 From: jimengliu Date: Mon, 8 Aug 2016 12:23:19 -0700 Subject: [PATCH 172/357] test: add case for sfolding empty snapshot to its parent (#214) Fix #211 --- integration/core/test_cli.py | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 72bfc415..b648bd0c 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -339,6 +339,45 @@ def test_snapshot_rm(bin, controller_client, replica_client, replica_client2): assert chain[2] == new_chain[1] +def test_snapshot_rm_empty( + bin, controller_client, replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + cmd = [bin, 'snapshot', 'create'] + + # first snapshot + output1 = subprocess.check_output(cmd).strip() + chain = replica_client.list_replica()[0].chain + assert len(chain) == 2 + assert chain[0] == 'volume-head-001.img' + assert chain[1] == 'volume-snap-{}.img'.format(output1) + + # second snapshot + output2 = subprocess.check_output(cmd).strip() + chain = replica_client.list_replica()[0].chain + assert len(chain) == 3 + assert chain[0] == 'volume-head-002.img' + assert chain[1] == 'volume-snap-{}.img'.format(output2) + assert chain[2] == 'volume-snap-{}.img'.format(output1) + + # remove the first snapshot(empty), it will fold second snapshot(empty) + # to the first snapshot(empty) and rename it to second snapshot + cmd = [bin, 'snapshot', 'rm', output1] + subprocess.check_call(cmd) + new_chain = replica_client.list_replica()[0].chain + assert len(new_chain) == 2 + assert chain[0] == new_chain[0] + assert chain[1] == new_chain[1] + + def test_snapshot_last(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) From 1819954c23a3ce13b69ad2975829c2f965cc9e79 Mon Sep 17 00:00:00 2001 From: jimengliu Date: Mon, 8 Aug 2016 15:23:06 -0700 Subject: [PATCH 173/357] vendor: update to the latest sparse-tools (#215) --- trash.yml | 2 +- .../rancher/sparse-tools/sparse/file.go | 3 + .../rancher/sparse-tools/sparse/layout.go | 139 +----------------- 3 files changed, 5 insertions(+), 139 deletions(-) diff --git a/trash.yml b/trash.yml index 7b11c1c6..8efd5d8d 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 02cb785a2eb87b76ec55269346357131944830cd + version: 1b461089e2db95e45faeff6bb07f3d599ba4aed6 - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/sparse/file.go b/vendor/github.com/rancher/sparse-tools/sparse/file.go index 1d037e2b..405cc13a 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/file.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/file.go @@ -185,6 +185,9 @@ func GetFiemapExtents(file FileIoProcessor) ([]Extent, error) { } func GetFiemapRegionExts(file FileIoProcessor, interval Interval) ([]Extent, error) { + if interval.End == 0 { + return nil, nil + } var exts []Extent fiemap := NewFiemapFile(file.GetFile()) diff --git a/vendor/github.com/rancher/sparse-tools/sparse/layout.go b/vendor/github.com/rancher/sparse-tools/sparse/layout.go index 9f33c736..670609e4 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/layout.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/layout.go @@ -1,12 +1,6 @@ package sparse -import ( - "bytes" - "fmt" - "os" - - log "github.com/Sirupsen/logrus" -) +import "fmt" // Interval [Begin, End) is non-inclusive at the End type Interval struct { @@ -59,134 +53,3 @@ const ( // Blocks : block size in bytes Blocks int64 = 4 << 10 // 4k ) - -// os.Seek sparse whence values. -const ( - // Adjust the file offset to the next location in the file - // greater than or equal to offset containing data. If offset - // points to data, then the file offset is set to offset. - seekData int = 3 - - // Adjust the file offset to the next hole in the file greater - // than or equal to offset. If offset points into the middle of - // a hole, then the file offset is set to offset. If there is no - // hole past offset, then the file offset is adjusted to the End - // of the file (i.e., there is an implicit hole at the End of any - // file). - seekHole int = 4 -) - -// syscall.Fallocate mode bits -const ( - // default is extend size - fallocFlKeepSize uint32 = 1 - - // de-allocates range - fallocFlPunchHole uint32 = 2 -) - -func MakeData(interval FileInterval) []byte { - data := make([]byte, interval.Len()) - if SparseData == interval.Kind { - for i := range data { - data[i] = byte(interval.Begin/Blocks + 1) - } - } - return data -} - -func isHashDifferent(a, b []byte) bool { - return !bytes.Equal(a, b) -} - -// RetrieveLayoutStream streams sparse file data/hole layout -// Based on fiemap -// To abort: abortStream <- error -// Check status: err := <- errStream -// Usage: go RetrieveLayoutStream(...) -func RetrieveLayoutStream(abortStream <-chan error, file *os.File, r Interval, layoutStream chan<- FileInterval, errStream chan<- error) { - const extents = 1024 - const chunkSizeMax = 1 /*GB*/ << 30 - chunkSize := r.Len() - if chunkSize > chunkSizeMax { - chunkSize = chunkSizeMax - } - - chunk := Interval{r.Begin, r.Begin + chunkSize} - // Process file extents for each chunk - intervalLast := Interval{chunk.Begin, chunk.Begin} - for chunk.Begin < r.End { - if chunk.End > r.End { - chunk.End = r.End - } - - for more := true; more && chunk.Len() > 0; { - fiemap := NewFiemapFile(file) - _, ext, errno := fiemap.Fiemap(uint32(chunk.Len())) - if errno != 0 { - close(layoutStream) - errStream <- &os.PathError{Op: "Fiemap", Path: file.Name(), Err: errno} - return - } - if len(ext) == 0 { - break - } - - // Process each extent - for _, e := range ext { - interval := Interval{int64(e.Logical), int64(e.Logical + e.Length)} - log.Debug("Extent:", interval, e.Flags) - if e.Flags&FIEMAP_EXTENT_LAST != 0 { - more = false - } - if intervalLast.End < interval.Begin { - if intervalLast.Len() > 0 { - // Pop last Data - layoutStream <- FileInterval{SparseData, intervalLast} - } - // report hole - intervalLast = Interval{intervalLast.End, interval.Begin} - layoutStream <- FileInterval{SparseHole, intervalLast} - - // Start data - intervalLast = interval - } else { - // coalesce - intervalLast.End = interval.End - } - chunk.Begin = interval.End - } - } - chunk = Interval{chunk.End, chunk.End + chunkSize} - } - - if intervalLast.Len() > 0 { - // Pop last Data - if intervalLast.End > r.End { - intervalLast.End = r.End - } - layoutStream <- FileInterval{SparseData, intervalLast} - } - if intervalLast.End < r.End { - // report hole - layoutStream <- FileInterval{SparseHole, Interval{intervalLast.End, r.End}} - } - - close(layoutStream) - errStream <- nil - return -} - -// RetrieveLayout retrieves sparse file hole and data layout -func RetrieveLayout(file *os.File, r Interval) ([]FileInterval, error) { - layout := make([]FileInterval, 0, 1024) - abortStream := make(chan error) - layoutStream := make(chan FileInterval, 128) - errStream := make(chan error) - - go RetrieveLayoutStream(abortStream, file, r, layoutStream, errStream) - for interval := range layoutStream { - layout = append(layout, interval) - } - return layout, <-errStream -} From 39d93aa0b9513ed665b96333be79183de1387b6a Mon Sep 17 00:00:00 2001 From: Nathan Valentine Date: Thu, 25 Aug 2016 12:12:41 -0700 Subject: [PATCH 174/357] change Drone YAML for Drone 0.5 (#217) --- .drone.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9a8850fc..c1b29922 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,9 @@ -build: - image: rancher/dapper:1.10.3 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - commands: - - dapper ci +--- +pipeline: + build: + privileged: true + image: rancher/dapper:1.10.3 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + commands: + - dapper ci From c728224c63dd2b254b9e3627b5f0d06a80d89a74 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:31:51 -0700 Subject: [PATCH 175/357] Update README.md Update Drone badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d91900b5..fad0a947 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -longhorn [![Build Status](https://ci-longhorn.rancher.io/api/badges/rancher/longhorn/status.svg)](https://ci-longhorn.rancher.io/rancher/longhorn) +longhorn [![Build Status](https://drone.rancher.io/api/badges/rancher/longhorn/status.svg)](https://drone.rancher.io/rancher/longhorn) ======== A microservice that does micro things. From 2cc448c7e4daee77de3e9acd611356209b5ed0ac Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:56 -0700 Subject: [PATCH 176/357] fuse: Rename FuseFs to LonghornFs --- frontend/fusedev/frontend.go | 10 ++-- frontend/fusedev/fuse.go | 88 ++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index 47e06887..e112058b 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -9,23 +9,23 @@ func New() types.Frontend { } type Fuse struct { - fs *FuseFs + lf *LonghornFs } func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { - f.fs = newFuseFs(name, size, sectorSize, rw) + f.lf = newLonghornFs(name, size, sectorSize, rw) if err := f.Shutdown(); err != nil { return err } log.Infof("Activate FUSE frontend for %v, size %v, sector size %v", name, size, sectorSize) - if err := f.fs.Start(); err != nil { + if err := f.lf.Start(); err != nil { return err } return nil } func (f *Fuse) Shutdown() error { - log.Infof("Shutdown FUSE frontend for %v", f.fs.Volume) - return f.fs.Stop() + log.Infof("Shutdown FUSE frontend for %v", f.lf.Volume) + return f.lf.Stop() } diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 2220dda2..858f47d4 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -16,7 +16,7 @@ import ( "github.com/rancher/longhorn/types" ) -type FuseFs struct { +type LonghornFs struct { pathfs.FileSystem Volume string file *FuseFile @@ -42,8 +42,8 @@ var ( log = logrus.WithFields(logrus.Fields{"pkg": "fusedev"}) ) -func newFuseFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *FuseFs { - return &FuseFs{ +func newLonghornFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *LonghornFs { + return &LonghornFs{ FileSystem: pathfs.NewDefaultFileSystem(), Volume: name, file: &FuseFile{ @@ -55,10 +55,10 @@ func newFuseFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *Fu } } -func (fs *FuseFs) Start() error { - newFs := pathfs.NewPathNodeFs(fs, nil) +func (lf *LonghornFs) Start() error { + newFs := pathfs.NewPathNodeFs(lf, nil) - mountDir := fs.GetMountDir() + mountDir := lf.GetMountDir() if err := os.MkdirAll(mountDir, 0700); err != nil { log.Fatal("Cannot create directory ", mountDir) } @@ -77,28 +77,28 @@ func (fs *FuseFs) Start() error { // This will be stopped when umount happens go server.Serve() - if err := fs.createDev(); err != nil { + if err := lf.createDev(); err != nil { return err } return nil } -func (fs *FuseFs) Stop() error { - if err := fs.removeDev(); err != nil { +func (lf *LonghornFs) Stop() error { + if err := lf.removeDev(); err != nil { return err } - if err := fs.umountFuse(); err != nil { + if err := lf.umountFuse(); err != nil { return err } return nil } -func (fs *FuseFs) getDev() string { - return filepath.Join(DevPath, fs.Volume) +func (lf *LonghornFs) getDev() string { + return filepath.Join(DevPath, lf.Volume) } -func (fs *FuseFs) getLoopbackDev() (string, error) { - devs, err := fs.getLoopbackDevs() +func (lf *LonghornFs) getLoopbackDev() (string, error) { + devs, err := lf.getLoopbackDevs() if err != nil { return "", err } @@ -108,8 +108,8 @@ func (fs *FuseFs) getLoopbackDev() (string, error) { return devs[0], nil } -func (fs *FuseFs) getLoopbackDevs() ([]string, error) { - filePath := fs.getImageFileFullPath() +func (lf *LonghornFs) getLoopbackDevs() ([]string, error) { + filePath := lf.getImageFileFullPath() devs, err := util.ListLoopbackDevice(filePath) if err != nil { return nil, err @@ -117,19 +117,19 @@ func (fs *FuseFs) getLoopbackDevs() ([]string, error) { return devs, nil } -func (fs *FuseFs) createDev() error { +func (lf *LonghornFs) createDev() error { if err := os.MkdirAll(DevPath, 0700); err != nil { log.Fatalln("Cannot create directory ", DevPath) } - dev := fs.getDev() + dev := lf.getDev() if _, err := os.Stat(dev); err == nil { return fmt.Errorf("Device %s already exists, can not create", dev) } found := false - path := fs.getImageFileFullPath() + path := lf.getImageFileFullPath() for i := 0; i < 30; i++ { var err error matches, err := filepath.Glob(path) @@ -151,7 +151,7 @@ func (fs *FuseFs) createDev() error { if err != nil { return err } - lodev, err := fs.getLoopbackDev() + lodev, err := lf.getLoopbackDev() if err != nil { return err } @@ -170,8 +170,8 @@ func (fs *FuseFs) createDev() error { return nil } -func (fs *FuseFs) removeDev() error { - dev := fs.getDev() +func (lf *LonghornFs) removeDev() error { + dev := lf.getDev() logrus.Infof("Removing device %s", dev) if _, err := os.Stat(dev); err == nil { if err := remove(dev); err != nil { @@ -179,13 +179,13 @@ func (fs *FuseFs) removeDev() error { } } - lodevs, err := fs.getLoopbackDevs() + lodevs, err := lf.getLoopbackDevs() if err != nil { return fmt.Errorf("Failed to get loopback device %v", err) } for _, lodev := range lodevs { logrus.Infof("Detaching loopback device %s", lodev) - if err := util.DetachLoopbackDevice(fs.getImageFileFullPath(), lodev); err != nil { + if err := util.DetachLoopbackDevice(lf.getImageFileFullPath(), lodev); err != nil { return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) } @@ -193,7 +193,7 @@ func (fs *FuseFs) removeDev() error { devs := []string{} for i := 0; i < RetryCounts; i++ { var err error - devs, err = util.ListLoopbackDevice(fs.getImageFileFullPath()) + devs, err = util.ListLoopbackDevice(lf.getImageFileFullPath()) if err != nil { return err } @@ -211,9 +211,9 @@ func (fs *FuseFs) removeDev() error { return nil } -func (fs *FuseFs) umountFuse() error { - if fs.isMounted() { - dir := fs.GetMountDir() +func (lf *LonghornFs) umountFuse() error { + if lf.isMounted() { + dir := lf.GetMountDir() logrus.Infof("Umounting %s", dir) if err := unix.Unmount(dir, 0); err != nil { return fmt.Errorf("Fail to umounting %s: %v", dir, err) @@ -222,31 +222,31 @@ func (fs *FuseFs) umountFuse() error { return nil } -func (fs *FuseFs) isMounted() bool { - path := fs.GetMountDir() +func (lf *LonghornFs) isMounted() bool { + path := lf.GetMountDir() if _, err := util.Execute("findmnt", []string{path}); err != nil { return false } return true } -func (fs *FuseFs) GetMountDir() string { - return filepath.Join(MountBase, fs.Volume) +func (lf *LonghornFs) GetMountDir() string { + return filepath.Join(MountBase, lf.Volume) } -func (fs *FuseFs) getImageFileName() string { - return fs.Volume + ImageSuffix +func (lf *LonghornFs) getImageFileName() string { + return lf.Volume + ImageSuffix } -func (fs *FuseFs) getImageFileFullPath() string { - return filepath.Join(fs.GetMountDir(), fs.getImageFileName()) +func (lf *LonghornFs) getImageFileFullPath() string { + return filepath.Join(lf.GetMountDir(), lf.getImageFileName()) } -func (fs *FuseFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { +func (lf *LonghornFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { switch name { - case fs.getImageFileName(): + case lf.getImageFileName(): return &fuse.Attr{ - Mode: fuse.S_IFREG | 0644, Size: uint64(fs.file.Size), + Mode: fuse.S_IFREG | 0644, Size: uint64(lf.file.Size), }, fuse.OK case "": return &fuse.Attr{ @@ -256,18 +256,18 @@ func (fs *FuseFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse. return nil, fuse.ENOENT } -func (fs *FuseFs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { +func (lf *LonghornFs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { if name == "" { - return []fuse.DirEntry{{Name: fs.getImageFileName(), Mode: fuse.S_IFREG}}, fuse.OK + return []fuse.DirEntry{{Name: lf.getImageFileName(), Mode: fuse.S_IFREG}}, fuse.OK } return nil, fuse.ENOENT } -func (fs *FuseFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) { - if name != fs.getImageFileName() { +func (lf *LonghornFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) { + if name != lf.getImageFileName() { return nil, fuse.ENOENT } - return fs.file, fuse.OK + return lf.file, fuse.OK } func (f *FuseFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) { From 5d4efcb0a5498ea3e1e60b3b187604e93ce12348 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:56 -0700 Subject: [PATCH 177/357] fuse: Rename FuseFile to RawFrontendFile --- frontend/fusedev/fuse.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 858f47d4..e3403dc8 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -18,11 +18,11 @@ import ( type LonghornFs struct { pathfs.FileSystem - Volume string - file *FuseFile + Volume string + rawFile *RawFrontendFile } -type FuseFile struct { +type RawFrontendFile struct { nodefs.File Backend types.ReaderWriterAt Size int64 @@ -46,7 +46,7 @@ func newLonghornFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) return &LonghornFs{ FileSystem: pathfs.NewDefaultFileSystem(), Volume: name, - file: &FuseFile{ + rawFile: &RawFrontendFile{ File: nodefs.NewDefaultFile(), Backend: rw, Size: size, @@ -246,7 +246,7 @@ func (lf *LonghornFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, f switch name { case lf.getImageFileName(): return &fuse.Attr{ - Mode: fuse.S_IFREG | 0644, Size: uint64(lf.file.Size), + Mode: fuse.S_IFREG | 0644, Size: uint64(lf.rawFile.Size), }, fuse.OK case "": return &fuse.Attr{ @@ -267,10 +267,10 @@ func (lf *LonghornFs) Open(name string, flags uint32, context *fuse.Context) (no if name != lf.getImageFileName() { return nil, fuse.ENOENT } - return lf.file, fuse.OK + return lf.rawFile, fuse.OK } -func (f *FuseFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) { +func (f *RawFrontendFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) { l := int64(len(dest)) if off+l > f.Size { l = f.Size - off @@ -283,7 +283,7 @@ func (f *FuseFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) { return fuse.ReadResultData(dest[:l]), fuse.OK } -func (f *FuseFile) Write(data []byte, off int64) (uint32, fuse.Status) { +func (f *RawFrontendFile) Write(data []byte, off int64) (uint32, fuse.Status) { l := int64(len(data)) if off+l > f.Size { l = f.Size - off From 86cd54972a93bdd18522bfe88cb7c44e25b5c700 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 178/357] fuse: Switch to use `bazil/fuse` `hanwen/go-fuse` seems unable to handle direct io case, it will cause kernel hang on release the user page. --- frontend/fusedev/fuse.go | 133 +- trash.yml | 6 +- vendor/bazil.org/fuse/.gitattributes | 2 + vendor/bazil.org/fuse/.gitignore | 11 + vendor/bazil.org/fuse/LICENSE | 93 + vendor/bazil.org/fuse/README.md | 23 + vendor/bazil.org/fuse/buffer.go | 35 + vendor/bazil.org/fuse/debug.go | 21 + vendor/bazil.org/fuse/error_darwin.go | 17 + vendor/bazil.org/fuse/error_freebsd.go | 15 + vendor/bazil.org/fuse/error_linux.go | 17 + vendor/bazil.org/fuse/error_std.go | 31 + vendor/bazil.org/fuse/fs/serve.go | 1568 +++++++++++ vendor/bazil.org/fuse/fs/tree.go | 99 + vendor/bazil.org/fuse/fuse.go | 2303 +++++++++++++++++ vendor/bazil.org/fuse/fuse_darwin.go | 9 + vendor/bazil.org/fuse/fuse_freebsd.go | 6 + vendor/bazil.org/fuse/fuse_kernel.go | 774 ++++++ vendor/bazil.org/fuse/fuse_kernel_darwin.go | 88 + vendor/bazil.org/fuse/fuse_kernel_freebsd.go | 62 + vendor/bazil.org/fuse/fuse_kernel_linux.go | 70 + vendor/bazil.org/fuse/fuse_kernel_std.go | 1 + vendor/bazil.org/fuse/fuse_linux.go | 7 + vendor/bazil.org/fuse/fuseutil/fuseutil.go | 20 + vendor/bazil.org/fuse/mount.go | 38 + vendor/bazil.org/fuse/mount_darwin.go | 208 ++ vendor/bazil.org/fuse/mount_freebsd.go | 111 + vendor/bazil.org/fuse/mount_linux.go | 150 ++ vendor/bazil.org/fuse/options.go | 272 ++ vendor/bazil.org/fuse/options_darwin.go | 30 + vendor/bazil.org/fuse/options_freebsd.go | 24 + vendor/bazil.org/fuse/options_linux.go | 21 + vendor/bazil.org/fuse/protocol.go | 75 + vendor/bazil.org/fuse/unmount.go | 6 + vendor/bazil.org/fuse/unmount_linux.go | 21 + vendor/bazil.org/fuse/unmount_std.go | 17 + vendor/github.com/hanwen/go-fuse/.gitignore | 14 - vendor/github.com/hanwen/go-fuse/CONTRIBUTING | 22 - vendor/github.com/hanwen/go-fuse/LICENSE | 30 - vendor/github.com/hanwen/go-fuse/README | 150 -- vendor/github.com/hanwen/go-fuse/all.bash | 33 - .../github.com/hanwen/go-fuse/fuse/.gitignore | 1 - vendor/github.com/hanwen/go-fuse/fuse/api.go | 131 - vendor/github.com/hanwen/go-fuse/fuse/attr.go | 75 - .../hanwen/go-fuse/fuse/attr_darwin.go | 22 - .../hanwen/go-fuse/fuse/attr_linux.go | 23 - .../hanwen/go-fuse/fuse/bufferpool.go | 95 - .../hanwen/go-fuse/fuse/constants.go | 31 - .../hanwen/go-fuse/fuse/constants_freebsd.go | 5 - .../hanwen/go-fuse/fuse/constants_linux.go | 8 - .../hanwen/go-fuse/fuse/defaultraw.go | 148 -- .../hanwen/go-fuse/fuse/direntry.go | 98 - .../hanwen/go-fuse/fuse/lockingfs.go | 206 -- vendor/github.com/hanwen/go-fuse/fuse/misc.go | 84 - .../hanwen/go-fuse/fuse/mount_darwin.go | 145 -- .../hanwen/go-fuse/fuse/mount_linux.go | 152 -- .../hanwen/go-fuse/fuse/nodefs/api.go | 181 -- .../hanwen/go-fuse/fuse/nodefs/defaultfile.go | 70 - .../hanwen/go-fuse/fuse/nodefs/defaultnode.go | 165 -- .../hanwen/go-fuse/fuse/nodefs/dir.go | 114 - .../hanwen/go-fuse/fuse/nodefs/files.go | 249 -- .../go-fuse/fuse/nodefs/files_darwin.go | 99 - .../hanwen/go-fuse/fuse/nodefs/files_linux.go | 45 - .../hanwen/go-fuse/fuse/nodefs/fsconnector.go | 419 --- .../hanwen/go-fuse/fuse/nodefs/fsmount.go | 154 -- .../hanwen/go-fuse/fuse/nodefs/fsops.go | 465 ---- .../hanwen/go-fuse/fuse/nodefs/fuse.go | 15 - .../hanwen/go-fuse/fuse/nodefs/handle.go | 147 -- .../hanwen/go-fuse/fuse/nodefs/inode.go | 285 -- .../hanwen/go-fuse/fuse/nodefs/lockingfile.go | 99 - .../hanwen/go-fuse/fuse/nodefs/memnode.go | 228 -- .../hanwen/go-fuse/fuse/nodefs/nodefs.go | 9 - .../hanwen/go-fuse/fuse/nodefs/print.go | 14 - .../go-fuse/fuse/nodefs/syscall_linux.go | 16 - .../github.com/hanwen/go-fuse/fuse/opcode.go | 642 ----- .../hanwen/go-fuse/fuse/pathfs/api.go | 78 - .../hanwen/go-fuse/fuse/pathfs/copy.go | 57 - .../hanwen/go-fuse/fuse/pathfs/default.go | 118 - .../hanwen/go-fuse/fuse/pathfs/locking.go | 163 -- .../hanwen/go-fuse/fuse/pathfs/loopback.go | 162 -- .../go-fuse/fuse/pathfs/loopback_darwin.go | 59 - .../go-fuse/fuse/pathfs/loopback_linux.go | 79 - .../hanwen/go-fuse/fuse/pathfs/pathfs.go | 737 ------ .../hanwen/go-fuse/fuse/pathfs/prefixfs.go | 128 - .../hanwen/go-fuse/fuse/pathfs/readonlyfs.go | 119 - .../go-fuse/fuse/pathfs/syscall_linux.go | 140 - .../github.com/hanwen/go-fuse/fuse/print.go | 246 -- .../hanwen/go-fuse/fuse/print_darwin.go | 50 - .../hanwen/go-fuse/fuse/print_linux.go | 58 - vendor/github.com/hanwen/go-fuse/fuse/read.go | 71 - .../github.com/hanwen/go-fuse/fuse/request.go | 213 -- .../hanwen/go-fuse/fuse/request_darwin.go | 9 - .../hanwen/go-fuse/fuse/request_linux.go | 9 - .../github.com/hanwen/go-fuse/fuse/server.go | 519 ---- .../hanwen/go-fuse/fuse/server_darwin.go | 28 - .../hanwen/go-fuse/fuse/server_linux.go | 38 - .../hanwen/go-fuse/fuse/splice_darwin.go | 13 - .../hanwen/go-fuse/fuse/splice_linux.go | 93 - .../hanwen/go-fuse/fuse/syscall_darwin.go | 135 - .../hanwen/go-fuse/fuse/syscall_linux.go | 45 - .../hanwen/go-fuse/fuse/typeprint.go | 5 - .../github.com/hanwen/go-fuse/fuse/types.go | 431 --- .../hanwen/go-fuse/fuse/types_darwin.go | 131 - .../hanwen/go-fuse/fuse/types_linux.go | 98 - .../github.com/hanwen/go-fuse/fuse/upgrade.go | 320 --- .../github.com/hanwen/go-fuse/splice/copy.go | 66 - .../github.com/hanwen/go-fuse/splice/pair.go | 64 - .../hanwen/go-fuse/splice/pair_darwin.go | 18 - .../hanwen/go-fuse/splice/pair_linux.go | 33 - .../github.com/hanwen/go-fuse/splice/pool.go | 115 - .../hanwen/go-fuse/splice/splice.go | 86 - vendor/golang.org/x/net/context/context.go | 447 ++++ 112 files changed, 6769 insertions(+), 9685 deletions(-) create mode 100644 vendor/bazil.org/fuse/.gitattributes create mode 100644 vendor/bazil.org/fuse/.gitignore create mode 100644 vendor/bazil.org/fuse/LICENSE create mode 100644 vendor/bazil.org/fuse/README.md create mode 100644 vendor/bazil.org/fuse/buffer.go create mode 100644 vendor/bazil.org/fuse/debug.go create mode 100644 vendor/bazil.org/fuse/error_darwin.go create mode 100644 vendor/bazil.org/fuse/error_freebsd.go create mode 100644 vendor/bazil.org/fuse/error_linux.go create mode 100644 vendor/bazil.org/fuse/error_std.go create mode 100644 vendor/bazil.org/fuse/fs/serve.go create mode 100644 vendor/bazil.org/fuse/fs/tree.go create mode 100644 vendor/bazil.org/fuse/fuse.go create mode 100644 vendor/bazil.org/fuse/fuse_darwin.go create mode 100644 vendor/bazil.org/fuse/fuse_freebsd.go create mode 100644 vendor/bazil.org/fuse/fuse_kernel.go create mode 100644 vendor/bazil.org/fuse/fuse_kernel_darwin.go create mode 100644 vendor/bazil.org/fuse/fuse_kernel_freebsd.go create mode 100644 vendor/bazil.org/fuse/fuse_kernel_linux.go create mode 100644 vendor/bazil.org/fuse/fuse_kernel_std.go create mode 100644 vendor/bazil.org/fuse/fuse_linux.go create mode 100644 vendor/bazil.org/fuse/fuseutil/fuseutil.go create mode 100644 vendor/bazil.org/fuse/mount.go create mode 100644 vendor/bazil.org/fuse/mount_darwin.go create mode 100644 vendor/bazil.org/fuse/mount_freebsd.go create mode 100644 vendor/bazil.org/fuse/mount_linux.go create mode 100644 vendor/bazil.org/fuse/options.go create mode 100644 vendor/bazil.org/fuse/options_darwin.go create mode 100644 vendor/bazil.org/fuse/options_freebsd.go create mode 100644 vendor/bazil.org/fuse/options_linux.go create mode 100644 vendor/bazil.org/fuse/protocol.go create mode 100644 vendor/bazil.org/fuse/unmount.go create mode 100644 vendor/bazil.org/fuse/unmount_linux.go create mode 100644 vendor/bazil.org/fuse/unmount_std.go delete mode 100644 vendor/github.com/hanwen/go-fuse/.gitignore delete mode 100644 vendor/github.com/hanwen/go-fuse/CONTRIBUTING delete mode 100644 vendor/github.com/hanwen/go-fuse/LICENSE delete mode 100644 vendor/github.com/hanwen/go-fuse/README delete mode 100755 vendor/github.com/hanwen/go-fuse/all.bash delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/.gitignore delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/api.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/attr.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/constants.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/direntry.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/misc.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/opcode.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/print.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/print_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/read.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/request.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/request_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/server.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/server_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/typeprint.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/types.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/types_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/fuse/upgrade.go delete mode 100644 vendor/github.com/hanwen/go-fuse/splice/copy.go delete mode 100644 vendor/github.com/hanwen/go-fuse/splice/pair.go delete mode 100644 vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go delete mode 100644 vendor/github.com/hanwen/go-fuse/splice/pair_linux.go delete mode 100644 vendor/github.com/hanwen/go-fuse/splice/pool.go delete mode 100644 vendor/github.com/hanwen/go-fuse/splice/splice.go create mode 100644 vendor/golang.org/x/net/context/context.go diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index e3403dc8..bbf3ab95 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -7,23 +7,23 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" - "github.com/hanwen/go-fuse/fuse/pathfs" "github.com/rancher/convoy/util" + "golang.org/x/net/context" "golang.org/x/sys/unix" + "bazil.org/fuse" + "bazil.org/fuse/fs" + "github.com/rancher/longhorn/types" ) type LonghornFs struct { - pathfs.FileSystem + Conn *fuse.Conn Volume string rawFile *RawFrontendFile } type RawFrontendFile struct { - nodefs.File Backend types.ReaderWriterAt Size int64 SectorSize int64 @@ -44,10 +44,8 @@ var ( func newLonghornFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *LonghornFs { return &LonghornFs{ - FileSystem: pathfs.NewDefaultFileSystem(), - Volume: name, + Volume: name, rawFile: &RawFrontendFile{ - File: nodefs.NewDefaultFile(), Backend: rw, Size: size, SectorSize: sectorSize, @@ -56,26 +54,21 @@ func newLonghornFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) } func (lf *LonghornFs) Start() error { - newFs := pathfs.NewPathNodeFs(lf, nil) - + var err error mountDir := lf.GetMountDir() if err := os.MkdirAll(mountDir, 0700); err != nil { - log.Fatal("Cannot create directory ", mountDir) - } - server, _, err := nodefs.MountRoot(mountDir, newFs.Root(), nil) - /* - conn := nodefs.NewFileSystemConnector(newFs.Root(), nil) - opts := &fuse.MountOptions{ - MaxBackground: 12, - Options: []string{"direct_io"}, - } - server, err := fuse.NewServer(conn.RawFS(), fs.GetMountDir(), opts) - */ + return fmt.Errorf("Cannot create directory %v", mountDir) + } + lf.Conn, err = fuse.Mount(mountDir, + fuse.FSName("longhorn"), + fuse.Subtype("longhornfs"), + fuse.VolumeName(lf.Volume), + ) if err != nil { - return err + log.Fatal(err) } - // This will be stopped when umount happens - go server.Serve() + + go lf.startFs() if err := lf.createDev(); err != nil { return err @@ -83,7 +76,21 @@ func (lf *LonghornFs) Start() error { return nil } +func (lf *LonghornFs) startFs() { + if err := fs.Serve(lf.Conn, lf); err != nil { + log.Fatal(err) + } + + <-lf.Conn.Ready + if err := lf.Conn.MountError; err != nil { + log.Fatal(err) + } +} + func (lf *LonghornFs) Stop() error { + if lf.Conn != nil { + defer lf.Conn.Close() + } if err := lf.removeDev(); err != nil { return err } @@ -242,59 +249,65 @@ func (lf *LonghornFs) getImageFileFullPath() string { return filepath.Join(lf.GetMountDir(), lf.getImageFileName()) } -func (lf *LonghornFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { - switch name { - case lf.getImageFileName(): - return &fuse.Attr{ - Mode: fuse.S_IFREG | 0644, Size: uint64(lf.rawFile.Size), - }, fuse.OK - case "": - return &fuse.Attr{ - Mode: fuse.S_IFDIR | 0755, - }, fuse.OK - } - return nil, fuse.ENOENT +func (lf *LonghornFs) Root() (fs.Node, error) { + return lf, nil +} + +func (lf *LonghornFs) Attr(cxt context.Context, a *fuse.Attr) error { + a.Inode = 1 + a.Mode = os.ModeDir | 0555 + return nil } -func (lf *LonghornFs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { - if name == "" { - return []fuse.DirEntry{{Name: lf.getImageFileName(), Mode: fuse.S_IFREG}}, fuse.OK +func (lf *LonghornFs) Lookup(cxt context.Context, name string) (fs.Node, error) { + if name == lf.getImageFileName() { + return lf.rawFile, nil } return nil, fuse.ENOENT } -func (lf *LonghornFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) { - if name != lf.getImageFileName() { - return nil, fuse.ENOENT - } - return lf.rawFile, fuse.OK +func (lf *LonghornFs) ReadDirAll(cxt context.Context) ([]fuse.Dirent, error) { + return []fuse.Dirent{ + {Inode: 2, Name: lf.getImageFileName(), Type: fuse.DT_File}, + }, nil +} + +func (f *RawFrontendFile) Attr(ctx context.Context, a *fuse.Attr) error { + a.Inode = 2 + a.Mode = 0444 + a.Size = uint64(f.Size) + return nil +} + +func (f *RawFrontendFile) Open(cxt context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { + return f, nil } -func (f *RawFrontendFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) { - l := int64(len(dest)) - if off+l > f.Size { - l = f.Size - off +func (f *RawFrontendFile) Read(cxt context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error { + l := int64(req.Size) + if req.Offset+l > f.Size { + l = f.Size - req.Offset } - _, err := f.Backend.ReadAt(dest[:l], off) + _, err := f.Backend.ReadAt(resp.Data[:l], req.Offset) if err != nil { - log.Errorln("read failed: ", err.Error()) - return nil, fuse.EIO + return fmt.Errorf("read failed: %v", err) } - return fuse.ReadResultData(dest[:l]), fuse.OK + resp.Data = resp.Data[:l] + return nil } -func (f *RawFrontendFile) Write(data []byte, off int64) (uint32, fuse.Status) { - l := int64(len(data)) - if off+l > f.Size { - l = f.Size - off +func (f *RawFrontendFile) Write(cxt context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error { + l := int64(len(req.Data)) + if req.Offset+l > f.Size { + l = f.Size - req.Offset } - written, err := f.Backend.WriteAt(data[:l], off) + _, err := f.Backend.WriteAt(req.Data[:l], req.Offset) if err != nil { - log.Errorln("write failed: ", err.Error()) - return 0, fuse.EIO + return fmt.Errorf("write failed: %v", err) } - return uint32(written), fuse.OK + resp.Size = int(l) + return nil } func mknod(device string, major, minor int) error { diff --git a/trash.yml b/trash.yml index 8efd5d8d..0b7ddf42 100644 --- a/trash.yml +++ b/trash.yml @@ -58,5 +58,7 @@ import: version: c01cf91b011868172fdcd9f41838e80c9d716264 - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 -- package: github.com/hanwen/go-fuse - version: bd746dd8bcc8c059a9d953a786a6156eb83f398e +- package: bazil.org/fuse + version: b3d5a5514a27076c63844bde6d60703a7aea4adc +- package: golang.org/x/net/context + version: 31df19d69da8728e9220def59b80ee577c3e48bf diff --git a/vendor/bazil.org/fuse/.gitattributes b/vendor/bazil.org/fuse/.gitattributes new file mode 100644 index 00000000..b65f2a9f --- /dev/null +++ b/vendor/bazil.org/fuse/.gitattributes @@ -0,0 +1,2 @@ +*.go filter=gofmt +*.cgo filter=gofmt diff --git a/vendor/bazil.org/fuse/.gitignore b/vendor/bazil.org/fuse/.gitignore new file mode 100644 index 00000000..53589948 --- /dev/null +++ b/vendor/bazil.org/fuse/.gitignore @@ -0,0 +1,11 @@ +*~ +.#* +## the next line needs to start with a backslash to avoid looking like +## a comment +\#*# +.*.swp + +*.test + +/clockfs +/hellofs diff --git a/vendor/bazil.org/fuse/LICENSE b/vendor/bazil.org/fuse/LICENSE new file mode 100644 index 00000000..4ac7cd83 --- /dev/null +++ b/vendor/bazil.org/fuse/LICENSE @@ -0,0 +1,93 @@ +Copyright (c) 2013-2015 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/vendor/bazil.org/fuse/README.md b/vendor/bazil.org/fuse/README.md new file mode 100644 index 00000000..8c6d556e --- /dev/null +++ b/vendor/bazil.org/fuse/README.md @@ -0,0 +1,23 @@ +bazil.org/fuse -- Filesystems in Go +=================================== + +`bazil.org/fuse` is a Go library for writing FUSE userspace +filesystems. + +It is a from-scratch implementation of the kernel-userspace +communication protocol, and does not use the C library from the +project called FUSE. `bazil.org/fuse` embraces Go fully for safety and +ease of programming. + +Here’s how to get going: + + go get bazil.org/fuse + +Website: http://bazil.org/fuse/ + +Github repository: https://github.com/bazil/fuse + +API docs: http://godoc.org/bazil.org/fuse + +Our thanks to Russ Cox for his fuse library, which this project is +based on. diff --git a/vendor/bazil.org/fuse/buffer.go b/vendor/bazil.org/fuse/buffer.go new file mode 100644 index 00000000..bb1d2b77 --- /dev/null +++ b/vendor/bazil.org/fuse/buffer.go @@ -0,0 +1,35 @@ +package fuse + +import "unsafe" + +// buffer provides a mechanism for constructing a message from +// multiple segments. +type buffer []byte + +// alloc allocates size bytes and returns a pointer to the new +// segment. +func (w *buffer) alloc(size uintptr) unsafe.Pointer { + s := int(size) + if len(*w)+s > cap(*w) { + old := *w + *w = make([]byte, len(*w), 2*cap(*w)+s) + copy(*w, old) + } + l := len(*w) + *w = (*w)[:l+s] + return unsafe.Pointer(&(*w)[l]) +} + +// reset clears out the contents of the buffer. +func (w *buffer) reset() { + for i := range (*w)[:cap(*w)] { + (*w)[i] = 0 + } + *w = (*w)[:0] +} + +func newBuffer(extra uintptr) buffer { + const hdrSize = unsafe.Sizeof(outHeader{}) + buf := make(buffer, hdrSize, hdrSize+extra) + return buf +} diff --git a/vendor/bazil.org/fuse/debug.go b/vendor/bazil.org/fuse/debug.go new file mode 100644 index 00000000..be9f900d --- /dev/null +++ b/vendor/bazil.org/fuse/debug.go @@ -0,0 +1,21 @@ +package fuse + +import ( + "runtime" +) + +func stack() string { + buf := make([]byte, 1024) + return string(buf[:runtime.Stack(buf, false)]) +} + +func nop(msg interface{}) {} + +// Debug is called to output debug messages, including protocol +// traces. The default behavior is to do nothing. +// +// The messages have human-friendly string representations and are +// safe to marshal to JSON. +// +// Implementations must not retain msg. +var Debug func(msg interface{}) = nop diff --git a/vendor/bazil.org/fuse/error_darwin.go b/vendor/bazil.org/fuse/error_darwin.go new file mode 100644 index 00000000..a3fb89ca --- /dev/null +++ b/vendor/bazil.org/fuse/error_darwin.go @@ -0,0 +1,17 @@ +package fuse + +import ( + "syscall" +) + +const ( + ENOATTR = Errno(syscall.ENOATTR) +) + +const ( + errNoXattr = ENOATTR +) + +func init() { + errnoNames[errNoXattr] = "ENOATTR" +} diff --git a/vendor/bazil.org/fuse/error_freebsd.go b/vendor/bazil.org/fuse/error_freebsd.go new file mode 100644 index 00000000..c6ea6d6e --- /dev/null +++ b/vendor/bazil.org/fuse/error_freebsd.go @@ -0,0 +1,15 @@ +package fuse + +import "syscall" + +const ( + ENOATTR = Errno(syscall.ENOATTR) +) + +const ( + errNoXattr = ENOATTR +) + +func init() { + errnoNames[errNoXattr] = "ENOATTR" +} diff --git a/vendor/bazil.org/fuse/error_linux.go b/vendor/bazil.org/fuse/error_linux.go new file mode 100644 index 00000000..6f113e71 --- /dev/null +++ b/vendor/bazil.org/fuse/error_linux.go @@ -0,0 +1,17 @@ +package fuse + +import ( + "syscall" +) + +const ( + ENODATA = Errno(syscall.ENODATA) +) + +const ( + errNoXattr = ENODATA +) + +func init() { + errnoNames[errNoXattr] = "ENODATA" +} diff --git a/vendor/bazil.org/fuse/error_std.go b/vendor/bazil.org/fuse/error_std.go new file mode 100644 index 00000000..398f43fb --- /dev/null +++ b/vendor/bazil.org/fuse/error_std.go @@ -0,0 +1,31 @@ +package fuse + +// There is very little commonality in extended attribute errors +// across platforms. +// +// getxattr return value for "extended attribute does not exist" is +// ENOATTR on OS X, and ENODATA on Linux and apparently at least +// NetBSD. There may be a #define ENOATTR on Linux too, but the value +// is ENODATA in the actual syscalls. FreeBSD and OpenBSD have no +// ENODATA, only ENOATTR. ENOATTR is not in any of the standards, +// ENODATA exists but is only used for STREAMs. +// +// Each platform will define it a errNoXattr constant, and this file +// will enforce that it implements the right interfaces and hide the +// implementation. +// +// https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/getxattr.2.html +// http://mail-index.netbsd.org/tech-kern/2012/04/30/msg013090.html +// http://mail-index.netbsd.org/tech-kern/2012/04/30/msg013097.html +// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html +// http://www.freebsd.org/cgi/man.cgi?query=extattr_get_file&sektion=2 +// http://nixdoc.net/man-pages/openbsd/man2/extattr_get_file.2.html + +// ErrNoXattr is a platform-independent error value meaning the +// extended attribute was not found. It can be used to respond to +// GetxattrRequest and such. +const ErrNoXattr = errNoXattr + +var _ error = ErrNoXattr +var _ Errno = ErrNoXattr +var _ ErrorNumber = ErrNoXattr diff --git a/vendor/bazil.org/fuse/fs/serve.go b/vendor/bazil.org/fuse/fs/serve.go new file mode 100644 index 00000000..e9fc5659 --- /dev/null +++ b/vendor/bazil.org/fuse/fs/serve.go @@ -0,0 +1,1568 @@ +// FUSE service loop, for servers that wish to use it. + +package fs // import "bazil.org/fuse/fs" + +import ( + "encoding/binary" + "fmt" + "hash/fnv" + "io" + "log" + "reflect" + "runtime" + "strings" + "sync" + "time" + + "golang.org/x/net/context" +) + +import ( + "bytes" + + "bazil.org/fuse" + "bazil.org/fuse/fuseutil" +) + +const ( + attrValidTime = 1 * time.Minute + entryValidTime = 1 * time.Minute +) + +// TODO: FINISH DOCS + +// An FS is the interface required of a file system. +// +// Other FUSE requests can be handled by implementing methods from the +// FS* interfaces, for example FSStatfser. +type FS interface { + // Root is called to obtain the Node for the file system root. + Root() (Node, error) +} + +type FSStatfser interface { + // Statfs is called to obtain file system metadata. + // It should write that data to resp. + Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error +} + +type FSDestroyer interface { + // Destroy is called when the file system is shutting down. + // + // Linux only sends this request for block device backed (fuseblk) + // filesystems, to allow them to flush writes to disk before the + // unmount completes. + Destroy() +} + +type FSInodeGenerator interface { + // GenerateInode is called to pick a dynamic inode number when it + // would otherwise be 0. + // + // Not all filesystems bother tracking inodes, but FUSE requires + // the inode to be set, and fewer duplicates in general makes UNIX + // tools work better. + // + // Operations where the nodes may return 0 inodes include Getattr, + // Setattr and ReadDir. + // + // If FS does not implement FSInodeGenerator, GenerateDynamicInode + // is used. + // + // Implementing this is useful to e.g. constrain the range of + // inode values used for dynamic inodes. + GenerateInode(parentInode uint64, name string) uint64 +} + +// A Node is the interface required of a file or directory. +// See the documentation for type FS for general information +// pertaining to all methods. +// +// A Node must be usable as a map key, that is, it cannot be a +// function, map or slice. +// +// Other FUSE requests can be handled by implementing methods from the +// Node* interfaces, for example NodeOpener. +// +// Methods returning Node should take care to return the same Node +// when the result is logically the same instance. Without this, each +// Node will get a new NodeID, causing spurious cache invalidations, +// extra lookups and aliasing anomalies. This may not matter for a +// simple, read-only filesystem. +type Node interface { + // Attr fills attr with the standard metadata for the node. + // + // Fields with reasonable defaults are prepopulated. For example, + // all times are set to a fixed moment when the program started. + // + // If Inode is left as 0, a dynamic inode number is chosen. + // + // The result may be cached for the duration set in Valid. + Attr(ctx context.Context, attr *fuse.Attr) error +} + +type NodeGetattrer interface { + // Getattr obtains the standard metadata for the receiver. + // It should store that metadata in resp. + // + // If this method is not implemented, the attributes will be + // generated based on Attr(), with zero values filled in. + Getattr(ctx context.Context, req *fuse.GetattrRequest, resp *fuse.GetattrResponse) error +} + +type NodeSetattrer interface { + // Setattr sets the standard metadata for the receiver. + // + // Note, this is also used to communicate changes in the size of + // the file, outside of Writes. + // + // req.Valid is a bitmask of what fields are actually being set. + // For example, the method should not change the mode of the file + // unless req.Valid.Mode() is true. + Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error +} + +type NodeSymlinker interface { + // Symlink creates a new symbolic link in the receiver, which must be a directory. + // + // TODO is the above true about directories? + Symlink(ctx context.Context, req *fuse.SymlinkRequest) (Node, error) +} + +// This optional request will be called only for symbolic link nodes. +type NodeReadlinker interface { + // Readlink reads a symbolic link. + Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) +} + +type NodeLinker interface { + // Link creates a new directory entry in the receiver based on an + // existing Node. Receiver must be a directory. + Link(ctx context.Context, req *fuse.LinkRequest, old Node) (Node, error) +} + +type NodeRemover interface { + // Remove removes the entry with the given name from + // the receiver, which must be a directory. The entry to be removed + // may correspond to a file (unlink) or to a directory (rmdir). + Remove(ctx context.Context, req *fuse.RemoveRequest) error +} + +type NodeAccesser interface { + // Access checks whether the calling context has permission for + // the given operations on the receiver. If so, Access should + // return nil. If not, Access should return EPERM. + // + // Note that this call affects the result of the access(2) system + // call but not the open(2) system call. If Access is not + // implemented, the Node behaves as if it always returns nil + // (permission granted), relying on checks in Open instead. + Access(ctx context.Context, req *fuse.AccessRequest) error +} + +type NodeStringLookuper interface { + // Lookup looks up a specific entry in the receiver, + // which must be a directory. Lookup should return a Node + // corresponding to the entry. If the name does not exist in + // the directory, Lookup should return ENOENT. + // + // Lookup need not to handle the names "." and "..". + Lookup(ctx context.Context, name string) (Node, error) +} + +type NodeRequestLookuper interface { + // Lookup looks up a specific entry in the receiver. + // See NodeStringLookuper for more. + Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (Node, error) +} + +type NodeMkdirer interface { + Mkdir(ctx context.Context, req *fuse.MkdirRequest) (Node, error) +} + +type NodeOpener interface { + // Open opens the receiver. After a successful open, a client + // process has a file descriptor referring to this Handle. + // + // Open can also be also called on non-files. For example, + // directories are Opened for ReadDir or fchdir(2). + // + // If this method is not implemented, the open will always + // succeed, and the Node itself will be used as the Handle. + // + // XXX note about access. XXX OpenFlags. + Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (Handle, error) +} + +type NodeCreater interface { + // Create creates a new directory entry in the receiver, which + // must be a directory. + Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (Node, Handle, error) +} + +type NodeForgetter interface { + // Forget about this node. This node will not receive further + // method calls. + // + // Forget is not necessarily seen on unmount, as all nodes are + // implicitly forgotten as part part of the unmount. + Forget() +} + +type NodeRenamer interface { + Rename(ctx context.Context, req *fuse.RenameRequest, newDir Node) error +} + +type NodeMknoder interface { + Mknod(ctx context.Context, req *fuse.MknodRequest) (Node, error) +} + +// TODO this should be on Handle not Node +type NodeFsyncer interface { + Fsync(ctx context.Context, req *fuse.FsyncRequest) error +} + +type NodeGetxattrer interface { + // Getxattr gets an extended attribute by the given name from the + // node. + // + // If there is no xattr by that name, returns fuse.ErrNoXattr. + Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error +} + +type NodeListxattrer interface { + // Listxattr lists the extended attributes recorded for the node. + Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error +} + +type NodeSetxattrer interface { + // Setxattr sets an extended attribute with the given name and + // value for the node. + Setxattr(ctx context.Context, req *fuse.SetxattrRequest) error +} + +type NodeRemovexattrer interface { + // Removexattr removes an extended attribute for the name. + // + // If there is no xattr by that name, returns fuse.ErrNoXattr. + Removexattr(ctx context.Context, req *fuse.RemovexattrRequest) error +} + +var startTime = time.Now() + +func nodeAttr(ctx context.Context, n Node, attr *fuse.Attr) error { + attr.Valid = attrValidTime + attr.Nlink = 1 + attr.Atime = startTime + attr.Mtime = startTime + attr.Ctime = startTime + attr.Crtime = startTime + if err := n.Attr(ctx, attr); err != nil { + return err + } + return nil +} + +// A Handle is the interface required of an opened file or directory. +// See the documentation for type FS for general information +// pertaining to all methods. +// +// Other FUSE requests can be handled by implementing methods from the +// Handle* interfaces. The most common to implement are HandleReader, +// HandleReadDirer, and HandleWriter. +// +// TODO implement methods: Getlk, Setlk, Setlkw +type Handle interface { +} + +type HandleFlusher interface { + // Flush is called each time the file or directory is closed. + // Because there can be multiple file descriptors referring to a + // single opened file, Flush can be called multiple times. + Flush(ctx context.Context, req *fuse.FlushRequest) error +} + +type HandleReadAller interface { + ReadAll(ctx context.Context) ([]byte, error) +} + +type HandleReadDirAller interface { + ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) +} + +type HandleReader interface { + // Read requests to read data from the handle. + // + // There is a page cache in the kernel that normally submits only + // page-aligned reads spanning one or more pages. However, you + // should not rely on this. To see individual requests as + // submitted by the file system clients, set OpenDirectIO. + // + // Note that reads beyond the size of the file as reported by Attr + // are not even attempted (except in OpenDirectIO mode). + Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error +} + +type HandleWriter interface { + // Write requests to write data into the handle at the given offset. + // Store the amount of data written in resp.Size. + // + // There is a writeback page cache in the kernel that normally submits + // only page-aligned writes spanning one or more pages. However, + // you should not rely on this. To see individual requests as + // submitted by the file system clients, set OpenDirectIO. + // + // Writes that grow the file are expected to update the file size + // (as seen through Attr). Note that file size changes are + // communicated also through Setattr. + Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error +} + +type HandleReleaser interface { + Release(ctx context.Context, req *fuse.ReleaseRequest) error +} + +type Config struct { + // Function to send debug log messages to. If nil, use fuse.Debug. + // Note that changing this or fuse.Debug may not affect existing + // calls to Serve. + // + // See fuse.Debug for the rules that log functions must follow. + Debug func(msg interface{}) + + // Function to put things into context for processing the request. + // The returned context must have ctx as its parent. + // + // Note that changing this may not affect existing calls to Serve. + // + // Must not retain req. + WithContext func(ctx context.Context, req fuse.Request) context.Context +} + +// New returns a new FUSE server ready to serve this kernel FUSE +// connection. +// +// Config may be nil. +func New(conn *fuse.Conn, config *Config) *Server { + s := &Server{ + conn: conn, + req: map[fuse.RequestID]*serveRequest{}, + nodeRef: map[Node]fuse.NodeID{}, + dynamicInode: GenerateDynamicInode, + } + if config != nil { + s.debug = config.Debug + s.context = config.WithContext + } + if s.debug == nil { + s.debug = fuse.Debug + } + return s +} + +type Server struct { + // set in New + conn *fuse.Conn + debug func(msg interface{}) + context func(ctx context.Context, req fuse.Request) context.Context + + // set once at Serve time + fs FS + dynamicInode func(parent uint64, name string) uint64 + + // state, protected by meta + meta sync.Mutex + req map[fuse.RequestID]*serveRequest + node []*serveNode + nodeRef map[Node]fuse.NodeID + handle []*serveHandle + freeNode []fuse.NodeID + freeHandle []fuse.HandleID + nodeGen uint64 + + // Used to ensure worker goroutines finish before Serve returns + wg sync.WaitGroup +} + +// Serve serves the FUSE connection by making calls to the methods +// of fs and the Nodes and Handles it makes available. It returns only +// when the connection has been closed or an unexpected error occurs. +func (s *Server) Serve(fs FS) error { + defer s.wg.Wait() // Wait for worker goroutines to complete before return + + s.fs = fs + if dyn, ok := fs.(FSInodeGenerator); ok { + s.dynamicInode = dyn.GenerateInode + } + + root, err := fs.Root() + if err != nil { + return fmt.Errorf("cannot obtain root node: %v", err) + } + // Recognize the root node if it's ever returned from Lookup, + // passed to Invalidate, etc. + s.nodeRef[root] = 1 + s.node = append(s.node, nil, &serveNode{ + inode: 1, + generation: s.nodeGen, + node: root, + refs: 1, + }) + s.handle = append(s.handle, nil) + + for { + req, err := s.conn.ReadRequest() + if err != nil { + if err == io.EOF { + break + } + return err + } + + s.wg.Add(1) + go func() { + defer s.wg.Done() + s.serve(req) + }() + } + return nil +} + +// Serve serves a FUSE connection with the default settings. See +// Server.Serve. +func Serve(c *fuse.Conn, fs FS) error { + server := New(c, nil) + return server.Serve(fs) +} + +type nothing struct{} + +type serveRequest struct { + Request fuse.Request + cancel func() +} + +type serveNode struct { + inode uint64 + generation uint64 + node Node + refs uint64 + + // Delay freeing the NodeID until waitgroup is done. This allows + // using the NodeID for short periods of time without holding the + // Server.meta lock. + // + // Rules: + // + // - hold Server.meta while calling wg.Add, then unlock + // - do NOT try to reacquire Server.meta + wg sync.WaitGroup +} + +func (sn *serveNode) attr(ctx context.Context, attr *fuse.Attr) error { + err := nodeAttr(ctx, sn.node, attr) + if attr.Inode == 0 { + attr.Inode = sn.inode + } + return err +} + +type serveHandle struct { + handle Handle + readData []byte + nodeID fuse.NodeID +} + +// NodeRef is deprecated. It remains here to decrease code churn on +// FUSE library users. You may remove it from your program now; +// returning the same Node values are now recognized automatically, +// without needing NodeRef. +type NodeRef struct{} + +func (c *Server) saveNode(inode uint64, node Node) (id fuse.NodeID, gen uint64) { + c.meta.Lock() + defer c.meta.Unlock() + + if id, ok := c.nodeRef[node]; ok { + sn := c.node[id] + sn.refs++ + return id, sn.generation + } + + sn := &serveNode{inode: inode, node: node, refs: 1} + if n := len(c.freeNode); n > 0 { + id = c.freeNode[n-1] + c.freeNode = c.freeNode[:n-1] + c.node[id] = sn + c.nodeGen++ + } else { + id = fuse.NodeID(len(c.node)) + c.node = append(c.node, sn) + } + sn.generation = c.nodeGen + c.nodeRef[node] = id + return id, sn.generation +} + +func (c *Server) saveHandle(handle Handle, nodeID fuse.NodeID) (id fuse.HandleID) { + c.meta.Lock() + shandle := &serveHandle{handle: handle, nodeID: nodeID} + if n := len(c.freeHandle); n > 0 { + id = c.freeHandle[n-1] + c.freeHandle = c.freeHandle[:n-1] + c.handle[id] = shandle + } else { + id = fuse.HandleID(len(c.handle)) + c.handle = append(c.handle, shandle) + } + c.meta.Unlock() + return +} + +type nodeRefcountDropBug struct { + N uint64 + Refs uint64 + Node fuse.NodeID +} + +func (n *nodeRefcountDropBug) String() string { + return fmt.Sprintf("bug: trying to drop %d of %d references to %v", n.N, n.Refs, n.Node) +} + +func (c *Server) dropNode(id fuse.NodeID, n uint64) (forget bool) { + c.meta.Lock() + defer c.meta.Unlock() + snode := c.node[id] + + if snode == nil { + // this should only happen if refcounts kernel<->us disagree + // *and* two ForgetRequests for the same node race each other; + // this indicates a bug somewhere + c.debug(nodeRefcountDropBug{N: n, Node: id}) + + // we may end up triggering Forget twice, but that's better + // than not even once, and that's the best we can do + return true + } + + if n > snode.refs { + c.debug(nodeRefcountDropBug{N: n, Refs: snode.refs, Node: id}) + n = snode.refs + } + + snode.refs -= n + if snode.refs == 0 { + snode.wg.Wait() + c.node[id] = nil + delete(c.nodeRef, snode.node) + c.freeNode = append(c.freeNode, id) + return true + } + return false +} + +func (c *Server) dropHandle(id fuse.HandleID) { + c.meta.Lock() + c.handle[id] = nil + c.freeHandle = append(c.freeHandle, id) + c.meta.Unlock() +} + +type missingHandle struct { + Handle fuse.HandleID + MaxHandle fuse.HandleID +} + +func (m missingHandle) String() string { + return fmt.Sprint("missing handle: ", m.Handle, m.MaxHandle) +} + +// Returns nil for invalid handles. +func (c *Server) getHandle(id fuse.HandleID) (shandle *serveHandle) { + c.meta.Lock() + defer c.meta.Unlock() + if id < fuse.HandleID(len(c.handle)) { + shandle = c.handle[uint(id)] + } + if shandle == nil { + c.debug(missingHandle{ + Handle: id, + MaxHandle: fuse.HandleID(len(c.handle)), + }) + } + return +} + +type request struct { + Op string + Request *fuse.Header + In interface{} `json:",omitempty"` +} + +func (r request) String() string { + return fmt.Sprintf("<- %s", r.In) +} + +type logResponseHeader struct { + ID fuse.RequestID +} + +func (m logResponseHeader) String() string { + return fmt.Sprintf("ID=%v", m.ID) +} + +type response struct { + Op string + Request logResponseHeader + Out interface{} `json:",omitempty"` + // Errno contains the errno value as a string, for example "EPERM". + Errno string `json:",omitempty"` + // Error may contain a free form error message. + Error string `json:",omitempty"` +} + +func (r response) errstr() string { + s := r.Errno + if r.Error != "" { + // prefix the errno constant to the long form message + s = s + ": " + r.Error + } + return s +} + +func (r response) String() string { + switch { + case r.Errno != "" && r.Out != nil: + return fmt.Sprintf("-> [%v] %v error=%s", r.Request, r.Out, r.errstr()) + case r.Errno != "": + return fmt.Sprintf("-> [%v] %s error=%s", r.Request, r.Op, r.errstr()) + case r.Out != nil: + // make sure (seemingly) empty values are readable + switch r.Out.(type) { + case string: + return fmt.Sprintf("-> [%v] %s %q", r.Request, r.Op, r.Out) + case []byte: + return fmt.Sprintf("-> [%v] %s [% x]", r.Request, r.Op, r.Out) + default: + return fmt.Sprintf("-> [%v] %v", r.Request, r.Out) + } + default: + return fmt.Sprintf("-> [%v] %s", r.Request, r.Op) + } +} + +type notification struct { + Op string + Node fuse.NodeID + Out interface{} `json:",omitempty"` + Err string `json:",omitempty"` +} + +func (n notification) String() string { + var buf bytes.Buffer + fmt.Fprintf(&buf, "=> %s %v", n.Op, n.Node) + if n.Out != nil { + // make sure (seemingly) empty values are readable + switch n.Out.(type) { + case string: + fmt.Fprintf(&buf, " %q", n.Out) + case []byte: + fmt.Fprintf(&buf, " [% x]", n.Out) + default: + fmt.Fprintf(&buf, " %s", n.Out) + } + } + if n.Err != "" { + fmt.Fprintf(&buf, " Err:%v", n.Err) + } + return buf.String() +} + +type logMissingNode struct { + MaxNode fuse.NodeID +} + +func opName(req fuse.Request) string { + t := reflect.Indirect(reflect.ValueOf(req)).Type() + s := t.Name() + s = strings.TrimSuffix(s, "Request") + return s +} + +type logLinkRequestOldNodeNotFound struct { + Request *fuse.Header + In *fuse.LinkRequest +} + +func (m *logLinkRequestOldNodeNotFound) String() string { + return fmt.Sprintf("In LinkRequest (request %v), node %d not found", m.Request.Hdr().ID, m.In.OldNode) +} + +type renameNewDirNodeNotFound struct { + Request *fuse.Header + In *fuse.RenameRequest +} + +func (m *renameNewDirNodeNotFound) String() string { + return fmt.Sprintf("In RenameRequest (request %v), node %d not found", m.Request.Hdr().ID, m.In.NewDir) +} + +type handlerPanickedError struct { + Request interface{} + Err interface{} +} + +var _ error = handlerPanickedError{} + +func (h handlerPanickedError) Error() string { + return fmt.Sprintf("handler panicked: %v", h.Err) +} + +var _ fuse.ErrorNumber = handlerPanickedError{} + +func (h handlerPanickedError) Errno() fuse.Errno { + if err, ok := h.Err.(fuse.ErrorNumber); ok { + return err.Errno() + } + return fuse.DefaultErrno +} + +// handlerTerminatedError happens when a handler terminates itself +// with runtime.Goexit. This is most commonly because of incorrect use +// of testing.TB.FailNow, typically via t.Fatal. +type handlerTerminatedError struct { + Request interface{} +} + +var _ error = handlerTerminatedError{} + +func (h handlerTerminatedError) Error() string { + return fmt.Sprintf("handler terminated (called runtime.Goexit)") +} + +var _ fuse.ErrorNumber = handlerTerminatedError{} + +func (h handlerTerminatedError) Errno() fuse.Errno { + return fuse.DefaultErrno +} + +type handleNotReaderError struct { + handle Handle +} + +var _ error = handleNotReaderError{} + +func (e handleNotReaderError) Error() string { + return fmt.Sprintf("handle has no Read: %T", e.handle) +} + +var _ fuse.ErrorNumber = handleNotReaderError{} + +func (e handleNotReaderError) Errno() fuse.Errno { + return fuse.ENOTSUP +} + +func initLookupResponse(s *fuse.LookupResponse) { + s.EntryValid = entryValidTime +} + +func (c *Server) serve(r fuse.Request) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + parentCtx := ctx + if c.context != nil { + ctx = c.context(ctx, r) + } + + req := &serveRequest{Request: r, cancel: cancel} + + c.debug(request{ + Op: opName(r), + Request: r.Hdr(), + In: r, + }) + var node Node + var snode *serveNode + c.meta.Lock() + hdr := r.Hdr() + if id := hdr.Node; id != 0 { + if id < fuse.NodeID(len(c.node)) { + snode = c.node[uint(id)] + } + if snode == nil { + c.meta.Unlock() + c.debug(response{ + Op: opName(r), + Request: logResponseHeader{ID: hdr.ID}, + Error: fuse.ESTALE.ErrnoName(), + // this is the only place that sets both Error and + // Out; not sure if i want to do that; might get rid + // of len(c.node) things altogether + Out: logMissingNode{ + MaxNode: fuse.NodeID(len(c.node)), + }, + }) + r.RespondError(fuse.ESTALE) + return + } + node = snode.node + } + if c.req[hdr.ID] != nil { + // This happens with OSXFUSE. Assume it's okay and + // that we'll never see an interrupt for this one. + // Otherwise everything wedges. TODO: Report to OSXFUSE? + // + // TODO this might have been because of missing done() calls + } else { + c.req[hdr.ID] = req + } + c.meta.Unlock() + + // Call this before responding. + // After responding is too late: we might get another request + // with the same ID and be very confused. + done := func(resp interface{}) { + msg := response{ + Op: opName(r), + Request: logResponseHeader{ID: hdr.ID}, + } + if err, ok := resp.(error); ok { + msg.Error = err.Error() + if ferr, ok := err.(fuse.ErrorNumber); ok { + errno := ferr.Errno() + msg.Errno = errno.ErrnoName() + if errno == err { + // it's just a fuse.Errno with no extra detail; + // skip the textual message for log readability + msg.Error = "" + } + } else { + msg.Errno = fuse.DefaultErrno.ErrnoName() + } + } else { + msg.Out = resp + } + c.debug(msg) + + c.meta.Lock() + delete(c.req, hdr.ID) + c.meta.Unlock() + } + + var responded bool + defer func() { + if rec := recover(); rec != nil { + const size = 1 << 16 + buf := make([]byte, size) + n := runtime.Stack(buf, false) + buf = buf[:n] + log.Printf("fuse: panic in handler for %v: %v\n%s", r, rec, buf) + err := handlerPanickedError{ + Request: r, + Err: rec, + } + done(err) + r.RespondError(err) + return + } + + if !responded { + err := handlerTerminatedError{ + Request: r, + } + done(err) + r.RespondError(err) + } + }() + + if err := c.handleRequest(ctx, node, snode, r, done); err != nil { + if err == context.Canceled { + select { + case <-parentCtx.Done(): + // We canceled the parent context because of an + // incoming interrupt request, so return EINTR + // to trigger the right behavior in the client app. + // + // Only do this when it's the parent context that was + // canceled, not a context controlled by the program + // using this library, so we don't return EINTR too + // eagerly -- it might cause busy loops. + // + // Decent write-up on role of EINTR: + // http://250bpm.com/blog:12 + err = fuse.EINTR + default: + // nothing + } + } + done(err) + r.RespondError(err) + } + + // disarm runtime.Goexit protection + responded = true +} + +// handleRequest will either a) call done(s) and r.Respond(s) OR b) return an error. +func (c *Server) handleRequest(ctx context.Context, node Node, snode *serveNode, r fuse.Request, done func(resp interface{})) error { + switch r := r.(type) { + default: + // Note: To FUSE, ENOSYS means "this server never implements this request." + // It would be inappropriate to return ENOSYS for other operations in this + // switch that might only be unavailable in some contexts, not all. + return fuse.ENOSYS + + case *fuse.StatfsRequest: + s := &fuse.StatfsResponse{} + if fs, ok := c.fs.(FSStatfser); ok { + if err := fs.Statfs(ctx, r, s); err != nil { + return err + } + } + done(s) + r.Respond(s) + return nil + + // Node operations. + case *fuse.GetattrRequest: + s := &fuse.GetattrResponse{} + if n, ok := node.(NodeGetattrer); ok { + if err := n.Getattr(ctx, r, s); err != nil { + return err + } + } else { + if err := snode.attr(ctx, &s.Attr); err != nil { + return err + } + } + done(s) + r.Respond(s) + return nil + + case *fuse.SetattrRequest: + s := &fuse.SetattrResponse{} + if n, ok := node.(NodeSetattrer); ok { + if err := n.Setattr(ctx, r, s); err != nil { + return err + } + } + + if err := snode.attr(ctx, &s.Attr); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + + case *fuse.SymlinkRequest: + s := &fuse.SymlinkResponse{} + initLookupResponse(&s.LookupResponse) + n, ok := node.(NodeSymlinker) + if !ok { + return fuse.EIO // XXX or EPERM like Mkdir? + } + n2, err := n.Symlink(ctx, r) + if err != nil { + return err + } + if err := c.saveLookup(ctx, &s.LookupResponse, snode, r.NewName, n2); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + + case *fuse.ReadlinkRequest: + n, ok := node.(NodeReadlinker) + if !ok { + return fuse.EIO /// XXX or EPERM? + } + target, err := n.Readlink(ctx, r) + if err != nil { + return err + } + done(target) + r.Respond(target) + return nil + + case *fuse.LinkRequest: + n, ok := node.(NodeLinker) + if !ok { + return fuse.EIO /// XXX or EPERM? + } + c.meta.Lock() + var oldNode *serveNode + if int(r.OldNode) < len(c.node) { + oldNode = c.node[r.OldNode] + } + c.meta.Unlock() + if oldNode == nil { + c.debug(logLinkRequestOldNodeNotFound{ + Request: r.Hdr(), + In: r, + }) + return fuse.EIO + } + n2, err := n.Link(ctx, r, oldNode.node) + if err != nil { + return err + } + s := &fuse.LookupResponse{} + initLookupResponse(s) + if err := c.saveLookup(ctx, s, snode, r.NewName, n2); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + + case *fuse.RemoveRequest: + n, ok := node.(NodeRemover) + if !ok { + return fuse.EIO /// XXX or EPERM? + } + err := n.Remove(ctx, r) + if err != nil { + return err + } + done(nil) + r.Respond() + return nil + + case *fuse.AccessRequest: + if n, ok := node.(NodeAccesser); ok { + if err := n.Access(ctx, r); err != nil { + return err + } + } + done(nil) + r.Respond() + return nil + + case *fuse.LookupRequest: + var n2 Node + var err error + s := &fuse.LookupResponse{} + initLookupResponse(s) + if n, ok := node.(NodeStringLookuper); ok { + n2, err = n.Lookup(ctx, r.Name) + } else if n, ok := node.(NodeRequestLookuper); ok { + n2, err = n.Lookup(ctx, r, s) + } else { + return fuse.ENOENT + } + if err != nil { + return err + } + if err := c.saveLookup(ctx, s, snode, r.Name, n2); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + + case *fuse.MkdirRequest: + s := &fuse.MkdirResponse{} + initLookupResponse(&s.LookupResponse) + n, ok := node.(NodeMkdirer) + if !ok { + return fuse.EPERM + } + n2, err := n.Mkdir(ctx, r) + if err != nil { + return err + } + if err := c.saveLookup(ctx, &s.LookupResponse, snode, r.Name, n2); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + + case *fuse.OpenRequest: + s := &fuse.OpenResponse{} + var h2 Handle + if n, ok := node.(NodeOpener); ok { + hh, err := n.Open(ctx, r, s) + if err != nil { + return err + } + h2 = hh + } else { + h2 = node + } + s.Handle = c.saveHandle(h2, r.Hdr().Node) + done(s) + r.Respond(s) + return nil + + case *fuse.CreateRequest: + n, ok := node.(NodeCreater) + if !ok { + // If we send back ENOSYS, FUSE will try mknod+open. + return fuse.EPERM + } + s := &fuse.CreateResponse{OpenResponse: fuse.OpenResponse{}} + initLookupResponse(&s.LookupResponse) + n2, h2, err := n.Create(ctx, r, s) + if err != nil { + return err + } + if err := c.saveLookup(ctx, &s.LookupResponse, snode, r.Name, n2); err != nil { + return err + } + s.Handle = c.saveHandle(h2, r.Hdr().Node) + done(s) + r.Respond(s) + return nil + + case *fuse.GetxattrRequest: + n, ok := node.(NodeGetxattrer) + if !ok { + return fuse.ENOTSUP + } + s := &fuse.GetxattrResponse{} + err := n.Getxattr(ctx, r, s) + if err != nil { + return err + } + if r.Size != 0 && uint64(len(s.Xattr)) > uint64(r.Size) { + return fuse.ERANGE + } + done(s) + r.Respond(s) + return nil + + case *fuse.ListxattrRequest: + n, ok := node.(NodeListxattrer) + if !ok { + return fuse.ENOTSUP + } + s := &fuse.ListxattrResponse{} + err := n.Listxattr(ctx, r, s) + if err != nil { + return err + } + if r.Size != 0 && uint64(len(s.Xattr)) > uint64(r.Size) { + return fuse.ERANGE + } + done(s) + r.Respond(s) + return nil + + case *fuse.SetxattrRequest: + n, ok := node.(NodeSetxattrer) + if !ok { + return fuse.ENOTSUP + } + err := n.Setxattr(ctx, r) + if err != nil { + return err + } + done(nil) + r.Respond() + return nil + + case *fuse.RemovexattrRequest: + n, ok := node.(NodeRemovexattrer) + if !ok { + return fuse.ENOTSUP + } + err := n.Removexattr(ctx, r) + if err != nil { + return err + } + done(nil) + r.Respond() + return nil + + case *fuse.ForgetRequest: + forget := c.dropNode(r.Hdr().Node, r.N) + if forget { + n, ok := node.(NodeForgetter) + if ok { + n.Forget() + } + } + done(nil) + r.Respond() + return nil + + // Handle operations. + case *fuse.ReadRequest: + shandle := c.getHandle(r.Handle) + if shandle == nil { + return fuse.ESTALE + } + handle := shandle.handle + + s := &fuse.ReadResponse{Data: make([]byte, 0, r.Size)} + if r.Dir { + if h, ok := handle.(HandleReadDirAller); ok { + // detect rewinddir(3) or similar seek and refresh + // contents + if r.Offset == 0 { + shandle.readData = nil + } + + if shandle.readData == nil { + dirs, err := h.ReadDirAll(ctx) + if err != nil { + return err + } + var data []byte + for _, dir := range dirs { + if dir.Inode == 0 { + dir.Inode = c.dynamicInode(snode.inode, dir.Name) + } + data = fuse.AppendDirent(data, dir) + } + shandle.readData = data + } + fuseutil.HandleRead(r, s, shandle.readData) + done(s) + r.Respond(s) + return nil + } + } else { + if h, ok := handle.(HandleReadAller); ok { + if shandle.readData == nil { + data, err := h.ReadAll(ctx) + if err != nil { + return err + } + if data == nil { + data = []byte{} + } + shandle.readData = data + } + fuseutil.HandleRead(r, s, shandle.readData) + done(s) + r.Respond(s) + return nil + } + h, ok := handle.(HandleReader) + if !ok { + err := handleNotReaderError{handle: handle} + return err + } + if err := h.Read(ctx, r, s); err != nil { + return err + } + } + done(s) + r.Respond(s) + return nil + + case *fuse.WriteRequest: + shandle := c.getHandle(r.Handle) + if shandle == nil { + return fuse.ESTALE + } + + s := &fuse.WriteResponse{} + if h, ok := shandle.handle.(HandleWriter); ok { + if err := h.Write(ctx, r, s); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + } + return fuse.EIO + + case *fuse.FlushRequest: + shandle := c.getHandle(r.Handle) + if shandle == nil { + return fuse.ESTALE + } + handle := shandle.handle + + if h, ok := handle.(HandleFlusher); ok { + if err := h.Flush(ctx, r); err != nil { + return err + } + } + done(nil) + r.Respond() + return nil + + case *fuse.ReleaseRequest: + shandle := c.getHandle(r.Handle) + if shandle == nil { + return fuse.ESTALE + } + handle := shandle.handle + + // No matter what, release the handle. + c.dropHandle(r.Handle) + + if h, ok := handle.(HandleReleaser); ok { + if err := h.Release(ctx, r); err != nil { + return err + } + } + done(nil) + r.Respond() + return nil + + case *fuse.DestroyRequest: + if fs, ok := c.fs.(FSDestroyer); ok { + fs.Destroy() + } + done(nil) + r.Respond() + return nil + + case *fuse.RenameRequest: + c.meta.Lock() + var newDirNode *serveNode + if int(r.NewDir) < len(c.node) { + newDirNode = c.node[r.NewDir] + } + c.meta.Unlock() + if newDirNode == nil { + c.debug(renameNewDirNodeNotFound{ + Request: r.Hdr(), + In: r, + }) + return fuse.EIO + } + n, ok := node.(NodeRenamer) + if !ok { + return fuse.EIO // XXX or EPERM like Mkdir? + } + err := n.Rename(ctx, r, newDirNode.node) + if err != nil { + return err + } + done(nil) + r.Respond() + return nil + + case *fuse.MknodRequest: + n, ok := node.(NodeMknoder) + if !ok { + return fuse.EIO + } + n2, err := n.Mknod(ctx, r) + if err != nil { + return err + } + s := &fuse.LookupResponse{} + initLookupResponse(s) + if err := c.saveLookup(ctx, s, snode, r.Name, n2); err != nil { + return err + } + done(s) + r.Respond(s) + return nil + + case *fuse.FsyncRequest: + n, ok := node.(NodeFsyncer) + if !ok { + return fuse.EIO + } + err := n.Fsync(ctx, r) + if err != nil { + return err + } + done(nil) + r.Respond() + return nil + + case *fuse.InterruptRequest: + c.meta.Lock() + ireq := c.req[r.IntrID] + if ireq != nil && ireq.cancel != nil { + ireq.cancel() + ireq.cancel = nil + } + c.meta.Unlock() + done(nil) + r.Respond() + return nil + + /* case *FsyncdirRequest: + return ENOSYS + + case *GetlkRequest, *SetlkRequest, *SetlkwRequest: + return ENOSYS + + case *BmapRequest: + return ENOSYS + + case *SetvolnameRequest, *GetxtimesRequest, *ExchangeRequest: + return ENOSYS + */ + } + + panic("not reached") +} + +func (c *Server) saveLookup(ctx context.Context, s *fuse.LookupResponse, snode *serveNode, elem string, n2 Node) error { + if err := nodeAttr(ctx, n2, &s.Attr); err != nil { + return err + } + if s.Attr.Inode == 0 { + s.Attr.Inode = c.dynamicInode(snode.inode, elem) + } + + s.Node, s.Generation = c.saveNode(s.Attr.Inode, n2) + return nil +} + +type invalidateNodeDetail struct { + Off int64 + Size int64 +} + +func (i invalidateNodeDetail) String() string { + return fmt.Sprintf("Off:%d Size:%d", i.Off, i.Size) +} + +func errstr(err error) string { + if err == nil { + return "" + } + return err.Error() +} + +func (s *Server) invalidateNode(node Node, off int64, size int64) error { + s.meta.Lock() + id, ok := s.nodeRef[node] + if ok { + snode := s.node[id] + snode.wg.Add(1) + defer snode.wg.Done() + } + s.meta.Unlock() + if !ok { + // This is what the kernel would have said, if we had been + // able to send this message; it's not cached. + return fuse.ErrNotCached + } + // Delay logging until after we can record the error too. We + // consider a /dev/fuse write to be instantaneous enough to not + // need separate before and after messages. + err := s.conn.InvalidateNode(id, off, size) + s.debug(notification{ + Op: "InvalidateNode", + Node: id, + Out: invalidateNodeDetail{ + Off: off, + Size: size, + }, + Err: errstr(err), + }) + return err +} + +// InvalidateNodeAttr invalidates the kernel cache of the attributes +// of node. +// +// Returns fuse.ErrNotCached if the kernel is not currently caching +// the node. +func (s *Server) InvalidateNodeAttr(node Node) error { + return s.invalidateNode(node, 0, 0) +} + +// InvalidateNodeData invalidates the kernel cache of the attributes +// and data of node. +// +// Returns fuse.ErrNotCached if the kernel is not currently caching +// the node. +func (s *Server) InvalidateNodeData(node Node) error { + return s.invalidateNode(node, 0, -1) +} + +// InvalidateNodeDataRange invalidates the kernel cache of the +// attributes and a range of the data of node. +// +// Returns fuse.ErrNotCached if the kernel is not currently caching +// the node. +func (s *Server) InvalidateNodeDataRange(node Node, off int64, size int64) error { + return s.invalidateNode(node, off, size) +} + +type invalidateEntryDetail struct { + Name string +} + +func (i invalidateEntryDetail) String() string { + return fmt.Sprintf("%q", i.Name) +} + +// InvalidateEntry invalidates the kernel cache of the directory entry +// identified by parent node and entry basename. +// +// Kernel may or may not cache directory listings. To invalidate +// those, use InvalidateNode to invalidate all of the data for a +// directory. (As of 2015-06, Linux FUSE does not cache directory +// listings.) +// +// Returns ErrNotCached if the kernel is not currently caching the +// node. +func (s *Server) InvalidateEntry(parent Node, name string) error { + s.meta.Lock() + id, ok := s.nodeRef[parent] + if ok { + snode := s.node[id] + snode.wg.Add(1) + defer snode.wg.Done() + } + s.meta.Unlock() + if !ok { + // This is what the kernel would have said, if we had been + // able to send this message; it's not cached. + return fuse.ErrNotCached + } + err := s.conn.InvalidateEntry(id, name) + s.debug(notification{ + Op: "InvalidateEntry", + Node: id, + Out: invalidateEntryDetail{ + Name: name, + }, + Err: errstr(err), + }) + return err +} + +// DataHandle returns a read-only Handle that satisfies reads +// using the given data. +func DataHandle(data []byte) Handle { + return &dataHandle{data} +} + +type dataHandle struct { + data []byte +} + +func (d *dataHandle) ReadAll(ctx context.Context) ([]byte, error) { + return d.data, nil +} + +// GenerateDynamicInode returns a dynamic inode. +// +// The parent inode and current entry name are used as the criteria +// for choosing a pseudorandom inode. This makes it likely the same +// entry will get the same inode on multiple runs. +func GenerateDynamicInode(parent uint64, name string) uint64 { + h := fnv.New64a() + var buf [8]byte + binary.LittleEndian.PutUint64(buf[:], parent) + _, _ = h.Write(buf[:]) + _, _ = h.Write([]byte(name)) + var inode uint64 + for { + inode = h.Sum64() + if inode != 0 { + break + } + // there's a tiny probability that result is zero; change the + // input a little and try again + _, _ = h.Write([]byte{'x'}) + } + return inode +} diff --git a/vendor/bazil.org/fuse/fs/tree.go b/vendor/bazil.org/fuse/fs/tree.go new file mode 100644 index 00000000..7e078045 --- /dev/null +++ b/vendor/bazil.org/fuse/fs/tree.go @@ -0,0 +1,99 @@ +// FUSE directory tree, for servers that wish to use it with the service loop. + +package fs + +import ( + "os" + pathpkg "path" + "strings" + + "golang.org/x/net/context" +) + +import ( + "bazil.org/fuse" +) + +// A Tree implements a basic read-only directory tree for FUSE. +// The Nodes contained in it may still be writable. +type Tree struct { + tree +} + +func (t *Tree) Root() (Node, error) { + return &t.tree, nil +} + +// Add adds the path to the tree, resolving to the given node. +// If path or a prefix of path has already been added to the tree, +// Add panics. +// +// Add is only safe to call before starting to serve requests. +func (t *Tree) Add(path string, node Node) { + path = pathpkg.Clean("/" + path)[1:] + elems := strings.Split(path, "/") + dir := Node(&t.tree) + for i, elem := range elems { + dt, ok := dir.(*tree) + if !ok { + panic("fuse: Tree.Add for " + strings.Join(elems[:i], "/") + " and " + path) + } + n := dt.lookup(elem) + if n != nil { + if i+1 == len(elems) { + panic("fuse: Tree.Add for " + path + " conflicts with " + elem) + } + dir = n + } else { + if i+1 == len(elems) { + dt.add(elem, node) + } else { + dir = &tree{} + dt.add(elem, dir) + } + } + } +} + +type treeDir struct { + name string + node Node +} + +type tree struct { + dir []treeDir +} + +func (t *tree) lookup(name string) Node { + for _, d := range t.dir { + if d.name == name { + return d.node + } + } + return nil +} + +func (t *tree) add(name string, n Node) { + t.dir = append(t.dir, treeDir{name, n}) +} + +func (t *tree) Attr(ctx context.Context, a *fuse.Attr) error { + a.Mode = os.ModeDir | 0555 + return nil +} + +func (t *tree) Lookup(ctx context.Context, name string) (Node, error) { + n := t.lookup(name) + if n != nil { + return n, nil + } + return nil, fuse.ENOENT +} + +func (t *tree) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { + var out []fuse.Dirent + for _, d := range t.dir { + out = append(out, fuse.Dirent{Name: d.name}) + } + return out, nil +} diff --git a/vendor/bazil.org/fuse/fuse.go b/vendor/bazil.org/fuse/fuse.go new file mode 100644 index 00000000..6db0ef29 --- /dev/null +++ b/vendor/bazil.org/fuse/fuse.go @@ -0,0 +1,2303 @@ +// See the file LICENSE for copyright and licensing information. + +// 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. + +// Package fuse enables writing FUSE file systems on Linux, OS X, and FreeBSD. +// +// On OS X, it requires OSXFUSE (http://osxfuse.github.com/). +// +// There are two approaches to writing a FUSE file system. The first is to speak +// the low-level message protocol, reading from a Conn using ReadRequest and +// writing using the various Respond methods. This approach is closest to +// the actual interaction with the kernel and can be the simplest one in contexts +// such as protocol translators. +// +// Servers of synthesized file systems tend to share common +// bookkeeping abstracted away by the second approach, which is to +// call fs.Serve to serve the FUSE protocol using an implementation of +// the service methods in the interfaces FS* (file system), Node* (file +// or directory), and Handle* (opened file or directory). +// There are a daunting number of such methods that can be written, +// but few are required. +// The specific methods are described in the documentation for those interfaces. +// +// The hellofs subdirectory contains a simple illustration of the fs.Serve approach. +// +// Service Methods +// +// The required and optional methods for the FS, Node, and Handle interfaces +// have the general form +// +// Op(ctx context.Context, req *OpRequest, resp *OpResponse) error +// +// where Op is the name of a FUSE operation. Op reads request +// parameters from req and writes results to resp. An operation whose +// only result is the error result omits the resp parameter. +// +// Multiple goroutines may call service methods simultaneously; the +// methods being called are responsible for appropriate +// synchronization. +// +// The operation must not hold on to the request or response, +// including any []byte fields such as WriteRequest.Data or +// SetxattrRequest.Xattr. +// +// Errors +// +// Operations can return errors. The FUSE interface can only +// communicate POSIX errno error numbers to file system clients, the +// message is not visible to file system clients. The returned error +// can implement ErrorNumber to control the errno returned. Without +// ErrorNumber, a generic errno (EIO) is returned. +// +// Error messages will be visible in the debug log as part of the +// response. +// +// Interrupted Operations +// +// In some file systems, some operations +// may take an undetermined amount of time. For example, a Read waiting for +// a network message or a matching Write might wait indefinitely. If the request +// is cancelled and no longer needed, the context will be cancelled. +// Blocking operations should select on a receive from ctx.Done() and attempt to +// abort the operation early if the receive succeeds (meaning the channel is closed). +// To indicate that the operation failed because it was aborted, return fuse.EINTR. +// +// If an operation does not block for an indefinite amount of time, supporting +// cancellation is not necessary. +// +// Authentication +// +// All requests types embed a Header, meaning that the method can +// inspect req.Pid, req.Uid, and req.Gid as necessary to implement +// permission checking. The kernel FUSE layer normally prevents other +// users from accessing the FUSE file system (to change this, see +// AllowOther, AllowRoot), but does not enforce access modes (to +// change this, see DefaultPermissions). +// +// Mount Options +// +// Behavior and metadata of the mounted file system can be changed by +// passing MountOption values to Mount. +// +package fuse // import "bazil.org/fuse" + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "sync" + "syscall" + "time" + "unsafe" +) + +// A Conn represents a connection to a mounted FUSE file system. +type Conn struct { + // Ready is closed when the mount is complete or has failed. + Ready <-chan struct{} + + // MountError stores any error from the mount process. Only valid + // after Ready is closed. + MountError error + + // File handle for kernel communication. Only safe to access if + // rio or wio is held. + dev *os.File + wio sync.RWMutex + rio sync.RWMutex + + // Protocol version negotiated with InitRequest/InitResponse. + proto Protocol +} + +// MountpointDoesNotExistError is an error returned when the +// mountpoint does not exist. +type MountpointDoesNotExistError struct { + Path string +} + +var _ error = (*MountpointDoesNotExistError)(nil) + +func (e *MountpointDoesNotExistError) Error() string { + return fmt.Sprintf("mountpoint does not exist: %v", e.Path) +} + +// Mount mounts a new FUSE connection on the named directory +// and returns a connection for reading and writing FUSE messages. +// +// After a successful return, caller must call Close to free +// resources. +// +// Even on successful return, the new mount is not guaranteed to be +// visible until after Conn.Ready is closed. See Conn.MountError for +// possible errors. Incoming requests on Conn must be served to make +// progress. +func Mount(dir string, options ...MountOption) (*Conn, error) { + conf := mountConfig{ + options: make(map[string]string), + } + for _, option := range options { + if err := option(&conf); err != nil { + return nil, err + } + } + + ready := make(chan struct{}, 1) + c := &Conn{ + Ready: ready, + } + f, err := mount(dir, &conf, ready, &c.MountError) + if err != nil { + return nil, err + } + c.dev = f + + if err := initMount(c, &conf); err != nil { + c.Close() + if err == ErrClosedWithoutInit { + // see if we can provide a better error + <-c.Ready + if err := c.MountError; err != nil { + return nil, err + } + } + return nil, err + } + + return c, nil +} + +type OldVersionError struct { + Kernel Protocol + LibraryMin Protocol +} + +func (e *OldVersionError) Error() string { + return fmt.Sprintf("kernel FUSE version is too old: %v < %v", e.Kernel, e.LibraryMin) +} + +var ( + ErrClosedWithoutInit = errors.New("fuse connection closed without init") +) + +func initMount(c *Conn, conf *mountConfig) error { + req, err := c.ReadRequest() + if err != nil { + if err == io.EOF { + return ErrClosedWithoutInit + } + return err + } + r, ok := req.(*InitRequest) + if !ok { + return fmt.Errorf("missing init, got: %T", req) + } + + min := Protocol{protoVersionMinMajor, protoVersionMinMinor} + if r.Kernel.LT(min) { + req.RespondError(Errno(syscall.EPROTO)) + c.Close() + return &OldVersionError{ + Kernel: r.Kernel, + LibraryMin: min, + } + } + + proto := Protocol{protoVersionMaxMajor, protoVersionMaxMinor} + if r.Kernel.LT(proto) { + // Kernel doesn't support the latest version we have. + proto = r.Kernel + } + c.proto = proto + + s := &InitResponse{ + Library: proto, + MaxReadahead: conf.maxReadahead, + MaxWrite: maxWrite, + Flags: InitBigWrites | conf.initFlags, + } + r.Respond(s) + return nil +} + +// A Request represents a single FUSE request received from the kernel. +// Use a type switch to determine the specific kind. +// A request of unrecognized type will have concrete type *Header. +type Request interface { + // Hdr returns the Header associated with this request. + Hdr() *Header + + // RespondError responds to the request with the given error. + RespondError(error) + + String() string +} + +// A RequestID identifies an active FUSE request. +type RequestID uint64 + +func (r RequestID) String() string { + return fmt.Sprintf("%#x", uint64(r)) +} + +// A NodeID is a number identifying a directory or file. +// It must be unique among IDs returned in LookupResponses +// that have not yet been forgotten by ForgetRequests. +type NodeID uint64 + +func (n NodeID) String() string { + return fmt.Sprintf("%#x", uint64(n)) +} + +// A HandleID is a number identifying an open directory or file. +// It only needs to be unique while the directory or file is open. +type HandleID uint64 + +func (h HandleID) String() string { + return fmt.Sprintf("%#x", uint64(h)) +} + +// The RootID identifies the root directory of a FUSE file system. +const RootID NodeID = rootID + +// A Header describes the basic information sent in every request. +type Header struct { + Conn *Conn `json:"-"` // connection this request was received on + ID RequestID // unique ID for request + Node NodeID // file or directory the request is about + Uid uint32 // user ID of process making request + Gid uint32 // group ID of process making request + Pid uint32 // process ID of process making request + + // for returning to reqPool + msg *message +} + +func (h *Header) String() string { + return fmt.Sprintf("ID=%v Node=%v Uid=%d Gid=%d Pid=%d", h.ID, h.Node, h.Uid, h.Gid, h.Pid) +} + +func (h *Header) Hdr() *Header { + return h +} + +func (h *Header) noResponse() { + putMessage(h.msg) +} + +func (h *Header) respond(msg []byte) { + out := (*outHeader)(unsafe.Pointer(&msg[0])) + out.Unique = uint64(h.ID) + h.Conn.respond(msg) + putMessage(h.msg) +} + +// An ErrorNumber is an error with a specific error number. +// +// Operations may return an error value that implements ErrorNumber to +// control what specific error number (errno) to return. +type ErrorNumber interface { + // Errno returns the the error number (errno) for this error. + Errno() Errno +} + +const ( + // ENOSYS indicates that the call is not supported. + ENOSYS = Errno(syscall.ENOSYS) + + // ESTALE is used by Serve to respond to violations of the FUSE protocol. + ESTALE = Errno(syscall.ESTALE) + + ENOENT = Errno(syscall.ENOENT) + EIO = Errno(syscall.EIO) + EPERM = Errno(syscall.EPERM) + + // EINTR indicates request was interrupted by an InterruptRequest. + // See also fs.Intr. + EINTR = Errno(syscall.EINTR) + + ERANGE = Errno(syscall.ERANGE) + ENOTSUP = Errno(syscall.ENOTSUP) + EEXIST = Errno(syscall.EEXIST) +) + +// DefaultErrno is the errno used when error returned does not +// implement ErrorNumber. +const DefaultErrno = EIO + +var errnoNames = map[Errno]string{ + ENOSYS: "ENOSYS", + ESTALE: "ESTALE", + ENOENT: "ENOENT", + EIO: "EIO", + EPERM: "EPERM", + EINTR: "EINTR", + EEXIST: "EEXIST", +} + +// Errno implements Error and ErrorNumber using a syscall.Errno. +type Errno syscall.Errno + +var _ = ErrorNumber(Errno(0)) +var _ = error(Errno(0)) + +func (e Errno) Errno() Errno { + return e +} + +func (e Errno) String() string { + return syscall.Errno(e).Error() +} + +func (e Errno) Error() string { + return syscall.Errno(e).Error() +} + +// ErrnoName returns the short non-numeric identifier for this errno. +// For example, "EIO". +func (e Errno) ErrnoName() string { + s := errnoNames[e] + if s == "" { + s = fmt.Sprint(e.Errno()) + } + return s +} + +func (e Errno) MarshalText() ([]byte, error) { + s := e.ErrnoName() + return []byte(s), nil +} + +func (h *Header) RespondError(err error) { + errno := DefaultErrno + if ferr, ok := err.(ErrorNumber); ok { + errno = ferr.Errno() + } + // FUSE uses negative errors! + // TODO: File bug report against OSXFUSE: positive error causes kernel panic. + buf := newBuffer(0) + hOut := (*outHeader)(unsafe.Pointer(&buf[0])) + hOut.Error = -int32(errno) + h.respond(buf) +} + +// All requests read from the kernel, without data, are shorter than +// this. +var maxRequestSize = syscall.Getpagesize() +var bufSize = maxRequestSize + maxWrite + +// reqPool is a pool of messages. +// +// Lifetime of a logical message is from getMessage to putMessage. +// getMessage is called by ReadRequest. putMessage is called by +// Conn.ReadRequest, Request.Respond, or Request.RespondError. +// +// Messages in the pool are guaranteed to have conn and off zeroed, +// buf allocated and len==bufSize, and hdr set. +var reqPool = sync.Pool{ + New: allocMessage, +} + +func allocMessage() interface{} { + m := &message{buf: make([]byte, bufSize)} + m.hdr = (*inHeader)(unsafe.Pointer(&m.buf[0])) + return m +} + +func getMessage(c *Conn) *message { + m := reqPool.Get().(*message) + m.conn = c + return m +} + +func putMessage(m *message) { + m.buf = m.buf[:bufSize] + m.conn = nil + m.off = 0 + reqPool.Put(m) +} + +// a message represents the bytes of a single FUSE message +type message struct { + conn *Conn + buf []byte // all bytes + hdr *inHeader // header + off int // offset for reading additional fields +} + +func (m *message) len() uintptr { + return uintptr(len(m.buf) - m.off) +} + +func (m *message) data() unsafe.Pointer { + var p unsafe.Pointer + if m.off < len(m.buf) { + p = unsafe.Pointer(&m.buf[m.off]) + } + return p +} + +func (m *message) bytes() []byte { + return m.buf[m.off:] +} + +func (m *message) Header() Header { + h := m.hdr + return Header{ + Conn: m.conn, + ID: RequestID(h.Unique), + Node: NodeID(h.Nodeid), + Uid: h.Uid, + Gid: h.Gid, + Pid: h.Pid, + + msg: m, + } +} + +// fileMode returns a Go os.FileMode from a Unix mode. +func fileMode(unixMode uint32) os.FileMode { + mode := os.FileMode(unixMode & 0777) + switch unixMode & syscall.S_IFMT { + case syscall.S_IFREG: + // nothing + case syscall.S_IFDIR: + mode |= os.ModeDir + case syscall.S_IFCHR: + mode |= os.ModeCharDevice | os.ModeDevice + case syscall.S_IFBLK: + mode |= os.ModeDevice + case syscall.S_IFIFO: + mode |= os.ModeNamedPipe + case syscall.S_IFLNK: + mode |= os.ModeSymlink + case syscall.S_IFSOCK: + mode |= os.ModeSocket + default: + // no idea + mode |= os.ModeDevice + } + if unixMode&syscall.S_ISUID != 0 { + mode |= os.ModeSetuid + } + if unixMode&syscall.S_ISGID != 0 { + mode |= os.ModeSetgid + } + return mode +} + +type noOpcode struct { + Opcode uint32 +} + +func (m noOpcode) String() string { + return fmt.Sprintf("No opcode %v", m.Opcode) +} + +type malformedMessage struct { +} + +func (malformedMessage) String() string { + return "malformed message" +} + +// Close closes the FUSE connection. +func (c *Conn) Close() error { + c.wio.Lock() + defer c.wio.Unlock() + c.rio.Lock() + defer c.rio.Unlock() + return c.dev.Close() +} + +// caller must hold wio or rio +func (c *Conn) fd() int { + return int(c.dev.Fd()) +} + +func (c *Conn) Protocol() Protocol { + return c.proto +} + +// ReadRequest returns the next FUSE request from the kernel. +// +// Caller must call either Request.Respond or Request.RespondError in +// a reasonable time. Caller must not retain Request after that call. +func (c *Conn) ReadRequest() (Request, error) { + m := getMessage(c) +loop: + c.rio.RLock() + n, err := syscall.Read(c.fd(), m.buf) + c.rio.RUnlock() + if err == syscall.EINTR { + // OSXFUSE sends EINTR to userspace when a request interrupt + // completed before it got sent to userspace? + goto loop + } + if err != nil && err != syscall.ENODEV { + putMessage(m) + return nil, err + } + if n <= 0 { + putMessage(m) + return nil, io.EOF + } + m.buf = m.buf[:n] + + if n < inHeaderSize { + putMessage(m) + return nil, errors.New("fuse: message too short") + } + + // FreeBSD FUSE sends a short length in the header + // for FUSE_INIT even though the actual read length is correct. + if n == inHeaderSize+initInSize && m.hdr.Opcode == opInit && m.hdr.Len < uint32(n) { + m.hdr.Len = uint32(n) + } + + // OSXFUSE sometimes sends the wrong m.hdr.Len in a FUSE_WRITE message. + if m.hdr.Len < uint32(n) && m.hdr.Len >= uint32(unsafe.Sizeof(writeIn{})) && m.hdr.Opcode == opWrite { + m.hdr.Len = uint32(n) + } + + if m.hdr.Len != uint32(n) { + // prepare error message before returning m to pool + err := fmt.Errorf("fuse: read %d opcode %d but expected %d", n, m.hdr.Opcode, m.hdr.Len) + putMessage(m) + return nil, err + } + + m.off = inHeaderSize + + // Convert to data structures. + // Do not trust kernel to hand us well-formed data. + var req Request + switch m.hdr.Opcode { + default: + Debug(noOpcode{Opcode: m.hdr.Opcode}) + goto unrecognized + + case opLookup: + buf := m.bytes() + n := len(buf) + if n == 0 || buf[n-1] != '\x00' { + goto corrupt + } + req = &LookupRequest{ + Header: m.Header(), + Name: string(buf[:n-1]), + } + + case opForget: + in := (*forgetIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &ForgetRequest{ + Header: m.Header(), + N: in.Nlookup, + } + + case opGetattr: + switch { + case c.proto.LT(Protocol{7, 9}): + req = &GetattrRequest{ + Header: m.Header(), + } + + default: + in := (*getattrIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &GetattrRequest{ + Header: m.Header(), + Flags: GetattrFlags(in.GetattrFlags), + Handle: HandleID(in.Fh), + } + } + + case opSetattr: + in := (*setattrIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &SetattrRequest{ + Header: m.Header(), + Valid: SetattrValid(in.Valid), + Handle: HandleID(in.Fh), + Size: in.Size, + Atime: time.Unix(int64(in.Atime), int64(in.AtimeNsec)), + Mtime: time.Unix(int64(in.Mtime), int64(in.MtimeNsec)), + Mode: fileMode(in.Mode), + Uid: in.Uid, + Gid: in.Gid, + Bkuptime: in.BkupTime(), + Chgtime: in.Chgtime(), + Flags: in.Flags(), + } + + case opReadlink: + if len(m.bytes()) > 0 { + goto corrupt + } + req = &ReadlinkRequest{ + Header: m.Header(), + } + + case opSymlink: + // m.bytes() is "newName\0target\0" + names := m.bytes() + if len(names) == 0 || names[len(names)-1] != 0 { + goto corrupt + } + i := bytes.IndexByte(names, '\x00') + if i < 0 { + goto corrupt + } + newName, target := names[0:i], names[i+1:len(names)-1] + req = &SymlinkRequest{ + Header: m.Header(), + NewName: string(newName), + Target: string(target), + } + + case opLink: + in := (*linkIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + newName := m.bytes()[unsafe.Sizeof(*in):] + if len(newName) < 2 || newName[len(newName)-1] != 0 { + goto corrupt + } + newName = newName[:len(newName)-1] + req = &LinkRequest{ + Header: m.Header(), + OldNode: NodeID(in.Oldnodeid), + NewName: string(newName), + } + + case opMknod: + size := mknodInSize(c.proto) + if m.len() < size { + goto corrupt + } + in := (*mknodIn)(m.data()) + name := m.bytes()[size:] + if len(name) < 2 || name[len(name)-1] != '\x00' { + goto corrupt + } + name = name[:len(name)-1] + r := &MknodRequest{ + Header: m.Header(), + Mode: fileMode(in.Mode), + Rdev: in.Rdev, + Name: string(name), + } + if c.proto.GE(Protocol{7, 12}) { + r.Umask = fileMode(in.Umask) & os.ModePerm + } + req = r + + case opMkdir: + size := mkdirInSize(c.proto) + if m.len() < size { + goto corrupt + } + in := (*mkdirIn)(m.data()) + name := m.bytes()[size:] + i := bytes.IndexByte(name, '\x00') + if i < 0 { + goto corrupt + } + r := &MkdirRequest{ + Header: m.Header(), + Name: string(name[:i]), + // observed on Linux: mkdirIn.Mode & syscall.S_IFMT == 0, + // and this causes fileMode to go into it's "no idea" + // code branch; enforce type to directory + Mode: fileMode((in.Mode &^ syscall.S_IFMT) | syscall.S_IFDIR), + } + if c.proto.GE(Protocol{7, 12}) { + r.Umask = fileMode(in.Umask) & os.ModePerm + } + req = r + + case opUnlink, opRmdir: + buf := m.bytes() + n := len(buf) + if n == 0 || buf[n-1] != '\x00' { + goto corrupt + } + req = &RemoveRequest{ + Header: m.Header(), + Name: string(buf[:n-1]), + Dir: m.hdr.Opcode == opRmdir, + } + + case opRename: + in := (*renameIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + newDirNodeID := NodeID(in.Newdir) + oldNew := m.bytes()[unsafe.Sizeof(*in):] + // oldNew should be "old\x00new\x00" + if len(oldNew) < 4 { + goto corrupt + } + if oldNew[len(oldNew)-1] != '\x00' { + goto corrupt + } + i := bytes.IndexByte(oldNew, '\x00') + if i < 0 { + goto corrupt + } + oldName, newName := string(oldNew[:i]), string(oldNew[i+1:len(oldNew)-1]) + req = &RenameRequest{ + Header: m.Header(), + NewDir: newDirNodeID, + OldName: oldName, + NewName: newName, + } + + case opOpendir, opOpen: + in := (*openIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &OpenRequest{ + Header: m.Header(), + Dir: m.hdr.Opcode == opOpendir, + Flags: openFlags(in.Flags), + } + + case opRead, opReaddir: + in := (*readIn)(m.data()) + if m.len() < readInSize(c.proto) { + goto corrupt + } + r := &ReadRequest{ + Header: m.Header(), + Dir: m.hdr.Opcode == opReaddir, + Handle: HandleID(in.Fh), + Offset: int64(in.Offset), + Size: int(in.Size), + } + if c.proto.GE(Protocol{7, 9}) { + r.Flags = ReadFlags(in.ReadFlags) + r.LockOwner = in.LockOwner + r.FileFlags = openFlags(in.Flags) + } + req = r + + case opWrite: + in := (*writeIn)(m.data()) + if m.len() < writeInSize(c.proto) { + goto corrupt + } + r := &WriteRequest{ + Header: m.Header(), + Handle: HandleID(in.Fh), + Offset: int64(in.Offset), + Flags: WriteFlags(in.WriteFlags), + } + if c.proto.GE(Protocol{7, 9}) { + r.LockOwner = in.LockOwner + r.FileFlags = openFlags(in.Flags) + } + buf := m.bytes()[writeInSize(c.proto):] + if uint32(len(buf)) < in.Size { + goto corrupt + } + r.Data = buf + req = r + + case opStatfs: + req = &StatfsRequest{ + Header: m.Header(), + } + + case opRelease, opReleasedir: + in := (*releaseIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &ReleaseRequest{ + Header: m.Header(), + Dir: m.hdr.Opcode == opReleasedir, + Handle: HandleID(in.Fh), + Flags: openFlags(in.Flags), + ReleaseFlags: ReleaseFlags(in.ReleaseFlags), + LockOwner: in.LockOwner, + } + + case opFsync, opFsyncdir: + in := (*fsyncIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &FsyncRequest{ + Dir: m.hdr.Opcode == opFsyncdir, + Header: m.Header(), + Handle: HandleID(in.Fh), + Flags: in.FsyncFlags, + } + + case opSetxattr: + in := (*setxattrIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + m.off += int(unsafe.Sizeof(*in)) + name := m.bytes() + i := bytes.IndexByte(name, '\x00') + if i < 0 { + goto corrupt + } + xattr := name[i+1:] + if uint32(len(xattr)) < in.Size { + goto corrupt + } + xattr = xattr[:in.Size] + req = &SetxattrRequest{ + Header: m.Header(), + Flags: in.Flags, + Position: in.position(), + Name: string(name[:i]), + Xattr: xattr, + } + + case opGetxattr: + in := (*getxattrIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + name := m.bytes()[unsafe.Sizeof(*in):] + i := bytes.IndexByte(name, '\x00') + if i < 0 { + goto corrupt + } + req = &GetxattrRequest{ + Header: m.Header(), + Name: string(name[:i]), + Size: in.Size, + Position: in.position(), + } + + case opListxattr: + in := (*getxattrIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &ListxattrRequest{ + Header: m.Header(), + Size: in.Size, + Position: in.position(), + } + + case opRemovexattr: + buf := m.bytes() + n := len(buf) + if n == 0 || buf[n-1] != '\x00' { + goto corrupt + } + req = &RemovexattrRequest{ + Header: m.Header(), + Name: string(buf[:n-1]), + } + + case opFlush: + in := (*flushIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &FlushRequest{ + Header: m.Header(), + Handle: HandleID(in.Fh), + Flags: in.FlushFlags, + LockOwner: in.LockOwner, + } + + case opInit: + in := (*initIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &InitRequest{ + Header: m.Header(), + Kernel: Protocol{in.Major, in.Minor}, + MaxReadahead: in.MaxReadahead, + Flags: InitFlags(in.Flags), + } + + case opGetlk: + panic("opGetlk") + case opSetlk: + panic("opSetlk") + case opSetlkw: + panic("opSetlkw") + + case opAccess: + in := (*accessIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &AccessRequest{ + Header: m.Header(), + Mask: in.Mask, + } + + case opCreate: + size := createInSize(c.proto) + if m.len() < size { + goto corrupt + } + in := (*createIn)(m.data()) + name := m.bytes()[size:] + i := bytes.IndexByte(name, '\x00') + if i < 0 { + goto corrupt + } + r := &CreateRequest{ + Header: m.Header(), + Flags: openFlags(in.Flags), + Mode: fileMode(in.Mode), + Name: string(name[:i]), + } + if c.proto.GE(Protocol{7, 12}) { + r.Umask = fileMode(in.Umask) & os.ModePerm + } + req = r + + case opInterrupt: + in := (*interruptIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + req = &InterruptRequest{ + Header: m.Header(), + IntrID: RequestID(in.Unique), + } + + case opBmap: + panic("opBmap") + + case opDestroy: + req = &DestroyRequest{ + Header: m.Header(), + } + + // OS X + case opSetvolname: + panic("opSetvolname") + case opGetxtimes: + panic("opGetxtimes") + case opExchange: + in := (*exchangeIn)(m.data()) + if m.len() < unsafe.Sizeof(*in) { + goto corrupt + } + oldDirNodeID := NodeID(in.Olddir) + newDirNodeID := NodeID(in.Newdir) + oldNew := m.bytes()[unsafe.Sizeof(*in):] + // oldNew should be "oldname\x00newname\x00" + if len(oldNew) < 4 { + goto corrupt + } + if oldNew[len(oldNew)-1] != '\x00' { + goto corrupt + } + i := bytes.IndexByte(oldNew, '\x00') + if i < 0 { + goto corrupt + } + oldName, newName := string(oldNew[:i]), string(oldNew[i+1:len(oldNew)-1]) + req = &ExchangeDataRequest{ + Header: m.Header(), + OldDir: oldDirNodeID, + NewDir: newDirNodeID, + OldName: oldName, + NewName: newName, + // TODO options + } + } + + return req, nil + +corrupt: + Debug(malformedMessage{}) + putMessage(m) + return nil, fmt.Errorf("fuse: malformed message") + +unrecognized: + // Unrecognized message. + // Assume higher-level code will send a "no idea what you mean" error. + h := m.Header() + return &h, nil +} + +type bugShortKernelWrite struct { + Written int64 + Length int64 + Error string + Stack string +} + +func (b bugShortKernelWrite) String() string { + return fmt.Sprintf("short kernel write: written=%d/%d error=%q stack=\n%s", b.Written, b.Length, b.Error, b.Stack) +} + +type bugKernelWriteError struct { + Error string + Stack string +} + +func (b bugKernelWriteError) String() string { + return fmt.Sprintf("kernel write error: error=%q stack=\n%s", b.Error, b.Stack) +} + +// safe to call even with nil error +func errorString(err error) string { + if err == nil { + return "" + } + return err.Error() +} + +func (c *Conn) writeToKernel(msg []byte) error { + out := (*outHeader)(unsafe.Pointer(&msg[0])) + out.Len = uint32(len(msg)) + + c.wio.RLock() + defer c.wio.RUnlock() + nn, err := syscall.Write(c.fd(), msg) + if err == nil && nn != len(msg) { + Debug(bugShortKernelWrite{ + Written: int64(nn), + Length: int64(len(msg)), + Error: errorString(err), + Stack: stack(), + }) + } + return err +} + +func (c *Conn) respond(msg []byte) { + if err := c.writeToKernel(msg); err != nil { + Debug(bugKernelWriteError{ + Error: errorString(err), + Stack: stack(), + }) + } +} + +type notCachedError struct{} + +func (notCachedError) Error() string { + return "node not cached" +} + +var _ ErrorNumber = notCachedError{} + +func (notCachedError) Errno() Errno { + // Behave just like if the original syscall.ENOENT had been passed + // straight through. + return ENOENT +} + +var ( + ErrNotCached = notCachedError{} +) + +// sendInvalidate sends an invalidate notification to kernel. +// +// A returned ENOENT is translated to a friendlier error. +func (c *Conn) sendInvalidate(msg []byte) error { + switch err := c.writeToKernel(msg); err { + case syscall.ENOENT: + return ErrNotCached + default: + return err + } +} + +// InvalidateNode invalidates the kernel cache of the attributes and a +// range of the data of a node. +// +// Giving offset 0 and size -1 means all data. To invalidate just the +// attributes, give offset 0 and size 0. +// +// Returns ErrNotCached if the kernel is not currently caching the +// node. +func (c *Conn) InvalidateNode(nodeID NodeID, off int64, size int64) error { + buf := newBuffer(unsafe.Sizeof(notifyInvalInodeOut{})) + h := (*outHeader)(unsafe.Pointer(&buf[0])) + // h.Unique is 0 + h.Error = notifyCodeInvalInode + out := (*notifyInvalInodeOut)(buf.alloc(unsafe.Sizeof(notifyInvalInodeOut{}))) + out.Ino = uint64(nodeID) + out.Off = off + out.Len = size + return c.sendInvalidate(buf) +} + +// InvalidateEntry invalidates the kernel cache of the directory entry +// identified by parent directory node ID and entry basename. +// +// Kernel may or may not cache directory listings. To invalidate +// those, use InvalidateNode to invalidate all of the data for a +// directory. (As of 2015-06, Linux FUSE does not cache directory +// listings.) +// +// Returns ErrNotCached if the kernel is not currently caching the +// node. +func (c *Conn) InvalidateEntry(parent NodeID, name string) error { + const maxUint32 = ^uint32(0) + if uint64(len(name)) > uint64(maxUint32) { + // very unlikely, but we don't want to silently truncate + return syscall.ENAMETOOLONG + } + buf := newBuffer(unsafe.Sizeof(notifyInvalEntryOut{}) + uintptr(len(name)) + 1) + h := (*outHeader)(unsafe.Pointer(&buf[0])) + // h.Unique is 0 + h.Error = notifyCodeInvalEntry + out := (*notifyInvalEntryOut)(buf.alloc(unsafe.Sizeof(notifyInvalEntryOut{}))) + out.Parent = uint64(parent) + out.Namelen = uint32(len(name)) + buf = append(buf, name...) + buf = append(buf, '\x00') + return c.sendInvalidate(buf) +} + +// An InitRequest is the first request sent on a FUSE file system. +type InitRequest struct { + Header `json:"-"` + Kernel Protocol + // Maximum readahead in bytes that the kernel plans to use. + MaxReadahead uint32 + Flags InitFlags +} + +var _ = Request(&InitRequest{}) + +func (r *InitRequest) String() string { + return fmt.Sprintf("Init [%v] %v ra=%d fl=%v", &r.Header, r.Kernel, r.MaxReadahead, r.Flags) +} + +// An InitResponse is the response to an InitRequest. +type InitResponse struct { + Library Protocol + // Maximum readahead in bytes that the kernel can use. Ignored if + // greater than InitRequest.MaxReadahead. + MaxReadahead uint32 + Flags InitFlags + // Maximum size of a single write operation. + // Linux enforces a minimum of 4 KiB. + MaxWrite uint32 +} + +func (r *InitResponse) String() string { + return fmt.Sprintf("Init %v ra=%d fl=%v w=%d", r.Library, r.MaxReadahead, r.Flags, r.MaxWrite) +} + +// Respond replies to the request with the given response. +func (r *InitRequest) Respond(resp *InitResponse) { + buf := newBuffer(unsafe.Sizeof(initOut{})) + out := (*initOut)(buf.alloc(unsafe.Sizeof(initOut{}))) + out.Major = resp.Library.Major + out.Minor = resp.Library.Minor + out.MaxReadahead = resp.MaxReadahead + out.Flags = uint32(resp.Flags) + out.MaxWrite = resp.MaxWrite + + // MaxWrite larger than our receive buffer would just lead to + // errors on large writes. + if out.MaxWrite > maxWrite { + out.MaxWrite = maxWrite + } + r.respond(buf) +} + +// A StatfsRequest requests information about the mounted file system. +type StatfsRequest struct { + Header `json:"-"` +} + +var _ = Request(&StatfsRequest{}) + +func (r *StatfsRequest) String() string { + return fmt.Sprintf("Statfs [%s]", &r.Header) +} + +// Respond replies to the request with the given response. +func (r *StatfsRequest) Respond(resp *StatfsResponse) { + buf := newBuffer(unsafe.Sizeof(statfsOut{})) + out := (*statfsOut)(buf.alloc(unsafe.Sizeof(statfsOut{}))) + out.St = kstatfs{ + Blocks: resp.Blocks, + Bfree: resp.Bfree, + Bavail: resp.Bavail, + Files: resp.Files, + Bsize: resp.Bsize, + Namelen: resp.Namelen, + Frsize: resp.Frsize, + } + r.respond(buf) +} + +// A StatfsResponse is the response to a StatfsRequest. +type StatfsResponse struct { + Blocks uint64 // Total data blocks in file system. + Bfree uint64 // Free blocks in file system. + Bavail uint64 // Free blocks in file system if you're not root. + Files uint64 // Total files in file system. + Ffree uint64 // Free files in file system. + Bsize uint32 // Block size + Namelen uint32 // Maximum file name length? + Frsize uint32 // Fragment size, smallest addressable data size in the file system. +} + +func (r *StatfsResponse) String() string { + return fmt.Sprintf("Statfs blocks=%d/%d/%d files=%d/%d bsize=%d frsize=%d namelen=%d", + r.Bavail, r.Bfree, r.Blocks, + r.Ffree, r.Files, + r.Bsize, + r.Frsize, + r.Namelen, + ) +} + +// An AccessRequest asks whether the file can be accessed +// for the purpose specified by the mask. +type AccessRequest struct { + Header `json:"-"` + Mask uint32 +} + +var _ = Request(&AccessRequest{}) + +func (r *AccessRequest) String() string { + return fmt.Sprintf("Access [%s] mask=%#x", &r.Header, r.Mask) +} + +// Respond replies to the request indicating that access is allowed. +// To deny access, use RespondError. +func (r *AccessRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// An Attr is the metadata for a single file or directory. +type Attr struct { + Valid time.Duration // how long Attr can be cached + + Inode uint64 // inode number + Size uint64 // size in bytes + Blocks uint64 // size in 512-byte units + Atime time.Time // time of last access + Mtime time.Time // time of last modification + Ctime time.Time // time of last inode change + Crtime time.Time // time of creation (OS X only) + Mode os.FileMode // file mode + Nlink uint32 // number of links (usually 1) + Uid uint32 // owner uid + Gid uint32 // group gid + Rdev uint32 // device numbers + Flags uint32 // chflags(2) flags (OS X only) + BlockSize uint32 // preferred blocksize for filesystem I/O +} + +func (a Attr) String() string { + return fmt.Sprintf("valid=%v ino=%v size=%d mode=%v", a.Valid, a.Inode, a.Size, a.Mode) +} + +func unix(t time.Time) (sec uint64, nsec uint32) { + nano := t.UnixNano() + sec = uint64(nano / 1e9) + nsec = uint32(nano % 1e9) + return +} + +func (a *Attr) attr(out *attr, proto Protocol) { + out.Ino = a.Inode + out.Size = a.Size + out.Blocks = a.Blocks + out.Atime, out.AtimeNsec = unix(a.Atime) + out.Mtime, out.MtimeNsec = unix(a.Mtime) + out.Ctime, out.CtimeNsec = unix(a.Ctime) + out.SetCrtime(unix(a.Crtime)) + out.Mode = uint32(a.Mode) & 0777 + switch { + default: + out.Mode |= syscall.S_IFREG + case a.Mode&os.ModeDir != 0: + out.Mode |= syscall.S_IFDIR + case a.Mode&os.ModeDevice != 0: + if a.Mode&os.ModeCharDevice != 0 { + out.Mode |= syscall.S_IFCHR + } else { + out.Mode |= syscall.S_IFBLK + } + case a.Mode&os.ModeNamedPipe != 0: + out.Mode |= syscall.S_IFIFO + case a.Mode&os.ModeSymlink != 0: + out.Mode |= syscall.S_IFLNK + case a.Mode&os.ModeSocket != 0: + out.Mode |= syscall.S_IFSOCK + } + if a.Mode&os.ModeSetuid != 0 { + out.Mode |= syscall.S_ISUID + } + if a.Mode&os.ModeSetgid != 0 { + out.Mode |= syscall.S_ISGID + } + out.Nlink = a.Nlink + out.Uid = a.Uid + out.Gid = a.Gid + out.Rdev = a.Rdev + out.SetFlags(a.Flags) + if proto.GE(Protocol{7, 9}) { + out.Blksize = a.BlockSize + } + + return +} + +// A GetattrRequest asks for the metadata for the file denoted by r.Node. +type GetattrRequest struct { + Header `json:"-"` + Flags GetattrFlags + Handle HandleID +} + +var _ = Request(&GetattrRequest{}) + +func (r *GetattrRequest) String() string { + return fmt.Sprintf("Getattr [%s] %v fl=%v", &r.Header, r.Handle, r.Flags) +} + +// Respond replies to the request with the given response. +func (r *GetattrRequest) Respond(resp *GetattrResponse) { + size := attrOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*attrOut)(buf.alloc(size)) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +// A GetattrResponse is the response to a GetattrRequest. +type GetattrResponse struct { + Attr Attr // file attributes +} + +func (r *GetattrResponse) String() string { + return fmt.Sprintf("Getattr %v", r.Attr) +} + +// A GetxattrRequest asks for the extended attributes associated with r.Node. +type GetxattrRequest struct { + Header `json:"-"` + + // Maximum size to return. + Size uint32 + + // Name of the attribute requested. + Name string + + // Offset within extended attributes. + // + // Only valid for OS X, and then only with the resource fork + // attribute. + Position uint32 +} + +var _ = Request(&GetxattrRequest{}) + +func (r *GetxattrRequest) String() string { + return fmt.Sprintf("Getxattr [%s] %q %d @%d", &r.Header, r.Name, r.Size, r.Position) +} + +// Respond replies to the request with the given response. +func (r *GetxattrRequest) Respond(resp *GetxattrResponse) { + if r.Size == 0 { + buf := newBuffer(unsafe.Sizeof(getxattrOut{})) + out := (*getxattrOut)(buf.alloc(unsafe.Sizeof(getxattrOut{}))) + out.Size = uint32(len(resp.Xattr)) + r.respond(buf) + } else { + buf := newBuffer(uintptr(len(resp.Xattr))) + buf = append(buf, resp.Xattr...) + r.respond(buf) + } +} + +// A GetxattrResponse is the response to a GetxattrRequest. +type GetxattrResponse struct { + Xattr []byte +} + +func (r *GetxattrResponse) String() string { + return fmt.Sprintf("Getxattr %x", r.Xattr) +} + +// A ListxattrRequest asks to list the extended attributes associated with r.Node. +type ListxattrRequest struct { + Header `json:"-"` + Size uint32 // maximum size to return + Position uint32 // offset within attribute list +} + +var _ = Request(&ListxattrRequest{}) + +func (r *ListxattrRequest) String() string { + return fmt.Sprintf("Listxattr [%s] %d @%d", &r.Header, r.Size, r.Position) +} + +// Respond replies to the request with the given response. +func (r *ListxattrRequest) Respond(resp *ListxattrResponse) { + if r.Size == 0 { + buf := newBuffer(unsafe.Sizeof(getxattrOut{})) + out := (*getxattrOut)(buf.alloc(unsafe.Sizeof(getxattrOut{}))) + out.Size = uint32(len(resp.Xattr)) + r.respond(buf) + } else { + buf := newBuffer(uintptr(len(resp.Xattr))) + buf = append(buf, resp.Xattr...) + r.respond(buf) + } +} + +// A ListxattrResponse is the response to a ListxattrRequest. +type ListxattrResponse struct { + Xattr []byte +} + +func (r *ListxattrResponse) String() string { + return fmt.Sprintf("Listxattr %x", r.Xattr) +} + +// Append adds an extended attribute name to the response. +func (r *ListxattrResponse) Append(names ...string) { + for _, name := range names { + r.Xattr = append(r.Xattr, name...) + r.Xattr = append(r.Xattr, '\x00') + } +} + +// A RemovexattrRequest asks to remove an extended attribute associated with r.Node. +type RemovexattrRequest struct { + Header `json:"-"` + Name string // name of extended attribute +} + +var _ = Request(&RemovexattrRequest{}) + +func (r *RemovexattrRequest) String() string { + return fmt.Sprintf("Removexattr [%s] %q", &r.Header, r.Name) +} + +// Respond replies to the request, indicating that the attribute was removed. +func (r *RemovexattrRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// A SetxattrRequest asks to set an extended attribute associated with a file. +type SetxattrRequest struct { + Header `json:"-"` + + // Flags can make the request fail if attribute does/not already + // exist. Unfortunately, the constants are platform-specific and + // not exposed by Go1.2. Look for XATTR_CREATE, XATTR_REPLACE. + // + // TODO improve this later + // + // TODO XATTR_CREATE and exist -> EEXIST + // + // TODO XATTR_REPLACE and not exist -> ENODATA + Flags uint32 + + // Offset within extended attributes. + // + // Only valid for OS X, and then only with the resource fork + // attribute. + Position uint32 + + Name string + Xattr []byte +} + +var _ = Request(&SetxattrRequest{}) + +func trunc(b []byte, max int) ([]byte, string) { + if len(b) > max { + return b[:max], "..." + } + return b, "" +} + +func (r *SetxattrRequest) String() string { + xattr, tail := trunc(r.Xattr, 16) + return fmt.Sprintf("Setxattr [%s] %q %x%s fl=%v @%#x", &r.Header, r.Name, xattr, tail, r.Flags, r.Position) +} + +// Respond replies to the request, indicating that the extended attribute was set. +func (r *SetxattrRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// A LookupRequest asks to look up the given name in the directory named by r.Node. +type LookupRequest struct { + Header `json:"-"` + Name string +} + +var _ = Request(&LookupRequest{}) + +func (r *LookupRequest) String() string { + return fmt.Sprintf("Lookup [%s] %q", &r.Header, r.Name) +} + +// Respond replies to the request with the given response. +func (r *LookupRequest) Respond(resp *LookupResponse) { + size := entryOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*entryOut)(buf.alloc(size)) + out.Nodeid = uint64(resp.Node) + out.Generation = resp.Generation + out.EntryValid = uint64(resp.EntryValid / time.Second) + out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +// A LookupResponse is the response to a LookupRequest. +type LookupResponse struct { + Node NodeID + Generation uint64 + EntryValid time.Duration + Attr Attr +} + +func (r *LookupResponse) string() string { + return fmt.Sprintf("%v gen=%d valid=%v attr={%v}", r.Node, r.Generation, r.EntryValid, r.Attr) +} + +func (r *LookupResponse) String() string { + return fmt.Sprintf("Lookup %s", r.string()) +} + +// An OpenRequest asks to open a file or directory +type OpenRequest struct { + Header `json:"-"` + Dir bool // is this Opendir? + Flags OpenFlags +} + +var _ = Request(&OpenRequest{}) + +func (r *OpenRequest) String() string { + return fmt.Sprintf("Open [%s] dir=%v fl=%v", &r.Header, r.Dir, r.Flags) +} + +// Respond replies to the request with the given response. +func (r *OpenRequest) Respond(resp *OpenResponse) { + buf := newBuffer(unsafe.Sizeof(openOut{})) + out := (*openOut)(buf.alloc(unsafe.Sizeof(openOut{}))) + out.Fh = uint64(resp.Handle) + out.OpenFlags = uint32(resp.Flags) + r.respond(buf) +} + +// A OpenResponse is the response to a OpenRequest. +type OpenResponse struct { + Handle HandleID + Flags OpenResponseFlags +} + +func (r *OpenResponse) string() string { + return fmt.Sprintf("%v fl=%v", r.Handle, r.Flags) +} + +func (r *OpenResponse) String() string { + return fmt.Sprintf("Open %s", r.string()) +} + +// A CreateRequest asks to create and open a file (not a directory). +type CreateRequest struct { + Header `json:"-"` + Name string + Flags OpenFlags + Mode os.FileMode + // Umask of the request. Not supported on OS X. + Umask os.FileMode +} + +var _ = Request(&CreateRequest{}) + +func (r *CreateRequest) String() string { + return fmt.Sprintf("Create [%s] %q fl=%v mode=%v umask=%v", &r.Header, r.Name, r.Flags, r.Mode, r.Umask) +} + +// Respond replies to the request with the given response. +func (r *CreateRequest) Respond(resp *CreateResponse) { + eSize := entryOutSize(r.Header.Conn.proto) + buf := newBuffer(eSize + unsafe.Sizeof(openOut{})) + + e := (*entryOut)(buf.alloc(eSize)) + e.Nodeid = uint64(resp.Node) + e.Generation = resp.Generation + e.EntryValid = uint64(resp.EntryValid / time.Second) + e.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) + e.AttrValid = uint64(resp.Attr.Valid / time.Second) + e.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&e.Attr, r.Header.Conn.proto) + + o := (*openOut)(buf.alloc(unsafe.Sizeof(openOut{}))) + o.Fh = uint64(resp.Handle) + o.OpenFlags = uint32(resp.Flags) + + r.respond(buf) +} + +// A CreateResponse is the response to a CreateRequest. +// It describes the created node and opened handle. +type CreateResponse struct { + LookupResponse + OpenResponse +} + +func (r *CreateResponse) String() string { + return fmt.Sprintf("Create {%s} {%s}", r.LookupResponse.string(), r.OpenResponse.string()) +} + +// A MkdirRequest asks to create (but not open) a directory. +type MkdirRequest struct { + Header `json:"-"` + Name string + Mode os.FileMode + // Umask of the request. Not supported on OS X. + Umask os.FileMode +} + +var _ = Request(&MkdirRequest{}) + +func (r *MkdirRequest) String() string { + return fmt.Sprintf("Mkdir [%s] %q mode=%v umask=%v", &r.Header, r.Name, r.Mode, r.Umask) +} + +// Respond replies to the request with the given response. +func (r *MkdirRequest) Respond(resp *MkdirResponse) { + size := entryOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*entryOut)(buf.alloc(size)) + out.Nodeid = uint64(resp.Node) + out.Generation = resp.Generation + out.EntryValid = uint64(resp.EntryValid / time.Second) + out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +// A MkdirResponse is the response to a MkdirRequest. +type MkdirResponse struct { + LookupResponse +} + +func (r *MkdirResponse) String() string { + return fmt.Sprintf("Mkdir %v", r.LookupResponse.string()) +} + +// A ReadRequest asks to read from an open file. +type ReadRequest struct { + Header `json:"-"` + Dir bool // is this Readdir? + Handle HandleID + Offset int64 + Size int + Flags ReadFlags + LockOwner uint64 + FileFlags OpenFlags +} + +var _ = Request(&ReadRequest{}) + +func (r *ReadRequest) String() string { + return fmt.Sprintf("Read [%s] %v %d @%#x dir=%v fl=%v lock=%d ffl=%v", &r.Header, r.Handle, r.Size, r.Offset, r.Dir, r.Flags, r.LockOwner, r.FileFlags) +} + +// Respond replies to the request with the given response. +func (r *ReadRequest) Respond(resp *ReadResponse) { + buf := newBuffer(uintptr(len(resp.Data))) + buf = append(buf, resp.Data...) + r.respond(buf) +} + +// A ReadResponse is the response to a ReadRequest. +type ReadResponse struct { + Data []byte +} + +func (r *ReadResponse) String() string { + return fmt.Sprintf("Read %d", len(r.Data)) +} + +type jsonReadResponse struct { + Len uint64 +} + +func (r *ReadResponse) MarshalJSON() ([]byte, error) { + j := jsonReadResponse{ + Len: uint64(len(r.Data)), + } + return json.Marshal(j) +} + +// A ReleaseRequest asks to release (close) an open file handle. +type ReleaseRequest struct { + Header `json:"-"` + Dir bool // is this Releasedir? + Handle HandleID + Flags OpenFlags // flags from OpenRequest + ReleaseFlags ReleaseFlags + LockOwner uint32 +} + +var _ = Request(&ReleaseRequest{}) + +func (r *ReleaseRequest) String() string { + return fmt.Sprintf("Release [%s] %v fl=%v rfl=%v owner=%#x", &r.Header, r.Handle, r.Flags, r.ReleaseFlags, r.LockOwner) +} + +// Respond replies to the request, indicating that the handle has been released. +func (r *ReleaseRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// A DestroyRequest is sent by the kernel when unmounting the file system. +// No more requests will be received after this one, but it should still be +// responded to. +type DestroyRequest struct { + Header `json:"-"` +} + +var _ = Request(&DestroyRequest{}) + +func (r *DestroyRequest) String() string { + return fmt.Sprintf("Destroy [%s]", &r.Header) +} + +// Respond replies to the request. +func (r *DestroyRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// A ForgetRequest is sent by the kernel when forgetting about r.Node +// as returned by r.N lookup requests. +type ForgetRequest struct { + Header `json:"-"` + N uint64 +} + +var _ = Request(&ForgetRequest{}) + +func (r *ForgetRequest) String() string { + return fmt.Sprintf("Forget [%s] %d", &r.Header, r.N) +} + +// Respond replies to the request, indicating that the forgetfulness has been recorded. +func (r *ForgetRequest) Respond() { + // Don't reply to forget messages. + r.noResponse() +} + +// A Dirent represents a single directory entry. +type Dirent struct { + // Inode this entry names. + Inode uint64 + + // Type of the entry, for example DT_File. + // + // Setting this is optional. The zero value (DT_Unknown) means + // callers will just need to do a Getattr when the type is + // needed. Providing a type can speed up operations + // significantly. + Type DirentType + + // Name of the entry + Name string +} + +// Type of an entry in a directory listing. +type DirentType uint32 + +const ( + // These don't quite match os.FileMode; especially there's an + // explicit unknown, instead of zero value meaning file. They + // are also not quite syscall.DT_*; nothing says the FUSE + // protocol follows those, and even if they were, we don't + // want each fs to fiddle with syscall. + + // The shift by 12 is hardcoded in the FUSE userspace + // low-level C library, so it's safe here. + + DT_Unknown DirentType = 0 + DT_Socket DirentType = syscall.S_IFSOCK >> 12 + DT_Link DirentType = syscall.S_IFLNK >> 12 + DT_File DirentType = syscall.S_IFREG >> 12 + DT_Block DirentType = syscall.S_IFBLK >> 12 + DT_Dir DirentType = syscall.S_IFDIR >> 12 + DT_Char DirentType = syscall.S_IFCHR >> 12 + DT_FIFO DirentType = syscall.S_IFIFO >> 12 +) + +func (t DirentType) String() string { + switch t { + case DT_Unknown: + return "unknown" + case DT_Socket: + return "socket" + case DT_Link: + return "link" + case DT_File: + return "file" + case DT_Block: + return "block" + case DT_Dir: + return "dir" + case DT_Char: + return "char" + case DT_FIFO: + return "fifo" + } + return "invalid" +} + +// AppendDirent appends the encoded form of a directory entry to data +// and returns the resulting slice. +func AppendDirent(data []byte, dir Dirent) []byte { + de := dirent{ + Ino: dir.Inode, + Namelen: uint32(len(dir.Name)), + Type: uint32(dir.Type), + } + de.Off = uint64(len(data) + direntSize + (len(dir.Name)+7)&^7) + data = append(data, (*[direntSize]byte)(unsafe.Pointer(&de))[:]...) + data = append(data, dir.Name...) + n := direntSize + uintptr(len(dir.Name)) + if n%8 != 0 { + var pad [8]byte + data = append(data, pad[:8-n%8]...) + } + return data +} + +// A WriteRequest asks to write to an open file. +type WriteRequest struct { + Header + Handle HandleID + Offset int64 + Data []byte + Flags WriteFlags + LockOwner uint64 + FileFlags OpenFlags +} + +var _ = Request(&WriteRequest{}) + +func (r *WriteRequest) String() string { + return fmt.Sprintf("Write [%s] %v %d @%d fl=%v lock=%d ffl=%v", &r.Header, r.Handle, len(r.Data), r.Offset, r.Flags, r.LockOwner, r.FileFlags) +} + +type jsonWriteRequest struct { + Handle HandleID + Offset int64 + Len uint64 + Flags WriteFlags +} + +func (r *WriteRequest) MarshalJSON() ([]byte, error) { + j := jsonWriteRequest{ + Handle: r.Handle, + Offset: r.Offset, + Len: uint64(len(r.Data)), + Flags: r.Flags, + } + return json.Marshal(j) +} + +// Respond replies to the request with the given response. +func (r *WriteRequest) Respond(resp *WriteResponse) { + buf := newBuffer(unsafe.Sizeof(writeOut{})) + out := (*writeOut)(buf.alloc(unsafe.Sizeof(writeOut{}))) + out.Size = uint32(resp.Size) + r.respond(buf) +} + +// A WriteResponse replies to a write indicating how many bytes were written. +type WriteResponse struct { + Size int +} + +func (r *WriteResponse) String() string { + return fmt.Sprintf("Write %d", r.Size) +} + +// A SetattrRequest asks to change one or more attributes associated with a file, +// as indicated by Valid. +type SetattrRequest struct { + Header `json:"-"` + Valid SetattrValid + Handle HandleID + Size uint64 + Atime time.Time + Mtime time.Time + Mode os.FileMode + Uid uint32 + Gid uint32 + + // OS X only + Bkuptime time.Time + Chgtime time.Time + Crtime time.Time + Flags uint32 // see chflags(2) +} + +var _ = Request(&SetattrRequest{}) + +func (r *SetattrRequest) String() string { + var buf bytes.Buffer + fmt.Fprintf(&buf, "Setattr [%s]", &r.Header) + if r.Valid.Mode() { + fmt.Fprintf(&buf, " mode=%v", r.Mode) + } + if r.Valid.Uid() { + fmt.Fprintf(&buf, " uid=%d", r.Uid) + } + if r.Valid.Gid() { + fmt.Fprintf(&buf, " gid=%d", r.Gid) + } + if r.Valid.Size() { + fmt.Fprintf(&buf, " size=%d", r.Size) + } + if r.Valid.Atime() { + fmt.Fprintf(&buf, " atime=%v", r.Atime) + } + if r.Valid.AtimeNow() { + fmt.Fprintf(&buf, " atime=now") + } + if r.Valid.Mtime() { + fmt.Fprintf(&buf, " mtime=%v", r.Mtime) + } + if r.Valid.MtimeNow() { + fmt.Fprintf(&buf, " mtime=now") + } + if r.Valid.Handle() { + fmt.Fprintf(&buf, " handle=%v", r.Handle) + } else { + fmt.Fprintf(&buf, " handle=INVALID-%v", r.Handle) + } + if r.Valid.LockOwner() { + fmt.Fprintf(&buf, " lockowner") + } + if r.Valid.Crtime() { + fmt.Fprintf(&buf, " crtime=%v", r.Crtime) + } + if r.Valid.Chgtime() { + fmt.Fprintf(&buf, " chgtime=%v", r.Chgtime) + } + if r.Valid.Bkuptime() { + fmt.Fprintf(&buf, " bkuptime=%v", r.Bkuptime) + } + if r.Valid.Flags() { + fmt.Fprintf(&buf, " flags=%v", r.Flags) + } + return buf.String() +} + +// Respond replies to the request with the given response, +// giving the updated attributes. +func (r *SetattrRequest) Respond(resp *SetattrResponse) { + size := attrOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*attrOut)(buf.alloc(size)) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +// A SetattrResponse is the response to a SetattrRequest. +type SetattrResponse struct { + Attr Attr // file attributes +} + +func (r *SetattrResponse) String() string { + return fmt.Sprintf("Setattr %v", r.Attr) +} + +// A FlushRequest asks for the current state of an open file to be flushed +// to storage, as when a file descriptor is being closed. A single opened Handle +// may receive multiple FlushRequests over its lifetime. +type FlushRequest struct { + Header `json:"-"` + Handle HandleID + Flags uint32 + LockOwner uint64 +} + +var _ = Request(&FlushRequest{}) + +func (r *FlushRequest) String() string { + return fmt.Sprintf("Flush [%s] %v fl=%#x lk=%#x", &r.Header, r.Handle, r.Flags, r.LockOwner) +} + +// Respond replies to the request, indicating that the flush succeeded. +func (r *FlushRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// A RemoveRequest asks to remove a file or directory from the +// directory r.Node. +type RemoveRequest struct { + Header `json:"-"` + Name string // name of the entry to remove + Dir bool // is this rmdir? +} + +var _ = Request(&RemoveRequest{}) + +func (r *RemoveRequest) String() string { + return fmt.Sprintf("Remove [%s] %q dir=%v", &r.Header, r.Name, r.Dir) +} + +// Respond replies to the request, indicating that the file was removed. +func (r *RemoveRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// A SymlinkRequest is a request to create a symlink making NewName point to Target. +type SymlinkRequest struct { + Header `json:"-"` + NewName, Target string +} + +var _ = Request(&SymlinkRequest{}) + +func (r *SymlinkRequest) String() string { + return fmt.Sprintf("Symlink [%s] from %q to target %q", &r.Header, r.NewName, r.Target) +} + +// Respond replies to the request, indicating that the symlink was created. +func (r *SymlinkRequest) Respond(resp *SymlinkResponse) { + size := entryOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*entryOut)(buf.alloc(size)) + out.Nodeid = uint64(resp.Node) + out.Generation = resp.Generation + out.EntryValid = uint64(resp.EntryValid / time.Second) + out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +// A SymlinkResponse is the response to a SymlinkRequest. +type SymlinkResponse struct { + LookupResponse +} + +func (r *SymlinkResponse) String() string { + return fmt.Sprintf("Symlink %v", r.LookupResponse.string()) +} + +// A ReadlinkRequest is a request to read a symlink's target. +type ReadlinkRequest struct { + Header `json:"-"` +} + +var _ = Request(&ReadlinkRequest{}) + +func (r *ReadlinkRequest) String() string { + return fmt.Sprintf("Readlink [%s]", &r.Header) +} + +func (r *ReadlinkRequest) Respond(target string) { + buf := newBuffer(uintptr(len(target))) + buf = append(buf, target...) + r.respond(buf) +} + +// A LinkRequest is a request to create a hard link. +type LinkRequest struct { + Header `json:"-"` + OldNode NodeID + NewName string +} + +var _ = Request(&LinkRequest{}) + +func (r *LinkRequest) String() string { + return fmt.Sprintf("Link [%s] node %d to %q", &r.Header, r.OldNode, r.NewName) +} + +func (r *LinkRequest) Respond(resp *LookupResponse) { + size := entryOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*entryOut)(buf.alloc(size)) + out.Nodeid = uint64(resp.Node) + out.Generation = resp.Generation + out.EntryValid = uint64(resp.EntryValid / time.Second) + out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +// A RenameRequest is a request to rename a file. +type RenameRequest struct { + Header `json:"-"` + NewDir NodeID + OldName, NewName string +} + +var _ = Request(&RenameRequest{}) + +func (r *RenameRequest) String() string { + return fmt.Sprintf("Rename [%s] from %q to dirnode %v %q", &r.Header, r.OldName, r.NewDir, r.NewName) +} + +func (r *RenameRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +type MknodRequest struct { + Header `json:"-"` + Name string + Mode os.FileMode + Rdev uint32 + // Umask of the request. Not supported on OS X. + Umask os.FileMode +} + +var _ = Request(&MknodRequest{}) + +func (r *MknodRequest) String() string { + return fmt.Sprintf("Mknod [%s] Name %q mode=%v umask=%v rdev=%d", &r.Header, r.Name, r.Mode, r.Umask, r.Rdev) +} + +func (r *MknodRequest) Respond(resp *LookupResponse) { + size := entryOutSize(r.Header.Conn.proto) + buf := newBuffer(size) + out := (*entryOut)(buf.alloc(size)) + out.Nodeid = uint64(resp.Node) + out.Generation = resp.Generation + out.EntryValid = uint64(resp.EntryValid / time.Second) + out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) + out.AttrValid = uint64(resp.Attr.Valid / time.Second) + out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) + resp.Attr.attr(&out.Attr, r.Header.Conn.proto) + r.respond(buf) +} + +type FsyncRequest struct { + Header `json:"-"` + Handle HandleID + // TODO bit 1 is datasync, not well documented upstream + Flags uint32 + Dir bool +} + +var _ = Request(&FsyncRequest{}) + +func (r *FsyncRequest) String() string { + return fmt.Sprintf("Fsync [%s] Handle %v Flags %v", &r.Header, r.Handle, r.Flags) +} + +func (r *FsyncRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} + +// An InterruptRequest is a request to interrupt another pending request. The +// response to that request should return an error status of EINTR. +type InterruptRequest struct { + Header `json:"-"` + IntrID RequestID // ID of the request to be interrupt. +} + +var _ = Request(&InterruptRequest{}) + +func (r *InterruptRequest) Respond() { + // nothing to do here + r.noResponse() +} + +func (r *InterruptRequest) String() string { + return fmt.Sprintf("Interrupt [%s] ID %v", &r.Header, r.IntrID) +} + +// An ExchangeDataRequest is a request to exchange the contents of two +// files, while leaving most metadata untouched. +// +// This request comes from OS X exchangedata(2) and represents its +// specific semantics. Crucially, it is very different from Linux +// renameat(2) RENAME_EXCHANGE. +// +// https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/exchangedata.2.html +type ExchangeDataRequest struct { + Header `json:"-"` + OldDir, NewDir NodeID + OldName, NewName string + // TODO options +} + +var _ = Request(&ExchangeDataRequest{}) + +func (r *ExchangeDataRequest) String() string { + // TODO options + return fmt.Sprintf("ExchangeData [%s] %v %q and %v %q", &r.Header, r.OldDir, r.OldName, r.NewDir, r.NewName) +} + +func (r *ExchangeDataRequest) Respond() { + buf := newBuffer(0) + r.respond(buf) +} diff --git a/vendor/bazil.org/fuse/fuse_darwin.go b/vendor/bazil.org/fuse/fuse_darwin.go new file mode 100644 index 00000000..b58dca97 --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_darwin.go @@ -0,0 +1,9 @@ +package fuse + +// Maximum file write size we are prepared to receive from the kernel. +// +// This value has to be >=16MB or OSXFUSE (3.4.0 observed) will +// forcibly close the /dev/fuse file descriptor on a Setxattr with a +// 16MB value. See TestSetxattr16MB and +// https://github.com/bazil/fuse/issues/42 +const maxWrite = 16 * 1024 * 1024 diff --git a/vendor/bazil.org/fuse/fuse_freebsd.go b/vendor/bazil.org/fuse/fuse_freebsd.go new file mode 100644 index 00000000..4aa83a0d --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_freebsd.go @@ -0,0 +1,6 @@ +package fuse + +// Maximum file write size we are prepared to receive from the kernel. +// +// This number is just a guess. +const maxWrite = 128 * 1024 diff --git a/vendor/bazil.org/fuse/fuse_kernel.go b/vendor/bazil.org/fuse/fuse_kernel.go new file mode 100644 index 00000000..87c5ca1d --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_kernel.go @@ -0,0 +1,774 @@ +// See the file LICENSE for copyright and licensing information. + +// Derived from FUSE's fuse_kernel.h, which carries this notice: +/* + 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. +*/ + +package fuse + +import ( + "fmt" + "syscall" + "unsafe" +) + +// The FUSE version implemented by the package. +const ( + protoVersionMinMajor = 7 + protoVersionMinMinor = 8 + protoVersionMaxMajor = 7 + protoVersionMaxMinor = 12 +) + +const ( + rootID = 1 +) + +type kstatfs struct { + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Bsize uint32 + Namelen uint32 + Frsize uint32 + _ uint32 + Spare [6]uint32 +} + +type fileLock struct { + Start uint64 + End uint64 + Type uint32 + Pid uint32 +} + +// GetattrFlags are bit flags that can be seen in GetattrRequest. +type GetattrFlags uint32 + +const ( + // Indicates the handle is valid. + GetattrFh GetattrFlags = 1 << 0 +) + +var getattrFlagsNames = []flagName{ + {uint32(GetattrFh), "GetattrFh"}, +} + +func (fl GetattrFlags) String() string { + return flagString(uint32(fl), getattrFlagsNames) +} + +// The SetattrValid are bit flags describing which fields in the SetattrRequest +// are included in the change. +type SetattrValid uint32 + +const ( + SetattrMode SetattrValid = 1 << 0 + SetattrUid SetattrValid = 1 << 1 + SetattrGid SetattrValid = 1 << 2 + SetattrSize SetattrValid = 1 << 3 + SetattrAtime SetattrValid = 1 << 4 + SetattrMtime SetattrValid = 1 << 5 + SetattrHandle SetattrValid = 1 << 6 + + // Linux only(?) + SetattrAtimeNow SetattrValid = 1 << 7 + SetattrMtimeNow SetattrValid = 1 << 8 + SetattrLockOwner SetattrValid = 1 << 9 // http://www.mail-archive.com/git-commits-head@vger.kernel.org/msg27852.html + + // OS X only + SetattrCrtime SetattrValid = 1 << 28 + SetattrChgtime SetattrValid = 1 << 29 + SetattrBkuptime SetattrValid = 1 << 30 + SetattrFlags SetattrValid = 1 << 31 +) + +func (fl SetattrValid) Mode() bool { return fl&SetattrMode != 0 } +func (fl SetattrValid) Uid() bool { return fl&SetattrUid != 0 } +func (fl SetattrValid) Gid() bool { return fl&SetattrGid != 0 } +func (fl SetattrValid) Size() bool { return fl&SetattrSize != 0 } +func (fl SetattrValid) Atime() bool { return fl&SetattrAtime != 0 } +func (fl SetattrValid) Mtime() bool { return fl&SetattrMtime != 0 } +func (fl SetattrValid) Handle() bool { return fl&SetattrHandle != 0 } +func (fl SetattrValid) AtimeNow() bool { return fl&SetattrAtimeNow != 0 } +func (fl SetattrValid) MtimeNow() bool { return fl&SetattrMtimeNow != 0 } +func (fl SetattrValid) LockOwner() bool { return fl&SetattrLockOwner != 0 } +func (fl SetattrValid) Crtime() bool { return fl&SetattrCrtime != 0 } +func (fl SetattrValid) Chgtime() bool { return fl&SetattrChgtime != 0 } +func (fl SetattrValid) Bkuptime() bool { return fl&SetattrBkuptime != 0 } +func (fl SetattrValid) Flags() bool { return fl&SetattrFlags != 0 } + +func (fl SetattrValid) String() string { + return flagString(uint32(fl), setattrValidNames) +} + +var setattrValidNames = []flagName{ + {uint32(SetattrMode), "SetattrMode"}, + {uint32(SetattrUid), "SetattrUid"}, + {uint32(SetattrGid), "SetattrGid"}, + {uint32(SetattrSize), "SetattrSize"}, + {uint32(SetattrAtime), "SetattrAtime"}, + {uint32(SetattrMtime), "SetattrMtime"}, + {uint32(SetattrHandle), "SetattrHandle"}, + {uint32(SetattrAtimeNow), "SetattrAtimeNow"}, + {uint32(SetattrMtimeNow), "SetattrMtimeNow"}, + {uint32(SetattrLockOwner), "SetattrLockOwner"}, + {uint32(SetattrCrtime), "SetattrCrtime"}, + {uint32(SetattrChgtime), "SetattrChgtime"}, + {uint32(SetattrBkuptime), "SetattrBkuptime"}, + {uint32(SetattrFlags), "SetattrFlags"}, +} + +// Flags that can be seen in OpenRequest.Flags. +const ( + // Access modes. These are not 1-bit flags, but alternatives where + // only one can be chosen. See the IsReadOnly etc convenience + // methods. + OpenReadOnly OpenFlags = syscall.O_RDONLY + OpenWriteOnly OpenFlags = syscall.O_WRONLY + OpenReadWrite OpenFlags = syscall.O_RDWR + + // File was opened in append-only mode, all writes will go to end + // of file. OS X does not provide this information. + OpenAppend OpenFlags = syscall.O_APPEND + OpenCreate OpenFlags = syscall.O_CREAT + OpenDirectory OpenFlags = syscall.O_DIRECTORY + OpenExclusive OpenFlags = syscall.O_EXCL + OpenNonblock OpenFlags = syscall.O_NONBLOCK + OpenSync OpenFlags = syscall.O_SYNC + OpenTruncate OpenFlags = syscall.O_TRUNC +) + +// OpenAccessModeMask is a bitmask that separates the access mode +// from the other flags in OpenFlags. +const OpenAccessModeMask OpenFlags = syscall.O_ACCMODE + +// OpenFlags are the O_FOO flags passed to open/create/etc calls. For +// example, os.O_WRONLY | os.O_APPEND. +type OpenFlags uint32 + +func (fl OpenFlags) String() string { + // O_RDONLY, O_RWONLY, O_RDWR are not flags + s := accModeName(fl & OpenAccessModeMask) + flags := uint32(fl &^ OpenAccessModeMask) + if flags != 0 { + s = s + "+" + flagString(flags, openFlagNames) + } + return s +} + +// Return true if OpenReadOnly is set. +func (fl OpenFlags) IsReadOnly() bool { + return fl&OpenAccessModeMask == OpenReadOnly +} + +// Return true if OpenWriteOnly is set. +func (fl OpenFlags) IsWriteOnly() bool { + return fl&OpenAccessModeMask == OpenWriteOnly +} + +// Return true if OpenReadWrite is set. +func (fl OpenFlags) IsReadWrite() bool { + return fl&OpenAccessModeMask == OpenReadWrite +} + +func accModeName(flags OpenFlags) string { + switch flags { + case OpenReadOnly: + return "OpenReadOnly" + case OpenWriteOnly: + return "OpenWriteOnly" + case OpenReadWrite: + return "OpenReadWrite" + default: + return "" + } +} + +var openFlagNames = []flagName{ + {uint32(OpenAppend), "OpenAppend"}, + {uint32(OpenCreate), "OpenCreate"}, + {uint32(OpenDirectory), "OpenDirectory"}, + {uint32(OpenExclusive), "OpenExclusive"}, + {uint32(OpenNonblock), "OpenNonblock"}, + {uint32(OpenSync), "OpenSync"}, + {uint32(OpenTruncate), "OpenTruncate"}, +} + +// The OpenResponseFlags are returned in the OpenResponse. +type OpenResponseFlags uint32 + +const ( + OpenDirectIO OpenResponseFlags = 1 << 0 // bypass page cache for this open file + OpenKeepCache OpenResponseFlags = 1 << 1 // don't invalidate the data cache on open + OpenNonSeekable OpenResponseFlags = 1 << 2 // mark the file as non-seekable (not supported on OS X) + + OpenPurgeAttr OpenResponseFlags = 1 << 30 // OS X + OpenPurgeUBC OpenResponseFlags = 1 << 31 // OS X +) + +func (fl OpenResponseFlags) String() string { + return flagString(uint32(fl), openResponseFlagNames) +} + +var openResponseFlagNames = []flagName{ + {uint32(OpenDirectIO), "OpenDirectIO"}, + {uint32(OpenKeepCache), "OpenKeepCache"}, + {uint32(OpenNonSeekable), "OpenNonSeekable"}, + {uint32(OpenPurgeAttr), "OpenPurgeAttr"}, + {uint32(OpenPurgeUBC), "OpenPurgeUBC"}, +} + +// The InitFlags are used in the Init exchange. +type InitFlags uint32 + +const ( + InitAsyncRead InitFlags = 1 << 0 + InitPosixLocks InitFlags = 1 << 1 + InitFileOps InitFlags = 1 << 2 + InitAtomicTrunc InitFlags = 1 << 3 + InitExportSupport InitFlags = 1 << 4 + InitBigWrites InitFlags = 1 << 5 + // Do not mask file access modes with umask. Not supported on OS X. + InitDontMask InitFlags = 1 << 6 + InitSpliceWrite InitFlags = 1 << 7 + InitSpliceMove InitFlags = 1 << 8 + InitSpliceRead InitFlags = 1 << 9 + InitFlockLocks InitFlags = 1 << 10 + InitHasIoctlDir InitFlags = 1 << 11 + InitAutoInvalData InitFlags = 1 << 12 + InitDoReaddirplus InitFlags = 1 << 13 + InitReaddirplusAuto InitFlags = 1 << 14 + InitAsyncDIO InitFlags = 1 << 15 + InitWritebackCache InitFlags = 1 << 16 + InitNoOpenSupport InitFlags = 1 << 17 + + InitCaseSensitive InitFlags = 1 << 29 // OS X only + InitVolRename InitFlags = 1 << 30 // OS X only + InitXtimes InitFlags = 1 << 31 // OS X only +) + +type flagName struct { + bit uint32 + name string +} + +var initFlagNames = []flagName{ + {uint32(InitAsyncRead), "InitAsyncRead"}, + {uint32(InitPosixLocks), "InitPosixLocks"}, + {uint32(InitFileOps), "InitFileOps"}, + {uint32(InitAtomicTrunc), "InitAtomicTrunc"}, + {uint32(InitExportSupport), "InitExportSupport"}, + {uint32(InitBigWrites), "InitBigWrites"}, + {uint32(InitDontMask), "InitDontMask"}, + {uint32(InitSpliceWrite), "InitSpliceWrite"}, + {uint32(InitSpliceMove), "InitSpliceMove"}, + {uint32(InitSpliceRead), "InitSpliceRead"}, + {uint32(InitFlockLocks), "InitFlockLocks"}, + {uint32(InitHasIoctlDir), "InitHasIoctlDir"}, + {uint32(InitAutoInvalData), "InitAutoInvalData"}, + {uint32(InitDoReaddirplus), "InitDoReaddirplus"}, + {uint32(InitReaddirplusAuto), "InitReaddirplusAuto"}, + {uint32(InitAsyncDIO), "InitAsyncDIO"}, + {uint32(InitWritebackCache), "InitWritebackCache"}, + {uint32(InitNoOpenSupport), "InitNoOpenSupport"}, + + {uint32(InitCaseSensitive), "InitCaseSensitive"}, + {uint32(InitVolRename), "InitVolRename"}, + {uint32(InitXtimes), "InitXtimes"}, +} + +func (fl InitFlags) String() string { + return flagString(uint32(fl), initFlagNames) +} + +func flagString(f uint32, names []flagName) string { + var s string + + if f == 0 { + return "0" + } + + for _, n := range names { + if f&n.bit != 0 { + s += "+" + n.name + f &^= n.bit + } + } + if f != 0 { + s += fmt.Sprintf("%+#x", f) + } + return s[1:] +} + +// The ReleaseFlags are used in the Release exchange. +type ReleaseFlags uint32 + +const ( + ReleaseFlush ReleaseFlags = 1 << 0 +) + +func (fl ReleaseFlags) String() string { + return flagString(uint32(fl), releaseFlagNames) +} + +var releaseFlagNames = []flagName{ + {uint32(ReleaseFlush), "ReleaseFlush"}, +} + +// Opcodes +const ( + opLookup = 1 + opForget = 2 // no reply + opGetattr = 3 + opSetattr = 4 + opReadlink = 5 + opSymlink = 6 + opMknod = 8 + opMkdir = 9 + opUnlink = 10 + opRmdir = 11 + opRename = 12 + opLink = 13 + opOpen = 14 + opRead = 15 + opWrite = 16 + opStatfs = 17 + opRelease = 18 + opFsync = 20 + opSetxattr = 21 + opGetxattr = 22 + opListxattr = 23 + opRemovexattr = 24 + opFlush = 25 + opInit = 26 + opOpendir = 27 + opReaddir = 28 + opReleasedir = 29 + opFsyncdir = 30 + opGetlk = 31 + opSetlk = 32 + opSetlkw = 33 + opAccess = 34 + opCreate = 35 + opInterrupt = 36 + opBmap = 37 + opDestroy = 38 + opIoctl = 39 // Linux? + opPoll = 40 // Linux? + + // OS X + opSetvolname = 61 + opGetxtimes = 62 + opExchange = 63 +) + +type entryOut struct { + Nodeid uint64 // Inode ID + Generation uint64 // Inode generation + EntryValid uint64 // Cache timeout for the name + AttrValid uint64 // Cache timeout for the attributes + EntryValidNsec uint32 + AttrValidNsec uint32 + Attr attr +} + +func entryOutSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 9}): + return unsafe.Offsetof(entryOut{}.Attr) + unsafe.Offsetof(entryOut{}.Attr.Blksize) + default: + return unsafe.Sizeof(entryOut{}) + } +} + +type forgetIn struct { + Nlookup uint64 +} + +type getattrIn struct { + GetattrFlags uint32 + _ uint32 + Fh uint64 +} + +type attrOut struct { + AttrValid uint64 // Cache timeout for the attributes + AttrValidNsec uint32 + _ uint32 + Attr attr +} + +func attrOutSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 9}): + return unsafe.Offsetof(attrOut{}.Attr) + unsafe.Offsetof(attrOut{}.Attr.Blksize) + default: + return unsafe.Sizeof(attrOut{}) + } +} + +// OS X +type getxtimesOut struct { + Bkuptime uint64 + Crtime uint64 + BkuptimeNsec uint32 + CrtimeNsec uint32 +} + +type mknodIn struct { + Mode uint32 + Rdev uint32 + Umask uint32 + _ uint32 + // "filename\x00" follows. +} + +func mknodInSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 12}): + return unsafe.Offsetof(mknodIn{}.Umask) + default: + return unsafe.Sizeof(mknodIn{}) + } +} + +type mkdirIn struct { + Mode uint32 + Umask uint32 + // filename follows +} + +func mkdirInSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 12}): + return unsafe.Offsetof(mkdirIn{}.Umask) + 4 + default: + return unsafe.Sizeof(mkdirIn{}) + } +} + +type renameIn struct { + Newdir uint64 + // "oldname\x00newname\x00" follows +} + +// OS X +type exchangeIn struct { + Olddir uint64 + Newdir uint64 + Options uint64 + // "oldname\x00newname\x00" follows +} + +type linkIn struct { + Oldnodeid uint64 +} + +type setattrInCommon struct { + Valid uint32 + _ uint32 + Fh uint64 + Size uint64 + LockOwner uint64 // unused on OS X? + Atime uint64 + Mtime uint64 + Unused2 uint64 + AtimeNsec uint32 + MtimeNsec uint32 + Unused3 uint32 + Mode uint32 + Unused4 uint32 + Uid uint32 + Gid uint32 + Unused5 uint32 +} + +type openIn struct { + Flags uint32 + Unused uint32 +} + +type openOut struct { + Fh uint64 + OpenFlags uint32 + _ uint32 +} + +type createIn struct { + Flags uint32 + Mode uint32 + Umask uint32 + _ uint32 +} + +func createInSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 12}): + return unsafe.Offsetof(createIn{}.Umask) + default: + return unsafe.Sizeof(createIn{}) + } +} + +type releaseIn struct { + Fh uint64 + Flags uint32 + ReleaseFlags uint32 + LockOwner uint32 +} + +type flushIn struct { + Fh uint64 + FlushFlags uint32 + _ uint32 + LockOwner uint64 +} + +type readIn struct { + Fh uint64 + Offset uint64 + Size uint32 + ReadFlags uint32 + LockOwner uint64 + Flags uint32 + _ uint32 +} + +func readInSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 9}): + return unsafe.Offsetof(readIn{}.ReadFlags) + 4 + default: + return unsafe.Sizeof(readIn{}) + } +} + +// The ReadFlags are passed in ReadRequest. +type ReadFlags uint32 + +const ( + // LockOwner field is valid. + ReadLockOwner ReadFlags = 1 << 1 +) + +var readFlagNames = []flagName{ + {uint32(ReadLockOwner), "ReadLockOwner"}, +} + +func (fl ReadFlags) String() string { + return flagString(uint32(fl), readFlagNames) +} + +type writeIn struct { + Fh uint64 + Offset uint64 + Size uint32 + WriteFlags uint32 + LockOwner uint64 + Flags uint32 + _ uint32 +} + +func writeInSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 9}): + return unsafe.Offsetof(writeIn{}.LockOwner) + default: + return unsafe.Sizeof(writeIn{}) + } +} + +type writeOut struct { + Size uint32 + _ uint32 +} + +// The WriteFlags are passed in WriteRequest. +type WriteFlags uint32 + +const ( + WriteCache WriteFlags = 1 << 0 + // LockOwner field is valid. + WriteLockOwner WriteFlags = 1 << 1 +) + +var writeFlagNames = []flagName{ + {uint32(WriteCache), "WriteCache"}, + {uint32(WriteLockOwner), "WriteLockOwner"}, +} + +func (fl WriteFlags) String() string { + return flagString(uint32(fl), writeFlagNames) +} + +const compatStatfsSize = 48 + +type statfsOut struct { + St kstatfs +} + +type fsyncIn struct { + Fh uint64 + FsyncFlags uint32 + _ uint32 +} + +type setxattrInCommon struct { + Size uint32 + Flags uint32 +} + +func (setxattrInCommon) position() uint32 { + return 0 +} + +type getxattrInCommon struct { + Size uint32 + _ uint32 +} + +func (getxattrInCommon) position() uint32 { + return 0 +} + +type getxattrOut struct { + Size uint32 + _ uint32 +} + +type lkIn struct { + Fh uint64 + Owner uint64 + Lk fileLock + LkFlags uint32 + _ uint32 +} + +func lkInSize(p Protocol) uintptr { + switch { + case p.LT(Protocol{7, 9}): + return unsafe.Offsetof(lkIn{}.LkFlags) + default: + return unsafe.Sizeof(lkIn{}) + } +} + +type lkOut struct { + Lk fileLock +} + +type accessIn struct { + Mask uint32 + _ uint32 +} + +type initIn struct { + Major uint32 + Minor uint32 + MaxReadahead uint32 + Flags uint32 +} + +const initInSize = int(unsafe.Sizeof(initIn{})) + +type initOut struct { + Major uint32 + Minor uint32 + MaxReadahead uint32 + Flags uint32 + Unused uint32 + MaxWrite uint32 +} + +type interruptIn struct { + Unique uint64 +} + +type bmapIn struct { + Block uint64 + BlockSize uint32 + _ uint32 +} + +type bmapOut struct { + Block uint64 +} + +type inHeader struct { + Len uint32 + Opcode uint32 + Unique uint64 + Nodeid uint64 + Uid uint32 + Gid uint32 + Pid uint32 + _ uint32 +} + +const inHeaderSize = int(unsafe.Sizeof(inHeader{})) + +type outHeader struct { + Len uint32 + Error int32 + Unique uint64 +} + +type dirent struct { + Ino uint64 + Off uint64 + Namelen uint32 + Type uint32 + Name [0]byte +} + +const direntSize = 8 + 8 + 4 + 4 + +const ( + notifyCodePoll int32 = 1 + notifyCodeInvalInode int32 = 2 + notifyCodeInvalEntry int32 = 3 +) + +type notifyInvalInodeOut struct { + Ino uint64 + Off int64 + Len int64 +} + +type notifyInvalEntryOut struct { + Parent uint64 + Namelen uint32 + _ uint32 +} diff --git a/vendor/bazil.org/fuse/fuse_kernel_darwin.go b/vendor/bazil.org/fuse/fuse_kernel_darwin.go new file mode 100644 index 00000000..b9873fdf --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_kernel_darwin.go @@ -0,0 +1,88 @@ +package fuse + +import ( + "time" +) + +type attr struct { + Ino uint64 + Size uint64 + Blocks uint64 + Atime uint64 + Mtime uint64 + Ctime uint64 + Crtime_ uint64 // OS X only + AtimeNsec uint32 + MtimeNsec uint32 + CtimeNsec uint32 + CrtimeNsec uint32 // OS X only + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Flags_ uint32 // OS X only; see chflags(2) + Blksize uint32 + padding uint32 +} + +func (a *attr) SetCrtime(s uint64, ns uint32) { + a.Crtime_, a.CrtimeNsec = s, ns +} + +func (a *attr) SetFlags(f uint32) { + a.Flags_ = f +} + +type setattrIn struct { + setattrInCommon + + // OS X only + Bkuptime_ uint64 + Chgtime_ uint64 + Crtime uint64 + BkuptimeNsec uint32 + ChgtimeNsec uint32 + CrtimeNsec uint32 + Flags_ uint32 // see chflags(2) +} + +func (in *setattrIn) BkupTime() time.Time { + return time.Unix(int64(in.Bkuptime_), int64(in.BkuptimeNsec)) +} + +func (in *setattrIn) Chgtime() time.Time { + return time.Unix(int64(in.Chgtime_), int64(in.ChgtimeNsec)) +} + +func (in *setattrIn) Flags() uint32 { + return in.Flags_ +} + +func openFlags(flags uint32) OpenFlags { + return OpenFlags(flags) +} + +type getxattrIn struct { + getxattrInCommon + + // OS X only + Position uint32 + Padding uint32 +} + +func (g *getxattrIn) position() uint32 { + return g.Position +} + +type setxattrIn struct { + setxattrInCommon + + // OS X only + Position uint32 + Padding uint32 +} + +func (s *setxattrIn) position() uint32 { + return s.Position +} diff --git a/vendor/bazil.org/fuse/fuse_kernel_freebsd.go b/vendor/bazil.org/fuse/fuse_kernel_freebsd.go new file mode 100644 index 00000000..b1141e41 --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_kernel_freebsd.go @@ -0,0 +1,62 @@ +package fuse + +import "time" + +type attr struct { + Ino uint64 + Size uint64 + Blocks uint64 + Atime uint64 + Mtime uint64 + Ctime uint64 + AtimeNsec uint32 + MtimeNsec uint32 + CtimeNsec uint32 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Blksize uint32 + padding uint32 +} + +func (a *attr) Crtime() time.Time { + return time.Time{} +} + +func (a *attr) SetCrtime(s uint64, ns uint32) { + // ignored on freebsd +} + +func (a *attr) SetFlags(f uint32) { + // ignored on freebsd +} + +type setattrIn struct { + setattrInCommon +} + +func (in *setattrIn) BkupTime() time.Time { + return time.Time{} +} + +func (in *setattrIn) Chgtime() time.Time { + return time.Time{} +} + +func (in *setattrIn) Flags() uint32 { + return 0 +} + +func openFlags(flags uint32) OpenFlags { + return OpenFlags(flags) +} + +type getxattrIn struct { + getxattrInCommon +} + +type setxattrIn struct { + setxattrInCommon +} diff --git a/vendor/bazil.org/fuse/fuse_kernel_linux.go b/vendor/bazil.org/fuse/fuse_kernel_linux.go new file mode 100644 index 00000000..d3ba8661 --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_kernel_linux.go @@ -0,0 +1,70 @@ +package fuse + +import "time" + +type attr struct { + Ino uint64 + Size uint64 + Blocks uint64 + Atime uint64 + Mtime uint64 + Ctime uint64 + AtimeNsec uint32 + MtimeNsec uint32 + CtimeNsec uint32 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Blksize uint32 + padding uint32 +} + +func (a *attr) Crtime() time.Time { + return time.Time{} +} + +func (a *attr) SetCrtime(s uint64, ns uint32) { + // Ignored on Linux. +} + +func (a *attr) SetFlags(f uint32) { + // Ignored on Linux. +} + +type setattrIn struct { + setattrInCommon +} + +func (in *setattrIn) BkupTime() time.Time { + return time.Time{} +} + +func (in *setattrIn) Chgtime() time.Time { + return time.Time{} +} + +func (in *setattrIn) Flags() uint32 { + return 0 +} + +func openFlags(flags uint32) OpenFlags { + // on amd64, the 32-bit O_LARGEFILE flag is always seen; + // on i386, the flag probably depends on the app + // requesting, but in any case should be utterly + // uninteresting to us here; our kernel protocol messages + // are not directly related to the client app's kernel + // API/ABI + flags &^= 0x8000 + + return OpenFlags(flags) +} + +type getxattrIn struct { + getxattrInCommon +} + +type setxattrIn struct { + setxattrInCommon +} diff --git a/vendor/bazil.org/fuse/fuse_kernel_std.go b/vendor/bazil.org/fuse/fuse_kernel_std.go new file mode 100644 index 00000000..074cfd32 --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_kernel_std.go @@ -0,0 +1 @@ +package fuse diff --git a/vendor/bazil.org/fuse/fuse_linux.go b/vendor/bazil.org/fuse/fuse_linux.go new file mode 100644 index 00000000..5fb96f9a --- /dev/null +++ b/vendor/bazil.org/fuse/fuse_linux.go @@ -0,0 +1,7 @@ +package fuse + +// Maximum file write size we are prepared to receive from the kernel. +// +// Linux 4.2.0 has been observed to cap this value at 128kB +// (FUSE_MAX_PAGES_PER_REQ=32, 4kB pages). +const maxWrite = 128 * 1024 diff --git a/vendor/bazil.org/fuse/fuseutil/fuseutil.go b/vendor/bazil.org/fuse/fuseutil/fuseutil.go new file mode 100644 index 00000000..b3f52b73 --- /dev/null +++ b/vendor/bazil.org/fuse/fuseutil/fuseutil.go @@ -0,0 +1,20 @@ +package fuseutil // import "bazil.org/fuse/fuseutil" + +import ( + "bazil.org/fuse" +) + +// HandleRead handles a read request assuming that data is the entire file content. +// It adjusts the amount returned in resp according to req.Offset and req.Size. +func HandleRead(req *fuse.ReadRequest, resp *fuse.ReadResponse, data []byte) { + if req.Offset >= int64(len(data)) { + data = nil + } else { + data = data[req.Offset:] + } + if len(data) > req.Size { + data = data[:req.Size] + } + n := copy(resp.Data[:req.Size], data) + resp.Data = resp.Data[:n] +} diff --git a/vendor/bazil.org/fuse/mount.go b/vendor/bazil.org/fuse/mount.go new file mode 100644 index 00000000..8054e902 --- /dev/null +++ b/vendor/bazil.org/fuse/mount.go @@ -0,0 +1,38 @@ +package fuse + +import ( + "bufio" + "errors" + "io" + "log" + "sync" +) + +var ( + // ErrOSXFUSENotFound is returned from Mount when the OSXFUSE + // installation is not detected. + // + // Only happens on OS X. Make sure OSXFUSE is installed, or see + // OSXFUSELocations for customization. + ErrOSXFUSENotFound = errors.New("cannot locate OSXFUSE") +) + +func neverIgnoreLine(line string) bool { + return false +} + +func lineLogger(wg *sync.WaitGroup, prefix string, ignore func(line string) bool, r io.ReadCloser) { + defer wg.Done() + + scanner := bufio.NewScanner(r) + for scanner.Scan() { + line := scanner.Text() + if ignore(line) { + continue + } + log.Printf("%s: %s", prefix, line) + } + if err := scanner.Err(); err != nil { + log.Printf("%s, error reading: %v", prefix, err) + } +} diff --git a/vendor/bazil.org/fuse/mount_darwin.go b/vendor/bazil.org/fuse/mount_darwin.go new file mode 100644 index 00000000..c1c36e62 --- /dev/null +++ b/vendor/bazil.org/fuse/mount_darwin.go @@ -0,0 +1,208 @@ +package fuse + +import ( + "errors" + "fmt" + "log" + "os" + "os/exec" + "path" + "strconv" + "strings" + "sync" + "syscall" +) + +var ( + errNoAvail = errors.New("no available fuse devices") + errNotLoaded = errors.New("osxfuse is not loaded") +) + +func loadOSXFUSE(bin string) error { + cmd := exec.Command(bin) + cmd.Dir = "/" + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + return err +} + +func openOSXFUSEDev(devPrefix string) (*os.File, error) { + var f *os.File + var err error + for i := uint64(0); ; i++ { + path := devPrefix + strconv.FormatUint(i, 10) + f, err = os.OpenFile(path, os.O_RDWR, 0000) + if os.IsNotExist(err) { + if i == 0 { + // not even the first device was found -> fuse is not loaded + return nil, errNotLoaded + } + + // we've run out of kernel-provided devices + return nil, errNoAvail + } + + if err2, ok := err.(*os.PathError); ok && err2.Err == syscall.EBUSY { + // try the next one + continue + } + + if err != nil { + return nil, err + } + return f, nil + } +} + +func handleMountOSXFUSE(helperName string, errCh chan<- error) func(line string) (ignore bool) { + var noMountpointPrefix = helperName + `: ` + const noMountpointSuffix = `: No such file or directory` + return func(line string) (ignore bool) { + if strings.HasPrefix(line, noMountpointPrefix) && strings.HasSuffix(line, noMountpointSuffix) { + // re-extract it from the error message in case some layer + // changed the path + mountpoint := line[len(noMountpointPrefix) : len(line)-len(noMountpointSuffix)] + err := &MountpointDoesNotExistError{ + Path: mountpoint, + } + select { + case errCh <- err: + return true + default: + // not the first error; fall back to logging it + return false + } + } + + return false + } +} + +// isBoringMountOSXFUSEError returns whether the Wait error is +// uninteresting; exit status 64 is. +func isBoringMountOSXFUSEError(err error) bool { + if err, ok := err.(*exec.ExitError); ok && err.Exited() { + if status, ok := err.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 64 { + return true + } + } + return false +} + +func callMount(bin string, daemonVar string, dir string, conf *mountConfig, f *os.File, ready chan<- struct{}, errp *error) error { + for k, v := range conf.options { + if strings.Contains(k, ",") || strings.Contains(v, ",") { + // Silly limitation but the mount helper does not + // understand any escaping. See TestMountOptionCommaError. + return fmt.Errorf("mount options cannot contain commas on darwin: %q=%q", k, v) + } + } + cmd := exec.Command( + bin, + "-o", conf.getOptions(), + // Tell osxfuse-kext how large our buffer is. It must split + // writes larger than this into multiple writes. + // + // OSXFUSE seems to ignore InitResponse.MaxWrite, and uses + // this instead. + "-o", "iosize="+strconv.FormatUint(maxWrite, 10), + // refers to fd passed in cmd.ExtraFiles + "3", + dir, + ) + cmd.ExtraFiles = []*os.File{f} + cmd.Env = os.Environ() + // OSXFUSE <3.3.0 + cmd.Env = append(cmd.Env, "MOUNT_FUSEFS_CALL_BY_LIB=") + // OSXFUSE >=3.3.0 + cmd.Env = append(cmd.Env, "MOUNT_OSXFUSE_CALL_BY_LIB=") + + daemon := os.Args[0] + if daemonVar != "" { + cmd.Env = append(cmd.Env, daemonVar+"="+daemon) + } + + stdout, err := cmd.StdoutPipe() + if err != nil { + return fmt.Errorf("setting up mount_osxfusefs stderr: %v", err) + } + stderr, err := cmd.StderrPipe() + if err != nil { + return fmt.Errorf("setting up mount_osxfusefs stderr: %v", err) + } + + if err := cmd.Start(); err != nil { + return fmt.Errorf("mount_osxfusefs: %v", err) + } + helperErrCh := make(chan error, 1) + go func() { + var wg sync.WaitGroup + wg.Add(2) + go lineLogger(&wg, "mount helper output", neverIgnoreLine, stdout) + helperName := path.Base(bin) + go lineLogger(&wg, "mount helper error", handleMountOSXFUSE(helperName, helperErrCh), stderr) + wg.Wait() + if err := cmd.Wait(); err != nil { + // see if we have a better error to report + select { + case helperErr := <-helperErrCh: + // log the Wait error if it's not what we expected + if !isBoringMountOSXFUSEError(err) { + log.Printf("mount helper failed: %v", err) + } + // and now return what we grabbed from stderr as the real + // error + *errp = helperErr + close(ready) + return + default: + // nope, fall back to generic message + } + + *errp = fmt.Errorf("mount_osxfusefs: %v", err) + close(ready) + return + } + + *errp = nil + close(ready) + }() + return nil +} + +func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) { + locations := conf.osxfuseLocations + if locations == nil { + locations = []OSXFUSEPaths{ + OSXFUSELocationV3, + OSXFUSELocationV2, + } + } + for _, loc := range locations { + if _, err := os.Stat(loc.Mount); os.IsNotExist(err) { + // try the other locations + continue + } + + f, err := openOSXFUSEDev(loc.DevicePrefix) + if err == errNotLoaded { + err = loadOSXFUSE(loc.Load) + if err != nil { + return nil, err + } + // try again + f, err = openOSXFUSEDev(loc.DevicePrefix) + } + if err != nil { + return nil, err + } + err = callMount(loc.Mount, loc.DaemonVar, dir, conf, f, ready, errp) + if err != nil { + f.Close() + return nil, err + } + return f, nil + } + return nil, ErrOSXFUSENotFound +} diff --git a/vendor/bazil.org/fuse/mount_freebsd.go b/vendor/bazil.org/fuse/mount_freebsd.go new file mode 100644 index 00000000..70bb4102 --- /dev/null +++ b/vendor/bazil.org/fuse/mount_freebsd.go @@ -0,0 +1,111 @@ +package fuse + +import ( + "fmt" + "log" + "os" + "os/exec" + "strings" + "sync" + "syscall" +) + +func handleMountFusefsStderr(errCh chan<- error) func(line string) (ignore bool) { + return func(line string) (ignore bool) { + const ( + noMountpointPrefix = `mount_fusefs: ` + noMountpointSuffix = `: No such file or directory` + ) + if strings.HasPrefix(line, noMountpointPrefix) && strings.HasSuffix(line, noMountpointSuffix) { + // re-extract it from the error message in case some layer + // changed the path + mountpoint := line[len(noMountpointPrefix) : len(line)-len(noMountpointSuffix)] + err := &MountpointDoesNotExistError{ + Path: mountpoint, + } + select { + case errCh <- err: + return true + default: + // not the first error; fall back to logging it + return false + } + } + + return false + } +} + +// isBoringMountFusefsError returns whether the Wait error is +// uninteresting; exit status 1 is. +func isBoringMountFusefsError(err error) bool { + if err, ok := err.(*exec.ExitError); ok && err.Exited() { + if status, ok := err.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 1 { + return true + } + } + return false +} + +func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) { + for k, v := range conf.options { + if strings.Contains(k, ",") || strings.Contains(v, ",") { + // Silly limitation but the mount helper does not + // understand any escaping. See TestMountOptionCommaError. + return nil, fmt.Errorf("mount options cannot contain commas on FreeBSD: %q=%q", k, v) + } + } + + f, err := os.OpenFile("/dev/fuse", os.O_RDWR, 0000) + if err != nil { + *errp = err + return nil, err + } + + cmd := exec.Command( + "/sbin/mount_fusefs", + "--safe", + "-o", conf.getOptions(), + "3", + dir, + ) + cmd.ExtraFiles = []*os.File{f} + + stdout, err := cmd.StdoutPipe() + if err != nil { + return nil, fmt.Errorf("setting up mount_fusefs stderr: %v", err) + } + stderr, err := cmd.StderrPipe() + if err != nil { + return nil, fmt.Errorf("setting up mount_fusefs stderr: %v", err) + } + + if err := cmd.Start(); err != nil { + return nil, fmt.Errorf("mount_fusefs: %v", err) + } + helperErrCh := make(chan error, 1) + var wg sync.WaitGroup + wg.Add(2) + go lineLogger(&wg, "mount helper output", neverIgnoreLine, stdout) + go lineLogger(&wg, "mount helper error", handleMountFusefsStderr(helperErrCh), stderr) + wg.Wait() + if err := cmd.Wait(); err != nil { + // see if we have a better error to report + select { + case helperErr := <-helperErrCh: + // log the Wait error if it's not what we expected + if !isBoringMountFusefsError(err) { + log.Printf("mount helper failed: %v", err) + } + // and now return what we grabbed from stderr as the real + // error + return nil, helperErr + default: + // nope, fall back to generic message + } + return nil, fmt.Errorf("mount_fusefs: %v", err) + } + + close(ready) + return f, nil +} diff --git a/vendor/bazil.org/fuse/mount_linux.go b/vendor/bazil.org/fuse/mount_linux.go new file mode 100644 index 00000000..197d1044 --- /dev/null +++ b/vendor/bazil.org/fuse/mount_linux.go @@ -0,0 +1,150 @@ +package fuse + +import ( + "fmt" + "log" + "net" + "os" + "os/exec" + "strings" + "sync" + "syscall" +) + +func handleFusermountStderr(errCh chan<- error) func(line string) (ignore bool) { + return func(line string) (ignore bool) { + if line == `fusermount: failed to open /etc/fuse.conf: Permission denied` { + // Silence this particular message, it occurs way too + // commonly and isn't very relevant to whether the mount + // succeeds or not. + return true + } + + const ( + noMountpointPrefix = `fusermount: failed to access mountpoint ` + noMountpointSuffix = `: No such file or directory` + ) + if strings.HasPrefix(line, noMountpointPrefix) && strings.HasSuffix(line, noMountpointSuffix) { + // re-extract it from the error message in case some layer + // changed the path + mountpoint := line[len(noMountpointPrefix) : len(line)-len(noMountpointSuffix)] + err := &MountpointDoesNotExistError{ + Path: mountpoint, + } + select { + case errCh <- err: + return true + default: + // not the first error; fall back to logging it + return false + } + } + + return false + } +} + +// isBoringFusermountError returns whether the Wait error is +// uninteresting; exit status 1 is. +func isBoringFusermountError(err error) bool { + if err, ok := err.(*exec.ExitError); ok && err.Exited() { + if status, ok := err.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 1 { + return true + } + } + return false +} + +func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (fusefd *os.File, err error) { + // linux mount is never delayed + close(ready) + + fds, err := syscall.Socketpair(syscall.AF_FILE, syscall.SOCK_STREAM, 0) + if err != nil { + return nil, fmt.Errorf("socketpair error: %v", err) + } + + writeFile := os.NewFile(uintptr(fds[0]), "fusermount-child-writes") + defer writeFile.Close() + + readFile := os.NewFile(uintptr(fds[1]), "fusermount-parent-reads") + defer readFile.Close() + + cmd := exec.Command( + "fusermount", + "-o", conf.getOptions(), + "--", + dir, + ) + cmd.Env = append(os.Environ(), "_FUSE_COMMFD=3") + + cmd.ExtraFiles = []*os.File{writeFile} + + var wg sync.WaitGroup + stdout, err := cmd.StdoutPipe() + if err != nil { + return nil, fmt.Errorf("setting up fusermount stderr: %v", err) + } + stderr, err := cmd.StderrPipe() + if err != nil { + return nil, fmt.Errorf("setting up fusermount stderr: %v", err) + } + + if err := cmd.Start(); err != nil { + return nil, fmt.Errorf("fusermount: %v", err) + } + helperErrCh := make(chan error, 1) + wg.Add(2) + go lineLogger(&wg, "mount helper output", neverIgnoreLine, stdout) + go lineLogger(&wg, "mount helper error", handleFusermountStderr(helperErrCh), stderr) + wg.Wait() + if err := cmd.Wait(); err != nil { + // see if we have a better error to report + select { + case helperErr := <-helperErrCh: + // log the Wait error if it's not what we expected + if !isBoringFusermountError(err) { + log.Printf("mount helper failed: %v", err) + } + // and now return what we grabbed from stderr as the real + // error + return nil, helperErr + default: + // nope, fall back to generic message + } + + return nil, fmt.Errorf("fusermount: %v", err) + } + + c, err := net.FileConn(readFile) + if err != nil { + return nil, fmt.Errorf("FileConn from fusermount socket: %v", err) + } + defer c.Close() + + uc, ok := c.(*net.UnixConn) + if !ok { + return nil, fmt.Errorf("unexpected FileConn type; expected UnixConn, got %T", c) + } + + buf := make([]byte, 32) // expect 1 byte + oob := make([]byte, 32) // expect 24 bytes + _, oobn, _, _, err := uc.ReadMsgUnix(buf, oob) + scms, err := syscall.ParseSocketControlMessage(oob[:oobn]) + if err != nil { + return nil, fmt.Errorf("ParseSocketControlMessage: %v", err) + } + if len(scms) != 1 { + return nil, fmt.Errorf("expected 1 SocketControlMessage; got scms = %#v", scms) + } + scm := scms[0] + gotFds, err := syscall.ParseUnixRights(&scm) + if err != nil { + return nil, fmt.Errorf("syscall.ParseUnixRights: %v", err) + } + if len(gotFds) != 1 { + return nil, fmt.Errorf("wanted 1 fd; got %#v", gotFds) + } + f := os.NewFile(uintptr(gotFds[0]), "/dev/fuse") + return f, nil +} diff --git a/vendor/bazil.org/fuse/options.go b/vendor/bazil.org/fuse/options.go new file mode 100644 index 00000000..caee4953 --- /dev/null +++ b/vendor/bazil.org/fuse/options.go @@ -0,0 +1,272 @@ +package fuse + +import ( + "errors" + "strings" +) + +func dummyOption(conf *mountConfig) error { + return nil +} + +// mountConfig holds the configuration for a mount operation. +// Use it by passing MountOption values to Mount. +type mountConfig struct { + options map[string]string + maxReadahead uint32 + initFlags InitFlags + osxfuseLocations []OSXFUSEPaths +} + +func escapeComma(s string) string { + s = strings.Replace(s, `\`, `\\`, -1) + s = strings.Replace(s, `,`, `\,`, -1) + return s +} + +// getOptions makes a string of options suitable for passing to FUSE +// mount flag `-o`. Returns an empty string if no options were set. +// Any platform specific adjustments should happen before the call. +func (m *mountConfig) getOptions() string { + var opts []string + for k, v := range m.options { + k = escapeComma(k) + if v != "" { + k += "=" + escapeComma(v) + } + opts = append(opts, k) + } + return strings.Join(opts, ",") +} + +type mountOption func(*mountConfig) error + +// MountOption is passed to Mount to change the behavior of the mount. +type MountOption mountOption + +// FSName sets the file system name (also called source) that is +// visible in the list of mounted file systems. +// +// FreeBSD ignores this option. +func FSName(name string) MountOption { + return func(conf *mountConfig) error { + conf.options["fsname"] = name + return nil + } +} + +// Subtype sets the subtype of the mount. The main type is always +// `fuse`. The type in a list of mounted file systems will look like +// `fuse.foo`. +// +// OS X ignores this option. +// FreeBSD ignores this option. +func Subtype(fstype string) MountOption { + return func(conf *mountConfig) error { + conf.options["subtype"] = fstype + return nil + } +} + +// LocalVolume sets the volume to be local (instead of network), +// changing the behavior of Finder, Spotlight, and such. +// +// OS X only. Others ignore this option. +func LocalVolume() MountOption { + return localVolume +} + +// VolumeName sets the volume name shown in Finder. +// +// OS X only. Others ignore this option. +func VolumeName(name string) MountOption { + return volumeName(name) +} + +// NoAppleDouble makes OSXFUSE disallow files with names used by OS X +// to store extended attributes on file systems that do not support +// them natively. +// +// Such file names are: +// +// ._* +// .DS_Store +// +// OS X only. Others ignore this option. +func NoAppleDouble() MountOption { + return noAppleDouble +} + +// NoAppleXattr makes OSXFUSE disallow extended attributes with the +// prefix "com.apple.". This disables persistent Finder state and +// other such information. +// +// OS X only. Others ignore this option. +func NoAppleXattr() MountOption { + return noAppleXattr +} + +// DaemonTimeout sets the time in seconds between a request and a reply before +// the FUSE mount is declared dead. +// +// OS X and FreeBSD only. Others ignore this option. +func DaemonTimeout(name string) MountOption { + return daemonTimeout(name) +} + +var ErrCannotCombineAllowOtherAndAllowRoot = errors.New("cannot combine AllowOther and AllowRoot") + +// AllowOther allows other users to access the file system. +// +// Only one of AllowOther or AllowRoot can be used. +func AllowOther() MountOption { + return func(conf *mountConfig) error { + if _, ok := conf.options["allow_root"]; ok { + return ErrCannotCombineAllowOtherAndAllowRoot + } + conf.options["allow_other"] = "" + return nil + } +} + +// AllowRoot allows other users to access the file system. +// +// Only one of AllowOther or AllowRoot can be used. +// +// FreeBSD ignores this option. +func AllowRoot() MountOption { + return func(conf *mountConfig) error { + if _, ok := conf.options["allow_other"]; ok { + return ErrCannotCombineAllowOtherAndAllowRoot + } + conf.options["allow_root"] = "" + return nil + } +} + +// AllowDev enables interpreting character or block special devices on the +// filesystem. +func AllowDev() MountOption { + return func(conf *mountConfig) error { + conf.options["dev"] = "" + return nil + } +} + +// AllowSUID allows set-user-identifier or set-group-identifier bits to take +// effect. +func AllowSUID() MountOption { + return func(conf *mountConfig) error { + conf.options["suid"] = "" + return nil + } +} + +// DefaultPermissions makes the kernel enforce access control based on +// the file mode (as in chmod). +// +// Without this option, the Node itself decides what is and is not +// allowed. This is normally ok because FUSE file systems cannot be +// accessed by other users without AllowOther/AllowRoot. +// +// FreeBSD ignores this option. +func DefaultPermissions() MountOption { + return func(conf *mountConfig) error { + conf.options["default_permissions"] = "" + return nil + } +} + +// ReadOnly makes the mount read-only. +func ReadOnly() MountOption { + return func(conf *mountConfig) error { + conf.options["ro"] = "" + return nil + } +} + +// MaxReadahead sets the number of bytes that can be prefetched for +// sequential reads. The kernel can enforce a maximum value lower than +// this. +// +// This setting makes the kernel perform speculative reads that do not +// originate from any client process. This usually tremendously +// improves read performance. +func MaxReadahead(n uint32) MountOption { + return func(conf *mountConfig) error { + conf.maxReadahead = n + return nil + } +} + +// AsyncRead enables multiple outstanding read requests for the same +// handle. Without this, there is at most one request in flight at a +// time. +func AsyncRead() MountOption { + return func(conf *mountConfig) error { + conf.initFlags |= InitAsyncRead + return nil + } +} + +// WritebackCache enables the kernel to buffer writes before sending +// them to the FUSE server. Without this, writethrough caching is +// used. +func WritebackCache() MountOption { + return func(conf *mountConfig) error { + conf.initFlags |= InitWritebackCache + return nil + } +} + +// OSXFUSEPaths describes the paths used by an installed OSXFUSE +// version. See OSXFUSELocationV3 for typical values. +type OSXFUSEPaths struct { + // Prefix for the device file. At mount time, an incrementing + // number is suffixed until a free FUSE device is found. + DevicePrefix string + // Path of the load helper, used to load the kernel extension if + // no device files are found. + Load string + // Path of the mount helper, used for the actual mount operation. + Mount string + // Environment variable used to pass the path to the executable + // calling the mount helper. + DaemonVar string +} + +// Default paths for OSXFUSE. See OSXFUSELocations. +var ( + OSXFUSELocationV3 = OSXFUSEPaths{ + DevicePrefix: "/dev/osxfuse", + Load: "/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse", + Mount: "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", + DaemonVar: "MOUNT_OSXFUSE_DAEMON_PATH", + } + OSXFUSELocationV2 = OSXFUSEPaths{ + DevicePrefix: "/dev/osxfuse", + Load: "/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", + Mount: "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", + DaemonVar: "MOUNT_FUSEFS_DAEMON_PATH", + } +) + +// OSXFUSELocations sets where to look for OSXFUSE files. The +// arguments are all the possible locations. The previous locations +// are replaced. +// +// Without this option, OSXFUSELocationV3 and OSXFUSELocationV2 are +// used. +// +// OS X only. Others ignore this option. +func OSXFUSELocations(paths ...OSXFUSEPaths) MountOption { + return func(conf *mountConfig) error { + if len(paths) == 0 { + return errors.New("must specify at least one location for OSXFUSELocations") + } + // replace previous values, but make a copy so there's no + // worries about caller mutating their slice + conf.osxfuseLocations = append(conf.osxfuseLocations[:0], paths...) + return nil + } +} diff --git a/vendor/bazil.org/fuse/options_darwin.go b/vendor/bazil.org/fuse/options_darwin.go new file mode 100644 index 00000000..b5340246 --- /dev/null +++ b/vendor/bazil.org/fuse/options_darwin.go @@ -0,0 +1,30 @@ +package fuse + +func localVolume(conf *mountConfig) error { + conf.options["local"] = "" + return nil +} + +func volumeName(name string) MountOption { + return func(conf *mountConfig) error { + conf.options["volname"] = name + return nil + } +} + +func daemonTimeout(name string) MountOption { + return func(conf *mountConfig) error { + conf.options["daemon_timeout"] = name + return nil + } +} + +func noAppleXattr(conf *mountConfig) error { + conf.options["noapplexattr"] = "" + return nil +} + +func noAppleDouble(conf *mountConfig) error { + conf.options["noappledouble"] = "" + return nil +} diff --git a/vendor/bazil.org/fuse/options_freebsd.go b/vendor/bazil.org/fuse/options_freebsd.go new file mode 100644 index 00000000..2387124c --- /dev/null +++ b/vendor/bazil.org/fuse/options_freebsd.go @@ -0,0 +1,24 @@ +package fuse + +func localVolume(conf *mountConfig) error { + return nil +} + +func volumeName(name string) MountOption { + return dummyOption +} + +func daemonTimeout(name string) MountOption { + return func(conf *mountConfig) error { + conf.options["timeout"] = name + return nil + } +} + +func noAppleXattr(conf *mountConfig) error { + return nil +} + +func noAppleDouble(conf *mountConfig) error { + return nil +} diff --git a/vendor/bazil.org/fuse/options_linux.go b/vendor/bazil.org/fuse/options_linux.go new file mode 100644 index 00000000..77b46a50 --- /dev/null +++ b/vendor/bazil.org/fuse/options_linux.go @@ -0,0 +1,21 @@ +package fuse + +func localVolume(conf *mountConfig) error { + return nil +} + +func volumeName(name string) MountOption { + return dummyOption +} + +func daemonTimeout(name string) MountOption { + return dummyOption +} + +func noAppleXattr(conf *mountConfig) error { + return nil +} + +func noAppleDouble(conf *mountConfig) error { + return nil +} diff --git a/vendor/bazil.org/fuse/protocol.go b/vendor/bazil.org/fuse/protocol.go new file mode 100644 index 00000000..a77bbf72 --- /dev/null +++ b/vendor/bazil.org/fuse/protocol.go @@ -0,0 +1,75 @@ +package fuse + +import ( + "fmt" +) + +// Protocol is a FUSE protocol version number. +type Protocol struct { + Major uint32 + Minor uint32 +} + +func (p Protocol) String() string { + return fmt.Sprintf("%d.%d", p.Major, p.Minor) +} + +// LT returns whether a is less than b. +func (a Protocol) LT(b Protocol) bool { + return a.Major < b.Major || + (a.Major == b.Major && a.Minor < b.Minor) +} + +// GE returns whether a is greater than or equal to b. +func (a Protocol) GE(b Protocol) bool { + return a.Major > b.Major || + (a.Major == b.Major && a.Minor >= b.Minor) +} + +func (a Protocol) is79() bool { + return a.GE(Protocol{7, 9}) +} + +// HasAttrBlockSize returns whether Attr.BlockSize is respected by the +// kernel. +func (a Protocol) HasAttrBlockSize() bool { + return a.is79() +} + +// HasReadWriteFlags returns whether ReadRequest/WriteRequest +// fields Flags and FileFlags are valid. +func (a Protocol) HasReadWriteFlags() bool { + return a.is79() +} + +// HasGetattrFlags returns whether GetattrRequest field Flags is +// valid. +func (a Protocol) HasGetattrFlags() bool { + return a.is79() +} + +func (a Protocol) is710() bool { + return a.GE(Protocol{7, 10}) +} + +// HasOpenNonSeekable returns whether OpenResponse field Flags flag +// OpenNonSeekable is supported. +func (a Protocol) HasOpenNonSeekable() bool { + return a.is710() +} + +func (a Protocol) is712() bool { + return a.GE(Protocol{7, 12}) +} + +// HasUmask returns whether CreateRequest/MkdirRequest/MknodRequest +// field Umask is valid. +func (a Protocol) HasUmask() bool { + return a.is712() +} + +// HasInvalidate returns whether InvalidateNode/InvalidateEntry are +// supported. +func (a Protocol) HasInvalidate() bool { + return a.is712() +} diff --git a/vendor/bazil.org/fuse/unmount.go b/vendor/bazil.org/fuse/unmount.go new file mode 100644 index 00000000..ffe3f155 --- /dev/null +++ b/vendor/bazil.org/fuse/unmount.go @@ -0,0 +1,6 @@ +package fuse + +// Unmount tries to unmount the filesystem mounted at dir. +func Unmount(dir string) error { + return unmount(dir) +} diff --git a/vendor/bazil.org/fuse/unmount_linux.go b/vendor/bazil.org/fuse/unmount_linux.go new file mode 100644 index 00000000..088f0cfe --- /dev/null +++ b/vendor/bazil.org/fuse/unmount_linux.go @@ -0,0 +1,21 @@ +package fuse + +import ( + "bytes" + "errors" + "os/exec" +) + +func unmount(dir string) error { + cmd := exec.Command("fusermount", "-u", dir) + output, err := cmd.CombinedOutput() + if err != nil { + if len(output) > 0 { + output = bytes.TrimRight(output, "\n") + msg := err.Error() + ": " + string(output) + err = errors.New(msg) + } + return err + } + return nil +} diff --git a/vendor/bazil.org/fuse/unmount_std.go b/vendor/bazil.org/fuse/unmount_std.go new file mode 100644 index 00000000..d6efe276 --- /dev/null +++ b/vendor/bazil.org/fuse/unmount_std.go @@ -0,0 +1,17 @@ +// +build !linux + +package fuse + +import ( + "os" + "syscall" +) + +func unmount(dir string) error { + err := syscall.Unmount(dir, 0) + if err != nil { + err = &os.PathError{Op: "unmount", Path: dir, Err: err} + return err + } + return nil +} diff --git a/vendor/github.com/hanwen/go-fuse/.gitignore b/vendor/github.com/hanwen/go-fuse/.gitignore deleted file mode 100644 index a18633a4..00000000 --- a/vendor/github.com/hanwen/go-fuse/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -*~ -*.6 -8.out -.nfs* -_* -6.out -#* -example/hello/hello -example/unionfs/unionfs -example/autounionfs/autounionfs -example/loopback/loopback -example/multizip/multizip -example/bulkstat/bulkstat -example/zipfs/zipfs diff --git a/vendor/github.com/hanwen/go-fuse/CONTRIBUTING b/vendor/github.com/hanwen/go-fuse/CONTRIBUTING deleted file mode 100644 index 16a740c7..00000000 --- a/vendor/github.com/hanwen/go-fuse/CONTRIBUTING +++ /dev/null @@ -1,22 +0,0 @@ - -Before sending a patch or Pull request, please fill out a Google CLA, using the following form: - - https://cla.developers.google.com/clas - -For complex changes, please use Gerrit: - -* Connect your github account with gerrithub, at - - https://review.gerrithub.io/static/intro.html - -* The signup will setup your SSH keys from Github. - -* Create your change as a commit - -* Add an ID to the commit message: - - echo "Change-Id: I"$(head -c 20 /dev/urandom | sha1sum | awk '{print $1}') - -* Push the change for review, - - git push ssh://$USER@review.gerrithub.io:29418/hanwen/go-fuse HEAD:refs/for/master diff --git a/vendor/github.com/hanwen/go-fuse/LICENSE b/vendor/github.com/hanwen/go-fuse/LICENSE deleted file mode 100644 index d3fb2062..00000000 --- a/vendor/github.com/hanwen/go-fuse/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -// New BSD License -// -// Copyright (c) 2010 Ivan Krasin (imkrasin@gmail.com). 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 Ivan Krasin 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/hanwen/go-fuse/README b/vendor/github.com/hanwen/go-fuse/README deleted file mode 100644 index 2576329b..00000000 --- a/vendor/github.com/hanwen/go-fuse/README +++ /dev/null @@ -1,150 +0,0 @@ - -GO-FUSE: native bindings for the FUSE kernel module. - - -HIGHLIGHTS - -* High speed: as fast as libfuse using the gc compiler for single -threaded loads. - -* Supports in-process mounting of different FileSystems onto -subdirectories of the FUSE mount. - -* Supports 3 interfaces for writing filesystems: - - PathFileSystem: define filesystems in terms path names. - - NodeFileSystem: define filesystems in terms of inodes. - - RawFileSystem: define filesystems in terms of FUSE's raw - wire protocol. - -* Both NodeFileSystem and PathFileSystem support manipulation of true - hardlinks. - -* Includes two fleshed out examples, zipfs and unionfs. - - -EXAMPLES - -* examples/hello/hello.go contains a 60-line "hello world" filesystem - -* zipfs/zipfs.go contains a small and simple read-only filesystem for - zip and tar files. The corresponding command is in example/zipfs/ - For example, - - mkdir /tmp/mountpoint - example/zipfs/zipfs /tmp/mountpoint file.zip & - ls /tmp/mountpoint - fusermount -u /tmp/mountpoint - -* zipfs/multizipfs.go shows how to use in-process mounts to - combine multiple Go-FUSE filesystems into a larger filesystem. - -* fuse/loopback.go mounts another piece of the filesystem. - Functionally, it is similar to a symlink. A binary to run is in - example/loopback/ . For example - - mkdir /tmp/mountpoint - example/loopback/loopback -debug /tmp/mountpoint /some/other/directory & - ls /tmp/mountpoint - fusermount -u /tmp/mountpoint - -* unionfs/unionfs.go: implements a union mount using 1 R/W branch, and - multiple R/O branches. - - mkdir -p /tmp/mountpoint /tmp/writable - example/unionfs/unionfs /tmp/mountpoint /tmp/writable /usr & - ls /tmp/mountpoint - ls -l /tmp/mountpoint/bin/vi - rm /tmp/mountpoint/bin/vi - ls -l /tmp/mountpoint/bin/vi - cat /tmp/writable/*DELETION*/* - -* union/autounionfs.go: creates UnionFs mounts automatically based on - existence of READONLY symlinks. - - -Tested on: - -- x86 32bits (Fedora 14). -- x86 64bits (Ubuntu Lucid). - - -BENCHMARKS - -We use threaded stats over a read-only filesystem for benchmarking. -Automated code is under benchmark/ directory. A simple C version of -the same FS gives a FUSE baseline - -Data points (Go-FUSE version May 2012), 1000 files, high level -interface, all kernel caching turned off, median stat time: - -platform libfuse Go-FUSE difference (%) - -Lenovo T60/Fedora16 (1cpu) 349us 355us 2% slower -Lenovo T400/Lucid (1cpu) 138us 140us 5% slower -Dell T3500/Lucid (1cpu) 72us 76us 5% slower - -On T60, for each file we have -- Client side latency is 360us -- 106us of this is server side latency (4.5x lookup 23us, 1x getattr 4us) -- 16.5us is due to latency measurements. -- 3us is due to garbage collection. - - - -MACOS SUPPORT - -go-fuse works somewhat on OSX. Known limitations: - -* All of the limitations of OSXFUSE, including lack of support for - NOTIFY. - -* OSX issues STATFS calls continuously (leading to performance - concerns). - -* OSX has trouble with concurrent reads from the FUSE device, leading - to performance concerns. - -* A bunch of tests under fuse/test/ fail, and the functionality they - test for OSX is likely broken. - - -CREDITS - -* Inspired by Taru Karttunen's package, https://bitbucket.org/taruti/go-extra. - -* Originally based on Ivan Krasin's https://github.com/krasin/go-fuse-zip - - -BUGS - -Yes, probably. Report them through -https://github.com/hanwen/go-fuse/issues - - -DISCLAIMER - -This is not an official Google product. - - -KNOWN PROBLEMS - -Grep source code for TODO. Major topics: - -* Support for umask in Create - -* Missing support for network FS file locking: FUSE_GETLK, FUSE_SETLK, - FUSE_SETLKW - -* Missing support for FUSE_INTERRUPT, CUSE, BMAP, POLL, IOCTL - -* In the path API, renames are racy; See also: - - http://sourceforge.net/mailarchive/message.php?msg_id=27550667 - - Don't use the path API if you care about correctness. - - -LICENSE - -Like Go, this library is distributed under the new BSD license. See -accompanying LICENSE file. diff --git a/vendor/github.com/hanwen/go-fuse/all.bash b/vendor/github.com/hanwen/go-fuse/all.bash deleted file mode 100755 index e7331f62..00000000 --- a/vendor/github.com/hanwen/go-fuse/all.bash +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -set -eu - -for target in "clean" "install" ; do - for d in fuse fuse/nodefs fuse/pathfs fuse/test zipfs unionfs \ - example/hello example/loopback example/zipfs \ - example/multizip example/unionfs example/memfs \ - example/autounionfs ; \ - do - if test "${target}" = "install" && test "${d}" = "fuse/test"; then - continue - fi - echo "go ${target} github.com/hanwen/go-fuse/${d}" - go ${target} github.com/hanwen/go-fuse/${d} - done -done - -for d in fuse zipfs unionfs fuse/test -do - ( - cd $d - echo "go test github.com/hanwen/go-fuse/$d" - go test github.com/hanwen/go-fuse/$d - echo "go test -race github.com/hanwen/go-fuse/$d" - go test -race github.com/hanwen/go-fuse/$d - ) -done - -make -C benchmark -for d in benchmark -do - go test github.com/hanwen/go-fuse/benchmark -test.bench '.*' -test.cpu 1,2 -done diff --git a/vendor/github.com/hanwen/go-fuse/fuse/.gitignore b/vendor/github.com/hanwen/go-fuse/fuse/.gitignore deleted file mode 100644 index 13df9161..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/.gitignore +++ /dev/null @@ -1 +0,0 @@ -version.gen.go diff --git a/vendor/github.com/hanwen/go-fuse/fuse/api.go b/vendor/github.com/hanwen/go-fuse/fuse/api.go deleted file mode 100644 index ea850931..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/api.go +++ /dev/null @@ -1,131 +0,0 @@ -// The fuse package provides APIs to implement filesystems in -// userspace. Typically, each call of the API happens in its own -// goroutine, so take care to make the file system thread-safe. - -package fuse - -// Types for users to implement. - -// The result of Read is an array of bytes, but for performance -// reasons, we can also return data as a file-descriptor/offset/size -// tuple. If the backing store for a file is another filesystem, this -// reduces the amount of copying between the kernel and the FUSE -// server. The ReadResult interface captures both cases. -type ReadResult interface { - // Returns the raw bytes for the read, possibly using the - // passed buffer. The buffer should be larger than the return - // value from Size. - Bytes(buf []byte) ([]byte, Status) - - // Size returns how many bytes this return value takes at most. - Size() int - - // Done() is called after sending the data to the kernel. - Done() -} - -type MountOptions struct { - AllowOther bool - - // Options are passed as -o string to fusermount. - Options []string - - // Default is _DEFAULT_BACKGROUND_TASKS, 12. This numbers - // controls the allowed number of requests that relate to - // async I/O. Concurrency for synchronous I/O is not limited. - MaxBackground int - - // Write size to use. If 0, use default. This number is - // capped at the kernel maximum. - MaxWrite int - - // If IgnoreSecurityLabels is set, all security related xattr - // requests will return NO_DATA without passing through the - // user defined filesystem. You should only set this if you - // file system implements extended attributes, and you are not - // interested in security labels. - IgnoreSecurityLabels bool // ignoring labels should be provided as a fusermount mount option. - - // If given, use this buffer pool instead of the global one. - Buffers BufferPool - - // If RememberInodes is set, we will never forget inodes. - // This may be useful for NFS. - RememberInodes bool - - // Values shown in "df -T" and friends - // First column, "Filesystem" - FsName string - // Second column, "Type", will be shown as "fuse." + Name - Name string - - // If set, wrap the file system in a single-threaded locking wrapper. - SingleThreaded bool -} - -// RawFileSystem is an interface close to the FUSE wire protocol. -// -// Unless you really know what you are doing, you should not implement -// this, but rather the FileSystem interface; the details of getting -// interactions with open files, renames, and threading right etc. are -// somewhat tricky and not very interesting. -// -// A null implementation is provided by NewDefaultRawFileSystem. -type RawFileSystem interface { - String() string - - // If called, provide debug output through the log package. - SetDebug(debug bool) - - Lookup(header *InHeader, name string, out *EntryOut) (status Status) - Forget(nodeid, nlookup uint64) - - // Attributes. - GetAttr(input *GetAttrIn, out *AttrOut) (code Status) - SetAttr(input *SetAttrIn, out *AttrOut) (code Status) - - // Modifying structure. - Mknod(input *MknodIn, name string, out *EntryOut) (code Status) - Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) - Unlink(header *InHeader, name string) (code Status) - Rmdir(header *InHeader, name string) (code Status) - Rename(input *RenameIn, oldName string, newName string) (code Status) - Link(input *LinkIn, filename string, out *EntryOut) (code Status) - - Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) - Readlink(header *InHeader) (out []byte, code Status) - Access(input *AccessIn) (code Status) - - // Extended attributes. - GetXAttrSize(header *InHeader, attr string) (sz int, code Status) - GetXAttrData(header *InHeader, attr string) (data []byte, code Status) - ListXAttr(header *InHeader) (attributes []byte, code Status) - SetXAttr(input *SetXAttrIn, attr string, data []byte) Status - RemoveXAttr(header *InHeader, attr string) (code Status) - - // File handling. - Create(input *CreateIn, name string, out *CreateOut) (code Status) - Open(input *OpenIn, out *OpenOut) (status Status) - Read(input *ReadIn, buf []byte) (ReadResult, Status) - - Release(input *ReleaseIn) - Write(input *WriteIn, data []byte) (written uint32, code Status) - Flush(input *FlushIn) Status - Fsync(input *FsyncIn) (code Status) - Fallocate(input *FallocateIn) (code Status) - - // Directory handling - OpenDir(input *OpenIn, out *OpenOut) (status Status) - ReadDir(input *ReadIn, out *DirEntryList) Status - ReadDirPlus(input *ReadIn, out *DirEntryList) Status - ReleaseDir(input *ReleaseIn) - FsyncDir(input *FsyncIn) (code Status) - - // - StatFs(input *InHeader, out *StatfsOut) (code Status) - - // This is called on processing the first request. The - // filesystem implementation can use the server argument to - // talk back to the kernel (through notify methods). - Init(*Server) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/attr.go b/vendor/github.com/hanwen/go-fuse/fuse/attr.go deleted file mode 100644 index 7211accb..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/attr.go +++ /dev/null @@ -1,75 +0,0 @@ -package fuse - -import ( - "os" - "syscall" - "time" -) - -func (a *Attr) IsFifo() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFIFO } - -// IsChar reports whether the FileInfo describes a character special file. -func (a *Attr) IsChar() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFCHR } - -// IsDir reports whether the FileInfo describes a directory. -func (a *Attr) IsDir() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFDIR } - -// IsBlock reports whether the FileInfo describes a block special file. -func (a *Attr) IsBlock() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFBLK } - -// IsRegular reports whether the FileInfo describes a regular file. -func (a *Attr) IsRegular() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFREG } - -// IsSymlink reports whether the FileInfo describes a symbolic link. -func (a *Attr) IsSymlink() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFLNK } - -// IsSocket reports whether the FileInfo describes a socket. -func (a *Attr) IsSocket() bool { return (uint32(a.Mode) & syscall.S_IFMT) == syscall.S_IFSOCK } - -func (a *Attr) SetTimes(access *time.Time, mod *time.Time, chstatus *time.Time) { - if access != nil { - a.Atime = uint64(access.Unix()) - a.Atimensec = uint32(access.Nanosecond()) - } - if mod != nil { - a.Mtime = uint64(mod.Unix()) - a.Mtimensec = uint32(mod.Nanosecond()) - } - if chstatus != nil { - a.Ctime = uint64(chstatus.Unix()) - a.Ctimensec = uint32(chstatus.Nanosecond()) - } -} - -func (a *Attr) ChangeTime() time.Time { - return time.Unix(int64(a.Ctime), int64(a.Ctimensec)) -} - -func (a *Attr) AccessTime() time.Time { - return time.Unix(int64(a.Atime), int64(a.Atimensec)) -} - -func (a *Attr) ModTime() time.Time { - return time.Unix(int64(a.Mtime), int64(a.Mtimensec)) -} - -func ToStatT(f os.FileInfo) *syscall.Stat_t { - s, _ := f.Sys().(*syscall.Stat_t) - if s != nil { - return s - } - return nil -} - -func ToAttr(f os.FileInfo) *Attr { - if f == nil { - return nil - } - s := ToStatT(f) - if s != nil { - a := &Attr{} - a.FromStat(s) - return a - } - return nil -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go deleted file mode 100644 index af3ef871..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/attr_darwin.go +++ /dev/null @@ -1,22 +0,0 @@ -package fuse - -import ( - "syscall" -) - -func (a *Attr) FromStat(s *syscall.Stat_t) { - a.Ino = uint64(s.Ino) - a.Size = uint64(s.Size) - a.Blocks = uint64(s.Blocks) - a.Atime = uint64(s.Atimespec.Sec) - a.Atimensec = uint32(s.Atimespec.Nsec) - a.Mtime = uint64(s.Mtimespec.Sec) - a.Mtimensec = uint32(s.Mtimespec.Nsec) - a.Ctime = uint64(s.Ctimespec.Sec) - a.Ctimensec = uint32(s.Ctimespec.Nsec) - a.Mode = uint32(s.Mode) - a.Nlink = uint32(s.Nlink) - a.Uid = uint32(s.Uid) - a.Gid = uint32(s.Gid) - a.Rdev = uint32(s.Rdev) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go deleted file mode 100644 index 37823699..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/attr_linux.go +++ /dev/null @@ -1,23 +0,0 @@ -package fuse - -import ( - "syscall" -) - -func (a *Attr) FromStat(s *syscall.Stat_t) { - a.Ino = uint64(s.Ino) - a.Size = uint64(s.Size) - a.Blocks = uint64(s.Blocks) - a.Atime = uint64(s.Atim.Sec) - a.Atimensec = uint32(s.Atim.Nsec) - a.Mtime = uint64(s.Mtim.Sec) - a.Mtimensec = uint32(s.Mtim.Nsec) - a.Ctime = uint64(s.Ctim.Sec) - a.Ctimensec = uint32(s.Ctim.Nsec) - a.Mode = s.Mode - a.Nlink = uint32(s.Nlink) - a.Uid = uint32(s.Uid) - a.Gid = uint32(s.Gid) - a.Rdev = uint32(s.Rdev) - a.Blksize = uint32(s.Blksize) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go b/vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go deleted file mode 100644 index 7ed06c16..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/bufferpool.go +++ /dev/null @@ -1,95 +0,0 @@ -package fuse - -import ( - "sync" -) - -var paranoia bool - -// BufferPool implements explicit memory management. It is used for -// minimizing the GC overhead of communicating with the kernel. -type BufferPool interface { - // AllocBuffer creates a buffer of at least the given size. After use, - // it should be deallocated with FreeBuffer(). - AllocBuffer(size uint32) []byte - - // FreeBuffer takes back a buffer if it was allocated through - // AllocBuffer. It is not an error to call FreeBuffer() on a slice - // obtained elsewhere. - FreeBuffer(slice []byte) -} - -type gcBufferPool struct { -} - -// NewGcBufferPool is a fallback to the standard allocation routines. -func NewGcBufferPool() BufferPool { - return &gcBufferPool{} -} - -func (p *gcBufferPool) AllocBuffer(size uint32) []byte { - return make([]byte, size) -} - -func (p *gcBufferPool) FreeBuffer(slice []byte) { -} - -type bufferPoolImpl struct { - lock sync.Mutex - - // For each page size multiple a list of slice pointers. - buffersBySize []*sync.Pool -} - -// NewBufferPool returns a BufferPool implementation that that returns -// slices with capacity of a multiple of PAGESIZE, which have possibly -// been used, and may contain random contents. When using -// NewBufferPool, file system handlers may not hang on to passed-in -// buffers beyond the handler's return. -func NewBufferPool() BufferPool { - bp := new(bufferPoolImpl) - return bp -} - -func (p *bufferPoolImpl) getPool(pageCount int) *sync.Pool { - p.lock.Lock() - for len(p.buffersBySize) < pageCount+1 { - p.buffersBySize = append(p.buffersBySize, nil) - } - if p.buffersBySize[pageCount] == nil { - p.buffersBySize[pageCount] = &sync.Pool{ - New: func() interface{} { return make([]byte, PAGESIZE*pageCount) }, - } - } - pool := p.buffersBySize[pageCount] - p.lock.Unlock() - return pool -} - -func (p *bufferPoolImpl) AllocBuffer(size uint32) []byte { - sz := int(size) - if sz < PAGESIZE { - sz = PAGESIZE - } - - if sz%PAGESIZE != 0 { - sz += PAGESIZE - } - pages := sz / PAGESIZE - - b := p.getPool(pages).Get().([]byte) - return b[:size] -} - -func (p *bufferPoolImpl) FreeBuffer(slice []byte) { - if slice == nil { - return - } - if cap(slice)%PAGESIZE != 0 || cap(slice) == 0 { - return - } - pages := cap(slice) / PAGESIZE - slice = slice[:cap(slice)] - - p.getPool(pages).Put(slice) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/constants.go b/vendor/github.com/hanwen/go-fuse/fuse/constants.go deleted file mode 100644 index 5aeaf1f3..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/constants.go +++ /dev/null @@ -1,31 +0,0 @@ -package fuse - -import ( - "os" - "syscall" -) - -const ( - FUSE_ROOT_ID = 1 - - FUSE_UNKNOWN_INO = 0xffffffff - - CUSE_UNRESTRICTED_IOCTL = (1 << 0) - - FUSE_LK_FLOCK = (1 << 0) - - FUSE_IOCTL_MAX_IOV = 256 - - FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0) - - CUSE_INIT_INFO_MAX = 4096 - - S_IFDIR = syscall.S_IFDIR - S_IFREG = syscall.S_IFREG - S_IFLNK = syscall.S_IFLNK - S_IFIFO = syscall.S_IFIFO - - CUSE_INIT = 4096 - - O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC) -) diff --git a/vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go b/vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go deleted file mode 100644 index ae8233a8..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/constants_freebsd.go +++ /dev/null @@ -1,5 +0,0 @@ -package fuse - -// arbitrary values -const syscall_O_LARGEFILE = 1 << 29 -const syscall_O_NOATIME = 1 << 30 diff --git a/vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go deleted file mode 100644 index 6c516762..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/constants_linux.go +++ /dev/null @@ -1,8 +0,0 @@ -package fuse - -import ( - "syscall" -) - -const syscall_O_LARGEFILE = syscall.O_LARGEFILE -const syscall_O_NOATIME = syscall.O_NOATIME diff --git a/vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go b/vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go deleted file mode 100644 index 8fc71cf6..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/defaultraw.go +++ /dev/null @@ -1,148 +0,0 @@ -package fuse - -import ( - "os" -) - -// NewDefaultRawFileSystem returns ENOSYS (not implemented) for all -// operations. -func NewDefaultRawFileSystem() RawFileSystem { - return (*defaultRawFileSystem)(nil) -} - -type defaultRawFileSystem struct{} - -func (fs *defaultRawFileSystem) Init(*Server) { -} - -func (fs *defaultRawFileSystem) String() string { - return os.Args[0] -} - -func (fs *defaultRawFileSystem) SetDebug(dbg bool) { -} - -func (fs *defaultRawFileSystem) StatFs(header *InHeader, out *StatfsOut) Status { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Lookup(header *InHeader, name string, out *EntryOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Forget(nodeID, nlookup uint64) { -} - -func (fs *defaultRawFileSystem) GetAttr(input *GetAttrIn, out *AttrOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Open(input *OpenIn, out *OpenOut) (status Status) { - return OK -} - -func (fs *defaultRawFileSystem) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { - return nil, ENOSYS -} - -func (fs *defaultRawFileSystem) Mknod(input *MknodIn, name string, out *EntryOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Unlink(header *InHeader, name string) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Rename(input *RenameIn, oldName string, newName string) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Link(input *LinkIn, name string, out *EntryOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) GetXAttrSize(header *InHeader, attr string) (size int, code Status) { - return 0, ENOSYS -} - -func (fs *defaultRawFileSystem) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { - return nil, ENOSYS -} - -func (fs *defaultRawFileSystem) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status { - return ENOSYS -} - -func (fs *defaultRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { - return nil, ENOSYS -} - -func (fs *defaultRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Access(input *AccessIn) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Create(input *CreateIn, name string, out *CreateOut) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) OpenDir(input *OpenIn, out *OpenOut) (status Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Read(input *ReadIn, buf []byte) (ReadResult, Status) { - return nil, ENOSYS -} - -func (fs *defaultRawFileSystem) Release(input *ReleaseIn) { -} - -func (fs *defaultRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { - return 0, ENOSYS -} - -func (fs *defaultRawFileSystem) Flush(input *FlushIn) Status { - return OK -} - -func (fs *defaultRawFileSystem) Fsync(input *FsyncIn) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) ReadDir(input *ReadIn, l *DirEntryList) Status { - return ENOSYS -} - -func (fs *defaultRawFileSystem) ReadDirPlus(input *ReadIn, l *DirEntryList) Status { - return ENOSYS -} - -func (fs *defaultRawFileSystem) ReleaseDir(input *ReleaseIn) { -} - -func (fs *defaultRawFileSystem) FsyncDir(input *FsyncIn) (code Status) { - return ENOSYS -} - -func (fs *defaultRawFileSystem) Fallocate(in *FallocateIn) (code Status) { - return ENOSYS -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/direntry.go b/vendor/github.com/hanwen/go-fuse/fuse/direntry.go deleted file mode 100644 index 34fbacf5..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/direntry.go +++ /dev/null @@ -1,98 +0,0 @@ -package fuse - -// all of the code for DirEntryList. - -import ( - "fmt" - "unsafe" -) - -var eightPadding [8]byte - -const direntSize = int(unsafe.Sizeof(_Dirent{})) - -// DirEntry is a type for PathFileSystem and NodeFileSystem to return -// directory contents in. -type DirEntry struct { - // Mode is the file's mode. Only the high bits (eg. S_IFDIR) - // are considered. - Mode uint32 - - // Name is the basename of the file in the directory. - Name string -} - -func (d DirEntry) String() string { - return fmt.Sprintf("%o: %q", d.Mode, d.Name) -} - -// DirEntryList holds the return value for READDIR and READDIRPLUS -// opcodes. -type DirEntryList struct { - buf []byte - size int - offset uint64 -} - -// NewDirEntryList creates a DirEntryList with the given data buffer -// and offset. -func NewDirEntryList(data []byte, off uint64) *DirEntryList { - return &DirEntryList{ - buf: data[:0], - size: len(data), - offset: off, - } -} - -// AddDirEntry tries to add an entry, and reports whether it -// succeeded. -func (l *DirEntryList) AddDirEntry(e DirEntry) (bool, uint64) { - return l.Add(0, e.Name, uint64(FUSE_UNKNOWN_INO), e.Mode) -} - -// Add adds a direntry to the DirEntryList, returning whether it -// succeeded. -func (l *DirEntryList) Add(prefix int, name string, inode uint64, mode uint32) (bool, uint64) { - padding := (8 - len(name)&7) & 7 - delta := padding + direntSize + len(name) + prefix - oldLen := len(l.buf) - newLen := delta + oldLen - - if newLen > l.size { - return false, l.offset - } - l.buf = l.buf[:newLen] - oldLen += prefix - dirent := (*_Dirent)(unsafe.Pointer(&l.buf[oldLen])) - dirent.Off = l.offset + 1 - dirent.Ino = inode - dirent.NameLen = uint32(len(name)) - dirent.Typ = (mode & 0170000) >> 12 - oldLen += direntSize - copy(l.buf[oldLen:], name) - oldLen += len(name) - - if padding > 0 { - copy(l.buf[oldLen:], eightPadding[:padding]) - } - - l.offset = dirent.Off - return true, l.offset -} - -// AddDirLookupEntry is used for ReadDirPlus. It serializes a DirEntry -// and returns the space for entry. If no space is left, returns a nil -// pointer. -func (l *DirEntryList) AddDirLookupEntry(e DirEntry) (*EntryOut, uint64) { - lastStart := len(l.buf) - ok, off := l.Add(int(unsafe.Sizeof(EntryOut{})), e.Name, - uint64(FUSE_UNKNOWN_INO), e.Mode) - if !ok { - return nil, off - } - return (*EntryOut)(unsafe.Pointer(&l.buf[lastStart])), off -} - -func (l *DirEntryList) bytes() []byte { - return l.buf -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go b/vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go deleted file mode 100644 index 2c3bd8d3..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/lockingfs.go +++ /dev/null @@ -1,206 +0,0 @@ -package fuse - -import ( - "fmt" - "sync" -) - -//////////////////////////////////////////////////////////////// -// Locking raw FS. - -type lockingRawFileSystem struct { - RawFS RawFileSystem - lock sync.Mutex -} - -// Returns a Wrap -func NewLockingRawFileSystem(fs RawFileSystem) RawFileSystem { - return &lockingRawFileSystem{ - RawFS: fs, - } -} - -func (fs *lockingRawFileSystem) FS() RawFileSystem { - return fs.RawFS -} - -func (fs *lockingRawFileSystem) locked() func() { - fs.lock.Lock() - return func() { fs.lock.Unlock() } -} - -func (fs *lockingRawFileSystem) Lookup(header *InHeader, name string, out *EntryOut) (code Status) { - defer fs.locked()() - return fs.RawFS.Lookup(header, name, out) -} - -func (fs *lockingRawFileSystem) SetDebug(dbg bool) { - defer fs.locked()() - fs.RawFS.SetDebug(dbg) -} - -func (fs *lockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) { - defer fs.locked()() - fs.RawFS.Forget(nodeID, nlookup) -} - -func (fs *lockingRawFileSystem) GetAttr(input *GetAttrIn, out *AttrOut) (code Status) { - defer fs.locked()() - return fs.RawFS.GetAttr(input, out) -} - -func (fs *lockingRawFileSystem) Open(input *OpenIn, out *OpenOut) (status Status) { - - defer fs.locked()() - return fs.RawFS.Open(input, out) -} - -func (fs *lockingRawFileSystem) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) { - defer fs.locked()() - return fs.RawFS.SetAttr(input, out) -} - -func (fs *lockingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { - defer fs.locked()() - return fs.RawFS.Readlink(header) -} - -func (fs *lockingRawFileSystem) Mknod(input *MknodIn, name string, out *EntryOut) (code Status) { - defer fs.locked()() - return fs.RawFS.Mknod(input, name, out) -} - -func (fs *lockingRawFileSystem) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) { - defer fs.locked()() - return fs.RawFS.Mkdir(input, name, out) -} - -func (fs *lockingRawFileSystem) Unlink(header *InHeader, name string) (code Status) { - defer fs.locked()() - return fs.RawFS.Unlink(header, name) -} - -func (fs *lockingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { - defer fs.locked()() - return fs.RawFS.Rmdir(header, name) -} - -func (fs *lockingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) { - defer fs.locked()() - return fs.RawFS.Symlink(header, pointedTo, linkName, out) -} - -func (fs *lockingRawFileSystem) Rename(input *RenameIn, oldName string, newName string) (code Status) { - defer fs.locked()() - return fs.RawFS.Rename(input, oldName, newName) -} - -func (fs *lockingRawFileSystem) Link(input *LinkIn, name string, out *EntryOut) (code Status) { - defer fs.locked()() - return fs.RawFS.Link(input, name, out) -} - -func (fs *lockingRawFileSystem) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status { - defer fs.locked()() - return fs.RawFS.SetXAttr(input, attr, data) -} - -func (fs *lockingRawFileSystem) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { - defer fs.locked()() - return fs.RawFS.GetXAttrData(header, attr) -} - -func (fs *lockingRawFileSystem) GetXAttrSize(header *InHeader, attr string) (sz int, code Status) { - defer fs.locked()() - return fs.RawFS.GetXAttrSize(header, attr) -} - -func (fs *lockingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { - defer fs.locked()() - return fs.RawFS.ListXAttr(header) -} - -func (fs *lockingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { - defer fs.locked()() - return fs.RawFS.RemoveXAttr(header, attr) -} - -func (fs *lockingRawFileSystem) Access(input *AccessIn) (code Status) { - defer fs.locked()() - return fs.RawFS.Access(input) -} - -func (fs *lockingRawFileSystem) Create(input *CreateIn, name string, out *CreateOut) (code Status) { - defer fs.locked()() - return fs.RawFS.Create(input, name, out) -} - -func (fs *lockingRawFileSystem) OpenDir(input *OpenIn, out *OpenOut) (status Status) { - defer fs.locked()() - return fs.RawFS.OpenDir(input, out) -} - -func (fs *lockingRawFileSystem) Release(input *ReleaseIn) { - defer fs.locked()() - fs.RawFS.Release(input) -} - -func (fs *lockingRawFileSystem) ReleaseDir(input *ReleaseIn) { - defer fs.locked()() - fs.RawFS.ReleaseDir(input) -} - -func (fs *lockingRawFileSystem) Read(input *ReadIn, buf []byte) (ReadResult, Status) { - defer fs.locked()() - return fs.RawFS.Read(input, buf) -} - -func (fs *lockingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { - defer fs.locked()() - return fs.RawFS.Write(input, data) -} - -func (fs *lockingRawFileSystem) Flush(input *FlushIn) Status { - defer fs.locked()() - return fs.RawFS.Flush(input) -} - -func (fs *lockingRawFileSystem) Fsync(input *FsyncIn) (code Status) { - defer fs.locked()() - return fs.RawFS.Fsync(input) -} - -func (fs *lockingRawFileSystem) ReadDir(input *ReadIn, out *DirEntryList) Status { - defer fs.locked()() - return fs.RawFS.ReadDir(input, out) -} - -func (fs *lockingRawFileSystem) ReadDirPlus(input *ReadIn, out *DirEntryList) Status { - defer fs.locked()() - return fs.RawFS.ReadDirPlus(input, out) -} - -func (fs *lockingRawFileSystem) FsyncDir(input *FsyncIn) (code Status) { - defer fs.locked()() - return fs.RawFS.FsyncDir(input) -} - -func (fs *lockingRawFileSystem) Init(s *Server) { - defer fs.locked()() - fs.RawFS.Init(s) -} - -func (fs *lockingRawFileSystem) StatFs(header *InHeader, out *StatfsOut) (code Status) { - defer fs.locked()() - return fs.RawFS.StatFs(header, out) -} - -func (fs *lockingRawFileSystem) Fallocate(in *FallocateIn) (code Status) { - defer fs.locked()() - return fs.RawFS.Fallocate(in) -} - -func (fs *lockingRawFileSystem) String() string { - defer fs.locked()() - return fmt.Sprintf("Locked(%s)", fs.RawFS.String()) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/misc.go b/vendor/github.com/hanwen/go-fuse/fuse/misc.go deleted file mode 100644 index 4e2879b8..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/misc.go +++ /dev/null @@ -1,84 +0,0 @@ -// Random odds and ends. - -package fuse - -import ( - "fmt" - "log" - "os" - "reflect" - "syscall" - "unsafe" -) - -func (code Status) String() string { - if code <= 0 { - return []string{ - "OK", - "NOTIFY_POLL", - "NOTIFY_INVAL_INODE", - "NOTIFY_INVAL_ENTRY", - "NOTIFY_INVAL_STORE", - "NOTIFY_INVAL_RETRIEVE", - "NOTIFY_INVAL_DELETE", - }[-code] - } - return fmt.Sprintf("%d=%v", int(code), syscall.Errno(code)) -} - -func (code Status) Ok() bool { - return code == OK -} - -// ToStatus extracts an errno number from Go error objects. If it -// fails, it logs an error and returns ENOSYS. -func ToStatus(err error) Status { - switch err { - case nil: - return OK - case os.ErrPermission: - return EPERM - case os.ErrExist: - return Status(syscall.EEXIST) - case os.ErrNotExist: - return ENOENT - case os.ErrInvalid: - return EINVAL - } - - switch t := err.(type) { - case syscall.Errno: - return Status(t) - case *os.SyscallError: - return Status(t.Err.(syscall.Errno)) - case *os.PathError: - return ToStatus(t.Err) - case *os.LinkError: - return ToStatus(t.Err) - } - log.Println("can't convert error type:", err) - return ENOSYS -} - -func toSlice(dest *[]byte, ptr unsafe.Pointer, byteCount uintptr) { - h := (*reflect.SliceHeader)(unsafe.Pointer(dest)) - *h = reflect.SliceHeader{ - Data: uintptr(ptr), - Len: int(byteCount), - Cap: int(byteCount), - } -} - -func CurrentOwner() *Owner { - return &Owner{ - Uid: uint32(os.Getuid()), - Gid: uint32(os.Getgid()), - } -} - -func init() { - p := syscall.Getpagesize() - if p != PAGESIZE { - log.Panicf("page size incorrect: %d", p) - } -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go deleted file mode 100644 index ceee372a..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/mount_darwin.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// TODO: Rewrite using package syscall not cgo - -package fuse - -/* - -// 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. - -#include -#include -#include -#include -#include -#include -#include -#include - -#define nil ((void*)0) - -static int -mountfuse(char *mtpt, char **err) -{ - int i, pid, fd, r; - char buf[200]; - struct vfsconf vfs; - char *f; - - if(getvfsbyname("osxfusefs", &vfs) < 0){ - if(access(f="/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", 0) < 0){ - *err = strdup("cannot find load_fusefs"); - return -1; - } - if((r=system(f)) < 0){ - snprintf(buf, sizeof buf, "%s: %s", f, strerror(errno)); - *err = strdup(buf); - return -1; - } - if(r != 0){ - snprintf(buf, sizeof buf, "load_fusefs failed: exit %d", r); - *err = strdup(buf); - return -1; - } - if(getvfsbyname("osxfusefs", &vfs) < 0){ - snprintf(buf, sizeof buf, "getvfsbyname osxfusefs: %s", strerror(errno)); - *err = strdup(buf); - return -1; - } - } - - // Look for available FUSE device. - for(i=0;; i++){ - snprintf(buf, sizeof buf, "/dev/osxfuse%d", i); - if(access(buf, 0) < 0){ - *err = strdup("no available fuse devices"); - return -1; - } - if((fd = open(buf, O_RDWR)) >= 0) - break; - } - - pid = fork(); - if(pid < 0) - return -1; - if(pid == 0){ - snprintf(buf, sizeof buf, "%d", fd); - setenv("MOUNT_FUSEFS_CALL_BY_LIB", "", 1); - // Different versions of MacFUSE put the - // mount_fusefs binary in different places. - // Try all. - // Leopard location - setenv("MOUNT_FUSEFS_DAEMON_PATH", "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", 1); - execl("/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", "mount_osxfusefs", "-o", "iosize=4096", buf, mtpt, nil); - fprintf(stderr, "exec mount_osxfusefs: %s\n", strerror(errno)); - _exit(1); - } - return fd; -} - -*/ -import "C" -import ( - "fmt" - "log" - "os/exec" - "syscall" - "unsafe" -) - -func mount(dir string, options string) (int, error) { - errp := (**C.char)(C.malloc(16)) - *errp = nil - defer C.free(unsafe.Pointer(errp)) - cdir := C.CString(dir) - defer C.free(unsafe.Pointer(cdir)) - fd := C.mountfuse(cdir, errp) - if *errp != nil { - return -1, mountError(C.GoString(*errp)) - } - return int(fd), nil -} - -type mountError string - -func (m mountError) Error() string { - return string(m) -} - -func unmount(mountPoint string) error { - if err := syscall.Unmount(mountPoint, 0); err != nil { - return fmt.Errorf("umount(%q): %v", mountPoint, err) - } - return nil -} - -var umountBinary string - -func init() { - var err error - umountBinary, err = exec.LookPath("umount") - if err != nil { - log.Fatalf("Could not find umount binary: %v", err) - } -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go deleted file mode 100644 index a33bb38a..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/mount_linux.go +++ /dev/null @@ -1,152 +0,0 @@ -package fuse - -import ( - "bytes" - "fmt" - "os" - "os/exec" - "path" - "path/filepath" - "syscall" - "unsafe" -) - -func unixgramSocketpair() (l, r *os.File, err error) { - fd, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_SEQPACKET, 0) - if err != nil { - return nil, nil, os.NewSyscallError("socketpair", - err.(syscall.Errno)) - } - l = os.NewFile(uintptr(fd[0]), "socketpair-half1") - r = os.NewFile(uintptr(fd[1]), "socketpair-half2") - return -} - -// Create a FUSE FS on the specified mount point. The returned -// mount point is always absolute. -func mount(mountPoint string, options string) (fd int, err error) { - local, remote, err := unixgramSocketpair() - if err != nil { - return - } - - defer local.Close() - defer remote.Close() - - bin, err := fusermountBinary() - if err != nil { - return 0, err - } - - cmd := []string{bin, mountPoint} - if options != "" { - cmd = append(cmd, "-o") - cmd = append(cmd, options) - } - proc, err := os.StartProcess(bin, - cmd, - &os.ProcAttr{ - Env: []string{"_FUSE_COMMFD=3"}, - Files: []*os.File{os.Stdin, os.Stdout, os.Stderr, remote}}) - - if err != nil { - return - } - - w, err := proc.Wait() - if err != nil { - return - } - if !w.Success() { - err = fmt.Errorf("fusermount exited with code %v\n", w.Sys()) - return - } - - return getConnection(local) -} - -func privilegedUnmount(mountPoint string) error { - dir, _ := filepath.Split(mountPoint) - bin, err := umountBinary() - if err != nil { - return err - } - - proc, err := os.StartProcess(bin, - []string{bin, mountPoint}, - &os.ProcAttr{Dir: dir, Files: []*os.File{nil, nil, os.Stderr}}) - if err != nil { - return err - } - w, err := proc.Wait() - if !w.Success() { - return fmt.Errorf("umount exited with code %v\n", w.Sys()) - } - return err -} - -func unmount(mountPoint string) (err error) { - if os.Geteuid() == 0 { - return privilegedUnmount(mountPoint) - } - bin, err := fusermountBinary() - if err != nil { - return err - } - errBuf := bytes.Buffer{} - cmd := exec.Command(bin, "-u", mountPoint) - cmd.Stderr = &errBuf - err = cmd.Run() - if errBuf.Len() > 0 { - return fmt.Errorf("%s (code %v)\n", - errBuf.String(), err) - } - return err -} - -func getConnection(local *os.File) (int, error) { - var data [4]byte - control := make([]byte, 4*256) - - // n, oobn, recvflags, from, errno - todo: error checking. - _, oobn, _, _, - err := syscall.Recvmsg( - int(local.Fd()), data[:], control[:], 0) - if err != nil { - return 0, err - } - - message := *(*syscall.Cmsghdr)(unsafe.Pointer(&control[0])) - fd := *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&control[0])) + syscall.SizeofCmsghdr)) - - if message.Type != 1 { - return 0, fmt.Errorf("getConnection: recvmsg returned wrong control type: %d", message.Type) - } - if oobn <= syscall.SizeofCmsghdr { - return 0, fmt.Errorf("getConnection: too short control message. Length: %d", oobn) - } - if fd < 0 { - return 0, fmt.Errorf("getConnection: fd < 0: %d", fd) - } - return int(fd), nil -} - -// lookPathFallback - search binary in PATH and, if that fails, -// in fallbackDir. This is useful if PATH is possible empty. -func lookPathFallback(file string, fallbackDir string) (string, error) { - binPath, err := exec.LookPath(file) - if err == nil { - return binPath, nil - } - - abs := path.Join(fallbackDir, file) - return exec.LookPath(abs) -} - -func fusermountBinary() (string, error) { - return lookPathFallback("fusermount", "/bin") -} - -func umountBinary() (string, error) { - return lookPathFallback("umount", "/bin") -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go deleted file mode 100644 index 05148256..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/api.go +++ /dev/null @@ -1,181 +0,0 @@ -// The nodefs package offers a high level API that resembles the -// kernel's idea of what an FS looks like. File systems can have -// multiple hard-links to one file, for example. It is also suited if -// the data to represent fits in memory: you can construct the -// complete file system tree at mount time -package nodefs - -import ( - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -// The Node interface implements the user-defined file system -// functionality -type Node interface { - // Inode and SetInode are basic getter/setters. They are - // called by the FileSystemConnector. You get them for free by - // embedding the result of NewDefaultNode() in your node - // struct. - Inode() *Inode - SetInode(node *Inode) - - // OnMount is called on the root node just after a mount is - // executed, either when the actual root is mounted, or when a - // filesystem is mounted in-process. The passed-in - // FileSystemConnector gives access to Notify methods and - // Debug settings. - OnMount(conn *FileSystemConnector) - - // OnUnmount is executed just before a submount is removed, - // and when the process receives a forget for the FUSE root - // node. - OnUnmount() - - // Lookup finds a child node to this node; it is only called - // for directory Nodes. - Lookup(out *fuse.Attr, name string, context *fuse.Context) (*Inode, fuse.Status) - - // Deletable() should return true if this node may be discarded once - // the kernel forgets its reference. - // If it returns false, OnForget will never get called for this node. This - // is appropriate if the filesystem has no persistent backing store - // (in-memory filesystems) where discarding the node loses the stored data. - // Deletable will be called from within the treeLock critical section, so you - // cannot look at other nodes. - Deletable() bool - - // OnForget is called when the kernel forgets its reference to this node and - // sends a FORGET request. It should perform cleanup and free memory as - // appropriate for the filesystem. - // OnForget is not called if the node is a directory and has children. - // This is called from within a treeLock critical section. - OnForget() - - // Misc. - Access(mode uint32, context *fuse.Context) (code fuse.Status) - Readlink(c *fuse.Context) ([]byte, fuse.Status) - - // Namespace operations; these are only called on directory Nodes. - - // Mknod should create the node, add it to the receiver's - // inode, and return it - Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) - - // Mkdir should create the directory Inode, add it to the - // receiver's Inode, and return it - Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) - Unlink(name string, context *fuse.Context) (code fuse.Status) - Rmdir(name string, context *fuse.Context) (code fuse.Status) - - // Symlink should create a child inode to the receiver, and - // return it. - Symlink(name string, content string, context *fuse.Context) (*Inode, fuse.Status) - Rename(oldName string, newParent Node, newName string, context *fuse.Context) (code fuse.Status) - - // Link should return the Inode of the resulting link. In - // a POSIX conformant file system, this should add 'existing' - // to the receiver, and return the Inode corresponding to - // 'existing'. - Link(name string, existing Node, context *fuse.Context) (newNode *Inode, code fuse.Status) - - // Create should return an open file, and the Inode for that file. - Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, child *Inode, code fuse.Status) - - // Open opens a file, and returns a File which is associated - // with a file handle. It is OK to return (nil, OK) here. In - // that case, the Node should implement Read or Write - // directly. - Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) - OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) - Read(file File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) - Write(file File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) - - // XAttrs - GetXAttr(attribute string, context *fuse.Context) (data []byte, code fuse.Status) - RemoveXAttr(attr string, context *fuse.Context) fuse.Status - SetXAttr(attr string, data []byte, flags int, context *fuse.Context) fuse.Status - ListXAttr(context *fuse.Context) (attrs []string, code fuse.Status) - - // Attributes - GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) - Chmod(file File, perms uint32, context *fuse.Context) (code fuse.Status) - Chown(file File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) - Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) - Utimens(file File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) - Fallocate(file File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) - - StatFs() *fuse.StatfsOut -} - -// A File object is returned from FileSystem.Open and -// FileSystem.Create. Include the NewDefaultFile return value into -// the struct to inherit a null implementation. -type File interface { - // Called upon registering the filehandle in the inode. - SetInode(*Inode) - - // The String method is for debug printing. - String() string - - // Wrappers around other File implementations, should return - // the inner file here. - InnerFile() File - - Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) - Write(data []byte, off int64) (written uint32, code fuse.Status) - - // Flush is called for close() call on a file descriptor. In - // case of duplicated descriptor, it may be called more than - // once for a file. - Flush() fuse.Status - - // This is called to before the file handle is forgotten. This - // method has no return value, so nothing can synchronizes on - // the call. Any cleanup that requires specific synchronization or - // could fail with I/O errors should happen in Flush instead. - Release() - Fsync(flags int) (code fuse.Status) - - // The methods below may be called on closed files, due to - // concurrency. In that case, you should return EBADF. - Truncate(size uint64) fuse.Status - GetAttr(out *fuse.Attr) fuse.Status - Chown(uid uint32, gid uint32) fuse.Status - Chmod(perms uint32) fuse.Status - Utimens(atime *time.Time, mtime *time.Time) fuse.Status - Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) -} - -// Wrap a File return in this to set FUSE flags. Also used internally -// to store open file data. -type WithFlags struct { - File - - // For debugging. - Description string - - // Put FOPEN_* flags here. - FuseFlags uint32 - - // O_RDWR, O_TRUNCATE, etc. - OpenFlags uint32 -} - -// Options contains time out options for a node FileSystem. The -// default copied from libfuse and set in NewMountOptions() is -// (1s,1s,0s). -type Options struct { - EntryTimeout time.Duration - AttrTimeout time.Duration - NegativeTimeout time.Duration - - // If set, replace all uids with given UID. - // NewFileSystemOptions() will set this to the daemon's - // uid/gid. - *fuse.Owner - - // This option exists for compatibility and is ignored. - PortableInodes bool -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go deleted file mode 100644 index c3b0b127..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultfile.go +++ /dev/null @@ -1,70 +0,0 @@ -package nodefs - -import ( - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -type defaultFile struct{} - -// NewDefaultFile returns a File instance that returns ENOSYS for -// every operation. -func NewDefaultFile() File { - return (*defaultFile)(nil) -} - -func (f *defaultFile) SetInode(*Inode) { -} - -func (f *defaultFile) InnerFile() File { - return nil -} - -func (f *defaultFile) String() string { - return "defaultFile" -} - -func (f *defaultFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { - return nil, fuse.ENOSYS -} - -func (f *defaultFile) Write(data []byte, off int64) (uint32, fuse.Status) { - return 0, fuse.ENOSYS -} - -func (f *defaultFile) Flush() fuse.Status { - return fuse.OK -} - -func (f *defaultFile) Release() { - -} - -func (f *defaultFile) GetAttr(*fuse.Attr) fuse.Status { - return fuse.ENOSYS -} - -func (f *defaultFile) Fsync(flags int) (code fuse.Status) { - return fuse.ENOSYS -} - -func (f *defaultFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { - return fuse.ENOSYS -} - -func (f *defaultFile) Truncate(size uint64) fuse.Status { - return fuse.ENOSYS -} - -func (f *defaultFile) Chown(uid uint32, gid uint32) fuse.Status { - return fuse.ENOSYS -} - -func (f *defaultFile) Chmod(perms uint32) fuse.Status { - return fuse.ENOSYS -} - -func (f *defaultFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { - return fuse.ENOSYS -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go deleted file mode 100644 index f4474dd5..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/defaultnode.go +++ /dev/null @@ -1,165 +0,0 @@ -package nodefs - -import ( - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -// NewDefaultNode returns an implementation of Node that returns -// ENOSYS for all operations. -func NewDefaultNode() Node { - return &defaultNode{} -} - -type defaultNode struct { - inode *Inode -} - -func (fs *defaultNode) OnUnmount() { -} - -func (fs *defaultNode) OnMount(conn *FileSystemConnector) { -} - -func (n *defaultNode) StatFs() *fuse.StatfsOut { - return nil -} - -func (n *defaultNode) SetInode(node *Inode) { - n.inode = node -} - -func (n *defaultNode) Deletable() bool { - return true -} - -func (n *defaultNode) Inode() *Inode { - return n.inode -} - -func (n *defaultNode) OnForget() { -} - -func (n *defaultNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (node *Inode, code fuse.Status) { - return nil, fuse.ENOENT -} - -func (n *defaultNode) Access(mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Readlink(c *fuse.Context) ([]byte, fuse.Status) { - return nil, fuse.ENOSYS -} - -func (n *defaultNode) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) { - return nil, fuse.ENOSYS -} -func (n *defaultNode) Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) { - return nil, fuse.ENOSYS -} -func (n *defaultNode) Unlink(name string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} -func (n *defaultNode) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} -func (n *defaultNode) Symlink(name string, content string, context *fuse.Context) (newNode *Inode, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (n *defaultNode) Rename(oldName string, newParent Node, newName string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Link(name string, existing Node, context *fuse.Context) (newNode *Inode, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (n *defaultNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, newNode *Inode, code fuse.Status) { - return nil, nil, fuse.ENOSYS -} - -func (n *defaultNode) Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (n *defaultNode) Flush(file File, openFlags uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { - ch := n.Inode().Children() - s := make([]fuse.DirEntry, 0, len(ch)) - for name, child := range ch { - if child.mountPoint != nil { - continue - } - var a fuse.Attr - code := child.Node().GetAttr(&a, nil, context) - if code.Ok() { - s = append(s, fuse.DirEntry{Name: name, Mode: a.Mode}) - } - } - return s, fuse.OK -} - -func (n *defaultNode) GetXAttr(attribute string, context *fuse.Context) (data []byte, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (n *defaultNode) RemoveXAttr(attr string, context *fuse.Context) fuse.Status { - return fuse.ENOSYS -} - -func (n *defaultNode) SetXAttr(attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - return fuse.ENOSYS -} - -func (n *defaultNode) ListXAttr(context *fuse.Context) (attrs []string, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (n *defaultNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) { - if n.Inode().IsDir() { - out.Mode = fuse.S_IFDIR | 0755 - } else { - out.Mode = fuse.S_IFREG | 0644 - } - return fuse.OK -} - -func (n *defaultNode) Chmod(file File, perms uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Chown(file File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Utimens(file File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Fallocate(file File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (n *defaultNode) Read(file File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) { - if file != nil { - return file.Read(dest, off) - } - return nil, fuse.ENOSYS -} - -func (n *defaultNode) Write(file File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { - if file != nil { - return file.Write(data, off) - } - return 0, fuse.ENOSYS -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go deleted file mode 100644 index 2f12fb19..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/dir.go +++ /dev/null @@ -1,114 +0,0 @@ -package nodefs - -import ( - "log" - "sync" - - "github.com/hanwen/go-fuse/fuse" -) - -type connectorDir struct { - node Node - rawFS fuse.RawFileSystem - - // Protect stream and lastOffset. These are written in case - // there is a seek on the directory. - mu sync.Mutex - stream []fuse.DirEntry - - // lastOffset stores the last offset for a readdir. This lets - // readdir pick up changes to the directory made after opening - // it. - lastOffset uint64 -} - -func (d *connectorDir) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) (code fuse.Status) { - d.mu.Lock() - defer d.mu.Unlock() - - if d.stream == nil { - return fuse.OK - } - // rewinddir() should be as if reopening directory. - // TODO - test this. - if d.lastOffset > 0 && input.Offset == 0 { - d.stream, code = d.node.OpenDir((*fuse.Context)(&input.Context)) - if !code.Ok() { - return code - } - } - - if input.Offset > uint64(len(d.stream)) { - // This shouldn't happen, but let's not crash. - return fuse.EINVAL - } - - todo := d.stream[input.Offset:] - for _, e := range todo { - if e.Name == "" { - log.Printf("got empty directory entry, mode %o.", e.Mode) - continue - } - ok, off := out.AddDirEntry(e) - d.lastOffset = off - if !ok { - break - } - } - return fuse.OK -} - -func (d *connectorDir) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) (code fuse.Status) { - d.mu.Lock() - defer d.mu.Unlock() - - if d.stream == nil { - return fuse.OK - } - - // rewinddir() should be as if reopening directory. - if d.lastOffset > 0 && input.Offset == 0 { - d.stream, code = d.node.OpenDir((*fuse.Context)(&input.Context)) - if !code.Ok() { - return code - } - } - - if input.Offset > uint64(len(d.stream)) { - // This shouldn't happen, but let's not crash. - return fuse.EINVAL - } - todo := d.stream[input.Offset:] - for _, e := range todo { - if e.Name == "" { - log.Printf("got empty directory entry, mode %o.", e.Mode) - continue - } - - // we have to be sure entry will fit if we try to add - // it, or we'll mess up the lookup counts. - entryDest, off := out.AddDirLookupEntry(e) - if entryDest == nil { - break - } - entryDest.Ino = uint64(fuse.FUSE_UNKNOWN_INO) - - // No need to fill attributes for . and .. - if e.Name == "." || e.Name == ".." { - continue - } - - // Clear entryDest before use it, some fields can be corrupted if does not set all fields in rawFS.Lookup - *entryDest = fuse.EntryOut{} - - d.rawFS.Lookup(&input.InHeader, e.Name, entryDest) - d.lastOffset = off - } - return fuse.OK - -} - -type rawDir interface { - ReadDir(out *fuse.DirEntryList, input *fuse.ReadIn, c *fuse.Context) fuse.Status - ReadDirPlus(out *fuse.DirEntryList, input *fuse.ReadIn, c *fuse.Context) fuse.Status -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go deleted file mode 100644 index 004406b3..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files.go +++ /dev/null @@ -1,249 +0,0 @@ -package nodefs - -import ( - "fmt" - "os" - "sync" - "syscall" - - "github.com/hanwen/go-fuse/fuse" -) - -// DataFile is for implementing read-only filesystems. This -// assumes we already have the data in memory. -type dataFile struct { - data []byte - - File -} - -func (f *dataFile) String() string { - l := len(f.data) - if l > 10 { - l = 10 - } - - return fmt.Sprintf("dataFile(%x)", f.data[:l]) -} - -func (f *dataFile) GetAttr(out *fuse.Attr) fuse.Status { - out.Mode = fuse.S_IFREG | 0644 - out.Size = uint64(len(f.data)) - return fuse.OK -} - -func NewDataFile(data []byte) File { - f := new(dataFile) - f.data = data - f.File = NewDefaultFile() - return f -} - -func (f *dataFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { - end := int(off) + int(len(buf)) - if end > len(f.data) { - end = len(f.data) - } - - return fuse.ReadResultData(f.data[off:end]), fuse.OK -} - -type devNullFile struct { - File -} - -// NewDevNullFile returns a file that accepts any write, and always -// returns EOF for reads. -func NewDevNullFile() File { - return &devNullFile{ - File: NewDefaultFile(), - } -} - -func (f *devNullFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { - return fuse.OK -} - -func (f *devNullFile) String() string { - return "devNullFile" -} - -func (f *devNullFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { - return fuse.ReadResultData(nil), fuse.OK -} - -func (f *devNullFile) Write(content []byte, off int64) (uint32, fuse.Status) { - return uint32(len(content)), fuse.OK -} - -func (f *devNullFile) Flush() fuse.Status { - return fuse.OK -} - -func (f *devNullFile) Fsync(flags int) (code fuse.Status) { - return fuse.OK -} - -func (f *devNullFile) Truncate(size uint64) (code fuse.Status) { - return fuse.OK -} - -//////////////// - -// LoopbackFile delegates all operations back to an underlying os.File. -func NewLoopbackFile(f *os.File) File { - return &loopbackFile{File: f} -} - -type loopbackFile struct { - File *os.File - - // os.File is not threadsafe. Although fd themselves are - // constant during the lifetime of an open file, the OS may - // reuse the fd number after it is closed. When open races - // with another close, they may lead to confusion as which - // file gets written in the end. - lock sync.Mutex -} - -func (f *loopbackFile) InnerFile() File { - return nil -} - -func (f *loopbackFile) SetInode(n *Inode) { -} - -func (f *loopbackFile) String() string { - return fmt.Sprintf("loopbackFile(%s)", f.File.Name()) -} - -func (f *loopbackFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { - f.lock.Lock() - // This is not racy by virtue of the kernel properly - // synchronizing the open/write/close. - r := fuse.ReadResultFd(f.File.Fd(), off, len(buf)) - f.lock.Unlock() - return r, fuse.OK -} - -func (f *loopbackFile) Write(data []byte, off int64) (uint32, fuse.Status) { - f.lock.Lock() - n, err := f.File.WriteAt(data, off) - f.lock.Unlock() - return uint32(n), fuse.ToStatus(err) -} - -func (f *loopbackFile) Release() { - f.lock.Lock() - f.File.Close() - f.lock.Unlock() -} - -func (f *loopbackFile) Flush() fuse.Status { - f.lock.Lock() - - // Since Flush() may be called for each dup'd fd, we don't - // want to really close the file, we just want to flush. This - // is achieved by closing a dup'd fd. - newFd, err := syscall.Dup(int(f.File.Fd())) - f.lock.Unlock() - - if err != nil { - return fuse.ToStatus(err) - } - err = syscall.Close(newFd) - return fuse.ToStatus(err) -} - -func (f *loopbackFile) Fsync(flags int) (code fuse.Status) { - f.lock.Lock() - r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd()))) - f.lock.Unlock() - - return r -} - -func (f *loopbackFile) Truncate(size uint64) fuse.Status { - f.lock.Lock() - r := fuse.ToStatus(syscall.Ftruncate(int(f.File.Fd()), int64(size))) - f.lock.Unlock() - - return r -} - -func (f *loopbackFile) Chmod(mode uint32) fuse.Status { - f.lock.Lock() - r := fuse.ToStatus(f.File.Chmod(os.FileMode(mode))) - f.lock.Unlock() - - return r -} - -func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status { - f.lock.Lock() - r := fuse.ToStatus(f.File.Chown(int(uid), int(gid))) - f.lock.Unlock() - - return r -} - -func (f *loopbackFile) GetAttr(a *fuse.Attr) fuse.Status { - st := syscall.Stat_t{} - f.lock.Lock() - err := syscall.Fstat(int(f.File.Fd()), &st) - f.lock.Unlock() - if err != nil { - return fuse.ToStatus(err) - } - a.FromStat(&st) - - return fuse.OK -} - -// Utimens implemented in files_linux.go - -// Allocate implemented in files_linux.go - -//////////////////////////////////////////////////////////////// - -// NewReadOnlyFile wraps a File so all read/write operations are -// denied. -func NewReadOnlyFile(f File) File { - return &readOnlyFile{File: f} -} - -type readOnlyFile struct { - File -} - -func (f *readOnlyFile) InnerFile() File { - return f.File -} - -func (f *readOnlyFile) String() string { - return fmt.Sprintf("readOnlyFile(%s)", f.File.String()) -} - -func (f *readOnlyFile) Write(data []byte, off int64) (uint32, fuse.Status) { - return 0, fuse.EPERM -} - -func (f *readOnlyFile) Fsync(flag int) (code fuse.Status) { - return fuse.OK -} - -func (f *readOnlyFile) Truncate(size uint64) fuse.Status { - return fuse.EPERM -} - -func (f *readOnlyFile) Chmod(mode uint32) fuse.Status { - return fuse.EPERM -} - -func (f *readOnlyFile) Chown(uid uint32, gid uint32) fuse.Status { - return fuse.EPERM -} - -func (f *readOnlyFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { - return fuse.EPERM -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go deleted file mode 100644 index 01ab0af3..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_darwin.go +++ /dev/null @@ -1,99 +0,0 @@ -package nodefs - -import ( - "syscall" - "time" - "unsafe" - - "github.com/hanwen/go-fuse/fuse" -) - -func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { - // TODO: Handle `mode` parameter. - - // From `man fcntl` on OSX: - // The F_PREALLOCATE command operates on the following structure: - // - // typedef struct fstore { - // u_int32_t fst_flags; /* IN: flags word */ - // int fst_posmode; /* IN: indicates offset field */ - // off_t fst_offset; /* IN: start of the region */ - // off_t fst_length; /* IN: size of the region */ - // off_t fst_bytesalloc; /* OUT: number of bytes allocated */ - // } fstore_t; - // - // The flags (fst_flags) for the F_PREALLOCATE command are as follows: - // - // F_ALLOCATECONTIG Allocate contiguous space. - // - // F_ALLOCATEALL Allocate all requested space or no space at all. - // - // The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field. The modes are as fol- - // lows: - // - // F_PEOFPOSMODE Allocate from the physical end of file. - // - // F_VOLPOSMODE Allocate from the volume offset. - - k := struct { - Flags uint32 // u_int32_t - Posmode int64 // int - Offset int64 // off_t - Length int64 // off_t - Bytesalloc int64 // off_t - }{ - 0, - 0, - int64(off), - int64(sz), - 0, - } - - // Linux version for reference: - // err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz)) - - f.lock.Lock() - _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.File.Fd(), uintptr(syscall.F_PREALLOCATE), uintptr(unsafe.Pointer(&k))) - f.lock.Unlock() - if errno != 0 { - return fuse.ToStatus(errno) - } - return fuse.OK -} - -const _UTIME_NOW = ((1 << 30) - 1) -const _UTIME_OMIT = ((1 << 30) - 2) - -// timeToTimeval - Convert time.Time to syscall.Timeval -// -// Note: This does not use syscall.NsecToTimespec because -// that does not work properly for times before 1970, -// see https://github.com/golang/go/issues/12777 -func timeToTimeval(t *time.Time) syscall.Timeval { - var tv syscall.Timeval - tv.Usec = int32(t.Nanosecond() / 1000) - tv.Sec = t.Unix() - return tv -} - -// OSX does not have the utimensat syscall neded to implement this properly. -// We do our best to emulate it using futimes. -func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status { - tv := make([]syscall.Timeval, 2) - if a == nil { - tv[0].Usec = _UTIME_OMIT - } else { - tv[0] = timeToTimeval(a) - } - - if m == nil { - tv[1].Usec = _UTIME_OMIT - } else { - tv[1] = timeToTimeval(m) - } - - f.lock.Lock() - err := syscall.Futimes(int(f.File.Fd()), tv) - f.lock.Unlock() - return fuse.ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go deleted file mode 100644 index ac4f7c5e..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/files_linux.go +++ /dev/null @@ -1,45 +0,0 @@ -package nodefs - -import ( - "syscall" - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { - f.lock.Lock() - err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz)) - f.lock.Unlock() - if err != nil { - return fuse.ToStatus(err) - } - return fuse.OK -} - -const _UTIME_NOW = ((1 << 30) - 1) -const _UTIME_OMIT = ((1 << 30) - 2) - -// Utimens - file handle based version of loopbackFileSystem.Utimens() -func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status { - var ts [2]syscall.Timespec - - if a == nil { - ts[0].Nsec = _UTIME_OMIT - } else { - ts[0] = syscall.NsecToTimespec(a.UnixNano()) - ts[0].Nsec = 0 - } - - if m == nil { - ts[1].Nsec = _UTIME_OMIT - } else { - ts[1] = syscall.NsecToTimespec(a.UnixNano()) - ts[1].Nsec = 0 - } - - f.lock.Lock() - err := futimens(int(f.File.Fd()), &ts) - f.lock.Unlock() - return fuse.ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go deleted file mode 100644 index a0e4e645..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsconnector.go +++ /dev/null @@ -1,419 +0,0 @@ -package nodefs - -// This file contains the internal logic of the -// FileSystemConnector. The functions for satisfying the raw interface -// are in fsops.go - -import ( - "log" - "path/filepath" - "strings" - "time" - "unsafe" - - "github.com/hanwen/go-fuse/fuse" -) - -// Tests should set to true. -var paranoia = false - -// FilesystemConnector translates the raw FUSE protocol (serialized -// structs of uint32/uint64) to operations on Go objects representing -// files and directories. -type FileSystemConnector struct { - debug bool - - // Callbacks for talking back to the kernel. - server *fuse.Server - - // Translate between uint64 handles and *Inode. - inodeMap handleMap - - // The root of the FUSE file system. - rootNode *Inode -} - -// NewOptions generates FUSE options that correspond to libfuse's -// defaults. -func NewOptions() *Options { - return &Options{ - NegativeTimeout: 0, - AttrTimeout: time.Second, - EntryTimeout: time.Second, - Owner: fuse.CurrentOwner(), - } -} - -// NewFileSystemConnector creates a FileSystemConnector with the given -// options. -func NewFileSystemConnector(root Node, opts *Options) (c *FileSystemConnector) { - c = new(FileSystemConnector) - if opts == nil { - opts = NewOptions() - } - c.inodeMap = newPortableHandleMap() - c.rootNode = newInode(true, root) - - c.verify() - c.mountRoot(opts) - - // FUSE does not issue a LOOKUP for 1 (obviously), but it does - // issue a forget. This lookupUpdate is to make the counts match. - c.lookupUpdate(c.rootNode) - - return c -} - -// Server returns the fuse.Server that talking to the kernel. -func (c *FileSystemConnector) Server() *fuse.Server { - return c.server -} - -// SetDebug toggles printing of debug information. -func (c *FileSystemConnector) SetDebug(debug bool) { - c.debug = debug -} - -// This verifies invariants of the data structure. This routine -// acquires tree locks as it walks the inode tree. -func (c *FileSystemConnector) verify() { - if !paranoia { - return - } - root := c.rootNode - root.verify(c.rootNode.mountPoint) -} - -// childLookup fills entry information for a newly created child inode -func (c *rawBridge) childLookup(out *fuse.EntryOut, n *Inode, context *fuse.Context) { - n.Node().GetAttr((*fuse.Attr)(&out.Attr), nil, context) - n.mount.fillEntry(out) - out.NodeId, out.Generation = c.fsConn().lookupUpdate(n) - if out.Ino == 0 { - out.Ino = out.NodeId - } - if out.Nlink == 0 { - // With Nlink == 0, newer kernels will refuse link - // operations. - out.Nlink = 1 - } -} - -func (c *rawBridge) toInode(nodeid uint64) *Inode { - if nodeid == fuse.FUSE_ROOT_ID { - return c.rootNode - } - i := (*Inode)(unsafe.Pointer(c.inodeMap.Decode(nodeid))) - return i -} - -// Must run outside treeLock. Returns the nodeId and generation. -func (c *FileSystemConnector) lookupUpdate(node *Inode) (id, generation uint64) { - id, generation = c.inodeMap.Register(&node.handled) - c.verify() - return -} - -// forgetUpdate decrements the reference counter for "nodeID" by "forgetCount". -// Must run outside treeLock. -func (c *FileSystemConnector) forgetUpdate(nodeID uint64, forgetCount int) { - if nodeID == fuse.FUSE_ROOT_ID { - c.rootNode.Node().OnUnmount() - - // We never got a lookup for root, so don't try to - // forget root. - return - } - - // Prevent concurrent modification of the tree while we are processing - // the FORGET - node := (*Inode)(unsafe.Pointer(c.inodeMap.Decode(nodeID))) - node.mount.treeLock.Lock() - defer node.mount.treeLock.Unlock() - - if forgotten, _ := c.inodeMap.Forget(nodeID, forgetCount); forgotten { - if len(node.children) > 0 || !node.Node().Deletable() || - node == c.rootNode || node.mountPoint != nil { - // We cannot forget a directory that still has children as these - // would become unreachable. - return - } - // We have to remove ourself from all parents. - // Create a copy of node.parents so we can safely iterate over it - // while modifying the original. - parents := make(map[parentData]struct{}, len(node.parents)) - for k, v := range node.parents { - parents[k] = v - } - - for p := range parents { - // This also modifies node.parents - p.parent.rmChild(p.name) - } - - node.fsInode.OnForget() - } - // TODO - try to drop children even forget was not successful. - c.verify() -} - -// InodeCount returns the number of inodes registered with the kernel. -func (c *FileSystemConnector) InodeHandleCount() int { - return c.inodeMap.Count() -} - -// Finds a node within the currently known inodes, returns the last -// known node and the remaining unknown path components. If parent is -// nil, start from FUSE mountpoint. -func (c *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []string) { - if parent == nil { - parent = c.rootNode - } - if fullPath == "" { - return parent, nil - } - - sep := string(filepath.Separator) - fullPath = strings.TrimLeft(filepath.Clean(fullPath), sep) - comps := strings.Split(fullPath, sep) - - node := parent - if node.mountPoint == nil { - node.mount.treeLock.RLock() - defer node.mount.treeLock.RUnlock() - } - - for i, component := range comps { - if len(component) == 0 { - continue - } - - if node.mountPoint != nil { - node.mount.treeLock.RLock() - defer node.mount.treeLock.RUnlock() - } - - next := node.children[component] - if next == nil { - return node, comps[i:] - } - node = next - } - - return node, nil -} - -// Follows the path from the given parent, doing lookups as -// necesary. The path should be '/' separated without leading slash. -func (c *FileSystemConnector) LookupNode(parent *Inode, path string) *Inode { - if path == "" { - return parent - } - - components := strings.Split(path, "/") - for _, r := range components { - var a fuse.Attr - // This will not affect inode ID lookup counts, which - // are only update in response to kernel requests. - var dummy fuse.InHeader - child, _ := c.internalLookup(&a, parent, r, &dummy) - if child == nil { - return nil - } - - parent = child - } - - return parent -} - -func (c *FileSystemConnector) mountRoot(opts *Options) { - c.rootNode.mountFs(opts) - c.rootNode.mount.connector = c - c.rootNode.Node().OnMount(c) - c.verify() -} - -// Mount() generates a synthetic directory node, and mounts the file -// system there. If opts is nil, the mount options of the root file -// system are inherited. The encompassing filesystem should pretend -// the mount point does not exist. -// -// It returns ENOENT if the directory containing the mount point does -// not exist, and EBUSY if the intended mount point already exists. -func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts *Options) fuse.Status { - node, code := c.lockMount(parent, name, root, opts) - if !code.Ok() { - return code - } - - node.Node().OnMount(c) - return code -} - -func (c *FileSystemConnector) lockMount(parent *Inode, name string, root Node, opts *Options) (*Inode, fuse.Status) { - defer c.verify() - parent.mount.treeLock.Lock() - defer parent.mount.treeLock.Unlock() - node := parent.children[name] - if node != nil { - return nil, fuse.EBUSY - } - - node = newInode(true, root) - if opts == nil { - opts = c.rootNode.mountPoint.options - } - - node.mountFs(opts) - node.mount.connector = c - parent.addChild(name, node) - - node.mountPoint.parentInode = parent - if c.debug { - log.Printf("Mount %T on subdir %s, parent %d", node, - name, c.inodeMap.Handle(&parent.handled)) - } - return node, fuse.OK -} - -// Unmount() tries to unmount the given inode. It returns EINVAL if the -// path does not exist, or is not a mount point, and EBUSY if there -// are open files or submounts below this node. -func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status { - // TODO - racy. - if node.mountPoint == nil { - log.Println("not a mountpoint:", c.inodeMap.Handle(&node.handled)) - return fuse.EINVAL - } - - nodeID := c.inodeMap.Handle(&node.handled) - - // Must lock parent to update tree structure. - parentNode := node.mountPoint.parentInode - parentNode.mount.treeLock.Lock() - defer parentNode.mount.treeLock.Unlock() - - mount := node.mountPoint - name := node.mountPoint.mountName() - if mount.openFiles.Count() > 0 { - return fuse.EBUSY - } - - node.mount.treeLock.Lock() - defer node.mount.treeLock.Unlock() - - if mount.mountInode != node { - log.Panicf("got two different mount inodes %v vs %v", - c.inodeMap.Handle(&mount.mountInode.handled), - c.inodeMap.Handle(&node.handled)) - } - - if !node.canUnmount() { - return fuse.EBUSY - } - - delete(parentNode.children, name) - node.Node().OnUnmount() - - parentId := c.inodeMap.Handle(&parentNode.handled) - if parentNode == c.rootNode { - // TODO - test coverage. Currently covered by zipfs/multizip_test.go - parentId = fuse.FUSE_ROOT_ID - } - - // We have to wait until the kernel has forgotten the - // mountpoint, so the write to node.mountPoint is no longer - // racy. - mount.treeLock.Unlock() - parentNode.mount.treeLock.Unlock() - code := c.server.DeleteNotify(parentId, nodeID, name) - - if code.Ok() { - delay := 100 * time.Microsecond - - for { - // This operation is rare, so we kludge it to avoid - // contention. - time.Sleep(delay) - delay = delay * 2 - if !c.inodeMap.Has(nodeID) { - break - } - - if delay >= time.Second { - // We limit the wait at one second. If - // it takes longer, something else is - // amiss, and we would be waiting forever. - log.Println("kernel did not issue FORGET for node on Unmount.") - break - } - } - - } - - parentNode.mount.treeLock.Lock() - mount.treeLock.Lock() - mount.mountInode = nil - node.mountPoint = nil - - return fuse.OK -} - -// FileNotify notifies the kernel that data and metadata of this inode -// has changed. After this call completes, the kernel will issue a -// new GetAttr requests for metadata and new Read calls for content. -// Use negative offset for metadata-only invalidation, and zero-length -// for invalidating all content. -func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) fuse.Status { - var nId uint64 - if node == c.rootNode { - nId = fuse.FUSE_ROOT_ID - } else { - nId = c.inodeMap.Handle(&node.handled) - } - - if nId == 0 { - return fuse.OK - } - return c.server.InodeNotify(nId, off, length) -} - -// EntryNotify makes the kernel forget the entry data from the given -// name from a directory. After this call, the kernel will issue a -// new lookup request for the given name when necessary. No filesystem -// related locks should be held when calling this. -func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status { - var nId uint64 - if node == c.rootNode { - nId = fuse.FUSE_ROOT_ID - } else { - nId = c.inodeMap.Handle(&node.handled) - } - - if nId == 0 { - return fuse.OK - } - return c.server.EntryNotify(nId, name) -} - -// DeleteNotify signals to the kernel that the named entry in dir for -// the child disappeared. No filesystem related locks should be held -// when calling this. -func (c *FileSystemConnector) DeleteNotify(dir *Inode, child *Inode, name string) fuse.Status { - var nId uint64 - - if dir == c.rootNode { - nId = fuse.FUSE_ROOT_ID - } else { - nId = c.inodeMap.Handle(&dir.handled) - } - - if nId == 0 { - return fuse.OK - } - - chId := c.inodeMap.Handle(&child.handled) - - return c.server.DeleteNotify(nId, chId, name) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go deleted file mode 100644 index eaf4f6bb..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsmount.go +++ /dev/null @@ -1,154 +0,0 @@ -package nodefs - -import ( - "log" - "sync" - "unsafe" - - "github.com/hanwen/go-fuse/fuse" -) - -// openedFile stores either an open dir or an open file. -type openedFile struct { - handled - - WithFlags - - dir *connectorDir -} - -type fileSystemMount struct { - // Node that we were mounted on. - mountInode *Inode - - // Parent to the mountInode. - parentInode *Inode - - // Options for the mount. - options *Options - - // Protects the "children" and "parents" hashmaps of the inodes - // within the mount. - // treeLock should be acquired before openFilesLock. - // - // If multiple treeLocks must be acquired, the treeLocks - // closer to the root must be acquired first. - treeLock sync.RWMutex - - // Manage filehandles of open files. - openFiles handleMap - - Debug bool - - connector *FileSystemConnector -} - -// Must called with lock for parent held. -func (m *fileSystemMount) mountName() string { - for k, v := range m.parentInode.children { - if m.mountInode == v { - return k - } - } - panic("not found") -} - -func (m *fileSystemMount) setOwner(attr *fuse.Attr) { - if m.options.Owner != nil { - attr.Owner = *(*fuse.Owner)(m.options.Owner) - } -} - -func (m *fileSystemMount) fillEntry(out *fuse.EntryOut) { - splitDuration(m.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec) - splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) - m.setOwner(&out.Attr) - if out.Mode&fuse.S_IFDIR == 0 && out.Nlink == 0 { - out.Nlink = 1 - } -} - -func (m *fileSystemMount) fillAttr(out *fuse.AttrOut, nodeId uint64) { - splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) - m.setOwner(&out.Attr) - if out.Ino == 0 { - out.Ino = nodeId - } -} - -func (m *fileSystemMount) getOpenedFile(h uint64) *openedFile { - var b *openedFile - if h != 0 { - b = (*openedFile)(unsafe.Pointer(m.openFiles.Decode(h))) - } - - if b != nil && m.connector.debug && b.WithFlags.Description != "" { - log.Printf("File %d = %q", h, b.WithFlags.Description) - } - return b -} - -func (m *fileSystemMount) unregisterFileHandle(handle uint64, node *Inode) *openedFile { - _, obj := m.openFiles.Forget(handle, 1) - opened := (*openedFile)(unsafe.Pointer(obj)) - node.openFilesMutex.Lock() - idx := -1 - for i, v := range node.openFiles { - if v == opened { - idx = i - break - } - } - - l := len(node.openFiles) - if idx == l-1 { - node.openFiles[idx] = nil - } else { - node.openFiles[idx] = node.openFiles[l-1] - } - node.openFiles = node.openFiles[:l-1] - node.openFilesMutex.Unlock() - - return opened -} - -func (m *fileSystemMount) registerFileHandle(node *Inode, dir *connectorDir, f File, flags uint32) (uint64, *openedFile) { - node.openFilesMutex.Lock() - b := &openedFile{ - dir: dir, - WithFlags: WithFlags{ - File: f, - OpenFlags: flags, - }, - } - - for { - withFlags, ok := f.(*WithFlags) - if !ok { - break - } - - b.WithFlags.File = withFlags.File - b.WithFlags.FuseFlags |= withFlags.FuseFlags - b.WithFlags.Description += withFlags.Description - f = withFlags.File - } - - if b.WithFlags.File != nil { - b.WithFlags.File.SetInode(node) - } - node.openFiles = append(node.openFiles, b) - handle, _ := m.openFiles.Register(&b.handled) - node.openFilesMutex.Unlock() - return handle, b -} - -// Creates a return entry for a non-existent path. -func (m *fileSystemMount) negativeEntry(out *fuse.EntryOut) bool { - if m.options.NegativeTimeout > 0.0 { - out.NodeId = 0 - splitDuration(m.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec) - return true - } - return false -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go deleted file mode 100644 index 757d6272..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fsops.go +++ /dev/null @@ -1,465 +0,0 @@ -package nodefs - -// This file contains FileSystemConnector's implementation of -// RawFileSystem - -import ( - "bytes" - "fmt" - "log" - "strings" - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -// Returns the RawFileSystem so it can be mounted. -func (c *FileSystemConnector) RawFS() fuse.RawFileSystem { - return (*rawBridge)(c) -} - -type rawBridge FileSystemConnector - -func (c *rawBridge) Fsync(input *fuse.FsyncIn) fuse.Status { - node := c.toInode(input.NodeId) - opened := node.mount.getOpenedFile(input.Fh) - - if opened != nil { - return opened.WithFlags.File.Fsync(int(input.FsyncFlags)) - } - - return fuse.ENOSYS -} - -func (c *rawBridge) SetDebug(debug bool) { - c.fsConn().SetDebug(debug) -} - -func (c *rawBridge) FsyncDir(input *fuse.FsyncIn) fuse.Status { - return fuse.ENOSYS -} - -func (c *rawBridge) fsConn() *FileSystemConnector { - return (*FileSystemConnector)(c) -} - -func (c *rawBridge) String() string { - if c.rootNode == nil || c.rootNode.mount == nil { - return "go-fuse:unmounted" - } - - name := fmt.Sprintf("%T", c.rootNode.Node()) - name = strings.TrimLeft(name, "*") - return name -} - -func (c *rawBridge) Init(s *fuse.Server) { - c.server = s -} - -func (c *FileSystemConnector) lookupMountUpdate(out *fuse.Attr, mount *fileSystemMount) (node *Inode, code fuse.Status) { - code = mount.mountInode.Node().GetAttr(out, nil, nil) - if !code.Ok() { - log.Println("Root getattr should not return error", code) - out.Mode = fuse.S_IFDIR | 0755 - return mount.mountInode, fuse.OK - } - - return mount.mountInode, fuse.OK -} - -// internalLookup executes a lookup without affecting NodeId reference counts. -func (c *FileSystemConnector) internalLookup(out *fuse.Attr, parent *Inode, name string, header *fuse.InHeader) (node *Inode, code fuse.Status) { - - // We may already know the child because it was created using Create or Mkdir, - // from an earlier lookup, or because the nodes were created in advance - // (in-memory filesystems). - child := parent.GetChild(name) - - if child != nil && child.mountPoint != nil { - return c.lookupMountUpdate(out, child.mountPoint) - } - - if child != nil { - parent = nil - } - if child != nil { - code = child.fsInode.GetAttr(out, nil, &header.Context) - } else { - child, code = parent.fsInode.Lookup(out, name, &header.Context) - } - - return child, code -} - -func (c *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOut) (code fuse.Status) { - parent := c.toInode(header.NodeId) - if !parent.IsDir() { - log.Printf("Lookup %q called on non-Directory node %d", name, header.NodeId) - return fuse.ENOTDIR - } - outAttr := (*fuse.Attr)(&out.Attr) - child, code := c.fsConn().internalLookup(outAttr, parent, name, header) - if code == fuse.ENOENT && parent.mount.negativeEntry(out) { - return fuse.OK - } - if !code.Ok() { - return code - } - if child == nil { - log.Println("Lookup returned fuse.OK with nil child", name) - } - - child.mount.fillEntry(out) - out.NodeId, out.Generation = c.fsConn().lookupUpdate(child) - if out.Ino == 0 { - out.Ino = out.NodeId - } - - return fuse.OK -} - -func (c *rawBridge) Forget(nodeID, nlookup uint64) { - c.fsConn().forgetUpdate(nodeID, int(nlookup)) -} - -func (c *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) { - node := c.toInode(input.NodeId) - - var f File - if input.Flags()&fuse.FUSE_GETATTR_FH != 0 { - if opened := node.mount.getOpenedFile(input.Fh()); opened != nil { - f = opened.WithFlags.File - } - } - - dest := (*fuse.Attr)(&out.Attr) - code = node.fsInode.GetAttr(dest, f, &input.Context) - if !code.Ok() { - return code - } - - node.mount.fillAttr(out, input.NodeId) - return fuse.OK -} - -func (c *rawBridge) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) (code fuse.Status) { - node := c.toInode(input.NodeId) - stream, err := node.fsInode.OpenDir(&input.Context) - if err != fuse.OK { - return err - } - stream = append(stream, node.getMountDirEntries()...) - de := &connectorDir{ - node: node.Node(), - stream: append(stream, - fuse.DirEntry{Mode: fuse.S_IFDIR, Name: "."}, - fuse.DirEntry{Mode: fuse.S_IFDIR, Name: ".."}), - rawFS: c, - } - h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags) - out.OpenFlags = opened.FuseFlags - out.Fh = h - return fuse.OK -} - -func (c *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status { - node := c.toInode(input.NodeId) - opened := node.mount.getOpenedFile(input.Fh) - return opened.dir.ReadDir(input, out) -} - -func (c *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status { - node := c.toInode(input.NodeId) - opened := node.mount.getOpenedFile(input.Fh) - return opened.dir.ReadDirPlus(input, out) -} - -func (c *rawBridge) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) { - node := c.toInode(input.NodeId) - f, code := node.fsInode.Open(input.Flags, &input.Context) - if !code.Ok() || f == nil { - return code - } - h, opened := node.mount.registerFileHandle(node, nil, f, input.Flags) - out.OpenFlags = opened.FuseFlags - out.Fh = h - return fuse.OK -} - -func (c *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) { - node := c.toInode(input.NodeId) - - var f File - if input.Valid&fuse.FATTR_FH != 0 { - opened := node.mount.getOpenedFile(input.Fh) - f = opened.WithFlags.File - } - - if code.Ok() && input.Valid&fuse.FATTR_MODE != 0 { - permissions := uint32(07777) & input.Mode - code = node.fsInode.Chmod(f, permissions, &input.Context) - } - if code.Ok() && (input.Valid&(fuse.FATTR_UID|fuse.FATTR_GID) != 0) { - var uid uint32 = ^uint32(0) // means "do not change" in chown(2) - var gid uint32 = ^uint32(0) - if input.Valid&fuse.FATTR_UID != 0 { - uid = input.Uid - } - if input.Valid&fuse.FATTR_GID != 0 { - gid = input.Gid - } - code = node.fsInode.Chown(f, uid, gid, &input.Context) - } - if code.Ok() && input.Valid&fuse.FATTR_SIZE != 0 { - code = node.fsInode.Truncate(f, input.Size, &input.Context) - } - if code.Ok() && (input.Valid&(fuse.FATTR_ATIME|fuse.FATTR_MTIME|fuse.FATTR_ATIME_NOW|fuse.FATTR_MTIME_NOW) != 0) { - now := time.Now() - var atime *time.Time - var mtime *time.Time - - if input.Valid&fuse.FATTR_ATIME != 0 { - if input.Valid&fuse.FATTR_ATIME_NOW != 0 { - atime = &now - } else { - t := time.Unix(int64(input.Atime), int64(input.Atimensec)) - atime = &t - } - } - - if input.Valid&fuse.FATTR_MTIME != 0 { - if input.Valid&fuse.FATTR_MTIME_NOW != 0 { - mtime = &now - } else { - t := time.Unix(int64(input.Mtime), int64(input.Mtimensec)) - mtime = &t - } - } - - code = node.fsInode.Utimens(f, atime, mtime, &input.Context) - } - - if !code.Ok() { - return code - } - - // Must call GetAttr(); the filesystem may override some of - // the changes we effect here. - attr := (*fuse.Attr)(&out.Attr) - code = node.fsInode.GetAttr(attr, nil, &input.Context) - if code.Ok() { - node.mount.fillAttr(out, input.NodeId) - } - return code -} - -func (c *rawBridge) Fallocate(input *fuse.FallocateIn) (code fuse.Status) { - n := c.toInode(input.NodeId) - opened := n.mount.getOpenedFile(input.Fh) - - return n.fsInode.Fallocate(opened, input.Offset, input.Length, input.Mode, &input.Context) -} - -func (c *rawBridge) Readlink(header *fuse.InHeader) (out []byte, code fuse.Status) { - n := c.toInode(header.NodeId) - return n.fsInode.Readlink(&header.Context) -} - -func (c *rawBridge) Mknod(input *fuse.MknodIn, name string, out *fuse.EntryOut) (code fuse.Status) { - parent := c.toInode(input.NodeId) - - child, code := parent.fsInode.Mknod(name, input.Mode, uint32(input.Rdev), &input.Context) - if code.Ok() { - c.childLookup(out, child, &input.Context) - code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &input.Context) - } - return code -} - -func (c *rawBridge) Mkdir(input *fuse.MkdirIn, name string, out *fuse.EntryOut) (code fuse.Status) { - parent := c.toInode(input.NodeId) - - child, code := parent.fsInode.Mkdir(name, input.Mode, &input.Context) - if code.Ok() { - c.childLookup(out, child, &input.Context) - code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &input.Context) - } - return code -} - -func (c *rawBridge) Unlink(header *fuse.InHeader, name string) (code fuse.Status) { - parent := c.toInode(header.NodeId) - return parent.fsInode.Unlink(name, &header.Context) -} - -func (c *rawBridge) Rmdir(header *fuse.InHeader, name string) (code fuse.Status) { - parent := c.toInode(header.NodeId) - return parent.fsInode.Rmdir(name, &header.Context) -} - -func (c *rawBridge) Symlink(header *fuse.InHeader, pointedTo string, linkName string, out *fuse.EntryOut) (code fuse.Status) { - parent := c.toInode(header.NodeId) - - child, code := parent.fsInode.Symlink(linkName, pointedTo, &header.Context) - if code.Ok() { - c.childLookup(out, child, &header.Context) - code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &header.Context) - } - return code -} - -func (c *rawBridge) Rename(input *fuse.RenameIn, oldName string, newName string) (code fuse.Status) { - oldParent := c.toInode(input.NodeId) - - child := oldParent.GetChild(oldName) - if child == nil { - return fuse.ENOENT - } - if child.mountPoint != nil { - return fuse.EBUSY - } - - newParent := c.toInode(input.Newdir) - if oldParent.mount != newParent.mount { - return fuse.EXDEV - } - - return oldParent.fsInode.Rename(oldName, newParent.fsInode, newName, &input.Context) -} - -func (c *rawBridge) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (code fuse.Status) { - existing := c.toInode(input.Oldnodeid) - parent := c.toInode(input.NodeId) - - if existing.mount != parent.mount { - return fuse.EXDEV - } - - child, code := parent.fsInode.Link(name, existing.fsInode, &input.Context) - if code.Ok() { - c.childLookup(out, child, &input.Context) - code = child.fsInode.GetAttr((*fuse.Attr)(&out.Attr), nil, &input.Context) - } - - return code -} - -func (c *rawBridge) Access(input *fuse.AccessIn) (code fuse.Status) { - n := c.toInode(input.NodeId) - return n.fsInode.Access(input.Mask, &input.Context) -} - -func (c *rawBridge) Create(input *fuse.CreateIn, name string, out *fuse.CreateOut) (code fuse.Status) { - parent := c.toInode(input.NodeId) - f, child, code := parent.fsInode.Create(name, uint32(input.Flags), input.Mode, &input.Context) - if !code.Ok() { - return code - } - - c.childLookup(&out.EntryOut, child, &input.Context) - handle, opened := parent.mount.registerFileHandle(child, nil, f, input.Flags) - - out.OpenOut.OpenFlags = opened.FuseFlags - out.OpenOut.Fh = handle - return code -} - -func (c *rawBridge) Release(input *fuse.ReleaseIn) { - if input.Fh != 0 { - node := c.toInode(input.NodeId) - opened := node.mount.unregisterFileHandle(input.Fh, node) - opened.WithFlags.File.Release() - } -} - -func (c *rawBridge) ReleaseDir(input *fuse.ReleaseIn) { - if input.Fh != 0 { - node := c.toInode(input.NodeId) - node.mount.unregisterFileHandle(input.Fh, node) - } -} - -func (c *rawBridge) GetXAttrSize(header *fuse.InHeader, attribute string) (sz int, code fuse.Status) { - node := c.toInode(header.NodeId) - data, errno := node.fsInode.GetXAttr(attribute, &header.Context) - return len(data), errno -} - -func (c *rawBridge) GetXAttrData(header *fuse.InHeader, attribute string) (data []byte, code fuse.Status) { - node := c.toInode(header.NodeId) - return node.fsInode.GetXAttr(attribute, &header.Context) -} - -func (c *rawBridge) RemoveXAttr(header *fuse.InHeader, attr string) fuse.Status { - node := c.toInode(header.NodeId) - return node.fsInode.RemoveXAttr(attr, &header.Context) -} - -func (c *rawBridge) SetXAttr(input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status { - node := c.toInode(input.NodeId) - return node.fsInode.SetXAttr(attr, data, int(input.Flags), &input.Context) -} - -func (c *rawBridge) ListXAttr(header *fuse.InHeader) (data []byte, code fuse.Status) { - node := c.toInode(header.NodeId) - attrs, code := node.fsInode.ListXAttr(&header.Context) - if code != fuse.OK { - return nil, code - } - - b := bytes.NewBuffer([]byte{}) - for _, v := range attrs { - b.Write([]byte(v)) - b.WriteByte(0) - } - - return b.Bytes(), code -} - -//////////////// -// files. - -func (c *rawBridge) Write(input *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) { - node := c.toInode(input.NodeId) - opened := node.mount.getOpenedFile(input.Fh) - - var f File - if opened != nil { - f = opened.WithFlags.File - } - - return node.Node().Write(f, data, int64(input.Offset), &input.Context) -} - -func (c *rawBridge) Read(input *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status) { - node := c.toInode(input.NodeId) - opened := node.mount.getOpenedFile(input.Fh) - - var f File - if opened != nil { - f = opened.WithFlags.File - } - - return node.Node().Read(f, buf, int64(input.Offset), &input.Context) -} - -func (c *rawBridge) StatFs(header *fuse.InHeader, out *fuse.StatfsOut) fuse.Status { - node := c.toInode(header.NodeId) - s := node.Node().StatFs() - if s == nil { - return fuse.ENOSYS - } - *out = *s - return fuse.OK -} - -func (c *rawBridge) Flush(input *fuse.FlushIn) fuse.Status { - node := c.toInode(input.NodeId) - opened := node.mount.getOpenedFile(input.Fh) - - if opened != nil { - return opened.WithFlags.File.Flush() - } - return fuse.OK -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go deleted file mode 100644 index 6845e8fd..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/fuse.go +++ /dev/null @@ -1,15 +0,0 @@ -package nodefs - -import ( - "github.com/hanwen/go-fuse/fuse" -) - -// Mounts a filesystem with the given root node on the given directory -func MountRoot(mountpoint string, root Node, opts *Options) (*fuse.Server, *FileSystemConnector, error) { - conn := NewFileSystemConnector(root, opts) - s, err := fuse.NewServer(conn.RawFS(), mountpoint, nil) - if err != nil { - return nil, nil, err - } - return s, conn, nil -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go deleted file mode 100644 index 3f35c9e4..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/handle.go +++ /dev/null @@ -1,147 +0,0 @@ -package nodefs - -import ( - "log" - "sync" -) - -// HandleMap translates objects in Go space to 64-bit handles that can -// be given out to -say- the linux kernel as NodeIds. -// -// The 32 bits version of this is a threadsafe wrapper around a map. -// -// To use it, include "handled" as first member of the structure -// you wish to export. -// -// This structure is thread-safe. -type handleMap interface { - // Register stores "obj" and returns a unique (NodeId, generation) tuple. - Register(obj *handled) (handle, generation uint64) - Count() int - // Decode retrieves a stored object from its 64-bit handle. - Decode(uint64) *handled - // Forget decrements the reference counter for "handle" by "count" and drops - // the object if the refcount reaches zero. - // Returns a boolean whether the object was dropped and the object itself. - Forget(handle uint64, count int) (bool, *handled) - // Handle gets the object's NodeId. - Handle(obj *handled) uint64 - // Has checks if NodeId is stored. - Has(uint64) bool -} - -type handled struct { - check uint32 - handle uint64 - count int -} - -func (h *handled) verify() { - if h.count < 0 { - log.Panicf("negative lookup count %d", h.count) - } - if (h.count == 0) != (h.handle == 0) { - log.Panicf("registration mismatch: lookup %d id %d", h.count, h.handle) - } -} - -const _ALREADY_MSG = "Object already has a handle" - -//////////////////////////////////////////////////////////////// -// portable version using 32 bit integers. - -type portableHandleMap struct { - sync.RWMutex - // The generation counter is incremented each time a NodeId is reused, - // hence the (NodeId, Generation) tuple is always unique. - generation uint64 - // Number of currently used handles - used int - // Array of Go objects indexed by NodeId - handles []*handled - // Free slots in the "handles" array - freeIds []uint64 -} - -func newPortableHandleMap() *portableHandleMap { - return &portableHandleMap{ - // Avoid handing out ID 0 and 1. - handles: []*handled{nil, nil}, - } -} - -func (m *portableHandleMap) Register(obj *handled) (handle, generation uint64) { - m.Lock() - if obj.count == 0 { - if obj.check != 0 { - panic(_ALREADY_MSG) - } - - if len(m.freeIds) == 0 { - handle = uint64(len(m.handles)) - m.handles = append(m.handles, obj) - } else { - handle = m.freeIds[len(m.freeIds)-1] - m.freeIds = m.freeIds[:len(m.freeIds)-1] - m.generation++ - m.handles[handle] = obj - } - m.used++ - obj.handle = handle - } else { - handle = obj.handle - } - obj.count++ - generation = m.generation - m.Unlock() - return -} - -func (m *portableHandleMap) Handle(obj *handled) (h uint64) { - m.RLock() - if obj.count == 0 { - h = 0 - } else { - h = obj.handle - } - m.RUnlock() - return h -} - -func (m *portableHandleMap) Count() int { - m.RLock() - c := m.used - m.RUnlock() - return c -} - -func (m *portableHandleMap) Decode(h uint64) *handled { - m.RLock() - v := m.handles[h] - m.RUnlock() - return v -} - -func (m *portableHandleMap) Forget(h uint64, count int) (forgotten bool, obj *handled) { - m.Lock() - obj = m.handles[h] - obj.count -= count - if obj.count < 0 { - log.Panicf("underflow: handle %d, count %d, object %d", h, count, obj.count) - } else if obj.count == 0 { - m.handles[h] = nil - m.freeIds = append(m.freeIds, h) - m.used-- - forgotten = true - obj.handle = 0 - } - m.Unlock() - return forgotten, obj -} - -func (m *portableHandleMap) Has(h uint64) bool { - m.RLock() - ok := m.handles[h] != nil - m.RUnlock() - return ok -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go deleted file mode 100644 index cfffc095..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/inode.go +++ /dev/null @@ -1,285 +0,0 @@ -package nodefs - -import ( - "log" - "sync" - - "github.com/hanwen/go-fuse/fuse" -) - -type parentData struct { - parent *Inode - name string -} - -// An Inode reflects the kernel's idea of the inode. Inodes have IDs -// that are communicated to the kernel, and they have a tree -// structure: a directory Inode may contain named children. Each -// Inode object is paired with a Node object, which file system -// implementers should supply. -type Inode struct { - handled handled - - // Generation number of the inode. Each (re)use of an inode - // should have a unique generation number. - generation uint64 - - // Number of open files and its protection. - openFilesMutex sync.Mutex - openFiles []*openedFile - - fsInode Node - - // Each inode belongs to exactly one fileSystemMount. This - // pointer is constant during the lifetime, except upon - // Unmount() when it is set to nil. - mount *fileSystemMount - - // All data below is protected by treeLock. - children map[string]*Inode - // Due to hard links, an Inode can have many parents. - parents map[parentData]struct{} - - // Non-nil if this inode is a mountpoint, ie. the Root of a - // NodeFileSystem. - mountPoint *fileSystemMount -} - -func newInode(isDir bool, fsNode Node) *Inode { - me := new(Inode) - me.parents = map[parentData]struct{}{} - if isDir { - me.children = make(map[string]*Inode, initDirSize) - } - me.fsInode = fsNode - me.fsInode.SetInode(me) - return me -} - -// public methods. - -// Returns any open file, preferably a r/w one. -func (n *Inode) AnyFile() (file File) { - n.openFilesMutex.Lock() - for _, f := range n.openFiles { - if file == nil || f.WithFlags.OpenFlags&fuse.O_ANYWRITE != 0 { - file = f.WithFlags.File - } - } - n.openFilesMutex.Unlock() - - return file -} - -// Children returns all children of this inode. -func (n *Inode) Children() (out map[string]*Inode) { - n.mount.treeLock.RLock() - out = make(map[string]*Inode, len(n.children)) - for k, v := range n.children { - out[k] = v - } - n.mount.treeLock.RUnlock() - - return out -} - -// Parent returns a random parent and the name this inode has under this parent. -// This function can be used to walk up the directory tree. It will not cross -// sub-mounts. -func (n *Inode) Parent() (parent *Inode, name string) { - if n.mountPoint != nil { - return nil, "" - } - for k := range n.parents { - return k.parent, k.name - } - return nil, "" -} - -// FsChildren returns all the children from the same filesystem. It -// will skip mountpoints. -func (n *Inode) FsChildren() (out map[string]*Inode) { - n.mount.treeLock.RLock() - out = map[string]*Inode{} - for k, v := range n.children { - if v.mount == n.mount { - out[k] = v - } - } - n.mount.treeLock.RUnlock() - - return out -} - -// Node returns the file-system specific node. -func (n *Inode) Node() Node { - return n.fsInode -} - -// Files() returns an opens file that have bits in common with the -// give mask. Use mask==0 to return all files. -func (n *Inode) Files(mask uint32) (files []WithFlags) { - n.openFilesMutex.Lock() - for _, f := range n.openFiles { - if mask == 0 || f.WithFlags.OpenFlags&mask != 0 { - files = append(files, f.WithFlags) - } - } - n.openFilesMutex.Unlock() - return files -} - -// IsDir returns true if this is a directory. -func (n *Inode) IsDir() bool { - return n.children != nil -} - -// NewChild adds a new child inode to this inode. -func (n *Inode) NewChild(name string, isDir bool, fsi Node) *Inode { - ch := newInode(isDir, fsi) - ch.mount = n.mount - n.AddChild(name, ch) - return ch -} - -// GetChild returns a child inode with the given name, or nil if it -// does not exist. -func (n *Inode) GetChild(name string) (child *Inode) { - n.mount.treeLock.RLock() - child = n.children[name] - n.mount.treeLock.RUnlock() - - return child -} - -// AddChild adds a child inode. The parent inode must be a directory -// node. -func (n *Inode) AddChild(name string, child *Inode) { - if child == nil { - log.Panicf("adding nil child as %q", name) - } - n.mount.treeLock.Lock() - n.addChild(name, child) - n.mount.treeLock.Unlock() -} - -// TreeWatcher is an additional interface that Nodes can implement. -// If they do, the OnAdd and OnRemove are called for operations on the -// file system tree. These functions run under a lock, so they should -// not do blocking operations. -type TreeWatcher interface { - OnAdd(parent *Inode, name string) - OnRemove(parent *Inode, name string) -} - -// RmChild removes an inode by name, and returns it. It returns nil if -// child does not exist. -func (n *Inode) RmChild(name string) (ch *Inode) { - n.mount.treeLock.Lock() - ch = n.rmChild(name) - n.mount.treeLock.Unlock() - return -} - -////////////////////////////////////////////////////////////// -// private - -// addChild adds "child" to our children under name "name". -// Must be called with treeLock for the mount held. -func (n *Inode) addChild(name string, child *Inode) { - if paranoia { - ch := n.children[name] - if ch != nil { - log.Panicf("Already have an Inode with same name: %v: %v", name, ch) - } - } - n.children[name] = child - child.parents[parentData{n, name}] = struct{}{} - if w, ok := child.Node().(TreeWatcher); ok && child.mountPoint == nil { - w.OnAdd(n, name) - } -} - -// rmChild throws out child "name". This means (1) deleting "name" from our -// "children" map and (2) deleting ourself from the child's "parents" map. -// Must be called with treeLock for the mount held. -func (n *Inode) rmChild(name string) *Inode { - ch := n.children[name] - if ch != nil { - delete(n.children, name) - delete(ch.parents, parentData{n, name}) - if w, ok := ch.Node().(TreeWatcher); ok && ch.mountPoint == nil { - w.OnRemove(n, name) - } - } - return ch -} - -// Can only be called on untouched root inodes. -func (n *Inode) mountFs(opts *Options) { - n.mountPoint = &fileSystemMount{ - openFiles: newPortableHandleMap(), - mountInode: n, - options: opts, - } - n.mount = n.mountPoint -} - -// Must be called with treeLock held. -func (n *Inode) canUnmount() bool { - for _, v := range n.children { - if v.mountPoint != nil { - // This access may be out of date, but it is no - // problem to err on the safe side. - return false - } - if !v.canUnmount() { - return false - } - } - - n.openFilesMutex.Lock() - ok := len(n.openFiles) == 0 - n.openFilesMutex.Unlock() - return ok -} - -func (n *Inode) getMountDirEntries() (out []fuse.DirEntry) { - n.mount.treeLock.RLock() - for k, v := range n.children { - if v.mountPoint != nil { - out = append(out, fuse.DirEntry{ - Name: k, - Mode: fuse.S_IFDIR, - }) - } - } - n.mount.treeLock.RUnlock() - - return out -} - -const initDirSize = 20 - -func (n *Inode) verify(cur *fileSystemMount) { - n.handled.verify() - if n.mountPoint != nil { - if n != n.mountPoint.mountInode { - log.Panicf("mountpoint mismatch %v %v", n, n.mountPoint.mountInode) - } - cur = n.mountPoint - - cur.treeLock.Lock() - defer cur.treeLock.Unlock() - } - if n.mount != cur { - log.Panicf("n.mount not set correctly %v %v", n.mount, cur) - } - - for nm, ch := range n.children { - if ch == nil { - log.Panicf("Found nil child: %q", nm) - } - ch.verify(cur) - } -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go deleted file mode 100644 index 051188cf..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/lockingfile.go +++ /dev/null @@ -1,99 +0,0 @@ -package nodefs - -import ( - "fmt" - "sync" - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -type lockingFile struct { - mu *sync.Mutex - file File -} - -// NewLockingFile serializes operations an existing File. -func NewLockingFile(mu *sync.Mutex, f File) File { - return &lockingFile{ - mu: mu, - file: f, - } -} - -func (f *lockingFile) SetInode(*Inode) { -} - -func (f *lockingFile) InnerFile() File { - return f.file -} - -func (f *lockingFile) String() string { - return fmt.Sprintf("lockingFile(%s)", f.file.String()) -} - -func (f *lockingFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Read(buf, off) -} - -func (f *lockingFile) Write(data []byte, off int64) (uint32, fuse.Status) { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Write(data, off) -} - -func (f *lockingFile) Flush() fuse.Status { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Flush() -} - -func (f *lockingFile) Release() { - f.mu.Lock() - defer f.mu.Unlock() - f.file.Release() -} - -func (f *lockingFile) GetAttr(a *fuse.Attr) fuse.Status { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.GetAttr(a) -} - -func (f *lockingFile) Fsync(flags int) (code fuse.Status) { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Fsync(flags) -} - -func (f *lockingFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Utimens(atime, mtime) -} - -func (f *lockingFile) Truncate(size uint64) fuse.Status { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Truncate(size) -} - -func (f *lockingFile) Chown(uid uint32, gid uint32) fuse.Status { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Chown(uid, gid) -} - -func (f *lockingFile) Chmod(perms uint32) fuse.Status { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Chmod(perms) -} - -func (f *lockingFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { - f.mu.Lock() - defer f.mu.Unlock() - return f.file.Allocate(off, size, mode) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go deleted file mode 100644 index 79f719f4..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/memnode.go +++ /dev/null @@ -1,228 +0,0 @@ -package nodefs - -import ( - "fmt" - "os" - "sync" - "syscall" - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -// NewMemNodeFSRoot creates an in-memory node-based filesystem. Files -// are written into a backing store under the given prefix. -func NewMemNodeFSRoot(prefix string) Node { - fs := &memNodeFs{ - backingStorePrefix: prefix, - } - fs.root = fs.newNode() - return fs.root -} - -type memNodeFs struct { - backingStorePrefix string - root *memNode - - mutex sync.Mutex - nextFree int -} - -func (fs *memNodeFs) String() string { - return fmt.Sprintf("MemNodeFs(%s)", fs.backingStorePrefix) -} - -func (fs *memNodeFs) Root() Node { - return fs.root -} - -func (fs *memNodeFs) SetDebug(bool) { -} - -func (fs *memNodeFs) OnMount(*FileSystemConnector) { -} - -func (fs *memNodeFs) OnUnmount() { -} - -func (fs *memNodeFs) newNode() *memNode { - fs.mutex.Lock() - id := fs.nextFree - fs.nextFree++ - fs.mutex.Unlock() - n := &memNode{ - Node: NewDefaultNode(), - fs: fs, - id: id, - } - now := time.Now() - n.info.SetTimes(&now, &now, &now) - n.info.Mode = fuse.S_IFDIR | 0777 - return n -} - -func (fs *memNodeFs) Filename(n *Inode) string { - mn := n.Node().(*memNode) - return mn.filename() -} - -type memNode struct { - Node - fs *memNodeFs - id int - - link string - info fuse.Attr -} - -func (n *memNode) filename() string { - return fmt.Sprintf("%s%d", n.fs.backingStorePrefix, n.id) -} - -func (n *memNode) Deletable() bool { - return false -} - -func (n *memNode) Readlink(c *fuse.Context) ([]byte, fuse.Status) { - return []byte(n.link), fuse.OK -} - -func (n *memNode) StatFs() *fuse.StatfsOut { - return &fuse.StatfsOut{} -} - -func (n *memNode) Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) { - ch := n.fs.newNode() - ch.info.Mode = mode | fuse.S_IFDIR - n.Inode().NewChild(name, true, ch) - return ch.Inode(), fuse.OK -} - -func (n *memNode) Unlink(name string, context *fuse.Context) (code fuse.Status) { - ch := n.Inode().RmChild(name) - if ch == nil { - return fuse.ENOENT - } - return fuse.OK -} - -func (n *memNode) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - return n.Unlink(name, context) -} - -func (n *memNode) Symlink(name string, content string, context *fuse.Context) (newNode *Inode, code fuse.Status) { - ch := n.fs.newNode() - ch.info.Mode = fuse.S_IFLNK | 0777 - ch.link = content - n.Inode().NewChild(name, false, ch) - return ch.Inode(), fuse.OK -} - -func (n *memNode) Rename(oldName string, newParent Node, newName string, context *fuse.Context) (code fuse.Status) { - ch := n.Inode().RmChild(oldName) - newParent.Inode().RmChild(newName) - newParent.Inode().AddChild(newName, ch) - return fuse.OK -} - -func (n *memNode) Link(name string, existing Node, context *fuse.Context) (*Inode, fuse.Status) { - n.Inode().AddChild(name, existing.Inode()) - return existing.Inode(), fuse.OK -} - -func (n *memNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, node *Inode, code fuse.Status) { - ch := n.fs.newNode() - ch.info.Mode = mode | fuse.S_IFREG - - f, err := os.Create(ch.filename()) - if err != nil { - return nil, nil, fuse.ToStatus(err) - } - n.Inode().NewChild(name, false, ch) - return ch.newFile(f), ch.Inode(), fuse.OK -} - -type memNodeFile struct { - File - node *memNode -} - -func (n *memNodeFile) String() string { - return fmt.Sprintf("memNodeFile(%s)", n.File.String()) -} - -func (n *memNodeFile) InnerFile() File { - return n.File -} - -func (n *memNodeFile) Flush() fuse.Status { - code := n.File.Flush() - - if !code.Ok() { - return code - } - - st := syscall.Stat_t{} - err := syscall.Stat(n.node.filename(), &st) - n.node.info.Size = uint64(st.Size) - n.node.info.Blocks = uint64(st.Blocks) - return fuse.ToStatus(err) -} - -func (n *memNode) newFile(f *os.File) File { - return &memNodeFile{ - File: NewLoopbackFile(f), - node: n, - } -} - -func (n *memNode) Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) { - f, err := os.OpenFile(n.filename(), int(flags), 0666) - if err != nil { - return nil, fuse.ToStatus(err) - } - - return n.newFile(f), fuse.OK -} - -func (n *memNode) GetAttr(fi *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) { - *fi = n.info - return fuse.OK -} - -func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) { - if file != nil { - code = file.Truncate(size) - } else { - err := os.Truncate(n.filename(), int64(size)) - code = fuse.ToStatus(err) - } - if code.Ok() { - now := time.Now() - n.info.SetTimes(nil, nil, &now) - // TODO - should update mtime too? - n.info.Size = size - } - return code -} - -func (n *memNode) Utimens(file File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) { - c := time.Now() - n.info.SetTimes(atime, mtime, &c) - return fuse.OK -} - -func (n *memNode) Chmod(file File, perms uint32, context *fuse.Context) (code fuse.Status) { - n.info.Mode = (n.info.Mode &^ 07777) | perms - now := time.Now() - n.info.SetTimes(nil, nil, &now) - return fuse.OK -} - -func (n *memNode) Chown(file File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - n.info.Uid = uid - n.info.Gid = gid - now := time.Now() - n.info.SetTimes(nil, nil, &now) - return fuse.OK -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go deleted file mode 100644 index dfadb418..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/nodefs.go +++ /dev/null @@ -1,9 +0,0 @@ -package nodefs - -import "time" - -func splitDuration(dt time.Duration, secs *uint64, nsecs *uint32) { - ns := int64(dt) - *nsecs = uint32(ns % 1e9) - *secs = uint64(ns / 1e9) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go deleted file mode 100644 index 46f37e89..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/print.go +++ /dev/null @@ -1,14 +0,0 @@ -package nodefs - -import ( - "fmt" - - "github.com/hanwen/go-fuse/fuse" -) - -// String provides a debug string for the given file. -func (f *WithFlags) String() string { - return fmt.Sprintf("File %s (%s) %s %s", - f.File, f.Description, fuse.FlagString(fuse.OpenFlagNames, int64(f.OpenFlags), "O_RDONLY"), - fuse.FlagString(fuse.FuseOpenFlagNames, int64(f.FuseFlags), "")) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go deleted file mode 100644 index c2cca285..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/nodefs/syscall_linux.go +++ /dev/null @@ -1,16 +0,0 @@ -package nodefs - -import ( - "syscall" - "unsafe" -) - -// futimens - futimens(3) calls utimensat(2) with "pathname" set to null and -// "flags" set to zero -func futimens(fd int, times *[2]syscall.Timespec) (err error) { - _, _, e1 := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(fd), 0, uintptr(unsafe.Pointer(times)), uintptr(0), 0, 0) - if e1 != 0 { - err = syscall.Errno(e1) - } - return -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/opcode.go b/vendor/github.com/hanwen/go-fuse/fuse/opcode.go deleted file mode 100644 index d24730b6..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/opcode.go +++ /dev/null @@ -1,642 +0,0 @@ -package fuse - -import ( - "bytes" - "log" - "reflect" - "runtime" - "unsafe" -) - -const ( - _OP_LOOKUP = int32(1) - _OP_FORGET = int32(2) - _OP_GETATTR = int32(3) - _OP_SETATTR = int32(4) - _OP_READLINK = int32(5) - _OP_SYMLINK = int32(6) - _OP_MKNOD = int32(8) - _OP_MKDIR = int32(9) - _OP_UNLINK = int32(10) - _OP_RMDIR = int32(11) - _OP_RENAME = int32(12) - _OP_LINK = int32(13) - _OP_OPEN = int32(14) - _OP_READ = int32(15) - _OP_WRITE = int32(16) - _OP_STATFS = int32(17) - _OP_RELEASE = int32(18) - _OP_FSYNC = int32(20) - _OP_SETXATTR = int32(21) - _OP_GETXATTR = int32(22) - _OP_LISTXATTR = int32(23) - _OP_REMOVEXATTR = int32(24) - _OP_FLUSH = int32(25) - _OP_INIT = int32(26) - _OP_OPENDIR = int32(27) - _OP_READDIR = int32(28) - _OP_RELEASEDIR = int32(29) - _OP_FSYNCDIR = int32(30) - _OP_GETLK = int32(31) - _OP_SETLK = int32(32) - _OP_SETLKW = int32(33) - _OP_ACCESS = int32(34) - _OP_CREATE = int32(35) - _OP_INTERRUPT = int32(36) - _OP_BMAP = int32(37) - _OP_DESTROY = int32(38) - _OP_IOCTL = int32(39) - _OP_POLL = int32(40) - _OP_NOTIFY_REPLY = int32(41) - _OP_BATCH_FORGET = int32(42) - _OP_FALLOCATE = int32(43) // protocol version 19. - _OP_READDIRPLUS = int32(44) // protocol version 21. - _OP_FUSE_RENAME2 = int32(45) // protocol version 23. - - // The following entries don't have to be compatible across Go-FUSE versions. - _OP_NOTIFY_ENTRY = int32(100) - _OP_NOTIFY_INODE = int32(101) - _OP_NOTIFY_DELETE = int32(102) // protocol version 18 - - _OPCODE_COUNT = int32(103) -) - -//////////////////////////////////////////////////////////////// - -func doInit(server *Server, req *request) { - input := (*InitIn)(req.inData) - if input.Major != _FUSE_KERNEL_VERSION { - log.Printf("Major versions does not match. Given %d, want %d\n", input.Major, _FUSE_KERNEL_VERSION) - req.status = EIO - return - } - if input.Minor < _MINIMUM_MINOR_VERSION { - log.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, _MINIMUM_MINOR_VERSION) - req.status = EIO - return - } - - server.reqMu.Lock() - server.kernelSettings = *input - server.kernelSettings.Flags = input.Flags & (CAP_ASYNC_READ | CAP_BIG_WRITES | CAP_FILE_OPS | - CAP_AUTO_INVAL_DATA | CAP_READDIRPLUS | CAP_NO_OPEN_SUPPORT) - - if input.Minor >= 13 { - server.setSplice() - } - server.reqMu.Unlock() - - out := &InitOut{ - Major: _FUSE_KERNEL_VERSION, - Minor: _OUR_MINOR_VERSION, - MaxReadAhead: input.MaxReadAhead, - Flags: server.kernelSettings.Flags, - MaxWrite: uint32(server.opts.MaxWrite), - CongestionThreshold: uint16(server.opts.MaxBackground * 3 / 4), - MaxBackground: uint16(server.opts.MaxBackground), - } - if out.Minor > input.Minor { - out.Minor = input.Minor - } - - if out.Minor <= 22 { - tweaked := *req.handler - - // v8-v22 don't have TimeGran and further fields. - tweaked.OutputSize = 24 - req.handler = &tweaked - } - - req.outData = unsafe.Pointer(out) - req.status = OK -} - -func doOpen(server *Server, req *request) { - out := (*OpenOut)(req.outData) - status := server.fileSystem.Open((*OpenIn)(req.inData), out) - req.status = status - if status != OK { - return - } -} - -func doCreate(server *Server, req *request) { - out := (*CreateOut)(req.outData) - status := server.fileSystem.Create((*CreateIn)(req.inData), req.filenames[0], out) - req.status = status -} - -func doReadDir(server *Server, req *request) { - in := (*ReadIn)(req.inData) - buf := server.allocOut(req, in.Size) - out := NewDirEntryList(buf, uint64(in.Offset)) - - code := server.fileSystem.ReadDir(in, out) - req.flatData = out.bytes() - req.status = code -} - -func doReadDirPlus(server *Server, req *request) { - in := (*ReadIn)(req.inData) - buf := server.allocOut(req, in.Size) - out := NewDirEntryList(buf, uint64(in.Offset)) - - code := server.fileSystem.ReadDirPlus(in, out) - req.flatData = out.bytes() - req.status = code -} - -func doOpenDir(server *Server, req *request) { - out := (*OpenOut)(req.outData) - status := server.fileSystem.OpenDir((*OpenIn)(req.inData), out) - req.status = status -} - -func doSetattr(server *Server, req *request) { - out := (*AttrOut)(req.outData) - req.status = server.fileSystem.SetAttr((*SetAttrIn)(req.inData), out) -} - -func doWrite(server *Server, req *request) { - n, status := server.fileSystem.Write((*WriteIn)(req.inData), req.arg) - o := (*WriteOut)(req.outData) - o.Size = n - req.status = status -} - -const _SECURITY_CAPABILITY = "security.capability" -const _SECURITY_ACL = "system.posix_acl_access" -const _SECURITY_ACL_DEFAULT = "system.posix_acl_default" - -func doGetXAttr(server *Server, req *request) { - if server.opts.IgnoreSecurityLabels && req.inHeader.Opcode == _OP_GETXATTR { - fn := req.filenames[0] - if fn == _SECURITY_CAPABILITY || fn == _SECURITY_ACL_DEFAULT || - fn == _SECURITY_ACL { - req.status = ENODATA - return - } - } - - input := (*GetXAttrIn)(req.inData) - - if input.Size == 0 { - out := (*GetXAttrOut)(req.outData) - switch req.inHeader.Opcode { - case _OP_GETXATTR: - sz, code := server.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0]) - if code.Ok() { - out.Size = uint32(sz) - } - req.status = code - return - case _OP_LISTXATTR: - data, code := server.fileSystem.ListXAttr(req.inHeader) - if code.Ok() { - out.Size = uint32(len(data)) - } - req.status = code - return - } - } - - req.outData = nil - var data []byte - switch req.inHeader.Opcode { - case _OP_GETXATTR: - data, req.status = server.fileSystem.GetXAttrData(req.inHeader, req.filenames[0]) - case _OP_LISTXATTR: - data, req.status = server.fileSystem.ListXAttr(req.inHeader) - default: - log.Panicf("xattr opcode %v", req.inHeader.Opcode) - req.status = ENOSYS - } - - if len(data) > int(input.Size) { - req.status = ERANGE - } - - if !req.status.Ok() { - return - } - - req.flatData = data -} - -func doGetAttr(server *Server, req *request) { - out := (*AttrOut)(req.outData) - s := server.fileSystem.GetAttr((*GetAttrIn)(req.inData), out) - req.status = s -} - -// doForget - forget one NodeId -func doForget(server *Server, req *request) { - if !server.opts.RememberInodes { - server.fileSystem.Forget(req.inHeader.NodeId, (*ForgetIn)(req.inData).Nlookup) - } -} - -// doBatchForget - forget a list of NodeIds -func doBatchForget(server *Server, req *request) { - in := (*_BatchForgetIn)(req.inData) - wantBytes := uintptr(in.Count) * unsafe.Sizeof(_ForgetOne{}) - if uintptr(len(req.arg)) < wantBytes { - // We have no return value to complain, so log an error. - log.Printf("Too few bytes for batch forget. Got %d bytes, want %d (%d entries)", - len(req.arg), wantBytes, in.Count) - } - - h := &reflect.SliceHeader{ - Data: uintptr(unsafe.Pointer(&req.arg[0])), - Len: int(in.Count), - Cap: int(in.Count), - } - - forgets := *(*[]_ForgetOne)(unsafe.Pointer(h)) - for i, f := range forgets { - if server.debug { - log.Printf("doBatchForget: forgetting %d of %d: NodeId: %d, Nlookup: %d", i+1, len(forgets), f.NodeId, f.Nlookup) - } - server.fileSystem.Forget(f.NodeId, f.Nlookup) - } -} - -func doReadlink(server *Server, req *request) { - req.flatData, req.status = server.fileSystem.Readlink(req.inHeader) -} - -func doLookup(server *Server, req *request) { - out := (*EntryOut)(req.outData) - s := server.fileSystem.Lookup(req.inHeader, req.filenames[0], out) - req.status = s - req.outData = unsafe.Pointer(out) -} - -func doMknod(server *Server, req *request) { - out := (*EntryOut)(req.outData) - - req.status = server.fileSystem.Mknod((*MknodIn)(req.inData), req.filenames[0], out) -} - -func doMkdir(server *Server, req *request) { - out := (*EntryOut)(req.outData) - req.status = server.fileSystem.Mkdir((*MkdirIn)(req.inData), req.filenames[0], out) -} - -func doUnlink(server *Server, req *request) { - req.status = server.fileSystem.Unlink(req.inHeader, req.filenames[0]) -} - -func doRmdir(server *Server, req *request) { - req.status = server.fileSystem.Rmdir(req.inHeader, req.filenames[0]) -} - -func doLink(server *Server, req *request) { - out := (*EntryOut)(req.outData) - req.status = server.fileSystem.Link((*LinkIn)(req.inData), req.filenames[0], out) -} - -func doRead(server *Server, req *request) { - in := (*ReadIn)(req.inData) - buf := server.allocOut(req, in.Size) - - req.readResult, req.status = server.fileSystem.Read(in, buf) - if fd, ok := req.readResult.(*readResultFd); ok { - req.fdData = fd - req.flatData = nil - } else if req.readResult != nil && req.status.Ok() { - req.flatData, req.status = req.readResult.Bytes(buf) - } -} - -func doFlush(server *Server, req *request) { - req.status = server.fileSystem.Flush((*FlushIn)(req.inData)) -} - -func doRelease(server *Server, req *request) { - server.fileSystem.Release((*ReleaseIn)(req.inData)) -} - -func doFsync(server *Server, req *request) { - req.status = server.fileSystem.Fsync((*FsyncIn)(req.inData)) -} - -func doReleaseDir(server *Server, req *request) { - server.fileSystem.ReleaseDir((*ReleaseIn)(req.inData)) -} - -func doFsyncDir(server *Server, req *request) { - req.status = server.fileSystem.FsyncDir((*FsyncIn)(req.inData)) -} - -func doSetXAttr(server *Server, req *request) { - splits := bytes.SplitN(req.arg, []byte{0}, 2) - req.status = server.fileSystem.SetXAttr((*SetXAttrIn)(req.inData), string(splits[0]), splits[1]) -} - -func doRemoveXAttr(server *Server, req *request) { - req.status = server.fileSystem.RemoveXAttr(req.inHeader, req.filenames[0]) -} - -func doAccess(server *Server, req *request) { - req.status = server.fileSystem.Access((*AccessIn)(req.inData)) -} - -func doSymlink(server *Server, req *request) { - out := (*EntryOut)(req.outData) - req.status = server.fileSystem.Symlink(req.inHeader, req.filenames[1], req.filenames[0], out) -} - -func doRename(server *Server, req *request) { - req.status = server.fileSystem.Rename((*RenameIn)(req.inData), req.filenames[0], req.filenames[1]) -} - -func doStatFs(server *Server, req *request) { - out := (*StatfsOut)(req.outData) - req.status = server.fileSystem.StatFs(req.inHeader, out) - if req.status == ENOSYS && runtime.GOOS == "darwin" { - // OSX FUSE requires Statfs to be implemented for the - // mount to succeed. - *out = StatfsOut{} - req.status = OK - } -} - -func doIoctl(server *Server, req *request) { - req.status = ENOSYS -} - -func doDestroy(server *Server, req *request) { - req.status = OK -} - -func doFallocate(server *Server, req *request) { - req.status = server.fileSystem.Fallocate((*FallocateIn)(req.inData)) -} - -//////////////////////////////////////////////////////////////// - -type operationFunc func(*Server, *request) -type castPointerFunc func(unsafe.Pointer) interface{} - -type operationHandler struct { - Name string - Func operationFunc - InputSize uintptr - OutputSize uintptr - DecodeIn castPointerFunc - DecodeOut castPointerFunc - FileNames int - FileNameOut bool -} - -var operationHandlers []*operationHandler - -func operationName(op int32) string { - h := getHandler(op) - if h == nil { - return "unknown" - } - return h.Name -} - -func getHandler(o int32) *operationHandler { - if o >= _OPCODE_COUNT { - return nil - } - return operationHandlers[o] -} - -func init() { - operationHandlers = make([]*operationHandler, _OPCODE_COUNT) - for i := range operationHandlers { - operationHandlers[i] = &operationHandler{Name: "UNKNOWN"} - } - - fileOps := []int32{_OP_READLINK, _OP_NOTIFY_ENTRY, _OP_NOTIFY_DELETE} - for _, op := range fileOps { - operationHandlers[op].FileNameOut = true - } - - for op, sz := range map[int32]uintptr{ - _OP_FORGET: unsafe.Sizeof(ForgetIn{}), - _OP_BATCH_FORGET: unsafe.Sizeof(_BatchForgetIn{}), - _OP_GETATTR: unsafe.Sizeof(GetAttrIn{}), - _OP_SETATTR: unsafe.Sizeof(SetAttrIn{}), - _OP_MKNOD: unsafe.Sizeof(MknodIn{}), - _OP_MKDIR: unsafe.Sizeof(MkdirIn{}), - _OP_RENAME: unsafe.Sizeof(RenameIn{}), - _OP_LINK: unsafe.Sizeof(LinkIn{}), - _OP_OPEN: unsafe.Sizeof(OpenIn{}), - _OP_READ: unsafe.Sizeof(ReadIn{}), - _OP_WRITE: unsafe.Sizeof(WriteIn{}), - _OP_RELEASE: unsafe.Sizeof(ReleaseIn{}), - _OP_FSYNC: unsafe.Sizeof(FsyncIn{}), - _OP_SETXATTR: unsafe.Sizeof(SetXAttrIn{}), - _OP_GETXATTR: unsafe.Sizeof(GetXAttrIn{}), - _OP_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}), - _OP_FLUSH: unsafe.Sizeof(FlushIn{}), - _OP_INIT: unsafe.Sizeof(InitIn{}), - _OP_OPENDIR: unsafe.Sizeof(OpenIn{}), - _OP_READDIR: unsafe.Sizeof(ReadIn{}), - _OP_RELEASEDIR: unsafe.Sizeof(ReleaseIn{}), - _OP_FSYNCDIR: unsafe.Sizeof(FsyncIn{}), - _OP_ACCESS: unsafe.Sizeof(AccessIn{}), - _OP_CREATE: unsafe.Sizeof(CreateIn{}), - _OP_INTERRUPT: unsafe.Sizeof(InterruptIn{}), - _OP_BMAP: unsafe.Sizeof(_BmapIn{}), - _OP_IOCTL: unsafe.Sizeof(_IoctlIn{}), - _OP_POLL: unsafe.Sizeof(_PollIn{}), - _OP_FALLOCATE: unsafe.Sizeof(FallocateIn{}), - _OP_READDIRPLUS: unsafe.Sizeof(ReadIn{}), - } { - operationHandlers[op].InputSize = sz - } - - for op, sz := range map[int32]uintptr{ - _OP_LOOKUP: unsafe.Sizeof(EntryOut{}), - _OP_GETATTR: unsafe.Sizeof(AttrOut{}), - _OP_SETATTR: unsafe.Sizeof(AttrOut{}), - _OP_SYMLINK: unsafe.Sizeof(EntryOut{}), - _OP_MKNOD: unsafe.Sizeof(EntryOut{}), - _OP_MKDIR: unsafe.Sizeof(EntryOut{}), - _OP_LINK: unsafe.Sizeof(EntryOut{}), - _OP_OPEN: unsafe.Sizeof(OpenOut{}), - _OP_WRITE: unsafe.Sizeof(WriteOut{}), - _OP_STATFS: unsafe.Sizeof(StatfsOut{}), - _OP_GETXATTR: unsafe.Sizeof(GetXAttrOut{}), - _OP_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}), - _OP_INIT: unsafe.Sizeof(InitOut{}), - _OP_OPENDIR: unsafe.Sizeof(OpenOut{}), - _OP_CREATE: unsafe.Sizeof(CreateOut{}), - _OP_BMAP: unsafe.Sizeof(_BmapOut{}), - _OP_IOCTL: unsafe.Sizeof(_IoctlOut{}), - _OP_POLL: unsafe.Sizeof(_PollOut{}), - _OP_NOTIFY_ENTRY: unsafe.Sizeof(NotifyInvalEntryOut{}), - _OP_NOTIFY_INODE: unsafe.Sizeof(NotifyInvalInodeOut{}), - _OP_NOTIFY_DELETE: unsafe.Sizeof(NotifyInvalDeleteOut{}), - } { - operationHandlers[op].OutputSize = sz - } - - for op, v := range map[int32]string{ - _OP_LOOKUP: "LOOKUP", - _OP_FORGET: "FORGET", - _OP_BATCH_FORGET: "BATCH_FORGET", - _OP_GETATTR: "GETATTR", - _OP_SETATTR: "SETATTR", - _OP_READLINK: "READLINK", - _OP_SYMLINK: "SYMLINK", - _OP_MKNOD: "MKNOD", - _OP_MKDIR: "MKDIR", - _OP_UNLINK: "UNLINK", - _OP_RMDIR: "RMDIR", - _OP_RENAME: "RENAME", - _OP_LINK: "LINK", - _OP_OPEN: "OPEN", - _OP_READ: "READ", - _OP_WRITE: "WRITE", - _OP_STATFS: "STATFS", - _OP_RELEASE: "RELEASE", - _OP_FSYNC: "FSYNC", - _OP_SETXATTR: "SETXATTR", - _OP_GETXATTR: "GETXATTR", - _OP_LISTXATTR: "LISTXATTR", - _OP_REMOVEXATTR: "REMOVEXATTR", - _OP_FLUSH: "FLUSH", - _OP_INIT: "INIT", - _OP_OPENDIR: "OPENDIR", - _OP_READDIR: "READDIR", - _OP_RELEASEDIR: "RELEASEDIR", - _OP_FSYNCDIR: "FSYNCDIR", - _OP_GETLK: "GETLK", - _OP_SETLK: "SETLK", - _OP_SETLKW: "SETLKW", - _OP_ACCESS: "ACCESS", - _OP_CREATE: "CREATE", - _OP_INTERRUPT: "INTERRUPT", - _OP_BMAP: "BMAP", - _OP_DESTROY: "DESTROY", - _OP_IOCTL: "IOCTL", - _OP_POLL: "POLL", - _OP_NOTIFY_ENTRY: "NOTIFY_ENTRY", - _OP_NOTIFY_INODE: "NOTIFY_INODE", - _OP_NOTIFY_DELETE: "NOTIFY_DELETE", - _OP_FALLOCATE: "FALLOCATE", - _OP_READDIRPLUS: "READDIRPLUS", - } { - operationHandlers[op].Name = v - } - - for op, v := range map[int32]operationFunc{ - _OP_OPEN: doOpen, - _OP_READDIR: doReadDir, - _OP_WRITE: doWrite, - _OP_OPENDIR: doOpenDir, - _OP_CREATE: doCreate, - _OP_SETATTR: doSetattr, - _OP_GETXATTR: doGetXAttr, - _OP_LISTXATTR: doGetXAttr, - _OP_GETATTR: doGetAttr, - _OP_FORGET: doForget, - _OP_BATCH_FORGET: doBatchForget, - _OP_READLINK: doReadlink, - _OP_INIT: doInit, - _OP_LOOKUP: doLookup, - _OP_MKNOD: doMknod, - _OP_MKDIR: doMkdir, - _OP_UNLINK: doUnlink, - _OP_RMDIR: doRmdir, - _OP_LINK: doLink, - _OP_READ: doRead, - _OP_FLUSH: doFlush, - _OP_RELEASE: doRelease, - _OP_FSYNC: doFsync, - _OP_RELEASEDIR: doReleaseDir, - _OP_FSYNCDIR: doFsyncDir, - _OP_SETXATTR: doSetXAttr, - _OP_REMOVEXATTR: doRemoveXAttr, - _OP_ACCESS: doAccess, - _OP_SYMLINK: doSymlink, - _OP_RENAME: doRename, - _OP_STATFS: doStatFs, - _OP_IOCTL: doIoctl, - _OP_DESTROY: doDestroy, - _OP_FALLOCATE: doFallocate, - _OP_READDIRPLUS: doReadDirPlus, - } { - operationHandlers[op].Func = v - } - - // Outputs. - for op, f := range map[int32]castPointerFunc{ - _OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, - _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*OpenOut)(ptr) }, - _OP_OPENDIR: func(ptr unsafe.Pointer) interface{} { return (*OpenOut)(ptr) }, - _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, - _OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateOut)(ptr) }, - _OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, - _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, - _OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitOut)(ptr) }, - _OP_MKDIR: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, - _OP_NOTIFY_ENTRY: func(ptr unsafe.Pointer) interface{} { return (*NotifyInvalEntryOut)(ptr) }, - _OP_NOTIFY_INODE: func(ptr unsafe.Pointer) interface{} { return (*NotifyInvalInodeOut)(ptr) }, - _OP_NOTIFY_DELETE: func(ptr unsafe.Pointer) interface{} { return (*NotifyInvalDeleteOut)(ptr) }, - _OP_STATFS: func(ptr unsafe.Pointer) interface{} { return (*StatfsOut)(ptr) }, - } { - operationHandlers[op].DecodeOut = f - } - - // Inputs. - for op, f := range map[int32]castPointerFunc{ - _OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*FlushIn)(ptr) }, - _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*GetAttrIn)(ptr) }, - _OP_GETXATTR: func(ptr unsafe.Pointer) interface{} { return (*GetXAttrIn)(ptr) }, - _OP_LISTXATTR: func(ptr unsafe.Pointer) interface{} { return (*GetXAttrIn)(ptr) }, - _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*SetAttrIn)(ptr) }, - _OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitIn)(ptr) }, - _OP_IOCTL: func(ptr unsafe.Pointer) interface{} { return (*_IoctlIn)(ptr) }, - _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*OpenIn)(ptr) }, - _OP_MKNOD: func(ptr unsafe.Pointer) interface{} { return (*MknodIn)(ptr) }, - _OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateIn)(ptr) }, - _OP_READ: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, - _OP_READDIR: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, - _OP_ACCESS: func(ptr unsafe.Pointer) interface{} { return (*AccessIn)(ptr) }, - _OP_FORGET: func(ptr unsafe.Pointer) interface{} { return (*ForgetIn)(ptr) }, - _OP_BATCH_FORGET: func(ptr unsafe.Pointer) interface{} { return (*_BatchForgetIn)(ptr) }, - _OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*LinkIn)(ptr) }, - _OP_MKDIR: func(ptr unsafe.Pointer) interface{} { return (*MkdirIn)(ptr) }, - _OP_RELEASE: func(ptr unsafe.Pointer) interface{} { return (*ReleaseIn)(ptr) }, - _OP_RELEASEDIR: func(ptr unsafe.Pointer) interface{} { return (*ReleaseIn)(ptr) }, - _OP_FALLOCATE: func(ptr unsafe.Pointer) interface{} { return (*FallocateIn)(ptr) }, - _OP_READDIRPLUS: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, - _OP_RENAME: func(ptr unsafe.Pointer) interface{} { return (*RenameIn)(ptr) }, - } { - operationHandlers[op].DecodeIn = f - } - - // File name args. - for op, count := range map[int32]int{ - _OP_CREATE: 1, - _OP_GETXATTR: 1, - _OP_LINK: 1, - _OP_LOOKUP: 1, - _OP_MKDIR: 1, - _OP_MKNOD: 1, - _OP_REMOVEXATTR: 1, - _OP_RENAME: 2, - _OP_RMDIR: 1, - _OP_SYMLINK: 2, - _OP_UNLINK: 1, - } { - operationHandlers[op].FileNames = count - } - - var r request - sizeOfOutHeader := unsafe.Sizeof(OutHeader{}) - for code, h := range operationHandlers { - if h.OutputSize+sizeOfOutHeader > unsafe.Sizeof(r.outBuf) { - log.Panicf("request output buffer too small: code %v, sz %d + %d %v", code, h.OutputSize, sizeOfOutHeader, h) - } - } -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go deleted file mode 100644 index 56184ba6..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/api.go +++ /dev/null @@ -1,78 +0,0 @@ -package pathfs - -import ( - "time" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -// A filesystem API that uses paths rather than inodes. A minimal -// file system should have at least a functional GetAttr method. -// Typically, each call happens in its own goroutine, so take care to -// make the file system thread-safe. -// -// NewDefaultFileSystem provides a null implementation of required -// methods. -type FileSystem interface { - // Used for pretty printing. - String() string - - // If called, provide debug output through the log package. - SetDebug(debug bool) - - // Attributes. This function is the main entry point, through - // which FUSE discovers which files and directories exist. - // - // If the filesystem wants to implement hard-links, it should - // return consistent non-zero FileInfo.Ino data. Using - // hardlinks incurs a performance hit. - GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) - - // These should update the file's ctime too. - Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) - Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) - Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) - - Truncate(name string, size uint64, context *fuse.Context) (code fuse.Status) - - Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) - - // Tree structure - Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) - Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status - Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status - Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) - Rmdir(name string, context *fuse.Context) (code fuse.Status) - Unlink(name string, context *fuse.Context) (code fuse.Status) - - // Extended attributes. - GetXAttr(name string, attribute string, context *fuse.Context) (data []byte, code fuse.Status) - ListXAttr(name string, context *fuse.Context) (attributes []string, code fuse.Status) - RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status - SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status - - // Called after mount. - OnMount(nodeFs *PathNodeFs) - OnUnmount() - - // File handling. If opening for writing, the file's mtime - // should be updated too. - Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) - Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) - - // Directory handling - OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, code fuse.Status) - - // Symlinks. - Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) - Readlink(name string, context *fuse.Context) (string, fuse.Status) - - StatFs(name string) *fuse.StatfsOut -} - -type PathNodeFsOptions struct { - // If ClientInodes is set, use Inode returned from GetAttr to - // find hard-linked files. - ClientInodes bool -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go deleted file mode 100644 index 3897fee4..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/copy.go +++ /dev/null @@ -1,57 +0,0 @@ -package pathfs - -import ( - "os" - - "github.com/hanwen/go-fuse/fuse" -) - -func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.Context) fuse.Status { - src, code := srcFs.Open(srcFile, uint32(os.O_RDONLY), context) - if !code.Ok() { - return code - } - defer src.Release() - defer src.Flush() - - attr, code := srcFs.GetAttr(srcFile, context) - if !code.Ok() { - return code - } - - dst, code := destFs.Create(destFile, uint32(os.O_WRONLY|os.O_CREATE|os.O_TRUNC), attr.Mode, context) - if !code.Ok() { - return code - } - defer dst.Release() - defer dst.Flush() - - buf := make([]byte, 128*(1<<10)) - off := int64(0) - for { - res, code := src.Read(buf, off) - if !code.Ok() { - return code - } - data, code := res.Bytes(buf) - if !code.Ok() { - return code - } - - if len(data) == 0 { - break - } - n, code := dst.Write(data, off) - if !code.Ok() { - return code - } - if int(n) < len(data) { - return fuse.EIO - } - if len(data) < len(buf) { - break - } - off += int64(len(data)) - } - return fuse.OK -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go deleted file mode 100644 index 62e11893..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/default.go +++ /dev/null @@ -1,118 +0,0 @@ -package pathfs - -import ( - "time" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -// NewDefaultFileSystem creates a filesystem that responds ENOSYS for -// all methods -func NewDefaultFileSystem() FileSystem { - return (*defaultFileSystem)(nil) -} - -// defaultFileSystem implements a FileSystem that returns ENOSYS for every operation. -type defaultFileSystem struct{} - -func (fs *defaultFileSystem) SetDebug(debug bool) {} - -// defaultFileSystem -func (fs *defaultFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { - return nil, fuse.ENOSYS -} - -func (fs *defaultFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { - return nil, fuse.ENOSYS -} - -func (fs *defaultFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { - return nil, fuse.ENOSYS -} - -func (fs *defaultFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { - return "", fuse.ENOSYS -} - -func (fs *defaultFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (fs *defaultFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { - return nil, fuse.ENOSYS -} - -func (fs *defaultFileSystem) OnMount(nodeFs *PathNodeFs) { -} - -func (fs *defaultFileSystem) OnUnmount() { -} - -func (fs *defaultFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - return nil, fuse.ENOSYS -} - -func (fs *defaultFileSystem) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) { - return fuse.ENOSYS -} - -func (fs *defaultFileSystem) String() string { - return "defaultFileSystem" -} - -func (fs *defaultFileSystem) StatFs(name string) *fuse.StatfsOut { - return nil -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go deleted file mode 100644 index 93bef52f..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/locking.go +++ /dev/null @@ -1,163 +0,0 @@ -package pathfs - -import ( - "sync" - "time" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -type lockingFileSystem struct { - // Should be public so people reusing can access the wrapped - // FS. - FS FileSystem - lock sync.Mutex -} - -// NewLockingFileSystem is a wrapper that makes a FileSystem -// threadsafe by serializing each operation. -func NewLockingFileSystem(pfs FileSystem) FileSystem { - l := new(lockingFileSystem) - l.FS = pfs - return l -} - -func (fs *lockingFileSystem) String() string { - defer fs.locked()() - return fs.FS.String() -} - -func (fs *lockingFileSystem) SetDebug(debug bool) { - defer fs.locked()() - fs.FS.SetDebug(debug) -} - -func (fs *lockingFileSystem) StatFs(name string) *fuse.StatfsOut { - defer fs.locked()() - return fs.FS.StatFs(name) -} - -func (fs *lockingFileSystem) locked() func() { - fs.lock.Lock() - return func() { fs.lock.Unlock() } -} - -func (fs *lockingFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { - defer fs.locked()() - return fs.FS.GetAttr(name, context) -} - -func (fs *lockingFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { - defer fs.locked()() - return fs.FS.Readlink(name, context) -} - -func (fs *lockingFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { - defer fs.locked()() - return fs.FS.Mknod(name, mode, dev, context) -} - -func (fs *lockingFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { - defer fs.locked()() - return fs.FS.Mkdir(name, mode, context) -} - -func (fs *lockingFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Unlink(name, context) -} - -func (fs *lockingFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Rmdir(name, context) -} - -func (fs *lockingFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Symlink(value, linkName, context) -} - -func (fs *lockingFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Rename(oldName, newName, context) -} - -func (fs *lockingFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Link(oldName, newName, context) -} - -func (fs *lockingFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Chmod(name, mode, context) -} - -func (fs *lockingFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Chown(name, uid, gid, context) -} - -func (fs *lockingFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Truncate(name, offset, context) -} - -func (fs *lockingFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - file, code = fs.FS.Open(name, flags, context) - file = nodefs.NewLockingFile(&fs.lock, file) - return -} - -func (fs *lockingFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { - defer fs.locked()() - return fs.FS.OpenDir(name, context) -} - -func (fs *lockingFileSystem) OnMount(nodeFs *PathNodeFs) { - defer fs.locked()() - fs.FS.OnMount(nodeFs) -} - -func (fs *lockingFileSystem) OnUnmount() { - defer fs.locked()() - fs.FS.OnUnmount() -} - -func (fs *lockingFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Access(name, mode, context) -} - -func (fs *lockingFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - defer fs.locked()() - file, code = fs.FS.Create(name, flags, mode, context) - - file = nodefs.NewLockingFile(&fs.lock, file) - return file, code -} - -func (fs *lockingFileSystem) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) { - defer fs.locked()() - return fs.FS.Utimens(name, Atime, Mtime, context) -} - -func (fs *lockingFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { - defer fs.locked()() - return fs.FS.GetXAttr(name, attr, context) -} - -func (fs *lockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - defer fs.locked()() - return fs.FS.SetXAttr(name, attr, data, flags, context) -} - -func (fs *lockingFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { - defer fs.locked()() - return fs.FS.ListXAttr(name, context) -} - -func (fs *lockingFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { - defer fs.locked()() - return fs.FS.RemoveXAttr(name, attr, context) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go deleted file mode 100644 index 68fd9f13..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback.go +++ /dev/null @@ -1,162 +0,0 @@ -package pathfs - -import ( - "io" - "log" - "os" - "path/filepath" - "syscall" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -type loopbackFileSystem struct { - // TODO - this should need default fill in. - FileSystem - Root string -} - -// A FUSE filesystem that shunts all request to an underlying file -// system. Its main purpose is to provide test coverage without -// having to build a synthetic filesystem. -func NewLoopbackFileSystem(root string) FileSystem { - return &loopbackFileSystem{ - FileSystem: NewDefaultFileSystem(), - Root: root, - } -} - -func (fs *loopbackFileSystem) OnMount(nodeFs *PathNodeFs) { -} - -func (fs *loopbackFileSystem) OnUnmount() {} - -func (fs *loopbackFileSystem) GetPath(relPath string) string { - return filepath.Join(fs.Root, relPath) -} - -func (fs *loopbackFileSystem) GetAttr(name string, context *fuse.Context) (a *fuse.Attr, code fuse.Status) { - fullPath := fs.GetPath(name) - var err error = nil - st := syscall.Stat_t{} - if name == "" { - // When GetAttr is called for the toplevel directory, we always want - // to look through symlinks. - err = syscall.Stat(fullPath, &st) - } else { - err = syscall.Lstat(fullPath, &st) - } - - if err != nil { - return nil, fuse.ToStatus(err) - } - a = &fuse.Attr{} - a.FromStat(&st) - return a, fuse.OK -} - -func (fs *loopbackFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { - // What other ways beyond O_RDONLY are there to open - // directories? - f, err := os.Open(fs.GetPath(name)) - if err != nil { - return nil, fuse.ToStatus(err) - } - want := 500 - output := make([]fuse.DirEntry, 0, want) - for { - infos, err := f.Readdir(want) - for i := range infos { - // workaround forhttps://code.google.com/p/go/issues/detail?id=5960 - if infos[i] == nil { - continue - } - n := infos[i].Name() - d := fuse.DirEntry{ - Name: n, - } - if s := fuse.ToStatT(infos[i]); s != nil { - d.Mode = uint32(s.Mode) - } else { - log.Printf("ReadDir entry %q for %q has no stat info", n, name) - } - output = append(output, d) - } - if len(infos) < want || err == io.EOF { - break - } - if err != nil { - log.Println("Readdir() returned err:", err) - break - } - } - f.Close() - - return output, fuse.OK -} - -func (fs *loopbackFileSystem) Open(name string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) { - f, err := os.OpenFile(fs.GetPath(name), int(flags), 0) - if err != nil { - return nil, fuse.ToStatus(err) - } - return nodefs.NewLoopbackFile(f), fuse.OK -} - -func (fs *loopbackFileSystem) Chmod(path string, mode uint32, context *fuse.Context) (code fuse.Status) { - err := os.Chmod(fs.GetPath(path), os.FileMode(mode)) - return fuse.ToStatus(err) -} - -func (fs *loopbackFileSystem) Chown(path string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(os.Chown(fs.GetPath(path), int(uid), int(gid))) -} - -func (fs *loopbackFileSystem) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(os.Truncate(fs.GetPath(path), int64(offset))) -} - -func (fs *loopbackFileSystem) Readlink(name string, context *fuse.Context) (out string, code fuse.Status) { - f, err := os.Readlink(fs.GetPath(name)) - return f, fuse.ToStatus(err) -} - -func (fs *loopbackFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(syscall.Mknod(fs.GetPath(name), mode, int(dev))) -} - -func (fs *loopbackFileSystem) Mkdir(path string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(os.Mkdir(fs.GetPath(path), os.FileMode(mode))) -} - -// Don't use os.Remove, it removes twice (unlink followed by rmdir). -func (fs *loopbackFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(syscall.Unlink(fs.GetPath(name))) -} - -func (fs *loopbackFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(syscall.Rmdir(fs.GetPath(name))) -} - -func (fs *loopbackFileSystem) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(os.Symlink(pointedTo, fs.GetPath(linkName))) -} - -func (fs *loopbackFileSystem) Rename(oldPath string, newPath string, context *fuse.Context) (codee fuse.Status) { - err := os.Rename(fs.GetPath(oldPath), fs.GetPath(newPath)) - return fuse.ToStatus(err) -} - -func (fs *loopbackFileSystem) Link(orig string, newName string, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(os.Link(fs.GetPath(orig), fs.GetPath(newName))) -} - -func (fs *loopbackFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.ToStatus(syscall.Access(fs.GetPath(name), mode)) -} - -func (fs *loopbackFileSystem) Create(path string, flags uint32, mode uint32, context *fuse.Context) (fuseFile nodefs.File, code fuse.Status) { - f, err := os.OpenFile(fs.GetPath(path), int(flags)|os.O_CREATE, os.FileMode(mode)) - return nodefs.NewLoopbackFile(f), fuse.ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go deleted file mode 100644 index 16e53b86..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_darwin.go +++ /dev/null @@ -1,59 +0,0 @@ -package pathfs - -import ( - "syscall" - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut { - s := syscall.Statfs_t{} - err := syscall.Statfs(fs.GetPath(name), &s) - if err == nil { - return &fuse.StatfsOut{ - Blocks: s.Blocks, - Bsize: uint32(s.Bsize), - Bfree: s.Bfree, - Bavail: s.Bavail, - Files: s.Files, - Ffree: s.Ffree, - } - } - return nil -} - -const _UTIME_NOW = ((1 << 30) - 1) -const _UTIME_OMIT = ((1 << 30) - 2) - -// timeToTimeval - Convert time.Time to syscall.Timeval -// -// Note: This does not use syscall.NsecToTimespec because -// that does not work properly for times before 1970, -// see https://github.com/golang/go/issues/12777 -func timeToTimeval(t *time.Time) syscall.Timeval { - var tv syscall.Timeval - tv.Usec = int32(t.Nanosecond() / 1000) - tv.Sec = t.Unix() - return tv -} - -// OSX does not have the utimensat syscall neded to implement this properly. -// We do our best to emulate it using futimes. -func (fs *loopbackFileSystem) Utimens(path string, a *time.Time, m *time.Time, context *fuse.Context) fuse.Status { - tv := make([]syscall.Timeval, 2) - if a == nil { - tv[0].Usec = _UTIME_OMIT - } else { - tv[0] = timeToTimeval(a) - } - - if m == nil { - tv[1].Usec = _UTIME_OMIT - } else { - tv[1] = timeToTimeval(m) - } - - err := syscall.Utimes(path, tv) - return fuse.ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go deleted file mode 100644 index 20bab223..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/loopback_linux.go +++ /dev/null @@ -1,79 +0,0 @@ -package pathfs - -import ( - "fmt" - "syscall" - "time" - - "github.com/hanwen/go-fuse/fuse" -) - -func (fs *loopbackFileSystem) StatFs(name string) *fuse.StatfsOut { - s := syscall.Statfs_t{} - err := syscall.Statfs(fs.GetPath(name), &s) - if err == nil { - return &fuse.StatfsOut{ - Blocks: s.Blocks, - Bsize: uint32(s.Bsize), - Bfree: s.Bfree, - Bavail: s.Bavail, - Files: s.Files, - Ffree: s.Ffree, - Frsize: uint32(s.Frsize), - NameLen: uint32(s.Namelen), - } - } - return nil -} - -func (fs *loopbackFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { - data, err := listXAttr(fs.GetPath(name)) - - return data, fuse.ToStatus(err) -} - -func (fs *loopbackFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { - err := sysRemovexattr(fs.GetPath(name), attr) - return fuse.ToStatus(err) -} - -func (fs *loopbackFileSystem) String() string { - return fmt.Sprintf("LoopbackFs(%s)", fs.Root) -} - -func (fs *loopbackFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { - data := make([]byte, 1024) - data, err := getXAttr(fs.GetPath(name), attr, data) - - return data, fuse.ToStatus(err) -} - -func (fs *loopbackFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - err := syscall.Setxattr(fs.GetPath(name), attr, data, flags) - return fuse.ToStatus(err) -} - -const _UTIME_NOW = ((1 << 30) - 1) -const _UTIME_OMIT = ((1 << 30) - 2) - -// Utimens - path based version of loopbackFile.Utimens() -func (fs *loopbackFileSystem) Utimens(path string, a *time.Time, m *time.Time, context *fuse.Context) (code fuse.Status) { - var ts [2]syscall.Timespec - - if a == nil { - ts[0].Nsec = _UTIME_OMIT - } else { - ts[0] = syscall.NsecToTimespec(a.UnixNano()) - ts[0].Nsec = 0 - } - - if m == nil { - ts[1].Nsec = _UTIME_OMIT - } else { - ts[1] = syscall.NsecToTimespec(m.UnixNano()) - ts[1].Nsec = 0 - } - - err := sysUtimensat(0, fs.GetPath(path), &ts, _AT_SYMLINK_NOFOLLOW) - return fuse.ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go deleted file mode 100644 index ff24d562..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/pathfs.go +++ /dev/null @@ -1,737 +0,0 @@ -package pathfs - -import ( - "fmt" - "log" - "path/filepath" - "strings" - "sync" - "time" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -// refCountedInode is used in clientInodeMap. The reference count is used to decide -// if the entry in clientInodeMap can be dropped. -type refCountedInode struct { - node *pathInode - refCount int -} - -// PathNodeFs is the file system that can translate an inode back to a -// path. The path name is then used to call into an object that has -// the FileSystem interface. -// -// Lookups (ie. FileSystem.GetAttr) may return a inode number in its -// return value. The inode number ("clientInode") is used to indicate -// linked files. -type PathNodeFs struct { - debug bool - fs FileSystem - root *pathInode - connector *nodefs.FileSystemConnector - - // protects clientInodeMap - pathLock sync.RWMutex - - // This map lists all the parent links known for a given inode number. - clientInodeMap map[uint64]*refCountedInode - - options *PathNodeFsOptions -} - -// SetDebug toggles debug information: it will log path names for -// each operation processed. -func (fs *PathNodeFs) SetDebug(dbg bool) { - fs.debug = dbg -} - -// Mount mounts a another node filesystem with the given root on the -// path. The last component of the path should not exist yet. -func (fs *PathNodeFs) Mount(path string, root nodefs.Node, opts *nodefs.Options) fuse.Status { - dir, name := filepath.Split(path) - if dir != "" { - dir = filepath.Clean(dir) - } - parent := fs.LookupNode(dir) - if parent == nil { - return fuse.ENOENT - } - return fs.connector.Mount(parent, name, root, opts) -} - -// ForgetClientInodes forgets all known information on client inodes. -func (fs *PathNodeFs) ForgetClientInodes() { - if !fs.options.ClientInodes { - return - } - fs.pathLock.Lock() - fs.clientInodeMap = map[uint64]*refCountedInode{} - fs.root.forgetClientInodes() - fs.pathLock.Unlock() -} - -// Rereads all inode numbers for all known files. -func (fs *PathNodeFs) RereadClientInodes() { - if !fs.options.ClientInodes { - return - } - fs.ForgetClientInodes() - fs.root.updateClientInodes() -} - -// UnmountNode unmounts the node filesystem with the given root. -func (fs *PathNodeFs) UnmountNode(node *nodefs.Inode) fuse.Status { - return fs.connector.Unmount(node) -} - -// UnmountNode unmounts the node filesystem with the given root. -func (fs *PathNodeFs) Unmount(path string) fuse.Status { - node := fs.Node(path) - if node == nil { - return fuse.ENOENT - } - return fs.connector.Unmount(node) -} - -// String returns a name for this file system -func (fs *PathNodeFs) String() string { - name := fs.fs.String() - if name == "defaultFileSystem" { - name = fmt.Sprintf("%T", fs.fs) - name = strings.TrimLeft(name, "*") - } - return name -} - -// Connector returns the FileSystemConnector (the bridge to the raw -// protocol) for this PathNodeFs. -func (fs *PathNodeFs) Connector() *nodefs.FileSystemConnector { - return fs.connector -} - -// Node looks up the Inode that corresponds to the given path name, or -// returns nil if not found. -func (fs *PathNodeFs) Node(name string) *nodefs.Inode { - n, rest := fs.LastNode(name) - if len(rest) > 0 { - return nil - } - return n -} - -// Like Node, but use Lookup to discover inodes we may not have yet. -func (fs *PathNodeFs) LookupNode(name string) *nodefs.Inode { - return fs.connector.LookupNode(fs.Root().Inode(), name) -} - -// Path constructs a path for the given Inode. If the file system -// implements hard links through client-inode numbers, the path may -// not be unique. -func (fs *PathNodeFs) Path(node *nodefs.Inode) string { - pNode := node.Node().(*pathInode) - return pNode.GetPath() -} - -// LastNode finds the deepest inode known corresponding to a path. The -// unknown part of the filename is also returned. -func (fs *PathNodeFs) LastNode(name string) (*nodefs.Inode, []string) { - return fs.connector.Node(fs.Root().Inode(), name) -} - -// FileNotify notifies that file contents were changed within the -// given range. Use negative offset for metadata-only invalidation, -// and zero-length for invalidating all content. -func (fs *PathNodeFs) FileNotify(path string, off int64, length int64) fuse.Status { - node, r := fs.connector.Node(fs.root.Inode(), path) - if len(r) > 0 { - return fuse.ENOENT - } - return fs.connector.FileNotify(node, off, length) -} - -// EntryNotify makes the kernel forget the entry data from the given -// name from a directory. After this call, the kernel will issue a -// new lookup request for the given name when necessary. -func (fs *PathNodeFs) EntryNotify(dir string, name string) fuse.Status { - node, rest := fs.connector.Node(fs.root.Inode(), dir) - if len(rest) > 0 { - return fuse.ENOENT - } - return fs.connector.EntryNotify(node, name) -} - -// Notify ensures that the path name is invalidates: if the inode is -// known, it issues an file content Notify, if not, an entry notify -// for the path is issued. The latter will clear out non-existence -// cache entries. -func (fs *PathNodeFs) Notify(path string) fuse.Status { - node, rest := fs.connector.Node(fs.root.Inode(), path) - if len(rest) > 0 { - return fs.connector.EntryNotify(node, rest[0]) - } - return fs.connector.FileNotify(node, 0, 0) -} - -// AllFiles returns all open files for the inode corresponding with -// the given mask. -func (fs *PathNodeFs) AllFiles(name string, mask uint32) []nodefs.WithFlags { - n := fs.Node(name) - if n == nil { - return nil - } - return n.Files(mask) -} - -// NewPathNodeFs returns a file system that translates from inodes to -// path names. -func NewPathNodeFs(fs FileSystem, opts *PathNodeFsOptions) *PathNodeFs { - root := &pathInode{} - root.fs = fs - - if opts == nil { - opts = &PathNodeFsOptions{} - } - - pfs := &PathNodeFs{ - fs: fs, - root: root, - clientInodeMap: map[uint64]*refCountedInode{}, - options: opts, - } - root.pathFs = pfs - return pfs -} - -// Root returns the root node for the path filesystem. -func (fs *PathNodeFs) Root() nodefs.Node { - return fs.root -} - -// This is a combination of dentry (entry in the file/directory and -// the inode). This structure is used to implement glue for FSes where -// there is a one-to-one mapping of paths and inodes. -type pathInode struct { - pathFs *PathNodeFs - fs FileSystem - - // This is to correctly resolve hardlinks of the underlying - // real filesystem. - clientInode uint64 - inode *nodefs.Inode -} - -func (n *pathInode) OnMount(conn *nodefs.FileSystemConnector) { - n.pathFs.connector = conn - n.pathFs.fs.OnMount(n.pathFs) -} - -func (n *pathInode) OnUnmount() { -} - -// Drop all known client inodes. Must have the treeLock. -func (n *pathInode) forgetClientInodes() { - n.clientInode = 0 - for _, ch := range n.Inode().FsChildren() { - ch.Node().(*pathInode).forgetClientInodes() - } -} - -func (fs *pathInode) Deletable() bool { - return true -} - -func (n *pathInode) Inode() *nodefs.Inode { - return n.inode -} - -func (n *pathInode) SetInode(node *nodefs.Inode) { - n.inode = node -} - -// Reread all client nodes below this node. Must run outside the treeLock. -func (n *pathInode) updateClientInodes() { - n.GetAttr(&fuse.Attr{}, nil, nil) - for _, ch := range n.Inode().FsChildren() { - ch.Node().(*pathInode).updateClientInodes() - } -} - -// GetPath returns the path relative to the mount governing this -// inode. It returns nil for mount if the file was deleted or the -// filesystem unmounted. -func (n *pathInode) GetPath() string { - if n == n.pathFs.root { - return "" - } - - pathLen := 1 - - // The simple solution is to collect names, and reverse join - // them, them, but since this is a hot path, we take some - // effort to avoid allocations. - - n.pathFs.pathLock.RLock() - walkUp := n.Inode() - - // TODO - guess depth? - segments := make([]string, 0, 10) - for { - parent, name := walkUp.Parent() - if parent == nil { - break - } - segments = append(segments, name) - pathLen += len(name) + 1 - walkUp = parent - } - pathLen-- - - pathBytes := make([]byte, 0, pathLen) - for i := len(segments) - 1; i >= 0; i-- { - pathBytes = append(pathBytes, segments[i]...) - if i > 0 { - pathBytes = append(pathBytes, '/') - } - } - n.pathFs.pathLock.RUnlock() - - path := string(pathBytes) - if n.pathFs.debug { - log.Printf("Inode = %q (%s)", path, n.fs.String()) - } - - if walkUp != n.pathFs.root.Inode() { - // This might happen if the node has been removed from - // the tree using unlink, but we are forced to run - // some file system operation, because the file is - // still opened. - - // TODO - add a deterministic disambiguating suffix. - return ".deleted" - } - - return path -} - -func (n *pathInode) OnAdd(parent *nodefs.Inode, name string) { - // TODO it would be logical to increment the clientInodeMap reference count - // here. However, as the inode number is loaded lazily, we cannot do it - // yet. -} - -func (n *pathInode) rmChild(name string) *pathInode { - childInode := n.Inode().RmChild(name) - if childInode == nil { - return nil - } - return childInode.Node().(*pathInode) -} - -func (n *pathInode) OnRemove(parent *nodefs.Inode, name string) { - if n.clientInode == 0 || !n.pathFs.options.ClientInodes || n.Inode().IsDir() { - return - } - - n.pathFs.pathLock.Lock() - r := n.pathFs.clientInodeMap[n.clientInode] - if r != nil { - r.refCount-- - if r.refCount == 0 { - delete(n.pathFs.clientInodeMap, n.clientInode) - } - } - n.pathFs.pathLock.Unlock() -} - -// setClientInode sets the inode number if has not been set yet. -// This function exists to allow lazy-loading of the inode number. -func (n *pathInode) setClientInode(ino uint64) { - if ino == 0 || n.clientInode != 0 || !n.pathFs.options.ClientInodes || n.Inode().IsDir() { - return - } - n.pathFs.pathLock.Lock() - defer n.pathFs.pathLock.Unlock() - n.clientInode = ino - n.pathFs.clientInodeMap[ino] = &refCountedInode{node: n, refCount: 1} -} - -func (n *pathInode) OnForget() { - if n.clientInode == 0 || !n.pathFs.options.ClientInodes || n.Inode().IsDir() { - return - } - n.pathFs.pathLock.Lock() - delete(n.pathFs.clientInodeMap, n.clientInode) - n.pathFs.pathLock.Unlock() -} - -//////////////////////////////////////////////////////////////// -// FS operations - -func (n *pathInode) StatFs() *fuse.StatfsOut { - return n.fs.StatFs(n.GetPath()) -} - -func (n *pathInode) Readlink(c *fuse.Context) ([]byte, fuse.Status) { - path := n.GetPath() - - val, err := n.fs.Readlink(path, c) - return []byte(val), err -} - -func (n *pathInode) Access(mode uint32, context *fuse.Context) (code fuse.Status) { - p := n.GetPath() - return n.fs.Access(p, mode, context) -} - -func (n *pathInode) GetXAttr(attribute string, context *fuse.Context) (data []byte, code fuse.Status) { - return n.fs.GetXAttr(n.GetPath(), attribute, context) -} - -func (n *pathInode) RemoveXAttr(attr string, context *fuse.Context) fuse.Status { - p := n.GetPath() - return n.fs.RemoveXAttr(p, attr, context) -} - -func (n *pathInode) SetXAttr(attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - return n.fs.SetXAttr(n.GetPath(), attr, data, flags, context) -} - -func (n *pathInode) ListXAttr(context *fuse.Context) (attrs []string, code fuse.Status) { - return n.fs.ListXAttr(n.GetPath(), context) -} - -func (n *pathInode) Flush(file nodefs.File, openFlags uint32, context *fuse.Context) (code fuse.Status) { - return file.Flush() -} - -func (n *pathInode) OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { - return n.fs.OpenDir(n.GetPath(), context) -} - -func (n *pathInode) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (*nodefs.Inode, fuse.Status) { - fullPath := filepath.Join(n.GetPath(), name) - code := n.fs.Mknod(fullPath, mode, dev, context) - var child *nodefs.Inode - if code.Ok() { - pNode := n.createChild(name, false) - child = pNode.Inode() - } - return child, code -} - -func (n *pathInode) Mkdir(name string, mode uint32, context *fuse.Context) (*nodefs.Inode, fuse.Status) { - fullPath := filepath.Join(n.GetPath(), name) - code := n.fs.Mkdir(fullPath, mode, context) - var child *nodefs.Inode - if code.Ok() { - pNode := n.createChild(name, true) - child = pNode.Inode() - } - return child, code -} - -func (n *pathInode) Unlink(name string, context *fuse.Context) (code fuse.Status) { - code = n.fs.Unlink(filepath.Join(n.GetPath(), name), context) - if code.Ok() { - n.Inode().RmChild(name) - } - return code -} - -func (n *pathInode) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - code = n.fs.Rmdir(filepath.Join(n.GetPath(), name), context) - if code.Ok() { - n.Inode().RmChild(name) - } - return code -} - -func (n *pathInode) Symlink(name string, content string, context *fuse.Context) (*nodefs.Inode, fuse.Status) { - fullPath := filepath.Join(n.GetPath(), name) - code := n.fs.Symlink(content, fullPath, context) - var child *nodefs.Inode - if code.Ok() { - pNode := n.createChild(name, false) - child = pNode.Inode() - } - return child, code -} - -func (n *pathInode) Rename(oldName string, newParent nodefs.Node, newName string, context *fuse.Context) (code fuse.Status) { - p := newParent.(*pathInode) - oldPath := filepath.Join(n.GetPath(), oldName) - newPath := filepath.Join(p.GetPath(), newName) - code = n.fs.Rename(oldPath, newPath, context) - if code.Ok() { - // The rename may have overwritten another file, remove it from the tree - p.Inode().RmChild(newName) - ch := n.Inode().RmChild(oldName) - if ch != nil { - // oldName may have been forgotten in the meantime. - p.Inode().AddChild(newName, ch) - } - } - return code -} - -func (n *pathInode) Link(name string, existingFsnode nodefs.Node, context *fuse.Context) (*nodefs.Inode, fuse.Status) { - if !n.pathFs.options.ClientInodes { - return nil, fuse.ENOSYS - } - - newPath := filepath.Join(n.GetPath(), name) - existing := existingFsnode.(*pathInode) - oldPath := existing.GetPath() - code := n.fs.Link(oldPath, newPath, context) - - var a *fuse.Attr - if code.Ok() { - a, code = n.fs.GetAttr(newPath, context) - } - - var child *nodefs.Inode - if code.Ok() { - if existing.clientInode != 0 && existing.clientInode == a.Ino { - child = existing.Inode() - n.Inode().AddChild(name, existing.Inode()) - } else { - pNode := n.createChild(name, false) - child = pNode.Inode() - pNode.clientInode = a.Ino - } - } - return child, code -} - -func (n *pathInode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, *nodefs.Inode, fuse.Status) { - var child *nodefs.Inode - fullPath := filepath.Join(n.GetPath(), name) - file, code := n.fs.Create(fullPath, flags, mode, context) - if code.Ok() { - pNode := n.createChild(name, false) - child = pNode.Inode() - } - return file, child, code -} - -func (n *pathInode) createChild(name string, isDir bool) *pathInode { - i := &pathInode{ - fs: n.fs, - pathFs: n.pathFs, - } - - n.Inode().NewChild(name, isDir, i) - - return i -} - -func (n *pathInode) Open(flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - p := n.GetPath() - file, code = n.fs.Open(p, flags, context) - if n.pathFs.debug { - file = &nodefs.WithFlags{ - File: file, - Description: n.GetPath(), - } - } - return -} - -func (n *pathInode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (node *nodefs.Inode, code fuse.Status) { - fullPath := filepath.Join(n.GetPath(), name) - fi, code := n.fs.GetAttr(fullPath, context) - if code.Ok() { - node = n.findChild(fi, name, fullPath).Inode() - *out = *fi - } - - return node, code -} - -func (n *pathInode) findChild(fi *fuse.Attr, name string, fullPath string) (out *pathInode) { - if fi.Ino > 0 { - n.pathFs.pathLock.RLock() - r := n.pathFs.clientInodeMap[fi.Ino] - if r != nil { - out = r.node - r.refCount++ - if fi.Nlink == 1 { - log.Printf("Found linked inode, but Nlink == 1, ino=%d, fullPath=%q", fi.Ino, fullPath) - } - } - n.pathFs.pathLock.RUnlock() - } - - if out == nil { - out = n.createChild(name, fi.IsDir()) - out.setClientInode(fi.Ino) - } else { - n.Inode().AddChild(name, out.Inode()) - } - return out -} - -func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) { - var fi *fuse.Attr - if file == nil { - // Linux currently (tested on v4.4) does not pass a file descriptor for - // fstat. To be able to stat a deleted file we have to find ourselves - // an open fd. - file = n.Inode().AnyFile() - } - - if file != nil { - code = file.GetAttr(out) - } - - if file == nil || code == fuse.ENOSYS || code == fuse.EBADF { - fi, code = n.fs.GetAttr(n.GetPath(), context) - } - - if fi != nil { - n.setClientInode(fi.Ino) - } - - if fi != nil && !fi.IsDir() && fi.Nlink == 0 { - fi.Nlink = 1 - } - - if fi != nil { - *out = *fi - } - return code -} - -func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context) (code fuse.Status) { - // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor - // to FUSE for fchmod. We still check because that may change in the future. - if file != nil { - code = file.Chmod(perms) - if code != fuse.ENOSYS { - return code - } - } - - files := n.Inode().Files(fuse.O_ANYWRITE) - for _, f := range files { - // TODO - pass context - code = f.Chmod(perms) - if code.Ok() { - return - } - } - - if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { - code = n.fs.Chmod(n.GetPath(), perms, context) - } - return code -} - -func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor - // to FUSE for fchown. We still check because it may change in the future. - if file != nil { - code = file.Chown(uid, gid) - if code != fuse.ENOSYS { - return code - } - } - - files := n.Inode().Files(fuse.O_ANYWRITE) - for _, f := range files { - // TODO - pass context - code = f.Chown(uid, gid) - if code.Ok() { - return code - } - } - if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { - // TODO - can we get just FATTR_GID but not FATTR_UID ? - code = n.fs.Chown(n.GetPath(), uid, gid, context) - } - return code -} - -func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Context) (code fuse.Status) { - // A file descriptor was passed in AND the filesystem implements the - // operation on the file handle. This the common case for ftruncate. - if file != nil { - code = file.Truncate(size) - if code != fuse.ENOSYS { - return code - } - } - - files := n.Inode().Files(fuse.O_ANYWRITE) - for _, f := range files { - // TODO - pass context - code = f.Truncate(size) - if code.Ok() { - return code - } - } - if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { - code = n.fs.Truncate(n.GetPath(), size, context) - } - return code -} - -func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time, context *fuse.Context) (code fuse.Status) { - // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor - // to FUSE for futimens. We still check because it may change in the future. - if file != nil { - code = file.Utimens(atime, mtime) - if code != fuse.ENOSYS { - return code - } - } - - files := n.Inode().Files(fuse.O_ANYWRITE) - for _, f := range files { - // TODO - pass context - code = f.Utimens(atime, mtime) - if code.Ok() { - return code - } - } - if len(files) == 0 || code == fuse.ENOSYS || code == fuse.EBADF { - code = n.fs.Utimens(n.GetPath(), atime, mtime, context) - } - return code -} - -func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) { - if file != nil { - code = file.Allocate(off, size, mode) - if code.Ok() { - return code - } - } - - files := n.Inode().Files(fuse.O_ANYWRITE) - for _, f := range files { - // TODO - pass context - code = f.Allocate(off, size, mode) - if code.Ok() { - return code - } - } - - return code -} - -func (n *pathInode) Read(file nodefs.File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) { - if file != nil { - return file.Read(dest, off) - } - return nil, fuse.ENOSYS -} - -func (n *pathInode) Write(file nodefs.File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { - if file != nil { - return file.Write(data, off) - } - return 0, fuse.ENOSYS -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go deleted file mode 100644 index 9b575c04..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/prefixfs.go +++ /dev/null @@ -1,128 +0,0 @@ -package pathfs - -import ( - "fmt" - "path/filepath" - "time" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -// PrefixFileSystem adds a path prefix to incoming calls. -type prefixFileSystem struct { - FileSystem FileSystem - Prefix string -} - -func NewPrefixFileSystem(fs FileSystem, prefix string) FileSystem { - return &prefixFileSystem{fs, prefix} -} - -func (fs *prefixFileSystem) SetDebug(debug bool) { - fs.FileSystem.SetDebug(debug) -} - -func (fs *prefixFileSystem) prefixed(n string) string { - return filepath.Join(fs.Prefix, n) -} - -func (fs *prefixFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { - return fs.FileSystem.GetAttr(fs.prefixed(name), context) -} - -func (fs *prefixFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { - return fs.FileSystem.Readlink(fs.prefixed(name), context) -} - -func (fs *prefixFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { - return fs.FileSystem.Mknod(fs.prefixed(name), mode, dev, context) -} - -func (fs *prefixFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { - return fs.FileSystem.Mkdir(fs.prefixed(name), mode, context) -} - -func (fs *prefixFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Unlink(fs.prefixed(name), context) -} - -func (fs *prefixFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Rmdir(fs.prefixed(name), context) -} - -func (fs *prefixFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Symlink(value, fs.prefixed(linkName), context) -} - -func (fs *prefixFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Rename(fs.prefixed(oldName), fs.prefixed(newName), context) -} - -func (fs *prefixFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Link(fs.prefixed(oldName), fs.prefixed(newName), context) -} - -func (fs *prefixFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Chmod(fs.prefixed(name), mode, context) -} - -func (fs *prefixFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Chown(fs.prefixed(name), uid, gid, context) -} - -func (fs *prefixFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Truncate(fs.prefixed(name), offset, context) -} - -func (fs *prefixFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - return fs.FileSystem.Open(fs.prefixed(name), flags, context) -} - -func (fs *prefixFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { - return fs.FileSystem.OpenDir(fs.prefixed(name), context) -} - -func (fs *prefixFileSystem) OnMount(nodeFs *PathNodeFs) { - fs.FileSystem.OnMount(nodeFs) -} - -func (fs *prefixFileSystem) OnUnmount() { - fs.FileSystem.OnUnmount() -} - -func (fs *prefixFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Access(fs.prefixed(name), mode, context) -} - -func (fs *prefixFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - return fs.FileSystem.Create(fs.prefixed(name), flags, mode, context) -} - -func (fs *prefixFileSystem) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Utimens(fs.prefixed(name), Atime, Mtime, context) -} - -func (fs *prefixFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { - return fs.FileSystem.GetXAttr(fs.prefixed(name), attr, context) -} - -func (fs *prefixFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - return fs.FileSystem.SetXAttr(fs.prefixed(name), attr, data, flags, context) -} - -func (fs *prefixFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { - return fs.FileSystem.ListXAttr(fs.prefixed(name), context) -} - -func (fs *prefixFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { - return fs.FileSystem.RemoveXAttr(fs.prefixed(name), attr, context) -} - -func (fs *prefixFileSystem) String() string { - return fmt.Sprintf("prefixFileSystem(%s,%s)", fs.FileSystem.String(), fs.Prefix) -} - -func (fs *prefixFileSystem) StatFs(name string) *fuse.StatfsOut { - return fs.FileSystem.StatFs(fs.prefixed(name)) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go deleted file mode 100644 index ea3dddfe..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/readonlyfs.go +++ /dev/null @@ -1,119 +0,0 @@ -package pathfs - -import ( - "fmt" - "time" - - "github.com/hanwen/go-fuse/fuse" - "github.com/hanwen/go-fuse/fuse/nodefs" -) - -// NewReadonlyFileSystem returns a wrapper that only exposes read-only -// operations. -func NewReadonlyFileSystem(fs FileSystem) FileSystem { - return &readonlyFileSystem{fs} -} - -type readonlyFileSystem struct { - FileSystem -} - -func (fs *readonlyFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) { - return fs.FileSystem.GetAttr(name, context) -} - -func (fs *readonlyFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) { - return fs.FileSystem.Readlink(name, context) -} - -func (fs *readonlyFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - if flags&fuse.O_ANYWRITE != 0 { - return nil, fuse.EPERM - } - file, code = fs.FileSystem.Open(name, flags, context) - return nodefs.NewReadOnlyFile(file), code -} - -func (fs *readonlyFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) { - return fs.FileSystem.OpenDir(name, context) -} - -func (fs *readonlyFileSystem) OnMount(nodeFs *PathNodeFs) { - fs.FileSystem.OnMount(nodeFs) -} - -func (fs *readonlyFileSystem) OnUnmount() { - fs.FileSystem.OnUnmount() -} - -func (fs *readonlyFileSystem) String() string { - return fmt.Sprintf("readonlyFileSystem(%v)", fs.FileSystem) -} - -func (fs *readonlyFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) { - return fs.FileSystem.Access(name, mode, context) -} - -func (fs *readonlyFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { - return nil, fuse.EPERM -} - -func (fs *readonlyFileSystem) Utimens(name string, atime *time.Time, ctime *time.Time, context *fuse.Context) (code fuse.Status) { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) { - return fs.FileSystem.GetXAttr(name, attr, context) -} - -func (fs *readonlyFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status { - return fuse.EPERM -} - -func (fs *readonlyFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) { - return fs.FileSystem.ListXAttr(name, context) -} - -func (fs *readonlyFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { - return fuse.EPERM -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go deleted file mode 100644 index 62a05ec5..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/pathfs/syscall_linux.go +++ /dev/null @@ -1,140 +0,0 @@ -package pathfs - -import ( - "bytes" - "syscall" - "unsafe" -) - -var _zero uintptr - -func getXAttr(path string, attr string, dest []byte) (value []byte, err error) { - sz, err := sysGetxattr(path, attr, dest) - for sz > cap(dest) && err == nil { - dest = make([]byte, sz) - sz, err = sysGetxattr(path, attr, dest) - } - - if err != nil { - return nil, err - } - - return dest[:sz], err -} - -func listXAttr(path string) (attributes []string, err error) { - dest := make([]byte, 0) - sz, err := sysListxattr(path, dest) - if err != nil { - return nil, err - } - - for sz > cap(dest) && err == nil { - dest = make([]byte, sz) - sz, err = sysListxattr(path, dest) - } - - if sz == 0 { - return nil, err - } - - // -1 to drop the final empty slice. - dest = dest[:sz-1] - attributesBytes := bytes.Split(dest, []byte{0}) - attributes = make([]string, len(attributesBytes)) - for i, v := range attributesBytes { - attributes[i] = string(v) - } - return attributes, err -} - -// Below is cut & paste from std lib syscall, so gccgo 4.8.1 can -// compile this too. -func sysGetxattr(path string, attr string, dest []byte) (sz int, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(path) - if err != nil { - return - } - var _p1 *byte - _p1, err = syscall.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 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) - sz = int(r0) - if e1 != 0 { - err = e1 - } - return -} - -func sysRemovexattr(path string, attr string) (err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(path) - if err != nil { - return - } - var _p1 *byte - _p1, err = syscall.BytePtrFromString(attr) - if err != nil { - return - } - _, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - if e1 != 0 { - err = e1 - } - return -} - -func sysListxattr(path string, dest []byte) (sz int, err error) { - var _p0 *byte - _p0, err = syscall.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.Syscall(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) - sz = int(r0) - if e1 != 0 { - err = e1 - } - return -} - -func sysSetxattr(path string, attr string, val []byte, flag int) error { - return syscall.Setxattr(path, attr, val, flag) -} - -const _AT_SYMLINK_NOFOLLOW = 0x100 - -// Linux kernel syscall utimensat(2) -// -// Needed to implement SetAttr on symlinks correctly as only utimensat provides -// AT_SYMLINK_NOFOLLOW. -func sysUtimensat(dirfd int, pathname string, times *[2]syscall.Timespec, flags int) (err error) { - - // Null-terminated version of pathname - p0, err := syscall.BytePtrFromString(pathname) - if err != nil { - return err - } - - _, _, e1 := syscall.Syscall6(syscall.SYS_UTIMENSAT, - uintptr(dirfd), uintptr(unsafe.Pointer(p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) - if e1 != 0 { - err = syscall.Errno(e1) - } - return -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/print.go b/vendor/github.com/hanwen/go-fuse/fuse/print.go deleted file mode 100644 index 29e12b0b..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/print.go +++ /dev/null @@ -1,246 +0,0 @@ -package fuse - -import ( - "fmt" - "os" - "strings" - "syscall" -) - -var initFlagNames map[int64]string -var releaseFlagNames map[int64]string -var OpenFlagNames map[int64]string -var FuseOpenFlagNames map[int64]string -var accessFlagName map[int64]string -var writeFlagNames map[int64]string -var readFlagNames map[int64]string - -func init() { - writeFlagNames = map[int64]string{ - WRITE_CACHE: "CACHE", - WRITE_LOCKOWNER: "LOCKOWNER", - } - readFlagNames = map[int64]string{ - READ_LOCKOWNER: "LOCKOWNER", - } - initFlagNames = map[int64]string{ - CAP_ASYNC_READ: "ASYNC_READ", - CAP_POSIX_LOCKS: "POSIX_LOCKS", - CAP_FILE_OPS: "FILE_OPS", - CAP_ATOMIC_O_TRUNC: "ATOMIC_O_TRUNC", - CAP_EXPORT_SUPPORT: "EXPORT_SUPPORT", - CAP_BIG_WRITES: "BIG_WRITES", - CAP_DONT_MASK: "DONT_MASK", - CAP_SPLICE_WRITE: "SPLICE_WRITE", - CAP_SPLICE_MOVE: "SPLICE_MOVE", - CAP_SPLICE_READ: "SPLICE_READ", - CAP_FLOCK_LOCKS: "FLOCK_LOCKS", - CAP_IOCTL_DIR: "IOCTL_DIR", - CAP_AUTO_INVAL_DATA: "AUTO_INVAL_DATA", - CAP_READDIRPLUS: "READDIRPLUS", - CAP_READDIRPLUS_AUTO: "READDIRPLUS_AUTO", - CAP_ASYNC_DIO: "ASYNC_DIO", - CAP_WRITEBACK_CACHE: "WRITEBACK_CACHE", - CAP_NO_OPEN_SUPPORT: "NO_OPEN_SUPPORT", - } - releaseFlagNames = map[int64]string{ - RELEASE_FLUSH: "FLUSH", - } - OpenFlagNames = map[int64]string{ - int64(os.O_WRONLY): "WRONLY", - int64(os.O_RDWR): "RDWR", - int64(os.O_APPEND): "APPEND", - int64(syscall.O_ASYNC): "ASYNC", - int64(os.O_CREATE): "CREAT", - int64(os.O_EXCL): "EXCL", - int64(syscall.O_NOCTTY): "NOCTTY", - int64(syscall.O_NONBLOCK): "NONBLOCK", - int64(os.O_SYNC): "SYNC", - int64(os.O_TRUNC): "TRUNC", - - int64(syscall.O_CLOEXEC): "CLOEXEC", - int64(syscall.O_DIRECTORY): "DIRECTORY", - } - FuseOpenFlagNames = map[int64]string{ - FOPEN_DIRECT_IO: "DIRECT", - FOPEN_KEEP_CACHE: "CACHE", - FOPEN_NONSEEKABLE: "NONSEEK", - } - accessFlagName = map[int64]string{ - X_OK: "x", - W_OK: "w", - R_OK: "r", - } - -} - -func FlagString(names map[int64]string, fl int64, def string) string { - s := []string{} - for k, v := range names { - if fl&k != 0 { - s = append(s, v) - fl ^= k - } - } - if len(s) == 0 && def != "" { - s = []string{def} - } - if fl != 0 { - s = append(s, fmt.Sprintf("0x%x", fl)) - } - - return strings.Join(s, ",") -} - -func (me *ForgetIn) string() string { - return fmt.Sprintf("{Nlookup=%d}", me.Nlookup) -} - -func (me *_BatchForgetIn) string() string { - return fmt.Sprintf("{Count=%d}", me.Count) -} - -func (me *MkdirIn) string() string { - return fmt.Sprintf("{0%o (0%o)}", me.Mode, me.Umask) -} - -func (me *RenameIn) string() string { - return fmt.Sprintf("{%d}", me.Newdir) -} - -func (me *SetAttrIn) string() string { - s := []string{} - if me.Valid&FATTR_MODE != 0 { - s = append(s, fmt.Sprintf("mode 0%o", me.Mode)) - } - if me.Valid&FATTR_UID != 0 { - s = append(s, fmt.Sprintf("uid %d", me.Uid)) - } - if me.Valid&FATTR_GID != 0 { - s = append(s, fmt.Sprintf("uid %d", me.Gid)) - } - if me.Valid&FATTR_SIZE != 0 { - s = append(s, fmt.Sprintf("size %d", me.Size)) - } - if me.Valid&FATTR_ATIME != 0 { - s = append(s, fmt.Sprintf("atime %d.%09d", me.Atime, me.Atimensec)) - } - if me.Valid&FATTR_MTIME != 0 { - s = append(s, fmt.Sprintf("mtime %d.%09d", me.Mtime, me.Mtimensec)) - } - if me.Valid&FATTR_FH != 0 { - s = append(s, fmt.Sprintf("fh %d", me.Fh)) - } - // TODO - FATTR_ATIME_NOW = (1 << 7), FATTR_MTIME_NOW = (1 << 8), FATTR_LOCKOWNER = (1 << 9) - return fmt.Sprintf("{%s}", strings.Join(s, ", ")) -} - -func (me *ReleaseIn) string() string { - return fmt.Sprintf("{Fh %d %s %s L%d}", - me.Fh, FlagString(OpenFlagNames, int64(me.Flags), ""), - FlagString(releaseFlagNames, int64(me.ReleaseFlags), ""), - me.LockOwner) -} - -func (me *OpenIn) string() string { - return fmt.Sprintf("{%s}", FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY")) -} - -func (me *OpenOut) string() string { - return fmt.Sprintf("{Fh %d %s}", me.Fh, - FlagString(FuseOpenFlagNames, int64(me.OpenFlags), "")) -} - -func (me *InitIn) string() string { - return fmt.Sprintf("{%d.%d Ra 0x%x %s}", - me.Major, me.Minor, me.MaxReadAhead, - FlagString(initFlagNames, int64(me.Flags), "")) -} - -func (me *InitOut) string() string { - return fmt.Sprintf("{%d.%d Ra 0x%x %s %d/%d Wr 0x%x Tg 0x%x}", - me.Major, me.Minor, me.MaxReadAhead, - FlagString(initFlagNames, int64(me.Flags), ""), - me.CongestionThreshold, me.MaxBackground, me.MaxWrite, - me.TimeGran) -} - -func (s *FsyncIn) string() string { - return fmt.Sprintf("{Fh %d Flags %x}", s.Fh, s.FsyncFlags) -} - -func (me *SetXAttrIn) string() string { - return fmt.Sprintf("{sz %d f%o}", me.Size, me.Flags) -} - -func (me *GetXAttrIn) string() string { - return fmt.Sprintf("{sz %d}", me.Size) -} - -func (me *GetXAttrOut) string() string { - return fmt.Sprintf("{sz %d}", me.Size) -} - -func (me *AccessIn) string() string { - return fmt.Sprintf("{%s}", FlagString(accessFlagName, int64(me.Mask), "")) -} - -func (me *FlushIn) string() string { - return fmt.Sprintf("{Fh %d}", me.Fh) -} - -func (me *AttrOut) string() string { - return fmt.Sprintf( - "{A%d.%09d %v}", - me.AttrValid, me.AttrValidNsec, &me.Attr) -} - -// Returned by LOOKUP -func (me *EntryOut) string() string { - return fmt.Sprintf("{NodeId: %d Generation=%d EntryValid=%d.%03d AttrValid=%d.%03d Attr=%v}", - me.NodeId, me.Generation, me.EntryValid, me.EntryValidNsec/1000000, - me.AttrValid, me.AttrValidNsec/1000000, &me.Attr) -} - -func (me *CreateOut) string() string { - return fmt.Sprintf("{NodeId: %d Generation=%d %v %v}", me.NodeId, me.Generation, &me.EntryOut, &me.OpenOut) -} - -func (me *StatfsOut) string() string { - return fmt.Sprintf( - "{blocks (%d,%d)/%d files %d/%d bs%d nl%d frs%d}", - me.Bfree, me.Bavail, me.Blocks, me.Ffree, me.Files, - me.Bsize, me.NameLen, me.Frsize) -} - -func (o *NotifyInvalEntryOut) string() string { - return fmt.Sprintf("{parent %d sz %d}", o.Parent, o.NameLen) -} - -func (o *NotifyInvalInodeOut) string() string { - return fmt.Sprintf("{ino %d off %d sz %d}", o.Ino, o.Off, o.Length) -} - -func (o *NotifyInvalDeleteOut) string() string { - return fmt.Sprintf("{parent %d ch %d sz %d}", o.Parent, o.Child, o.NameLen) -} - -func (f *FallocateIn) string() string { - return fmt.Sprintf("{Fh %d off %d sz %d mod 0%o}", - f.Fh, f.Offset, f.Length, f.Mode) -} - -func (f *LinkIn) string() string { - return fmt.Sprintf("{Oldnodeid: %d}", f.Oldnodeid) -} - -// Print pretty prints FUSE data types for kernel communication -func Print(obj interface{}) string { - t, ok := obj.(interface { - string() string - }) - if ok { - return t.string() - } - return fmt.Sprintf("%T: %v", obj, obj) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go deleted file mode 100644 index 16a9d6e3..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/print_darwin.go +++ /dev/null @@ -1,50 +0,0 @@ -package fuse - -import ( - "fmt" -) - -func init() { - initFlagNames[CAP_XTIMES] = "XTIMES" - initFlagNames[CAP_VOL_RENAME] = "VOL_RENAME" - initFlagNames[CAP_CASE_INSENSITIVE] = "CASE_INSENSITIVE" -} - -func (a *Attr) string() string { - return fmt.Sprintf( - "{M0%o SZ=%d L=%d "+ - "%d:%d "+ - "%d %d:%d "+ - "A %d.%09d "+ - "M %d.%09d "+ - "C %d.%09d}", - a.Mode, a.Size, a.Nlink, - a.Uid, a.Gid, - a.Blocks, - a.Rdev, a.Ino, a.Atime, a.Atimensec, a.Mtime, a.Mtimensec, - a.Ctime, a.Ctimensec) -} - -func (me *CreateIn) string() string { - return fmt.Sprintf( - "{0%o [%s]}", me.Mode, - FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY")) -} - -func (me *GetAttrIn) string() string { return "" } - -func (me *MknodIn) string() string { - return fmt.Sprintf("{0%o, %d}", me.Mode, me.Rdev) -} - -func (me *ReadIn) string() string { - return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", - me.Fh, me.Offset, me.Size, - FlagString(readFlagNames, int64(me.ReadFlags), "")) -} - -func (me *WriteIn) string() string { - return fmt.Sprintf("{Fh %d off %d sz %d %s}", - me.Fh, me.Offset, me.Size, - FlagString(writeFlagNames, int64(me.WriteFlags), "")) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/print_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/print_linux.go deleted file mode 100644 index 2b9f26f6..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/print_linux.go +++ /dev/null @@ -1,58 +0,0 @@ -package fuse - -import ( - "fmt" - "syscall" -) - -func init() { - OpenFlagNames[syscall.O_DIRECT] = "DIRECT" - OpenFlagNames[syscall.O_LARGEFILE] = "LARGEFILE" - OpenFlagNames[syscall_O_NOATIME] = "NOATIME" - -} - -func (a *Attr) string() string { - return fmt.Sprintf( - "{M0%o SZ=%d L=%d "+ - "%d:%d "+ - "B%d*%d i%d:%d "+ - "A %d.%09d "+ - "M %d.%09d "+ - "C %d.%09d}", - a.Mode, a.Size, a.Nlink, - a.Uid, a.Gid, - a.Blocks, a.Blksize, - a.Rdev, a.Ino, a.Atime, a.Atimensec, a.Mtime, a.Mtimensec, - a.Ctime, a.Ctimensec) -} - -func (me *CreateIn) string() string { - return fmt.Sprintf( - "{0%o [%s] (0%o)}", me.Mode, - FlagString(OpenFlagNames, int64(me.Flags), "O_RDONLY"), me.Umask) -} - -func (me *GetAttrIn) string() string { - return fmt.Sprintf("{Fh %d}", me.Fh_) -} - -func (me *MknodIn) string() string { - return fmt.Sprintf("{0%o (0%o), %d}", me.Mode, me.Umask, me.Rdev) -} - -func (me *ReadIn) string() string { - return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", - me.Fh, me.Offset, me.Size, - FlagString(readFlagNames, int64(me.ReadFlags), ""), - me.LockOwner, - FlagString(OpenFlagNames, int64(me.Flags), "RDONLY")) -} - -func (me *WriteIn) string() string { - return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", - me.Fh, me.Offset, me.Size, - FlagString(writeFlagNames, int64(me.WriteFlags), ""), - me.LockOwner, - FlagString(OpenFlagNames, int64(me.Flags), "RDONLY")) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/read.go b/vendor/github.com/hanwen/go-fuse/fuse/read.go deleted file mode 100644 index 60304b5e..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/read.go +++ /dev/null @@ -1,71 +0,0 @@ -package fuse - -import ( - "io" - "syscall" -) - -// ReadResultData is the read return for returning bytes directly. -type readResultData struct { - // Raw bytes for the read. - Data []byte -} - -func (r *readResultData) Size() int { - return len(r.Data) -} - -func (r *readResultData) Done() { -} - -func (r *readResultData) Bytes(buf []byte) ([]byte, Status) { - return r.Data, OK -} - -func ReadResultData(b []byte) ReadResult { - return &readResultData{b} -} - -func ReadResultFd(fd uintptr, off int64, sz int) ReadResult { - return &readResultFd{fd, off, sz} -} - -// ReadResultFd is the read return for zero-copy file data. -type readResultFd struct { - // Splice from the following file. - Fd uintptr - - // Offset within Fd, or -1 to use current offset. - Off int64 - - // Size of data to be loaded. Actual data available may be - // less at the EOF. - Sz int -} - -// Reads raw bytes from file descriptor if necessary, using the passed -// buffer as storage. -func (r *readResultFd) Bytes(buf []byte) ([]byte, Status) { - sz := r.Sz - if len(buf) < sz { - sz = len(buf) - } - - n, err := syscall.Pread(int(r.Fd), buf[:sz], r.Off) - if err == io.EOF { - err = nil - } - - if n < 0 { - n = 0 - } - - return buf[:n], ToStatus(err) -} - -func (r *readResultFd) Size() int { - return r.Sz -} - -func (r *readResultFd) Done() { -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/request.go b/vendor/github.com/hanwen/go-fuse/fuse/request.go deleted file mode 100644 index c9768aca..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/request.go +++ /dev/null @@ -1,213 +0,0 @@ -package fuse - -import ( - "bytes" - "fmt" - "log" - "strings" - "time" - "unsafe" -) - -var sizeOfOutHeader = unsafe.Sizeof(OutHeader{}) -var zeroOutBuf [outputHeaderSize]byte - -type request struct { - inputBuf []byte - - // These split up inputBuf. - inHeader *InHeader // generic header - inData unsafe.Pointer // per op data - arg []byte // flat data. - - filenames []string // filename arguments - - // Unstructured data, a pointer to the relevant XxxxOut struct. - outData unsafe.Pointer - status Status - flatData []byte - fdData *readResultFd - - // In case of read, keep read result here so we can call - // Done() on it. - readResult ReadResult - - // Start timestamp for timing info. - startTime time.Time - - // All information pertaining to opcode of this request. - handler *operationHandler - - // Request storage. For large inputs and outputs, use data - // obtained through bufferpool. - bufferPoolInputBuf []byte - bufferPoolOutputBuf []byte - - // For small pieces of data, we use the following inlines - // arrays: - // - // Output header and structured data. - outBuf [outputHeaderSize]byte - - // Input, if small enough to fit here. - smallInputBuf [128]byte - - context Context -} - -func (r *request) clear() { - r.inputBuf = nil - r.inHeader = nil - r.inData = nil - r.arg = nil - r.filenames = nil - r.outData = nil - r.status = OK - r.flatData = nil - r.fdData = nil - r.startTime = time.Time{} - r.handler = nil - r.readResult = nil -} - -func (r *request) InputDebug() string { - val := " " - if r.handler.DecodeIn != nil { - val = fmt.Sprintf(" data: %v ", Print(r.handler.DecodeIn(r.inData))) - } - - names := "" - if r.filenames != nil { - names = fmt.Sprintf("names: %v", r.filenames) - } - - if len(r.arg) > 0 { - names += fmt.Sprintf(" %d bytes", len(r.arg)) - } - - return fmt.Sprintf("Dispatch %d: %s, NodeId: %v.%v%v", - r.inHeader.Unique, operationName(r.inHeader.Opcode), - r.inHeader.NodeId, val, names) -} - -func (r *request) OutputDebug() string { - var dataStr string - if r.handler.DecodeOut != nil && r.outData != nil { - dataStr = Print(r.handler.DecodeOut(r.outData)) - } - - max := 1024 - if len(dataStr) > max { - dataStr = dataStr[:max] + fmt.Sprintf(" ...trimmed") - } - - flatStr := "" - if r.flatDataSize() > 0 { - if r.handler.FileNameOut { - s := strings.TrimRight(string(r.flatData), "\x00") - flatStr = fmt.Sprintf(" %q", s) - } else { - spl := "" - if r.fdData != nil { - spl = " (fd data)" - } - flatStr = fmt.Sprintf(" %d bytes data%s\n", r.flatDataSize(), spl) - } - } - - return fmt.Sprintf("Serialize %d: %s code: %v value: %v%v", - r.inHeader.Unique, operationName(r.inHeader.Opcode), r.status, - dataStr, flatStr) -} - -// setInput returns true if it takes ownership of the argument, false if not. -func (r *request) setInput(input []byte) bool { - if len(input) < len(r.smallInputBuf) { - copy(r.smallInputBuf[:], input) - r.inputBuf = r.smallInputBuf[:len(input)] - return false - } - r.inputBuf = input - r.bufferPoolInputBuf = input[:cap(input)] - - return true -} - -func (r *request) parse() { - inHSize := int(unsafe.Sizeof(InHeader{})) - if len(r.inputBuf) < inHSize { - log.Printf("Short read for input header: %v", r.inputBuf) - return - } - - r.inHeader = (*InHeader)(unsafe.Pointer(&r.inputBuf[0])) - r.arg = r.inputBuf[:] - - r.handler = getHandler(r.inHeader.Opcode) - if r.handler == nil { - log.Printf("Unknown opcode %d", r.inHeader.Opcode) - r.status = ENOSYS - return - } - - if len(r.arg) < int(r.handler.InputSize) { - log.Printf("Short read for %v: %v", operationName(r.inHeader.Opcode), r.arg) - r.status = EIO - return - } - - if r.handler.InputSize > 0 { - r.inData = unsafe.Pointer(&r.arg[0]) - r.arg = r.arg[r.handler.InputSize:] - } else { - r.arg = r.arg[inHSize:] - } - - count := r.handler.FileNames - if count > 0 { - if count == 1 { - r.filenames = []string{string(r.arg[:len(r.arg)-1])} - } else { - names := bytes.SplitN(r.arg[:len(r.arg)-1], []byte{0}, count) - r.filenames = make([]string, len(names)) - for i, n := range names { - r.filenames[i] = string(n) - } - if len(names) != count { - log.Println("filename argument mismatch", names, count) - r.status = EIO - } - } - } - - copy(r.outBuf[:r.handler.OutputSize+sizeOfOutHeader], - zeroOutBuf[:r.handler.OutputSize+sizeOfOutHeader]) - r.outData = unsafe.Pointer(&r.outBuf[sizeOfOutHeader]) -} - -func (r *request) serializeHeader(dataSize int) (header []byte) { - dataLength := r.handler.OutputSize - if r.outData == nil || r.status > OK { - dataLength = 0 - } - - sizeOfOutHeader := unsafe.Sizeof(OutHeader{}) - header = r.outBuf[:sizeOfOutHeader+dataLength] - o := (*OutHeader)(unsafe.Pointer(&header[0])) - o.Unique = r.inHeader.Unique - o.Status = int32(-r.status) - o.Length = uint32( - int(sizeOfOutHeader) + int(dataLength) + dataSize) - - var asSlice []byte - toSlice(&asSlice, r.outData, dataLength) - copy(header[sizeOfOutHeader:], asSlice) - return header -} - -func (r *request) flatDataSize() int { - if r.fdData != nil { - return r.fdData.Size() - } - return len(r.flatData) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go deleted file mode 100644 index c9202379..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/request_darwin.go +++ /dev/null @@ -1,9 +0,0 @@ -package fuse - -const outputHeaderSize = 200 - -const ( - _FUSE_KERNEL_VERSION = 7 - _MINIMUM_MINOR_VERSION = 8 - _OUR_MINOR_VERSION = 8 -) diff --git a/vendor/github.com/hanwen/go-fuse/fuse/request_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/request_linux.go deleted file mode 100644 index b7d62652..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/request_linux.go +++ /dev/null @@ -1,9 +0,0 @@ -package fuse - -const outputHeaderSize = 160 - -const ( - _FUSE_KERNEL_VERSION = 7 - _MINIMUM_MINOR_VERSION = 12 - _OUR_MINOR_VERSION = 23 -) diff --git a/vendor/github.com/hanwen/go-fuse/fuse/server.go b/vendor/github.com/hanwen/go-fuse/fuse/server.go deleted file mode 100644 index cc597c3e..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/server.go +++ /dev/null @@ -1,519 +0,0 @@ -package fuse - -import ( - "fmt" - "log" - "os" - "path/filepath" - "runtime" - "strings" - "sync" - "syscall" - "time" - "unsafe" -) - -const ( - // The kernel caps writes at 128k. - MAX_KERNEL_WRITE = 128 * 1024 -) - -// Server contains the logic for reading from the FUSE device and -// translating it to RawFileSystem interface calls. -type Server struct { - // Empty if unmounted. - mountPoint string - fileSystem RawFileSystem - - // writeMu serializes close and notify writes - writeMu sync.Mutex - - // I/O with kernel and daemon. - mountFd int - - // Dump debug info onto stdout. - debug bool - - latencies LatencyMap - - opts *MountOptions - - started chan struct{} - - // Pool for request structs. - reqPool sync.Pool - - // Pool for raw requests data - readPool sync.Pool - reqMu sync.Mutex - reqReaders int - kernelSettings InitIn - - singleReader bool - canSplice bool - loops sync.WaitGroup -} - -func (ms *Server) SetDebug(dbg bool) { - ms.debug = dbg -} - -// KernelSettings returns the Init message from the kernel, so -// filesystems can adapt to availability of features of the kernel -// driver. -func (ms *Server) KernelSettings() InitIn { - ms.reqMu.Lock() - s := ms.kernelSettings - ms.reqMu.Unlock() - - return s -} - -const _MAX_NAME_LEN = 20 - -// This type may be provided for recording latencies of each FUSE -// operation. -type LatencyMap interface { - Add(name string, dt time.Duration) -} - -// RecordLatencies switches on collection of timing for each request -// coming from the kernel.P assing a nil argument switches off the -func (ms *Server) RecordLatencies(l LatencyMap) { - ms.latencies = l -} - -// Unmount calls fusermount -u on the mount. This has the effect of -// shutting down the filesystem. After the Server is unmounted, it -// should be discarded. -func (ms *Server) Unmount() (err error) { - if ms.mountPoint == "" { - return nil - } - delay := time.Duration(0) - for try := 0; try < 5; try++ { - err = unmount(ms.mountPoint) - if err == nil { - break - } - - // Sleep for a bit. This is not pretty, but there is - // no way we can be certain that the kernel thinks all - // open files have already been closed. - delay = 2*delay + 5*time.Millisecond - time.Sleep(delay) - } - if err != nil { - return - } - // Wait for event loops to exit. - ms.loops.Wait() - ms.mountPoint = "" - return err -} - -// NewServer creates a server and attaches it to the given directory. -func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server, error) { - if opts == nil { - opts = &MountOptions{ - MaxBackground: _DEFAULT_BACKGROUND_TASKS, - } - } - o := *opts - if o.SingleThreaded { - fs = NewLockingRawFileSystem(fs) - } - - if o.Buffers == nil { - o.Buffers = defaultBufferPool - } - if o.MaxWrite < 0 { - o.MaxWrite = 0 - } - if o.MaxWrite == 0 { - o.MaxWrite = 1 << 16 - } - if o.MaxWrite > MAX_KERNEL_WRITE { - o.MaxWrite = MAX_KERNEL_WRITE - } - opts = &o - ms := &Server{ - fileSystem: fs, - started: make(chan struct{}), - opts: &o, - // OSX has races when multiple routines read from the - // FUSE device: on unmount, sometime some reads do not - // error-out, meaning that unmount will hang. - singleReader: runtime.GOOS == "darwin", - } - ms.reqPool.New = func() interface{} { return new(request) } - ms.readPool.New = func() interface{} { return make([]byte, o.MaxWrite+PAGESIZE) } - optStrs := opts.Options - if opts.AllowOther { - optStrs = append(optStrs, "allow_other") - } - - name := opts.Name - if name == "" { - name = ms.fileSystem.String() - l := len(name) - if l > _MAX_NAME_LEN { - l = _MAX_NAME_LEN - } - name = strings.Replace(name[:l], ",", ";", -1) - } - optStrs = append(optStrs, "subtype="+name) - - fsname := opts.FsName - if len(fsname) > 0 { - optStrs = append(optStrs, "fsname="+fsname) - } - - mountPoint = filepath.Clean(mountPoint) - if !filepath.IsAbs(mountPoint) { - cwd, err := os.Getwd() - if err != nil { - return nil, err - } - mountPoint = filepath.Clean(filepath.Join(cwd, mountPoint)) - } - fd, err := mount(mountPoint, strings.Join(optStrs, ",")) - if err != nil { - return nil, err - } - - ms.fileSystem.Init(ms) - ms.mountPoint = mountPoint - ms.mountFd = fd - return ms, nil -} - -// DebugData returns internal status information for debugging -// purposes. -func (ms *Server) DebugData() string { - var r int - ms.reqMu.Lock() - r = ms.reqReaders - ms.reqMu.Unlock() - - return fmt.Sprintf("readers: %d", r) -} - -// What is a good number? Maybe the number of CPUs? -const _MAX_READERS = 2 - -// handleEINTR retries the given function until it doesn't return syscall.EINTR. -// This is similar to the HANDLE_EINTR() macro from Chromium ( see -// https://code.google.com/p/chromium/codesearch#chromium/src/base/posix/eintr_wrapper.h -// ) and the TEMP_FAILURE_RETRY() from glibc (see -// https://www.gnu.org/software/libc/manual/html_node/Interrupted-Primitives.html -// ). -// -// Don't use handleEINTR() with syscall.Close(); see -// https://code.google.com/p/chromium/issues/detail?id=269623 . -func handleEINTR(fn func() error) (err error) { - for { - err = fn() - if err != syscall.EINTR { - break - } - } - return -} - -// Returns a new request, or error. In case exitIdle is given, returns -// nil, OK if we have too many readers already. -func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) { - ms.reqMu.Lock() - if ms.reqReaders > _MAX_READERS { - ms.reqMu.Unlock() - return nil, OK - } - req = ms.reqPool.Get().(*request) - dest := ms.readPool.Get().([]byte) - ms.reqReaders++ - ms.reqMu.Unlock() - - var n int - err := handleEINTR(func() error { - var err error - n, err = syscall.Read(ms.mountFd, dest) - return err - }) - if err != nil { - code = ToStatus(err) - ms.reqPool.Put(req) - ms.reqMu.Lock() - ms.reqReaders-- - ms.reqMu.Unlock() - return nil, code - } - - if ms.latencies != nil { - req.startTime = time.Now() - } - gobbled := req.setInput(dest[:n]) - - ms.reqMu.Lock() - if !gobbled { - ms.readPool.Put(dest) - dest = nil - } - ms.reqReaders-- - if !ms.singleReader && ms.reqReaders <= 0 { - ms.loops.Add(1) - go ms.loop(true) - } - ms.reqMu.Unlock() - - return req, OK -} - -// returnRequest returns a request to the pool of unused requests. -func (ms *Server) returnRequest(req *request) { - ms.recordStats(req) - - if req.bufferPoolOutputBuf != nil { - ms.opts.Buffers.FreeBuffer(req.bufferPoolOutputBuf) - req.bufferPoolOutputBuf = nil - } - - req.clear() - ms.reqMu.Lock() - if req.bufferPoolInputBuf != nil { - ms.readPool.Put(req.bufferPoolInputBuf) - req.bufferPoolInputBuf = nil - } - ms.reqPool.Put(req) - ms.reqMu.Unlock() -} - -func (ms *Server) recordStats(req *request) { - if ms.latencies != nil { - dt := time.Now().Sub(req.startTime) - opname := operationName(req.inHeader.Opcode) - ms.latencies.Add(opname, dt) - } -} - -// Serve initiates the FUSE loop. Normally, callers should run Serve() -// and wait for it to exit, but tests will want to run this in a -// goroutine. -// -// Each filesystem operation executes in a separate goroutine. -func (ms *Server) Serve() { - ms.loops.Add(1) - ms.loop(false) - ms.loops.Wait() - - ms.writeMu.Lock() - syscall.Close(ms.mountFd) - ms.writeMu.Unlock() -} - -func (ms *Server) loop(exitIdle bool) { - defer ms.loops.Done() -exit: - for { - req, errNo := ms.readRequest(exitIdle) - switch errNo { - case OK: - if req == nil { - break exit - } - case ENOENT: - continue - case ENODEV: - // unmount - break exit - default: // some other error? - log.Printf("Failed to read from fuse conn: %v", errNo) - break exit - } - - if ms.singleReader { - go ms.handleRequest(req) - } else { - ms.handleRequest(req) - } - } -} - -func (ms *Server) handleRequest(req *request) { - req.parse() - if req.handler == nil { - req.status = ENOSYS - } - - if req.status.Ok() && ms.debug { - log.Println(req.InputDebug()) - } - - if req.status.Ok() && req.handler.Func == nil { - log.Printf("Unimplemented opcode %v", operationName(req.inHeader.Opcode)) - req.status = ENOSYS - } - - if req.status.Ok() { - req.handler.Func(ms, req) - } - - errNo := ms.write(req) - if errNo != 0 { - log.Printf("writer: Write/Writev failed, err: %v. opcode: %v", - errNo, operationName(req.inHeader.Opcode)) - } - ms.returnRequest(req) -} - -func (ms *Server) allocOut(req *request, size uint32) []byte { - if cap(req.bufferPoolOutputBuf) >= int(size) { - req.bufferPoolOutputBuf = req.bufferPoolOutputBuf[:size] - return req.bufferPoolOutputBuf - } - if req.bufferPoolOutputBuf != nil { - ms.opts.Buffers.FreeBuffer(req.bufferPoolOutputBuf) - } - req.bufferPoolOutputBuf = ms.opts.Buffers.AllocBuffer(size) - return req.bufferPoolOutputBuf -} - -func (ms *Server) write(req *request) Status { - // Forget does not wait for reply. - if req.inHeader.Opcode == _OP_FORGET || req.inHeader.Opcode == _OP_BATCH_FORGET { - return OK - } - - header := req.serializeHeader(req.flatDataSize()) - if ms.debug { - log.Println(req.OutputDebug()) - } - - if header == nil { - return OK - } - - s := ms.systemWrite(req, header) - if req.inHeader.Opcode == _OP_INIT { - close(ms.started) - } - return s -} - -// InodeNotify invalidates the information associated with the inode -// (ie. data cache, attributes, etc.) -func (ms *Server) InodeNotify(node uint64, off int64, length int64) Status { - entry := &NotifyInvalInodeOut{ - Ino: node, - Off: off, - Length: length, - } - req := request{ - inHeader: &InHeader{ - Opcode: _OP_NOTIFY_INODE, - }, - handler: operationHandlers[_OP_NOTIFY_INODE], - status: NOTIFY_INVAL_INODE, - } - req.outData = unsafe.Pointer(entry) - - // Protect against concurrent close. - ms.writeMu.Lock() - result := ms.write(&req) - ms.writeMu.Unlock() - - if ms.debug { - log.Println("Response: INODE_NOTIFY", result) - } - return result -} - -// DeleteNotify notifies the kernel that an entry is removed from a -// directory. In many cases, this is equivalent to EntryNotify, -// except when the directory is in use, eg. as working directory of -// some process. You should not hold any FUSE filesystem locks, as that -// can lead to deadlock. -func (ms *Server) DeleteNotify(parent uint64, child uint64, name string) Status { - if ms.kernelSettings.Minor < 18 { - return ms.EntryNotify(parent, name) - } - - req := request{ - inHeader: &InHeader{ - Opcode: _OP_NOTIFY_DELETE, - }, - handler: operationHandlers[_OP_NOTIFY_DELETE], - status: NOTIFY_INVAL_DELETE, - } - entry := &NotifyInvalDeleteOut{ - Parent: parent, - Child: child, - NameLen: uint32(len(name)), - } - - // Many versions of FUSE generate stacktraces if the - // terminating null byte is missing. - nameBytes := make([]byte, len(name)+1) - copy(nameBytes, name) - nameBytes[len(nameBytes)-1] = '\000' - req.outData = unsafe.Pointer(entry) - req.flatData = nameBytes - - // Protect against concurrent close. - ms.writeMu.Lock() - result := ms.write(&req) - ms.writeMu.Unlock() - - if ms.debug { - log.Printf("Response: DELETE_NOTIFY: %v", result) - } - return result -} - -// EntryNotify should be used if the existence status of an entry -// within a directory changes. You should not hold any FUSE filesystem -// locks, as that can lead to deadlock. -func (ms *Server) EntryNotify(parent uint64, name string) Status { - req := request{ - inHeader: &InHeader{ - Opcode: _OP_NOTIFY_ENTRY, - }, - handler: operationHandlers[_OP_NOTIFY_ENTRY], - status: NOTIFY_INVAL_ENTRY, - } - entry := &NotifyInvalEntryOut{ - Parent: parent, - NameLen: uint32(len(name)), - } - - // Many versions of FUSE generate stacktraces if the - // terminating null byte is missing. - nameBytes := make([]byte, len(name)+1) - copy(nameBytes, name) - nameBytes[len(nameBytes)-1] = '\000' - req.outData = unsafe.Pointer(entry) - req.flatData = nameBytes - - // Protect against concurrent close. - ms.writeMu.Lock() - result := ms.write(&req) - ms.writeMu.Unlock() - - if ms.debug { - log.Printf("Response: ENTRY_NOTIFY: %v", result) - } - return result -} - -var defaultBufferPool BufferPool - -func init() { - defaultBufferPool = NewBufferPool() -} - -// WaitMount waits for the first request to be served. Use this to -// avoid racing between accessing the (empty) mountpoint, and the OS -// trying to setup the user-space mount. -func (ms *Server) WaitMount() { - <-ms.started -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go deleted file mode 100644 index 043e51c4..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/server_darwin.go +++ /dev/null @@ -1,28 +0,0 @@ -package fuse - -import ( - "syscall" -) - -func (ms *Server) systemWrite(req *request, header []byte) Status { - if req.flatDataSize() == 0 { - err := handleEINTR(func() error { - _, err := syscall.Write(ms.mountFd, header) - return err - }) - return ToStatus(err) - } - - if req.fdData != nil { - sz := req.flatDataSize() - buf := ms.allocOut(req, uint32(sz)) - req.flatData, req.status = req.fdData.Bytes(buf) - header = req.serializeHeader(len(req.flatData)) - } - - _, err := writev(int(ms.mountFd), [][]byte{header, req.flatData}) - if req.readResult != nil { - req.readResult.Done() - } - return ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/server_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/server_linux.go deleted file mode 100644 index b3fe8dde..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/server_linux.go +++ /dev/null @@ -1,38 +0,0 @@ -package fuse - -import ( - "log" - "syscall" -) - -func (ms *Server) systemWrite(req *request, header []byte) Status { - if req.flatDataSize() == 0 { - err := handleEINTR(func() error { - _, err := syscall.Write(ms.mountFd, header) - return err - }) - return ToStatus(err) - } - - if req.fdData != nil { - if ms.canSplice { - err := ms.trySplice(header, req, req.fdData) - if err == nil { - req.readResult.Done() - return OK - } - log.Println("trySplice:", err) - } - - sz := req.flatDataSize() - buf := ms.allocOut(req, uint32(sz)) - req.flatData, req.status = req.fdData.Bytes(buf) - header = req.serializeHeader(len(req.flatData)) - } - - _, err := writev(ms.mountFd, [][]byte{header, req.flatData}) - if req.readResult != nil { - req.readResult.Done() - } - return ToStatus(err) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go deleted file mode 100644 index b5a8d5f6..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/splice_darwin.go +++ /dev/null @@ -1,13 +0,0 @@ -package fuse - -import ( - "fmt" -) - -func (s *Server) setSplice() { - panic("darwin has no splice.") -} - -func (ms *Server) trySplice(header []byte, req *request, fdData *readResultFd) error { - return fmt.Errorf("unimplemented") -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go deleted file mode 100644 index 3fd6dd9f..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/splice_linux.go +++ /dev/null @@ -1,93 +0,0 @@ -package fuse - -import ( - "fmt" - "os" - - "github.com/hanwen/go-fuse/splice" -) - -func (s *Server) setSplice() { - s.canSplice = splice.Resizable() -} - -// trySplice: Zero-copy read from fdData.Fd into /dev/fuse -// -// This is a four-step process: -// -// 1) Splice data form fdData.Fd into the "pair1" pipe buffer --> pair1: [payload] -// Now we know the actual payload length and can -// construct the reply header -// 2) Write header into the "pair2" pipe buffer --> pair2: [header] -// 4) Splice data from "pair1" into "pair2" --> pair2: [header][payload] -// 3) Splice the data from "pair2" into /dev/fuse -// -// This dance is neccessary because header and payload cannot be split across -// two splices and we cannot seek in a pipe buffer. -func (ms *Server) trySplice(header []byte, req *request, fdData *readResultFd) error { - var err error - - // Get a pair of connected pipes - pair1, err := splice.Get() - if err != nil { - return err - } - defer splice.Done(pair1) - - // Grow buffer pipe to requested size + one extra page - // Without the extra page the kernel will block once the pipe is almost full - pair1Sz := fdData.Size() + os.Getpagesize() - if err := pair1.Grow(pair1Sz); err != nil { - return err - } - - // Read data from file - payloadLen, err := pair1.LoadFromAt(fdData.Fd, fdData.Size(), fdData.Off) - - if err != nil { - // TODO - extract the data from splice. - return err - } - - // Get another pair of connected pipes - pair2, err := splice.Get() - if err != nil { - return err - } - defer splice.Done(pair2) - - // Grow pipe to header + actually read size + one extra page - // Without the extra page the kernel will block once the pipe is almost full - header = req.serializeHeader(payloadLen) - total := len(header) + payloadLen - pair2Sz := total + os.Getpagesize() - if err := pair2.Grow(pair2Sz); err != nil { - return err - } - - // Write header into pair2 - n, err := pair2.Write(header) - if err != nil { - return err - } - if n != len(header) { - return fmt.Errorf("Short write into splice: wrote %d, want %d", n, len(header)) - } - - // Write data into pair2 - n, err = pair2.LoadFrom(pair1.ReadFd(), payloadLen) - if err != nil { - return err - } - if n != payloadLen { - return fmt.Errorf("Short splice: wrote %d, want %d", n, payloadLen) - } - - // Write header + data to /dev/fuse - _, err = pair2.WriteTo(uintptr(ms.mountFd), total) - if err != nil { - return err - } - - return nil -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go deleted file mode 100644 index aaf157f0..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/syscall_darwin.go +++ /dev/null @@ -1,135 +0,0 @@ -package fuse - -import ( - "bytes" - "os" - "syscall" - "unsafe" -) - -// TODO - move these into Go's syscall package. - -func sys_writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, err error) { - n1, _, e1 := syscall.Syscall( - syscall.SYS_WRITEV, - uintptr(fd), uintptr(unsafe.Pointer(iovecs)), uintptr(cnt)) - n = int(n1) - if e1 != 0 { - err = syscall.Errno(e1) - } - return -} - -func writev(fd int, packet [][]byte) (n int, err error) { - iovecs := make([]syscall.Iovec, 0, len(packet)) - - for _, v := range packet { - if len(v) == 0 { - continue - } - vec := syscall.Iovec{ - Base: &v[0], - } - vec.SetLen(len(v)) - iovecs = append(iovecs, vec) - } - - sysErr := handleEINTR(func() error { - var err error - n, err = sys_writev(fd, &iovecs[0], len(iovecs)) - return err - }) - if sysErr != nil { - err = os.NewSyscallError("writev", sysErr) - } - return n, err -} - -func getxattr(path string, attr string, dest []byte) (sz int, errno int) { - pathBs := syscall.StringBytePtr(path) - attrBs := syscall.StringBytePtr(attr) - size, _, errNo := syscall.Syscall6( - syscall.SYS_GETXATTR, - uintptr(unsafe.Pointer(pathBs)), - uintptr(unsafe.Pointer(attrBs)), - uintptr(unsafe.Pointer(&dest[0])), - uintptr(len(dest)), - 0, 0) - return int(size), int(errNo) -} - -func GetXAttr(path string, attr string, dest []byte) (value []byte, errno int) { - sz, errno := getxattr(path, attr, dest) - - for sz > cap(dest) && errno == 0 { - dest = make([]byte, sz) - sz, errno = getxattr(path, attr, dest) - } - - if errno != 0 { - return nil, errno - } - - return dest[:sz], errno -} - -func listxattr(path string, dest []byte) (sz int, errno int) { - pathbs := syscall.StringBytePtr(path) - var destPointer unsafe.Pointer - if len(dest) > 0 { - destPointer = unsafe.Pointer(&dest[0]) - } - size, _, errNo := syscall.Syscall( - syscall.SYS_LISTXATTR, - uintptr(unsafe.Pointer(pathbs)), - uintptr(destPointer), - uintptr(len(dest))) - - return int(size), int(errNo) -} - -func ListXAttr(path string) (attributes []string, errno int) { - dest := make([]byte, 0) - sz, errno := listxattr(path, dest) - if errno != 0 { - return nil, errno - } - - for sz > cap(dest) && errno == 0 { - dest = make([]byte, sz) - sz, errno = listxattr(path, dest) - } - - // -1 to drop the final empty slice. - dest = dest[:sz-1] - attributesBytes := bytes.Split(dest, []byte{0}) - attributes = make([]string, len(attributesBytes)) - for i, v := range attributesBytes { - attributes[i] = string(v) - } - return attributes, errno -} - -func Setxattr(path string, attr string, data []byte, flags int) (errno int) { - pathbs := syscall.StringBytePtr(path) - attrbs := syscall.StringBytePtr(attr) - _, _, errNo := syscall.Syscall6( - syscall.SYS_SETXATTR, - uintptr(unsafe.Pointer(pathbs)), - uintptr(unsafe.Pointer(attrbs)), - uintptr(unsafe.Pointer(&data[0])), - uintptr(len(data)), - uintptr(flags), 0) - - return int(errNo) -} - -func Removexattr(path string, attr string) (errno int) { - pathbs := syscall.StringBytePtr(path) - attrbs := syscall.StringBytePtr(attr) - _, _, errNo := syscall.Syscall( - syscall.SYS_REMOVEXATTR, - uintptr(unsafe.Pointer(pathbs)), - uintptr(unsafe.Pointer(attrbs)), 0) - return int(errNo) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go deleted file mode 100644 index 69aafb2b..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/syscall_linux.go +++ /dev/null @@ -1,45 +0,0 @@ -package fuse - -import ( - "os" - "syscall" - "unsafe" -) - -// TODO - move these into Go's syscall package. - -func sys_writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, err error) { - n1, _, e1 := syscall.Syscall( - syscall.SYS_WRITEV, - uintptr(fd), uintptr(unsafe.Pointer(iovecs)), uintptr(cnt)) - n = int(n1) - if e1 != 0 { - err = syscall.Errno(e1) - } - return n, err -} - -func writev(fd int, packet [][]byte) (n int, err error) { - iovecs := make([]syscall.Iovec, 0, len(packet)) - - for _, v := range packet { - if len(v) == 0 { - continue - } - vec := syscall.Iovec{ - Base: &v[0], - } - vec.SetLen(len(v)) - iovecs = append(iovecs, vec) - } - - sysErr := handleEINTR(func() error { - var err error - n, err = sys_writev(fd, &iovecs[0], len(iovecs)) - return err - }) - if sysErr != nil { - err = os.NewSyscallError("writev", sysErr) - } - return n, err -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/typeprint.go b/vendor/github.com/hanwen/go-fuse/fuse/typeprint.go deleted file mode 100644 index fd68a65e..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/typeprint.go +++ /dev/null @@ -1,5 +0,0 @@ -package fuse - -func (a *Attr) String() string { - return Print((*Attr)(a)) -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/types.go b/vendor/github.com/hanwen/go-fuse/fuse/types.go deleted file mode 100644 index 73b65ba7..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/types.go +++ /dev/null @@ -1,431 +0,0 @@ -package fuse - -import ( - "syscall" -) - -const PAGESIZE = 4096 - -const ( - _DEFAULT_BACKGROUND_TASKS = 12 -) - -// Status is the errno number that a FUSE call returns to the kernel. -type Status int32 - -const ( - OK = Status(0) - EACCES = Status(syscall.EACCES) - EBUSY = Status(syscall.EBUSY) - EINVAL = Status(syscall.EINVAL) - EIO = Status(syscall.EIO) - ENOENT = Status(syscall.ENOENT) - ENOSYS = Status(syscall.ENOSYS) - ENODATA = Status(syscall.ENODATA) - ENOTDIR = Status(syscall.ENOTDIR) - EPERM = Status(syscall.EPERM) - ERANGE = Status(syscall.ERANGE) - EXDEV = Status(syscall.EXDEV) - EBADF = Status(syscall.EBADF) - ENODEV = Status(syscall.ENODEV) - EROFS = Status(syscall.EROFS) -) - -type ForgetIn struct { - InHeader - - Nlookup uint64 -} - -// batch forget is handled internally. -type _ForgetOne struct { - NodeId uint64 - Nlookup uint64 -} - -// batch forget is handled internally. -type _BatchForgetIn struct { - InHeader - Count uint32 - Dummy uint32 -} - -type MkdirIn struct { - InHeader - Mode uint32 - Umask uint32 -} - -type RenameIn struct { - InHeader - Newdir uint64 -} - -type Rename2In struct { - InHeader - Newdir uint64 - Flags uint32 - Padding uint32 -} - -type LinkIn struct { - InHeader - Oldnodeid uint64 -} - -type Owner struct { - Uid uint32 - Gid uint32 -} - -const ( // SetAttrIn.Valid - FATTR_MODE = (1 << 0) - FATTR_UID = (1 << 1) - FATTR_GID = (1 << 2) - FATTR_SIZE = (1 << 3) - FATTR_ATIME = (1 << 4) - FATTR_MTIME = (1 << 5) - FATTR_FH = (1 << 6) - FATTR_ATIME_NOW = (1 << 7) - FATTR_MTIME_NOW = (1 << 8) - FATTR_LOCKOWNER = (1 << 9) - FATTR_CTIME = (1 << 10) -) - -type SetAttrInCommon struct { - InHeader - - Valid uint32 - Padding uint32 - Fh uint64 - Size uint64 - LockOwner uint64 - Atime uint64 - Mtime uint64 - Ctime uint64 - Atimensec uint32 - Mtimensec uint32 - Ctimensec uint32 - Mode uint32 - Unused4 uint32 - Owner - Unused5 uint32 -} - -const RELEASE_FLUSH = (1 << 0) - -type ReleaseIn struct { - InHeader - Fh uint64 - Flags uint32 - ReleaseFlags uint32 - LockOwner uint64 -} - -type OpenIn struct { - InHeader - Flags uint32 - Mode uint32 -} - -const ( - // OpenOut.Flags - FOPEN_DIRECT_IO = (1 << 0) - FOPEN_KEEP_CACHE = (1 << 1) - FOPEN_NONSEEKABLE = (1 << 2) -) - -type OpenOut struct { - Fh uint64 - OpenFlags uint32 - Padding uint32 -} - -// To be set in InitIn/InitOut.Flags. -const ( - CAP_ASYNC_READ = (1 << 0) - CAP_POSIX_LOCKS = (1 << 1) - CAP_FILE_OPS = (1 << 2) - CAP_ATOMIC_O_TRUNC = (1 << 3) - CAP_EXPORT_SUPPORT = (1 << 4) - CAP_BIG_WRITES = (1 << 5) - CAP_DONT_MASK = (1 << 6) - CAP_SPLICE_WRITE = (1 << 7) - CAP_SPLICE_MOVE = (1 << 8) - CAP_SPLICE_READ = (1 << 9) - CAP_FLOCK_LOCKS = (1 << 10) - CAP_IOCTL_DIR = (1 << 11) - CAP_AUTO_INVAL_DATA = (1 << 12) - CAP_READDIRPLUS = (1 << 13) - CAP_READDIRPLUS_AUTO = (1 << 14) - CAP_ASYNC_DIO = (1 << 15) - CAP_WRITEBACK_CACHE = (1 << 16) - CAP_NO_OPEN_SUPPORT = (1 << 17) -) - -type InitIn struct { - InHeader - - Major uint32 - Minor uint32 - MaxReadAhead uint32 - Flags uint32 -} - -type InitOut struct { - Major uint32 - Minor uint32 - MaxReadAhead uint32 - Flags uint32 - MaxBackground uint16 - CongestionThreshold uint16 - MaxWrite uint32 - TimeGran uint32 - Unused [9]uint32 -} - -type _CuseInitIn struct { - InHeader - Major uint32 - Minor uint32 - Unused uint32 - Flags uint32 -} - -type _CuseInitOut struct { - Major uint32 - Minor uint32 - Unused uint32 - Flags uint32 - MaxRead uint32 - MaxWrite uint32 - DevMajor uint32 - DevMinor uint32 - Spare [10]uint32 -} - -type InterruptIn struct { - InHeader - Unique uint64 -} - -type _BmapIn struct { - InHeader - Block uint64 - Blocksize uint32 - Padding uint32 -} - -type _BmapOut struct { - Block uint64 -} - -const ( - FUSE_IOCTL_COMPAT = (1 << 0) - FUSE_IOCTL_UNRESTRICTED = (1 << 1) - FUSE_IOCTL_RETRY = (1 << 2) -) - -type _IoctlIn struct { - InHeader - Fh uint64 - Flags uint32 - Cmd uint32 - Arg uint64 - InSize uint32 - OutSize uint32 -} - -type _IoctlOut struct { - Result int32 - Flags uint32 - InIovs uint32 - OutIovs uint32 -} - -type _PollIn struct { - InHeader - Fh uint64 - Kh uint64 - Flags uint32 - Padding uint32 -} - -type _PollOut struct { - Revents uint32 - Padding uint32 -} - -type _NotifyPollWakeupOut struct { - Kh uint64 -} - -type WriteOut struct { - Size uint32 - Padding uint32 -} - -type GetXAttrOut struct { - Size uint32 - Padding uint32 -} - -type _FileLock struct { - Start uint64 - End uint64 - Typ uint32 - Pid uint32 -} - -type _LkIn struct { - InHeader - Fh uint64 - Owner uint64 - Lk _FileLock - LkFlags uint32 - Padding uint32 -} - -type _LkOut struct { - Lk _FileLock -} - -// For AccessIn.Mask. -const ( - X_OK = 1 - W_OK = 2 - R_OK = 4 - F_OK = 0 -) - -type AccessIn struct { - InHeader - Mask uint32 - Padding uint32 -} - -type FsyncIn struct { - InHeader - Fh uint64 - FsyncFlags uint32 - Padding uint32 -} - -type OutHeader struct { - Length uint32 - Status int32 - Unique uint64 -} - -type NotifyInvalInodeOut struct { - Ino uint64 - Off int64 - Length int64 -} - -type NotifyInvalEntryOut struct { - Parent uint64 - NameLen uint32 - Padding uint32 -} - -type NotifyInvalDeleteOut struct { - Parent uint64 - Child uint64 - NameLen uint32 - Padding uint32 -} - -const ( - NOTIFY_POLL = -1 - NOTIFY_INVAL_INODE = -2 - NOTIFY_INVAL_ENTRY = -3 - NOTIFY_STORE = -4 - NOTIFY_RETRIEVE = -5 - NOTIFY_INVAL_DELETE = -6 - NOTIFY_CODE_MAX = -6 -) - -type FlushIn struct { - InHeader - Fh uint64 - Unused uint32 - Padding uint32 - LockOwner uint64 -} - -type EntryOut struct { - NodeId uint64 - Generation uint64 - EntryValid uint64 - AttrValid uint64 - EntryValidNsec uint32 - AttrValidNsec uint32 - Attr -} - -type AttrOut struct { - AttrValid uint64 - AttrValidNsec uint32 - Dummy uint32 - Attr -} - -type CreateOut struct { - EntryOut - OpenOut -} - -type Context struct { - Owner - Pid uint32 -} - -type InHeader struct { - Length uint32 - Opcode int32 - Unique uint64 - NodeId uint64 - Context - Padding uint32 -} - -type StatfsOut struct { - Blocks uint64 - Bfree uint64 - Bavail uint64 - Files uint64 - Ffree uint64 - Bsize uint32 - NameLen uint32 - Frsize uint32 - Padding uint32 - Spare [6]uint32 -} - -// _Dirent is what we send to the kernel, but we offer DirEntry and -// DirEntryList to the user. -type _Dirent struct { - Ino uint64 - Off uint64 - NameLen uint32 - Typ uint32 -} - -const ( - READ_LOCKOWNER = (1 << 1) -) - -const ( - WRITE_CACHE = (1 << 0) - WRITE_LOCKOWNER = (1 << 1) -) - -type FallocateIn struct { - InHeader - Fh uint64 - Offset uint64 - Length uint64 - Mode uint32 - Padding uint32 -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go b/vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go deleted file mode 100644 index 162244fd..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/types_darwin.go +++ /dev/null @@ -1,131 +0,0 @@ -package fuse - -type Attr struct { - Ino uint64 - Size uint64 - Blocks uint64 - Atime uint64 - Mtime uint64 - Ctime uint64 - Crtime_ uint64 // OS X - Atimensec uint32 - Mtimensec uint32 - Ctimensec uint32 - Crtimensec_ uint32 // OS X - Mode uint32 - Nlink uint32 - Owner - Rdev uint32 - Flags_ uint32 // OS X -} - -const ( - FATTR_CRTIME = (1 << 28) - FATTR_CHGTIME = (1 << 29) - FATTR_BKUPTIME = (1 << 30) - FATTR_FLAGS = (1 << 31) -) - -type SetAttrIn struct { - SetAttrInCommon - - // OS X only - Bkuptime_ uint64 - Chgtime_ uint64 - Crtime uint64 - BkuptimeNsec uint32 - ChgtimeNsec uint32 - CrtimeNsec uint32 - Flags_ uint32 // see chflags(2) -} - -const ( - FOPEN_PURGE_ATTR = (1 << 30) - FOPEN_PURGE_UBC = (1 << 31) -) - -// compat with linux. -const ( - // Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set. - FUSE_GETATTR_FH = (1 << 0) -) - -type GetAttrIn struct { - InHeader -} - -func (g *GetAttrIn) Flags() uint32 { - return 0 -} - -func (g *GetAttrIn) Fh() uint64 { - return 0 -} - -// Uses OpenIn struct for create. -type CreateIn struct { - InHeader - - Flags uint32 - Mode uint32 -} - -type MknodIn struct { - InHeader - - Mode uint32 - Rdev uint32 -} - -type ReadIn struct { - InHeader - - Fh uint64 - Offset uint64 - Size uint32 - ReadFlags uint32 -} - -type WriteIn struct { - InHeader - Fh uint64 - Offset uint64 - Size uint32 - WriteFlags uint32 -} - -type SetXAttrIn struct { - InHeader - Size uint32 - Flags uint32 - Position uint32 - Padding uint32 -} - -type GetXAttrIn struct { - InHeader - Size uint32 - Padding uint32 - Position uint32 - Padding2 uint32 -} - -const ( - CAP_CASE_INSENSITIVE = (1 << 29) - CAP_VOL_RENAME = (1 << 30) - CAP_XTIMES = (1 << 31) -) - -type GetxtimesOut struct { - Bkuptime uint64 - Crtime uint64 - Bkuptimensec uint32 - Crtimensec uint32 -} - -type ExchangeIn struct { - InHeader - Olddir uint64 - Newdir uint64 - Options uint64 -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/types_linux.go b/vendor/github.com/hanwen/go-fuse/fuse/types_linux.go deleted file mode 100644 index 33e4252a..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/types_linux.go +++ /dev/null @@ -1,98 +0,0 @@ -package fuse - -type Attr struct { - Ino uint64 - Size uint64 - Blocks uint64 - Atime uint64 - Mtime uint64 - Ctime uint64 - Atimensec uint32 - Mtimensec uint32 - Ctimensec uint32 - Mode uint32 - Nlink uint32 - Owner - Rdev uint32 - Blksize uint32 - Padding uint32 -} - -type SetAttrIn struct { - SetAttrInCommon -} - -const ( - // Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set. - FUSE_GETATTR_FH = (1 << 0) -) - -type GetAttrIn struct { - InHeader - - Flags_ uint32 - Dummy uint32 - Fh_ uint64 -} - -// Flags accesses the flags. This is a method, because OSXFuse does not -// have GetAttrIn flags. -func (g *GetAttrIn) Flags() uint32 { - return g.Flags_ -} - -// Fh accesses the file handle. This is a method, because OSXFuse does not -// have GetAttrIn flags. -func (g *GetAttrIn) Fh() uint64 { - return g.Fh_ -} - -type CreateIn struct { - InHeader - Flags uint32 - Mode uint32 - Umask uint32 - Pading uint32 -} - -type MknodIn struct { - InHeader - Mode uint32 - Rdev uint32 - Umask uint32 - Padding uint32 -} - -type ReadIn struct { - InHeader - Fh uint64 - Offset uint64 - Size uint32 - ReadFlags uint32 - LockOwner uint64 - Flags uint32 - Padding uint32 -} - -type WriteIn struct { - InHeader - Fh uint64 - Offset uint64 - Size uint32 - WriteFlags uint32 - LockOwner uint64 - Flags uint32 - Padding uint32 -} - -type SetXAttrIn struct { - InHeader - Size uint32 - Flags uint32 -} - -type GetXAttrIn struct { - InHeader - Size uint32 - Padding uint32 -} diff --git a/vendor/github.com/hanwen/go-fuse/fuse/upgrade.go b/vendor/github.com/hanwen/go-fuse/fuse/upgrade.go deleted file mode 100644 index fce8ee90..00000000 --- a/vendor/github.com/hanwen/go-fuse/fuse/upgrade.go +++ /dev/null @@ -1,320 +0,0 @@ -package fuse - -import ( - "fmt" -) - -// NewRawFileSystem adds the methods missing for implementing a -// RawFileSystem to any object. -func NewRawFileSystem(fs interface{}) RawFileSystem { - return &wrappingFS{fs} -} - -type wrappingFS struct { - fs interface{} -} - -func (fs *wrappingFS) Init(srv *Server) { - if s, ok := fs.fs.(interface { - Init(*Server) - }); ok { - s.Init(srv) - } -} - -func (fs *wrappingFS) String() string { - return fmt.Sprintf("%v", fs.fs) -} - -func (fs *wrappingFS) SetDebug(dbg bool) { - if s, ok := fs.fs.(interface { - SetDebug(bool) - }); ok { - s.SetDebug(dbg) - } -} - -func (fs *wrappingFS) StatFs(header *InHeader, out *StatfsOut) Status { - if s, ok := fs.fs.(interface { - StatFs(header *InHeader, out *StatfsOut) Status - }); ok { - return s.StatFs(header, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Lookup(header *InHeader, name string, out *EntryOut) (code Status) { - if s, ok := fs.fs.(interface { - Lookup(header *InHeader, name string, out *EntryOut) (code Status) - }); ok { - return s.Lookup(header, name, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Forget(nodeID, nlookup uint64) { - if s, ok := fs.fs.(interface { - Forget(nodeID, nlookup uint64) - }); ok { - s.Forget(nodeID, nlookup) - } -} - -func (fs *wrappingFS) GetAttr(input *GetAttrIn, out *AttrOut) (code Status) { - if s, ok := fs.fs.(interface { - GetAttr(input *GetAttrIn, out *AttrOut) (code Status) - }); ok { - return s.GetAttr(input, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Open(input *OpenIn, out *OpenOut) (status Status) { - if s, ok := fs.fs.(interface { - Open(input *OpenIn, out *OpenOut) (status Status) - }); ok { - return s.Open(input, out) - } - return ENOSYS -} - -func (fs *wrappingFS) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) { - if s, ok := fs.fs.(interface { - SetAttr(input *SetAttrIn, out *AttrOut) (code Status) - }); ok { - return s.SetAttr(input, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Readlink(header *InHeader) (out []byte, code Status) { - if s, ok := fs.fs.(interface { - Readlink(header *InHeader) (out []byte, code Status) - }); ok { - return s.Readlink(header) - } - return nil, ENOSYS -} - -func (fs *wrappingFS) Mknod(input *MknodIn, name string, out *EntryOut) (code Status) { - if s, ok := fs.fs.(interface { - Mknod(input *MknodIn, name string, out *EntryOut) (code Status) - }); ok { - return s.Mknod(input, name, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) { - if s, ok := fs.fs.(interface { - Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) - }); ok { - return s.Mkdir(input, name, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Unlink(header *InHeader, name string) (code Status) { - if s, ok := fs.fs.(interface { - Unlink(header *InHeader, name string) (code Status) - }); ok { - return s.Unlink(header, name) - } - return ENOSYS -} - -func (fs *wrappingFS) Rmdir(header *InHeader, name string) (code Status) { - if s, ok := fs.fs.(interface { - Rmdir(header *InHeader, name string) (code Status) - }); ok { - return s.Rmdir(header, name) - } - return ENOSYS -} - -func (fs *wrappingFS) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) { - if s, ok := fs.fs.(interface { - Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) - }); ok { - return s.Symlink(header, pointedTo, linkName, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Rename(input *RenameIn, oldName string, newName string) (code Status) { - if s, ok := fs.fs.(interface { - Rename(input *RenameIn, oldName string, newName string) (code Status) - }); ok { - return s.Rename(input, oldName, newName) - } - return ENOSYS -} - -func (fs *wrappingFS) Link(input *LinkIn, name string, out *EntryOut) (code Status) { - if s, ok := fs.fs.(interface { - Link(input *LinkIn, name string, out *EntryOut) (code Status) - }); ok { - return s.Link(input, name, out) - } - return ENOSYS -} - -func (fs *wrappingFS) GetXAttrSize(header *InHeader, attr string) (size int, code Status) { - if s, ok := fs.fs.(interface { - GetXAttrSize(header *InHeader, attr string) (size int, code Status) - }); ok { - return s.GetXAttrSize(header, attr) - } - return 0, ENOSYS -} - -func (fs *wrappingFS) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { - if s, ok := fs.fs.(interface { - GetXAttrData(header *InHeader, attr string) (data []byte, code Status) - }); ok { - return s.GetXAttrData(header, attr) - } - return nil, ENOSYS -} - -func (fs *wrappingFS) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status { - if s, ok := fs.fs.(interface { - SetXAttr(input *SetXAttrIn, attr string, data []byte) Status - }); ok { - return s.SetXAttr(input, attr, data) - } - return ENOSYS -} - -func (fs *wrappingFS) ListXAttr(header *InHeader) (data []byte, code Status) { - if s, ok := fs.fs.(interface { - ListXAttr(header *InHeader) (data []byte, code Status) - }); ok { - return s.ListXAttr(header) - } - return nil, ENOSYS -} - -func (fs *wrappingFS) RemoveXAttr(header *InHeader, attr string) Status { - if s, ok := fs.fs.(interface { - RemoveXAttr(header *InHeader, attr string) Status - }); ok { - return s.RemoveXAttr(header, attr) - } - return ENOSYS -} - -func (fs *wrappingFS) Access(input *AccessIn) (code Status) { - if s, ok := fs.fs.(interface { - Access(input *AccessIn) (code Status) - }); ok { - return s.Access(input) - } - return ENOSYS -} - -func (fs *wrappingFS) Create(input *CreateIn, name string, out *CreateOut) (code Status) { - if s, ok := fs.fs.(interface { - Create(input *CreateIn, name string, out *CreateOut) (code Status) - }); ok { - return s.Create(input, name, out) - } - return ENOSYS -} - -func (fs *wrappingFS) OpenDir(input *OpenIn, out *OpenOut) (status Status) { - if s, ok := fs.fs.(interface { - OpenDir(input *OpenIn, out *OpenOut) (status Status) - }); ok { - return s.OpenDir(input, out) - } - return ENOSYS -} - -func (fs *wrappingFS) Read(input *ReadIn, buf []byte) (ReadResult, Status) { - if s, ok := fs.fs.(interface { - Read(input *ReadIn, buf []byte) (ReadResult, Status) - }); ok { - return s.Read(input, buf) - } - return nil, ENOSYS -} - -func (fs *wrappingFS) Release(input *ReleaseIn) { - if s, ok := fs.fs.(interface { - Release(input *ReleaseIn) - }); ok { - s.Release(input) - } -} - -func (fs *wrappingFS) Write(input *WriteIn, data []byte) (written uint32, code Status) { - if s, ok := fs.fs.(interface { - Write(input *WriteIn, data []byte) (written uint32, code Status) - }); ok { - return s.Write(input, data) - } - return 0, ENOSYS -} - -func (fs *wrappingFS) Flush(input *FlushIn) Status { - if s, ok := fs.fs.(interface { - Flush(input *FlushIn) Status - }); ok { - return s.Flush(input) - } - return OK -} - -func (fs *wrappingFS) Fsync(input *FsyncIn) (code Status) { - if s, ok := fs.fs.(interface { - Fsync(input *FsyncIn) (code Status) - }); ok { - return s.Fsync(input) - } - return ENOSYS -} - -func (fs *wrappingFS) ReadDir(input *ReadIn, l *DirEntryList) Status { - if s, ok := fs.fs.(interface { - ReadDir(input *ReadIn, l *DirEntryList) Status - }); ok { - return s.ReadDir(input, l) - } - return ENOSYS -} - -func (fs *wrappingFS) ReadDirPlus(input *ReadIn, l *DirEntryList) Status { - if s, ok := fs.fs.(interface { - ReadDirPlus(input *ReadIn, l *DirEntryList) Status - }); ok { - return s.ReadDirPlus(input, l) - } - return ENOSYS -} - -func (fs *wrappingFS) ReleaseDir(input *ReleaseIn) { - if s, ok := fs.fs.(interface { - ReleaseDir(input *ReleaseIn) - }); ok { - s.ReleaseDir(input) - } -} - -func (fs *wrappingFS) FsyncDir(input *FsyncIn) (code Status) { - if s, ok := fs.fs.(interface { - FsyncDir(input *FsyncIn) (code Status) - }); ok { - return s.FsyncDir(input) - } - return ENOSYS -} - -func (fs *wrappingFS) Fallocate(in *FallocateIn) (code Status) { - if s, ok := fs.fs.(interface { - Fallocate(in *FallocateIn) (code Status) - }); ok { - return s.Fallocate(in) - } - return ENOSYS -} diff --git a/vendor/github.com/hanwen/go-fuse/splice/copy.go b/vendor/github.com/hanwen/go-fuse/splice/copy.go deleted file mode 100644 index b34e79be..00000000 --- a/vendor/github.com/hanwen/go-fuse/splice/copy.go +++ /dev/null @@ -1,66 +0,0 @@ -package splice - -import ( - "io" - "os" -) - -func SpliceCopy(dst *os.File, src *os.File, p *Pair) (int64, error) { - total := int64(0) - - for { - n, err := p.LoadFrom(src.Fd(), p.size) - if err != nil { - return total, err - } - if n == 0 { - break - } - m, err := p.WriteTo(dst.Fd(), n) - total += int64(m) - if err != nil { - return total, err - } - if m < n { - return total, err - } - if int(n) < p.size { - break - } - } - - return total, nil -} - -// Argument ordering follows io.Copy. -func CopyFile(dstName string, srcName string, mode int) error { - src, err := os.Open(srcName) - if err != nil { - return err - } - defer src.Close() - - dst, err := os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(mode)) - if err != nil { - return err - } - defer dst.Close() - - return CopyFds(dst, src) -} - -func CopyFds(dst *os.File, src *os.File) (err error) { - p, err := splicePool.get() - if p != nil { - p.Grow(256 * 1024) - _, err := SpliceCopy(dst, src, p) - splicePool.done(p) - return err - } else { - _, err = io.Copy(dst, src) - } - if err == io.EOF { - err = nil - } - return err -} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pair.go b/vendor/github.com/hanwen/go-fuse/splice/pair.go deleted file mode 100644 index 1fb7b286..00000000 --- a/vendor/github.com/hanwen/go-fuse/splice/pair.go +++ /dev/null @@ -1,64 +0,0 @@ -package splice - -import ( - "fmt" - "os" -) - -type Pair struct { - r, w *os.File - size int -} - -func (p *Pair) MaxGrow() { - for p.Grow(2*p.size) == nil { - } -} - -func (p *Pair) Grow(n int) error { - if n <= p.size { - return nil - } - if !resizable { - return fmt.Errorf("splice: want %d bytes, but not resizable", n) - } - if n > maxPipeSize { - return fmt.Errorf("splice: want %d bytes, max pipe size %d", n, maxPipeSize) - } - - newsize, errNo := fcntl(p.r.Fd(), F_SETPIPE_SZ, n) - if errNo != 0 { - return fmt.Errorf("splice: fcntl returned %v", errNo) - } - p.size = newsize - return nil -} - -func (p *Pair) Cap() int { - return p.size -} - -func (p *Pair) Close() error { - err1 := p.r.Close() - err2 := p.w.Close() - if err1 != nil { - return err1 - } - return err2 -} - -func (p *Pair) Read(d []byte) (n int, err error) { - return p.r.Read(d) -} - -func (p *Pair) ReadFd() uintptr { - return p.r.Fd() -} - -func (p *Pair) WriteFd() uintptr { - return p.w.Fd() -} - -func (p *Pair) Write(d []byte) (n int, err error) { - return p.w.Write(d) -} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go b/vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go deleted file mode 100644 index 8cd7f278..00000000 --- a/vendor/github.com/hanwen/go-fuse/splice/pair_darwin.go +++ /dev/null @@ -1,18 +0,0 @@ -package splice - -import () - -func (p *Pair) LoadFromAt(fd uintptr, sz int, off int64) (int, error) { - panic("not implemented") - return 0, nil -} - -func (p *Pair) LoadFrom(fd uintptr, sz int) (int, error) { - panic("not implemented") - return 0, nil -} - -func (p *Pair) WriteTo(fd uintptr, n int) (int, error) { - panic("not implemented") - return 0, nil -} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pair_linux.go b/vendor/github.com/hanwen/go-fuse/splice/pair_linux.go deleted file mode 100644 index 5e27d1f0..00000000 --- a/vendor/github.com/hanwen/go-fuse/splice/pair_linux.go +++ /dev/null @@ -1,33 +0,0 @@ -package splice - -import ( - "fmt" - "os" - "syscall" -) - -func (p *Pair) LoadFromAt(fd uintptr, sz int, off int64) (int, error) { - n, err := syscall.Splice(int(fd), &off, int(p.w.Fd()), nil, sz, 0) - return int(n), err -} - -func (p *Pair) LoadFrom(fd uintptr, sz int) (int, error) { - if sz > p.size { - return 0, fmt.Errorf("LoadFrom: not enough space %d, %d", - sz, p.size) - } - - n, err := syscall.Splice(int(fd), nil, int(p.w.Fd()), nil, sz, 0) - if err != nil { - err = os.NewSyscallError("Splice load from", err) - } - return int(n), err -} - -func (p *Pair) WriteTo(fd uintptr, n int) (int, error) { - m, err := syscall.Splice(int(p.r.Fd()), nil, int(fd), nil, int(n), 0) - if err != nil { - err = os.NewSyscallError("Splice write", err) - } - return int(m), err -} diff --git a/vendor/github.com/hanwen/go-fuse/splice/pool.go b/vendor/github.com/hanwen/go-fuse/splice/pool.go deleted file mode 100644 index 28c3911f..00000000 --- a/vendor/github.com/hanwen/go-fuse/splice/pool.go +++ /dev/null @@ -1,115 +0,0 @@ -package splice - -import ( - "io" - "sync" -) - -var splicePool *pairPool - -type pairPool struct { - sync.Mutex - unused []*Pair - usedCount int -} - -func ClearSplicePool() { - splicePool.clear() -} - -func Get() (*Pair, error) { - return splicePool.get() -} - -func Total() int { - return splicePool.total() -} - -func Used() int { - return splicePool.used() -} - -// Return pipe pair to pool -func Done(p *Pair) { - splicePool.done(p) -} - -// Closes and discards pipe pair. -func Drop(p *Pair) { - splicePool.drop(p) -} - -func newSplicePairPool() *pairPool { - return &pairPool{} -} - -func (me *pairPool) clear() { - me.Lock() - for _, p := range me.unused { - p.Close() - } - me.unused = me.unused[:0] - me.Unlock() -} - -func (me *pairPool) used() (n int) { - me.Lock() - n = me.usedCount - me.Unlock() - - return n -} - -func (me *pairPool) total() int { - me.Lock() - n := me.usedCount + len(me.unused) - me.Unlock() - return n -} - -func (me *pairPool) drop(p *Pair) { - p.Close() - me.Lock() - me.usedCount-- - me.Unlock() -} - -func (me *pairPool) get() (p *Pair, err error) { - me.Lock() - defer me.Unlock() - - me.usedCount++ - l := len(me.unused) - if l > 0 { - p := me.unused[l-1] - me.unused = me.unused[:l-1] - return p, nil - } - - return newSplicePair() -} - -var discardBuffer [32 * 1024]byte - -func DiscardAll(r io.Reader) { - buf := discardBuffer[:] - for { - n, _ := r.Read(buf) - if n < len(buf) { - break - } - } -} - -func (me *pairPool) done(p *Pair) { - DiscardAll(p.r) - - me.Lock() - me.usedCount-- - me.unused = append(me.unused, p) - me.Unlock() -} - -func init() { - splicePool = newSplicePairPool() -} diff --git a/vendor/github.com/hanwen/go-fuse/splice/splice.go b/vendor/github.com/hanwen/go-fuse/splice/splice.go deleted file mode 100644 index f415e786..00000000 --- a/vendor/github.com/hanwen/go-fuse/splice/splice.go +++ /dev/null @@ -1,86 +0,0 @@ -package splice - -// Routines for efficient file to file copying. - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "syscall" -) - -var maxPipeSize int -var resizable bool - -func Resizable() bool { - return resizable -} - -func MaxPipeSize() int { - return maxPipeSize -} - -// From manpage on ubuntu Lucid: -// -// Since Linux 2.6.11, the pipe capacity is 65536 bytes. -const DefaultPipeSize = 16 * 4096 - -func init() { - content, err := ioutil.ReadFile("/proc/sys/fs/pipe-max-size") - if err != nil { - maxPipeSize = DefaultPipeSize - } else { - fmt.Sscan(string(content), &maxPipeSize) - } - - r, w, err := os.Pipe() - if err != nil { - log.Panicf("cannot create pipe: %v", err) - } - sz, errNo := fcntl(r.Fd(), F_GETPIPE_SZ, 0) - resizable = (errNo == 0) - _, errNo = fcntl(r.Fd(), F_SETPIPE_SZ, 2*sz) - resizable = resizable && (errNo == 0) - r.Close() - w.Close() -} - -// copy & paste from syscall. -func fcntl(fd uintptr, cmd int, arg int) (val int, errno syscall.Errno) { - r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), uintptr(arg)) - val = int(r0) - errno = syscall.Errno(e1) - return -} - -const F_SETPIPE_SZ = 1031 -const F_GETPIPE_SZ = 1032 - -func newSplicePair() (p *Pair, err error) { - p = &Pair{} - p.r, p.w, err = os.Pipe() - if err != nil { - return nil, err - } - - errNo := syscall.Errno(0) - for _, f := range []*os.File{p.r, p.w} { - _, errNo = fcntl(f.Fd(), syscall.F_SETFL, syscall.O_NONBLOCK) - if errNo != 0 { - p.Close() - return nil, os.NewSyscallError("fcntl setfl", errNo) - } - } - - p.size, errNo = fcntl(p.r.Fd(), F_GETPIPE_SZ, 0) - if errNo == syscall.EINVAL { - p.size = DefaultPipeSize - return p, nil - } - if errNo != 0 { - p.Close() - return nil, os.NewSyscallError("fcntl getsize", errNo) - } - return p, nil -} diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go new file mode 100644 index 00000000..19235cf2 --- /dev/null +++ b/vendor/golang.org/x/net/context/context.go @@ -0,0 +1,447 @@ +// 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 context defines the Context type, which carries deadlines, +// cancelation signals, and other request-scoped values across API boundaries +// and between processes. +// +// Incoming requests to a server should create a Context, and outgoing calls to +// servers should accept a Context. The chain of function calls between must +// propagate the Context, optionally replacing it with a modified copy created +// using WithDeadline, WithTimeout, WithCancel, or WithValue. +// +// Programs that use Contexts should follow these rules to keep interfaces +// consistent across packages and enable static analysis tools to check context +// propagation: +// +// Do not store Contexts inside a struct type; instead, pass a Context +// explicitly to each function that needs it. The Context should be the first +// parameter, typically named ctx: +// +// func DoSomething(ctx context.Context, arg Arg) error { +// // ... use ctx ... +// } +// +// Do not pass a nil Context, even if a function permits it. Pass context.TODO +// if you are unsure about which Context to use. +// +// Use context Values only for request-scoped data that transits processes and +// APIs, not for passing optional parameters to functions. +// +// The same Context may be passed to functions running in different goroutines; +// Contexts are safe for simultaneous use by multiple goroutines. +// +// See http://blog.golang.org/context for example code for a server that uses +// Contexts. +package context // import "golang.org/x/net/context" + +import ( + "errors" + "fmt" + "sync" + "time" +) + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context interface { + // Deadline returns the time when work done on behalf of this context + // should be canceled. Deadline returns ok==false when no deadline is + // set. Successive calls to Deadline return the same results. + Deadline() (deadline time.Time, ok bool) + + // Done returns a channel that's closed when work done on behalf of this + // context should be canceled. Done may return nil if this context can + // never be canceled. Successive calls to Done return the same value. + // + // WithCancel arranges for Done to be closed when cancel is called; + // WithDeadline arranges for Done to be closed when the deadline + // expires; WithTimeout arranges for Done to be closed when the timeout + // elapses. + // + // Done is provided for use in select statements: + // + // // Stream generates values with DoSomething and sends them to out + // // until DoSomething returns an error or ctx.Done is closed. + // func Stream(ctx context.Context, out <-chan Value) error { + // for { + // v, err := DoSomething(ctx) + // if err != nil { + // return err + // } + // select { + // case <-ctx.Done(): + // return ctx.Err() + // case out <- v: + // } + // } + // } + // + // See http://blog.golang.org/pipelines for more examples of how to use + // a Done channel for cancelation. + Done() <-chan struct{} + + // Err returns a non-nil error value after Done is closed. Err returns + // Canceled if the context was canceled or DeadlineExceeded if the + // context's deadline passed. No other values for Err are defined. + // After Done is closed, successive calls to Err return the same value. + Err() error + + // Value returns the value associated with this context for key, or nil + // if no value is associated with key. Successive calls to Value with + // the same key returns the same result. + // + // Use context values only for request-scoped data that transits + // processes and API boundaries, not for passing optional parameters to + // functions. + // + // A key identifies a specific value in a Context. Functions that wish + // to store values in Context typically allocate a key in a global + // variable then use that key as the argument to context.WithValue and + // Context.Value. A key can be any type that supports equality; + // packages should define keys as an unexported type to avoid + // collisions. + // + // Packages that define a Context key should provide type-safe accessors + // for the values stores using that key: + // + // // Package user defines a User type that's stored in Contexts. + // package user + // + // import "golang.org/x/net/context" + // + // // User is the type of value stored in the Contexts. + // type User struct {...} + // + // // key is an unexported type for keys defined in this package. + // // This prevents collisions with keys defined in other packages. + // type key int + // + // // userKey is the key for user.User values in Contexts. It is + // // unexported; clients use user.NewContext and user.FromContext + // // instead of using this key directly. + // var userKey key = 0 + // + // // NewContext returns a new Context that carries value u. + // func NewContext(ctx context.Context, u *User) context.Context { + // return context.WithValue(ctx, userKey, u) + // } + // + // // FromContext returns the User value stored in ctx, if any. + // func FromContext(ctx context.Context) (*User, bool) { + // u, ok := ctx.Value(userKey).(*User) + // return u, ok + // } + Value(key interface{}) interface{} +} + +// Canceled is the error returned by Context.Err when the context is canceled. +var Canceled = errors.New("context canceled") + +// DeadlineExceeded is the error returned by Context.Err when the context's +// deadline passes. +var DeadlineExceeded = errors.New("context deadline exceeded") + +// An emptyCtx is never canceled, has no values, and has no deadline. It is not +// struct{}, since vars of this type must have distinct addresses. +type emptyCtx int + +func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { + return +} + +func (*emptyCtx) Done() <-chan struct{} { + return nil +} + +func (*emptyCtx) Err() error { + return nil +} + +func (*emptyCtx) Value(key interface{}) interface{} { + return nil +} + +func (e *emptyCtx) String() string { + switch e { + case background: + return "context.Background" + case todo: + return "context.TODO" + } + return "unknown empty Context" +} + +var ( + background = new(emptyCtx) + todo = new(emptyCtx) +) + +// Background returns a non-nil, empty Context. It is never canceled, has no +// values, and has no deadline. It is typically used by the main function, +// initialization, and tests, and as the top-level Context for incoming +// requests. +func Background() Context { + return background +} + +// TODO returns a non-nil, empty Context. Code should use context.TODO when +// it's unclear which Context to use or it is not yet available (because the +// surrounding function has not yet been extended to accept a Context +// parameter). TODO is recognized by static analysis tools that determine +// whether Contexts are propagated correctly in a program. +func TODO() Context { + return todo +} + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc func() + +// WithCancel returns a copy of parent with a new Done channel. The returned +// context's Done channel is closed when the returned cancel function is called +// or when the parent context's Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete. +func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { + c := newCancelCtx(parent) + propagateCancel(parent, c) + return c, func() { c.cancel(true, Canceled) } +} + +// newCancelCtx returns an initialized cancelCtx. +func newCancelCtx(parent Context) *cancelCtx { + return &cancelCtx{ + Context: parent, + done: make(chan struct{}), + } +} + +// propagateCancel arranges for child to be canceled when parent is. +func propagateCancel(parent Context, child canceler) { + if parent.Done() == nil { + return // parent is never canceled + } + if p, ok := parentCancelCtx(parent); ok { + p.mu.Lock() + if p.err != nil { + // parent has already been canceled + child.cancel(false, p.err) + } else { + if p.children == nil { + p.children = make(map[canceler]bool) + } + p.children[child] = true + } + p.mu.Unlock() + } else { + go func() { + select { + case <-parent.Done(): + child.cancel(false, parent.Err()) + case <-child.Done(): + } + }() + } +} + +// parentCancelCtx follows a chain of parent references until it finds a +// *cancelCtx. This function understands how each of the concrete types in this +// package represents its parent. +func parentCancelCtx(parent Context) (*cancelCtx, bool) { + for { + switch c := parent.(type) { + case *cancelCtx: + return c, true + case *timerCtx: + return c.cancelCtx, true + case *valueCtx: + parent = c.Context + default: + return nil, false + } + } +} + +// removeChild removes a context from its parent. +func removeChild(parent Context, child canceler) { + p, ok := parentCancelCtx(parent) + if !ok { + return + } + p.mu.Lock() + if p.children != nil { + delete(p.children, child) + } + p.mu.Unlock() +} + +// A canceler is a context type that can be canceled directly. The +// implementations are *cancelCtx and *timerCtx. +type canceler interface { + cancel(removeFromParent bool, err error) + Done() <-chan struct{} +} + +// A cancelCtx can be canceled. When canceled, it also cancels any children +// that implement canceler. +type cancelCtx struct { + Context + + done chan struct{} // closed by the first cancel call. + + mu sync.Mutex + children map[canceler]bool // set to nil by the first cancel call + err error // set to non-nil by the first cancel call +} + +func (c *cancelCtx) Done() <-chan struct{} { + return c.done +} + +func (c *cancelCtx) Err() error { + c.mu.Lock() + defer c.mu.Unlock() + return c.err +} + +func (c *cancelCtx) String() string { + return fmt.Sprintf("%v.WithCancel", c.Context) +} + +// cancel closes c.done, cancels each of c's children, and, if +// removeFromParent is true, removes c from its parent's children. +func (c *cancelCtx) cancel(removeFromParent bool, err error) { + if err == nil { + panic("context: internal error: missing cancel error") + } + c.mu.Lock() + if c.err != nil { + c.mu.Unlock() + return // already canceled + } + c.err = err + close(c.done) + for child := range c.children { + // NOTE: acquiring the child's lock while holding parent's lock. + child.cancel(false, err) + } + c.children = nil + c.mu.Unlock() + + if removeFromParent { + removeChild(c.Context, c) + } +} + +// WithDeadline returns a copy of the parent context with the deadline adjusted +// to be no later than d. If the parent's deadline is already earlier than d, +// WithDeadline(parent, d) is semantically equivalent to parent. The returned +// context's Done channel is closed when the deadline expires, when the returned +// cancel function is called, or when the parent context's Done channel is +// closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete. +func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { + if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { + // The current deadline is already sooner than the new one. + return WithCancel(parent) + } + c := &timerCtx{ + cancelCtx: newCancelCtx(parent), + deadline: deadline, + } + propagateCancel(parent, c) + d := deadline.Sub(time.Now()) + if d <= 0 { + c.cancel(true, DeadlineExceeded) // deadline has already passed + return c, func() { c.cancel(true, Canceled) } + } + c.mu.Lock() + defer c.mu.Unlock() + if c.err == nil { + c.timer = time.AfterFunc(d, func() { + c.cancel(true, DeadlineExceeded) + }) + } + return c, func() { c.cancel(true, Canceled) } +} + +// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to +// implement Done and Err. It implements cancel by stopping its timer then +// delegating to cancelCtx.cancel. +type timerCtx struct { + *cancelCtx + timer *time.Timer // Under cancelCtx.mu. + + deadline time.Time +} + +func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { + return c.deadline, true +} + +func (c *timerCtx) String() string { + return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) +} + +func (c *timerCtx) cancel(removeFromParent bool, err error) { + c.cancelCtx.cancel(false, err) + if removeFromParent { + // Remove this timerCtx from its parent cancelCtx's children. + removeChild(c.cancelCtx.Context, c) + } + c.mu.Lock() + if c.timer != nil { + c.timer.Stop() + c.timer = nil + } + c.mu.Unlock() +} + +// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete: +// +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } +func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { + return WithDeadline(parent, time.Now().Add(timeout)) +} + +// WithValue returns a copy of parent in which the value associated with key is +// val. +// +// Use context Values only for request-scoped data that transits processes and +// APIs, not for passing optional parameters to functions. +func WithValue(parent Context, key interface{}, val interface{}) Context { + return &valueCtx{parent, key, val} +} + +// A valueCtx carries a key-value pair. It implements Value for that key and +// delegates all other calls to the embedded Context. +type valueCtx struct { + Context + key, val interface{} +} + +func (c *valueCtx) String() string { + return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) +} + +func (c *valueCtx) Value(key interface{}) interface{} { + if c.key == key { + return c.val + } + return c.Context.Value(key) +} From ed9c7f4f359c8f00548c713a7cd89490018fa519 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 179/357] package: Fix `oci runtime error: exec format error` Also remove debug level for launch-simple-longhorn --- package/launch-simple-longhorn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/launch-simple-longhorn b/package/launch-simple-longhorn index ecefca31..297df7cd 100755 --- a/package/launch-simple-longhorn +++ b/package/launch-simple-longhorn @@ -1,3 +1,5 @@ +#!/bin/bash + set -x mount --rbind /host/dev /dev @@ -11,4 +13,4 @@ volume=$1 longhorn replica --size 1g --listen localhost:9502 /volume/ & sleep 1 -exec longhorn --debug controller --frontend tcmu --replica tcp://localhost:9502 $volume +exec longhorn controller --frontend tcmu --replica tcp://localhost:9502 $volume From 316282008251985f957a93036a1e695e9172fcc2 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 180/357] test: Add direct-io package We should read/write device in direct-io way always. --- Dockerfile.dapper | 3 ++- integration/requirements.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 412db0e5..c22063ae 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -24,7 +24,8 @@ RUN apt-get update && \ psmisc \ python-tox \ qemu-utils \ - fuse + fuse \ + python-dev # Install Go 1.6 RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz diff --git a/integration/requirements.txt b/integration/requirements.txt index afcbb445..6bc8668d 100644 --- a/integration/requirements.txt +++ b/integration/requirements.txt @@ -1,4 +1,5 @@ cattle==0.5.1 +directio==1.2 flake8 pytest==2.3.5 From 3d2690e9eb8975eefc81cd7e403262dc73506124 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 181/357] test: Direct IO enabled fuse test --- frontend/fusedev/frontend.go | 7 ++-- integration/data/common.py | 1 + integration/data/frontend.py | 53 ++++++++++++++++++++++++++--- integration/data/test_basic_ops.py | 17 +++++---- integration/flake8-requirements.txt | 1 + integration/tox.ini | 2 +- 6 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 integration/flake8-requirements.txt diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index e112058b..f6b537a5 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -26,6 +26,9 @@ func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWrit } func (f *Fuse) Shutdown() error { - log.Infof("Shutdown FUSE frontend for %v", f.lf.Volume) - return f.lf.Stop() + if f.lf != nil { + log.Infof("Shutdown FUSE frontend for %v", f.lf.Volume) + return f.lf.Stop() + } + return nil } diff --git a/integration/data/common.py b/integration/data/common.py index 9c66d806..26b0dc56 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -10,6 +10,7 @@ import cattle from frontend import restdev, fusedev +from frontend import PAGE_SIZE # NOQA REPLICA1 = 'tcp://localhost:9502' diff --git a/integration/data/frontend.py b/integration/data/frontend.py index 74ccce1d..81cc48fa 100644 --- a/integration/data/frontend.py +++ b/integration/data/frontend.py @@ -1,11 +1,58 @@ import base64 +import os from os import path +import mmap +import directio import cattle LONGHORN_DEV_DIR = '/dev/longhorn' +PAGE_SIZE = 512 + + +def readat_direct(dev, offset, length): + pg = offset / PAGE_SIZE + in_page_offset = offset % PAGE_SIZE + # either read less than a page, or whole pages + if in_page_offset != 0: + assert pg == (offset + length - 1) / PAGE_SIZE + to_read = PAGE_SIZE + else: + assert length % PAGE_SIZE == 0 + to_read = length + pg_offset = pg * PAGE_SIZE + + f = os.open(dev, os.O_DIRECT | os.O_RDONLY) + try: + os.lseek(f, pg_offset, os.SEEK_SET) + ret = directio.read(f, to_read) + finally: + os.close(f) + return ret[in_page_offset: in_page_offset + length] + + +def writeat_direct(dev, offset, data): + pg = offset / PAGE_SIZE + # don't support across page write + assert pg == (offset + len(data) - 1) / PAGE_SIZE + pg_offset = pg * PAGE_SIZE + + f = os.open(dev, os.O_DIRECT | os.O_RDWR) + m = mmap.mmap(-1, PAGE_SIZE) + try: + os.lseek(f, pg_offset, os.SEEK_SET) + pg_data = readat_direct(dev, pg_offset, PAGE_SIZE) + m.write(pg_data) + m.seek(offset % PAGE_SIZE) + m.write(data) + ret = directio.write(f, m) + finally: + m.close() + os.close(f) + return ret + class restdev: @@ -47,9 +94,7 @@ def readat(self, offset, length): f.seek(offset) ret = f.read(length) return ret + # return readat_direct(self.dev, offset, length) def writeat(self, offset, data): - with open(self.dev, 'r+b') as f: - f.seek(offset) - ret = f.write(data) - return ret + return writeat_direct(self.dev, offset, data) diff --git a/integration/data/test_basic_ops.py b/integration/data/test_basic_ops.py index 75a2a4a9..cd108832 100644 --- a/integration/data/test_basic_ops.py +++ b/integration/data/test_basic_ops.py @@ -4,13 +4,16 @@ import common from common import dev # NOQA -from common import SIZE, read_dev, write_dev +from common import PAGE_SIZE, SIZE, read_dev, write_dev def test_basic_rw(dev): # NOQA for i in range(0, 10): - offset = random.randint(0, SIZE - 256) - length = random.randint(0, 256) + base = random.randint(0, SIZE - PAGE_SIZE) + offset = (base / PAGE_SIZE) * PAGE_SIZE + length = base - offset + if length == 0: + length = 128 data = common.random_string(length) common.verify_data(dev, offset, data) @@ -22,14 +25,10 @@ def test_beyond_boundary(dev): # NOQA common.verify_data(dev, SIZE - 128, data) # out of bounds - with pytest.raises(IOError) as err: + with pytest.raises(EnvironmentError) as err: write_dev(dev, SIZE, "1") assert 'No space left' in str(err.value) assert len(read_dev(dev, SIZE, 1)) == 0 # normal writes to verify controller/replica survival - for i in range(0, 10): - offset = random.randint(0, SIZE - 256) - length = random.randint(0, 256) - data = common.random_string(length) - common.verify_data(dev, offset, data) + test_basic_rw(dev) diff --git a/integration/flake8-requirements.txt b/integration/flake8-requirements.txt new file mode 100644 index 00000000..39304807 --- /dev/null +++ b/integration/flake8-requirements.txt @@ -0,0 +1 @@ +flake8 diff --git a/integration/tox.ini b/integration/tox.ini index d28d5d38..f3e93d3c 100644 --- a/integration/tox.ini +++ b/integration/tox.ini @@ -7,6 +7,6 @@ changedir={toxinidir} commands=py.test core data --durations=20 {posargs} [testenv:flake8] -deps=-rrequirements.txt +deps=-rflake8-requirements.txt changedir={toxinidir} commands=flake8 core data From f12afe78ec31e36935a633bf5ea04010b680d1a7 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 182/357] fuse: Fix bad file descriptor --- frontend/fusedev/frontend.go | 2 +- frontend/fusedev/fuse.go | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index f6b537a5..31d3cc61 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -13,11 +13,11 @@ type Fuse struct { } func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { - f.lf = newLonghornFs(name, size, sectorSize, rw) if err := f.Shutdown(); err != nil { return err } + f.lf = newLonghornFs(name, size, sectorSize, rw) log.Infof("Activate FUSE frontend for %v, size %v, sector size %v", name, size, sectorSize) if err := f.lf.Start(); err != nil { return err diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index bbf3ab95..a997cdfb 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -65,7 +65,7 @@ func (lf *LonghornFs) Start() error { fuse.VolumeName(lf.Volume), ) if err != nil { - log.Fatal(err) + log.Fatal("FUSE: Unable to mount: ", err) } go lf.startFs() @@ -78,16 +78,28 @@ func (lf *LonghornFs) Start() error { func (lf *LonghornFs) startFs() { if err := fs.Serve(lf.Conn, lf); err != nil { - log.Fatal(err) + // Likely caused by umount, so ignore it for now + if err == unix.EBADF { + log.Warnf("Serve return ", err) + } else { + log.Fatal("FUSE: Unable to serve: ", err) + } } <-lf.Conn.Ready if err := lf.Conn.MountError; err != nil { - log.Fatal(err) + log.Fatal("FUSE: Mount error occured: ", err) } } func (lf *LonghornFs) Stop() error { + if err := lf.initStop(); err != nil { + return err + } + return nil +} + +func (lf *LonghornFs) initStop() error { if lf.Conn != nil { defer lf.Conn.Close() } From ce7f763381be38f8759794fd5d925056b99286c3 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 183/357] fuse: Enable async dio Will only usable if file is opened with O_DIRECT. And file cannot be opened with fuse.OpenDirectIO flag. --- frontend/fusedev/fuse.go | 1 + vendor/bazil.org/fuse/options.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index a997cdfb..245f9e41 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -63,6 +63,7 @@ func (lf *LonghornFs) Start() error { fuse.FSName("longhorn"), fuse.Subtype("longhornfs"), fuse.VolumeName(lf.Volume), + fuse.AsyncDIO(), ) if err != nil { log.Fatal("FUSE: Unable to mount: ", err) diff --git a/vendor/bazil.org/fuse/options.go b/vendor/bazil.org/fuse/options.go index caee4953..1ea42d03 100644 --- a/vendor/bazil.org/fuse/options.go +++ b/vendor/bazil.org/fuse/options.go @@ -209,6 +209,13 @@ func AsyncRead() MountOption { } } +func AsyncDIO() MountOption { + return func(conf *mountConfig) error { + conf.initFlags |= InitAsyncDIO + return nil + } +} + // WritebackCache enables the kernel to buffer writes before sending // them to the FUSE server. Without this, writethrough caching is // used. From 9c1eba0b66bb39fb90d3f98bba00d6b0a1d8b536 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 26 Aug 2016 11:35:57 -0700 Subject: [PATCH 184/357] package: Add frontend option to `launch-simple-longhorn` --- package/launch-simple-longhorn | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/package/launch-simple-longhorn b/package/launch-simple-longhorn index 297df7cd..63804380 100755 --- a/package/launch-simple-longhorn +++ b/package/launch-simple-longhorn @@ -3,14 +3,23 @@ set -x mount --rbind /host/dev /dev -if [ -z $1 ] +volume=$1 +frontend=$2 + +if [ -z $volume ] then - echo Need a volume name as first parameter + echo "Usage: launch-simple-longhorn " + echo ": Required. User defined volume name" + echo ": Optional. By default 'tcmu'. " exit -1 fi -volume=$1 +if [ -z $frontend ] +then + echo Use default frontend TCMU + frontend="tcmu" +fi longhorn replica --size 1g --listen localhost:9502 /volume/ & sleep 1 -exec longhorn controller --frontend tcmu --replica tcp://localhost:9502 $volume +exec longhorn controller --frontend $frontend --replica tcp://localhost:9502 $volume From 6d42681030267ec122cae2ee60739c1271ed3646 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 31 Aug 2016 18:29:12 -0700 Subject: [PATCH 185/357] build: Change ubuntu sources.list use nearest mirror `archive.ubuntu.com` is way too slow for new build. It's painful to wait. --- Dockerfile.dapper | 3 ++- package/Dockerfile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index c22063ae..ce2cd851 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -11,7 +11,8 @@ ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} # Install packages -RUN apt-get update && \ +RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ + apt-get update && \ apt-get install -y \ cmake \ curl \ diff --git a/package/Dockerfile b/package/Dockerfile index add6a6d4..67fa59b5 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,5 +1,6 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y kmod curl nfs-common fuse +RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ + apt-get update && apt-get install -y kmod curl nfs-common fuse RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.1.2/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin From 204959dd0ef46eb3084f252cd1ec8b57afb6b493 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 31 Aug 2016 18:45:29 -0700 Subject: [PATCH 186/357] build: Update to use Go 1.7 --- Dockerfile.dapper | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ce2cd851..19f61cee 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -28,9 +28,9 @@ RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.co fuse \ python-dev -# Install Go 1.6 -RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz -RUN echo 'e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a go.tar.gz' | sha256sum -c && \ +# Install Go +RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz +RUN echo '702ad90f705365227e902b42d91dd1a40e48ca7f67a2f4b2fd052aaa4295cd95 go.tar.gz' | sha256sum -c && \ tar xzf go.tar.gz -C /usr/local && \ rm go.tar.gz RUN mkdir -p /go From c1dcef43d67d8f25f16251ca341442ba5827b05c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 31 Aug 2016 18:51:46 -0700 Subject: [PATCH 187/357] build: Add tgt in the build And install the result deb package in the longhorn container --- Dockerfile.dapper | 24 ++++++++++-------------- package/Dockerfile | 4 +++- scripts/package | 1 + 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 19f61cee..3e675284 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -13,20 +13,9 @@ WORKDIR ${DAPPER_SOURCE} # Install packages RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ apt-get update && \ - apt-get install -y \ - cmake \ - curl \ - git \ - libglib2.0-dev \ - libkmod-dev \ - libnl-genl-3-dev \ - linux-libc-dev \ - pkg-config \ - psmisc \ - python-tox \ - qemu-utils \ - fuse \ - python-dev + apt-get install -y cmake curl git \ + libglib2.0-dev libkmod-dev libnl-genl-3-dev linux-libc-dev pkg-config psmisc python-tox qemu-utils fuse python-dev \ + devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl # Install Go RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz @@ -74,6 +63,13 @@ RUN cd /usr/src/libqcow-20160123 && \ make -j$(nproc) && \ make install +# Build TGT +RUN cd /usr/src && \ + git clone https://github.com/yasker/tgt.git && \ + cd tgt && \ + git checkout 2cee9922fcc030b347477e020b3b7aebc4518b6f && \ + ./scripts/build-pkg.sh deb + VOLUME /tmp ENV TMPDIR /tmp ENTRYPOINT ["./scripts/entry"] diff --git a/package/Dockerfile b/package/Dockerfile index 67fa59b5..afc8801e 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,9 +1,11 @@ FROM ubuntu:16.04 RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ - apt-get update && apt-get install -y kmod curl nfs-common fuse + apt-get update && apt-get install -y kmod curl nfs-common fuse libibverbs1 librdmacm1 libconfig-general-perl RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.1.2/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/bin/ +COPY tgt_*.deb /opt/ +RUN dpkg -i /opt/tgt_*.deb CMD ["longhorn"] diff --git a/scripts/package b/scripts/package index f4b1f94c..620899e2 100755 --- a/scripts/package +++ b/scripts/package @@ -14,6 +14,7 @@ fi cp ../bin/longhorn* . cp /usr/local/bin/docker-longhorn-driver . +cp /usr/src/tgt/pkg/tgt_*.deb . docker build -t ${REPO}/longhorn:${TAG} . echo Built ${REPO}/longhorn:${TAG} From 67e5455c351ed76e1dbe6774761b78ab8af3d1ed Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 19 Sep 2016 17:35:14 -0700 Subject: [PATCH 188/357] fuse: Replace loopback device with iscsi device Require open-iscsi to be installed on the host --- Dockerfile.dapper | 7 +- frontend/fusedev/fuse.go | 74 ++----- trash.yml | 2 + util/util.go | 91 ++++++++ .../yasker/go-iscsi-helper/.gitignore | 24 +++ .../yasker/go-iscsi-helper/Dockerfile.dapper | 47 ++++ .../github.com/yasker/go-iscsi-helper/LICENSE | 201 ++++++++++++++++++ .../yasker/go-iscsi-helper/Makefile | 23 ++ .../yasker/go-iscsi-helper/README.md | 12 ++ .../yasker/go-iscsi-helper/iscsi/initiator.go | 153 +++++++++++++ .../yasker/go-iscsi-helper/iscsi/target.go | 121 +++++++++++ .../yasker/go-iscsi-helper/trash.conf | 12 ++ .../yasker/go-iscsi-helper/util/util.go | 68 ++++++ 13 files changed, 775 insertions(+), 60 deletions(-) create mode 100644 vendor/github.com/yasker/go-iscsi-helper/.gitignore create mode 100644 vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper create mode 100644 vendor/github.com/yasker/go-iscsi-helper/LICENSE create mode 100644 vendor/github.com/yasker/go-iscsi-helper/Makefile create mode 100644 vendor/github.com/yasker/go-iscsi-helper/README.md create mode 100644 vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go create mode 100644 vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go create mode 100644 vendor/github.com/yasker/go-iscsi-helper/trash.conf create mode 100644 vendor/github.com/yasker/go-iscsi-helper/util/util.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 3e675284..0c942522 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -5,7 +5,7 @@ ENV PATH /go/bin:$PATH ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_ENV TAG REPO ENV DAPPER_OUTPUT bin -ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec -v /dev:/host/dev --pid host +ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec -v /dev:/host/dev -v /proc:/host/proc ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} @@ -15,7 +15,7 @@ RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.co apt-get update && \ apt-get install -y cmake curl git \ libglib2.0-dev libkmod-dev libnl-genl-3-dev linux-libc-dev pkg-config psmisc python-tox qemu-utils fuse python-dev \ - devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl + devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl libconfig-general-perl # Install Go RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz @@ -68,7 +68,8 @@ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ git checkout 2cee9922fcc030b347477e020b3b7aebc4518b6f && \ - ./scripts/build-pkg.sh deb + ./scripts/build-pkg.sh deb && \ + dpkg -i ./pkg/tgt_*.deb VOLUME /tmp ENV TMPDIR /tmp diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 245f9e41..105e9517 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -7,20 +7,23 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/util" "golang.org/x/net/context" "golang.org/x/sys/unix" "bazil.org/fuse" "bazil.org/fuse/fs" + cutil "github.com/rancher/convoy/util" + "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" ) type LonghornFs struct { Conn *fuse.Conn Volume string rawFile *RawFrontendFile + scsiDev *util.ScsiDevice } type RawFrontendFile struct { @@ -72,6 +75,7 @@ func (lf *LonghornFs) Start() error { go lf.startFs() if err := lf.createDev(); err != nil { + log.Warn("Fail to bring up device, waiting") return err } return nil @@ -117,26 +121,6 @@ func (lf *LonghornFs) getDev() string { return filepath.Join(DevPath, lf.Volume) } -func (lf *LonghornFs) getLoopbackDev() (string, error) { - devs, err := lf.getLoopbackDevs() - if err != nil { - return "", err - } - if len(devs) != 1 { - return "", fmt.Errorf("Found more than one loopback devices %v", devs) - } - return devs[0], nil -} - -func (lf *LonghornFs) getLoopbackDevs() ([]string, error) { - filePath := lf.getImageFileFullPath() - devs, err := util.ListLoopbackDevice(filePath) - if err != nil { - return nil, err - } - return devs, nil -} - func (lf *LonghornFs) createDev() error { if err := os.MkdirAll(DevPath, 0700); err != nil { log.Fatalln("Cannot create directory ", DevPath) @@ -166,19 +150,19 @@ func (lf *LonghornFs) createDev() error { return fmt.Errorf("Fail to wait for %v", path) } - logrus.Infof("Attaching loopback device") - _, err := util.AttachLoopbackDevice(path, false) - if err != nil { - return err + if lf.scsiDev == nil { + scsiDev, err := util.NewScsiDevice(lf.Volume, path) + if err != nil { + return err + } + lf.scsiDev = scsiDev } - lodev, err := lf.getLoopbackDev() - if err != nil { + if err := lf.scsiDev.Startup(); err != nil { return err } - logrus.Infof("Attached loopback device %v", lodev) stat := unix.Stat_t{} - if err := unix.Stat(lodev, &stat); err != nil { + if err := unix.Stat(lf.scsiDev.Device, &stat); err != nil { return err } major := int(stat.Rdev / 256) @@ -199,33 +183,9 @@ func (lf *LonghornFs) removeDev() error { } } - lodevs, err := lf.getLoopbackDevs() - if err != nil { - return fmt.Errorf("Failed to get loopback device %v", err) - } - for _, lodev := range lodevs { - logrus.Infof("Detaching loopback device %s", lodev) - if err := util.DetachLoopbackDevice(lf.getImageFileFullPath(), lodev); err != nil { - return fmt.Errorf("Fail to detach loopback device %s: %v", lodev, err) - } - - detached := false - devs := []string{} - for i := 0; i < RetryCounts; i++ { - var err error - devs, err = util.ListLoopbackDevice(lf.getImageFileFullPath()) - if err != nil { - return err - } - if len(devs) == 0 { - detached = true - break - } - logrus.Infof("Waitting for detaching loopback device", devs) - time.Sleep(RetryInterval) - } - if !detached { - return fmt.Errorf("Loopback device busy, cannot detach device, devices %v remains", devs) + if lf.scsiDev.Device != "" { + if err := lf.scsiDev.Shutdown(); err != nil { + return err } } return nil @@ -244,7 +204,7 @@ func (lf *LonghornFs) umountFuse() error { func (lf *LonghornFs) isMounted() bool { path := lf.GetMountDir() - if _, err := util.Execute("findmnt", []string{path}); err != nil { + if _, err := cutil.Execute("findmnt", []string{path}); err != nil { return false } return true diff --git a/trash.yml b/trash.yml index 0b7ddf42..6d81b942 100644 --- a/trash.yml +++ b/trash.yml @@ -62,3 +62,5 @@ import: version: b3d5a5514a27076c63844bde6d60703a7aea4adc - package: golang.org/x/net/context version: 31df19d69da8728e9220def59b80ee577c3e48bf +- package: github.com/yasker/go-iscsi-helper + version: 9d43b5b232ad51582b70b0200b7ff5b67a11da65 diff --git a/util/util.go b/util/util.go index 4ca0e5bd..4a3a14be 100644 --- a/util/util.go +++ b/util/util.go @@ -9,6 +9,8 @@ import ( "github.com/gorilla/handlers" "github.com/satori/go.uuid" + "github.com/yasker/go-iscsi-helper/iscsi" + iutil "github.com/yasker/go-iscsi-helper/util" ) var ( @@ -76,3 +78,92 @@ func (h filteredLoggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque } h.loggingHandler.ServeHTTP(w, req) } + +type ScsiDevice struct { + Target string + TargetID int + LunID int + Device string + Portal string + BackingFile string +} + +func NewScsiDevice(name, backingFile string) (*ScsiDevice, error) { + dev := &ScsiDevice{ + Target: "iqn.2014-07.com.rancher:" + name, + TargetID: 1, + LunID: 1, + BackingFile: backingFile, + } + ips, err := iutil.GetLocalIPs() + if err != nil { + return nil, err + } + dev.Portal = ips[0] + return dev, nil +} + +func (dev *ScsiDevice) Startup() error { + ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + if err != nil { + return err + } + + // Setup target + if err := iscsi.StartDaemon(); err != nil { + return err + } + if err := iscsi.CreateTarget(dev.TargetID, dev.Target); err != nil { + return err + } + if err := iscsi.AddLunBackedByFile(dev.TargetID, dev.LunID, dev.BackingFile); err != nil { + return err + } + if err := iscsi.BindInitiator(dev.TargetID, "ALL"); err != nil { + return err + } + + // Setup initiator + if err := iscsi.DiscoverTarget(dev.Portal, dev.Target, ne); err != nil { + return err + } + if err := iscsi.LoginTarget(dev.Portal, dev.Target, ne); err != nil { + return err + } + if dev.Device, err = iscsi.GetDevice(dev.Portal, dev.Target, dev.LunID, ne); err != nil { + return err + } + return nil +} + +func (dev *ScsiDevice) Shutdown() error { + if dev.Device == "" { + return fmt.Errorf("SCSI Device is already down") + } + + ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + if err != nil { + return err + } + + // Teardown initiator + if err := iscsi.LogoutTarget(dev.Portal, dev.Target, ne); err != nil { + return err + } + dev.Device = "" + if err := iscsi.DeleteDiscoveredTarget(dev.Portal, dev.Target, ne); err != nil { + return err + } + + // Teardown target + if err := iscsi.UnbindInitiator(dev.TargetID, "ALL"); err != nil { + return err + } + if err := iscsi.DeleteLun(dev.TargetID, dev.LunID); err != nil { + return err + } + if err := iscsi.DeleteTarget(dev.TargetID); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/yasker/go-iscsi-helper/.gitignore b/vendor/github.com/yasker/go-iscsi-helper/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/.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/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper b/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper new file mode 100644 index 00000000..2c205b06 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper @@ -0,0 +1,47 @@ +FROM ubuntu:16.04 + +# Setup environment +ENV PATH /go/bin:$PATH +ENV DAPPER_DOCKER_SOCKET true +ENV DAPPER_ENV TAG REPO +ENV DAPPER_OUTPUT bin +ENV DAPPER_RUN_ARGS --privileged -v /dev:/host/dev -v /proc:/host/proc +ENV DAPPER_SOURCE /go/src/github.com/yasker/go-iscsi-helper +ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache +WORKDIR ${DAPPER_SOURCE} + +# Install packages +RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y cmake curl git \ + devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl libconfig-general-perl + +# Install Go +RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz +RUN echo '702ad90f705365227e902b42d91dd1a40e48ca7f67a2f4b2fd052aaa4295cd95 go.tar.gz' | sha256sum -c && \ + tar xzf go.tar.gz -C /usr/local && \ + rm go.tar.gz +RUN mkdir -p /go +ENV PATH $PATH:/usr/local/go/bin +ENV GOPATH=/go + +# Go tools +RUN go get github.com/rancher/trash +RUN go get github.com/golang/lint/golint + +# Docker +RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ + chmod +x /usr/bin/docker + +# Build TGT +RUN cd /usr/src && \ + git clone https://github.com/yasker/tgt.git && \ + cd tgt && \ + git checkout 2cee9922fcc030b347477e020b3b7aebc4518b6f && \ + ./scripts/build-pkg.sh deb && \ + dpkg -i ./pkg/tgt_*.deb + +VOLUME /tmp +ENV TMPDIR /tmp +ENTRYPOINT ["./scripts/entry"] +CMD ["ci"] diff --git a/vendor/github.com/yasker/go-iscsi-helper/LICENSE b/vendor/github.com/yasker/go-iscsi-helper/LICENSE new file mode 100644 index 00000000..8dada3ed --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/LICENSE @@ -0,0 +1,201 @@ + 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/yasker/go-iscsi-helper/Makefile b/vendor/github.com/yasker/go-iscsi-helper/Makefile new file mode 100644 index 00000000..d7d72a16 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/Makefile @@ -0,0 +1,23 @@ +TARGETS := $(shell ls scripts) + +.dapper: + @echo Downloading dapper + @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp + @@chmod +x .dapper.tmp + @./.dapper.tmp -v + @mv .dapper.tmp .dapper + +$(TARGETS): .dapper + ./.dapper $@ + +trash: .dapper + ./.dapper -m bind trash + +trash-keep: .dapper + ./.dapper -m bind trash -k + +deps: trash + +.DEFAULT_GOAL := ci + +.PHONY: $(TARGETS) diff --git a/vendor/github.com/yasker/go-iscsi-helper/README.md b/vendor/github.com/yasker/go-iscsi-helper/README.md new file mode 100644 index 00000000..14c414b6 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/README.md @@ -0,0 +1,12 @@ +# go-iscsi-helper +Helper function for iSCSI + +Require TGT to be installed, as well as open-iscsi. + +If used in container, open-iscsi need to be installed on the host. + +This library is good enough for: +1. Start/stop a iscsi target using tgt, with certain backstores. This can be + done inside container. +2. Start/stop a iscsi initiator on the host, connect to a target then create the + device. diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go new file mode 100644 index 00000000..c31e25cd --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -0,0 +1,153 @@ +package iscsi + +import ( + "bufio" + "fmt" + "strconv" + "strings" + "time" + + "github.com/yasker/go-iscsi-helper/util" +) + +const ( + iscsiBinary = "iscsiadm" + + retryInterval = 1 * time.Second + retryMax = 5 +) + +func DiscoverTarget(ip, target string, ne *util.NamespaceExecutor) error { + opts := []string{ + "-m", "discovery", + "-t", "sendtargets", + "-p", ip, + } + output, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return err + } + if !strings.Contains(output, target) { + return fmt.Errorf("Cannot find target %s in discovered targets %s", target, output) + } + return nil +} + +func DeleteDiscoveredTarget(ip, target string, ne *util.NamespaceExecutor) error { + opts := []string{ + "-m", "node", + "-o", "delete", + "-p", ip, + "-T", target, + } + _, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return err + } + return nil +} + +func LoginTarget(ip, target string, ne *util.NamespaceExecutor) error { + opts := []string{ + "-m", "node", + "-T", target, + "-p", ip, + "--login", + } + _, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return err + } + return nil +} + +func LogoutTarget(ip, target string, ne *util.NamespaceExecutor) error { + opts := []string{ + "-m", "node", + "-T", target, + "-p", ip, + "--logout", + } + _, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return err + } + return nil +} + +func GetDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (string, error) { + var err error + + dev := "" + for i := 0; i < retryMax; i++ { + dev, err = findScsiDevice(ip, target, lun, ne) + if err == nil { + break + } + time.Sleep(retryInterval) + } + if err != nil { + return "", err + } + return strings.TrimSpace(dev), nil +} + +func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (string, error) { + dev := "" + + opts := []string{ + "-m", "session", + "-P", "3", + } + output, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return "", err + } + /* + Now we got something like this in output, and need to parse it + Target: iqn.2016-09.com.rancher:for.all (non-flash) + Current Portal: 172.17.0.2:3260,1 + Persistent Portal: 172.17.0.2:3260,1 + ... + Attached SCSI devices: + ... + scsi12 Channel 00 Id 0 Lun: 0 + scsi12 Channel 00 Id 0 Lun: 1 + Attached scsi disk sdb State: running + ... + Target: ... + */ + scanner := bufio.NewScanner(strings.NewReader(output)) + targetLine := "Target: " + target + lunLine := "Lun: " + strconv.Itoa(lun) + diskPrefix := "Attached scsi disk" + stateLine := "State:" + inTarget := false + inLun := false + for scanner.Scan() { + if !inTarget && strings.Contains(scanner.Text(), targetLine) { + inTarget = true + continue + } + if inTarget && strings.Contains(scanner.Text(), lunLine) { + inLun = true + continue + } + // The line we need + if inLun { + line := scanner.Text() + if !strings.Contains(line, diskPrefix) { + return "", fmt.Errorf("Invalid output format, cannot find disk in: %s", line) + } + line = strings.TrimSpace(strings.Split(line, stateLine)[0]) + line = strings.TrimPrefix(line, diskPrefix) + dev = strings.TrimSpace(line) + break + } + } + if dev == "" { + return "", fmt.Errorf("Cannot find iscsi device") + } + dev = "/dev/" + dev + return dev, nil +} diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go new file mode 100644 index 00000000..8fb36115 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -0,0 +1,121 @@ +package iscsi + +import ( + "strconv" + + "github.com/rancher/convoy/util" +) + +var ( + tgtBinary = "tgtadm" +) + +// CreateTarget will create a iSCSI target using the name specified. If name is +// unspecified, a name will be generated. Notice the name must comply with iSCSI +// name format. +func CreateTarget(tid int, name string) error { + opts := []string{ + "--lld", "iscsi", + "--op", "new", + "--mode", "target", + "--tid", strconv.Itoa(tid), + "-T", name, + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + +// DeleteTarget will remove a iSCSI target specified by tid +func DeleteTarget(tid int) error { + opts := []string{ + "--lld", "iscsi", + "--op", "delete", + "--mode", "target", + "--tid", strconv.Itoa(tid), + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + +// AddLunBackedByFile will add a LUN in an existing target, which backing by +// specified file. +func AddLunBackedByFile(tid int, lun int, backingFile string) error { + opts := []string{ + "--lld", "iscsi", + "--op", "new", + "--mode", "logicalunit", + "--tid", strconv.Itoa(tid), + "--lun", strconv.Itoa(lun), + "-b", backingFile, + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + +// DeleteLun will remove a LUN from an target +func DeleteLun(tid int, lun int) error { + opts := []string{ + "--lld", "iscsi", + "--op", "delete", + "--mode", "logicalunit", + "--tid", strconv.Itoa(tid), + "--lun", strconv.Itoa(lun), + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + +// BindInitiator will add permission to allow certain initiator(s) to connect to +// certain target. "ALL" is a special initiator which is the wildcard +func BindInitiator(tid int, initiator string) error { + opts := []string{ + "--lld", "iscsi", + "--op", "bind", + "--mode", "target", + "--tid", strconv.Itoa(tid), + "-I", initiator, + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + +// UnbindInitiator will remove permission to allow certain initiator(s) to connect to +// certain target. +func UnbindInitiator(tid int, initiator string) error { + opts := []string{ + "--lld", "iscsi", + "--op", "unbind", + "--mode", "target", + "--tid", strconv.Itoa(tid), + "-I", initiator, + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + +// StartDaemon will start tgtd daemon, prepare for further commands +func StartDaemon() error { + _, err := util.Execute("tgtd", []string{}) + if err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/yasker/go-iscsi-helper/trash.conf b/vendor/github.com/yasker/go-iscsi-helper/trash.conf new file mode 100644 index 00000000..dc2e0cc7 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/trash.conf @@ -0,0 +1,12 @@ +# trash.conf + +# package +github.com/yasker/go-iscsi-helper + +github.com/Sirupsen/logrus v0.10.0-38-g3ec0642 +github.com/codegangsta/cli v1.18.0-65-g61f519f +github.com/mcuadros/go-version d52711f +github.com/rancher/convoy v0.5.0-rc2-1-g0eda7c7 +github.com/satori/go.uuid v1.1.0-1-g0aa62d5 +golang.org/x/sys 30de6d1 +gopkg.in/check.v1 4f90aea diff --git a/vendor/github.com/yasker/go-iscsi-helper/util/util.go b/vendor/github.com/yasker/go-iscsi-helper/util/util.go new file mode 100644 index 00000000..5353df94 --- /dev/null +++ b/vendor/github.com/yasker/go-iscsi-helper/util/util.go @@ -0,0 +1,68 @@ +package util + +import ( + "fmt" + "net" + "path/filepath" + + cutil "github.com/rancher/convoy/util" +) + +const ( + NSBinary = "nsenter" +) + +func GetLocalIPs() ([]string, error) { + results := []string{} + addrs, err := net.InterfaceAddrs() + if err != nil { + return nil, err + } + for _, addr := range addrs { + if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() { + if ip.IP.To4() != nil { + results = append(results, ip.IP.String()) + } + } + } + return results, nil +} + +type NamespaceExecutor struct { + ns string +} + +func NewNamespaceExecutor(ns string) (*NamespaceExecutor, error) { + ne := &NamespaceExecutor{ + ns: ns, + } + + if ns == "" { + return ne, nil + } + mntNS := filepath.Join(ns, "mnt") + netNS := filepath.Join(ns, "net") + if _, err := cutil.Execute(NSBinary, []string{"-V"}); err != nil { + return nil, fmt.Errorf("Cannot find nsenter for namespace switching") + } + if _, err := cutil.Execute(NSBinary, []string{"--mount=" + mntNS, "mount"}); err != nil { + return nil, fmt.Errorf("Invalid mount namespace %v, error %v", mntNS, err) + } + if _, err := cutil.Execute(NSBinary, []string{"--net=" + netNS, "ip", "addr"}); err != nil { + return nil, fmt.Errorf("Invalid net namespace %v, error %v", netNS, err) + } + return ne, nil +} + +func (ne *NamespaceExecutor) Execute(name string, args []string) (string, error) { + if ne.ns == "" { + return cutil.Execute(name, args) + } + cmdArgs := []string{ + "--mount=" + filepath.Join(ne.ns, "mnt"), + "--net=" + filepath.Join(ne.ns, "net"), + name, + } + cmdArgs = append(cmdArgs, args...) + return cutil.Execute(NSBinary, cmdArgs) +} From db2f995b128e65581caaad151dfff58ff351337b Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 21 Sep 2016 15:51:49 -0700 Subject: [PATCH 189/357] tgt: Enable AIO for better performance --- Dockerfile.dapper | 5 ++- package/Dockerfile | 3 +- trash.yml | 2 +- util/util.go | 2 +- .../yasker/go-iscsi-helper/Dockerfile.dapper | 5 ++- .../yasker/go-iscsi-helper/iscsi/target.go | 37 +++++++++++++++++++ 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 0c942522..15632409 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -15,7 +15,8 @@ RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.co apt-get update && \ apt-get install -y cmake curl git \ libglib2.0-dev libkmod-dev libnl-genl-3-dev linux-libc-dev pkg-config psmisc python-tox qemu-utils fuse python-dev \ - devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl libconfig-general-perl + devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl \ + libconfig-general-perl libaio-dev libc6-dev # Install Go RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz @@ -67,7 +68,7 @@ RUN cd /usr/src/libqcow-20160123 && \ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout 2cee9922fcc030b347477e020b3b7aebc4518b6f && \ + git checkout ec01080ee9ed3484ca27e70b2b71808618e8338a && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb diff --git a/package/Dockerfile b/package/Dockerfile index afc8801e..7ca133f0 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,6 +1,7 @@ FROM ubuntu:16.04 RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ - apt-get update && apt-get install -y kmod curl nfs-common fuse libibverbs1 librdmacm1 libconfig-general-perl + apt-get update && apt-get install -y kmod curl nfs-common fuse \ + libibverbs1 librdmacm1 libconfig-general-perl libaio1 RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.1.2/share-mnt && \ chmod u+x share-mnt && mv share-mnt /usr/bin diff --git a/trash.yml b/trash.yml index 6d81b942..fd4da7ad 100644 --- a/trash.yml +++ b/trash.yml @@ -63,4 +63,4 @@ import: - package: golang.org/x/net/context version: 31df19d69da8728e9220def59b80ee577c3e48bf - package: github.com/yasker/go-iscsi-helper - version: 9d43b5b232ad51582b70b0200b7ff5b67a11da65 + version: a0011be003f3248128506b0e43fbb0658a8f61f3 diff --git a/util/util.go b/util/util.go index 4a3a14be..4ceb52c3 100644 --- a/util/util.go +++ b/util/util.go @@ -116,7 +116,7 @@ func (dev *ScsiDevice) Startup() error { if err := iscsi.CreateTarget(dev.TargetID, dev.Target); err != nil { return err } - if err := iscsi.AddLunBackedByFile(dev.TargetID, dev.LunID, dev.BackingFile); err != nil { + if err := iscsi.AddLunBackedByAIOFile(dev.TargetID, dev.LunID, dev.BackingFile); err != nil { return err } if err := iscsi.BindInitiator(dev.TargetID, "ALL"); err != nil { diff --git a/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper b/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper index 2c205b06..c45bb88e 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper +++ b/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper @@ -14,7 +14,8 @@ WORKDIR ${DAPPER_SOURCE} RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ apt-get update && \ apt-get install -y cmake curl git \ - devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl libconfig-general-perl + devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl \ + libconfig-general-perl libaio-dev libc6-dev # Install Go RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz @@ -37,7 +38,7 @@ RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout 2cee9922fcc030b347477e020b3b7aebc4518b6f && \ + git checkout ec01080ee9ed3484ca27e70b2b71808618e8338a && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go index 8fb36115..1556a741 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -1,7 +1,9 @@ package iscsi import ( + "fmt" "strconv" + "strings" "github.com/rancher/convoy/util" ) @@ -61,6 +63,28 @@ func AddLunBackedByFile(tid int, lun int, backingFile string) error { return nil } +// AddLunBackedByAIOFile will add a LUN in an existing target, which backing by +// specified file, using AIO backing-store +func AddLunBackedByAIOFile(tid int, lun int, backingFile string) error { + if !CheckTargetForBackingStore("aio") { + return fmt.Errorf("Backing-store aio is not supported") + } + opts := []string{ + "--lld", "iscsi", + "--op", "new", + "--mode", "logicalunit", + "--tid", strconv.Itoa(tid), + "--lun", strconv.Itoa(lun), + "-b", backingFile, + "--bstype", "aio", + } + _, err := util.Execute(tgtBinary, opts) + if err != nil { + return err + } + return nil +} + // DeleteLun will remove a LUN from an target func DeleteLun(tid int, lun int) error { opts := []string{ @@ -119,3 +143,16 @@ func StartDaemon() error { } return nil } + +func CheckTargetForBackingStore(name string) bool { + opts := []string{ + "--lld", "iscsi", + "--op", "show", + "--mode", "system", + } + output, err := util.Execute(tgtBinary, opts) + if err != nil { + return false + } + return strings.Contains(output, " "+name) +} From 922864b0b0d4a170c0df1a933509dbc64890ee4b Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 6 Oct 2016 18:41:45 -0700 Subject: [PATCH 190/357] Update to use more flexible go-iscsi-helper backstore interface --- frontend/fusedev/fuse.go | 2 +- trash.yml | 2 +- util/util.go | 8 ++++++-- .../yasker/go-iscsi-helper/iscsi/target.go | 13 ++++++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 105e9517..090523e0 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -151,7 +151,7 @@ func (lf *LonghornFs) createDev() error { } if lf.scsiDev == nil { - scsiDev, err := util.NewScsiDevice(lf.Volume, path) + scsiDev, err := util.NewScsiDevice(lf.Volume, path, "aio", "") if err != nil { return err } diff --git a/trash.yml b/trash.yml index fd4da7ad..e77b5f4b 100644 --- a/trash.yml +++ b/trash.yml @@ -63,4 +63,4 @@ import: - package: golang.org/x/net/context version: 31df19d69da8728e9220def59b80ee577c3e48bf - package: github.com/yasker/go-iscsi-helper - version: a0011be003f3248128506b0e43fbb0658a8f61f3 + version: d74bf63003e240a5be55339df085777ceb692361 diff --git a/util/util.go b/util/util.go index 4ceb52c3..faf9eeff 100644 --- a/util/util.go +++ b/util/util.go @@ -86,14 +86,18 @@ type ScsiDevice struct { Device string Portal string BackingFile string + BSType string + BSOpts string } -func NewScsiDevice(name, backingFile string) (*ScsiDevice, error) { +func NewScsiDevice(name, backingFile, bsType, bsOpts string) (*ScsiDevice, error) { dev := &ScsiDevice{ Target: "iqn.2014-07.com.rancher:" + name, TargetID: 1, LunID: 1, BackingFile: backingFile, + BSType: bsType, + BSOpts: bsOpts, } ips, err := iutil.GetLocalIPs() if err != nil { @@ -116,7 +120,7 @@ func (dev *ScsiDevice) Startup() error { if err := iscsi.CreateTarget(dev.TargetID, dev.Target); err != nil { return err } - if err := iscsi.AddLunBackedByAIOFile(dev.TargetID, dev.LunID, dev.BackingFile); err != nil { + if err := iscsi.AddLun(dev.TargetID, dev.LunID, dev.BackingFile, dev.BSType, dev.BSOpts); err != nil { return err } if err := iscsi.BindInitiator(dev.TargetID, "ALL"); err != nil { diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go index 1556a741..2c87a8e0 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -63,11 +63,11 @@ func AddLunBackedByFile(tid int, lun int, backingFile string) error { return nil } -// AddLunBackedByAIOFile will add a LUN in an existing target, which backing by +// AddLun will add a LUN in an existing target, which backing by // specified file, using AIO backing-store -func AddLunBackedByAIOFile(tid int, lun int, backingFile string) error { - if !CheckTargetForBackingStore("aio") { - return fmt.Errorf("Backing-store aio is not supported") +func AddLun(tid int, lun int, backingFile string, bstype string, bsopts string) error { + if !CheckTargetForBackingStore(bstype) { + return fmt.Errorf("Backing-store %s is not supported", bstype) } opts := []string{ "--lld", "iscsi", @@ -76,7 +76,10 @@ func AddLunBackedByAIOFile(tid int, lun int, backingFile string) error { "--tid", strconv.Itoa(tid), "--lun", strconv.Itoa(lun), "-b", backingFile, - "--bstype", "aio", + "--bstype", bstype, + } + if bsopts != "" { + opts = append(opts, "\""+bsopts+"\"") } _, err := util.Execute(tgtBinary, opts) if err != nil { From 6e4924c7d5826f0a50db2348eb52b770d68229f1 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 6 Oct 2016 18:22:37 -0700 Subject: [PATCH 191/357] frontend: TGT --- Dockerfile.dapper | 2 +- app/controller_tgt.go | 9 + frontend/fusedev/fuse.go | 44 +---- frontend/tgt/frontend.go | 167 ++++++++++++++++++ trash.yml | 2 +- util/util.go | 58 +++++- .../yasker/go-iscsi-helper/Dockerfile.dapper | 2 +- .../yasker/go-iscsi-helper/iscsi/initiator.go | 12 +- .../yasker/go-iscsi-helper/iscsi/target.go | 46 ++++- 9 files changed, 289 insertions(+), 53 deletions(-) create mode 100644 app/controller_tgt.go create mode 100644 frontend/tgt/frontend.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 15632409..b6d894dc 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -68,7 +68,7 @@ RUN cd /usr/src/libqcow-20160123 && \ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout ec01080ee9ed3484ca27e70b2b71808618e8338a && \ + git checkout 4574d18db4eeebb0f761fe272ccbe1e3ff681b7f && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb diff --git a/app/controller_tgt.go b/app/controller_tgt.go new file mode 100644 index 00000000..2e987957 --- /dev/null +++ b/app/controller_tgt.go @@ -0,0 +1,9 @@ +package app + +import ( + "github.com/rancher/longhorn/frontend/tgt" +) + +func init() { + frontends["tgt"] = tgt.New() +} diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go index 090523e0..3db66eb3 100644 --- a/frontend/fusedev/fuse.go +++ b/frontend/fusedev/fuse.go @@ -161,14 +161,7 @@ func (lf *LonghornFs) createDev() error { return err } - stat := unix.Stat_t{} - if err := unix.Stat(lf.scsiDev.Device, &stat); err != nil { - return err - } - major := int(stat.Rdev / 256) - minor := int(stat.Rdev % 256) - logrus.Infof("Creating device %s %d:%d", dev, major, minor) - if err := mknod(dev, major, minor); err != nil { + if err := util.DuplicateDevice(lf.scsiDev.Device, dev); err != nil { return err } return nil @@ -177,10 +170,8 @@ func (lf *LonghornFs) createDev() error { func (lf *LonghornFs) removeDev() error { dev := lf.getDev() logrus.Infof("Removing device %s", dev) - if _, err := os.Stat(dev); err == nil { - if err := remove(dev); err != nil { - return fmt.Errorf("Failed to removing device %s, %v", dev, err) - } + if err := util.RemoveDevice(dev); err != nil { + return err } if lf.scsiDev.Device != "" { @@ -282,32 +273,3 @@ func (f *RawFrontendFile) Write(cxt context.Context, req *fuse.WriteRequest, res resp.Size = int(l) return nil } - -func mknod(device string, major, minor int) error { - var fileMode os.FileMode = 0600 - fileMode |= unix.S_IFBLK - dev := int((major << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)) - - return unix.Mknod(device, uint32(fileMode), dev) -} - -func removeAsync(path string, done chan<- error) { - logrus.Infof("Removing: %s", path) - if err := os.Remove(path); err != nil && !os.IsNotExist(err) { - logrus.Errorf("Unable to remove: %v", path) - done <- err - } - logrus.Debugf("Removed: %s", path) - done <- nil -} - -func remove(path string) error { - done := make(chan error) - go removeAsync(path, done) - select { - case err := <-done: - return err - case <-time.After(30 * time.Second): - return fmt.Errorf("Timeout trying to delete %s.", path) - } -} diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go new file mode 100644 index 00000000..efdf1432 --- /dev/null +++ b/frontend/tgt/frontend.go @@ -0,0 +1,167 @@ +package tgt + +import ( + "fmt" + "io" + "net" + "os" + "path/filepath" + + "github.com/Sirupsen/logrus" + + "github.com/rancher/longhorn/rpc" + "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" +) + +const ( + SocketDirectory = "/var/run" + DevPath = "/dev/longhorn/" +) + +func New() types.Frontend { + return &Tgt{} +} + +type Tgt struct { + Volume string + Size int64 + SectorSize int + + socketPath string + socketServer *rpc.Server + scsiDevice *util.ScsiDevice +} + +func (t *Tgt) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { + if err := t.Shutdown(); err != nil { + return err + } + + t.Volume = name + t.Size = size + t.SectorSize = int(sectorSize) + + if err := t.startSocketServer(rw); err != nil { + return err + } + + if err := t.startScsiDevice(); err != nil { + return err + } + + if err := t.createDev(); err != nil { + return err + } + + return nil +} + +func (t *Tgt) Shutdown() error { + dev := t.getDev() + logrus.Infof("Removing device %s", dev) + if err := util.RemoveDevice(dev); err != nil { + return err + } + if t.scsiDevice != nil { + logrus.Infof("Shutdown SCSI device at %v", t.scsiDevice.Device) + if err := t.scsiDevice.Shutdown(); err != nil { + return err + } + } + if t.socketServer != nil { + //log.Infof("Shutdown TGT socket server for %v", t.Volume) + // TODO: In fact we don't know how to shutdown socket server, there is + // no way yet + } + return nil +} + +func (t *Tgt) getSocketPath() string { + if t.Volume == "" { + panic("Invalid volume name") + } + return filepath.Join(SocketDirectory, "longhorn-"+t.Volume+".sock") +} + +func (t *Tgt) startSocketServer(rw types.ReaderWriterAt) error { + socketPath := t.getSocketPath() + if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil { + return fmt.Errorf("Cannot create directory %v", filepath.Dir(socketPath)) + } + // Check and remove existing socket + if st, err := os.Stat(socketPath); err == nil && !st.IsDir() { + if err := os.Remove(socketPath); err != nil { + return err + } + } + + t.socketPath = socketPath + go t.startSocketServerListen(rw) + return nil +} + +func (t *Tgt) startSocketServerListen(rw types.ReaderWriterAt) error { + ln, err := net.Listen("unix", t.socketPath) + if err != nil { + return err + } + defer ln.Close() + + for { + conn, err := ln.Accept() + if err != nil { + logrus.Errorln("Fail to accept socket connection") + continue + } + go t.handleServerConnection(conn, rw) + } +} + +func (t *Tgt) handleServerConnection(c net.Conn, rw types.ReaderWriterAt) { + defer c.Close() + + server := rpc.NewServer(c, rw) + if err := server.Handle(); err != nil && err != io.EOF { + logrus.Errorln("Fail to handle socket server connection due to ", err) + } else if err == io.EOF { + logrus.Warnln("Socket server connection closed") + } +} + +func (t *Tgt) getDev() string { + return filepath.Join(DevPath, t.Volume) +} + +func (t *Tgt) startScsiDevice() error { + if t.scsiDevice == nil { + bsOpts := fmt.Sprintf("size=%v", t.Size) + scsiDev, err := util.NewScsiDevice(t.Volume, t.socketPath, "longhorn", bsOpts) + if err != nil { + return err + } + t.scsiDevice = scsiDev + } + if err := t.scsiDevice.Startup(); err != nil { + return err + } + logrus.Infof("SCSI device %s created", t.scsiDevice.Device) + return nil +} + +func (t *Tgt) createDev() error { + if err := os.MkdirAll(DevPath, 0700); err != nil { + logrus.Fatalln("Cannot create directory ", DevPath) + } + + dev := t.getDev() + if _, err := os.Stat(dev); err == nil { + return fmt.Errorf("Device %s already exists, can not create", dev) + } + + if err := util.DuplicateDevice(t.scsiDevice.Device, dev); err != nil { + return err + } + logrus.Infof("Device %s is ready", dev) + return nil +} diff --git a/trash.yml b/trash.yml index e77b5f4b..6c9092d4 100644 --- a/trash.yml +++ b/trash.yml @@ -63,4 +63,4 @@ import: - package: golang.org/x/net/context version: 31df19d69da8728e9220def59b80ee577c3e48bf - package: github.com/yasker/go-iscsi-helper - version: d74bf63003e240a5be55339df085777ceb692361 + version: 3dd81f79f590d3eb571964bb043d6fe96637942c diff --git a/util/util.go b/util/util.go index faf9eeff..8779b233 100644 --- a/util/util.go +++ b/util/util.go @@ -4,13 +4,17 @@ import ( "fmt" "io" "net/http" + "os" "regexp" "strconv" + "time" + "github.com/Sirupsen/logrus" "github.com/gorilla/handlers" "github.com/satori/go.uuid" "github.com/yasker/go-iscsi-helper/iscsi" iutil "github.com/yasker/go-iscsi-helper/util" + "golang.org/x/sys/unix" ) var ( @@ -114,7 +118,7 @@ func (dev *ScsiDevice) Startup() error { } // Setup target - if err := iscsi.StartDaemon(); err != nil { + if err := iscsi.StartDaemon(false); err != nil { return err } if err := iscsi.CreateTarget(dev.TargetID, dev.Target); err != nil { @@ -171,3 +175,55 @@ func (dev *ScsiDevice) Shutdown() error { } return nil } + +func DuplicateDevice(src, dest string) error { + stat := unix.Stat_t{} + if err := unix.Stat(src, &stat); err != nil { + return err + } + major := int(stat.Rdev / 256) + minor := int(stat.Rdev % 256) + if err := mknod(dest, major, minor); err != nil { + return err + } + return nil +} + +func mknod(device string, major, minor int) error { + var fileMode os.FileMode = 0600 + fileMode |= unix.S_IFBLK + dev := int((major << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)) + + logrus.Infof("Creating device %s %d:%d", device, major, minor) + return unix.Mknod(device, uint32(fileMode), dev) +} + +func RemoveDevice(dev string) error { + if _, err := os.Stat(dev); err == nil { + if err := remove(dev); err != nil { + return fmt.Errorf("Failed to removing device %s, %v", dev, err) + } + } + return nil +} + +func removeAsync(path string, done chan<- error) { + logrus.Infof("Removing: %s", path) + if err := os.Remove(path); err != nil && !os.IsNotExist(err) { + logrus.Errorf("Unable to remove: %v", path) + done <- err + } + logrus.Debugf("Removed: %s", path) + done <- nil +} + +func remove(path string) error { + done := make(chan error) + go removeAsync(path, done) + select { + case err := <-done: + return err + case <-time.After(30 * time.Second): + return fmt.Errorf("Timeout trying to delete %s.", path) + } +} diff --git a/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper b/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper index c45bb88e..e00461b8 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper +++ b/vendor/github.com/yasker/go-iscsi-helper/Dockerfile.dapper @@ -38,7 +38,7 @@ RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout ec01080ee9ed3484ca27e70b2b71808618e8338a && \ + git checkout 4574d18db4eeebb0f761fe272ccbe1e3ff681b7f && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index c31e25cd..e6d794ca 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -10,11 +10,13 @@ import ( "github.com/yasker/go-iscsi-helper/util" ) +var ( + DeviceWaitRetryCounts = 5 + DeviceWaitRetryInterval = 1 * time.Second +) + const ( iscsiBinary = "iscsiadm" - - retryInterval = 1 * time.Second - retryMax = 5 ) func DiscoverTarget(ip, target string, ne *util.NamespaceExecutor) error { @@ -79,12 +81,12 @@ func GetDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (string, var err error dev := "" - for i := 0; i < retryMax; i++ { + for i := 0; i < DeviceWaitRetryCounts; i++ { dev, err = findScsiDevice(ip, target, lun, ne) if err == nil { break } - time.Sleep(retryInterval) + time.Sleep(DeviceWaitRetryInterval) } if err != nil { return "", err diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go index 2c87a8e0..5753d9ed 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -2,13 +2,21 @@ package iscsi import ( "fmt" + "os" + "os/exec" "strconv" "strings" + "time" "github.com/rancher/convoy/util" ) var ( + TgtdRetryCounts = 5 + TgtdRetryInterval = 1 * time.Second +) + +const ( tgtBinary = "tgtadm" ) @@ -79,7 +87,7 @@ func AddLun(tid int, lun int, backingFile string, bstype string, bsopts string) "--bstype", bstype, } if bsopts != "" { - opts = append(opts, "\""+bsopts+"\"") + opts = append(opts, "--bsopts", bsopts) } _, err := util.Execute(tgtBinary, opts) if err != nil { @@ -139,14 +147,46 @@ func UnbindInitiator(tid int, initiator string) error { } // StartDaemon will start tgtd daemon, prepare for further commands -func StartDaemon() error { - _, err := util.Execute("tgtd", []string{}) +func StartDaemon(debug bool) error { + logFile := "/var/log/tgtd.log" + logf, err := os.Create(logFile) if err != nil { return err } + go startDaemon(logf, debug) + + // Wait until daemon is up + done := false + for i := 0; i < TgtdRetryCounts; i++ { + if CheckTargetForBackingStore("rdwr") { + done = true + break + } + time.Sleep(TgtdRetryInterval) + } + if !done { + return fmt.Errorf("Fail to start tgtd daemon") + } return nil } +func startDaemon(logf *os.File, debug bool) { + opts := []string{ + "-f", + } + if debug { + opts = append(opts, "-d", "1") + } + cmd := exec.Command("tgtd", opts...) + cmd.Stdout = logf + cmd.Stderr = logf + + err := cmd.Run() + if err != nil { + panic(err) + } +} + func CheckTargetForBackingStore(name string) bool { opts := []string{ "--lld", "iscsi", From e2cafd2e4554a1a0f8a680826ed60d7078484b88 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 10 Oct 2016 16:24:30 -0700 Subject: [PATCH 192/357] package: More generic longhorn quick launch script --- package/launch-simple-longhorn | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/package/launch-simple-longhorn b/package/launch-simple-longhorn index 63804380..e744ac5a 100755 --- a/package/launch-simple-longhorn +++ b/package/launch-simple-longhorn @@ -1,10 +1,12 @@ #!/bin/bash set -x +set -e mount --rbind /host/dev /dev volume=$1 -frontend=$2 +size=$2 +frontend=$3 if [ -z $volume ] then @@ -14,12 +16,18 @@ then exit -1 fi +if [ -z $size ] +then + echo Use default size 1g + size="1g" +fi + if [ -z $frontend ] then echo Use default frontend TCMU frontend="tcmu" fi -longhorn replica --size 1g --listen localhost:9502 /volume/ & +longhorn replica --size $size --listen localhost:9502 /volume/ & sleep 1 exec longhorn controller --frontend $frontend --replica tcp://localhost:9502 $volume From dfe2067dad6ad96228fd2f519f2322b69edcb7db Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 10 Oct 2016 16:24:08 -0700 Subject: [PATCH 193/357] tgt: Add check for iscsiadm on the host --- trash.yml | 2 +- util/util.go | 8 ++++++++ .../yasker/go-iscsi-helper/iscsi/initiator.go | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/trash.yml b/trash.yml index 6c9092d4..3c220d61 100644 --- a/trash.yml +++ b/trash.yml @@ -63,4 +63,4 @@ import: - package: golang.org/x/net/context version: 31df19d69da8728e9220def59b80ee577c3e48bf - package: github.com/yasker/go-iscsi-helper - version: 3dd81f79f590d3eb571964bb043d6fe96637942c + version: 04d34eea76ed6af5afdf7b1c281aa909904c3a96 diff --git a/util/util.go b/util/util.go index 8779b233..4cfd953a 100644 --- a/util/util.go +++ b/util/util.go @@ -117,6 +117,10 @@ func (dev *ScsiDevice) Startup() error { return err } + if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + return err + } + // Setup target if err := iscsi.StartDaemon(false); err != nil { return err @@ -154,6 +158,10 @@ func (dev *ScsiDevice) Shutdown() error { return err } + if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + return err + } + // Teardown initiator if err := iscsi.LogoutTarget(dev.Portal, dev.Target, ne); err != nil { return err diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index e6d794ca..76bd54d0 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -19,6 +19,17 @@ const ( iscsiBinary = "iscsiadm" ) +func CheckForInitiatorExistence(ne *util.NamespaceExecutor) error { + opts := []string{ + "--version", + } + _, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return err + } + return nil +} + func DiscoverTarget(ip, target string, ne *util.NamespaceExecutor) error { opts := []string{ "-m", "discovery", From 4da9700392856233a59b91c524afd9a6d0593170 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 10 Oct 2016 17:29:53 -0700 Subject: [PATCH 194/357] tgt: Fix restart frontend Add status check for tgtd --- frontend/tgt/frontend.go | 12 ++++++++---- trash.yml | 2 +- util/util.go | 2 -- .../yasker/go-iscsi-helper/iscsi/target.go | 12 +++++++++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index efdf1432..6b54b6eb 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -58,16 +58,20 @@ func (t *Tgt) Activate(name string, size, sectorSize int64, rw types.ReaderWrite } func (t *Tgt) Shutdown() error { - dev := t.getDev() - logrus.Infof("Removing device %s", dev) - if err := util.RemoveDevice(dev); err != nil { - return err + if t.Volume != "" { + dev := t.getDev() + if err := util.RemoveDevice(dev); err != nil { + return err + } + t.Volume = "" } + if t.scsiDevice != nil { logrus.Infof("Shutdown SCSI device at %v", t.scsiDevice.Device) if err := t.scsiDevice.Shutdown(); err != nil { return err } + t.scsiDevice = nil } if t.socketServer != nil { //log.Infof("Shutdown TGT socket server for %v", t.Volume) diff --git a/trash.yml b/trash.yml index 3c220d61..836aa786 100644 --- a/trash.yml +++ b/trash.yml @@ -63,4 +63,4 @@ import: - package: golang.org/x/net/context version: 31df19d69da8728e9220def59b80ee577c3e48bf - package: github.com/yasker/go-iscsi-helper - version: 04d34eea76ed6af5afdf7b1c281aa909904c3a96 + version: 378989ccf1cd08b5b8bff8e35c221495b59efca5 diff --git a/util/util.go b/util/util.go index 4cfd953a..e62ac4f3 100644 --- a/util/util.go +++ b/util/util.go @@ -216,12 +216,10 @@ func RemoveDevice(dev string) error { } func removeAsync(path string, done chan<- error) { - logrus.Infof("Removing: %s", path) if err := os.Remove(path); err != nil && !os.IsNotExist(err) { logrus.Errorf("Unable to remove: %v", path) done <- err } - logrus.Debugf("Removed: %s", path) done <- nil } diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go index 5753d9ed..fb707f69 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -14,6 +14,8 @@ import ( var ( TgtdRetryCounts = 5 TgtdRetryInterval = 1 * time.Second + + daemonIsRunning = false ) const ( @@ -148,6 +150,10 @@ func UnbindInitiator(tid int, initiator string) error { // StartDaemon will start tgtd daemon, prepare for further commands func StartDaemon(debug bool) error { + if daemonIsRunning { + return nil + } + logFile := "/var/log/tgtd.log" logf, err := os.Create(logFile) if err != nil { @@ -156,15 +162,15 @@ func StartDaemon(debug bool) error { go startDaemon(logf, debug) // Wait until daemon is up - done := false + daemonIsRunning = false for i := 0; i < TgtdRetryCounts; i++ { if CheckTargetForBackingStore("rdwr") { - done = true + daemonIsRunning = true break } time.Sleep(TgtdRetryInterval) } - if !done { + if !daemonIsRunning { return fmt.Errorf("Fail to start tgtd daemon") } return nil From c3c746141cf843a9bc3028b60dc542ad21f6d4cf Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 10 Oct 2016 17:35:52 -0700 Subject: [PATCH 195/357] test: Use TGT frontend in test case --- integration/data/common.py | 10 +++++----- integration/data/frontend.py | 2 +- scripts/integration-test | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index 26b0dc56..143b9e1a 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -9,7 +9,7 @@ import pytest import cattle -from frontend import restdev, fusedev +from frontend import restdev, blockdev from frontend import PAGE_SIZE # NOQA @@ -60,7 +60,7 @@ def dev(request): REPLICA2 ]) assert v.replicaCount == 2 - d = get_restdev() + d = get_blockdev() return d @@ -84,7 +84,7 @@ def backing_dev(request): BACKED_REPLICA2 ]) assert v.replicaCount == 2 - d = get_restdev() + d = get_blockdev() return d @@ -148,8 +148,8 @@ def get_restdev(): return restdev(VOLUME_NAME) -def get_fusedev(): - return fusedev(VOLUME_NAME) +def get_blockdev(): + return blockdev(VOLUME_NAME) def write_dev(dev, offset, data): diff --git a/integration/data/frontend.py b/integration/data/frontend.py index 81cc48fa..d872ba80 100644 --- a/integration/data/frontend.py +++ b/integration/data/frontend.py @@ -84,7 +84,7 @@ def writeat(self, offset, data): return ret -class fusedev: +class blockdev: def __init__(self, volume): self.dev = path.join(LONGHORN_DEV_DIR, volume) diff --git a/scripts/integration-test b/scripts/integration-test index f42c7f57..3a78753a 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -41,7 +41,7 @@ then mount --rbind /host/dev /dev fi -./bin/longhorn controller --frontend rest --enable-backend file test-volume & +./bin/longhorn controller --frontend tgt --enable-backend file test-volume & controller_pid=$! ./bin/longhorn replica $temp & replica1_pid=$! From d409049a00bcde97290913e596b3f2bde347c7dc Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 11 Oct 2016 15:47:26 -0700 Subject: [PATCH 196/357] Fix drone build Update sparse-tools --- trash.yml | 2 +- vendor/github.com/rancher/sparse-tools/cli/sfold/main.go | 1 + vendor/github.com/rancher/sparse-tools/sparse/file.go | 5 ----- vendor/github.com/rancher/sparse-tools/sparse/sfold.go | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/trash.yml b/trash.yml index 0b7ddf42..a2d2a337 100644 --- a/trash.yml +++ b/trash.yml @@ -25,7 +25,7 @@ import: - package: github.com/satori/go.uuid version: f9ab0dce87d815821e221626b772e3475a0d2749 - package: github.com/rancher/sparse-tools - version: 1b461089e2db95e45faeff6bb07f3d599ba4aed6 + version: df7d04b769d34b52878e9e60ba22dabf7dc8b7ca - package: github.com/rancher/go-rancher-metadata version: 721b783c9983a17ec0d63d5530337610de9519ec - package: github.com/rancher/convoy diff --git a/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go b/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go index f1ff3b6b..b1b5d646 100644 --- a/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go +++ b/vendor/github.com/rancher/sparse-tools/cli/sfold/main.go @@ -46,6 +46,7 @@ Examples: err := sparse.FoldFile(srcPath, dstPath) if err != nil { + log.Errorf("failed to fold file: %s to: %s, err: %v", srcPath, dstPath, err) os.Exit(1) } } diff --git a/vendor/github.com/rancher/sparse-tools/sparse/file.go b/vendor/github.com/rancher/sparse-tools/sparse/file.go index 405cc13a..7e10e8ef 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/file.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/file.go @@ -220,10 +220,5 @@ func GetFiemapRegionExts(file FileIoProcessor, interval Interval) ([]Extent, err lastExtStart = ext.Logical } - // last ext should have the FIEMAP_EXTENT_LAST set, otherwise we don't get all exts - if exts[len(exts)-1].Flags&FIEMAP_EXTENT_LAST == 0 { - return exts, fmt.Errorf("The exts returned by fiemap are not complete") - } - return exts, nil } diff --git a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go index 4fb10beb..2f8c4b77 100644 --- a/vendor/github.com/rancher/sparse-tools/sparse/sfold.go +++ b/vendor/github.com/rancher/sparse-tools/sparse/sfold.go @@ -56,7 +56,7 @@ func coalesce(parentFileIo FileIoProcessor, childFileIo FileIoProcessor) error { } exts, err := GetFiemapExtents(childFileIo) if err != nil { - log.Errorf("Failed to GetFiemapExtents of childFile filename: %v", childFileIo.Name()) + log.Errorf("Failed to GetFiemapExtents of childFile filename: %s, err: %v", childFileIo.Name(), err) return err } for _, e := range exts { From 12b1fee24735c09077294aac43e114a7ad8aeb03 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 12 Oct 2016 18:12:56 -0700 Subject: [PATCH 197/357] Fix wrong response type drone triggered --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index b6d894dc..01291ba4 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -68,7 +68,7 @@ RUN cd /usr/src/libqcow-20160123 && \ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout 4574d18db4eeebb0f761fe272ccbe1e3ff681b7f && \ + git checkout e101b78e28b40a06d04467925d3fbd17985fdc73 && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb From 7092316092af52201ddcf61c13c906b73ac329d3 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 13 Oct 2016 15:47:38 -0700 Subject: [PATCH 198/357] frontend: Update interface to include an state checker Also rename the Activate() to Startup() --- controller/control.go | 4 ++-- frontend/fusedev/frontend.go | 18 +++++++++++++++--- frontend/rest/frontend.go | 15 +++++++++++++-- frontend/tcmu/frontend.go | 22 +++++++++++++++++++--- frontend/tgt/frontend.go | 14 +++++++++++++- types/types.go | 8 +++++++- 6 files changed, 69 insertions(+), 12 deletions(-) diff --git a/controller/control.go b/controller/control.go index c96e42b9..379ebf0d 100644 --- a/controller/control.go +++ b/controller/control.go @@ -170,9 +170,9 @@ func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { func (c *Controller) startFrontend() error { if len(c.replicas) > 0 && c.frontend != nil { - if err := c.frontend.Activate(c.Name, c.size, c.sectorSize, c); err != nil { + if err := c.frontend.Startup(c.Name, c.size, c.sectorSize, c); err != nil { // FATAL - logrus.Fatalf("Failed to activate frontend: %v", err) + logrus.Fatalf("Failed to start up frontend: %v", err) // This will never be reached return err } diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go index 31d3cc61..35e97a75 100644 --- a/frontend/fusedev/frontend.go +++ b/frontend/fusedev/frontend.go @@ -9,10 +9,11 @@ func New() types.Frontend { } type Fuse struct { - lf *LonghornFs + lf *LonghornFs + isUp bool } -func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (f *Fuse) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { if err := f.Shutdown(); err != nil { return err } @@ -22,13 +23,24 @@ func (f *Fuse) Activate(name string, size, sectorSize int64, rw types.ReaderWrit if err := f.lf.Start(); err != nil { return err } + f.isUp = true return nil } func (f *Fuse) Shutdown() error { if f.lf != nil { log.Infof("Shutdown FUSE frontend for %v", f.lf.Volume) - return f.lf.Stop() + if err := f.lf.Stop(); err != nil { + return err + } } + f.isUp = false return nil } + +func (f *Fuse) State() types.State { + if f.isUp { + return types.StateUp + } + return types.StateDown +} diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go index d6d2e43a..924e84b0 100644 --- a/frontend/rest/frontend.go +++ b/frontend/rest/frontend.go @@ -17,14 +17,16 @@ type Device struct { Name string Size int64 SectorSize int64 - backend types.ReaderWriterAt + + isUp bool + backend types.ReaderWriterAt } func New() types.Frontend { return &Device{} } -func (d *Device) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (d *Device) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { d.Name = name d.backend = rw d.Size = size @@ -34,6 +36,7 @@ func (d *Device) Activate(name string, size, sectorSize int64, rw types.ReaderWr return err } + d.isUp = true return nil } @@ -57,5 +60,13 @@ func (d *Device) start() error { } func (d *Device) stop() error { + d.isUp = false return nil } + +func (d *Device) State() types.State { + if d.isUp { + return types.StateUp + } + return types.StateDown +} diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index d7fa75d7..7fdae662 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -32,9 +32,10 @@ func New() types.Frontend { type Tcmu struct { volume string + isUp bool } -func (t *Tcmu) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *Tcmu) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { t.volume = name t.Shutdown() @@ -47,11 +48,26 @@ func (t *Tcmu) Activate(name string, size, sectorSize int64, rw types.ReaderWrit return err } - return PostEnableTcmu(name) + if err := PostEnableTcmu(name); err != nil { + return err + } + t.isUp = true + return nil } func (t *Tcmu) Shutdown() error { - return TeardownTcmu(t.volume) + if err := TeardownTcmu(t.volume); err != nil { + return err + } + t.isUp = false + return nil +} + +func (t *Tcmu) State() types.State { + if t.isUp { + return types.StateUp + } + return types.StateDown } func PreEnableTcmu(volume string, size, sectorSize int64) error { diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 6b54b6eb..f575647b 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -28,12 +28,13 @@ type Tgt struct { Size int64 SectorSize int + isUp bool socketPath string socketServer *rpc.Server scsiDevice *util.ScsiDevice } -func (t *Tgt) Activate(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *Tgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { if err := t.Shutdown(); err != nil { return err } @@ -54,6 +55,8 @@ func (t *Tgt) Activate(name string, size, sectorSize int64, rw types.ReaderWrite return err } + t.isUp = true + return nil } @@ -78,9 +81,18 @@ func (t *Tgt) Shutdown() error { // TODO: In fact we don't know how to shutdown socket server, there is // no way yet } + t.isUp = false + return nil } +func (t *Tgt) State() types.State { + if t.isUp { + return types.StateUp + } + return types.StateDown +} + func (t *Tgt) getSocketPath() string { if t.Volume == "" { panic("Invalid volume name") diff --git a/types/types.go b/types/types.go index 4b3f0970..ab97e19a 100644 --- a/types/types.go +++ b/types/types.go @@ -6,6 +6,9 @@ const ( WO = Mode("WO") RW = Mode("RW") ERR = Mode("ERR") + + StateUp = State("Up") + StateDown = State("Down") ) type ReaderWriterAt interface { @@ -47,12 +50,15 @@ type Server interface { type Mode string +type State string + type Replica struct { Address string Mode Mode } type Frontend interface { - Activate(name string, size, sectorSize int64, rw ReaderWriterAt) error + Startup(name string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error + State() State } From 4bec257f2212d722c5ffcb8f11ff649929777961 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 13 Oct 2016 14:13:15 -0700 Subject: [PATCH 199/357] controller: Prevent user to remove last replica if volume is up The standard process should be stop the volume(frontend), then remove the replicas. Otherwise frontend will connect to nothing in backend. Also update in test to reflect that. --- controller/control.go | 3 +++ integration/core/test_cli.py | 3 +++ integration/core/test_controller.py | 3 +++ integration/data/common.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/controller/control.go b/controller/control.go index 379ebf0d..de39b47e 100644 --- a/controller/control.go +++ b/controller/control.go @@ -130,6 +130,9 @@ func (c *Controller) RemoveReplica(address string) error { for i, r := range c.replicas { if r.Address == address { + if len(c.replicas) == 1 && c.frontend.State() == types.StateUp { + return fmt.Errorf("Cannot remove last replica if volume is up") + } c.replicas = append(c.replicas[:i], c.replicas[i+1:]...) c.backend.RemoveBackend(r.Address) } diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index b648bd0c..1c737f6a 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -29,6 +29,9 @@ def controller_client(request): def cleanup_controller(client): + v = client.list_volume()[0] + if v.replicaCount != 0: + v = v.shutdown() for r in client.list_replica(): client.delete(r) return client diff --git a/integration/core/test_controller.py b/integration/core/test_controller.py index c38f8b0d..d4275131 100644 --- a/integration/core/test_controller.py +++ b/integration/core/test_controller.py @@ -15,6 +15,9 @@ def client(request): def cleanup(client): + v = client.list_volume()[0] + if v.replicaCount != 0: + v = v.shutdown() for r in client.list_replica(): client.delete(r) return client diff --git a/integration/data/common.py b/integration/data/common.py index 143b9e1a..2bf1484b 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -99,6 +99,9 @@ def controller_client(request): def cleanup_controller(client): + v = client.list_volume()[0] + if v.replicaCount != 0: + v = v.shutdown() for r in client.list_replica(): client.delete(r) return client From 87c61c676ed8c71b31909871d4c8deaa2cfc18ec Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 13 Oct 2016 17:44:23 -0700 Subject: [PATCH 200/357] Update README.me to include TGT frontend Also remove replica setup parts for now. --- README.md | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index fad0a947..b99cca01 100644 --- a/README.md +++ b/README.md @@ -9,38 +9,47 @@ A microservice that does micro things. ## Running -You need to be running RancherOS v0.4.4 (all kernel patches are not yet fully upstreamed). -Also ensure that TCMU is enabled: +You can choose either TGT or TCMU frontend. TGT frontend is recommended. TGT +can work with majority of the Linux distributions, while TCMU can work with +RancherOS v0.4.4 and above only. - modprobe target_core_user - mount -t configfs none /sys/kernel/config +Host need to have `docker` installed. Run following command to check: +``` +docker info +``` -Then run +### With TGT frontend - ./bin/longhorn replica --size 10g /opt/volume - ./bin/longhorn replica --size 10g --listen localhost:9505 /opt/volume2 - ./bin/longhorn controller --frontend tcmu --replica tcp://localhost:9502 --replica tcp://localhost:9505 vol-name - -That will create the device `/dev/longhorn/vol-name` +User need to make sure the host has `iscsiadm` installed. Run following command to check: +``` +iscsiadm --version +``` -## Ports +To start Longhorn with an single replica, run following command: +``` +docker run --privileged -v /dev:/host/dev -v /proc:/host/proc rancher/longhorn launch-simple-longhorn vol-name 10g tgt +``` -Each replica uses three consequetive ports. By default they are 9502, 9503, and 9504. They are used for -controll channel, data channel, and sync communication respectively. +That will create the device `/dev/longhorn/vol-name` -## CLI +### With TCMU frontend -List replicas +You need to be running RancherOS v0.4.4 (all kernel patches are upstreamed but only available after Linux v4.5). +Also ensure that TCMU is enabled: - longhorn ls + modprobe target_core_user + mount -t configfs none /sys/kernel/config -Remove replica +To start Longhorn with an single replica, run following command: +``` +docker run --privileged -v /dev:/host/dev -v /proc:/host/proc -v /sys/kernel/config:/sys/kernel/config rancher/longhorn launch-simple-longhorn vol-name 10g tcmu +``` - longhorn rm tcp://localhost:9502 +That will create the device `/dev/longhorn/vol-name` -Add replica +### Longhorn with multiple replicas - longhorn add tcp://localhost:9502 +To be documented. ## License Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) From fc89b1adf8c4c4ad9e17db238960402d843f9199 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 13 Oct 2016 18:36:02 -0700 Subject: [PATCH 201/357] Update README.md Add volume to cmdline --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b99cca01..645a9e18 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ iscsiadm --version To start Longhorn with an single replica, run following command: ``` -docker run --privileged -v /dev:/host/dev -v /proc:/host/proc rancher/longhorn launch-simple-longhorn vol-name 10g tgt +docker run --privileged -v /dev:/host/dev -v /proc:/host/proc -v /volume rancher/longhorn launch-simple-longhorn vol-name 10g tgt ``` That will create the device `/dev/longhorn/vol-name` @@ -42,7 +42,7 @@ Also ensure that TCMU is enabled: To start Longhorn with an single replica, run following command: ``` -docker run --privileged -v /dev:/host/dev -v /proc:/host/proc -v /sys/kernel/config:/sys/kernel/config rancher/longhorn launch-simple-longhorn vol-name 10g tcmu +docker run --privileged -v /dev:/host/dev -v /proc:/host/proc -v /sys/kernel/config:/sys/kernel/config -v /volume rancher/longhorn launch-simple-longhorn vol-name 10g tcmu ``` That will create the device `/dev/longhorn/vol-name` From 5288d6804345224249e05aceef2b03fff049ee26 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 14 Oct 2016 00:11:42 -0700 Subject: [PATCH 202/357] util: Add more detail info about failure reason --- util/util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/util.go b/util/util.go index e62ac4f3..7c0c7c3a 100644 --- a/util/util.go +++ b/util/util.go @@ -187,12 +187,12 @@ func (dev *ScsiDevice) Shutdown() error { func DuplicateDevice(src, dest string) error { stat := unix.Stat_t{} if err := unix.Stat(src, &stat); err != nil { - return err + return fmt.Errorf("Cannot find %s: %v", src, err) } major := int(stat.Rdev / 256) minor := int(stat.Rdev % 256) if err := mknod(dest, major, minor); err != nil { - return err + return fmt.Errorf("Cannot duplicate device %s to %s", src, dest) } return nil } From be5b1f21a92df74ca4ee36934bc1fc2d387cd75b Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 14 Oct 2016 13:59:00 -0700 Subject: [PATCH 203/357] Update README.md Add information for how to use multiple replicas with container. --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 645a9e18..6fe4217d 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,23 @@ That will create the device `/dev/longhorn/vol-name` ### Longhorn with multiple replicas -To be documented. +In order to start Longhorn with multiple replicas, you need to setup a network between Longhorn replica container and controller container. Here we use Docker(v1.10 or later) network feature to demostrate that: + +##### 1. Create a network named `longhorn-net` +``` +docker network create --subnet=172.18.0.0/16 longhorn-net +``` +##### 2. Add two replicas to the network, suppose their IPs are `172.18.0.2` and `172.18.0.3`: +``` +docker run --net longhorn-net --ip 172.18.0.2 -p 9502:9504 -v /volume rancher/longhorn launch replica --listen 172.18.0.2:9502 --size 10g /volume +docker run --net longhorn-net --ip 172.18.0.3 -p 9502:9504 -v /volume rancher/longhorn launch replica --listen 172.18.0.3:9502 --size 10g /volume +``` +Notice you need to expose port 9502 to 9504 for Longhorn controller to communicate with replica. +##### 3. Start Longhorn controller. Take TGT for example: +``` +docker run --net longhorn-net --privileged -v /dev:/host/dev -v /proc:/host/proc rancher/longhorn launch controller --frontend tgt --replica tcp://172.18.0.2:9502 --replica tcp://172.18.0.3:9502 vol-name +``` +Now you will have device `/dev/longhorn/vol-name`. ## License Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) From 006f628d97ca950df468e00d2e43fddbae54512e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 17 Oct 2016 14:11:34 -0700 Subject: [PATCH 204/357] Update README.md Update `docker run` to include correct port expose command. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6fe4217d..3f0cc366 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ docker network create --subnet=172.18.0.0/16 longhorn-net ``` ##### 2. Add two replicas to the network, suppose their IPs are `172.18.0.2` and `172.18.0.3`: ``` -docker run --net longhorn-net --ip 172.18.0.2 -p 9502:9504 -v /volume rancher/longhorn launch replica --listen 172.18.0.2:9502 --size 10g /volume -docker run --net longhorn-net --ip 172.18.0.3 -p 9502:9504 -v /volume rancher/longhorn launch replica --listen 172.18.0.3:9502 --size 10g /volume +docker run --net longhorn-net --ip 172.18.0.2 --expose 9502-9504 -v /volume rancher/longhorn launch replica --listen 172.18.0.2:9502 --size 10g /volume +docker run --net longhorn-net --ip 172.18.0.3 --expose 9502-9504 -v /volume rancher/longhorn launch replica --listen 172.18.0.3:9502 --size 10g /volume ``` Notice you need to expose port 9502 to 9504 for Longhorn controller to communicate with replica. ##### 3. Start Longhorn controller. Take TGT for example: From 8647aad790d045cf39da512d3ad08838ad2b0cde Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 17 Oct 2016 16:52:05 -0700 Subject: [PATCH 205/357] package: Update launch script to skip TCMU steps if necessary We're going to use TGT as frontend. Also remove `set -x` --- package/launch | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/package/launch b/package/launch index fb8b8195..97d1a573 100755 --- a/package/launch +++ b/package/launch @@ -1,14 +1,34 @@ #!/bin/bash -set -x - if [ "$1" == "controller" ]; then - if [ ! -d /sys/kernel/config ]; then - modprobe target_core_user - fi + mount --rbind /host/dev /dev + + frontend= + fe=0 + for i in "$@" + do + if [ $fe -eq 1 ] + then + frontend=$i + break + fi + case $i in + --frontend) + fe=1 + ;; + *) + ;; + esac + done - mount --rbind /host/dev /dev - mount -t configfs none /sys/kernel/config + if [ "$frontend" == "tcmu" ] + then + echo "Prepare for TCMU" + if [ ! -d /sys/kernel/config ]; then + modprobe target_core_user + fi + mount -t configfs none /sys/kernel/config + fi fi exec longhorn "$@" From eb8ebf1db3c652be2cf51d3b9597fc6222ccf634 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 21 Oct 2016 14:03:33 -0700 Subject: [PATCH 206/357] Remove FUSE frontend --- app/controller_fusedev.go | 9 - frontend/fusedev/frontend.go | 46 - frontend/fusedev/fuse.go | 275 --- trash.yml | 4 - vendor/bazil.org/fuse/.gitattributes | 2 - vendor/bazil.org/fuse/.gitignore | 11 - vendor/bazil.org/fuse/LICENSE | 93 - vendor/bazil.org/fuse/README.md | 23 - vendor/bazil.org/fuse/buffer.go | 35 - vendor/bazil.org/fuse/debug.go | 21 - vendor/bazil.org/fuse/error_darwin.go | 17 - vendor/bazil.org/fuse/error_freebsd.go | 15 - vendor/bazil.org/fuse/error_linux.go | 17 - vendor/bazil.org/fuse/error_std.go | 31 - vendor/bazil.org/fuse/fs/serve.go | 1568 ------------ vendor/bazil.org/fuse/fs/tree.go | 99 - vendor/bazil.org/fuse/fuse.go | 2303 ------------------ vendor/bazil.org/fuse/fuse_darwin.go | 9 - vendor/bazil.org/fuse/fuse_freebsd.go | 6 - vendor/bazil.org/fuse/fuse_kernel.go | 774 ------ vendor/bazil.org/fuse/fuse_kernel_darwin.go | 88 - vendor/bazil.org/fuse/fuse_kernel_freebsd.go | 62 - vendor/bazil.org/fuse/fuse_kernel_linux.go | 70 - vendor/bazil.org/fuse/fuse_kernel_std.go | 1 - vendor/bazil.org/fuse/fuse_linux.go | 7 - vendor/bazil.org/fuse/fuseutil/fuseutil.go | 20 - vendor/bazil.org/fuse/mount.go | 38 - vendor/bazil.org/fuse/mount_darwin.go | 208 -- vendor/bazil.org/fuse/mount_freebsd.go | 111 - vendor/bazil.org/fuse/mount_linux.go | 150 -- vendor/bazil.org/fuse/options.go | 279 --- vendor/bazil.org/fuse/options_darwin.go | 30 - vendor/bazil.org/fuse/options_freebsd.go | 24 - vendor/bazil.org/fuse/options_linux.go | 21 - vendor/bazil.org/fuse/protocol.go | 75 - vendor/bazil.org/fuse/unmount.go | 6 - vendor/bazil.org/fuse/unmount_linux.go | 21 - vendor/bazil.org/fuse/unmount_std.go | 17 - vendor/golang.org/x/net/context/context.go | 447 ---- 39 files changed, 7033 deletions(-) delete mode 100644 app/controller_fusedev.go delete mode 100644 frontend/fusedev/frontend.go delete mode 100644 frontend/fusedev/fuse.go delete mode 100644 vendor/bazil.org/fuse/.gitattributes delete mode 100644 vendor/bazil.org/fuse/.gitignore delete mode 100644 vendor/bazil.org/fuse/LICENSE delete mode 100644 vendor/bazil.org/fuse/README.md delete mode 100644 vendor/bazil.org/fuse/buffer.go delete mode 100644 vendor/bazil.org/fuse/debug.go delete mode 100644 vendor/bazil.org/fuse/error_darwin.go delete mode 100644 vendor/bazil.org/fuse/error_freebsd.go delete mode 100644 vendor/bazil.org/fuse/error_linux.go delete mode 100644 vendor/bazil.org/fuse/error_std.go delete mode 100644 vendor/bazil.org/fuse/fs/serve.go delete mode 100644 vendor/bazil.org/fuse/fs/tree.go delete mode 100644 vendor/bazil.org/fuse/fuse.go delete mode 100644 vendor/bazil.org/fuse/fuse_darwin.go delete mode 100644 vendor/bazil.org/fuse/fuse_freebsd.go delete mode 100644 vendor/bazil.org/fuse/fuse_kernel.go delete mode 100644 vendor/bazil.org/fuse/fuse_kernel_darwin.go delete mode 100644 vendor/bazil.org/fuse/fuse_kernel_freebsd.go delete mode 100644 vendor/bazil.org/fuse/fuse_kernel_linux.go delete mode 100644 vendor/bazil.org/fuse/fuse_kernel_std.go delete mode 100644 vendor/bazil.org/fuse/fuse_linux.go delete mode 100644 vendor/bazil.org/fuse/fuseutil/fuseutil.go delete mode 100644 vendor/bazil.org/fuse/mount.go delete mode 100644 vendor/bazil.org/fuse/mount_darwin.go delete mode 100644 vendor/bazil.org/fuse/mount_freebsd.go delete mode 100644 vendor/bazil.org/fuse/mount_linux.go delete mode 100644 vendor/bazil.org/fuse/options.go delete mode 100644 vendor/bazil.org/fuse/options_darwin.go delete mode 100644 vendor/bazil.org/fuse/options_freebsd.go delete mode 100644 vendor/bazil.org/fuse/options_linux.go delete mode 100644 vendor/bazil.org/fuse/protocol.go delete mode 100644 vendor/bazil.org/fuse/unmount.go delete mode 100644 vendor/bazil.org/fuse/unmount_linux.go delete mode 100644 vendor/bazil.org/fuse/unmount_std.go delete mode 100644 vendor/golang.org/x/net/context/context.go diff --git a/app/controller_fusedev.go b/app/controller_fusedev.go deleted file mode 100644 index 711f05b9..00000000 --- a/app/controller_fusedev.go +++ /dev/null @@ -1,9 +0,0 @@ -package app - -import ( - "github.com/rancher/longhorn/frontend/fusedev" -) - -func init() { - frontends["fuse"] = fusedev.New() -} diff --git a/frontend/fusedev/frontend.go b/frontend/fusedev/frontend.go deleted file mode 100644 index 35e97a75..00000000 --- a/frontend/fusedev/frontend.go +++ /dev/null @@ -1,46 +0,0 @@ -package fusedev - -import ( - "github.com/rancher/longhorn/types" -) - -func New() types.Frontend { - return &Fuse{} -} - -type Fuse struct { - lf *LonghornFs - isUp bool -} - -func (f *Fuse) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { - if err := f.Shutdown(); err != nil { - return err - } - - f.lf = newLonghornFs(name, size, sectorSize, rw) - log.Infof("Activate FUSE frontend for %v, size %v, sector size %v", name, size, sectorSize) - if err := f.lf.Start(); err != nil { - return err - } - f.isUp = true - return nil -} - -func (f *Fuse) Shutdown() error { - if f.lf != nil { - log.Infof("Shutdown FUSE frontend for %v", f.lf.Volume) - if err := f.lf.Stop(); err != nil { - return err - } - } - f.isUp = false - return nil -} - -func (f *Fuse) State() types.State { - if f.isUp { - return types.StateUp - } - return types.StateDown -} diff --git a/frontend/fusedev/fuse.go b/frontend/fusedev/fuse.go deleted file mode 100644 index 3db66eb3..00000000 --- a/frontend/fusedev/fuse.go +++ /dev/null @@ -1,275 +0,0 @@ -package fusedev - -import ( - "fmt" - "os" - "path/filepath" - "time" - - "github.com/Sirupsen/logrus" - "golang.org/x/net/context" - "golang.org/x/sys/unix" - - "bazil.org/fuse" - "bazil.org/fuse/fs" - - cutil "github.com/rancher/convoy/util" - - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" -) - -type LonghornFs struct { - Conn *fuse.Conn - Volume string - rawFile *RawFrontendFile - scsiDev *util.ScsiDevice -} - -type RawFrontendFile struct { - Backend types.ReaderWriterAt - Size int64 - SectorSize int64 -} - -const ( - ImageSuffix = ".img" - DevPath = "/dev/longhorn/" - MountBase = "/tmp/longhorn-fuse-mount" - - RetryCounts = 5 - RetryInterval = 1 * time.Second -) - -var ( - log = logrus.WithFields(logrus.Fields{"pkg": "fusedev"}) -) - -func newLonghornFs(name string, size, sectorSize int64, rw types.ReaderWriterAt) *LonghornFs { - return &LonghornFs{ - Volume: name, - rawFile: &RawFrontendFile{ - Backend: rw, - Size: size, - SectorSize: sectorSize, - }, - } -} - -func (lf *LonghornFs) Start() error { - var err error - mountDir := lf.GetMountDir() - if err := os.MkdirAll(mountDir, 0700); err != nil { - return fmt.Errorf("Cannot create directory %v", mountDir) - } - lf.Conn, err = fuse.Mount(mountDir, - fuse.FSName("longhorn"), - fuse.Subtype("longhornfs"), - fuse.VolumeName(lf.Volume), - fuse.AsyncDIO(), - ) - if err != nil { - log.Fatal("FUSE: Unable to mount: ", err) - } - - go lf.startFs() - - if err := lf.createDev(); err != nil { - log.Warn("Fail to bring up device, waiting") - return err - } - return nil -} - -func (lf *LonghornFs) startFs() { - if err := fs.Serve(lf.Conn, lf); err != nil { - // Likely caused by umount, so ignore it for now - if err == unix.EBADF { - log.Warnf("Serve return ", err) - } else { - log.Fatal("FUSE: Unable to serve: ", err) - } - } - - <-lf.Conn.Ready - if err := lf.Conn.MountError; err != nil { - log.Fatal("FUSE: Mount error occured: ", err) - } -} - -func (lf *LonghornFs) Stop() error { - if err := lf.initStop(); err != nil { - return err - } - return nil -} - -func (lf *LonghornFs) initStop() error { - if lf.Conn != nil { - defer lf.Conn.Close() - } - if err := lf.removeDev(); err != nil { - return err - } - if err := lf.umountFuse(); err != nil { - return err - } - return nil -} - -func (lf *LonghornFs) getDev() string { - return filepath.Join(DevPath, lf.Volume) -} - -func (lf *LonghornFs) createDev() error { - if err := os.MkdirAll(DevPath, 0700); err != nil { - log.Fatalln("Cannot create directory ", DevPath) - } - - dev := lf.getDev() - - if _, err := os.Stat(dev); err == nil { - return fmt.Errorf("Device %s already exists, can not create", dev) - } - - found := false - path := lf.getImageFileFullPath() - for i := 0; i < 30; i++ { - var err error - matches, err := filepath.Glob(path) - if len(matches) > 0 && err == nil { - found = true - break - } - - logrus.Infof("Waiting for %s", path) - time.Sleep(1 * time.Second) - } - - if !found { - return fmt.Errorf("Fail to wait for %v", path) - } - - if lf.scsiDev == nil { - scsiDev, err := util.NewScsiDevice(lf.Volume, path, "aio", "") - if err != nil { - return err - } - lf.scsiDev = scsiDev - } - if err := lf.scsiDev.Startup(); err != nil { - return err - } - - if err := util.DuplicateDevice(lf.scsiDev.Device, dev); err != nil { - return err - } - return nil -} - -func (lf *LonghornFs) removeDev() error { - dev := lf.getDev() - logrus.Infof("Removing device %s", dev) - if err := util.RemoveDevice(dev); err != nil { - return err - } - - if lf.scsiDev.Device != "" { - if err := lf.scsiDev.Shutdown(); err != nil { - return err - } - } - return nil -} - -func (lf *LonghornFs) umountFuse() error { - if lf.isMounted() { - dir := lf.GetMountDir() - logrus.Infof("Umounting %s", dir) - if err := unix.Unmount(dir, 0); err != nil { - return fmt.Errorf("Fail to umounting %s: %v", dir, err) - } - } - return nil -} - -func (lf *LonghornFs) isMounted() bool { - path := lf.GetMountDir() - if _, err := cutil.Execute("findmnt", []string{path}); err != nil { - return false - } - return true -} - -func (lf *LonghornFs) GetMountDir() string { - return filepath.Join(MountBase, lf.Volume) -} - -func (lf *LonghornFs) getImageFileName() string { - return lf.Volume + ImageSuffix -} - -func (lf *LonghornFs) getImageFileFullPath() string { - return filepath.Join(lf.GetMountDir(), lf.getImageFileName()) -} - -func (lf *LonghornFs) Root() (fs.Node, error) { - return lf, nil -} - -func (lf *LonghornFs) Attr(cxt context.Context, a *fuse.Attr) error { - a.Inode = 1 - a.Mode = os.ModeDir | 0555 - return nil -} - -func (lf *LonghornFs) Lookup(cxt context.Context, name string) (fs.Node, error) { - if name == lf.getImageFileName() { - return lf.rawFile, nil - } - return nil, fuse.ENOENT -} - -func (lf *LonghornFs) ReadDirAll(cxt context.Context) ([]fuse.Dirent, error) { - return []fuse.Dirent{ - {Inode: 2, Name: lf.getImageFileName(), Type: fuse.DT_File}, - }, nil -} - -func (f *RawFrontendFile) Attr(ctx context.Context, a *fuse.Attr) error { - a.Inode = 2 - a.Mode = 0444 - a.Size = uint64(f.Size) - return nil -} - -func (f *RawFrontendFile) Open(cxt context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { - return f, nil -} - -func (f *RawFrontendFile) Read(cxt context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error { - l := int64(req.Size) - if req.Offset+l > f.Size { - l = f.Size - req.Offset - } - _, err := f.Backend.ReadAt(resp.Data[:l], req.Offset) - if err != nil { - return fmt.Errorf("read failed: %v", err) - } - resp.Data = resp.Data[:l] - return nil -} - -func (f *RawFrontendFile) Write(cxt context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error { - l := int64(len(req.Data)) - if req.Offset+l > f.Size { - l = f.Size - req.Offset - } - - _, err := f.Backend.WriteAt(req.Data[:l], req.Offset) - if err != nil { - return fmt.Errorf("write failed: %v", err) - } - resp.Size = int(l) - return nil -} diff --git a/trash.yml b/trash.yml index da31e4f4..f0eee423 100644 --- a/trash.yml +++ b/trash.yml @@ -58,9 +58,5 @@ import: version: c01cf91b011868172fdcd9f41838e80c9d716264 - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 -- package: bazil.org/fuse - version: b3d5a5514a27076c63844bde6d60703a7aea4adc -- package: golang.org/x/net/context - version: 31df19d69da8728e9220def59b80ee577c3e48bf - package: github.com/yasker/go-iscsi-helper version: 378989ccf1cd08b5b8bff8e35c221495b59efca5 diff --git a/vendor/bazil.org/fuse/.gitattributes b/vendor/bazil.org/fuse/.gitattributes deleted file mode 100644 index b65f2a9f..00000000 --- a/vendor/bazil.org/fuse/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.go filter=gofmt -*.cgo filter=gofmt diff --git a/vendor/bazil.org/fuse/.gitignore b/vendor/bazil.org/fuse/.gitignore deleted file mode 100644 index 53589948..00000000 --- a/vendor/bazil.org/fuse/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -*~ -.#* -## the next line needs to start with a backslash to avoid looking like -## a comment -\#*# -.*.swp - -*.test - -/clockfs -/hellofs diff --git a/vendor/bazil.org/fuse/LICENSE b/vendor/bazil.org/fuse/LICENSE deleted file mode 100644 index 4ac7cd83..00000000 --- a/vendor/bazil.org/fuse/LICENSE +++ /dev/null @@ -1,93 +0,0 @@ -Copyright (c) 2013-2015 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/vendor/bazil.org/fuse/README.md b/vendor/bazil.org/fuse/README.md deleted file mode 100644 index 8c6d556e..00000000 --- a/vendor/bazil.org/fuse/README.md +++ /dev/null @@ -1,23 +0,0 @@ -bazil.org/fuse -- Filesystems in Go -=================================== - -`bazil.org/fuse` is a Go library for writing FUSE userspace -filesystems. - -It is a from-scratch implementation of the kernel-userspace -communication protocol, and does not use the C library from the -project called FUSE. `bazil.org/fuse` embraces Go fully for safety and -ease of programming. - -Here’s how to get going: - - go get bazil.org/fuse - -Website: http://bazil.org/fuse/ - -Github repository: https://github.com/bazil/fuse - -API docs: http://godoc.org/bazil.org/fuse - -Our thanks to Russ Cox for his fuse library, which this project is -based on. diff --git a/vendor/bazil.org/fuse/buffer.go b/vendor/bazil.org/fuse/buffer.go deleted file mode 100644 index bb1d2b77..00000000 --- a/vendor/bazil.org/fuse/buffer.go +++ /dev/null @@ -1,35 +0,0 @@ -package fuse - -import "unsafe" - -// buffer provides a mechanism for constructing a message from -// multiple segments. -type buffer []byte - -// alloc allocates size bytes and returns a pointer to the new -// segment. -func (w *buffer) alloc(size uintptr) unsafe.Pointer { - s := int(size) - if len(*w)+s > cap(*w) { - old := *w - *w = make([]byte, len(*w), 2*cap(*w)+s) - copy(*w, old) - } - l := len(*w) - *w = (*w)[:l+s] - return unsafe.Pointer(&(*w)[l]) -} - -// reset clears out the contents of the buffer. -func (w *buffer) reset() { - for i := range (*w)[:cap(*w)] { - (*w)[i] = 0 - } - *w = (*w)[:0] -} - -func newBuffer(extra uintptr) buffer { - const hdrSize = unsafe.Sizeof(outHeader{}) - buf := make(buffer, hdrSize, hdrSize+extra) - return buf -} diff --git a/vendor/bazil.org/fuse/debug.go b/vendor/bazil.org/fuse/debug.go deleted file mode 100644 index be9f900d..00000000 --- a/vendor/bazil.org/fuse/debug.go +++ /dev/null @@ -1,21 +0,0 @@ -package fuse - -import ( - "runtime" -) - -func stack() string { - buf := make([]byte, 1024) - return string(buf[:runtime.Stack(buf, false)]) -} - -func nop(msg interface{}) {} - -// Debug is called to output debug messages, including protocol -// traces. The default behavior is to do nothing. -// -// The messages have human-friendly string representations and are -// safe to marshal to JSON. -// -// Implementations must not retain msg. -var Debug func(msg interface{}) = nop diff --git a/vendor/bazil.org/fuse/error_darwin.go b/vendor/bazil.org/fuse/error_darwin.go deleted file mode 100644 index a3fb89ca..00000000 --- a/vendor/bazil.org/fuse/error_darwin.go +++ /dev/null @@ -1,17 +0,0 @@ -package fuse - -import ( - "syscall" -) - -const ( - ENOATTR = Errno(syscall.ENOATTR) -) - -const ( - errNoXattr = ENOATTR -) - -func init() { - errnoNames[errNoXattr] = "ENOATTR" -} diff --git a/vendor/bazil.org/fuse/error_freebsd.go b/vendor/bazil.org/fuse/error_freebsd.go deleted file mode 100644 index c6ea6d6e..00000000 --- a/vendor/bazil.org/fuse/error_freebsd.go +++ /dev/null @@ -1,15 +0,0 @@ -package fuse - -import "syscall" - -const ( - ENOATTR = Errno(syscall.ENOATTR) -) - -const ( - errNoXattr = ENOATTR -) - -func init() { - errnoNames[errNoXattr] = "ENOATTR" -} diff --git a/vendor/bazil.org/fuse/error_linux.go b/vendor/bazil.org/fuse/error_linux.go deleted file mode 100644 index 6f113e71..00000000 --- a/vendor/bazil.org/fuse/error_linux.go +++ /dev/null @@ -1,17 +0,0 @@ -package fuse - -import ( - "syscall" -) - -const ( - ENODATA = Errno(syscall.ENODATA) -) - -const ( - errNoXattr = ENODATA -) - -func init() { - errnoNames[errNoXattr] = "ENODATA" -} diff --git a/vendor/bazil.org/fuse/error_std.go b/vendor/bazil.org/fuse/error_std.go deleted file mode 100644 index 398f43fb..00000000 --- a/vendor/bazil.org/fuse/error_std.go +++ /dev/null @@ -1,31 +0,0 @@ -package fuse - -// There is very little commonality in extended attribute errors -// across platforms. -// -// getxattr return value for "extended attribute does not exist" is -// ENOATTR on OS X, and ENODATA on Linux and apparently at least -// NetBSD. There may be a #define ENOATTR on Linux too, but the value -// is ENODATA in the actual syscalls. FreeBSD and OpenBSD have no -// ENODATA, only ENOATTR. ENOATTR is not in any of the standards, -// ENODATA exists but is only used for STREAMs. -// -// Each platform will define it a errNoXattr constant, and this file -// will enforce that it implements the right interfaces and hide the -// implementation. -// -// https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/getxattr.2.html -// http://mail-index.netbsd.org/tech-kern/2012/04/30/msg013090.html -// http://mail-index.netbsd.org/tech-kern/2012/04/30/msg013097.html -// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html -// http://www.freebsd.org/cgi/man.cgi?query=extattr_get_file&sektion=2 -// http://nixdoc.net/man-pages/openbsd/man2/extattr_get_file.2.html - -// ErrNoXattr is a platform-independent error value meaning the -// extended attribute was not found. It can be used to respond to -// GetxattrRequest and such. -const ErrNoXattr = errNoXattr - -var _ error = ErrNoXattr -var _ Errno = ErrNoXattr -var _ ErrorNumber = ErrNoXattr diff --git a/vendor/bazil.org/fuse/fs/serve.go b/vendor/bazil.org/fuse/fs/serve.go deleted file mode 100644 index e9fc5659..00000000 --- a/vendor/bazil.org/fuse/fs/serve.go +++ /dev/null @@ -1,1568 +0,0 @@ -// FUSE service loop, for servers that wish to use it. - -package fs // import "bazil.org/fuse/fs" - -import ( - "encoding/binary" - "fmt" - "hash/fnv" - "io" - "log" - "reflect" - "runtime" - "strings" - "sync" - "time" - - "golang.org/x/net/context" -) - -import ( - "bytes" - - "bazil.org/fuse" - "bazil.org/fuse/fuseutil" -) - -const ( - attrValidTime = 1 * time.Minute - entryValidTime = 1 * time.Minute -) - -// TODO: FINISH DOCS - -// An FS is the interface required of a file system. -// -// Other FUSE requests can be handled by implementing methods from the -// FS* interfaces, for example FSStatfser. -type FS interface { - // Root is called to obtain the Node for the file system root. - Root() (Node, error) -} - -type FSStatfser interface { - // Statfs is called to obtain file system metadata. - // It should write that data to resp. - Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error -} - -type FSDestroyer interface { - // Destroy is called when the file system is shutting down. - // - // Linux only sends this request for block device backed (fuseblk) - // filesystems, to allow them to flush writes to disk before the - // unmount completes. - Destroy() -} - -type FSInodeGenerator interface { - // GenerateInode is called to pick a dynamic inode number when it - // would otherwise be 0. - // - // Not all filesystems bother tracking inodes, but FUSE requires - // the inode to be set, and fewer duplicates in general makes UNIX - // tools work better. - // - // Operations where the nodes may return 0 inodes include Getattr, - // Setattr and ReadDir. - // - // If FS does not implement FSInodeGenerator, GenerateDynamicInode - // is used. - // - // Implementing this is useful to e.g. constrain the range of - // inode values used for dynamic inodes. - GenerateInode(parentInode uint64, name string) uint64 -} - -// A Node is the interface required of a file or directory. -// See the documentation for type FS for general information -// pertaining to all methods. -// -// A Node must be usable as a map key, that is, it cannot be a -// function, map or slice. -// -// Other FUSE requests can be handled by implementing methods from the -// Node* interfaces, for example NodeOpener. -// -// Methods returning Node should take care to return the same Node -// when the result is logically the same instance. Without this, each -// Node will get a new NodeID, causing spurious cache invalidations, -// extra lookups and aliasing anomalies. This may not matter for a -// simple, read-only filesystem. -type Node interface { - // Attr fills attr with the standard metadata for the node. - // - // Fields with reasonable defaults are prepopulated. For example, - // all times are set to a fixed moment when the program started. - // - // If Inode is left as 0, a dynamic inode number is chosen. - // - // The result may be cached for the duration set in Valid. - Attr(ctx context.Context, attr *fuse.Attr) error -} - -type NodeGetattrer interface { - // Getattr obtains the standard metadata for the receiver. - // It should store that metadata in resp. - // - // If this method is not implemented, the attributes will be - // generated based on Attr(), with zero values filled in. - Getattr(ctx context.Context, req *fuse.GetattrRequest, resp *fuse.GetattrResponse) error -} - -type NodeSetattrer interface { - // Setattr sets the standard metadata for the receiver. - // - // Note, this is also used to communicate changes in the size of - // the file, outside of Writes. - // - // req.Valid is a bitmask of what fields are actually being set. - // For example, the method should not change the mode of the file - // unless req.Valid.Mode() is true. - Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error -} - -type NodeSymlinker interface { - // Symlink creates a new symbolic link in the receiver, which must be a directory. - // - // TODO is the above true about directories? - Symlink(ctx context.Context, req *fuse.SymlinkRequest) (Node, error) -} - -// This optional request will be called only for symbolic link nodes. -type NodeReadlinker interface { - // Readlink reads a symbolic link. - Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) -} - -type NodeLinker interface { - // Link creates a new directory entry in the receiver based on an - // existing Node. Receiver must be a directory. - Link(ctx context.Context, req *fuse.LinkRequest, old Node) (Node, error) -} - -type NodeRemover interface { - // Remove removes the entry with the given name from - // the receiver, which must be a directory. The entry to be removed - // may correspond to a file (unlink) or to a directory (rmdir). - Remove(ctx context.Context, req *fuse.RemoveRequest) error -} - -type NodeAccesser interface { - // Access checks whether the calling context has permission for - // the given operations on the receiver. If so, Access should - // return nil. If not, Access should return EPERM. - // - // Note that this call affects the result of the access(2) system - // call but not the open(2) system call. If Access is not - // implemented, the Node behaves as if it always returns nil - // (permission granted), relying on checks in Open instead. - Access(ctx context.Context, req *fuse.AccessRequest) error -} - -type NodeStringLookuper interface { - // Lookup looks up a specific entry in the receiver, - // which must be a directory. Lookup should return a Node - // corresponding to the entry. If the name does not exist in - // the directory, Lookup should return ENOENT. - // - // Lookup need not to handle the names "." and "..". - Lookup(ctx context.Context, name string) (Node, error) -} - -type NodeRequestLookuper interface { - // Lookup looks up a specific entry in the receiver. - // See NodeStringLookuper for more. - Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (Node, error) -} - -type NodeMkdirer interface { - Mkdir(ctx context.Context, req *fuse.MkdirRequest) (Node, error) -} - -type NodeOpener interface { - // Open opens the receiver. After a successful open, a client - // process has a file descriptor referring to this Handle. - // - // Open can also be also called on non-files. For example, - // directories are Opened for ReadDir or fchdir(2). - // - // If this method is not implemented, the open will always - // succeed, and the Node itself will be used as the Handle. - // - // XXX note about access. XXX OpenFlags. - Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (Handle, error) -} - -type NodeCreater interface { - // Create creates a new directory entry in the receiver, which - // must be a directory. - Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (Node, Handle, error) -} - -type NodeForgetter interface { - // Forget about this node. This node will not receive further - // method calls. - // - // Forget is not necessarily seen on unmount, as all nodes are - // implicitly forgotten as part part of the unmount. - Forget() -} - -type NodeRenamer interface { - Rename(ctx context.Context, req *fuse.RenameRequest, newDir Node) error -} - -type NodeMknoder interface { - Mknod(ctx context.Context, req *fuse.MknodRequest) (Node, error) -} - -// TODO this should be on Handle not Node -type NodeFsyncer interface { - Fsync(ctx context.Context, req *fuse.FsyncRequest) error -} - -type NodeGetxattrer interface { - // Getxattr gets an extended attribute by the given name from the - // node. - // - // If there is no xattr by that name, returns fuse.ErrNoXattr. - Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error -} - -type NodeListxattrer interface { - // Listxattr lists the extended attributes recorded for the node. - Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error -} - -type NodeSetxattrer interface { - // Setxattr sets an extended attribute with the given name and - // value for the node. - Setxattr(ctx context.Context, req *fuse.SetxattrRequest) error -} - -type NodeRemovexattrer interface { - // Removexattr removes an extended attribute for the name. - // - // If there is no xattr by that name, returns fuse.ErrNoXattr. - Removexattr(ctx context.Context, req *fuse.RemovexattrRequest) error -} - -var startTime = time.Now() - -func nodeAttr(ctx context.Context, n Node, attr *fuse.Attr) error { - attr.Valid = attrValidTime - attr.Nlink = 1 - attr.Atime = startTime - attr.Mtime = startTime - attr.Ctime = startTime - attr.Crtime = startTime - if err := n.Attr(ctx, attr); err != nil { - return err - } - return nil -} - -// A Handle is the interface required of an opened file or directory. -// See the documentation for type FS for general information -// pertaining to all methods. -// -// Other FUSE requests can be handled by implementing methods from the -// Handle* interfaces. The most common to implement are HandleReader, -// HandleReadDirer, and HandleWriter. -// -// TODO implement methods: Getlk, Setlk, Setlkw -type Handle interface { -} - -type HandleFlusher interface { - // Flush is called each time the file or directory is closed. - // Because there can be multiple file descriptors referring to a - // single opened file, Flush can be called multiple times. - Flush(ctx context.Context, req *fuse.FlushRequest) error -} - -type HandleReadAller interface { - ReadAll(ctx context.Context) ([]byte, error) -} - -type HandleReadDirAller interface { - ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) -} - -type HandleReader interface { - // Read requests to read data from the handle. - // - // There is a page cache in the kernel that normally submits only - // page-aligned reads spanning one or more pages. However, you - // should not rely on this. To see individual requests as - // submitted by the file system clients, set OpenDirectIO. - // - // Note that reads beyond the size of the file as reported by Attr - // are not even attempted (except in OpenDirectIO mode). - Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error -} - -type HandleWriter interface { - // Write requests to write data into the handle at the given offset. - // Store the amount of data written in resp.Size. - // - // There is a writeback page cache in the kernel that normally submits - // only page-aligned writes spanning one or more pages. However, - // you should not rely on this. To see individual requests as - // submitted by the file system clients, set OpenDirectIO. - // - // Writes that grow the file are expected to update the file size - // (as seen through Attr). Note that file size changes are - // communicated also through Setattr. - Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error -} - -type HandleReleaser interface { - Release(ctx context.Context, req *fuse.ReleaseRequest) error -} - -type Config struct { - // Function to send debug log messages to. If nil, use fuse.Debug. - // Note that changing this or fuse.Debug may not affect existing - // calls to Serve. - // - // See fuse.Debug for the rules that log functions must follow. - Debug func(msg interface{}) - - // Function to put things into context for processing the request. - // The returned context must have ctx as its parent. - // - // Note that changing this may not affect existing calls to Serve. - // - // Must not retain req. - WithContext func(ctx context.Context, req fuse.Request) context.Context -} - -// New returns a new FUSE server ready to serve this kernel FUSE -// connection. -// -// Config may be nil. -func New(conn *fuse.Conn, config *Config) *Server { - s := &Server{ - conn: conn, - req: map[fuse.RequestID]*serveRequest{}, - nodeRef: map[Node]fuse.NodeID{}, - dynamicInode: GenerateDynamicInode, - } - if config != nil { - s.debug = config.Debug - s.context = config.WithContext - } - if s.debug == nil { - s.debug = fuse.Debug - } - return s -} - -type Server struct { - // set in New - conn *fuse.Conn - debug func(msg interface{}) - context func(ctx context.Context, req fuse.Request) context.Context - - // set once at Serve time - fs FS - dynamicInode func(parent uint64, name string) uint64 - - // state, protected by meta - meta sync.Mutex - req map[fuse.RequestID]*serveRequest - node []*serveNode - nodeRef map[Node]fuse.NodeID - handle []*serveHandle - freeNode []fuse.NodeID - freeHandle []fuse.HandleID - nodeGen uint64 - - // Used to ensure worker goroutines finish before Serve returns - wg sync.WaitGroup -} - -// Serve serves the FUSE connection by making calls to the methods -// of fs and the Nodes and Handles it makes available. It returns only -// when the connection has been closed or an unexpected error occurs. -func (s *Server) Serve(fs FS) error { - defer s.wg.Wait() // Wait for worker goroutines to complete before return - - s.fs = fs - if dyn, ok := fs.(FSInodeGenerator); ok { - s.dynamicInode = dyn.GenerateInode - } - - root, err := fs.Root() - if err != nil { - return fmt.Errorf("cannot obtain root node: %v", err) - } - // Recognize the root node if it's ever returned from Lookup, - // passed to Invalidate, etc. - s.nodeRef[root] = 1 - s.node = append(s.node, nil, &serveNode{ - inode: 1, - generation: s.nodeGen, - node: root, - refs: 1, - }) - s.handle = append(s.handle, nil) - - for { - req, err := s.conn.ReadRequest() - if err != nil { - if err == io.EOF { - break - } - return err - } - - s.wg.Add(1) - go func() { - defer s.wg.Done() - s.serve(req) - }() - } - return nil -} - -// Serve serves a FUSE connection with the default settings. See -// Server.Serve. -func Serve(c *fuse.Conn, fs FS) error { - server := New(c, nil) - return server.Serve(fs) -} - -type nothing struct{} - -type serveRequest struct { - Request fuse.Request - cancel func() -} - -type serveNode struct { - inode uint64 - generation uint64 - node Node - refs uint64 - - // Delay freeing the NodeID until waitgroup is done. This allows - // using the NodeID for short periods of time without holding the - // Server.meta lock. - // - // Rules: - // - // - hold Server.meta while calling wg.Add, then unlock - // - do NOT try to reacquire Server.meta - wg sync.WaitGroup -} - -func (sn *serveNode) attr(ctx context.Context, attr *fuse.Attr) error { - err := nodeAttr(ctx, sn.node, attr) - if attr.Inode == 0 { - attr.Inode = sn.inode - } - return err -} - -type serveHandle struct { - handle Handle - readData []byte - nodeID fuse.NodeID -} - -// NodeRef is deprecated. It remains here to decrease code churn on -// FUSE library users. You may remove it from your program now; -// returning the same Node values are now recognized automatically, -// without needing NodeRef. -type NodeRef struct{} - -func (c *Server) saveNode(inode uint64, node Node) (id fuse.NodeID, gen uint64) { - c.meta.Lock() - defer c.meta.Unlock() - - if id, ok := c.nodeRef[node]; ok { - sn := c.node[id] - sn.refs++ - return id, sn.generation - } - - sn := &serveNode{inode: inode, node: node, refs: 1} - if n := len(c.freeNode); n > 0 { - id = c.freeNode[n-1] - c.freeNode = c.freeNode[:n-1] - c.node[id] = sn - c.nodeGen++ - } else { - id = fuse.NodeID(len(c.node)) - c.node = append(c.node, sn) - } - sn.generation = c.nodeGen - c.nodeRef[node] = id - return id, sn.generation -} - -func (c *Server) saveHandle(handle Handle, nodeID fuse.NodeID) (id fuse.HandleID) { - c.meta.Lock() - shandle := &serveHandle{handle: handle, nodeID: nodeID} - if n := len(c.freeHandle); n > 0 { - id = c.freeHandle[n-1] - c.freeHandle = c.freeHandle[:n-1] - c.handle[id] = shandle - } else { - id = fuse.HandleID(len(c.handle)) - c.handle = append(c.handle, shandle) - } - c.meta.Unlock() - return -} - -type nodeRefcountDropBug struct { - N uint64 - Refs uint64 - Node fuse.NodeID -} - -func (n *nodeRefcountDropBug) String() string { - return fmt.Sprintf("bug: trying to drop %d of %d references to %v", n.N, n.Refs, n.Node) -} - -func (c *Server) dropNode(id fuse.NodeID, n uint64) (forget bool) { - c.meta.Lock() - defer c.meta.Unlock() - snode := c.node[id] - - if snode == nil { - // this should only happen if refcounts kernel<->us disagree - // *and* two ForgetRequests for the same node race each other; - // this indicates a bug somewhere - c.debug(nodeRefcountDropBug{N: n, Node: id}) - - // we may end up triggering Forget twice, but that's better - // than not even once, and that's the best we can do - return true - } - - if n > snode.refs { - c.debug(nodeRefcountDropBug{N: n, Refs: snode.refs, Node: id}) - n = snode.refs - } - - snode.refs -= n - if snode.refs == 0 { - snode.wg.Wait() - c.node[id] = nil - delete(c.nodeRef, snode.node) - c.freeNode = append(c.freeNode, id) - return true - } - return false -} - -func (c *Server) dropHandle(id fuse.HandleID) { - c.meta.Lock() - c.handle[id] = nil - c.freeHandle = append(c.freeHandle, id) - c.meta.Unlock() -} - -type missingHandle struct { - Handle fuse.HandleID - MaxHandle fuse.HandleID -} - -func (m missingHandle) String() string { - return fmt.Sprint("missing handle: ", m.Handle, m.MaxHandle) -} - -// Returns nil for invalid handles. -func (c *Server) getHandle(id fuse.HandleID) (shandle *serveHandle) { - c.meta.Lock() - defer c.meta.Unlock() - if id < fuse.HandleID(len(c.handle)) { - shandle = c.handle[uint(id)] - } - if shandle == nil { - c.debug(missingHandle{ - Handle: id, - MaxHandle: fuse.HandleID(len(c.handle)), - }) - } - return -} - -type request struct { - Op string - Request *fuse.Header - In interface{} `json:",omitempty"` -} - -func (r request) String() string { - return fmt.Sprintf("<- %s", r.In) -} - -type logResponseHeader struct { - ID fuse.RequestID -} - -func (m logResponseHeader) String() string { - return fmt.Sprintf("ID=%v", m.ID) -} - -type response struct { - Op string - Request logResponseHeader - Out interface{} `json:",omitempty"` - // Errno contains the errno value as a string, for example "EPERM". - Errno string `json:",omitempty"` - // Error may contain a free form error message. - Error string `json:",omitempty"` -} - -func (r response) errstr() string { - s := r.Errno - if r.Error != "" { - // prefix the errno constant to the long form message - s = s + ": " + r.Error - } - return s -} - -func (r response) String() string { - switch { - case r.Errno != "" && r.Out != nil: - return fmt.Sprintf("-> [%v] %v error=%s", r.Request, r.Out, r.errstr()) - case r.Errno != "": - return fmt.Sprintf("-> [%v] %s error=%s", r.Request, r.Op, r.errstr()) - case r.Out != nil: - // make sure (seemingly) empty values are readable - switch r.Out.(type) { - case string: - return fmt.Sprintf("-> [%v] %s %q", r.Request, r.Op, r.Out) - case []byte: - return fmt.Sprintf("-> [%v] %s [% x]", r.Request, r.Op, r.Out) - default: - return fmt.Sprintf("-> [%v] %v", r.Request, r.Out) - } - default: - return fmt.Sprintf("-> [%v] %s", r.Request, r.Op) - } -} - -type notification struct { - Op string - Node fuse.NodeID - Out interface{} `json:",omitempty"` - Err string `json:",omitempty"` -} - -func (n notification) String() string { - var buf bytes.Buffer - fmt.Fprintf(&buf, "=> %s %v", n.Op, n.Node) - if n.Out != nil { - // make sure (seemingly) empty values are readable - switch n.Out.(type) { - case string: - fmt.Fprintf(&buf, " %q", n.Out) - case []byte: - fmt.Fprintf(&buf, " [% x]", n.Out) - default: - fmt.Fprintf(&buf, " %s", n.Out) - } - } - if n.Err != "" { - fmt.Fprintf(&buf, " Err:%v", n.Err) - } - return buf.String() -} - -type logMissingNode struct { - MaxNode fuse.NodeID -} - -func opName(req fuse.Request) string { - t := reflect.Indirect(reflect.ValueOf(req)).Type() - s := t.Name() - s = strings.TrimSuffix(s, "Request") - return s -} - -type logLinkRequestOldNodeNotFound struct { - Request *fuse.Header - In *fuse.LinkRequest -} - -func (m *logLinkRequestOldNodeNotFound) String() string { - return fmt.Sprintf("In LinkRequest (request %v), node %d not found", m.Request.Hdr().ID, m.In.OldNode) -} - -type renameNewDirNodeNotFound struct { - Request *fuse.Header - In *fuse.RenameRequest -} - -func (m *renameNewDirNodeNotFound) String() string { - return fmt.Sprintf("In RenameRequest (request %v), node %d not found", m.Request.Hdr().ID, m.In.NewDir) -} - -type handlerPanickedError struct { - Request interface{} - Err interface{} -} - -var _ error = handlerPanickedError{} - -func (h handlerPanickedError) Error() string { - return fmt.Sprintf("handler panicked: %v", h.Err) -} - -var _ fuse.ErrorNumber = handlerPanickedError{} - -func (h handlerPanickedError) Errno() fuse.Errno { - if err, ok := h.Err.(fuse.ErrorNumber); ok { - return err.Errno() - } - return fuse.DefaultErrno -} - -// handlerTerminatedError happens when a handler terminates itself -// with runtime.Goexit. This is most commonly because of incorrect use -// of testing.TB.FailNow, typically via t.Fatal. -type handlerTerminatedError struct { - Request interface{} -} - -var _ error = handlerTerminatedError{} - -func (h handlerTerminatedError) Error() string { - return fmt.Sprintf("handler terminated (called runtime.Goexit)") -} - -var _ fuse.ErrorNumber = handlerTerminatedError{} - -func (h handlerTerminatedError) Errno() fuse.Errno { - return fuse.DefaultErrno -} - -type handleNotReaderError struct { - handle Handle -} - -var _ error = handleNotReaderError{} - -func (e handleNotReaderError) Error() string { - return fmt.Sprintf("handle has no Read: %T", e.handle) -} - -var _ fuse.ErrorNumber = handleNotReaderError{} - -func (e handleNotReaderError) Errno() fuse.Errno { - return fuse.ENOTSUP -} - -func initLookupResponse(s *fuse.LookupResponse) { - s.EntryValid = entryValidTime -} - -func (c *Server) serve(r fuse.Request) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - parentCtx := ctx - if c.context != nil { - ctx = c.context(ctx, r) - } - - req := &serveRequest{Request: r, cancel: cancel} - - c.debug(request{ - Op: opName(r), - Request: r.Hdr(), - In: r, - }) - var node Node - var snode *serveNode - c.meta.Lock() - hdr := r.Hdr() - if id := hdr.Node; id != 0 { - if id < fuse.NodeID(len(c.node)) { - snode = c.node[uint(id)] - } - if snode == nil { - c.meta.Unlock() - c.debug(response{ - Op: opName(r), - Request: logResponseHeader{ID: hdr.ID}, - Error: fuse.ESTALE.ErrnoName(), - // this is the only place that sets both Error and - // Out; not sure if i want to do that; might get rid - // of len(c.node) things altogether - Out: logMissingNode{ - MaxNode: fuse.NodeID(len(c.node)), - }, - }) - r.RespondError(fuse.ESTALE) - return - } - node = snode.node - } - if c.req[hdr.ID] != nil { - // This happens with OSXFUSE. Assume it's okay and - // that we'll never see an interrupt for this one. - // Otherwise everything wedges. TODO: Report to OSXFUSE? - // - // TODO this might have been because of missing done() calls - } else { - c.req[hdr.ID] = req - } - c.meta.Unlock() - - // Call this before responding. - // After responding is too late: we might get another request - // with the same ID and be very confused. - done := func(resp interface{}) { - msg := response{ - Op: opName(r), - Request: logResponseHeader{ID: hdr.ID}, - } - if err, ok := resp.(error); ok { - msg.Error = err.Error() - if ferr, ok := err.(fuse.ErrorNumber); ok { - errno := ferr.Errno() - msg.Errno = errno.ErrnoName() - if errno == err { - // it's just a fuse.Errno with no extra detail; - // skip the textual message for log readability - msg.Error = "" - } - } else { - msg.Errno = fuse.DefaultErrno.ErrnoName() - } - } else { - msg.Out = resp - } - c.debug(msg) - - c.meta.Lock() - delete(c.req, hdr.ID) - c.meta.Unlock() - } - - var responded bool - defer func() { - if rec := recover(); rec != nil { - const size = 1 << 16 - buf := make([]byte, size) - n := runtime.Stack(buf, false) - buf = buf[:n] - log.Printf("fuse: panic in handler for %v: %v\n%s", r, rec, buf) - err := handlerPanickedError{ - Request: r, - Err: rec, - } - done(err) - r.RespondError(err) - return - } - - if !responded { - err := handlerTerminatedError{ - Request: r, - } - done(err) - r.RespondError(err) - } - }() - - if err := c.handleRequest(ctx, node, snode, r, done); err != nil { - if err == context.Canceled { - select { - case <-parentCtx.Done(): - // We canceled the parent context because of an - // incoming interrupt request, so return EINTR - // to trigger the right behavior in the client app. - // - // Only do this when it's the parent context that was - // canceled, not a context controlled by the program - // using this library, so we don't return EINTR too - // eagerly -- it might cause busy loops. - // - // Decent write-up on role of EINTR: - // http://250bpm.com/blog:12 - err = fuse.EINTR - default: - // nothing - } - } - done(err) - r.RespondError(err) - } - - // disarm runtime.Goexit protection - responded = true -} - -// handleRequest will either a) call done(s) and r.Respond(s) OR b) return an error. -func (c *Server) handleRequest(ctx context.Context, node Node, snode *serveNode, r fuse.Request, done func(resp interface{})) error { - switch r := r.(type) { - default: - // Note: To FUSE, ENOSYS means "this server never implements this request." - // It would be inappropriate to return ENOSYS for other operations in this - // switch that might only be unavailable in some contexts, not all. - return fuse.ENOSYS - - case *fuse.StatfsRequest: - s := &fuse.StatfsResponse{} - if fs, ok := c.fs.(FSStatfser); ok { - if err := fs.Statfs(ctx, r, s); err != nil { - return err - } - } - done(s) - r.Respond(s) - return nil - - // Node operations. - case *fuse.GetattrRequest: - s := &fuse.GetattrResponse{} - if n, ok := node.(NodeGetattrer); ok { - if err := n.Getattr(ctx, r, s); err != nil { - return err - } - } else { - if err := snode.attr(ctx, &s.Attr); err != nil { - return err - } - } - done(s) - r.Respond(s) - return nil - - case *fuse.SetattrRequest: - s := &fuse.SetattrResponse{} - if n, ok := node.(NodeSetattrer); ok { - if err := n.Setattr(ctx, r, s); err != nil { - return err - } - } - - if err := snode.attr(ctx, &s.Attr); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - - case *fuse.SymlinkRequest: - s := &fuse.SymlinkResponse{} - initLookupResponse(&s.LookupResponse) - n, ok := node.(NodeSymlinker) - if !ok { - return fuse.EIO // XXX or EPERM like Mkdir? - } - n2, err := n.Symlink(ctx, r) - if err != nil { - return err - } - if err := c.saveLookup(ctx, &s.LookupResponse, snode, r.NewName, n2); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - - case *fuse.ReadlinkRequest: - n, ok := node.(NodeReadlinker) - if !ok { - return fuse.EIO /// XXX or EPERM? - } - target, err := n.Readlink(ctx, r) - if err != nil { - return err - } - done(target) - r.Respond(target) - return nil - - case *fuse.LinkRequest: - n, ok := node.(NodeLinker) - if !ok { - return fuse.EIO /// XXX or EPERM? - } - c.meta.Lock() - var oldNode *serveNode - if int(r.OldNode) < len(c.node) { - oldNode = c.node[r.OldNode] - } - c.meta.Unlock() - if oldNode == nil { - c.debug(logLinkRequestOldNodeNotFound{ - Request: r.Hdr(), - In: r, - }) - return fuse.EIO - } - n2, err := n.Link(ctx, r, oldNode.node) - if err != nil { - return err - } - s := &fuse.LookupResponse{} - initLookupResponse(s) - if err := c.saveLookup(ctx, s, snode, r.NewName, n2); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - - case *fuse.RemoveRequest: - n, ok := node.(NodeRemover) - if !ok { - return fuse.EIO /// XXX or EPERM? - } - err := n.Remove(ctx, r) - if err != nil { - return err - } - done(nil) - r.Respond() - return nil - - case *fuse.AccessRequest: - if n, ok := node.(NodeAccesser); ok { - if err := n.Access(ctx, r); err != nil { - return err - } - } - done(nil) - r.Respond() - return nil - - case *fuse.LookupRequest: - var n2 Node - var err error - s := &fuse.LookupResponse{} - initLookupResponse(s) - if n, ok := node.(NodeStringLookuper); ok { - n2, err = n.Lookup(ctx, r.Name) - } else if n, ok := node.(NodeRequestLookuper); ok { - n2, err = n.Lookup(ctx, r, s) - } else { - return fuse.ENOENT - } - if err != nil { - return err - } - if err := c.saveLookup(ctx, s, snode, r.Name, n2); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - - case *fuse.MkdirRequest: - s := &fuse.MkdirResponse{} - initLookupResponse(&s.LookupResponse) - n, ok := node.(NodeMkdirer) - if !ok { - return fuse.EPERM - } - n2, err := n.Mkdir(ctx, r) - if err != nil { - return err - } - if err := c.saveLookup(ctx, &s.LookupResponse, snode, r.Name, n2); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - - case *fuse.OpenRequest: - s := &fuse.OpenResponse{} - var h2 Handle - if n, ok := node.(NodeOpener); ok { - hh, err := n.Open(ctx, r, s) - if err != nil { - return err - } - h2 = hh - } else { - h2 = node - } - s.Handle = c.saveHandle(h2, r.Hdr().Node) - done(s) - r.Respond(s) - return nil - - case *fuse.CreateRequest: - n, ok := node.(NodeCreater) - if !ok { - // If we send back ENOSYS, FUSE will try mknod+open. - return fuse.EPERM - } - s := &fuse.CreateResponse{OpenResponse: fuse.OpenResponse{}} - initLookupResponse(&s.LookupResponse) - n2, h2, err := n.Create(ctx, r, s) - if err != nil { - return err - } - if err := c.saveLookup(ctx, &s.LookupResponse, snode, r.Name, n2); err != nil { - return err - } - s.Handle = c.saveHandle(h2, r.Hdr().Node) - done(s) - r.Respond(s) - return nil - - case *fuse.GetxattrRequest: - n, ok := node.(NodeGetxattrer) - if !ok { - return fuse.ENOTSUP - } - s := &fuse.GetxattrResponse{} - err := n.Getxattr(ctx, r, s) - if err != nil { - return err - } - if r.Size != 0 && uint64(len(s.Xattr)) > uint64(r.Size) { - return fuse.ERANGE - } - done(s) - r.Respond(s) - return nil - - case *fuse.ListxattrRequest: - n, ok := node.(NodeListxattrer) - if !ok { - return fuse.ENOTSUP - } - s := &fuse.ListxattrResponse{} - err := n.Listxattr(ctx, r, s) - if err != nil { - return err - } - if r.Size != 0 && uint64(len(s.Xattr)) > uint64(r.Size) { - return fuse.ERANGE - } - done(s) - r.Respond(s) - return nil - - case *fuse.SetxattrRequest: - n, ok := node.(NodeSetxattrer) - if !ok { - return fuse.ENOTSUP - } - err := n.Setxattr(ctx, r) - if err != nil { - return err - } - done(nil) - r.Respond() - return nil - - case *fuse.RemovexattrRequest: - n, ok := node.(NodeRemovexattrer) - if !ok { - return fuse.ENOTSUP - } - err := n.Removexattr(ctx, r) - if err != nil { - return err - } - done(nil) - r.Respond() - return nil - - case *fuse.ForgetRequest: - forget := c.dropNode(r.Hdr().Node, r.N) - if forget { - n, ok := node.(NodeForgetter) - if ok { - n.Forget() - } - } - done(nil) - r.Respond() - return nil - - // Handle operations. - case *fuse.ReadRequest: - shandle := c.getHandle(r.Handle) - if shandle == nil { - return fuse.ESTALE - } - handle := shandle.handle - - s := &fuse.ReadResponse{Data: make([]byte, 0, r.Size)} - if r.Dir { - if h, ok := handle.(HandleReadDirAller); ok { - // detect rewinddir(3) or similar seek and refresh - // contents - if r.Offset == 0 { - shandle.readData = nil - } - - if shandle.readData == nil { - dirs, err := h.ReadDirAll(ctx) - if err != nil { - return err - } - var data []byte - for _, dir := range dirs { - if dir.Inode == 0 { - dir.Inode = c.dynamicInode(snode.inode, dir.Name) - } - data = fuse.AppendDirent(data, dir) - } - shandle.readData = data - } - fuseutil.HandleRead(r, s, shandle.readData) - done(s) - r.Respond(s) - return nil - } - } else { - if h, ok := handle.(HandleReadAller); ok { - if shandle.readData == nil { - data, err := h.ReadAll(ctx) - if err != nil { - return err - } - if data == nil { - data = []byte{} - } - shandle.readData = data - } - fuseutil.HandleRead(r, s, shandle.readData) - done(s) - r.Respond(s) - return nil - } - h, ok := handle.(HandleReader) - if !ok { - err := handleNotReaderError{handle: handle} - return err - } - if err := h.Read(ctx, r, s); err != nil { - return err - } - } - done(s) - r.Respond(s) - return nil - - case *fuse.WriteRequest: - shandle := c.getHandle(r.Handle) - if shandle == nil { - return fuse.ESTALE - } - - s := &fuse.WriteResponse{} - if h, ok := shandle.handle.(HandleWriter); ok { - if err := h.Write(ctx, r, s); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - } - return fuse.EIO - - case *fuse.FlushRequest: - shandle := c.getHandle(r.Handle) - if shandle == nil { - return fuse.ESTALE - } - handle := shandle.handle - - if h, ok := handle.(HandleFlusher); ok { - if err := h.Flush(ctx, r); err != nil { - return err - } - } - done(nil) - r.Respond() - return nil - - case *fuse.ReleaseRequest: - shandle := c.getHandle(r.Handle) - if shandle == nil { - return fuse.ESTALE - } - handle := shandle.handle - - // No matter what, release the handle. - c.dropHandle(r.Handle) - - if h, ok := handle.(HandleReleaser); ok { - if err := h.Release(ctx, r); err != nil { - return err - } - } - done(nil) - r.Respond() - return nil - - case *fuse.DestroyRequest: - if fs, ok := c.fs.(FSDestroyer); ok { - fs.Destroy() - } - done(nil) - r.Respond() - return nil - - case *fuse.RenameRequest: - c.meta.Lock() - var newDirNode *serveNode - if int(r.NewDir) < len(c.node) { - newDirNode = c.node[r.NewDir] - } - c.meta.Unlock() - if newDirNode == nil { - c.debug(renameNewDirNodeNotFound{ - Request: r.Hdr(), - In: r, - }) - return fuse.EIO - } - n, ok := node.(NodeRenamer) - if !ok { - return fuse.EIO // XXX or EPERM like Mkdir? - } - err := n.Rename(ctx, r, newDirNode.node) - if err != nil { - return err - } - done(nil) - r.Respond() - return nil - - case *fuse.MknodRequest: - n, ok := node.(NodeMknoder) - if !ok { - return fuse.EIO - } - n2, err := n.Mknod(ctx, r) - if err != nil { - return err - } - s := &fuse.LookupResponse{} - initLookupResponse(s) - if err := c.saveLookup(ctx, s, snode, r.Name, n2); err != nil { - return err - } - done(s) - r.Respond(s) - return nil - - case *fuse.FsyncRequest: - n, ok := node.(NodeFsyncer) - if !ok { - return fuse.EIO - } - err := n.Fsync(ctx, r) - if err != nil { - return err - } - done(nil) - r.Respond() - return nil - - case *fuse.InterruptRequest: - c.meta.Lock() - ireq := c.req[r.IntrID] - if ireq != nil && ireq.cancel != nil { - ireq.cancel() - ireq.cancel = nil - } - c.meta.Unlock() - done(nil) - r.Respond() - return nil - - /* case *FsyncdirRequest: - return ENOSYS - - case *GetlkRequest, *SetlkRequest, *SetlkwRequest: - return ENOSYS - - case *BmapRequest: - return ENOSYS - - case *SetvolnameRequest, *GetxtimesRequest, *ExchangeRequest: - return ENOSYS - */ - } - - panic("not reached") -} - -func (c *Server) saveLookup(ctx context.Context, s *fuse.LookupResponse, snode *serveNode, elem string, n2 Node) error { - if err := nodeAttr(ctx, n2, &s.Attr); err != nil { - return err - } - if s.Attr.Inode == 0 { - s.Attr.Inode = c.dynamicInode(snode.inode, elem) - } - - s.Node, s.Generation = c.saveNode(s.Attr.Inode, n2) - return nil -} - -type invalidateNodeDetail struct { - Off int64 - Size int64 -} - -func (i invalidateNodeDetail) String() string { - return fmt.Sprintf("Off:%d Size:%d", i.Off, i.Size) -} - -func errstr(err error) string { - if err == nil { - return "" - } - return err.Error() -} - -func (s *Server) invalidateNode(node Node, off int64, size int64) error { - s.meta.Lock() - id, ok := s.nodeRef[node] - if ok { - snode := s.node[id] - snode.wg.Add(1) - defer snode.wg.Done() - } - s.meta.Unlock() - if !ok { - // This is what the kernel would have said, if we had been - // able to send this message; it's not cached. - return fuse.ErrNotCached - } - // Delay logging until after we can record the error too. We - // consider a /dev/fuse write to be instantaneous enough to not - // need separate before and after messages. - err := s.conn.InvalidateNode(id, off, size) - s.debug(notification{ - Op: "InvalidateNode", - Node: id, - Out: invalidateNodeDetail{ - Off: off, - Size: size, - }, - Err: errstr(err), - }) - return err -} - -// InvalidateNodeAttr invalidates the kernel cache of the attributes -// of node. -// -// Returns fuse.ErrNotCached if the kernel is not currently caching -// the node. -func (s *Server) InvalidateNodeAttr(node Node) error { - return s.invalidateNode(node, 0, 0) -} - -// InvalidateNodeData invalidates the kernel cache of the attributes -// and data of node. -// -// Returns fuse.ErrNotCached if the kernel is not currently caching -// the node. -func (s *Server) InvalidateNodeData(node Node) error { - return s.invalidateNode(node, 0, -1) -} - -// InvalidateNodeDataRange invalidates the kernel cache of the -// attributes and a range of the data of node. -// -// Returns fuse.ErrNotCached if the kernel is not currently caching -// the node. -func (s *Server) InvalidateNodeDataRange(node Node, off int64, size int64) error { - return s.invalidateNode(node, off, size) -} - -type invalidateEntryDetail struct { - Name string -} - -func (i invalidateEntryDetail) String() string { - return fmt.Sprintf("%q", i.Name) -} - -// InvalidateEntry invalidates the kernel cache of the directory entry -// identified by parent node and entry basename. -// -// Kernel may or may not cache directory listings. To invalidate -// those, use InvalidateNode to invalidate all of the data for a -// directory. (As of 2015-06, Linux FUSE does not cache directory -// listings.) -// -// Returns ErrNotCached if the kernel is not currently caching the -// node. -func (s *Server) InvalidateEntry(parent Node, name string) error { - s.meta.Lock() - id, ok := s.nodeRef[parent] - if ok { - snode := s.node[id] - snode.wg.Add(1) - defer snode.wg.Done() - } - s.meta.Unlock() - if !ok { - // This is what the kernel would have said, if we had been - // able to send this message; it's not cached. - return fuse.ErrNotCached - } - err := s.conn.InvalidateEntry(id, name) - s.debug(notification{ - Op: "InvalidateEntry", - Node: id, - Out: invalidateEntryDetail{ - Name: name, - }, - Err: errstr(err), - }) - return err -} - -// DataHandle returns a read-only Handle that satisfies reads -// using the given data. -func DataHandle(data []byte) Handle { - return &dataHandle{data} -} - -type dataHandle struct { - data []byte -} - -func (d *dataHandle) ReadAll(ctx context.Context) ([]byte, error) { - return d.data, nil -} - -// GenerateDynamicInode returns a dynamic inode. -// -// The parent inode and current entry name are used as the criteria -// for choosing a pseudorandom inode. This makes it likely the same -// entry will get the same inode on multiple runs. -func GenerateDynamicInode(parent uint64, name string) uint64 { - h := fnv.New64a() - var buf [8]byte - binary.LittleEndian.PutUint64(buf[:], parent) - _, _ = h.Write(buf[:]) - _, _ = h.Write([]byte(name)) - var inode uint64 - for { - inode = h.Sum64() - if inode != 0 { - break - } - // there's a tiny probability that result is zero; change the - // input a little and try again - _, _ = h.Write([]byte{'x'}) - } - return inode -} diff --git a/vendor/bazil.org/fuse/fs/tree.go b/vendor/bazil.org/fuse/fs/tree.go deleted file mode 100644 index 7e078045..00000000 --- a/vendor/bazil.org/fuse/fs/tree.go +++ /dev/null @@ -1,99 +0,0 @@ -// FUSE directory tree, for servers that wish to use it with the service loop. - -package fs - -import ( - "os" - pathpkg "path" - "strings" - - "golang.org/x/net/context" -) - -import ( - "bazil.org/fuse" -) - -// A Tree implements a basic read-only directory tree for FUSE. -// The Nodes contained in it may still be writable. -type Tree struct { - tree -} - -func (t *Tree) Root() (Node, error) { - return &t.tree, nil -} - -// Add adds the path to the tree, resolving to the given node. -// If path or a prefix of path has already been added to the tree, -// Add panics. -// -// Add is only safe to call before starting to serve requests. -func (t *Tree) Add(path string, node Node) { - path = pathpkg.Clean("/" + path)[1:] - elems := strings.Split(path, "/") - dir := Node(&t.tree) - for i, elem := range elems { - dt, ok := dir.(*tree) - if !ok { - panic("fuse: Tree.Add for " + strings.Join(elems[:i], "/") + " and " + path) - } - n := dt.lookup(elem) - if n != nil { - if i+1 == len(elems) { - panic("fuse: Tree.Add for " + path + " conflicts with " + elem) - } - dir = n - } else { - if i+1 == len(elems) { - dt.add(elem, node) - } else { - dir = &tree{} - dt.add(elem, dir) - } - } - } -} - -type treeDir struct { - name string - node Node -} - -type tree struct { - dir []treeDir -} - -func (t *tree) lookup(name string) Node { - for _, d := range t.dir { - if d.name == name { - return d.node - } - } - return nil -} - -func (t *tree) add(name string, n Node) { - t.dir = append(t.dir, treeDir{name, n}) -} - -func (t *tree) Attr(ctx context.Context, a *fuse.Attr) error { - a.Mode = os.ModeDir | 0555 - return nil -} - -func (t *tree) Lookup(ctx context.Context, name string) (Node, error) { - n := t.lookup(name) - if n != nil { - return n, nil - } - return nil, fuse.ENOENT -} - -func (t *tree) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { - var out []fuse.Dirent - for _, d := range t.dir { - out = append(out, fuse.Dirent{Name: d.name}) - } - return out, nil -} diff --git a/vendor/bazil.org/fuse/fuse.go b/vendor/bazil.org/fuse/fuse.go deleted file mode 100644 index 6db0ef29..00000000 --- a/vendor/bazil.org/fuse/fuse.go +++ /dev/null @@ -1,2303 +0,0 @@ -// See the file LICENSE for copyright and licensing information. - -// 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. - -// Package fuse enables writing FUSE file systems on Linux, OS X, and FreeBSD. -// -// On OS X, it requires OSXFUSE (http://osxfuse.github.com/). -// -// There are two approaches to writing a FUSE file system. The first is to speak -// the low-level message protocol, reading from a Conn using ReadRequest and -// writing using the various Respond methods. This approach is closest to -// the actual interaction with the kernel and can be the simplest one in contexts -// such as protocol translators. -// -// Servers of synthesized file systems tend to share common -// bookkeeping abstracted away by the second approach, which is to -// call fs.Serve to serve the FUSE protocol using an implementation of -// the service methods in the interfaces FS* (file system), Node* (file -// or directory), and Handle* (opened file or directory). -// There are a daunting number of such methods that can be written, -// but few are required. -// The specific methods are described in the documentation for those interfaces. -// -// The hellofs subdirectory contains a simple illustration of the fs.Serve approach. -// -// Service Methods -// -// The required and optional methods for the FS, Node, and Handle interfaces -// have the general form -// -// Op(ctx context.Context, req *OpRequest, resp *OpResponse) error -// -// where Op is the name of a FUSE operation. Op reads request -// parameters from req and writes results to resp. An operation whose -// only result is the error result omits the resp parameter. -// -// Multiple goroutines may call service methods simultaneously; the -// methods being called are responsible for appropriate -// synchronization. -// -// The operation must not hold on to the request or response, -// including any []byte fields such as WriteRequest.Data or -// SetxattrRequest.Xattr. -// -// Errors -// -// Operations can return errors. The FUSE interface can only -// communicate POSIX errno error numbers to file system clients, the -// message is not visible to file system clients. The returned error -// can implement ErrorNumber to control the errno returned. Without -// ErrorNumber, a generic errno (EIO) is returned. -// -// Error messages will be visible in the debug log as part of the -// response. -// -// Interrupted Operations -// -// In some file systems, some operations -// may take an undetermined amount of time. For example, a Read waiting for -// a network message or a matching Write might wait indefinitely. If the request -// is cancelled and no longer needed, the context will be cancelled. -// Blocking operations should select on a receive from ctx.Done() and attempt to -// abort the operation early if the receive succeeds (meaning the channel is closed). -// To indicate that the operation failed because it was aborted, return fuse.EINTR. -// -// If an operation does not block for an indefinite amount of time, supporting -// cancellation is not necessary. -// -// Authentication -// -// All requests types embed a Header, meaning that the method can -// inspect req.Pid, req.Uid, and req.Gid as necessary to implement -// permission checking. The kernel FUSE layer normally prevents other -// users from accessing the FUSE file system (to change this, see -// AllowOther, AllowRoot), but does not enforce access modes (to -// change this, see DefaultPermissions). -// -// Mount Options -// -// Behavior and metadata of the mounted file system can be changed by -// passing MountOption values to Mount. -// -package fuse // import "bazil.org/fuse" - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "io" - "os" - "sync" - "syscall" - "time" - "unsafe" -) - -// A Conn represents a connection to a mounted FUSE file system. -type Conn struct { - // Ready is closed when the mount is complete or has failed. - Ready <-chan struct{} - - // MountError stores any error from the mount process. Only valid - // after Ready is closed. - MountError error - - // File handle for kernel communication. Only safe to access if - // rio or wio is held. - dev *os.File - wio sync.RWMutex - rio sync.RWMutex - - // Protocol version negotiated with InitRequest/InitResponse. - proto Protocol -} - -// MountpointDoesNotExistError is an error returned when the -// mountpoint does not exist. -type MountpointDoesNotExistError struct { - Path string -} - -var _ error = (*MountpointDoesNotExistError)(nil) - -func (e *MountpointDoesNotExistError) Error() string { - return fmt.Sprintf("mountpoint does not exist: %v", e.Path) -} - -// Mount mounts a new FUSE connection on the named directory -// and returns a connection for reading and writing FUSE messages. -// -// After a successful return, caller must call Close to free -// resources. -// -// Even on successful return, the new mount is not guaranteed to be -// visible until after Conn.Ready is closed. See Conn.MountError for -// possible errors. Incoming requests on Conn must be served to make -// progress. -func Mount(dir string, options ...MountOption) (*Conn, error) { - conf := mountConfig{ - options: make(map[string]string), - } - for _, option := range options { - if err := option(&conf); err != nil { - return nil, err - } - } - - ready := make(chan struct{}, 1) - c := &Conn{ - Ready: ready, - } - f, err := mount(dir, &conf, ready, &c.MountError) - if err != nil { - return nil, err - } - c.dev = f - - if err := initMount(c, &conf); err != nil { - c.Close() - if err == ErrClosedWithoutInit { - // see if we can provide a better error - <-c.Ready - if err := c.MountError; err != nil { - return nil, err - } - } - return nil, err - } - - return c, nil -} - -type OldVersionError struct { - Kernel Protocol - LibraryMin Protocol -} - -func (e *OldVersionError) Error() string { - return fmt.Sprintf("kernel FUSE version is too old: %v < %v", e.Kernel, e.LibraryMin) -} - -var ( - ErrClosedWithoutInit = errors.New("fuse connection closed without init") -) - -func initMount(c *Conn, conf *mountConfig) error { - req, err := c.ReadRequest() - if err != nil { - if err == io.EOF { - return ErrClosedWithoutInit - } - return err - } - r, ok := req.(*InitRequest) - if !ok { - return fmt.Errorf("missing init, got: %T", req) - } - - min := Protocol{protoVersionMinMajor, protoVersionMinMinor} - if r.Kernel.LT(min) { - req.RespondError(Errno(syscall.EPROTO)) - c.Close() - return &OldVersionError{ - Kernel: r.Kernel, - LibraryMin: min, - } - } - - proto := Protocol{protoVersionMaxMajor, protoVersionMaxMinor} - if r.Kernel.LT(proto) { - // Kernel doesn't support the latest version we have. - proto = r.Kernel - } - c.proto = proto - - s := &InitResponse{ - Library: proto, - MaxReadahead: conf.maxReadahead, - MaxWrite: maxWrite, - Flags: InitBigWrites | conf.initFlags, - } - r.Respond(s) - return nil -} - -// A Request represents a single FUSE request received from the kernel. -// Use a type switch to determine the specific kind. -// A request of unrecognized type will have concrete type *Header. -type Request interface { - // Hdr returns the Header associated with this request. - Hdr() *Header - - // RespondError responds to the request with the given error. - RespondError(error) - - String() string -} - -// A RequestID identifies an active FUSE request. -type RequestID uint64 - -func (r RequestID) String() string { - return fmt.Sprintf("%#x", uint64(r)) -} - -// A NodeID is a number identifying a directory or file. -// It must be unique among IDs returned in LookupResponses -// that have not yet been forgotten by ForgetRequests. -type NodeID uint64 - -func (n NodeID) String() string { - return fmt.Sprintf("%#x", uint64(n)) -} - -// A HandleID is a number identifying an open directory or file. -// It only needs to be unique while the directory or file is open. -type HandleID uint64 - -func (h HandleID) String() string { - return fmt.Sprintf("%#x", uint64(h)) -} - -// The RootID identifies the root directory of a FUSE file system. -const RootID NodeID = rootID - -// A Header describes the basic information sent in every request. -type Header struct { - Conn *Conn `json:"-"` // connection this request was received on - ID RequestID // unique ID for request - Node NodeID // file or directory the request is about - Uid uint32 // user ID of process making request - Gid uint32 // group ID of process making request - Pid uint32 // process ID of process making request - - // for returning to reqPool - msg *message -} - -func (h *Header) String() string { - return fmt.Sprintf("ID=%v Node=%v Uid=%d Gid=%d Pid=%d", h.ID, h.Node, h.Uid, h.Gid, h.Pid) -} - -func (h *Header) Hdr() *Header { - return h -} - -func (h *Header) noResponse() { - putMessage(h.msg) -} - -func (h *Header) respond(msg []byte) { - out := (*outHeader)(unsafe.Pointer(&msg[0])) - out.Unique = uint64(h.ID) - h.Conn.respond(msg) - putMessage(h.msg) -} - -// An ErrorNumber is an error with a specific error number. -// -// Operations may return an error value that implements ErrorNumber to -// control what specific error number (errno) to return. -type ErrorNumber interface { - // Errno returns the the error number (errno) for this error. - Errno() Errno -} - -const ( - // ENOSYS indicates that the call is not supported. - ENOSYS = Errno(syscall.ENOSYS) - - // ESTALE is used by Serve to respond to violations of the FUSE protocol. - ESTALE = Errno(syscall.ESTALE) - - ENOENT = Errno(syscall.ENOENT) - EIO = Errno(syscall.EIO) - EPERM = Errno(syscall.EPERM) - - // EINTR indicates request was interrupted by an InterruptRequest. - // See also fs.Intr. - EINTR = Errno(syscall.EINTR) - - ERANGE = Errno(syscall.ERANGE) - ENOTSUP = Errno(syscall.ENOTSUP) - EEXIST = Errno(syscall.EEXIST) -) - -// DefaultErrno is the errno used when error returned does not -// implement ErrorNumber. -const DefaultErrno = EIO - -var errnoNames = map[Errno]string{ - ENOSYS: "ENOSYS", - ESTALE: "ESTALE", - ENOENT: "ENOENT", - EIO: "EIO", - EPERM: "EPERM", - EINTR: "EINTR", - EEXIST: "EEXIST", -} - -// Errno implements Error and ErrorNumber using a syscall.Errno. -type Errno syscall.Errno - -var _ = ErrorNumber(Errno(0)) -var _ = error(Errno(0)) - -func (e Errno) Errno() Errno { - return e -} - -func (e Errno) String() string { - return syscall.Errno(e).Error() -} - -func (e Errno) Error() string { - return syscall.Errno(e).Error() -} - -// ErrnoName returns the short non-numeric identifier for this errno. -// For example, "EIO". -func (e Errno) ErrnoName() string { - s := errnoNames[e] - if s == "" { - s = fmt.Sprint(e.Errno()) - } - return s -} - -func (e Errno) MarshalText() ([]byte, error) { - s := e.ErrnoName() - return []byte(s), nil -} - -func (h *Header) RespondError(err error) { - errno := DefaultErrno - if ferr, ok := err.(ErrorNumber); ok { - errno = ferr.Errno() - } - // FUSE uses negative errors! - // TODO: File bug report against OSXFUSE: positive error causes kernel panic. - buf := newBuffer(0) - hOut := (*outHeader)(unsafe.Pointer(&buf[0])) - hOut.Error = -int32(errno) - h.respond(buf) -} - -// All requests read from the kernel, without data, are shorter than -// this. -var maxRequestSize = syscall.Getpagesize() -var bufSize = maxRequestSize + maxWrite - -// reqPool is a pool of messages. -// -// Lifetime of a logical message is from getMessage to putMessage. -// getMessage is called by ReadRequest. putMessage is called by -// Conn.ReadRequest, Request.Respond, or Request.RespondError. -// -// Messages in the pool are guaranteed to have conn and off zeroed, -// buf allocated and len==bufSize, and hdr set. -var reqPool = sync.Pool{ - New: allocMessage, -} - -func allocMessage() interface{} { - m := &message{buf: make([]byte, bufSize)} - m.hdr = (*inHeader)(unsafe.Pointer(&m.buf[0])) - return m -} - -func getMessage(c *Conn) *message { - m := reqPool.Get().(*message) - m.conn = c - return m -} - -func putMessage(m *message) { - m.buf = m.buf[:bufSize] - m.conn = nil - m.off = 0 - reqPool.Put(m) -} - -// a message represents the bytes of a single FUSE message -type message struct { - conn *Conn - buf []byte // all bytes - hdr *inHeader // header - off int // offset for reading additional fields -} - -func (m *message) len() uintptr { - return uintptr(len(m.buf) - m.off) -} - -func (m *message) data() unsafe.Pointer { - var p unsafe.Pointer - if m.off < len(m.buf) { - p = unsafe.Pointer(&m.buf[m.off]) - } - return p -} - -func (m *message) bytes() []byte { - return m.buf[m.off:] -} - -func (m *message) Header() Header { - h := m.hdr - return Header{ - Conn: m.conn, - ID: RequestID(h.Unique), - Node: NodeID(h.Nodeid), - Uid: h.Uid, - Gid: h.Gid, - Pid: h.Pid, - - msg: m, - } -} - -// fileMode returns a Go os.FileMode from a Unix mode. -func fileMode(unixMode uint32) os.FileMode { - mode := os.FileMode(unixMode & 0777) - switch unixMode & syscall.S_IFMT { - case syscall.S_IFREG: - // nothing - case syscall.S_IFDIR: - mode |= os.ModeDir - case syscall.S_IFCHR: - mode |= os.ModeCharDevice | os.ModeDevice - case syscall.S_IFBLK: - mode |= os.ModeDevice - case syscall.S_IFIFO: - mode |= os.ModeNamedPipe - case syscall.S_IFLNK: - mode |= os.ModeSymlink - case syscall.S_IFSOCK: - mode |= os.ModeSocket - default: - // no idea - mode |= os.ModeDevice - } - if unixMode&syscall.S_ISUID != 0 { - mode |= os.ModeSetuid - } - if unixMode&syscall.S_ISGID != 0 { - mode |= os.ModeSetgid - } - return mode -} - -type noOpcode struct { - Opcode uint32 -} - -func (m noOpcode) String() string { - return fmt.Sprintf("No opcode %v", m.Opcode) -} - -type malformedMessage struct { -} - -func (malformedMessage) String() string { - return "malformed message" -} - -// Close closes the FUSE connection. -func (c *Conn) Close() error { - c.wio.Lock() - defer c.wio.Unlock() - c.rio.Lock() - defer c.rio.Unlock() - return c.dev.Close() -} - -// caller must hold wio or rio -func (c *Conn) fd() int { - return int(c.dev.Fd()) -} - -func (c *Conn) Protocol() Protocol { - return c.proto -} - -// ReadRequest returns the next FUSE request from the kernel. -// -// Caller must call either Request.Respond or Request.RespondError in -// a reasonable time. Caller must not retain Request after that call. -func (c *Conn) ReadRequest() (Request, error) { - m := getMessage(c) -loop: - c.rio.RLock() - n, err := syscall.Read(c.fd(), m.buf) - c.rio.RUnlock() - if err == syscall.EINTR { - // OSXFUSE sends EINTR to userspace when a request interrupt - // completed before it got sent to userspace? - goto loop - } - if err != nil && err != syscall.ENODEV { - putMessage(m) - return nil, err - } - if n <= 0 { - putMessage(m) - return nil, io.EOF - } - m.buf = m.buf[:n] - - if n < inHeaderSize { - putMessage(m) - return nil, errors.New("fuse: message too short") - } - - // FreeBSD FUSE sends a short length in the header - // for FUSE_INIT even though the actual read length is correct. - if n == inHeaderSize+initInSize && m.hdr.Opcode == opInit && m.hdr.Len < uint32(n) { - m.hdr.Len = uint32(n) - } - - // OSXFUSE sometimes sends the wrong m.hdr.Len in a FUSE_WRITE message. - if m.hdr.Len < uint32(n) && m.hdr.Len >= uint32(unsafe.Sizeof(writeIn{})) && m.hdr.Opcode == opWrite { - m.hdr.Len = uint32(n) - } - - if m.hdr.Len != uint32(n) { - // prepare error message before returning m to pool - err := fmt.Errorf("fuse: read %d opcode %d but expected %d", n, m.hdr.Opcode, m.hdr.Len) - putMessage(m) - return nil, err - } - - m.off = inHeaderSize - - // Convert to data structures. - // Do not trust kernel to hand us well-formed data. - var req Request - switch m.hdr.Opcode { - default: - Debug(noOpcode{Opcode: m.hdr.Opcode}) - goto unrecognized - - case opLookup: - buf := m.bytes() - n := len(buf) - if n == 0 || buf[n-1] != '\x00' { - goto corrupt - } - req = &LookupRequest{ - Header: m.Header(), - Name: string(buf[:n-1]), - } - - case opForget: - in := (*forgetIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &ForgetRequest{ - Header: m.Header(), - N: in.Nlookup, - } - - case opGetattr: - switch { - case c.proto.LT(Protocol{7, 9}): - req = &GetattrRequest{ - Header: m.Header(), - } - - default: - in := (*getattrIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &GetattrRequest{ - Header: m.Header(), - Flags: GetattrFlags(in.GetattrFlags), - Handle: HandleID(in.Fh), - } - } - - case opSetattr: - in := (*setattrIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &SetattrRequest{ - Header: m.Header(), - Valid: SetattrValid(in.Valid), - Handle: HandleID(in.Fh), - Size: in.Size, - Atime: time.Unix(int64(in.Atime), int64(in.AtimeNsec)), - Mtime: time.Unix(int64(in.Mtime), int64(in.MtimeNsec)), - Mode: fileMode(in.Mode), - Uid: in.Uid, - Gid: in.Gid, - Bkuptime: in.BkupTime(), - Chgtime: in.Chgtime(), - Flags: in.Flags(), - } - - case opReadlink: - if len(m.bytes()) > 0 { - goto corrupt - } - req = &ReadlinkRequest{ - Header: m.Header(), - } - - case opSymlink: - // m.bytes() is "newName\0target\0" - names := m.bytes() - if len(names) == 0 || names[len(names)-1] != 0 { - goto corrupt - } - i := bytes.IndexByte(names, '\x00') - if i < 0 { - goto corrupt - } - newName, target := names[0:i], names[i+1:len(names)-1] - req = &SymlinkRequest{ - Header: m.Header(), - NewName: string(newName), - Target: string(target), - } - - case opLink: - in := (*linkIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - newName := m.bytes()[unsafe.Sizeof(*in):] - if len(newName) < 2 || newName[len(newName)-1] != 0 { - goto corrupt - } - newName = newName[:len(newName)-1] - req = &LinkRequest{ - Header: m.Header(), - OldNode: NodeID(in.Oldnodeid), - NewName: string(newName), - } - - case opMknod: - size := mknodInSize(c.proto) - if m.len() < size { - goto corrupt - } - in := (*mknodIn)(m.data()) - name := m.bytes()[size:] - if len(name) < 2 || name[len(name)-1] != '\x00' { - goto corrupt - } - name = name[:len(name)-1] - r := &MknodRequest{ - Header: m.Header(), - Mode: fileMode(in.Mode), - Rdev: in.Rdev, - Name: string(name), - } - if c.proto.GE(Protocol{7, 12}) { - r.Umask = fileMode(in.Umask) & os.ModePerm - } - req = r - - case opMkdir: - size := mkdirInSize(c.proto) - if m.len() < size { - goto corrupt - } - in := (*mkdirIn)(m.data()) - name := m.bytes()[size:] - i := bytes.IndexByte(name, '\x00') - if i < 0 { - goto corrupt - } - r := &MkdirRequest{ - Header: m.Header(), - Name: string(name[:i]), - // observed on Linux: mkdirIn.Mode & syscall.S_IFMT == 0, - // and this causes fileMode to go into it's "no idea" - // code branch; enforce type to directory - Mode: fileMode((in.Mode &^ syscall.S_IFMT) | syscall.S_IFDIR), - } - if c.proto.GE(Protocol{7, 12}) { - r.Umask = fileMode(in.Umask) & os.ModePerm - } - req = r - - case opUnlink, opRmdir: - buf := m.bytes() - n := len(buf) - if n == 0 || buf[n-1] != '\x00' { - goto corrupt - } - req = &RemoveRequest{ - Header: m.Header(), - Name: string(buf[:n-1]), - Dir: m.hdr.Opcode == opRmdir, - } - - case opRename: - in := (*renameIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - newDirNodeID := NodeID(in.Newdir) - oldNew := m.bytes()[unsafe.Sizeof(*in):] - // oldNew should be "old\x00new\x00" - if len(oldNew) < 4 { - goto corrupt - } - if oldNew[len(oldNew)-1] != '\x00' { - goto corrupt - } - i := bytes.IndexByte(oldNew, '\x00') - if i < 0 { - goto corrupt - } - oldName, newName := string(oldNew[:i]), string(oldNew[i+1:len(oldNew)-1]) - req = &RenameRequest{ - Header: m.Header(), - NewDir: newDirNodeID, - OldName: oldName, - NewName: newName, - } - - case opOpendir, opOpen: - in := (*openIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &OpenRequest{ - Header: m.Header(), - Dir: m.hdr.Opcode == opOpendir, - Flags: openFlags(in.Flags), - } - - case opRead, opReaddir: - in := (*readIn)(m.data()) - if m.len() < readInSize(c.proto) { - goto corrupt - } - r := &ReadRequest{ - Header: m.Header(), - Dir: m.hdr.Opcode == opReaddir, - Handle: HandleID(in.Fh), - Offset: int64(in.Offset), - Size: int(in.Size), - } - if c.proto.GE(Protocol{7, 9}) { - r.Flags = ReadFlags(in.ReadFlags) - r.LockOwner = in.LockOwner - r.FileFlags = openFlags(in.Flags) - } - req = r - - case opWrite: - in := (*writeIn)(m.data()) - if m.len() < writeInSize(c.proto) { - goto corrupt - } - r := &WriteRequest{ - Header: m.Header(), - Handle: HandleID(in.Fh), - Offset: int64(in.Offset), - Flags: WriteFlags(in.WriteFlags), - } - if c.proto.GE(Protocol{7, 9}) { - r.LockOwner = in.LockOwner - r.FileFlags = openFlags(in.Flags) - } - buf := m.bytes()[writeInSize(c.proto):] - if uint32(len(buf)) < in.Size { - goto corrupt - } - r.Data = buf - req = r - - case opStatfs: - req = &StatfsRequest{ - Header: m.Header(), - } - - case opRelease, opReleasedir: - in := (*releaseIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &ReleaseRequest{ - Header: m.Header(), - Dir: m.hdr.Opcode == opReleasedir, - Handle: HandleID(in.Fh), - Flags: openFlags(in.Flags), - ReleaseFlags: ReleaseFlags(in.ReleaseFlags), - LockOwner: in.LockOwner, - } - - case opFsync, opFsyncdir: - in := (*fsyncIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &FsyncRequest{ - Dir: m.hdr.Opcode == opFsyncdir, - Header: m.Header(), - Handle: HandleID(in.Fh), - Flags: in.FsyncFlags, - } - - case opSetxattr: - in := (*setxattrIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - m.off += int(unsafe.Sizeof(*in)) - name := m.bytes() - i := bytes.IndexByte(name, '\x00') - if i < 0 { - goto corrupt - } - xattr := name[i+1:] - if uint32(len(xattr)) < in.Size { - goto corrupt - } - xattr = xattr[:in.Size] - req = &SetxattrRequest{ - Header: m.Header(), - Flags: in.Flags, - Position: in.position(), - Name: string(name[:i]), - Xattr: xattr, - } - - case opGetxattr: - in := (*getxattrIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - name := m.bytes()[unsafe.Sizeof(*in):] - i := bytes.IndexByte(name, '\x00') - if i < 0 { - goto corrupt - } - req = &GetxattrRequest{ - Header: m.Header(), - Name: string(name[:i]), - Size: in.Size, - Position: in.position(), - } - - case opListxattr: - in := (*getxattrIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &ListxattrRequest{ - Header: m.Header(), - Size: in.Size, - Position: in.position(), - } - - case opRemovexattr: - buf := m.bytes() - n := len(buf) - if n == 0 || buf[n-1] != '\x00' { - goto corrupt - } - req = &RemovexattrRequest{ - Header: m.Header(), - Name: string(buf[:n-1]), - } - - case opFlush: - in := (*flushIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &FlushRequest{ - Header: m.Header(), - Handle: HandleID(in.Fh), - Flags: in.FlushFlags, - LockOwner: in.LockOwner, - } - - case opInit: - in := (*initIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &InitRequest{ - Header: m.Header(), - Kernel: Protocol{in.Major, in.Minor}, - MaxReadahead: in.MaxReadahead, - Flags: InitFlags(in.Flags), - } - - case opGetlk: - panic("opGetlk") - case opSetlk: - panic("opSetlk") - case opSetlkw: - panic("opSetlkw") - - case opAccess: - in := (*accessIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &AccessRequest{ - Header: m.Header(), - Mask: in.Mask, - } - - case opCreate: - size := createInSize(c.proto) - if m.len() < size { - goto corrupt - } - in := (*createIn)(m.data()) - name := m.bytes()[size:] - i := bytes.IndexByte(name, '\x00') - if i < 0 { - goto corrupt - } - r := &CreateRequest{ - Header: m.Header(), - Flags: openFlags(in.Flags), - Mode: fileMode(in.Mode), - Name: string(name[:i]), - } - if c.proto.GE(Protocol{7, 12}) { - r.Umask = fileMode(in.Umask) & os.ModePerm - } - req = r - - case opInterrupt: - in := (*interruptIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - req = &InterruptRequest{ - Header: m.Header(), - IntrID: RequestID(in.Unique), - } - - case opBmap: - panic("opBmap") - - case opDestroy: - req = &DestroyRequest{ - Header: m.Header(), - } - - // OS X - case opSetvolname: - panic("opSetvolname") - case opGetxtimes: - panic("opGetxtimes") - case opExchange: - in := (*exchangeIn)(m.data()) - if m.len() < unsafe.Sizeof(*in) { - goto corrupt - } - oldDirNodeID := NodeID(in.Olddir) - newDirNodeID := NodeID(in.Newdir) - oldNew := m.bytes()[unsafe.Sizeof(*in):] - // oldNew should be "oldname\x00newname\x00" - if len(oldNew) < 4 { - goto corrupt - } - if oldNew[len(oldNew)-1] != '\x00' { - goto corrupt - } - i := bytes.IndexByte(oldNew, '\x00') - if i < 0 { - goto corrupt - } - oldName, newName := string(oldNew[:i]), string(oldNew[i+1:len(oldNew)-1]) - req = &ExchangeDataRequest{ - Header: m.Header(), - OldDir: oldDirNodeID, - NewDir: newDirNodeID, - OldName: oldName, - NewName: newName, - // TODO options - } - } - - return req, nil - -corrupt: - Debug(malformedMessage{}) - putMessage(m) - return nil, fmt.Errorf("fuse: malformed message") - -unrecognized: - // Unrecognized message. - // Assume higher-level code will send a "no idea what you mean" error. - h := m.Header() - return &h, nil -} - -type bugShortKernelWrite struct { - Written int64 - Length int64 - Error string - Stack string -} - -func (b bugShortKernelWrite) String() string { - return fmt.Sprintf("short kernel write: written=%d/%d error=%q stack=\n%s", b.Written, b.Length, b.Error, b.Stack) -} - -type bugKernelWriteError struct { - Error string - Stack string -} - -func (b bugKernelWriteError) String() string { - return fmt.Sprintf("kernel write error: error=%q stack=\n%s", b.Error, b.Stack) -} - -// safe to call even with nil error -func errorString(err error) string { - if err == nil { - return "" - } - return err.Error() -} - -func (c *Conn) writeToKernel(msg []byte) error { - out := (*outHeader)(unsafe.Pointer(&msg[0])) - out.Len = uint32(len(msg)) - - c.wio.RLock() - defer c.wio.RUnlock() - nn, err := syscall.Write(c.fd(), msg) - if err == nil && nn != len(msg) { - Debug(bugShortKernelWrite{ - Written: int64(nn), - Length: int64(len(msg)), - Error: errorString(err), - Stack: stack(), - }) - } - return err -} - -func (c *Conn) respond(msg []byte) { - if err := c.writeToKernel(msg); err != nil { - Debug(bugKernelWriteError{ - Error: errorString(err), - Stack: stack(), - }) - } -} - -type notCachedError struct{} - -func (notCachedError) Error() string { - return "node not cached" -} - -var _ ErrorNumber = notCachedError{} - -func (notCachedError) Errno() Errno { - // Behave just like if the original syscall.ENOENT had been passed - // straight through. - return ENOENT -} - -var ( - ErrNotCached = notCachedError{} -) - -// sendInvalidate sends an invalidate notification to kernel. -// -// A returned ENOENT is translated to a friendlier error. -func (c *Conn) sendInvalidate(msg []byte) error { - switch err := c.writeToKernel(msg); err { - case syscall.ENOENT: - return ErrNotCached - default: - return err - } -} - -// InvalidateNode invalidates the kernel cache of the attributes and a -// range of the data of a node. -// -// Giving offset 0 and size -1 means all data. To invalidate just the -// attributes, give offset 0 and size 0. -// -// Returns ErrNotCached if the kernel is not currently caching the -// node. -func (c *Conn) InvalidateNode(nodeID NodeID, off int64, size int64) error { - buf := newBuffer(unsafe.Sizeof(notifyInvalInodeOut{})) - h := (*outHeader)(unsafe.Pointer(&buf[0])) - // h.Unique is 0 - h.Error = notifyCodeInvalInode - out := (*notifyInvalInodeOut)(buf.alloc(unsafe.Sizeof(notifyInvalInodeOut{}))) - out.Ino = uint64(nodeID) - out.Off = off - out.Len = size - return c.sendInvalidate(buf) -} - -// InvalidateEntry invalidates the kernel cache of the directory entry -// identified by parent directory node ID and entry basename. -// -// Kernel may or may not cache directory listings. To invalidate -// those, use InvalidateNode to invalidate all of the data for a -// directory. (As of 2015-06, Linux FUSE does not cache directory -// listings.) -// -// Returns ErrNotCached if the kernel is not currently caching the -// node. -func (c *Conn) InvalidateEntry(parent NodeID, name string) error { - const maxUint32 = ^uint32(0) - if uint64(len(name)) > uint64(maxUint32) { - // very unlikely, but we don't want to silently truncate - return syscall.ENAMETOOLONG - } - buf := newBuffer(unsafe.Sizeof(notifyInvalEntryOut{}) + uintptr(len(name)) + 1) - h := (*outHeader)(unsafe.Pointer(&buf[0])) - // h.Unique is 0 - h.Error = notifyCodeInvalEntry - out := (*notifyInvalEntryOut)(buf.alloc(unsafe.Sizeof(notifyInvalEntryOut{}))) - out.Parent = uint64(parent) - out.Namelen = uint32(len(name)) - buf = append(buf, name...) - buf = append(buf, '\x00') - return c.sendInvalidate(buf) -} - -// An InitRequest is the first request sent on a FUSE file system. -type InitRequest struct { - Header `json:"-"` - Kernel Protocol - // Maximum readahead in bytes that the kernel plans to use. - MaxReadahead uint32 - Flags InitFlags -} - -var _ = Request(&InitRequest{}) - -func (r *InitRequest) String() string { - return fmt.Sprintf("Init [%v] %v ra=%d fl=%v", &r.Header, r.Kernel, r.MaxReadahead, r.Flags) -} - -// An InitResponse is the response to an InitRequest. -type InitResponse struct { - Library Protocol - // Maximum readahead in bytes that the kernel can use. Ignored if - // greater than InitRequest.MaxReadahead. - MaxReadahead uint32 - Flags InitFlags - // Maximum size of a single write operation. - // Linux enforces a minimum of 4 KiB. - MaxWrite uint32 -} - -func (r *InitResponse) String() string { - return fmt.Sprintf("Init %v ra=%d fl=%v w=%d", r.Library, r.MaxReadahead, r.Flags, r.MaxWrite) -} - -// Respond replies to the request with the given response. -func (r *InitRequest) Respond(resp *InitResponse) { - buf := newBuffer(unsafe.Sizeof(initOut{})) - out := (*initOut)(buf.alloc(unsafe.Sizeof(initOut{}))) - out.Major = resp.Library.Major - out.Minor = resp.Library.Minor - out.MaxReadahead = resp.MaxReadahead - out.Flags = uint32(resp.Flags) - out.MaxWrite = resp.MaxWrite - - // MaxWrite larger than our receive buffer would just lead to - // errors on large writes. - if out.MaxWrite > maxWrite { - out.MaxWrite = maxWrite - } - r.respond(buf) -} - -// A StatfsRequest requests information about the mounted file system. -type StatfsRequest struct { - Header `json:"-"` -} - -var _ = Request(&StatfsRequest{}) - -func (r *StatfsRequest) String() string { - return fmt.Sprintf("Statfs [%s]", &r.Header) -} - -// Respond replies to the request with the given response. -func (r *StatfsRequest) Respond(resp *StatfsResponse) { - buf := newBuffer(unsafe.Sizeof(statfsOut{})) - out := (*statfsOut)(buf.alloc(unsafe.Sizeof(statfsOut{}))) - out.St = kstatfs{ - Blocks: resp.Blocks, - Bfree: resp.Bfree, - Bavail: resp.Bavail, - Files: resp.Files, - Bsize: resp.Bsize, - Namelen: resp.Namelen, - Frsize: resp.Frsize, - } - r.respond(buf) -} - -// A StatfsResponse is the response to a StatfsRequest. -type StatfsResponse struct { - Blocks uint64 // Total data blocks in file system. - Bfree uint64 // Free blocks in file system. - Bavail uint64 // Free blocks in file system if you're not root. - Files uint64 // Total files in file system. - Ffree uint64 // Free files in file system. - Bsize uint32 // Block size - Namelen uint32 // Maximum file name length? - Frsize uint32 // Fragment size, smallest addressable data size in the file system. -} - -func (r *StatfsResponse) String() string { - return fmt.Sprintf("Statfs blocks=%d/%d/%d files=%d/%d bsize=%d frsize=%d namelen=%d", - r.Bavail, r.Bfree, r.Blocks, - r.Ffree, r.Files, - r.Bsize, - r.Frsize, - r.Namelen, - ) -} - -// An AccessRequest asks whether the file can be accessed -// for the purpose specified by the mask. -type AccessRequest struct { - Header `json:"-"` - Mask uint32 -} - -var _ = Request(&AccessRequest{}) - -func (r *AccessRequest) String() string { - return fmt.Sprintf("Access [%s] mask=%#x", &r.Header, r.Mask) -} - -// Respond replies to the request indicating that access is allowed. -// To deny access, use RespondError. -func (r *AccessRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// An Attr is the metadata for a single file or directory. -type Attr struct { - Valid time.Duration // how long Attr can be cached - - Inode uint64 // inode number - Size uint64 // size in bytes - Blocks uint64 // size in 512-byte units - Atime time.Time // time of last access - Mtime time.Time // time of last modification - Ctime time.Time // time of last inode change - Crtime time.Time // time of creation (OS X only) - Mode os.FileMode // file mode - Nlink uint32 // number of links (usually 1) - Uid uint32 // owner uid - Gid uint32 // group gid - Rdev uint32 // device numbers - Flags uint32 // chflags(2) flags (OS X only) - BlockSize uint32 // preferred blocksize for filesystem I/O -} - -func (a Attr) String() string { - return fmt.Sprintf("valid=%v ino=%v size=%d mode=%v", a.Valid, a.Inode, a.Size, a.Mode) -} - -func unix(t time.Time) (sec uint64, nsec uint32) { - nano := t.UnixNano() - sec = uint64(nano / 1e9) - nsec = uint32(nano % 1e9) - return -} - -func (a *Attr) attr(out *attr, proto Protocol) { - out.Ino = a.Inode - out.Size = a.Size - out.Blocks = a.Blocks - out.Atime, out.AtimeNsec = unix(a.Atime) - out.Mtime, out.MtimeNsec = unix(a.Mtime) - out.Ctime, out.CtimeNsec = unix(a.Ctime) - out.SetCrtime(unix(a.Crtime)) - out.Mode = uint32(a.Mode) & 0777 - switch { - default: - out.Mode |= syscall.S_IFREG - case a.Mode&os.ModeDir != 0: - out.Mode |= syscall.S_IFDIR - case a.Mode&os.ModeDevice != 0: - if a.Mode&os.ModeCharDevice != 0 { - out.Mode |= syscall.S_IFCHR - } else { - out.Mode |= syscall.S_IFBLK - } - case a.Mode&os.ModeNamedPipe != 0: - out.Mode |= syscall.S_IFIFO - case a.Mode&os.ModeSymlink != 0: - out.Mode |= syscall.S_IFLNK - case a.Mode&os.ModeSocket != 0: - out.Mode |= syscall.S_IFSOCK - } - if a.Mode&os.ModeSetuid != 0 { - out.Mode |= syscall.S_ISUID - } - if a.Mode&os.ModeSetgid != 0 { - out.Mode |= syscall.S_ISGID - } - out.Nlink = a.Nlink - out.Uid = a.Uid - out.Gid = a.Gid - out.Rdev = a.Rdev - out.SetFlags(a.Flags) - if proto.GE(Protocol{7, 9}) { - out.Blksize = a.BlockSize - } - - return -} - -// A GetattrRequest asks for the metadata for the file denoted by r.Node. -type GetattrRequest struct { - Header `json:"-"` - Flags GetattrFlags - Handle HandleID -} - -var _ = Request(&GetattrRequest{}) - -func (r *GetattrRequest) String() string { - return fmt.Sprintf("Getattr [%s] %v fl=%v", &r.Header, r.Handle, r.Flags) -} - -// Respond replies to the request with the given response. -func (r *GetattrRequest) Respond(resp *GetattrResponse) { - size := attrOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*attrOut)(buf.alloc(size)) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -// A GetattrResponse is the response to a GetattrRequest. -type GetattrResponse struct { - Attr Attr // file attributes -} - -func (r *GetattrResponse) String() string { - return fmt.Sprintf("Getattr %v", r.Attr) -} - -// A GetxattrRequest asks for the extended attributes associated with r.Node. -type GetxattrRequest struct { - Header `json:"-"` - - // Maximum size to return. - Size uint32 - - // Name of the attribute requested. - Name string - - // Offset within extended attributes. - // - // Only valid for OS X, and then only with the resource fork - // attribute. - Position uint32 -} - -var _ = Request(&GetxattrRequest{}) - -func (r *GetxattrRequest) String() string { - return fmt.Sprintf("Getxattr [%s] %q %d @%d", &r.Header, r.Name, r.Size, r.Position) -} - -// Respond replies to the request with the given response. -func (r *GetxattrRequest) Respond(resp *GetxattrResponse) { - if r.Size == 0 { - buf := newBuffer(unsafe.Sizeof(getxattrOut{})) - out := (*getxattrOut)(buf.alloc(unsafe.Sizeof(getxattrOut{}))) - out.Size = uint32(len(resp.Xattr)) - r.respond(buf) - } else { - buf := newBuffer(uintptr(len(resp.Xattr))) - buf = append(buf, resp.Xattr...) - r.respond(buf) - } -} - -// A GetxattrResponse is the response to a GetxattrRequest. -type GetxattrResponse struct { - Xattr []byte -} - -func (r *GetxattrResponse) String() string { - return fmt.Sprintf("Getxattr %x", r.Xattr) -} - -// A ListxattrRequest asks to list the extended attributes associated with r.Node. -type ListxattrRequest struct { - Header `json:"-"` - Size uint32 // maximum size to return - Position uint32 // offset within attribute list -} - -var _ = Request(&ListxattrRequest{}) - -func (r *ListxattrRequest) String() string { - return fmt.Sprintf("Listxattr [%s] %d @%d", &r.Header, r.Size, r.Position) -} - -// Respond replies to the request with the given response. -func (r *ListxattrRequest) Respond(resp *ListxattrResponse) { - if r.Size == 0 { - buf := newBuffer(unsafe.Sizeof(getxattrOut{})) - out := (*getxattrOut)(buf.alloc(unsafe.Sizeof(getxattrOut{}))) - out.Size = uint32(len(resp.Xattr)) - r.respond(buf) - } else { - buf := newBuffer(uintptr(len(resp.Xattr))) - buf = append(buf, resp.Xattr...) - r.respond(buf) - } -} - -// A ListxattrResponse is the response to a ListxattrRequest. -type ListxattrResponse struct { - Xattr []byte -} - -func (r *ListxattrResponse) String() string { - return fmt.Sprintf("Listxattr %x", r.Xattr) -} - -// Append adds an extended attribute name to the response. -func (r *ListxattrResponse) Append(names ...string) { - for _, name := range names { - r.Xattr = append(r.Xattr, name...) - r.Xattr = append(r.Xattr, '\x00') - } -} - -// A RemovexattrRequest asks to remove an extended attribute associated with r.Node. -type RemovexattrRequest struct { - Header `json:"-"` - Name string // name of extended attribute -} - -var _ = Request(&RemovexattrRequest{}) - -func (r *RemovexattrRequest) String() string { - return fmt.Sprintf("Removexattr [%s] %q", &r.Header, r.Name) -} - -// Respond replies to the request, indicating that the attribute was removed. -func (r *RemovexattrRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// A SetxattrRequest asks to set an extended attribute associated with a file. -type SetxattrRequest struct { - Header `json:"-"` - - // Flags can make the request fail if attribute does/not already - // exist. Unfortunately, the constants are platform-specific and - // not exposed by Go1.2. Look for XATTR_CREATE, XATTR_REPLACE. - // - // TODO improve this later - // - // TODO XATTR_CREATE and exist -> EEXIST - // - // TODO XATTR_REPLACE and not exist -> ENODATA - Flags uint32 - - // Offset within extended attributes. - // - // Only valid for OS X, and then only with the resource fork - // attribute. - Position uint32 - - Name string - Xattr []byte -} - -var _ = Request(&SetxattrRequest{}) - -func trunc(b []byte, max int) ([]byte, string) { - if len(b) > max { - return b[:max], "..." - } - return b, "" -} - -func (r *SetxattrRequest) String() string { - xattr, tail := trunc(r.Xattr, 16) - return fmt.Sprintf("Setxattr [%s] %q %x%s fl=%v @%#x", &r.Header, r.Name, xattr, tail, r.Flags, r.Position) -} - -// Respond replies to the request, indicating that the extended attribute was set. -func (r *SetxattrRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// A LookupRequest asks to look up the given name in the directory named by r.Node. -type LookupRequest struct { - Header `json:"-"` - Name string -} - -var _ = Request(&LookupRequest{}) - -func (r *LookupRequest) String() string { - return fmt.Sprintf("Lookup [%s] %q", &r.Header, r.Name) -} - -// Respond replies to the request with the given response. -func (r *LookupRequest) Respond(resp *LookupResponse) { - size := entryOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*entryOut)(buf.alloc(size)) - out.Nodeid = uint64(resp.Node) - out.Generation = resp.Generation - out.EntryValid = uint64(resp.EntryValid / time.Second) - out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -// A LookupResponse is the response to a LookupRequest. -type LookupResponse struct { - Node NodeID - Generation uint64 - EntryValid time.Duration - Attr Attr -} - -func (r *LookupResponse) string() string { - return fmt.Sprintf("%v gen=%d valid=%v attr={%v}", r.Node, r.Generation, r.EntryValid, r.Attr) -} - -func (r *LookupResponse) String() string { - return fmt.Sprintf("Lookup %s", r.string()) -} - -// An OpenRequest asks to open a file or directory -type OpenRequest struct { - Header `json:"-"` - Dir bool // is this Opendir? - Flags OpenFlags -} - -var _ = Request(&OpenRequest{}) - -func (r *OpenRequest) String() string { - return fmt.Sprintf("Open [%s] dir=%v fl=%v", &r.Header, r.Dir, r.Flags) -} - -// Respond replies to the request with the given response. -func (r *OpenRequest) Respond(resp *OpenResponse) { - buf := newBuffer(unsafe.Sizeof(openOut{})) - out := (*openOut)(buf.alloc(unsafe.Sizeof(openOut{}))) - out.Fh = uint64(resp.Handle) - out.OpenFlags = uint32(resp.Flags) - r.respond(buf) -} - -// A OpenResponse is the response to a OpenRequest. -type OpenResponse struct { - Handle HandleID - Flags OpenResponseFlags -} - -func (r *OpenResponse) string() string { - return fmt.Sprintf("%v fl=%v", r.Handle, r.Flags) -} - -func (r *OpenResponse) String() string { - return fmt.Sprintf("Open %s", r.string()) -} - -// A CreateRequest asks to create and open a file (not a directory). -type CreateRequest struct { - Header `json:"-"` - Name string - Flags OpenFlags - Mode os.FileMode - // Umask of the request. Not supported on OS X. - Umask os.FileMode -} - -var _ = Request(&CreateRequest{}) - -func (r *CreateRequest) String() string { - return fmt.Sprintf("Create [%s] %q fl=%v mode=%v umask=%v", &r.Header, r.Name, r.Flags, r.Mode, r.Umask) -} - -// Respond replies to the request with the given response. -func (r *CreateRequest) Respond(resp *CreateResponse) { - eSize := entryOutSize(r.Header.Conn.proto) - buf := newBuffer(eSize + unsafe.Sizeof(openOut{})) - - e := (*entryOut)(buf.alloc(eSize)) - e.Nodeid = uint64(resp.Node) - e.Generation = resp.Generation - e.EntryValid = uint64(resp.EntryValid / time.Second) - e.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) - e.AttrValid = uint64(resp.Attr.Valid / time.Second) - e.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&e.Attr, r.Header.Conn.proto) - - o := (*openOut)(buf.alloc(unsafe.Sizeof(openOut{}))) - o.Fh = uint64(resp.Handle) - o.OpenFlags = uint32(resp.Flags) - - r.respond(buf) -} - -// A CreateResponse is the response to a CreateRequest. -// It describes the created node and opened handle. -type CreateResponse struct { - LookupResponse - OpenResponse -} - -func (r *CreateResponse) String() string { - return fmt.Sprintf("Create {%s} {%s}", r.LookupResponse.string(), r.OpenResponse.string()) -} - -// A MkdirRequest asks to create (but not open) a directory. -type MkdirRequest struct { - Header `json:"-"` - Name string - Mode os.FileMode - // Umask of the request. Not supported on OS X. - Umask os.FileMode -} - -var _ = Request(&MkdirRequest{}) - -func (r *MkdirRequest) String() string { - return fmt.Sprintf("Mkdir [%s] %q mode=%v umask=%v", &r.Header, r.Name, r.Mode, r.Umask) -} - -// Respond replies to the request with the given response. -func (r *MkdirRequest) Respond(resp *MkdirResponse) { - size := entryOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*entryOut)(buf.alloc(size)) - out.Nodeid = uint64(resp.Node) - out.Generation = resp.Generation - out.EntryValid = uint64(resp.EntryValid / time.Second) - out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -// A MkdirResponse is the response to a MkdirRequest. -type MkdirResponse struct { - LookupResponse -} - -func (r *MkdirResponse) String() string { - return fmt.Sprintf("Mkdir %v", r.LookupResponse.string()) -} - -// A ReadRequest asks to read from an open file. -type ReadRequest struct { - Header `json:"-"` - Dir bool // is this Readdir? - Handle HandleID - Offset int64 - Size int - Flags ReadFlags - LockOwner uint64 - FileFlags OpenFlags -} - -var _ = Request(&ReadRequest{}) - -func (r *ReadRequest) String() string { - return fmt.Sprintf("Read [%s] %v %d @%#x dir=%v fl=%v lock=%d ffl=%v", &r.Header, r.Handle, r.Size, r.Offset, r.Dir, r.Flags, r.LockOwner, r.FileFlags) -} - -// Respond replies to the request with the given response. -func (r *ReadRequest) Respond(resp *ReadResponse) { - buf := newBuffer(uintptr(len(resp.Data))) - buf = append(buf, resp.Data...) - r.respond(buf) -} - -// A ReadResponse is the response to a ReadRequest. -type ReadResponse struct { - Data []byte -} - -func (r *ReadResponse) String() string { - return fmt.Sprintf("Read %d", len(r.Data)) -} - -type jsonReadResponse struct { - Len uint64 -} - -func (r *ReadResponse) MarshalJSON() ([]byte, error) { - j := jsonReadResponse{ - Len: uint64(len(r.Data)), - } - return json.Marshal(j) -} - -// A ReleaseRequest asks to release (close) an open file handle. -type ReleaseRequest struct { - Header `json:"-"` - Dir bool // is this Releasedir? - Handle HandleID - Flags OpenFlags // flags from OpenRequest - ReleaseFlags ReleaseFlags - LockOwner uint32 -} - -var _ = Request(&ReleaseRequest{}) - -func (r *ReleaseRequest) String() string { - return fmt.Sprintf("Release [%s] %v fl=%v rfl=%v owner=%#x", &r.Header, r.Handle, r.Flags, r.ReleaseFlags, r.LockOwner) -} - -// Respond replies to the request, indicating that the handle has been released. -func (r *ReleaseRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// A DestroyRequest is sent by the kernel when unmounting the file system. -// No more requests will be received after this one, but it should still be -// responded to. -type DestroyRequest struct { - Header `json:"-"` -} - -var _ = Request(&DestroyRequest{}) - -func (r *DestroyRequest) String() string { - return fmt.Sprintf("Destroy [%s]", &r.Header) -} - -// Respond replies to the request. -func (r *DestroyRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// A ForgetRequest is sent by the kernel when forgetting about r.Node -// as returned by r.N lookup requests. -type ForgetRequest struct { - Header `json:"-"` - N uint64 -} - -var _ = Request(&ForgetRequest{}) - -func (r *ForgetRequest) String() string { - return fmt.Sprintf("Forget [%s] %d", &r.Header, r.N) -} - -// Respond replies to the request, indicating that the forgetfulness has been recorded. -func (r *ForgetRequest) Respond() { - // Don't reply to forget messages. - r.noResponse() -} - -// A Dirent represents a single directory entry. -type Dirent struct { - // Inode this entry names. - Inode uint64 - - // Type of the entry, for example DT_File. - // - // Setting this is optional. The zero value (DT_Unknown) means - // callers will just need to do a Getattr when the type is - // needed. Providing a type can speed up operations - // significantly. - Type DirentType - - // Name of the entry - Name string -} - -// Type of an entry in a directory listing. -type DirentType uint32 - -const ( - // These don't quite match os.FileMode; especially there's an - // explicit unknown, instead of zero value meaning file. They - // are also not quite syscall.DT_*; nothing says the FUSE - // protocol follows those, and even if they were, we don't - // want each fs to fiddle with syscall. - - // The shift by 12 is hardcoded in the FUSE userspace - // low-level C library, so it's safe here. - - DT_Unknown DirentType = 0 - DT_Socket DirentType = syscall.S_IFSOCK >> 12 - DT_Link DirentType = syscall.S_IFLNK >> 12 - DT_File DirentType = syscall.S_IFREG >> 12 - DT_Block DirentType = syscall.S_IFBLK >> 12 - DT_Dir DirentType = syscall.S_IFDIR >> 12 - DT_Char DirentType = syscall.S_IFCHR >> 12 - DT_FIFO DirentType = syscall.S_IFIFO >> 12 -) - -func (t DirentType) String() string { - switch t { - case DT_Unknown: - return "unknown" - case DT_Socket: - return "socket" - case DT_Link: - return "link" - case DT_File: - return "file" - case DT_Block: - return "block" - case DT_Dir: - return "dir" - case DT_Char: - return "char" - case DT_FIFO: - return "fifo" - } - return "invalid" -} - -// AppendDirent appends the encoded form of a directory entry to data -// and returns the resulting slice. -func AppendDirent(data []byte, dir Dirent) []byte { - de := dirent{ - Ino: dir.Inode, - Namelen: uint32(len(dir.Name)), - Type: uint32(dir.Type), - } - de.Off = uint64(len(data) + direntSize + (len(dir.Name)+7)&^7) - data = append(data, (*[direntSize]byte)(unsafe.Pointer(&de))[:]...) - data = append(data, dir.Name...) - n := direntSize + uintptr(len(dir.Name)) - if n%8 != 0 { - var pad [8]byte - data = append(data, pad[:8-n%8]...) - } - return data -} - -// A WriteRequest asks to write to an open file. -type WriteRequest struct { - Header - Handle HandleID - Offset int64 - Data []byte - Flags WriteFlags - LockOwner uint64 - FileFlags OpenFlags -} - -var _ = Request(&WriteRequest{}) - -func (r *WriteRequest) String() string { - return fmt.Sprintf("Write [%s] %v %d @%d fl=%v lock=%d ffl=%v", &r.Header, r.Handle, len(r.Data), r.Offset, r.Flags, r.LockOwner, r.FileFlags) -} - -type jsonWriteRequest struct { - Handle HandleID - Offset int64 - Len uint64 - Flags WriteFlags -} - -func (r *WriteRequest) MarshalJSON() ([]byte, error) { - j := jsonWriteRequest{ - Handle: r.Handle, - Offset: r.Offset, - Len: uint64(len(r.Data)), - Flags: r.Flags, - } - return json.Marshal(j) -} - -// Respond replies to the request with the given response. -func (r *WriteRequest) Respond(resp *WriteResponse) { - buf := newBuffer(unsafe.Sizeof(writeOut{})) - out := (*writeOut)(buf.alloc(unsafe.Sizeof(writeOut{}))) - out.Size = uint32(resp.Size) - r.respond(buf) -} - -// A WriteResponse replies to a write indicating how many bytes were written. -type WriteResponse struct { - Size int -} - -func (r *WriteResponse) String() string { - return fmt.Sprintf("Write %d", r.Size) -} - -// A SetattrRequest asks to change one or more attributes associated with a file, -// as indicated by Valid. -type SetattrRequest struct { - Header `json:"-"` - Valid SetattrValid - Handle HandleID - Size uint64 - Atime time.Time - Mtime time.Time - Mode os.FileMode - Uid uint32 - Gid uint32 - - // OS X only - Bkuptime time.Time - Chgtime time.Time - Crtime time.Time - Flags uint32 // see chflags(2) -} - -var _ = Request(&SetattrRequest{}) - -func (r *SetattrRequest) String() string { - var buf bytes.Buffer - fmt.Fprintf(&buf, "Setattr [%s]", &r.Header) - if r.Valid.Mode() { - fmt.Fprintf(&buf, " mode=%v", r.Mode) - } - if r.Valid.Uid() { - fmt.Fprintf(&buf, " uid=%d", r.Uid) - } - if r.Valid.Gid() { - fmt.Fprintf(&buf, " gid=%d", r.Gid) - } - if r.Valid.Size() { - fmt.Fprintf(&buf, " size=%d", r.Size) - } - if r.Valid.Atime() { - fmt.Fprintf(&buf, " atime=%v", r.Atime) - } - if r.Valid.AtimeNow() { - fmt.Fprintf(&buf, " atime=now") - } - if r.Valid.Mtime() { - fmt.Fprintf(&buf, " mtime=%v", r.Mtime) - } - if r.Valid.MtimeNow() { - fmt.Fprintf(&buf, " mtime=now") - } - if r.Valid.Handle() { - fmt.Fprintf(&buf, " handle=%v", r.Handle) - } else { - fmt.Fprintf(&buf, " handle=INVALID-%v", r.Handle) - } - if r.Valid.LockOwner() { - fmt.Fprintf(&buf, " lockowner") - } - if r.Valid.Crtime() { - fmt.Fprintf(&buf, " crtime=%v", r.Crtime) - } - if r.Valid.Chgtime() { - fmt.Fprintf(&buf, " chgtime=%v", r.Chgtime) - } - if r.Valid.Bkuptime() { - fmt.Fprintf(&buf, " bkuptime=%v", r.Bkuptime) - } - if r.Valid.Flags() { - fmt.Fprintf(&buf, " flags=%v", r.Flags) - } - return buf.String() -} - -// Respond replies to the request with the given response, -// giving the updated attributes. -func (r *SetattrRequest) Respond(resp *SetattrResponse) { - size := attrOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*attrOut)(buf.alloc(size)) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -// A SetattrResponse is the response to a SetattrRequest. -type SetattrResponse struct { - Attr Attr // file attributes -} - -func (r *SetattrResponse) String() string { - return fmt.Sprintf("Setattr %v", r.Attr) -} - -// A FlushRequest asks for the current state of an open file to be flushed -// to storage, as when a file descriptor is being closed. A single opened Handle -// may receive multiple FlushRequests over its lifetime. -type FlushRequest struct { - Header `json:"-"` - Handle HandleID - Flags uint32 - LockOwner uint64 -} - -var _ = Request(&FlushRequest{}) - -func (r *FlushRequest) String() string { - return fmt.Sprintf("Flush [%s] %v fl=%#x lk=%#x", &r.Header, r.Handle, r.Flags, r.LockOwner) -} - -// Respond replies to the request, indicating that the flush succeeded. -func (r *FlushRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// A RemoveRequest asks to remove a file or directory from the -// directory r.Node. -type RemoveRequest struct { - Header `json:"-"` - Name string // name of the entry to remove - Dir bool // is this rmdir? -} - -var _ = Request(&RemoveRequest{}) - -func (r *RemoveRequest) String() string { - return fmt.Sprintf("Remove [%s] %q dir=%v", &r.Header, r.Name, r.Dir) -} - -// Respond replies to the request, indicating that the file was removed. -func (r *RemoveRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// A SymlinkRequest is a request to create a symlink making NewName point to Target. -type SymlinkRequest struct { - Header `json:"-"` - NewName, Target string -} - -var _ = Request(&SymlinkRequest{}) - -func (r *SymlinkRequest) String() string { - return fmt.Sprintf("Symlink [%s] from %q to target %q", &r.Header, r.NewName, r.Target) -} - -// Respond replies to the request, indicating that the symlink was created. -func (r *SymlinkRequest) Respond(resp *SymlinkResponse) { - size := entryOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*entryOut)(buf.alloc(size)) - out.Nodeid = uint64(resp.Node) - out.Generation = resp.Generation - out.EntryValid = uint64(resp.EntryValid / time.Second) - out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -// A SymlinkResponse is the response to a SymlinkRequest. -type SymlinkResponse struct { - LookupResponse -} - -func (r *SymlinkResponse) String() string { - return fmt.Sprintf("Symlink %v", r.LookupResponse.string()) -} - -// A ReadlinkRequest is a request to read a symlink's target. -type ReadlinkRequest struct { - Header `json:"-"` -} - -var _ = Request(&ReadlinkRequest{}) - -func (r *ReadlinkRequest) String() string { - return fmt.Sprintf("Readlink [%s]", &r.Header) -} - -func (r *ReadlinkRequest) Respond(target string) { - buf := newBuffer(uintptr(len(target))) - buf = append(buf, target...) - r.respond(buf) -} - -// A LinkRequest is a request to create a hard link. -type LinkRequest struct { - Header `json:"-"` - OldNode NodeID - NewName string -} - -var _ = Request(&LinkRequest{}) - -func (r *LinkRequest) String() string { - return fmt.Sprintf("Link [%s] node %d to %q", &r.Header, r.OldNode, r.NewName) -} - -func (r *LinkRequest) Respond(resp *LookupResponse) { - size := entryOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*entryOut)(buf.alloc(size)) - out.Nodeid = uint64(resp.Node) - out.Generation = resp.Generation - out.EntryValid = uint64(resp.EntryValid / time.Second) - out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -// A RenameRequest is a request to rename a file. -type RenameRequest struct { - Header `json:"-"` - NewDir NodeID - OldName, NewName string -} - -var _ = Request(&RenameRequest{}) - -func (r *RenameRequest) String() string { - return fmt.Sprintf("Rename [%s] from %q to dirnode %v %q", &r.Header, r.OldName, r.NewDir, r.NewName) -} - -func (r *RenameRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -type MknodRequest struct { - Header `json:"-"` - Name string - Mode os.FileMode - Rdev uint32 - // Umask of the request. Not supported on OS X. - Umask os.FileMode -} - -var _ = Request(&MknodRequest{}) - -func (r *MknodRequest) String() string { - return fmt.Sprintf("Mknod [%s] Name %q mode=%v umask=%v rdev=%d", &r.Header, r.Name, r.Mode, r.Umask, r.Rdev) -} - -func (r *MknodRequest) Respond(resp *LookupResponse) { - size := entryOutSize(r.Header.Conn.proto) - buf := newBuffer(size) - out := (*entryOut)(buf.alloc(size)) - out.Nodeid = uint64(resp.Node) - out.Generation = resp.Generation - out.EntryValid = uint64(resp.EntryValid / time.Second) - out.EntryValidNsec = uint32(resp.EntryValid % time.Second / time.Nanosecond) - out.AttrValid = uint64(resp.Attr.Valid / time.Second) - out.AttrValidNsec = uint32(resp.Attr.Valid % time.Second / time.Nanosecond) - resp.Attr.attr(&out.Attr, r.Header.Conn.proto) - r.respond(buf) -} - -type FsyncRequest struct { - Header `json:"-"` - Handle HandleID - // TODO bit 1 is datasync, not well documented upstream - Flags uint32 - Dir bool -} - -var _ = Request(&FsyncRequest{}) - -func (r *FsyncRequest) String() string { - return fmt.Sprintf("Fsync [%s] Handle %v Flags %v", &r.Header, r.Handle, r.Flags) -} - -func (r *FsyncRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} - -// An InterruptRequest is a request to interrupt another pending request. The -// response to that request should return an error status of EINTR. -type InterruptRequest struct { - Header `json:"-"` - IntrID RequestID // ID of the request to be interrupt. -} - -var _ = Request(&InterruptRequest{}) - -func (r *InterruptRequest) Respond() { - // nothing to do here - r.noResponse() -} - -func (r *InterruptRequest) String() string { - return fmt.Sprintf("Interrupt [%s] ID %v", &r.Header, r.IntrID) -} - -// An ExchangeDataRequest is a request to exchange the contents of two -// files, while leaving most metadata untouched. -// -// This request comes from OS X exchangedata(2) and represents its -// specific semantics. Crucially, it is very different from Linux -// renameat(2) RENAME_EXCHANGE. -// -// https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/exchangedata.2.html -type ExchangeDataRequest struct { - Header `json:"-"` - OldDir, NewDir NodeID - OldName, NewName string - // TODO options -} - -var _ = Request(&ExchangeDataRequest{}) - -func (r *ExchangeDataRequest) String() string { - // TODO options - return fmt.Sprintf("ExchangeData [%s] %v %q and %v %q", &r.Header, r.OldDir, r.OldName, r.NewDir, r.NewName) -} - -func (r *ExchangeDataRequest) Respond() { - buf := newBuffer(0) - r.respond(buf) -} diff --git a/vendor/bazil.org/fuse/fuse_darwin.go b/vendor/bazil.org/fuse/fuse_darwin.go deleted file mode 100644 index b58dca97..00000000 --- a/vendor/bazil.org/fuse/fuse_darwin.go +++ /dev/null @@ -1,9 +0,0 @@ -package fuse - -// Maximum file write size we are prepared to receive from the kernel. -// -// This value has to be >=16MB or OSXFUSE (3.4.0 observed) will -// forcibly close the /dev/fuse file descriptor on a Setxattr with a -// 16MB value. See TestSetxattr16MB and -// https://github.com/bazil/fuse/issues/42 -const maxWrite = 16 * 1024 * 1024 diff --git a/vendor/bazil.org/fuse/fuse_freebsd.go b/vendor/bazil.org/fuse/fuse_freebsd.go deleted file mode 100644 index 4aa83a0d..00000000 --- a/vendor/bazil.org/fuse/fuse_freebsd.go +++ /dev/null @@ -1,6 +0,0 @@ -package fuse - -// Maximum file write size we are prepared to receive from the kernel. -// -// This number is just a guess. -const maxWrite = 128 * 1024 diff --git a/vendor/bazil.org/fuse/fuse_kernel.go b/vendor/bazil.org/fuse/fuse_kernel.go deleted file mode 100644 index 87c5ca1d..00000000 --- a/vendor/bazil.org/fuse/fuse_kernel.go +++ /dev/null @@ -1,774 +0,0 @@ -// See the file LICENSE for copyright and licensing information. - -// Derived from FUSE's fuse_kernel.h, which carries this notice: -/* - 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. -*/ - -package fuse - -import ( - "fmt" - "syscall" - "unsafe" -) - -// The FUSE version implemented by the package. -const ( - protoVersionMinMajor = 7 - protoVersionMinMinor = 8 - protoVersionMaxMajor = 7 - protoVersionMaxMinor = 12 -) - -const ( - rootID = 1 -) - -type kstatfs struct { - Blocks uint64 - Bfree uint64 - Bavail uint64 - Files uint64 - Ffree uint64 - Bsize uint32 - Namelen uint32 - Frsize uint32 - _ uint32 - Spare [6]uint32 -} - -type fileLock struct { - Start uint64 - End uint64 - Type uint32 - Pid uint32 -} - -// GetattrFlags are bit flags that can be seen in GetattrRequest. -type GetattrFlags uint32 - -const ( - // Indicates the handle is valid. - GetattrFh GetattrFlags = 1 << 0 -) - -var getattrFlagsNames = []flagName{ - {uint32(GetattrFh), "GetattrFh"}, -} - -func (fl GetattrFlags) String() string { - return flagString(uint32(fl), getattrFlagsNames) -} - -// The SetattrValid are bit flags describing which fields in the SetattrRequest -// are included in the change. -type SetattrValid uint32 - -const ( - SetattrMode SetattrValid = 1 << 0 - SetattrUid SetattrValid = 1 << 1 - SetattrGid SetattrValid = 1 << 2 - SetattrSize SetattrValid = 1 << 3 - SetattrAtime SetattrValid = 1 << 4 - SetattrMtime SetattrValid = 1 << 5 - SetattrHandle SetattrValid = 1 << 6 - - // Linux only(?) - SetattrAtimeNow SetattrValid = 1 << 7 - SetattrMtimeNow SetattrValid = 1 << 8 - SetattrLockOwner SetattrValid = 1 << 9 // http://www.mail-archive.com/git-commits-head@vger.kernel.org/msg27852.html - - // OS X only - SetattrCrtime SetattrValid = 1 << 28 - SetattrChgtime SetattrValid = 1 << 29 - SetattrBkuptime SetattrValid = 1 << 30 - SetattrFlags SetattrValid = 1 << 31 -) - -func (fl SetattrValid) Mode() bool { return fl&SetattrMode != 0 } -func (fl SetattrValid) Uid() bool { return fl&SetattrUid != 0 } -func (fl SetattrValid) Gid() bool { return fl&SetattrGid != 0 } -func (fl SetattrValid) Size() bool { return fl&SetattrSize != 0 } -func (fl SetattrValid) Atime() bool { return fl&SetattrAtime != 0 } -func (fl SetattrValid) Mtime() bool { return fl&SetattrMtime != 0 } -func (fl SetattrValid) Handle() bool { return fl&SetattrHandle != 0 } -func (fl SetattrValid) AtimeNow() bool { return fl&SetattrAtimeNow != 0 } -func (fl SetattrValid) MtimeNow() bool { return fl&SetattrMtimeNow != 0 } -func (fl SetattrValid) LockOwner() bool { return fl&SetattrLockOwner != 0 } -func (fl SetattrValid) Crtime() bool { return fl&SetattrCrtime != 0 } -func (fl SetattrValid) Chgtime() bool { return fl&SetattrChgtime != 0 } -func (fl SetattrValid) Bkuptime() bool { return fl&SetattrBkuptime != 0 } -func (fl SetattrValid) Flags() bool { return fl&SetattrFlags != 0 } - -func (fl SetattrValid) String() string { - return flagString(uint32(fl), setattrValidNames) -} - -var setattrValidNames = []flagName{ - {uint32(SetattrMode), "SetattrMode"}, - {uint32(SetattrUid), "SetattrUid"}, - {uint32(SetattrGid), "SetattrGid"}, - {uint32(SetattrSize), "SetattrSize"}, - {uint32(SetattrAtime), "SetattrAtime"}, - {uint32(SetattrMtime), "SetattrMtime"}, - {uint32(SetattrHandle), "SetattrHandle"}, - {uint32(SetattrAtimeNow), "SetattrAtimeNow"}, - {uint32(SetattrMtimeNow), "SetattrMtimeNow"}, - {uint32(SetattrLockOwner), "SetattrLockOwner"}, - {uint32(SetattrCrtime), "SetattrCrtime"}, - {uint32(SetattrChgtime), "SetattrChgtime"}, - {uint32(SetattrBkuptime), "SetattrBkuptime"}, - {uint32(SetattrFlags), "SetattrFlags"}, -} - -// Flags that can be seen in OpenRequest.Flags. -const ( - // Access modes. These are not 1-bit flags, but alternatives where - // only one can be chosen. See the IsReadOnly etc convenience - // methods. - OpenReadOnly OpenFlags = syscall.O_RDONLY - OpenWriteOnly OpenFlags = syscall.O_WRONLY - OpenReadWrite OpenFlags = syscall.O_RDWR - - // File was opened in append-only mode, all writes will go to end - // of file. OS X does not provide this information. - OpenAppend OpenFlags = syscall.O_APPEND - OpenCreate OpenFlags = syscall.O_CREAT - OpenDirectory OpenFlags = syscall.O_DIRECTORY - OpenExclusive OpenFlags = syscall.O_EXCL - OpenNonblock OpenFlags = syscall.O_NONBLOCK - OpenSync OpenFlags = syscall.O_SYNC - OpenTruncate OpenFlags = syscall.O_TRUNC -) - -// OpenAccessModeMask is a bitmask that separates the access mode -// from the other flags in OpenFlags. -const OpenAccessModeMask OpenFlags = syscall.O_ACCMODE - -// OpenFlags are the O_FOO flags passed to open/create/etc calls. For -// example, os.O_WRONLY | os.O_APPEND. -type OpenFlags uint32 - -func (fl OpenFlags) String() string { - // O_RDONLY, O_RWONLY, O_RDWR are not flags - s := accModeName(fl & OpenAccessModeMask) - flags := uint32(fl &^ OpenAccessModeMask) - if flags != 0 { - s = s + "+" + flagString(flags, openFlagNames) - } - return s -} - -// Return true if OpenReadOnly is set. -func (fl OpenFlags) IsReadOnly() bool { - return fl&OpenAccessModeMask == OpenReadOnly -} - -// Return true if OpenWriteOnly is set. -func (fl OpenFlags) IsWriteOnly() bool { - return fl&OpenAccessModeMask == OpenWriteOnly -} - -// Return true if OpenReadWrite is set. -func (fl OpenFlags) IsReadWrite() bool { - return fl&OpenAccessModeMask == OpenReadWrite -} - -func accModeName(flags OpenFlags) string { - switch flags { - case OpenReadOnly: - return "OpenReadOnly" - case OpenWriteOnly: - return "OpenWriteOnly" - case OpenReadWrite: - return "OpenReadWrite" - default: - return "" - } -} - -var openFlagNames = []flagName{ - {uint32(OpenAppend), "OpenAppend"}, - {uint32(OpenCreate), "OpenCreate"}, - {uint32(OpenDirectory), "OpenDirectory"}, - {uint32(OpenExclusive), "OpenExclusive"}, - {uint32(OpenNonblock), "OpenNonblock"}, - {uint32(OpenSync), "OpenSync"}, - {uint32(OpenTruncate), "OpenTruncate"}, -} - -// The OpenResponseFlags are returned in the OpenResponse. -type OpenResponseFlags uint32 - -const ( - OpenDirectIO OpenResponseFlags = 1 << 0 // bypass page cache for this open file - OpenKeepCache OpenResponseFlags = 1 << 1 // don't invalidate the data cache on open - OpenNonSeekable OpenResponseFlags = 1 << 2 // mark the file as non-seekable (not supported on OS X) - - OpenPurgeAttr OpenResponseFlags = 1 << 30 // OS X - OpenPurgeUBC OpenResponseFlags = 1 << 31 // OS X -) - -func (fl OpenResponseFlags) String() string { - return flagString(uint32(fl), openResponseFlagNames) -} - -var openResponseFlagNames = []flagName{ - {uint32(OpenDirectIO), "OpenDirectIO"}, - {uint32(OpenKeepCache), "OpenKeepCache"}, - {uint32(OpenNonSeekable), "OpenNonSeekable"}, - {uint32(OpenPurgeAttr), "OpenPurgeAttr"}, - {uint32(OpenPurgeUBC), "OpenPurgeUBC"}, -} - -// The InitFlags are used in the Init exchange. -type InitFlags uint32 - -const ( - InitAsyncRead InitFlags = 1 << 0 - InitPosixLocks InitFlags = 1 << 1 - InitFileOps InitFlags = 1 << 2 - InitAtomicTrunc InitFlags = 1 << 3 - InitExportSupport InitFlags = 1 << 4 - InitBigWrites InitFlags = 1 << 5 - // Do not mask file access modes with umask. Not supported on OS X. - InitDontMask InitFlags = 1 << 6 - InitSpliceWrite InitFlags = 1 << 7 - InitSpliceMove InitFlags = 1 << 8 - InitSpliceRead InitFlags = 1 << 9 - InitFlockLocks InitFlags = 1 << 10 - InitHasIoctlDir InitFlags = 1 << 11 - InitAutoInvalData InitFlags = 1 << 12 - InitDoReaddirplus InitFlags = 1 << 13 - InitReaddirplusAuto InitFlags = 1 << 14 - InitAsyncDIO InitFlags = 1 << 15 - InitWritebackCache InitFlags = 1 << 16 - InitNoOpenSupport InitFlags = 1 << 17 - - InitCaseSensitive InitFlags = 1 << 29 // OS X only - InitVolRename InitFlags = 1 << 30 // OS X only - InitXtimes InitFlags = 1 << 31 // OS X only -) - -type flagName struct { - bit uint32 - name string -} - -var initFlagNames = []flagName{ - {uint32(InitAsyncRead), "InitAsyncRead"}, - {uint32(InitPosixLocks), "InitPosixLocks"}, - {uint32(InitFileOps), "InitFileOps"}, - {uint32(InitAtomicTrunc), "InitAtomicTrunc"}, - {uint32(InitExportSupport), "InitExportSupport"}, - {uint32(InitBigWrites), "InitBigWrites"}, - {uint32(InitDontMask), "InitDontMask"}, - {uint32(InitSpliceWrite), "InitSpliceWrite"}, - {uint32(InitSpliceMove), "InitSpliceMove"}, - {uint32(InitSpliceRead), "InitSpliceRead"}, - {uint32(InitFlockLocks), "InitFlockLocks"}, - {uint32(InitHasIoctlDir), "InitHasIoctlDir"}, - {uint32(InitAutoInvalData), "InitAutoInvalData"}, - {uint32(InitDoReaddirplus), "InitDoReaddirplus"}, - {uint32(InitReaddirplusAuto), "InitReaddirplusAuto"}, - {uint32(InitAsyncDIO), "InitAsyncDIO"}, - {uint32(InitWritebackCache), "InitWritebackCache"}, - {uint32(InitNoOpenSupport), "InitNoOpenSupport"}, - - {uint32(InitCaseSensitive), "InitCaseSensitive"}, - {uint32(InitVolRename), "InitVolRename"}, - {uint32(InitXtimes), "InitXtimes"}, -} - -func (fl InitFlags) String() string { - return flagString(uint32(fl), initFlagNames) -} - -func flagString(f uint32, names []flagName) string { - var s string - - if f == 0 { - return "0" - } - - for _, n := range names { - if f&n.bit != 0 { - s += "+" + n.name - f &^= n.bit - } - } - if f != 0 { - s += fmt.Sprintf("%+#x", f) - } - return s[1:] -} - -// The ReleaseFlags are used in the Release exchange. -type ReleaseFlags uint32 - -const ( - ReleaseFlush ReleaseFlags = 1 << 0 -) - -func (fl ReleaseFlags) String() string { - return flagString(uint32(fl), releaseFlagNames) -} - -var releaseFlagNames = []flagName{ - {uint32(ReleaseFlush), "ReleaseFlush"}, -} - -// Opcodes -const ( - opLookup = 1 - opForget = 2 // no reply - opGetattr = 3 - opSetattr = 4 - opReadlink = 5 - opSymlink = 6 - opMknod = 8 - opMkdir = 9 - opUnlink = 10 - opRmdir = 11 - opRename = 12 - opLink = 13 - opOpen = 14 - opRead = 15 - opWrite = 16 - opStatfs = 17 - opRelease = 18 - opFsync = 20 - opSetxattr = 21 - opGetxattr = 22 - opListxattr = 23 - opRemovexattr = 24 - opFlush = 25 - opInit = 26 - opOpendir = 27 - opReaddir = 28 - opReleasedir = 29 - opFsyncdir = 30 - opGetlk = 31 - opSetlk = 32 - opSetlkw = 33 - opAccess = 34 - opCreate = 35 - opInterrupt = 36 - opBmap = 37 - opDestroy = 38 - opIoctl = 39 // Linux? - opPoll = 40 // Linux? - - // OS X - opSetvolname = 61 - opGetxtimes = 62 - opExchange = 63 -) - -type entryOut struct { - Nodeid uint64 // Inode ID - Generation uint64 // Inode generation - EntryValid uint64 // Cache timeout for the name - AttrValid uint64 // Cache timeout for the attributes - EntryValidNsec uint32 - AttrValidNsec uint32 - Attr attr -} - -func entryOutSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 9}): - return unsafe.Offsetof(entryOut{}.Attr) + unsafe.Offsetof(entryOut{}.Attr.Blksize) - default: - return unsafe.Sizeof(entryOut{}) - } -} - -type forgetIn struct { - Nlookup uint64 -} - -type getattrIn struct { - GetattrFlags uint32 - _ uint32 - Fh uint64 -} - -type attrOut struct { - AttrValid uint64 // Cache timeout for the attributes - AttrValidNsec uint32 - _ uint32 - Attr attr -} - -func attrOutSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 9}): - return unsafe.Offsetof(attrOut{}.Attr) + unsafe.Offsetof(attrOut{}.Attr.Blksize) - default: - return unsafe.Sizeof(attrOut{}) - } -} - -// OS X -type getxtimesOut struct { - Bkuptime uint64 - Crtime uint64 - BkuptimeNsec uint32 - CrtimeNsec uint32 -} - -type mknodIn struct { - Mode uint32 - Rdev uint32 - Umask uint32 - _ uint32 - // "filename\x00" follows. -} - -func mknodInSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 12}): - return unsafe.Offsetof(mknodIn{}.Umask) - default: - return unsafe.Sizeof(mknodIn{}) - } -} - -type mkdirIn struct { - Mode uint32 - Umask uint32 - // filename follows -} - -func mkdirInSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 12}): - return unsafe.Offsetof(mkdirIn{}.Umask) + 4 - default: - return unsafe.Sizeof(mkdirIn{}) - } -} - -type renameIn struct { - Newdir uint64 - // "oldname\x00newname\x00" follows -} - -// OS X -type exchangeIn struct { - Olddir uint64 - Newdir uint64 - Options uint64 - // "oldname\x00newname\x00" follows -} - -type linkIn struct { - Oldnodeid uint64 -} - -type setattrInCommon struct { - Valid uint32 - _ uint32 - Fh uint64 - Size uint64 - LockOwner uint64 // unused on OS X? - Atime uint64 - Mtime uint64 - Unused2 uint64 - AtimeNsec uint32 - MtimeNsec uint32 - Unused3 uint32 - Mode uint32 - Unused4 uint32 - Uid uint32 - Gid uint32 - Unused5 uint32 -} - -type openIn struct { - Flags uint32 - Unused uint32 -} - -type openOut struct { - Fh uint64 - OpenFlags uint32 - _ uint32 -} - -type createIn struct { - Flags uint32 - Mode uint32 - Umask uint32 - _ uint32 -} - -func createInSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 12}): - return unsafe.Offsetof(createIn{}.Umask) - default: - return unsafe.Sizeof(createIn{}) - } -} - -type releaseIn struct { - Fh uint64 - Flags uint32 - ReleaseFlags uint32 - LockOwner uint32 -} - -type flushIn struct { - Fh uint64 - FlushFlags uint32 - _ uint32 - LockOwner uint64 -} - -type readIn struct { - Fh uint64 - Offset uint64 - Size uint32 - ReadFlags uint32 - LockOwner uint64 - Flags uint32 - _ uint32 -} - -func readInSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 9}): - return unsafe.Offsetof(readIn{}.ReadFlags) + 4 - default: - return unsafe.Sizeof(readIn{}) - } -} - -// The ReadFlags are passed in ReadRequest. -type ReadFlags uint32 - -const ( - // LockOwner field is valid. - ReadLockOwner ReadFlags = 1 << 1 -) - -var readFlagNames = []flagName{ - {uint32(ReadLockOwner), "ReadLockOwner"}, -} - -func (fl ReadFlags) String() string { - return flagString(uint32(fl), readFlagNames) -} - -type writeIn struct { - Fh uint64 - Offset uint64 - Size uint32 - WriteFlags uint32 - LockOwner uint64 - Flags uint32 - _ uint32 -} - -func writeInSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 9}): - return unsafe.Offsetof(writeIn{}.LockOwner) - default: - return unsafe.Sizeof(writeIn{}) - } -} - -type writeOut struct { - Size uint32 - _ uint32 -} - -// The WriteFlags are passed in WriteRequest. -type WriteFlags uint32 - -const ( - WriteCache WriteFlags = 1 << 0 - // LockOwner field is valid. - WriteLockOwner WriteFlags = 1 << 1 -) - -var writeFlagNames = []flagName{ - {uint32(WriteCache), "WriteCache"}, - {uint32(WriteLockOwner), "WriteLockOwner"}, -} - -func (fl WriteFlags) String() string { - return flagString(uint32(fl), writeFlagNames) -} - -const compatStatfsSize = 48 - -type statfsOut struct { - St kstatfs -} - -type fsyncIn struct { - Fh uint64 - FsyncFlags uint32 - _ uint32 -} - -type setxattrInCommon struct { - Size uint32 - Flags uint32 -} - -func (setxattrInCommon) position() uint32 { - return 0 -} - -type getxattrInCommon struct { - Size uint32 - _ uint32 -} - -func (getxattrInCommon) position() uint32 { - return 0 -} - -type getxattrOut struct { - Size uint32 - _ uint32 -} - -type lkIn struct { - Fh uint64 - Owner uint64 - Lk fileLock - LkFlags uint32 - _ uint32 -} - -func lkInSize(p Protocol) uintptr { - switch { - case p.LT(Protocol{7, 9}): - return unsafe.Offsetof(lkIn{}.LkFlags) - default: - return unsafe.Sizeof(lkIn{}) - } -} - -type lkOut struct { - Lk fileLock -} - -type accessIn struct { - Mask uint32 - _ uint32 -} - -type initIn struct { - Major uint32 - Minor uint32 - MaxReadahead uint32 - Flags uint32 -} - -const initInSize = int(unsafe.Sizeof(initIn{})) - -type initOut struct { - Major uint32 - Minor uint32 - MaxReadahead uint32 - Flags uint32 - Unused uint32 - MaxWrite uint32 -} - -type interruptIn struct { - Unique uint64 -} - -type bmapIn struct { - Block uint64 - BlockSize uint32 - _ uint32 -} - -type bmapOut struct { - Block uint64 -} - -type inHeader struct { - Len uint32 - Opcode uint32 - Unique uint64 - Nodeid uint64 - Uid uint32 - Gid uint32 - Pid uint32 - _ uint32 -} - -const inHeaderSize = int(unsafe.Sizeof(inHeader{})) - -type outHeader struct { - Len uint32 - Error int32 - Unique uint64 -} - -type dirent struct { - Ino uint64 - Off uint64 - Namelen uint32 - Type uint32 - Name [0]byte -} - -const direntSize = 8 + 8 + 4 + 4 - -const ( - notifyCodePoll int32 = 1 - notifyCodeInvalInode int32 = 2 - notifyCodeInvalEntry int32 = 3 -) - -type notifyInvalInodeOut struct { - Ino uint64 - Off int64 - Len int64 -} - -type notifyInvalEntryOut struct { - Parent uint64 - Namelen uint32 - _ uint32 -} diff --git a/vendor/bazil.org/fuse/fuse_kernel_darwin.go b/vendor/bazil.org/fuse/fuse_kernel_darwin.go deleted file mode 100644 index b9873fdf..00000000 --- a/vendor/bazil.org/fuse/fuse_kernel_darwin.go +++ /dev/null @@ -1,88 +0,0 @@ -package fuse - -import ( - "time" -) - -type attr struct { - Ino uint64 - Size uint64 - Blocks uint64 - Atime uint64 - Mtime uint64 - Ctime uint64 - Crtime_ uint64 // OS X only - AtimeNsec uint32 - MtimeNsec uint32 - CtimeNsec uint32 - CrtimeNsec uint32 // OS X only - Mode uint32 - Nlink uint32 - Uid uint32 - Gid uint32 - Rdev uint32 - Flags_ uint32 // OS X only; see chflags(2) - Blksize uint32 - padding uint32 -} - -func (a *attr) SetCrtime(s uint64, ns uint32) { - a.Crtime_, a.CrtimeNsec = s, ns -} - -func (a *attr) SetFlags(f uint32) { - a.Flags_ = f -} - -type setattrIn struct { - setattrInCommon - - // OS X only - Bkuptime_ uint64 - Chgtime_ uint64 - Crtime uint64 - BkuptimeNsec uint32 - ChgtimeNsec uint32 - CrtimeNsec uint32 - Flags_ uint32 // see chflags(2) -} - -func (in *setattrIn) BkupTime() time.Time { - return time.Unix(int64(in.Bkuptime_), int64(in.BkuptimeNsec)) -} - -func (in *setattrIn) Chgtime() time.Time { - return time.Unix(int64(in.Chgtime_), int64(in.ChgtimeNsec)) -} - -func (in *setattrIn) Flags() uint32 { - return in.Flags_ -} - -func openFlags(flags uint32) OpenFlags { - return OpenFlags(flags) -} - -type getxattrIn struct { - getxattrInCommon - - // OS X only - Position uint32 - Padding uint32 -} - -func (g *getxattrIn) position() uint32 { - return g.Position -} - -type setxattrIn struct { - setxattrInCommon - - // OS X only - Position uint32 - Padding uint32 -} - -func (s *setxattrIn) position() uint32 { - return s.Position -} diff --git a/vendor/bazil.org/fuse/fuse_kernel_freebsd.go b/vendor/bazil.org/fuse/fuse_kernel_freebsd.go deleted file mode 100644 index b1141e41..00000000 --- a/vendor/bazil.org/fuse/fuse_kernel_freebsd.go +++ /dev/null @@ -1,62 +0,0 @@ -package fuse - -import "time" - -type attr struct { - Ino uint64 - Size uint64 - Blocks uint64 - Atime uint64 - Mtime uint64 - Ctime uint64 - AtimeNsec uint32 - MtimeNsec uint32 - CtimeNsec uint32 - Mode uint32 - Nlink uint32 - Uid uint32 - Gid uint32 - Rdev uint32 - Blksize uint32 - padding uint32 -} - -func (a *attr) Crtime() time.Time { - return time.Time{} -} - -func (a *attr) SetCrtime(s uint64, ns uint32) { - // ignored on freebsd -} - -func (a *attr) SetFlags(f uint32) { - // ignored on freebsd -} - -type setattrIn struct { - setattrInCommon -} - -func (in *setattrIn) BkupTime() time.Time { - return time.Time{} -} - -func (in *setattrIn) Chgtime() time.Time { - return time.Time{} -} - -func (in *setattrIn) Flags() uint32 { - return 0 -} - -func openFlags(flags uint32) OpenFlags { - return OpenFlags(flags) -} - -type getxattrIn struct { - getxattrInCommon -} - -type setxattrIn struct { - setxattrInCommon -} diff --git a/vendor/bazil.org/fuse/fuse_kernel_linux.go b/vendor/bazil.org/fuse/fuse_kernel_linux.go deleted file mode 100644 index d3ba8661..00000000 --- a/vendor/bazil.org/fuse/fuse_kernel_linux.go +++ /dev/null @@ -1,70 +0,0 @@ -package fuse - -import "time" - -type attr struct { - Ino uint64 - Size uint64 - Blocks uint64 - Atime uint64 - Mtime uint64 - Ctime uint64 - AtimeNsec uint32 - MtimeNsec uint32 - CtimeNsec uint32 - Mode uint32 - Nlink uint32 - Uid uint32 - Gid uint32 - Rdev uint32 - Blksize uint32 - padding uint32 -} - -func (a *attr) Crtime() time.Time { - return time.Time{} -} - -func (a *attr) SetCrtime(s uint64, ns uint32) { - // Ignored on Linux. -} - -func (a *attr) SetFlags(f uint32) { - // Ignored on Linux. -} - -type setattrIn struct { - setattrInCommon -} - -func (in *setattrIn) BkupTime() time.Time { - return time.Time{} -} - -func (in *setattrIn) Chgtime() time.Time { - return time.Time{} -} - -func (in *setattrIn) Flags() uint32 { - return 0 -} - -func openFlags(flags uint32) OpenFlags { - // on amd64, the 32-bit O_LARGEFILE flag is always seen; - // on i386, the flag probably depends on the app - // requesting, but in any case should be utterly - // uninteresting to us here; our kernel protocol messages - // are not directly related to the client app's kernel - // API/ABI - flags &^= 0x8000 - - return OpenFlags(flags) -} - -type getxattrIn struct { - getxattrInCommon -} - -type setxattrIn struct { - setxattrInCommon -} diff --git a/vendor/bazil.org/fuse/fuse_kernel_std.go b/vendor/bazil.org/fuse/fuse_kernel_std.go deleted file mode 100644 index 074cfd32..00000000 --- a/vendor/bazil.org/fuse/fuse_kernel_std.go +++ /dev/null @@ -1 +0,0 @@ -package fuse diff --git a/vendor/bazil.org/fuse/fuse_linux.go b/vendor/bazil.org/fuse/fuse_linux.go deleted file mode 100644 index 5fb96f9a..00000000 --- a/vendor/bazil.org/fuse/fuse_linux.go +++ /dev/null @@ -1,7 +0,0 @@ -package fuse - -// Maximum file write size we are prepared to receive from the kernel. -// -// Linux 4.2.0 has been observed to cap this value at 128kB -// (FUSE_MAX_PAGES_PER_REQ=32, 4kB pages). -const maxWrite = 128 * 1024 diff --git a/vendor/bazil.org/fuse/fuseutil/fuseutil.go b/vendor/bazil.org/fuse/fuseutil/fuseutil.go deleted file mode 100644 index b3f52b73..00000000 --- a/vendor/bazil.org/fuse/fuseutil/fuseutil.go +++ /dev/null @@ -1,20 +0,0 @@ -package fuseutil // import "bazil.org/fuse/fuseutil" - -import ( - "bazil.org/fuse" -) - -// HandleRead handles a read request assuming that data is the entire file content. -// It adjusts the amount returned in resp according to req.Offset and req.Size. -func HandleRead(req *fuse.ReadRequest, resp *fuse.ReadResponse, data []byte) { - if req.Offset >= int64(len(data)) { - data = nil - } else { - data = data[req.Offset:] - } - if len(data) > req.Size { - data = data[:req.Size] - } - n := copy(resp.Data[:req.Size], data) - resp.Data = resp.Data[:n] -} diff --git a/vendor/bazil.org/fuse/mount.go b/vendor/bazil.org/fuse/mount.go deleted file mode 100644 index 8054e902..00000000 --- a/vendor/bazil.org/fuse/mount.go +++ /dev/null @@ -1,38 +0,0 @@ -package fuse - -import ( - "bufio" - "errors" - "io" - "log" - "sync" -) - -var ( - // ErrOSXFUSENotFound is returned from Mount when the OSXFUSE - // installation is not detected. - // - // Only happens on OS X. Make sure OSXFUSE is installed, or see - // OSXFUSELocations for customization. - ErrOSXFUSENotFound = errors.New("cannot locate OSXFUSE") -) - -func neverIgnoreLine(line string) bool { - return false -} - -func lineLogger(wg *sync.WaitGroup, prefix string, ignore func(line string) bool, r io.ReadCloser) { - defer wg.Done() - - scanner := bufio.NewScanner(r) - for scanner.Scan() { - line := scanner.Text() - if ignore(line) { - continue - } - log.Printf("%s: %s", prefix, line) - } - if err := scanner.Err(); err != nil { - log.Printf("%s, error reading: %v", prefix, err) - } -} diff --git a/vendor/bazil.org/fuse/mount_darwin.go b/vendor/bazil.org/fuse/mount_darwin.go deleted file mode 100644 index c1c36e62..00000000 --- a/vendor/bazil.org/fuse/mount_darwin.go +++ /dev/null @@ -1,208 +0,0 @@ -package fuse - -import ( - "errors" - "fmt" - "log" - "os" - "os/exec" - "path" - "strconv" - "strings" - "sync" - "syscall" -) - -var ( - errNoAvail = errors.New("no available fuse devices") - errNotLoaded = errors.New("osxfuse is not loaded") -) - -func loadOSXFUSE(bin string) error { - cmd := exec.Command(bin) - cmd.Dir = "/" - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - return err -} - -func openOSXFUSEDev(devPrefix string) (*os.File, error) { - var f *os.File - var err error - for i := uint64(0); ; i++ { - path := devPrefix + strconv.FormatUint(i, 10) - f, err = os.OpenFile(path, os.O_RDWR, 0000) - if os.IsNotExist(err) { - if i == 0 { - // not even the first device was found -> fuse is not loaded - return nil, errNotLoaded - } - - // we've run out of kernel-provided devices - return nil, errNoAvail - } - - if err2, ok := err.(*os.PathError); ok && err2.Err == syscall.EBUSY { - // try the next one - continue - } - - if err != nil { - return nil, err - } - return f, nil - } -} - -func handleMountOSXFUSE(helperName string, errCh chan<- error) func(line string) (ignore bool) { - var noMountpointPrefix = helperName + `: ` - const noMountpointSuffix = `: No such file or directory` - return func(line string) (ignore bool) { - if strings.HasPrefix(line, noMountpointPrefix) && strings.HasSuffix(line, noMountpointSuffix) { - // re-extract it from the error message in case some layer - // changed the path - mountpoint := line[len(noMountpointPrefix) : len(line)-len(noMountpointSuffix)] - err := &MountpointDoesNotExistError{ - Path: mountpoint, - } - select { - case errCh <- err: - return true - default: - // not the first error; fall back to logging it - return false - } - } - - return false - } -} - -// isBoringMountOSXFUSEError returns whether the Wait error is -// uninteresting; exit status 64 is. -func isBoringMountOSXFUSEError(err error) bool { - if err, ok := err.(*exec.ExitError); ok && err.Exited() { - if status, ok := err.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 64 { - return true - } - } - return false -} - -func callMount(bin string, daemonVar string, dir string, conf *mountConfig, f *os.File, ready chan<- struct{}, errp *error) error { - for k, v := range conf.options { - if strings.Contains(k, ",") || strings.Contains(v, ",") { - // Silly limitation but the mount helper does not - // understand any escaping. See TestMountOptionCommaError. - return fmt.Errorf("mount options cannot contain commas on darwin: %q=%q", k, v) - } - } - cmd := exec.Command( - bin, - "-o", conf.getOptions(), - // Tell osxfuse-kext how large our buffer is. It must split - // writes larger than this into multiple writes. - // - // OSXFUSE seems to ignore InitResponse.MaxWrite, and uses - // this instead. - "-o", "iosize="+strconv.FormatUint(maxWrite, 10), - // refers to fd passed in cmd.ExtraFiles - "3", - dir, - ) - cmd.ExtraFiles = []*os.File{f} - cmd.Env = os.Environ() - // OSXFUSE <3.3.0 - cmd.Env = append(cmd.Env, "MOUNT_FUSEFS_CALL_BY_LIB=") - // OSXFUSE >=3.3.0 - cmd.Env = append(cmd.Env, "MOUNT_OSXFUSE_CALL_BY_LIB=") - - daemon := os.Args[0] - if daemonVar != "" { - cmd.Env = append(cmd.Env, daemonVar+"="+daemon) - } - - stdout, err := cmd.StdoutPipe() - if err != nil { - return fmt.Errorf("setting up mount_osxfusefs stderr: %v", err) - } - stderr, err := cmd.StderrPipe() - if err != nil { - return fmt.Errorf("setting up mount_osxfusefs stderr: %v", err) - } - - if err := cmd.Start(); err != nil { - return fmt.Errorf("mount_osxfusefs: %v", err) - } - helperErrCh := make(chan error, 1) - go func() { - var wg sync.WaitGroup - wg.Add(2) - go lineLogger(&wg, "mount helper output", neverIgnoreLine, stdout) - helperName := path.Base(bin) - go lineLogger(&wg, "mount helper error", handleMountOSXFUSE(helperName, helperErrCh), stderr) - wg.Wait() - if err := cmd.Wait(); err != nil { - // see if we have a better error to report - select { - case helperErr := <-helperErrCh: - // log the Wait error if it's not what we expected - if !isBoringMountOSXFUSEError(err) { - log.Printf("mount helper failed: %v", err) - } - // and now return what we grabbed from stderr as the real - // error - *errp = helperErr - close(ready) - return - default: - // nope, fall back to generic message - } - - *errp = fmt.Errorf("mount_osxfusefs: %v", err) - close(ready) - return - } - - *errp = nil - close(ready) - }() - return nil -} - -func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) { - locations := conf.osxfuseLocations - if locations == nil { - locations = []OSXFUSEPaths{ - OSXFUSELocationV3, - OSXFUSELocationV2, - } - } - for _, loc := range locations { - if _, err := os.Stat(loc.Mount); os.IsNotExist(err) { - // try the other locations - continue - } - - f, err := openOSXFUSEDev(loc.DevicePrefix) - if err == errNotLoaded { - err = loadOSXFUSE(loc.Load) - if err != nil { - return nil, err - } - // try again - f, err = openOSXFUSEDev(loc.DevicePrefix) - } - if err != nil { - return nil, err - } - err = callMount(loc.Mount, loc.DaemonVar, dir, conf, f, ready, errp) - if err != nil { - f.Close() - return nil, err - } - return f, nil - } - return nil, ErrOSXFUSENotFound -} diff --git a/vendor/bazil.org/fuse/mount_freebsd.go b/vendor/bazil.org/fuse/mount_freebsd.go deleted file mode 100644 index 70bb4102..00000000 --- a/vendor/bazil.org/fuse/mount_freebsd.go +++ /dev/null @@ -1,111 +0,0 @@ -package fuse - -import ( - "fmt" - "log" - "os" - "os/exec" - "strings" - "sync" - "syscall" -) - -func handleMountFusefsStderr(errCh chan<- error) func(line string) (ignore bool) { - return func(line string) (ignore bool) { - const ( - noMountpointPrefix = `mount_fusefs: ` - noMountpointSuffix = `: No such file or directory` - ) - if strings.HasPrefix(line, noMountpointPrefix) && strings.HasSuffix(line, noMountpointSuffix) { - // re-extract it from the error message in case some layer - // changed the path - mountpoint := line[len(noMountpointPrefix) : len(line)-len(noMountpointSuffix)] - err := &MountpointDoesNotExistError{ - Path: mountpoint, - } - select { - case errCh <- err: - return true - default: - // not the first error; fall back to logging it - return false - } - } - - return false - } -} - -// isBoringMountFusefsError returns whether the Wait error is -// uninteresting; exit status 1 is. -func isBoringMountFusefsError(err error) bool { - if err, ok := err.(*exec.ExitError); ok && err.Exited() { - if status, ok := err.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 1 { - return true - } - } - return false -} - -func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) { - for k, v := range conf.options { - if strings.Contains(k, ",") || strings.Contains(v, ",") { - // Silly limitation but the mount helper does not - // understand any escaping. See TestMountOptionCommaError. - return nil, fmt.Errorf("mount options cannot contain commas on FreeBSD: %q=%q", k, v) - } - } - - f, err := os.OpenFile("/dev/fuse", os.O_RDWR, 0000) - if err != nil { - *errp = err - return nil, err - } - - cmd := exec.Command( - "/sbin/mount_fusefs", - "--safe", - "-o", conf.getOptions(), - "3", - dir, - ) - cmd.ExtraFiles = []*os.File{f} - - stdout, err := cmd.StdoutPipe() - if err != nil { - return nil, fmt.Errorf("setting up mount_fusefs stderr: %v", err) - } - stderr, err := cmd.StderrPipe() - if err != nil { - return nil, fmt.Errorf("setting up mount_fusefs stderr: %v", err) - } - - if err := cmd.Start(); err != nil { - return nil, fmt.Errorf("mount_fusefs: %v", err) - } - helperErrCh := make(chan error, 1) - var wg sync.WaitGroup - wg.Add(2) - go lineLogger(&wg, "mount helper output", neverIgnoreLine, stdout) - go lineLogger(&wg, "mount helper error", handleMountFusefsStderr(helperErrCh), stderr) - wg.Wait() - if err := cmd.Wait(); err != nil { - // see if we have a better error to report - select { - case helperErr := <-helperErrCh: - // log the Wait error if it's not what we expected - if !isBoringMountFusefsError(err) { - log.Printf("mount helper failed: %v", err) - } - // and now return what we grabbed from stderr as the real - // error - return nil, helperErr - default: - // nope, fall back to generic message - } - return nil, fmt.Errorf("mount_fusefs: %v", err) - } - - close(ready) - return f, nil -} diff --git a/vendor/bazil.org/fuse/mount_linux.go b/vendor/bazil.org/fuse/mount_linux.go deleted file mode 100644 index 197d1044..00000000 --- a/vendor/bazil.org/fuse/mount_linux.go +++ /dev/null @@ -1,150 +0,0 @@ -package fuse - -import ( - "fmt" - "log" - "net" - "os" - "os/exec" - "strings" - "sync" - "syscall" -) - -func handleFusermountStderr(errCh chan<- error) func(line string) (ignore bool) { - return func(line string) (ignore bool) { - if line == `fusermount: failed to open /etc/fuse.conf: Permission denied` { - // Silence this particular message, it occurs way too - // commonly and isn't very relevant to whether the mount - // succeeds or not. - return true - } - - const ( - noMountpointPrefix = `fusermount: failed to access mountpoint ` - noMountpointSuffix = `: No such file or directory` - ) - if strings.HasPrefix(line, noMountpointPrefix) && strings.HasSuffix(line, noMountpointSuffix) { - // re-extract it from the error message in case some layer - // changed the path - mountpoint := line[len(noMountpointPrefix) : len(line)-len(noMountpointSuffix)] - err := &MountpointDoesNotExistError{ - Path: mountpoint, - } - select { - case errCh <- err: - return true - default: - // not the first error; fall back to logging it - return false - } - } - - return false - } -} - -// isBoringFusermountError returns whether the Wait error is -// uninteresting; exit status 1 is. -func isBoringFusermountError(err error) bool { - if err, ok := err.(*exec.ExitError); ok && err.Exited() { - if status, ok := err.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 1 { - return true - } - } - return false -} - -func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (fusefd *os.File, err error) { - // linux mount is never delayed - close(ready) - - fds, err := syscall.Socketpair(syscall.AF_FILE, syscall.SOCK_STREAM, 0) - if err != nil { - return nil, fmt.Errorf("socketpair error: %v", err) - } - - writeFile := os.NewFile(uintptr(fds[0]), "fusermount-child-writes") - defer writeFile.Close() - - readFile := os.NewFile(uintptr(fds[1]), "fusermount-parent-reads") - defer readFile.Close() - - cmd := exec.Command( - "fusermount", - "-o", conf.getOptions(), - "--", - dir, - ) - cmd.Env = append(os.Environ(), "_FUSE_COMMFD=3") - - cmd.ExtraFiles = []*os.File{writeFile} - - var wg sync.WaitGroup - stdout, err := cmd.StdoutPipe() - if err != nil { - return nil, fmt.Errorf("setting up fusermount stderr: %v", err) - } - stderr, err := cmd.StderrPipe() - if err != nil { - return nil, fmt.Errorf("setting up fusermount stderr: %v", err) - } - - if err := cmd.Start(); err != nil { - return nil, fmt.Errorf("fusermount: %v", err) - } - helperErrCh := make(chan error, 1) - wg.Add(2) - go lineLogger(&wg, "mount helper output", neverIgnoreLine, stdout) - go lineLogger(&wg, "mount helper error", handleFusermountStderr(helperErrCh), stderr) - wg.Wait() - if err := cmd.Wait(); err != nil { - // see if we have a better error to report - select { - case helperErr := <-helperErrCh: - // log the Wait error if it's not what we expected - if !isBoringFusermountError(err) { - log.Printf("mount helper failed: %v", err) - } - // and now return what we grabbed from stderr as the real - // error - return nil, helperErr - default: - // nope, fall back to generic message - } - - return nil, fmt.Errorf("fusermount: %v", err) - } - - c, err := net.FileConn(readFile) - if err != nil { - return nil, fmt.Errorf("FileConn from fusermount socket: %v", err) - } - defer c.Close() - - uc, ok := c.(*net.UnixConn) - if !ok { - return nil, fmt.Errorf("unexpected FileConn type; expected UnixConn, got %T", c) - } - - buf := make([]byte, 32) // expect 1 byte - oob := make([]byte, 32) // expect 24 bytes - _, oobn, _, _, err := uc.ReadMsgUnix(buf, oob) - scms, err := syscall.ParseSocketControlMessage(oob[:oobn]) - if err != nil { - return nil, fmt.Errorf("ParseSocketControlMessage: %v", err) - } - if len(scms) != 1 { - return nil, fmt.Errorf("expected 1 SocketControlMessage; got scms = %#v", scms) - } - scm := scms[0] - gotFds, err := syscall.ParseUnixRights(&scm) - if err != nil { - return nil, fmt.Errorf("syscall.ParseUnixRights: %v", err) - } - if len(gotFds) != 1 { - return nil, fmt.Errorf("wanted 1 fd; got %#v", gotFds) - } - f := os.NewFile(uintptr(gotFds[0]), "/dev/fuse") - return f, nil -} diff --git a/vendor/bazil.org/fuse/options.go b/vendor/bazil.org/fuse/options.go deleted file mode 100644 index 1ea42d03..00000000 --- a/vendor/bazil.org/fuse/options.go +++ /dev/null @@ -1,279 +0,0 @@ -package fuse - -import ( - "errors" - "strings" -) - -func dummyOption(conf *mountConfig) error { - return nil -} - -// mountConfig holds the configuration for a mount operation. -// Use it by passing MountOption values to Mount. -type mountConfig struct { - options map[string]string - maxReadahead uint32 - initFlags InitFlags - osxfuseLocations []OSXFUSEPaths -} - -func escapeComma(s string) string { - s = strings.Replace(s, `\`, `\\`, -1) - s = strings.Replace(s, `,`, `\,`, -1) - return s -} - -// getOptions makes a string of options suitable for passing to FUSE -// mount flag `-o`. Returns an empty string if no options were set. -// Any platform specific adjustments should happen before the call. -func (m *mountConfig) getOptions() string { - var opts []string - for k, v := range m.options { - k = escapeComma(k) - if v != "" { - k += "=" + escapeComma(v) - } - opts = append(opts, k) - } - return strings.Join(opts, ",") -} - -type mountOption func(*mountConfig) error - -// MountOption is passed to Mount to change the behavior of the mount. -type MountOption mountOption - -// FSName sets the file system name (also called source) that is -// visible in the list of mounted file systems. -// -// FreeBSD ignores this option. -func FSName(name string) MountOption { - return func(conf *mountConfig) error { - conf.options["fsname"] = name - return nil - } -} - -// Subtype sets the subtype of the mount. The main type is always -// `fuse`. The type in a list of mounted file systems will look like -// `fuse.foo`. -// -// OS X ignores this option. -// FreeBSD ignores this option. -func Subtype(fstype string) MountOption { - return func(conf *mountConfig) error { - conf.options["subtype"] = fstype - return nil - } -} - -// LocalVolume sets the volume to be local (instead of network), -// changing the behavior of Finder, Spotlight, and such. -// -// OS X only. Others ignore this option. -func LocalVolume() MountOption { - return localVolume -} - -// VolumeName sets the volume name shown in Finder. -// -// OS X only. Others ignore this option. -func VolumeName(name string) MountOption { - return volumeName(name) -} - -// NoAppleDouble makes OSXFUSE disallow files with names used by OS X -// to store extended attributes on file systems that do not support -// them natively. -// -// Such file names are: -// -// ._* -// .DS_Store -// -// OS X only. Others ignore this option. -func NoAppleDouble() MountOption { - return noAppleDouble -} - -// NoAppleXattr makes OSXFUSE disallow extended attributes with the -// prefix "com.apple.". This disables persistent Finder state and -// other such information. -// -// OS X only. Others ignore this option. -func NoAppleXattr() MountOption { - return noAppleXattr -} - -// DaemonTimeout sets the time in seconds between a request and a reply before -// the FUSE mount is declared dead. -// -// OS X and FreeBSD only. Others ignore this option. -func DaemonTimeout(name string) MountOption { - return daemonTimeout(name) -} - -var ErrCannotCombineAllowOtherAndAllowRoot = errors.New("cannot combine AllowOther and AllowRoot") - -// AllowOther allows other users to access the file system. -// -// Only one of AllowOther or AllowRoot can be used. -func AllowOther() MountOption { - return func(conf *mountConfig) error { - if _, ok := conf.options["allow_root"]; ok { - return ErrCannotCombineAllowOtherAndAllowRoot - } - conf.options["allow_other"] = "" - return nil - } -} - -// AllowRoot allows other users to access the file system. -// -// Only one of AllowOther or AllowRoot can be used. -// -// FreeBSD ignores this option. -func AllowRoot() MountOption { - return func(conf *mountConfig) error { - if _, ok := conf.options["allow_other"]; ok { - return ErrCannotCombineAllowOtherAndAllowRoot - } - conf.options["allow_root"] = "" - return nil - } -} - -// AllowDev enables interpreting character or block special devices on the -// filesystem. -func AllowDev() MountOption { - return func(conf *mountConfig) error { - conf.options["dev"] = "" - return nil - } -} - -// AllowSUID allows set-user-identifier or set-group-identifier bits to take -// effect. -func AllowSUID() MountOption { - return func(conf *mountConfig) error { - conf.options["suid"] = "" - return nil - } -} - -// DefaultPermissions makes the kernel enforce access control based on -// the file mode (as in chmod). -// -// Without this option, the Node itself decides what is and is not -// allowed. This is normally ok because FUSE file systems cannot be -// accessed by other users without AllowOther/AllowRoot. -// -// FreeBSD ignores this option. -func DefaultPermissions() MountOption { - return func(conf *mountConfig) error { - conf.options["default_permissions"] = "" - return nil - } -} - -// ReadOnly makes the mount read-only. -func ReadOnly() MountOption { - return func(conf *mountConfig) error { - conf.options["ro"] = "" - return nil - } -} - -// MaxReadahead sets the number of bytes that can be prefetched for -// sequential reads. The kernel can enforce a maximum value lower than -// this. -// -// This setting makes the kernel perform speculative reads that do not -// originate from any client process. This usually tremendously -// improves read performance. -func MaxReadahead(n uint32) MountOption { - return func(conf *mountConfig) error { - conf.maxReadahead = n - return nil - } -} - -// AsyncRead enables multiple outstanding read requests for the same -// handle. Without this, there is at most one request in flight at a -// time. -func AsyncRead() MountOption { - return func(conf *mountConfig) error { - conf.initFlags |= InitAsyncRead - return nil - } -} - -func AsyncDIO() MountOption { - return func(conf *mountConfig) error { - conf.initFlags |= InitAsyncDIO - return nil - } -} - -// WritebackCache enables the kernel to buffer writes before sending -// them to the FUSE server. Without this, writethrough caching is -// used. -func WritebackCache() MountOption { - return func(conf *mountConfig) error { - conf.initFlags |= InitWritebackCache - return nil - } -} - -// OSXFUSEPaths describes the paths used by an installed OSXFUSE -// version. See OSXFUSELocationV3 for typical values. -type OSXFUSEPaths struct { - // Prefix for the device file. At mount time, an incrementing - // number is suffixed until a free FUSE device is found. - DevicePrefix string - // Path of the load helper, used to load the kernel extension if - // no device files are found. - Load string - // Path of the mount helper, used for the actual mount operation. - Mount string - // Environment variable used to pass the path to the executable - // calling the mount helper. - DaemonVar string -} - -// Default paths for OSXFUSE. See OSXFUSELocations. -var ( - OSXFUSELocationV3 = OSXFUSEPaths{ - DevicePrefix: "/dev/osxfuse", - Load: "/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse", - Mount: "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", - DaemonVar: "MOUNT_OSXFUSE_DAEMON_PATH", - } - OSXFUSELocationV2 = OSXFUSEPaths{ - DevicePrefix: "/dev/osxfuse", - Load: "/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", - Mount: "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", - DaemonVar: "MOUNT_FUSEFS_DAEMON_PATH", - } -) - -// OSXFUSELocations sets where to look for OSXFUSE files. The -// arguments are all the possible locations. The previous locations -// are replaced. -// -// Without this option, OSXFUSELocationV3 and OSXFUSELocationV2 are -// used. -// -// OS X only. Others ignore this option. -func OSXFUSELocations(paths ...OSXFUSEPaths) MountOption { - return func(conf *mountConfig) error { - if len(paths) == 0 { - return errors.New("must specify at least one location for OSXFUSELocations") - } - // replace previous values, but make a copy so there's no - // worries about caller mutating their slice - conf.osxfuseLocations = append(conf.osxfuseLocations[:0], paths...) - return nil - } -} diff --git a/vendor/bazil.org/fuse/options_darwin.go b/vendor/bazil.org/fuse/options_darwin.go deleted file mode 100644 index b5340246..00000000 --- a/vendor/bazil.org/fuse/options_darwin.go +++ /dev/null @@ -1,30 +0,0 @@ -package fuse - -func localVolume(conf *mountConfig) error { - conf.options["local"] = "" - return nil -} - -func volumeName(name string) MountOption { - return func(conf *mountConfig) error { - conf.options["volname"] = name - return nil - } -} - -func daemonTimeout(name string) MountOption { - return func(conf *mountConfig) error { - conf.options["daemon_timeout"] = name - return nil - } -} - -func noAppleXattr(conf *mountConfig) error { - conf.options["noapplexattr"] = "" - return nil -} - -func noAppleDouble(conf *mountConfig) error { - conf.options["noappledouble"] = "" - return nil -} diff --git a/vendor/bazil.org/fuse/options_freebsd.go b/vendor/bazil.org/fuse/options_freebsd.go deleted file mode 100644 index 2387124c..00000000 --- a/vendor/bazil.org/fuse/options_freebsd.go +++ /dev/null @@ -1,24 +0,0 @@ -package fuse - -func localVolume(conf *mountConfig) error { - return nil -} - -func volumeName(name string) MountOption { - return dummyOption -} - -func daemonTimeout(name string) MountOption { - return func(conf *mountConfig) error { - conf.options["timeout"] = name - return nil - } -} - -func noAppleXattr(conf *mountConfig) error { - return nil -} - -func noAppleDouble(conf *mountConfig) error { - return nil -} diff --git a/vendor/bazil.org/fuse/options_linux.go b/vendor/bazil.org/fuse/options_linux.go deleted file mode 100644 index 77b46a50..00000000 --- a/vendor/bazil.org/fuse/options_linux.go +++ /dev/null @@ -1,21 +0,0 @@ -package fuse - -func localVolume(conf *mountConfig) error { - return nil -} - -func volumeName(name string) MountOption { - return dummyOption -} - -func daemonTimeout(name string) MountOption { - return dummyOption -} - -func noAppleXattr(conf *mountConfig) error { - return nil -} - -func noAppleDouble(conf *mountConfig) error { - return nil -} diff --git a/vendor/bazil.org/fuse/protocol.go b/vendor/bazil.org/fuse/protocol.go deleted file mode 100644 index a77bbf72..00000000 --- a/vendor/bazil.org/fuse/protocol.go +++ /dev/null @@ -1,75 +0,0 @@ -package fuse - -import ( - "fmt" -) - -// Protocol is a FUSE protocol version number. -type Protocol struct { - Major uint32 - Minor uint32 -} - -func (p Protocol) String() string { - return fmt.Sprintf("%d.%d", p.Major, p.Minor) -} - -// LT returns whether a is less than b. -func (a Protocol) LT(b Protocol) bool { - return a.Major < b.Major || - (a.Major == b.Major && a.Minor < b.Minor) -} - -// GE returns whether a is greater than or equal to b. -func (a Protocol) GE(b Protocol) bool { - return a.Major > b.Major || - (a.Major == b.Major && a.Minor >= b.Minor) -} - -func (a Protocol) is79() bool { - return a.GE(Protocol{7, 9}) -} - -// HasAttrBlockSize returns whether Attr.BlockSize is respected by the -// kernel. -func (a Protocol) HasAttrBlockSize() bool { - return a.is79() -} - -// HasReadWriteFlags returns whether ReadRequest/WriteRequest -// fields Flags and FileFlags are valid. -func (a Protocol) HasReadWriteFlags() bool { - return a.is79() -} - -// HasGetattrFlags returns whether GetattrRequest field Flags is -// valid. -func (a Protocol) HasGetattrFlags() bool { - return a.is79() -} - -func (a Protocol) is710() bool { - return a.GE(Protocol{7, 10}) -} - -// HasOpenNonSeekable returns whether OpenResponse field Flags flag -// OpenNonSeekable is supported. -func (a Protocol) HasOpenNonSeekable() bool { - return a.is710() -} - -func (a Protocol) is712() bool { - return a.GE(Protocol{7, 12}) -} - -// HasUmask returns whether CreateRequest/MkdirRequest/MknodRequest -// field Umask is valid. -func (a Protocol) HasUmask() bool { - return a.is712() -} - -// HasInvalidate returns whether InvalidateNode/InvalidateEntry are -// supported. -func (a Protocol) HasInvalidate() bool { - return a.is712() -} diff --git a/vendor/bazil.org/fuse/unmount.go b/vendor/bazil.org/fuse/unmount.go deleted file mode 100644 index ffe3f155..00000000 --- a/vendor/bazil.org/fuse/unmount.go +++ /dev/null @@ -1,6 +0,0 @@ -package fuse - -// Unmount tries to unmount the filesystem mounted at dir. -func Unmount(dir string) error { - return unmount(dir) -} diff --git a/vendor/bazil.org/fuse/unmount_linux.go b/vendor/bazil.org/fuse/unmount_linux.go deleted file mode 100644 index 088f0cfe..00000000 --- a/vendor/bazil.org/fuse/unmount_linux.go +++ /dev/null @@ -1,21 +0,0 @@ -package fuse - -import ( - "bytes" - "errors" - "os/exec" -) - -func unmount(dir string) error { - cmd := exec.Command("fusermount", "-u", dir) - output, err := cmd.CombinedOutput() - if err != nil { - if len(output) > 0 { - output = bytes.TrimRight(output, "\n") - msg := err.Error() + ": " + string(output) - err = errors.New(msg) - } - return err - } - return nil -} diff --git a/vendor/bazil.org/fuse/unmount_std.go b/vendor/bazil.org/fuse/unmount_std.go deleted file mode 100644 index d6efe276..00000000 --- a/vendor/bazil.org/fuse/unmount_std.go +++ /dev/null @@ -1,17 +0,0 @@ -// +build !linux - -package fuse - -import ( - "os" - "syscall" -) - -func unmount(dir string) error { - err := syscall.Unmount(dir, 0) - if err != nil { - err = &os.PathError{Op: "unmount", Path: dir, Err: err} - return err - } - return nil -} diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go deleted file mode 100644 index 19235cf2..00000000 --- a/vendor/golang.org/x/net/context/context.go +++ /dev/null @@ -1,447 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package context defines the Context type, which carries deadlines, -// cancelation signals, and other request-scoped values across API boundaries -// and between processes. -// -// Incoming requests to a server should create a Context, and outgoing calls to -// servers should accept a Context. The chain of function calls between must -// propagate the Context, optionally replacing it with a modified copy created -// using WithDeadline, WithTimeout, WithCancel, or WithValue. -// -// Programs that use Contexts should follow these rules to keep interfaces -// consistent across packages and enable static analysis tools to check context -// propagation: -// -// Do not store Contexts inside a struct type; instead, pass a Context -// explicitly to each function that needs it. The Context should be the first -// parameter, typically named ctx: -// -// func DoSomething(ctx context.Context, arg Arg) error { -// // ... use ctx ... -// } -// -// Do not pass a nil Context, even if a function permits it. Pass context.TODO -// if you are unsure about which Context to use. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -// -// The same Context may be passed to functions running in different goroutines; -// Contexts are safe for simultaneous use by multiple goroutines. -// -// See http://blog.golang.org/context for example code for a server that uses -// Contexts. -package context // import "golang.org/x/net/context" - -import ( - "errors" - "fmt" - "sync" - "time" -) - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out <-chan Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = errors.New("context canceled") - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = errors.New("context deadline exceeded") - -// An emptyCtx is never canceled, has no values, and has no deadline. It is not -// struct{}, since vars of this type must have distinct addresses. -type emptyCtx int - -func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { - return -} - -func (*emptyCtx) Done() <-chan struct{} { - return nil -} - -func (*emptyCtx) Err() error { - return nil -} - -func (*emptyCtx) Value(key interface{}) interface{} { - return nil -} - -func (e *emptyCtx) String() string { - switch e { - case background: - return "context.Background" - case todo: - return "context.TODO" - } - return "unknown empty Context" -} - -var ( - background = new(emptyCtx) - todo = new(emptyCtx) -) - -// Background returns a non-nil, empty Context. It is never canceled, has no -// values, and has no deadline. It is typically used by the main function, -// initialization, and tests, and as the top-level Context for incoming -// requests. -func Background() Context { - return background -} - -// TODO returns a non-nil, empty Context. Code should use context.TODO when -// it's unclear which Context to use or it is not yet available (because the -// surrounding function has not yet been extended to accept a Context -// parameter). TODO is recognized by static analysis tools that determine -// whether Contexts are propagated correctly in a program. -func TODO() Context { - return todo -} - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - c := newCancelCtx(parent) - propagateCancel(parent, c) - return c, func() { c.cancel(true, Canceled) } -} - -// newCancelCtx returns an initialized cancelCtx. -func newCancelCtx(parent Context) *cancelCtx { - return &cancelCtx{ - Context: parent, - done: make(chan struct{}), - } -} - -// propagateCancel arranges for child to be canceled when parent is. -func propagateCancel(parent Context, child canceler) { - if parent.Done() == nil { - return // parent is never canceled - } - if p, ok := parentCancelCtx(parent); ok { - p.mu.Lock() - if p.err != nil { - // parent has already been canceled - child.cancel(false, p.err) - } else { - if p.children == nil { - p.children = make(map[canceler]bool) - } - p.children[child] = true - } - p.mu.Unlock() - } else { - go func() { - select { - case <-parent.Done(): - child.cancel(false, parent.Err()) - case <-child.Done(): - } - }() - } -} - -// parentCancelCtx follows a chain of parent references until it finds a -// *cancelCtx. This function understands how each of the concrete types in this -// package represents its parent. -func parentCancelCtx(parent Context) (*cancelCtx, bool) { - for { - switch c := parent.(type) { - case *cancelCtx: - return c, true - case *timerCtx: - return c.cancelCtx, true - case *valueCtx: - parent = c.Context - default: - return nil, false - } - } -} - -// removeChild removes a context from its parent. -func removeChild(parent Context, child canceler) { - p, ok := parentCancelCtx(parent) - if !ok { - return - } - p.mu.Lock() - if p.children != nil { - delete(p.children, child) - } - p.mu.Unlock() -} - -// A canceler is a context type that can be canceled directly. The -// implementations are *cancelCtx and *timerCtx. -type canceler interface { - cancel(removeFromParent bool, err error) - Done() <-chan struct{} -} - -// A cancelCtx can be canceled. When canceled, it also cancels any children -// that implement canceler. -type cancelCtx struct { - Context - - done chan struct{} // closed by the first cancel call. - - mu sync.Mutex - children map[canceler]bool // set to nil by the first cancel call - err error // set to non-nil by the first cancel call -} - -func (c *cancelCtx) Done() <-chan struct{} { - return c.done -} - -func (c *cancelCtx) Err() error { - c.mu.Lock() - defer c.mu.Unlock() - return c.err -} - -func (c *cancelCtx) String() string { - return fmt.Sprintf("%v.WithCancel", c.Context) -} - -// cancel closes c.done, cancels each of c's children, and, if -// removeFromParent is true, removes c from its parent's children. -func (c *cancelCtx) cancel(removeFromParent bool, err error) { - if err == nil { - panic("context: internal error: missing cancel error") - } - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return // already canceled - } - c.err = err - close(c.done) - for child := range c.children { - // NOTE: acquiring the child's lock while holding parent's lock. - child.cancel(false, err) - } - c.children = nil - c.mu.Unlock() - - if removeFromParent { - removeChild(c.Context, c) - } -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { - // The current deadline is already sooner than the new one. - return WithCancel(parent) - } - c := &timerCtx{ - cancelCtx: newCancelCtx(parent), - deadline: deadline, - } - propagateCancel(parent, c) - d := deadline.Sub(time.Now()) - if d <= 0 { - c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } - } - c.mu.Lock() - defer c.mu.Unlock() - if c.err == nil { - c.timer = time.AfterFunc(d, func() { - c.cancel(true, DeadlineExceeded) - }) - } - return c, func() { c.cancel(true, Canceled) } -} - -// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to -// implement Done and Err. It implements cancel by stopping its timer then -// delegating to cancelCtx.cancel. -type timerCtx struct { - *cancelCtx - timer *time.Timer // Under cancelCtx.mu. - - deadline time.Time -} - -func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { - return c.deadline, true -} - -func (c *timerCtx) String() string { - return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) -} - -func (c *timerCtx) cancel(removeFromParent bool, err error) { - c.cancelCtx.cancel(false, err) - if removeFromParent { - // Remove this timerCtx from its parent cancelCtx's children. - removeChild(c.cancelCtx.Context, c) - } - c.mu.Lock() - if c.timer != nil { - c.timer.Stop() - c.timer = nil - } - c.mu.Unlock() -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return &valueCtx{parent, key, val} -} - -// A valueCtx carries a key-value pair. It implements Value for that key and -// delegates all other calls to the embedded Context. -type valueCtx struct { - Context - key, val interface{} -} - -func (c *valueCtx) String() string { - return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) -} - -func (c *valueCtx) Value(key interface{}) interface{} { - if c.key == key { - return c.val - } - return c.Context.Value(key) -} From 3a0595dfee9eb08ca9f564f0dea33794259bd780 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 21 Oct 2016 11:41:04 -0700 Subject: [PATCH 207/357] tgt: Clean up session upon process kill --- frontend/tgt/frontend.go | 19 ++-- trash.yml | 2 +- util/util.go | 103 +++++++++++------- .../yasker/go-iscsi-helper/iscsi/initiator.go | 21 ++++ .../yasker/go-iscsi-helper/iscsi/target.go | 36 ++++++ 5 files changed, 131 insertions(+), 50 deletions(-) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index f575647b..9f028cba 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -35,14 +35,14 @@ type Tgt struct { } func (t *Tgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { - if err := t.Shutdown(); err != nil { - return err - } - t.Volume = name t.Size = size t.SectorSize = int(sectorSize) + if err := t.Shutdown(); err != nil { + return err + } + if err := t.startSocketServer(rw); err != nil { return err } @@ -66,16 +66,11 @@ func (t *Tgt) Shutdown() error { if err := util.RemoveDevice(dev); err != nil { return err } - t.Volume = "" - } - - if t.scsiDevice != nil { - logrus.Infof("Shutdown SCSI device at %v", t.scsiDevice.Device) - if err := t.scsiDevice.Shutdown(); err != nil { + if err := util.StopScsi(t.Volume); err != nil { return err } - t.scsiDevice = nil } + if t.socketServer != nil { //log.Infof("Shutdown TGT socket server for %v", t.Volume) // TODO: In fact we don't know how to shutdown socket server, there is @@ -158,7 +153,7 @@ func (t *Tgt) startScsiDevice() error { } t.scsiDevice = scsiDev } - if err := t.scsiDevice.Startup(); err != nil { + if err := util.StartScsi(t.scsiDevice); err != nil { return err } logrus.Infof("SCSI device %s created", t.scsiDevice.Device) diff --git a/trash.yml b/trash.yml index f0eee423..96d5f9a5 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: 378989ccf1cd08b5b8bff8e35c221495b59efca5 + version: d89a2d026b24a148033ecfe5e6acba573c9c4173 diff --git a/util/util.go b/util/util.go index 7c0c7c3a..720d7b24 100644 --- a/util/util.go +++ b/util/util.go @@ -19,6 +19,9 @@ import ( var ( parsePattern = regexp.MustCompile(`(.*):(\d+)`) + + TargetID = 1 + TargetLunID = 1 ) func ParseAddresses(name string) (string, string, string, error) { @@ -85,10 +88,7 @@ func (h filteredLoggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque type ScsiDevice struct { Target string - TargetID int - LunID int Device string - Portal string BackingFile string BSType string BSOpts string @@ -96,22 +96,27 @@ type ScsiDevice struct { func NewScsiDevice(name, backingFile, bsType, bsOpts string) (*ScsiDevice, error) { dev := &ScsiDevice{ - Target: "iqn.2014-07.com.rancher:" + name, - TargetID: 1, - LunID: 1, + Target: GetTargetName(name), BackingFile: backingFile, BSType: bsType, BSOpts: bsOpts, } + return dev, nil +} + +func GetTargetName(name string) string { + return "iqn.2014-07.com.rancher:" + name +} + +func GetLocalIP() (string, error) { ips, err := iutil.GetLocalIPs() if err != nil { - return nil, err + return "", err } - dev.Portal = ips[0] - return dev, nil + return ips[0], nil } -func (dev *ScsiDevice) Startup() error { +func StartScsi(dev *ScsiDevice) error { ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") if err != nil { return err @@ -121,65 +126,89 @@ func (dev *ScsiDevice) Startup() error { return err } + localIP, err := GetLocalIP() + if err != nil { + return err + } + // Setup target if err := iscsi.StartDaemon(false); err != nil { return err } - if err := iscsi.CreateTarget(dev.TargetID, dev.Target); err != nil { + if err := iscsi.CreateTarget(TargetID, dev.Target); err != nil { return err } - if err := iscsi.AddLun(dev.TargetID, dev.LunID, dev.BackingFile, dev.BSType, dev.BSOpts); err != nil { + if err := iscsi.AddLun(TargetID, TargetLunID, dev.BackingFile, dev.BSType, dev.BSOpts); err != nil { return err } - if err := iscsi.BindInitiator(dev.TargetID, "ALL"); err != nil { + if err := iscsi.BindInitiator(TargetID, "ALL"); err != nil { return err } // Setup initiator - if err := iscsi.DiscoverTarget(dev.Portal, dev.Target, ne); err != nil { + if err := iscsi.DiscoverTarget(localIP, dev.Target, ne); err != nil { return err } - if err := iscsi.LoginTarget(dev.Portal, dev.Target, ne); err != nil { + if err := iscsi.LoginTarget(localIP, dev.Target, ne); err != nil { return err } - if dev.Device, err = iscsi.GetDevice(dev.Portal, dev.Target, dev.LunID, ne); err != nil { + if dev.Device, err = iscsi.GetDevice(localIP, dev.Target, TargetLunID, ne); err != nil { return err } return nil } -func (dev *ScsiDevice) Shutdown() error { - if dev.Device == "" { - return fmt.Errorf("SCSI Device is already down") - } - - ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") - if err != nil { +func StopScsi(volumeName string) error { + target := GetTargetName(volumeName) + if err := LogoutTarget(target); err != nil { return err } - - if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + if err := DeleteTarget(target); err != nil { return err } + return nil +} - // Teardown initiator - if err := iscsi.LogoutTarget(dev.Portal, dev.Target, ne); err != nil { +func LogoutTarget(target string) error { + ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + if err != nil { return err } - dev.Device = "" - if err := iscsi.DeleteDiscoveredTarget(dev.Portal, dev.Target, ne); err != nil { + ip, err := GetLocalIP() + if err != nil { return err } - // Teardown target - if err := iscsi.UnbindInitiator(dev.TargetID, "ALL"); err != nil { - return err - } - if err := iscsi.DeleteLun(dev.TargetID, dev.LunID); err != nil { - return err + if iscsi.IsTargetLoggedIn(ip, target, ne) { + logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) + if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + return err + } + if err := iscsi.LogoutTarget(ip, target, ne); err != nil { + return err + } + if err := iscsi.DeleteDiscoveredTarget(ip, target, ne); err != nil { + return err + } } - if err := iscsi.DeleteTarget(dev.TargetID); err != nil { - return err + return nil +} + +func DeleteTarget(target string) error { + if tid, err := iscsi.GetTargetTid(target); err == nil && tid != -1 { + if tid != TargetID { + logrus.Fatalf("BUG: Invalid TID %v found for %v", tid, target) + } + logrus.Infof("Shutdown SCSI target %v", target) + if err := iscsi.UnbindInitiator(TargetID, "ALL"); err != nil { + return err + } + if err := iscsi.DeleteLun(TargetID, TargetLunID); err != nil { + return err + } + if err := iscsi.DeleteTarget(TargetID); err != nil { + return err + } } return nil } diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index 76bd54d0..7fddda4d 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -105,6 +105,27 @@ func GetDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (string, return strings.TrimSpace(dev), nil } +func IsTargetLoggedIn(ip, target string, ne *util.NamespaceExecutor) bool { + opts := []string{ + "-m", "session", + } + output, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return false + } + + found := false + scanner := bufio.NewScanner(strings.NewReader(output)) + for scanner.Scan() { + if strings.Contains(scanner.Text(), ip) && strings.Contains(scanner.Text(), " "+target+" ") { + found = true + break + } + } + + return found +} + func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (string, error) { dev := "" diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go index fb707f69..dc080bf9 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -1,6 +1,7 @@ package iscsi import ( + "bufio" "fmt" "os" "os/exec" @@ -205,3 +206,38 @@ func CheckTargetForBackingStore(name string) bool { } return strings.Contains(output, " "+name) } + +// GetTargetTid If returned TID is -1, then target doesn't exist, but we won't +// return error +func GetTargetTid(name string) (int, error) { + opts := []string{ + "--lld", "iscsi", + "--op", "show", + "--mode", "target", + } + output, err := util.Execute(tgtBinary, opts) + if err != nil { + return -1, err + } + /* Output will looks like: + Target 1: iqn.2016-08.com.example:a + System information: + ... + Target 2: iqn.2016-08.com.example:b + System information: + ... + */ + tid := -1 + scanner := bufio.NewScanner(strings.NewReader(output)) + for scanner.Scan() { + if strings.HasSuffix(scanner.Text(), " "+name) { + tidString := strings.Fields(strings.Split(scanner.Text(), ":")[0])[1] + tid, err = strconv.Atoi(tidString) + if err != nil { + return -1, fmt.Errorf("BUG: Fail to parse %s, %v", tidString, err) + } + break + } + } + return tid, nil +} From 75bae931db0b4a8f3bf82a013050078af0b2ef52 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 24 Oct 2016 14:57:47 -0700 Subject: [PATCH 208/357] tgt: Fix logout iSCSI target --- frontend/tgt/frontend.go | 4 ++-- trash.yml | 2 +- util/util.go | 4 ++-- .../yasker/go-iscsi-helper/iscsi/initiator.go | 16 ++++++++++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 9f028cba..1a365a3e 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -64,10 +64,10 @@ func (t *Tgt) Shutdown() error { if t.Volume != "" { dev := t.getDev() if err := util.RemoveDevice(dev); err != nil { - return err + return fmt.Errorf("Fail to remove device %s: %v", dev, err) } if err := util.StopScsi(t.Volume); err != nil { - return err + return fmt.Errorf("Fail to stop SCSI device: %v", err) } } diff --git a/trash.yml b/trash.yml index 96d5f9a5..b354784b 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: d89a2d026b24a148033ecfe5e6acba573c9c4173 + version: ce953bdc7b6df131bb9d098cbbd526aa2382d518 diff --git a/util/util.go b/util/util.go index 720d7b24..2db83b05 100644 --- a/util/util.go +++ b/util/util.go @@ -161,10 +161,10 @@ func StartScsi(dev *ScsiDevice) error { func StopScsi(volumeName string) error { target := GetTargetName(volumeName) if err := LogoutTarget(target); err != nil { - return err + return fmt.Errorf("Fail to logout target: %v", err) } if err := DeleteTarget(target); err != nil { - return err + return fmt.Errorf("Fail to delete target: %v", err) } return nil } diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index 7fddda4d..75e5b1b3 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -113,13 +113,21 @@ func IsTargetLoggedIn(ip, target string, ne *util.NamespaceExecutor) bool { if err != nil { return false } - + /* It will looks like: + tcp: [463] 172.17.0.2:3260,1 iqn.2014-07.com.rancher:test-volume + or: + tcp: [463] 172.17.0.2:3260,1 iqn.2014-07.com.rancher:test-volume (non-flash) + */ found := false scanner := bufio.NewScanner(strings.NewReader(output)) for scanner.Scan() { - if strings.Contains(scanner.Text(), ip) && strings.Contains(scanner.Text(), " "+target+" ") { - found = true - break + line := scanner.Text() + if strings.Contains(line, ip+":") { + if strings.HasSuffix(line, " "+target) || + strings.Contains(scanner.Text(), " "+target+" ") { + found = true + break + } } } From 4e6cf06d41dcf75bd982fde2b75a91a70bf09b93 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 24 Oct 2016 16:58:46 -0700 Subject: [PATCH 209/357] test: ensure device is ready before continue --- integration/data/common.py | 8 +++++++- integration/data/frontend.py | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index 2bf1484b..e22c63dd 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -2,6 +2,7 @@ import string import subprocess import hashlib +import time import os from os import path @@ -152,7 +153,12 @@ def get_restdev(): def get_blockdev(): - return blockdev(VOLUME_NAME) + dev = blockdev(VOLUME_NAME) + for i in range(10): + if not dev.ready(): + time.sleep(1) + assert dev.ready() + return dev def write_dev(dev, offset, data): diff --git a/integration/data/frontend.py b/integration/data/frontend.py index d872ba80..ebc980a6 100644 --- a/integration/data/frontend.py +++ b/integration/data/frontend.py @@ -1,6 +1,7 @@ import base64 import os from os import path +import stat import mmap import directio @@ -71,7 +72,6 @@ def readat(self, offset, length): return [] raise e return base64.decodestring(data) - def writeat(self, offset, data): l = len(data) encoded_data = base64.encodestring(data) @@ -83,6 +83,9 @@ def writeat(self, offset, data): raise e return ret + def ready(self): + return True + class blockdev: @@ -98,3 +101,11 @@ def readat(self, offset, length): def writeat(self, offset, data): return writeat_direct(self.dev, offset, data) + + def ready(self): + if not os.path.exists(self.dev): + return False + mode = os.stat(self.dev).st_mode + if not stat.S_ISBLK(mode): + return False + return True From f33de8ea6c2b8fc3ba98161cfc15acbd349a9206 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 25 Oct 2016 11:52:31 -0700 Subject: [PATCH 210/357] rpc: Add a way to shutdown rpc server --- frontend/tgt/frontend.go | 11 ++++----- integration/data/frontend.py | 1 + rpc/server.go | 47 +++++++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 1a365a3e..396c27eb 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -66,16 +66,15 @@ func (t *Tgt) Shutdown() error { if err := util.RemoveDevice(dev); err != nil { return fmt.Errorf("Fail to remove device %s: %v", dev, err) } + if t.socketServer != nil { + logrus.Infof("Shutdown TGT socket server for %v", t.Volume) + t.socketServer.Stop() + t.socketServer = nil + } if err := util.StopScsi(t.Volume); err != nil { return fmt.Errorf("Fail to stop SCSI device: %v", err) } } - - if t.socketServer != nil { - //log.Infof("Shutdown TGT socket server for %v", t.Volume) - // TODO: In fact we don't know how to shutdown socket server, there is - // no way yet - } t.isUp = false return nil diff --git a/integration/data/frontend.py b/integration/data/frontend.py index ebc980a6..71497e22 100644 --- a/integration/data/frontend.py +++ b/integration/data/frontend.py @@ -72,6 +72,7 @@ def readat(self, offset, length): return [] raise e return base64.decodestring(data) + def writeat(self, offset, data): l = len(data) encoded_data = base64.encodestring(data) diff --git a/rpc/server.go b/rpc/server.go index 5b51d8f3..3da2053f 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -32,24 +32,47 @@ func (s *Server) Handle() error { return s.read() } +func (s *Server) readFromWire(ret chan<- error) { + msg, err := s.wire.Read() + if err == io.EOF { + ret <- err + return + } else if err != nil { + logrus.Errorf("Failed to read: %v", err) + ret <- err + return + } + switch msg.Type { + case TypeRead: + go s.handleRead(msg) + case TypeWrite: + go s.handleWrite(msg) + } + ret <- nil +} + func (s *Server) read() error { + ret := make(chan error) for { - msg, err := s.wire.Read() - if err == io.EOF { - return err - } else if err != nil { - logrus.Errorf("Failed to read: %v", err) - return err - } - switch msg.Type { - case TypeRead: - go s.handleRead(msg) - case TypeWrite: - go s.handleWrite(msg) + go s.readFromWire(ret) + + select { + case err := <-ret: + if err != nil { + return err + } + continue + case <-s.done: + logrus.Debugf("RPC server stopped") + return nil } } } +func (s *Server) Stop() { + s.done <- struct{}{} +} + func (s *Server) handleRead(msg *Message) { c, err := s.data.ReadAt(msg.Data, msg.Offset) s.pushResponse(c, msg, err) From 4b9d3b34133c70e5cabf838686781a4756095cf8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 25 Oct 2016 12:46:16 -0700 Subject: [PATCH 211/357] tgt: Add retry to iscsiadm delete op It may fail with following error message: Could not execute operation on all records: encountered iSCSI database failure The same issue has been spotted at: https://bugs.launchpad.net/ironic/+bug/1324670 --- util/util.go | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/util/util.go b/util/util.go index 2db83b05..ba9fc71a 100644 --- a/util/util.go +++ b/util/util.go @@ -3,10 +3,12 @@ package util import ( "fmt" "io" + "math/rand" "net/http" "os" "regexp" "strconv" + "strings" "time" "github.com/Sirupsen/logrus" @@ -22,6 +24,9 @@ var ( TargetID = 1 TargetLunID = 1 + + RetryCounts = 5 + RetryInterval = 3000 //ms ) func ParseAddresses(name string) (string, string, string, error) { @@ -179,15 +184,34 @@ func LogoutTarget(target string) error { return err } + if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + return err + } if iscsi.IsTargetLoggedIn(ip, target, ne) { logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) - if err := iscsi.CheckForInitiatorExistence(ne); err != nil { - return err - } if err := iscsi.LogoutTarget(ip, target, ne); err != nil { return err } - if err := iscsi.DeleteDiscoveredTarget(ip, target, ne); err != nil { + /* + * Immediately delete target after logout may result in error: + * + * "Could not execute operation on all records: encountered + * iSCSI database failure" in iscsiadm + * + * This happenes especially there are other iscsiadm db + * operations go on at the same time. + * Retry to workaround this issue. Also treat "exit status + * 21"(no record found) as valid result + */ + for i := 0; i < RetryCounts; i++ { + err = iscsi.DeleteDiscoveredTarget(ip, target, ne) + if err == nil || strings.Contains(err.Error(), "exit status 21") { + err = nil + break + } + time.Sleep(time.Duration(rand.Intn(RetryInterval)) * time.Millisecond) + } + if err != nil { return err } } From 23f40bf53219022ac69462109439ba3ef08c53b7 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 26 Oct 2016 00:13:15 -0700 Subject: [PATCH 212/357] tgt: Update go-iscsi-helper vendor --- trash.yml | 2 +- vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/trash.yml b/trash.yml index b354784b..5075781a 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: ce953bdc7b6df131bb9d098cbbd526aa2382d518 + version: 3d6223e8fa3d1f4e491313b9318c680de432c106 diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index 75e5b1b3..8c127185 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -74,13 +74,16 @@ func LoginTarget(ip, target string, ne *util.NamespaceExecutor) error { return nil } +// LogoutTarget will logout all sessions if ip == "" func LogoutTarget(ip, target string, ne *util.NamespaceExecutor) error { opts := []string{ "-m", "node", "-T", target, - "-p", ip, "--logout", } + if ip != "" { + opts = append(opts, "-p", ip) + } _, err := ne.Execute(iscsiBinary, opts) if err != nil { return err @@ -105,6 +108,7 @@ func GetDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (string, return strings.TrimSpace(dev), nil } +// IsTargetLoggedIn check all portals if ip == "" func IsTargetLoggedIn(ip, target string, ne *util.NamespaceExecutor) bool { opts := []string{ "-m", "session", From 04a4c5c8c432cef3054db8a95f2257deec17c14f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 26 Oct 2016 18:51:22 -0700 Subject: [PATCH 213/357] tgt: Check for discovered target after discovery Multiple discoveries issued at the same time may have impact on db, db may be delayed or too busy to update at the moment. Need retry mechanism. --- trash.yml | 2 +- util/util.go | 12 +++++++--- .../yasker/go-iscsi-helper/iscsi/initiator.go | 22 +++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/trash.yml b/trash.yml index 5075781a..bba43a14 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: 3d6223e8fa3d1f4e491313b9318c680de432c106 + version: f6e48a193930249202b147a0a184321713f185db diff --git a/util/util.go b/util/util.go index ba9fc71a..abf793b5 100644 --- a/util/util.go +++ b/util/util.go @@ -3,7 +3,6 @@ package util import ( "fmt" "io" - "math/rand" "net/http" "os" "regexp" @@ -26,7 +25,7 @@ var ( TargetLunID = 1 RetryCounts = 5 - RetryInterval = 3000 //ms + RetryInterval = 3 ) func ParseAddresses(name string) (string, string, string, error) { @@ -188,6 +187,8 @@ func LogoutTarget(target string) error { return err } if iscsi.IsTargetLoggedIn(ip, target, ne) { + var err error + logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) if err := iscsi.LogoutTarget(ip, target, ne); err != nil { return err @@ -204,12 +205,17 @@ func LogoutTarget(target string) error { * 21"(no record found) as valid result */ for i := 0; i < RetryCounts; i++ { + if !iscsi.IsTargetDiscovered(ip, target, ne) { + err = nil + break + } + err = iscsi.DeleteDiscoveredTarget(ip, target, ne) if err == nil || strings.Contains(err.Error(), "exit status 21") { err = nil break } - time.Sleep(time.Duration(rand.Intn(RetryInterval)) * time.Millisecond) + time.Sleep(time.Duration(RetryInterval) * time.Second) } if err != nil { return err diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index 8c127185..74592bee 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -40,6 +40,15 @@ func DiscoverTarget(ip, target string, ne *util.NamespaceExecutor) error { if err != nil { return err } + // Sometime iscsiadm won't return error but showing e.g.: + // iscsiadm: Could not stat /etc/iscsi/nodes//,3260,-1/default to + // delete node: No such file or directory\n\niscsiadm: Could not + // add/update [tcp:[hw=,ip=,net_if=,iscsi_if=default] 172.18.0.5,3260,1 + // iqn.2014-07.com.rancher:vol9]\n172.18.0.5:3260,1 + // iqn.2014-07.com.rancher:vol9\n" + if strings.Contains(output, "Could not") { + return fmt.Errorf("Cannot discover target: %s", output) + } if !strings.Contains(output, target) { return fmt.Errorf("Cannot find target %s in discovered targets %s", target, output) } @@ -60,6 +69,19 @@ func DeleteDiscoveredTarget(ip, target string, ne *util.NamespaceExecutor) error return nil } +func IsTargetDiscovered(ip, target string, ne *util.NamespaceExecutor) bool { + opts := []string{ + "-m", "node", + "-T", target, + "-p", ip, + } + _, err := ne.Execute(iscsiBinary, opts) + if err != nil { + return false + } + return true +} + func LoginTarget(ip, target string, ne *util.NamespaceExecutor) error { opts := []string{ "-m", "node", From 8d20b203ceac39b690a58358c7965a80516c2003 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 1 Nov 2016 14:47:27 -0700 Subject: [PATCH 214/357] tgt: update new go-iscsi-helper to fix #228 --- trash.yml | 2 +- .../yasker/go-iscsi-helper/iscsi/initiator.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/trash.yml b/trash.yml index bba43a14..6cdbc9f5 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: f6e48a193930249202b147a0a184321713f185db + version: e46488a20c17f7730d0c459099ab2b06918a243f diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index 74592bee..d06dfaff 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -193,7 +193,14 @@ func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (str inTarget := false inLun := false for scanner.Scan() { - if !inTarget && strings.Contains(scanner.Text(), targetLine) { + /* Target line can be: + Target: iqn.2016-09.com.rancher:for.all (non-flash) + or: + Target: iqn.2016-09.com.rancher:for.all + */ + if !inTarget && + (strings.Contains(scanner.Text(), targetLine+" ") || + strings.HasSuffix(scanner.Text(), targetLine)) { inTarget = true continue } @@ -205,7 +212,7 @@ func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (str if inLun { line := scanner.Text() if !strings.Contains(line, diskPrefix) { - return "", fmt.Errorf("Invalid output format, cannot find disk in: %s", line) + return "", fmt.Errorf("Invalid output format, cannot find disk in: %s\n %s", line, output) } line = strings.TrimSpace(strings.Split(line, stateLine)[0]) line = strings.TrimPrefix(line, diskPrefix) From 508c59d20b641fe1e75b8019793954f86f80fd39 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 1 Nov 2016 16:27:55 -0700 Subject: [PATCH 215/357] tgt: Clean up invalid empty iscsi nodes on the host if discover failed Fixes #226 Also update iqn prefix to `iqn.2014-09.rancher.com` --- trash.yml | 2 +- util/util.go | 22 +++++++++-- .../yasker/go-iscsi-helper/iscsi/initiator.go | 39 +++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/trash.yml b/trash.yml index 6cdbc9f5..9f8149e8 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: e46488a20c17f7730d0c459099ab2b06918a243f + version: 58912b2918090b07fb15f078f37eecbee61300d1 diff --git a/util/util.go b/util/util.go index abf793b5..8421c42d 100644 --- a/util/util.go +++ b/util/util.go @@ -109,7 +109,7 @@ func NewScsiDevice(name, backingFile, bsType, bsOpts string) (*ScsiDevice, error } func GetTargetName(name string) string { - return "iqn.2014-07.com.rancher:" + name + return "iqn.2014-09.com.rancher:" + name } func GetLocalIP() (string, error) { @@ -150,8 +150,24 @@ func StartScsi(dev *ScsiDevice) error { } // Setup initiator - if err := iscsi.DiscoverTarget(localIP, dev.Target, ne); err != nil { - return err + err = nil + for i := 0; i < RetryCounts; i++ { + err = iscsi.DiscoverTarget(localIP, dev.Target, ne) + if iscsi.IsTargetDiscovered(localIP, dev.Target, ne) { + break + } + + logrus.Warnf("FAIL to discover %v", err) + // This is a trick to recover from the case. Remove the + // empty entries in /etc/iscsi/nodes/. If one of the entry + // is empty it will triggered the issue. + if err := iscsi.CleanupScsiNodes(dev.Target, ne); err != nil { + logrus.Warnf("Fail to cleanup nodes for %v: %v", dev.Target, err) + } else { + logrus.Warnf("Nodes cleaned up for %v", dev.Target) + } + + time.Sleep(time.Duration(RetryInterval) * time.Second) } if err := iscsi.LoginTarget(localIP, dev.Target, ne); err != nil { return err diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index d06dfaff..07efe042 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -3,6 +3,7 @@ package iscsi import ( "bufio" "fmt" + "path/filepath" "strconv" "strings" "time" @@ -13,6 +14,11 @@ import ( var ( DeviceWaitRetryCounts = 5 DeviceWaitRetryInterval = 1 * time.Second + + ScsiNodesDirs = []string{ + "/etc/iscsi/nodes/", + "/var/lib/iscsi/nodes/", + } ) const ( @@ -226,3 +232,36 @@ func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (str dev = "/dev/" + dev return dev, nil } + +func CleanupScsiNodes(target string, ne *util.NamespaceExecutor) error { + for _, dir := range ScsiNodesDirs { + if _, err := ne.Execute("ls", []string{dir}); err != nil { + continue + } + targetDir := filepath.Join(dir, target) + if _, err := ne.Execute("ls", []string{targetDir}); err != nil { + continue + } + // Remove all empty files in the directory + output, err := ne.Execute("find", []string{targetDir}) + if err != nil { + return fmt.Errorf("Failed to search SCSI directory %v: %v", targetDir, err) + } + scanner := bufio.NewScanner(strings.NewReader(output)) + for scanner.Scan() { + file := scanner.Text() + output, err := ne.Execute("stat", []string{file}) + if err != nil { + return fmt.Errorf("Failed to check SCSI node file %v: %v", file, err) + } + if strings.Contains(output, "regular empty file") { + if _, err := ne.Execute("rm", []string{file}); err != nil { + return fmt.Errorf("Failed to cleanup empty SCSI node file %v: %v", file, err) + } + // We're trying to clean up the upper level directory as well, but won't mind if we fail + ne.Execute("rmdir", []string{filepath.Dir(file)}) + } + } + } + return nil +} From f9e9848bbf049b3a28f1c328fde8af3875a8db98 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 3 Nov 2016 19:24:49 -0700 Subject: [PATCH 216/357] tgt: Add wait for device to show up after iscsiadm reports the name Fixes #231 --- util/util.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/util/util.go b/util/util.go index 8421c42d..dac450f9 100644 --- a/util/util.go +++ b/util/util.go @@ -175,6 +175,18 @@ func StartScsi(dev *ScsiDevice) error { if dev.Device, err = iscsi.GetDevice(localIP, dev.Target, TargetLunID, ne); err != nil { return err } + + deviceFound := false + for i := 0; i < RetryCounts; i++ { + if st, err := os.Stat(dev.Device); err == nil && (st.Mode()&os.ModeDevice != 0) { + deviceFound = true + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + if !deviceFound { + return fmt.Errorf("Failed to wait for device %s to show up", dev.Device) + } return nil } @@ -262,7 +274,7 @@ func DeleteTarget(target string) error { func DuplicateDevice(src, dest string) error { stat := unix.Stat_t{} if err := unix.Stat(src, &stat); err != nil { - return fmt.Errorf("Cannot find %s: %v", src, err) + return fmt.Errorf("Cannot duplicate device because cannot find %s: %v", src, err) } major := int(stat.Rdev / 256) minor := int(stat.Rdev % 256) From 72089c370f90fbc9ff6822a2ce3190aabf4ca63d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 4 Nov 2016 23:40:42 -0700 Subject: [PATCH 217/357] tgt: update tgtd to include retry mechanism Should fix the issue #235 --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 01291ba4..e792593e 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -68,7 +68,7 @@ RUN cd /usr/src/libqcow-20160123 && \ RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout e101b78e28b40a06d04467925d3fbd17985fdc73 && \ + git checkout 1f116a1bf03c4ec16a0a1294189a5f802739f343 && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb From b777060b2ba896513ce29542f51ddf85a6804bd9 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 8 Nov 2016 15:50:43 -0800 Subject: [PATCH 218/357] tgt: Fix issue when parsing device name from iscsiadm output It need to be associated with IP, otherwise it can pick up wrong device. Fixes #237. --- trash.yml | 2 +- .../github.com/yasker/go-iscsi-helper/iscsi/initiator.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/trash.yml b/trash.yml index 9f8149e8..04ab339a 100644 --- a/trash.yml +++ b/trash.yml @@ -59,4 +59,4 @@ import: - package: github.com/deckarep/golang-set version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper - version: 58912b2918090b07fb15f078f37eecbee61300d1 + version: a95ec6c0750d3426e3fd0b10f6f0f50721fe75cf diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go index 07efe042..5380d1db 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/initiator.go @@ -193,10 +193,13 @@ func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (str */ scanner := bufio.NewScanner(strings.NewReader(output)) targetLine := "Target: " + target + ipLine := " " + ip + ":" lunLine := "Lun: " + strconv.Itoa(lun) diskPrefix := "Attached scsi disk" stateLine := "State:" + inTarget := false + inIP := false inLun := false for scanner.Scan() { /* Target line can be: @@ -210,7 +213,11 @@ func findScsiDevice(ip, target string, lun int, ne *util.NamespaceExecutor) (str inTarget = true continue } - if inTarget && strings.Contains(scanner.Text(), lunLine) { + if inTarget && strings.Contains(scanner.Text(), ipLine) { + inIP = true + continue + } + if inIP && strings.Contains(scanner.Text(), lunLine) { inLun = true continue } From 3791d38d325a53739dac5bfd76390de57e2bf3ee Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 11 Nov 2016 11:55:53 -0800 Subject: [PATCH 219/357] tgt: Fix failed to logout issue Fix #230 --- util/util.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/util/util.go b/util/util.go index dac450f9..68f5e078 100644 --- a/util/util.go +++ b/util/util.go @@ -216,10 +216,35 @@ func LogoutTarget(target string) error { } if iscsi.IsTargetLoggedIn(ip, target, ne) { var err error + loggingOut := false logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) - if err := iscsi.LogoutTarget(ip, target, ne); err != nil { - return err + for i := 0; i < RetryCounts; i++ { + err = iscsi.LogoutTarget(ip, target, ne) + if err == nil { + break + } + // The timeout for response may return in the future, + // check session to know if it's logged out or not + if strings.Contains(err.Error(), "Timeout executing: ") { + loggingOut = true + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + // Wait for device to logout + if loggingOut { + logrus.Infof("Logout SCSI device timeout, waiting for logout complete") + for i := 0; i < RetryCounts; i++ { + if !iscsi.IsTargetLoggedIn(ip, target, ne) { + err = nil + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + } + if err != nil { + return fmt.Errorf("Failed to logout target: %v", err) } /* * Immediately delete target after logout may result in error: From cbbc0db16810a30457c57aaad4aba050bafdc2ef Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 14 Nov 2016 16:59:35 -0800 Subject: [PATCH 220/357] controller: Retry read if fail and there is at least one healthy replica Fixes #242 --- controller/replicator.go | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/controller/replicator.go b/controller/replicator.go index b5e014a0..f2bd64e4 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -80,26 +80,35 @@ func (r *replicator) RemoveBackend(address string) { } func (r *replicator) ReadAt(buf []byte, off int64) (int, error) { + var ( + n int + err error + ) + if !r.backendsAvailable { return 0, ErrNoBackend } + readersLen := len(r.readers) + r.next = (r.next + 1) % readersLen index := r.next - r.next++ - if index >= len(r.readers) { - r.next = 0 - index = 0 - } - n, err := r.readers[index].ReadAt(buf, off) - if err != nil { - logrus.Error("Replicator.ReadAt:", index, err) - return n, &BackendError{ - Errors: map[string]error{ - r.readerIndex[index]: err, - }, + retError := &BackendError{ + Errors: map[string]error{}, + } + for i := 0; i < readersLen; i++ { + reader := r.readers[index] + n, err = reader.ReadAt(buf, off) + if err == nil { + break } + logrus.Error("Replicator.ReadAt:", index, err) + retError.Errors[r.readerIndex[index]] = err + index = (index + 1) % readersLen } - return n, err + if len(retError.Errors) != 0 { + return n, retError + } + return n, nil } func (r *replicator) WriteAt(p []byte, off int64) (int, error) { From 0121d03f61639f85edee90a956b1ec2ef46907ad Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 21 Nov 2016 14:43:46 -0800 Subject: [PATCH 221/357] replica: Rename DiskChildMap to DiskChildrenMap --- replica/replica.go | 40 +++++++------- replica/replica_test.go | 114 ++++++++++++++++++++-------------------- 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 7a2094a8..3779c289 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -33,13 +33,13 @@ var ( type Replica struct { sync.RWMutex - volume diffDisk - dir string - info Info - diskData map[string]*disk - diskChildMap map[string]mapset.Set - activeDiskData []*disk - readOnly bool + volume diffDisk + dir string + info Info + diskData map[string]*disk + diskChildrenMap map[string]mapset.Set + activeDiskData []*disk + readOnly bool } type Info struct { @@ -102,10 +102,10 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF } r := &Replica{ - dir: dir, - activeDiskData: make([]*disk, 1), - diskData: make(map[string]*disk), - diskChildMap: map[string]mapset.Set{}, + dir: dir, + activeDiskData: make([]*disk, 1), + diskData: make(map[string]*disk), + diskChildrenMap: map[string]mapset.Set{}, } r.info.Size = size r.info.SectorSize = sectorSize @@ -170,7 +170,7 @@ func (r *Replica) insertBackingFile() { } d := disk{name: r.info.BackingFile.Name} - r.activeDiskData = append([]*disk{&disk{}, &d}, r.activeDiskData[1:]...) + r.activeDiskData = append([]*disk{{}, &d}, r.activeDiskData[1:]...) r.volume.files = append([]types.DiffDisk{nil, r.info.BackingFile.Disk}, r.volume.files[1:]...) r.diskData[d.name] = &d } @@ -227,7 +227,7 @@ func (r *Replica) RemoveDiffDisk(name string) error { func (r *Replica) removeDiskNode(name string) error { // If snapshot has no child, then we can safely delete it // And it's definitely not in the live chain - children := r.diskChildMap[name] + children := r.diskChildrenMap[name] if children == nil { r.updateChildDisk(name, "") delete(r.diskData, name) @@ -314,7 +314,7 @@ func (r *Replica) processPrepareRemoveDisks(disks []string) ([]PrepareRemoveActi return nil, fmt.Errorf("Wrong disk %v doesn't exist", disk) } - children := r.diskChildMap[disk] + children := r.diskChildrenMap[disk] // 1) leaf node if children == nil { actions = append(actions, PrepareRemoveAction{ @@ -540,7 +540,7 @@ func (r *Replica) revertDisk(parent string) (*Replica, error) { return nil, err } - // Need to execute before r.Reload() to update r.diskChildMap + // Need to execute before r.Reload() to update r.diskChildrenMap r.rmDisk(oldHead) rNew, err := r.Reload() @@ -609,16 +609,16 @@ func (r *Replica) createDisk(name string) error { } func (r *Replica) addChildDisk(parent, child string) { - children, exists := r.diskChildMap[parent] + children, exists := r.diskChildrenMap[parent] if !exists { children = mapset.NewSet() } children.Add(child) - r.diskChildMap[parent] = children + r.diskChildrenMap[parent] = children } func (r *Replica) rmChildDisk(parent, child string) { - children, exists := r.diskChildMap[parent] + children, exists := r.diskChildrenMap[parent] if !exists { return } @@ -627,10 +627,10 @@ func (r *Replica) rmChildDisk(parent, child string) { } children.Remove(child) if children.Cardinality() == 0 { - delete(r.diskChildMap, parent) + delete(r.diskChildrenMap, parent) return } - r.diskChildMap[parent] = children + r.diskChildrenMap[parent] = children } func (r *Replica) updateChildDisk(oldName, newName string) { diff --git a/replica/replica_test.go b/replica/replica_test.go index cf8bbdf2..c0def0bf 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -64,13 +64,13 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRevert(c *C) { @@ -112,13 +112,13 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-003.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-003.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) - c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) - c.Assert(r.diskChildMap["volume-head-003.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-003.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-001.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-head-003.img"], IsNil) err = r.Snapshot("003") c.Assert(err, IsNil) @@ -129,13 +129,13 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-003.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-003.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-003.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-003.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-snap-003.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-003.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-003.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-003.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-003.img"].Contains("volume-head-004.img"), Equals, true) r, err = r.Revert("volume-snap-001.img") c.Assert(err, IsNil) @@ -153,10 +153,10 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-005.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-005.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-snap-003.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-head-005.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-003.img"], IsNil) } func (s *TestSuite) TestRemoveLeafNode(c *C) { @@ -205,14 +205,14 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-002.img"], IsNil) err = r.RemoveDiffDisk("volume-snap-002.img") c.Assert(err, IsNil) @@ -222,7 +222,7 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildMap["volume-snap-001.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-001.img"], IsNil) err = r.RemoveDiffDisk("volume-snap-001.img") c.Assert(err, IsNil) @@ -231,9 +231,9 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 1) } func (s *TestSuite) TestRemoveLast(c *C) { @@ -276,10 +276,10 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "") c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRemoveMiddle(c *C) { @@ -322,10 +322,10 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-002.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-head-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-002.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRemoveFirst(c *C) { @@ -405,13 +405,13 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-001.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-002.img"], IsNil) err = r.RemoveDiffDisk("volume-snap-001.img") c.Assert(err, IsNil) @@ -428,11 +428,11 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-000.img"].Contains("volume-snap-002.img"), Equals, true) - c.Assert(r.diskChildMap["volume-snap-002.img"], IsNil) + c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-002.img"], IsNil) } func (s *TestSuite) TestPrepareRemove(c *C) { From 2866a2cc69b7fd255d4f0722cbdac3a7ea6aaa87 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 21 Nov 2016 15:21:00 -0800 Subject: [PATCH 222/357] replica: Replace mapset with regular map --- replica/replica.go | 35 +-- replica/replica_test.go | 82 +++--- trash.yml | 2 - .../github.com/deckarep/golang-set/.gitignore | 22 -- .../deckarep/golang-set/.travis.yml | 11 - vendor/github.com/deckarep/golang-set/LICENSE | 22 -- .../github.com/deckarep/golang-set/README.md | 94 ------- vendor/github.com/deckarep/golang-set/set.go | 174 ------------- .../deckarep/golang-set/threadsafe.go | 204 --------------- .../deckarep/golang-set/threadunsafe.go | 246 ------------------ 10 files changed, 54 insertions(+), 838 deletions(-) delete mode 100644 vendor/github.com/deckarep/golang-set/.gitignore delete mode 100644 vendor/github.com/deckarep/golang-set/.travis.yml delete mode 100644 vendor/github.com/deckarep/golang-set/LICENSE delete mode 100644 vendor/github.com/deckarep/golang-set/README.md delete mode 100644 vendor/github.com/deckarep/golang-set/set.go delete mode 100644 vendor/github.com/deckarep/golang-set/threadsafe.go delete mode 100644 vendor/github.com/deckarep/golang-set/threadunsafe.go diff --git a/replica/replica.go b/replica/replica.go index 3779c289..1fbecb4e 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -13,7 +13,6 @@ import ( "syscall" "github.com/Sirupsen/logrus" - "github.com/deckarep/golang-set" "github.com/rancher/longhorn/types" "github.com/rancher/sparse-tools/sparse" ) @@ -37,7 +36,7 @@ type Replica struct { dir string info Info diskData map[string]*disk - diskChildrenMap map[string]mapset.Set + diskChildrenMap map[string]map[string]bool activeDiskData []*disk readOnly bool } @@ -105,7 +104,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF dir: dir, activeDiskData: make([]*disk, 1), diskData: make(map[string]*disk), - diskChildrenMap: map[string]mapset.Set{}, + diskChildrenMap: map[string]map[string]bool{}, } r.info.Size = size r.info.SectorSize = sectorSize @@ -227,22 +226,23 @@ func (r *Replica) RemoveDiffDisk(name string) error { func (r *Replica) removeDiskNode(name string) error { // If snapshot has no child, then we can safely delete it // And it's definitely not in the live chain - children := r.diskChildrenMap[name] - if children == nil { + children, exists := r.diskChildrenMap[name] + if !exists { r.updateChildDisk(name, "") delete(r.diskData, name) return nil } // If snapshot has more than one child, we cannot really delete it - if children.Cardinality() > 1 { + if len(children) > 1 { return fmt.Errorf("Cannot remove snapshot %v with %v children", - name, children.Cardinality()) + name, len(children)) } // only one child from here - childIter := <-children.Iter() - child := childIter.(string) + var child string + for child = range children { + } r.updateChildDisk(name, child) if err := r.updateParentDisk(child, name); err != nil { return err @@ -325,8 +325,11 @@ func (r *Replica) processPrepareRemoveDisks(disks []string) ([]PrepareRemoveActi } // 2) has only one child and is not head - if children.Cardinality() == 1 { - child := (<-children.Iter()).(string) + if len(children) == 1 { + var child string + // Get the only element in children + for child = range children { + } if child != r.info.Head { actions = append(actions, PrepareRemoveAction{ @@ -611,9 +614,9 @@ func (r *Replica) createDisk(name string) error { func (r *Replica) addChildDisk(parent, child string) { children, exists := r.diskChildrenMap[parent] if !exists { - children = mapset.NewSet() + children = map[string]bool{} } - children.Add(child) + children[child] = true r.diskChildrenMap[parent] = children } @@ -622,11 +625,11 @@ func (r *Replica) rmChildDisk(parent, child string) { if !exists { return } - if !children.Contains(child) { + if _, exists := children[child]; !exists { return } - children.Remove(child) - if children.Cardinality() == 0 { + delete(children, child) + if len(children) == 0 { delete(r.diskChildrenMap, parent) return } diff --git a/replica/replica_test.go b/replica/replica_test.go index c0def0bf..d62fa69b 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -64,12 +64,11 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(len(r.diskChildrenMap), Equals, 3) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-head-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) } @@ -112,10 +111,9 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-003.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-003.img"), Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-003.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-001.img"], IsNil) c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) c.Assert(r.diskChildrenMap["volume-head-003.img"], IsNil) @@ -129,13 +127,11 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-003.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-003.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-003.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-003.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildrenMap["volume-snap-003.img"].Contains("volume-head-004.img"), Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-003.img"], Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-003.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-003.img"]["volume-head-004.img"], Equals, true) r, err = r.Revert("volume-snap-001.img") c.Assert(err, IsNil) @@ -153,9 +149,8 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-005.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-head-005.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-head-005.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-003.img"], IsNil) } @@ -205,13 +200,11 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-004.img"], Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-snap-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-002.img"], IsNil) err = r.RemoveDiffDisk("volume-snap-002.img") @@ -231,9 +224,8 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-004.img"], Equals, true) } func (s *TestSuite) TestRemoveLast(c *C) { @@ -276,9 +268,8 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "") c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildrenMap["volume-snap-001.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-head-002.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) + c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-head-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) } @@ -322,9 +313,8 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-002.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 1) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) } @@ -355,7 +345,7 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(r.activeDiskData[1].Parent, Equals, "") err = r.RemoveDiffDisk("volume-head-002.img") - c.Assert(err, Not(IsNil)) + c.Assert(err, NotNil) } func (s *TestSuite) TestRemoveOutOfChain(c *C) { @@ -405,12 +395,11 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-001.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Cardinality(), Equals, 1) - c.Assert(r.diskChildrenMap["volume-snap-001.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-004.img"], Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) + c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-snap-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-002.img"], IsNil) err = r.RemoveDiffDisk("volume-snap-001.img") @@ -428,10 +417,9 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.diskData["volume-head-004.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-000.img") - c.Assert(r.diskChildrenMap["volume-snap-000.img"], Not(IsNil)) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Cardinality(), Equals, 2) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-head-004.img"), Equals, true) - c.Assert(r.diskChildrenMap["volume-snap-000.img"].Contains("volume-snap-002.img"), Equals, true) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 2) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-004.img"], Equals, true) + c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-002.img"], IsNil) } diff --git a/trash.yml b/trash.yml index 04ab339a..94ad32d9 100644 --- a/trash.yml +++ b/trash.yml @@ -56,7 +56,5 @@ import: version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 - package: github.com/jmespath/go-jmespath version: c01cf91b011868172fdcd9f41838e80c9d716264 -- package: github.com/deckarep/golang-set - version: 1f0f4ff8d3fbef9328522993ce71c35890f67554 - package: github.com/yasker/go-iscsi-helper version: a95ec6c0750d3426e3fd0b10f6f0f50721fe75cf diff --git a/vendor/github.com/deckarep/golang-set/.gitignore b/vendor/github.com/deckarep/golang-set/.gitignore deleted file mode 100644 index 00268614..00000000 --- a/vendor/github.com/deckarep/golang-set/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# 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 diff --git a/vendor/github.com/deckarep/golang-set/.travis.yml b/vendor/github.com/deckarep/golang-set/.travis.yml deleted file mode 100644 index 48d5a91e..00000000 --- a/vendor/github.com/deckarep/golang-set/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: go - -go: - - 1.2 - - 1.3 - - tip - -script: - - go test -race ./... - - go test -bench=. - diff --git a/vendor/github.com/deckarep/golang-set/LICENSE b/vendor/github.com/deckarep/golang-set/LICENSE deleted file mode 100644 index b5768f89..00000000 --- a/vendor/github.com/deckarep/golang-set/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Open Source Initiative OSI - The MIT License (MIT):Licensing - -The MIT License (MIT) -Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) - -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/deckarep/golang-set/README.md b/vendor/github.com/deckarep/golang-set/README.md deleted file mode 100644 index 564d904f..00000000 --- a/vendor/github.com/deckarep/golang-set/README.md +++ /dev/null @@ -1,94 +0,0 @@ -[![Build Status](https://travis-ci.org/deckarep/golang-set.png?branch=master)](https://travis-ci.org/deckarep/golang-set) -[![GoDoc](https://godoc.org/github.com/deckarep/golang-set?status.png)](http://godoc.org/github.com/deckarep/golang-set) - -## golang-set - - -The missing set collection for the Go language. Until Go has sets built-in...use this. - -Coming from Python one of the things I miss is the superbly wonderful set collection. This is my attempt to mimic the primary features of the set from Python. -You can of course argue that there is no need for a set in Go, otherwise the creators would have added one to the standard library. To those I say simply ignore this repository -and carry-on and to the rest that find this useful please contribute in helping me make it better by: - -* Helping to make more idiomatic improvements to the code. -* Helping to increase the performance of it. ~~(So far, no attempt has been made, but since it uses a map internally, I expect it to be mostly performant.)~~ -* Helping to make the unit-tests more robust and kick-ass. -* Helping to fill in the [documentation.](http://godoc.org/github.com/deckarep/golang-set) -* Simply offering feedback and suggestions. (Positive, constructive feedback is appreciated.) - -I have to give some credit for helping seed the idea with this post on [stackoverflow.](http://programmers.stackexchange.com/questions/177428/sets-data-structure-in-golang) - -*Update* - as of 3/9/2014, you can use a compile-time generic version of this package in the [gen](http://clipperhouse.github.io/gen/) framework. This framework allows you to use the golang-set in a completely generic and type-safe way by allowing you to generate a supporting .go file based on your custom types. - -## Features (as of 9/22/2014) - -* a CartesianProduct() method has been added with unit-tests: [Read more about the cartesian product](http://en.wikipedia.org/wiki/Cartesian_product) - -## Features (as of 9/15/2014) - -* a PowerSet() method has been added with unit-tests: [Read more about the Power set](http://en.wikipedia.org/wiki/Power_set) - -## Features (as of 4/22/2014) - -* One common interface to both implementations -* Two set implementations to choose from - * a thread-safe implementation designed for concurrent use - * a non-thread-safe implementation designed for performance -* 75 benchmarks for both implementations -* 35 unit tests for both implementations -* 14 concurrent tests for the thread-safe implementation - - - -Please see the unit test file for additional usage examples. The Python set documentation will also do a better job than I can of explaining how a set typically [works.](http://docs.python.org/2/library/sets.html) Please keep in mind -however that the Python set is a built-in type and supports additional features and syntax that make it awesome. - -## Examples but not exhaustive: - -```go -requiredClasses := mapset.NewSet() -requiredClasses.Add("Cooking") -requiredClasses.Add("English") -requiredClasses.Add("Math") -requiredClasses.Add("Biology") - -scienceSlice := []interface{}{"Biology", "Chemistry"} -scienceClasses := mapset.NewSetFromSlice(scienceSlice) - -electiveClasses := mapset.NewSet() -electiveClasses.Add("Welding") -electiveClasses.Add("Music") -electiveClasses.Add("Automotive") - -bonusClasses := mapset.NewSet() -bonusClasses.Add("Go Programming") -bonusClasses.Add("Python Programming") - -//Show me all the available classes I can take -allClasses := requiredClasses.Union(scienceClasses).Union(electiveClasses).Union(bonusClasses) -fmt.Println(allClasses) //Set{Cooking, English, Math, Chemistry, Welding, Biology, Music, Automotive, Go Programming, Python Programming} - - -//Is cooking considered a science class? -fmt.Println(scienceClasses.Contains("Cooking")) //false - -//Show me all classes that are not science classes, since I hate science. -fmt.Println(allClasses.Difference(scienceClasses)) //Set{Music, Automotive, Go Programming, Python Programming, Cooking, English, Math, Welding} - -//Which science classes are also required classes? -fmt.Println(scienceClasses.Intersect(requiredClasses)) //Set{Biology} - -//How many bonus classes do you offer? -fmt.Println(bonusClasses.Cardinality()) //2 - -//Do you have the following classes? Welding, Automotive and English? -fmt.Println(allClasses.IsSuperset(mapset.NewSetFromSlice([]interface{}{"Welding", "Automotive", "English"}))) //true -``` - -Thanks! - --Ralph - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/deckarep/golang-set/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - -[![Analytics](https://ga-beacon.appspot.com/UA-42584447-2/deckarep/golang-set)](https://github.com/igrigorik/ga-beacon) diff --git a/vendor/github.com/deckarep/golang-set/set.go b/vendor/github.com/deckarep/golang-set/set.go deleted file mode 100644 index 5d2b0725..00000000 --- a/vendor/github.com/deckarep/golang-set/set.go +++ /dev/null @@ -1,174 +0,0 @@ -/* -Open Source Initiative OSI - The MIT License (MIT):Licensing - -The MIT License (MIT) -Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) - -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. -*/ - -// Package mapset implements a simple and generic set collection. -// Items stored within it are unordered and unique. It supports -// typical set operations: membership testing, intersection, union, -// difference, symmetric difference and cloning. -// -// Package mapset provides two implementations. The default -// implementation is safe for concurrent access. There is a non-threadsafe -// implementation which is slightly more performant. -package mapset - -type Set interface { - // Adds an element to the set. Returns whether - // the item was added. - Add(i interface{}) bool - - // Returns the number of elements in the set. - Cardinality() int - - // Removes all elements from the set, leaving - // the emtpy set. - Clear() - - // Returns a clone of the set using the same - // implementation, duplicating all keys. - Clone() Set - - // Returns whether the given items - // are all in the set. - Contains(i ...interface{}) bool - - // Returns the difference between this set - // and other. The returned set will contain - // all elements of this set that are not also - // elements of other. - // - // Note that the argument to Difference - // must be of the same type as the receiver - // of the method. Otherwise, Difference will - // panic. - Difference(other Set) Set - - // Determines if two sets are equal to each - // other. If they have the same cardinality - // and contain the same elements, they are - // considered equal. The order in which - // the elements were added is irrelevant. - // - // Note that the argument to Equal must be - // of the same type as the receiver of the - // method. Otherwise, Equal will panic. - Equal(other Set) bool - - // Returns a new set containing only the elements - // that exist only in both sets. - // - // Note that the argument to Intersect - // must be of the same type as the receiver - // of the method. Otherwise, Intersect will - // panic. - Intersect(other Set) Set - - // Determines if every element in the other set - // is in this set. - // - // Note that the argument to IsSubset - // must be of the same type as the receiver - // of the method. Otherwise, IsSubset will - // panic. - IsSubset(other Set) bool - - // Determines if every element in this set is in - // the other set. - // - // Note that the argument to IsSuperset - // must be of the same type as the receiver - // of the method. Otherwise, IsSuperset will - // panic. - IsSuperset(other Set) bool - - // Returns a channel of elements that you can - // range over. - Iter() <-chan interface{} - - // Remove a single element from the set. - Remove(i interface{}) - - // Provides a convenient string representation - // of the current state of the set. - String() string - - // Returns a new set with all elements which are - // in either this set or the other set but not in both. - // - // Note that the argument to SymmetricDifference - // must be of the same type as the receiver - // of the method. Otherwise, SymmetricDifference - // will panic. - SymmetricDifference(other Set) Set - - // Returns a new set with all elements in both sets. - // - // Note that the argument to Union must be of the - - // same type as the receiver of the method. - // Otherwise, IsSuperset will panic. - Union(other Set) Set - - // Returns all subsets of a given set (Power Set). - PowerSet() Set - - // Returns the Cartesian Product of two sets. - CartesianProduct(other Set) Set - - // Returns the members of the set as a slice. - ToSlice() []interface{} -} - -// Creates and returns a reference to an empty set. -func NewSet(s ...interface{}) Set { - set := newThreadSafeSet() - for _, item := range s { - set.Add(item) - } - return &set -} - -// Creates and returns a new set with the given elements -func NewSetWith(elts ...interface{}) Set { - return NewSetFromSlice(elts) -} - -// Creates and returns a reference to a set from an existing slice -func NewSetFromSlice(s []interface{}) Set { - a := NewSet(s...) - return a -} - -func NewThreadUnsafeSet() Set { - set := newThreadUnsafeSet() - return &set -} - -func NewThreadUnsafeSetFromSlice(s []interface{}) Set { - a := NewThreadUnsafeSet() - for _, item := range s { - a.Add(item) - } - return a -} diff --git a/vendor/github.com/deckarep/golang-set/threadsafe.go b/vendor/github.com/deckarep/golang-set/threadsafe.go deleted file mode 100644 index 9dca94af..00000000 --- a/vendor/github.com/deckarep/golang-set/threadsafe.go +++ /dev/null @@ -1,204 +0,0 @@ -/* -Open Source Initiative OSI - The MIT License (MIT):Licensing - -The MIT License (MIT) -Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) - -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. -*/ - -package mapset - -import "sync" - -type threadSafeSet struct { - s threadUnsafeSet - sync.RWMutex -} - -func newThreadSafeSet() threadSafeSet { - return threadSafeSet{s: newThreadUnsafeSet()} -} - -func (set *threadSafeSet) Add(i interface{}) bool { - set.Lock() - ret := set.s.Add(i) - set.Unlock() - return ret -} - -func (set *threadSafeSet) Contains(i ...interface{}) bool { - set.RLock() - ret := set.s.Contains(i...) - set.RUnlock() - return ret -} - -func (set *threadSafeSet) IsSubset(other Set) bool { - o := other.(*threadSafeSet) - - set.RLock() - o.RLock() - - ret := set.s.IsSubset(&o.s) - set.RUnlock() - o.RUnlock() - return ret -} - -func (set *threadSafeSet) IsSuperset(other Set) bool { - return other.IsSubset(set) -} - -func (set *threadSafeSet) Union(other Set) Set { - o := other.(*threadSafeSet) - - set.RLock() - o.RLock() - - unsafeUnion := set.s.Union(&o.s).(*threadUnsafeSet) - ret := &threadSafeSet{s: *unsafeUnion} - set.RUnlock() - o.RUnlock() - return ret -} - -func (set *threadSafeSet) Intersect(other Set) Set { - o := other.(*threadSafeSet) - - set.RLock() - o.RLock() - - unsafeIntersection := set.s.Intersect(&o.s).(*threadUnsafeSet) - ret := &threadSafeSet{s: *unsafeIntersection} - set.RUnlock() - o.RUnlock() - return ret -} - -func (set *threadSafeSet) Difference(other Set) Set { - o := other.(*threadSafeSet) - - set.RLock() - o.RLock() - - unsafeDifference := set.s.Difference(&o.s).(*threadUnsafeSet) - ret := &threadSafeSet{s: *unsafeDifference} - set.RUnlock() - o.RUnlock() - return ret -} - -func (set *threadSafeSet) SymmetricDifference(other Set) Set { - o := other.(*threadSafeSet) - - unsafeDifference := set.s.SymmetricDifference(&o.s).(*threadUnsafeSet) - return &threadSafeSet{s: *unsafeDifference} -} - -func (set *threadSafeSet) Clear() { - set.Lock() - set.s = newThreadUnsafeSet() - set.Unlock() -} - -func (set *threadSafeSet) Remove(i interface{}) { - set.Lock() - delete(set.s, i) - set.Unlock() -} - -func (set *threadSafeSet) Cardinality() int { - set.RLock() - defer set.RUnlock() - return len(set.s) -} - -func (set *threadSafeSet) Iter() <-chan interface{} { - ch := make(chan interface{}) - go func() { - set.RLock() - - for elem := range set.s { - ch <- elem - } - close(ch) - set.RUnlock() - }() - - return ch -} - -func (set *threadSafeSet) Equal(other Set) bool { - o := other.(*threadSafeSet) - - set.RLock() - o.RLock() - - ret := set.s.Equal(&o.s) - set.RUnlock() - o.RUnlock() - return ret -} - -func (set *threadSafeSet) Clone() Set { - set.RLock() - - unsafeClone := set.s.Clone().(*threadUnsafeSet) - ret := &threadSafeSet{s: *unsafeClone} - set.RUnlock() - return ret -} - -func (set *threadSafeSet) String() string { - set.RLock() - ret := set.s.String() - set.RUnlock() - return ret -} - -func (set *threadSafeSet) PowerSet() Set { - set.RLock() - ret := set.s.PowerSet() - set.RUnlock() - return ret -} - -func (set *threadSafeSet) CartesianProduct(other Set) Set { - o := other.(*threadSafeSet) - - set.RLock() - o.RLock() - - unsafeCartProduct := set.s.CartesianProduct(&o.s).(*threadUnsafeSet) - ret := &threadSafeSet{s: *unsafeCartProduct} - set.RUnlock() - o.RUnlock() - return ret -} - -func (set *threadSafeSet) ToSlice() []interface{} { - set.RLock() - keys := make([]interface{}, 0, set.Cardinality()) - for elem := range set.s { - keys = append(keys, elem) - } - set.RUnlock() - return keys -} diff --git a/vendor/github.com/deckarep/golang-set/threadunsafe.go b/vendor/github.com/deckarep/golang-set/threadunsafe.go deleted file mode 100644 index 124521e2..00000000 --- a/vendor/github.com/deckarep/golang-set/threadunsafe.go +++ /dev/null @@ -1,246 +0,0 @@ -/* -Open Source Initiative OSI - The MIT License (MIT):Licensing - -The MIT License (MIT) -Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com) - -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. -*/ - -package mapset - -import ( - "fmt" - "reflect" - "strings" -) - -type threadUnsafeSet map[interface{}]struct{} - -type orderedPair struct { - first interface{} - second interface{} -} - -func newThreadUnsafeSet() threadUnsafeSet { - return make(threadUnsafeSet) -} - -func (pair *orderedPair) Equal(other orderedPair) bool { - if pair.first == other.first && - pair.second == other.second { - return true - } - - return false -} - -func (set *threadUnsafeSet) Add(i interface{}) bool { - _, found := (*set)[i] - (*set)[i] = struct{}{} - return !found //False if it existed already -} - -func (set *threadUnsafeSet) Contains(i ...interface{}) bool { - for _, val := range i { - if _, ok := (*set)[val]; !ok { - return false - } - } - return true -} - -func (set *threadUnsafeSet) IsSubset(other Set) bool { - _ = other.(*threadUnsafeSet) - for elem := range *set { - if !other.Contains(elem) { - return false - } - } - return true -} - -func (set *threadUnsafeSet) IsSuperset(other Set) bool { - return other.IsSubset(set) -} - -func (set *threadUnsafeSet) Union(other Set) Set { - o := other.(*threadUnsafeSet) - - unionedSet := newThreadUnsafeSet() - - for elem := range *set { - unionedSet.Add(elem) - } - for elem := range *o { - unionedSet.Add(elem) - } - return &unionedSet -} - -func (set *threadUnsafeSet) Intersect(other Set) Set { - o := other.(*threadUnsafeSet) - - intersection := newThreadUnsafeSet() - // loop over smaller set - if set.Cardinality() < other.Cardinality() { - for elem := range *set { - if other.Contains(elem) { - intersection.Add(elem) - } - } - } else { - for elem := range *o { - if set.Contains(elem) { - intersection.Add(elem) - } - } - } - return &intersection -} - -func (set *threadUnsafeSet) Difference(other Set) Set { - _ = other.(*threadUnsafeSet) - - difference := newThreadUnsafeSet() - for elem := range *set { - if !other.Contains(elem) { - difference.Add(elem) - } - } - return &difference -} - -func (set *threadUnsafeSet) SymmetricDifference(other Set) Set { - _ = other.(*threadUnsafeSet) - - aDiff := set.Difference(other) - bDiff := other.Difference(set) - return aDiff.Union(bDiff) -} - -func (set *threadUnsafeSet) Clear() { - *set = newThreadUnsafeSet() -} - -func (set *threadUnsafeSet) Remove(i interface{}) { - delete(*set, i) -} - -func (set *threadUnsafeSet) Cardinality() int { - return len(*set) -} - -func (set *threadUnsafeSet) Iter() <-chan interface{} { - ch := make(chan interface{}) - go func() { - for elem := range *set { - ch <- elem - } - close(ch) - }() - - return ch -} - -func (set *threadUnsafeSet) Equal(other Set) bool { - _ = other.(*threadUnsafeSet) - - if set.Cardinality() != other.Cardinality() { - return false - } - for elem := range *set { - if !other.Contains(elem) { - return false - } - } - return true -} - -func (set *threadUnsafeSet) Clone() Set { - clonedSet := newThreadUnsafeSet() - for elem := range *set { - clonedSet.Add(elem) - } - return &clonedSet -} - -func (set *threadUnsafeSet) String() string { - items := make([]string, 0, len(*set)) - - for elem := range *set { - items = append(items, fmt.Sprintf("%v", elem)) - } - return fmt.Sprintf("Set{%s}", strings.Join(items, ", ")) -} - -func (pair orderedPair) String() string { - return fmt.Sprintf("(%v, %v)", pair.first, pair.second) -} - -func (set *threadUnsafeSet) PowerSet() Set { - powSet := NewThreadUnsafeSet() - nullset := newThreadUnsafeSet() - powSet.Add(&nullset) - - for es := range *set { - u := newThreadUnsafeSet() - j := powSet.Iter() - for er := range j { - p := newThreadUnsafeSet() - if reflect.TypeOf(er).Name() == "" { - k := er.(*threadUnsafeSet) - for ek := range *(k) { - p.Add(ek) - } - } else { - p.Add(er) - } - p.Add(es) - u.Add(&p) - } - - powSet = powSet.Union(&u) - } - - return powSet -} - -func (set *threadUnsafeSet) CartesianProduct(other Set) Set { - o := other.(*threadUnsafeSet) - cartProduct := NewThreadUnsafeSet() - - for i := range *set { - for j := range *o { - elem := orderedPair{first: i, second: j} - cartProduct.Add(elem) - } - } - - return cartProduct -} - -func (set *threadUnsafeSet) ToSlice() []interface{} { - keys := make([]interface{}, 0, set.Cardinality()) - for elem := range *set { - keys = append(keys, elem) - } - - return keys -} From 0129cedd0eb5a0caff3a13c1db376a560e8ff6fa Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 21 Nov 2016 14:41:11 -0800 Subject: [PATCH 223/357] replica: Add DiskChildrenMap in RestAPI Now caller can get full list of disks, as well as relationship between them. The output format will be a map of map of bool. First part of #190. --- replica/replica.go | 4 ++++ replica/replica_test.go | 8 ++++++++ replica/rest/model.go | 36 +++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 1fbecb4e..fb99be52 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -784,3 +784,7 @@ func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { r.RUnlock() return c, err } + +func (r *Replica) ShowDiskChildrenMap() map[string]map[string]bool { + return r.diskChildrenMap +} diff --git a/replica/replica_test.go b/replica/replica_test.go index d62fa69b..2d9f9985 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -70,6 +70,14 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-head-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) + + dcm := r.ShowDiskChildrenMap() + c.Assert(len(dcm), Equals, 3) + c.Assert(len(dcm["volume-snap-000.img"]), Equals, 1) + c.Assert(dcm["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) + c.Assert(len(dcm["volume-snap-001.img"]), Equals, 1) + c.Assert(dcm["volume-snap-001.img"]["volume-head-002.img"], Equals, true) + c.Assert(dcm["volume-head-002.img"], IsNil) } func (s *TestSuite) TestRevert(c *C) { diff --git a/replica/rest/model.go b/replica/rest/model.go index 6dc14e06..237e599c 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -10,14 +10,15 @@ import ( type Replica struct { client.Resource - Dirty bool `json:"dirty"` - Rebuilding bool `json:"rebuilding"` - Head string `json:"head"` - Parent string `json:"parent"` - Size string `json:"size"` - SectorSize int64 `json:"sectorSize"` - State string `json:"state"` - Chain []string `json:"chain"` + Dirty bool `json:"dirty"` + Rebuilding bool `json:"rebuilding"` + Head string `json:"head"` + Parent string `json:"parent"` + Size string `json:"size"` + SectorSize int64 `json:"sectorSize"` + State string `json:"state"` + Chain []string `json:"chain"` + DiskChildrenMap map[string]map[string]bool `json:"diskchildrenmap"` } type CreateInput struct { @@ -113,6 +114,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, if rep != nil { r.Chain, _ = rep.DisplayChain() + r.DiskChildrenMap = rep.ShowDiskChildrenMap() } return r @@ -135,36 +137,36 @@ func NewSchema() *client.Schemas { replica.ResourceMethods = []string{"GET", "DELETE"} replica.ResourceActions = map[string]client.Action{ - "close": client.Action{ + "close": { Output: "replica", }, - "open": client.Action{ + "open": { Output: "replica", }, - "reload": client.Action{ + "reload": { Output: "replica", }, - "snapshot": client.Action{ + "snapshot": { Input: "snapshotInput", Output: "replica", }, - "removedisk": client.Action{ + "removedisk": { Input: "removediskInput", Output: "replica", }, - "setrebuilding": client.Action{ + "setrebuilding": { Input: "rebuildingInput", Output: "replica", }, - "create": client.Action{ + "create": { Input: "createInput", Output: "replica", }, - "revert": client.Action{ + "revert": { Input: "revertInput", Output: "replica", }, - "prepareremovedisk": client.Action{ + "prepareremovedisk": { Input: "prepareRemoveDiskInput", Output: "prepareRemoveDiskOutput", }, From 9ac7f335518be281929e6164bea0f56bb42c630a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 22 Nov 2016 10:47:59 -0800 Subject: [PATCH 224/357] replica: Add Disks in rest API It's going to list all the disks for the replica, not only ones in the live chain --- replica/replica.go | 8 ++++++++ replica/replica_test.go | 15 +++++++++++++++ replica/rest/model.go | 2 ++ 3 files changed, 25 insertions(+) diff --git a/replica/replica.go b/replica/replica.go index fb99be52..4d2c8c60 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -785,6 +785,14 @@ func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { return c, err } +func (r *Replica) ListDisks() []string { + result := []string{} + for disk := range r.diskData { + result = append(result, disk) + } + return result +} + func (r *Replica) ShowDiskChildrenMap() map[string]map[string]bool { return r.diskChildrenMap } diff --git a/replica/replica_test.go b/replica/replica_test.go index 2d9f9985..ca07e00b 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -157,6 +157,21 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-005.img"].Parent, Equals, "volume-snap-001.img") + disks := r.ListDisks() + c.Assert(len(disks), Equals, 4) + verifyDisks := map[string]bool{ + "volume-snap-000.img": false, + "volume-snap-001.img": false, + "volume-snap-003.img": false, + "volume-head-005.img": false, + } + for _, disk := range disks { + value, exists := verifyDisks[disk] + c.Assert(exists, Equals, true) + c.Assert(value, Equals, false) + verifyDisks[disk] = true + } + c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-head-005.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-003.img"], IsNil) diff --git a/replica/rest/model.go b/replica/rest/model.go index 237e599c..ab9c6e79 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -18,6 +18,7 @@ type Replica struct { SectorSize int64 `json:"sectorSize"` State string `json:"state"` Chain []string `json:"chain"` + Disks []string `json:"disks"` DiskChildrenMap map[string]map[string]bool `json:"diskchildrenmap"` } @@ -114,6 +115,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, if rep != nil { r.Chain, _ = rep.DisplayChain() + r.Disks = rep.ListDisks() r.DiskChildrenMap = rep.ShowDiskChildrenMap() } From b03b54f5c22b2d4340102b888592c73d86eb1bab Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 21 Nov 2016 14:27:45 -0800 Subject: [PATCH 225/357] replica: Sync snapshots not in the chain as well Fix #248 --- replica/replica.go | 7 +++---- sync/sync.go | 12 ++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 4d2c8c60..12b41cdc 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -114,6 +114,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF } r.volume.sectorSize = defaultSectorSize + // Scan all the disks to build the disk map exists, err := r.readMetadata() if err != nil { return nil, err @@ -137,7 +138,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF } if exists { - if err := r.openFiles(); err != nil { + if err := r.openLiveChain(); err != nil { return nil, err } } else if size <= 0 { @@ -655,9 +656,7 @@ func (r *Replica) updateParentDisk(name, oldParent string) error { return r.encodeToFile(child, child.name+metadataSuffix) } -func (r *Replica) openFiles() error { - // We have live chain, which will be included here - // We also need to scan all other disks, and track them properly +func (r *Replica) openLiveChain() error { chain, err := r.Chain() if err != nil { return err diff --git a/sync/sync.go b/sync/sync.go index 1b96b22f..3206440f 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -278,20 +278,20 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl fromHead := "" toHead := "" - for _, i := range from.Chain { - if strings.Contains(i, "volume-head") { + for _, disk := range from.Disks { + if strings.Contains(disk, "volume-head") { if fromHead != "" { - return fmt.Errorf("More than one head volume found in the from replica %s, %s", fromHead, i) + return fmt.Errorf("More than one head volume found in the from replica %s, %s", fromHead, disk) } - fromHead = i + fromHead = disk continue } - if err := t.syncFile(i, "", fromClient, toClient); err != nil { + if err := t.syncFile(disk, "", fromClient, toClient); err != nil { return err } - if err := t.syncFile(i+".meta", "", fromClient, toClient); err != nil { + if err := t.syncFile(disk+".meta", "", fromClient, toClient); err != nil { return err } } From 1557011b05730942260550fee9afa0b7590ae61e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 15 Nov 2016 18:36:24 -0800 Subject: [PATCH 226/357] controller: Allow revert if at least one replica is in RW mode Also return success if even only one replica success in revert But doesn't allow revert if one replica is in WO mode. Issue #243 --- controller/revert.go | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/controller/revert.go b/controller/revert.go index 200e4e40..b4519107 100644 --- a/controller/revert.go +++ b/controller/revert.go @@ -10,11 +10,24 @@ import ( ) func (c *Controller) Revert(name string) error { + doable := false + rw := false + wo := false for _, rep := range c.replicas { - if rep.Mode != types.RW { - return fmt.Errorf("Replica %s is in mode %s", rep.Address, rep.Mode) + //BUG: Need to deal with replica in rebuilding(WO) mode. + if rep.Mode == types.RW { + rw = true + } else if rep.Mode == types.WO { + wo = true } } + if rw && !wo { + doable = true + } + + if !doable { + return fmt.Errorf("Not valid state to revert, rebuilding in process or all replica are in ERR state") + } clients, name, err := c.clientsAndSnapshot(name) if err != nil { @@ -28,14 +41,22 @@ func (c *Controller) Revert(name string) error { c.Lock() defer c.Unlock() + minimalSuccess := false for address, client := range clients { logrus.Infof("Reverting to snapshot %s on %s", name, address) if err := client.Revert(name); err != nil { + logrus.Errorf("Error on reverting to %s on %s: %v", name, address, err) c.setReplicaModeNoLock(address, types.ERR) - return err + } else { + minimalSuccess = true + logrus.Infof("Reverting to snapshot %s on %s successed", name, address) } } + if !minimalSuccess { + return fmt.Errorf("Fail to revert to %v on all replicas", name) + } + return c.startFrontend() } @@ -43,6 +64,13 @@ func (c *Controller) clientsAndSnapshot(name string) (map[string]*client.Replica clients := map[string]*client.ReplicaClient{} for _, replica := range c.replicas { + if replica.Mode == types.WO { + return nil, "", fmt.Errorf("Cannot revert %s during rebuilding process", replica.Address) + } + if replica.Mode != types.RW { + continue + } + if !strings.HasPrefix(replica.Address, "tcp://") { return nil, "", fmt.Errorf("Backend %s does not support revert", replica.Address) } From 7c71b5e207ede022f08e2793c0d9308cd536f1e7 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 15 Nov 2016 16:41:50 -0800 Subject: [PATCH 227/357] controller: Allow create snapshot even one replica is bad Issue #243 --- controller/control.go | 12 ++++++++---- controller/replicator.go | 32 +++++++++++++++++--------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/controller/control.go b/controller/control.go index de39b47e..6dbb0699 100644 --- a/controller/control.go +++ b/controller/control.go @@ -80,7 +80,7 @@ func (c *Controller) Snapshot(name string) (string, error) { name = util.UUID() } - return name, c.backend.Snapshot(name) + return name, c.handleErrorNoLock(c.backend.Snapshot(name)) } func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { @@ -265,9 +265,8 @@ func (c *Controller) ReadAt(b []byte, off int64) (int, error) { return n, err } -func (c *Controller) handleError(err error) error { +func (c *Controller) handleErrorNoLock(err error) error { if bErr, ok := err.(*BackendError); ok { - c.Lock() if len(bErr.Errors) > 0 { for address, replicaErr := range bErr.Errors { logrus.Errorf("Setting replica %s to ERR due to: %v", address, replicaErr) @@ -282,7 +281,6 @@ func (c *Controller) handleError(err error) error { } } } - c.Unlock() } if err != nil { logrus.Errorf("I/O error: %v", err) @@ -290,6 +288,12 @@ func (c *Controller) handleError(err error) error { return err } +func (c *Controller) handleError(err error) error { + c.Lock() + defer c.Unlock() + return c.handleErrorNoLock(err) +} + func (c *Controller) reset() { c.replicas = []types.Replica{} c.backend = &replicator{} diff --git a/controller/replicator.go b/controller/replicator.go index f2bd64e4..6087535c 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -172,27 +172,29 @@ func (r *replicator) SetMode(address string, mode types.Mode) { } func (r *replicator) Snapshot(name string) error { - for _, wrapper := range r.backends { - if wrapper.mode == types.ERR { - return errors.New("Can not snapshot while a replica is in ERR") - } + retError := &BackendError{ + Errors: map[string]error{}, } - - var lastErr error wg := sync.WaitGroup{} - for _, backend := range r.backends { - wg.Add(1) - go func(backend types.Backend) { - if err := backend.Snapshot(name); err != nil { - lastErr = err - } - wg.Done() - }(backend.backend) + for addr, backend := range r.backends { + if backend.mode != types.ERR { + wg.Add(1) + go func(backend types.Backend) { + if err := backend.Snapshot(name); err != nil { + retError.Errors[addr] = err + } + wg.Done() + }(backend.backend) + } } wg.Wait() - return lastErr + + if len(retError.Errors) != 0 { + return retError + } + return nil } func (r *replicator) Close() error { From 22de00763ffdaca45900a75c909727cc6ca4f01a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 22 Nov 2016 15:04:59 -0800 Subject: [PATCH 228/357] Fix snapshot creation during rebuilding process Issue #247 --- sync/sync.go | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/sync/sync.go b/sync/sync.go index 3206440f..9f7053a2 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -12,6 +12,10 @@ import ( replicaClient "github.com/rancher/longhorn/replica/client" ) +var ( + RetryCounts = 3 +) + type Task struct { client *client.ControllerClient } @@ -182,7 +186,7 @@ func (t *Task) AddReplica(replica string) error { return err } - if err := t.syncFiles(fromClient, toClient); err != nil { + if err = t.syncFiles(fromClient, toClient); err != nil { return err } @@ -310,11 +314,35 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl return fmt.Errorf("Failed to find both source and destination head volumes, %s, %s", fromHead, toHead) } - if err := t.syncFile(fromHead+".meta", toHead+".meta", fromClient, toClient); err != nil { - return err + for i := 0; i < RetryCounts; i++ { + err = t.syncFile(fromHead+".meta", toHead+".meta", fromClient, toClient) + if err == nil { + break + } + + logrus.Warnf("Retry sync volume head since may caused by snapshot in progress: %v", + fromHead, toHead, err) + + from, ferr := fromClient.GetReplica() + if ferr != nil { + return ferr + } + + fromHead = "" + for _, disk := range from.Disks { + if strings.Contains(disk, "volume-head") { + if fromHead != "" { + return fmt.Errorf("More than one head volume found in the from replica %s, %s", + fromHead, disk) + } + fromHead = disk + continue + } + } + logrus.Warnf("Sync current volume head %s to %s", fromHead, toHead) } - return nil + return err } func (t *Task) syncFile(from, to string, fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { From 868fc8aa5a9e1cd90db24ac697b9a40594b12e1b Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 22 Nov 2016 16:39:34 -0800 Subject: [PATCH 229/357] replica: Enforce limitation of maximum 250 snapshots Issue #247 --- replica/replica.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 12b41cdc..3a15bb73 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -18,12 +18,13 @@ import ( ) const ( - metadataSuffix = ".meta" - imgSuffix = ".img" - volumeMetaData = "volume.meta" - defaultSectorSize = 4096 - headName = "volume-head-%03d.img" - diskName = "volume-snap-%s.img" + metadataSuffix = ".meta" + imgSuffix = ".img" + volumeMetaData = "volume.meta" + defaultSectorSize = 4096 + headName = "volume-head-%03d.img" + diskName = "volume-snap-%s.img" + maximumChainLength = 250 ) var ( @@ -559,6 +560,10 @@ func (r *Replica) createDisk(name string) error { return fmt.Errorf("Can not create disk on read-only replica") } + if len(r.activeDiskData)+1 > maximumChainLength { + return fmt.Errorf("Too many active disks: %v", len(r.activeDiskData)+1) + } + done := false oldHead := r.info.Head newSnapName := GenerateSnapshotDiskName(name) @@ -662,6 +667,10 @@ func (r *Replica) openLiveChain() error { return err } + if len(chain) > maximumChainLength { + return fmt.Errorf("Live chain is too long: %v", len(chain)) + } + for i := len(chain) - 1; i >= 0; i-- { parent := chain[i] f, err := r.openFile(parent, 0) From 2671c33a0efb32223d415ccfc20b6a608a750e11 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 22 Nov 2016 17:34:27 -0800 Subject: [PATCH 230/357] controller: Make it possible for backend to report available slots for snapshots Otherwise controller will mark user error(too many snapshots) as replica error and won't be able to recover from it. --- backend/file/file.go | 4 ++++ backend/remote/remote.go | 8 ++++++++ controller/control.go | 12 ++++++++++++ controller/replicator.go | 26 ++++++++++++++++++++++++++ replica/replica.go | 4 ++++ replica/rest/model.go | 2 ++ types/types.go | 1 + 7 files changed, 57 insertions(+) diff --git a/backend/file/file.go b/backend/file/file.go index 4f57a400..ad72783e 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -39,6 +39,10 @@ func (f *Wrapper) SectorSize() (int64, error) { return 4096, nil } +func (f *Wrapper) RemainSnapshots() (int, error) { + return 1, nil +} + func (ff *Factory) Create(address string) (types.Backend, error) { logrus.Infof("Creating file: %s", address) file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE, 0600) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index e08756c9..e6a3ab73 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -109,6 +109,14 @@ func (r *Remote) SectorSize() (int64, error) { return replica.SectorSize, nil } +func (r *Remote) RemainSnapshots() (int, error) { + replica, err := r.info() + if err != nil { + return 0, err + } + return replica.RemainSnapshots, nil +} + func (r *Remote) info() (rest.Replica, error) { var replica rest.Replica req, err := http.NewRequest("GET", r.replicaURL, nil) diff --git a/controller/control.go b/controller/control.go index 6dbb0699..77669918 100644 --- a/controller/control.go +++ b/controller/control.go @@ -80,6 +80,12 @@ func (c *Controller) Snapshot(name string) (string, error) { name = util.UUID() } + if remain, err := c.backend.RemainSnapshots(); err != nil { + return "", err + } else if remain <= 0 { + return "", fmt.Errorf("Too many snapshots created") + } + return name, c.handleErrorNoLock(c.backend.Snapshot(name)) } @@ -91,6 +97,12 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, if snapshot { uuid := util.UUID() + if remain, err := c.backend.RemainSnapshots(); err != nil { + return err + } else if remain <= 0 { + return fmt.Errorf("Too many snapshots created") + } + if err := c.backend.Snapshot(uuid); err != nil { newBackend.Close() return err diff --git a/controller/replicator.go b/controller/replicator.go index 6087535c..7505cccc 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "math" "strings" "sync" @@ -228,3 +229,28 @@ type backendWrapper struct { backend types.Backend mode types.Mode } + +func (r *replicator) RemainSnapshots() (int, error) { + // addReplica may call here even without any backend + if len(r.backends) == 0 { + return 1, nil + } + + ret := math.MaxInt32 + for _, backend := range r.backends { + if backend.mode == types.ERR { + continue + } + // ignore error and try next one. We can deal with all + // error situation later + if remain, err := backend.backend.RemainSnapshots(); err == nil { + if remain < ret { + ret = remain + } + } + } + if ret == math.MaxInt32 { + return 0, fmt.Errorf("Cannot get valid result for remain snapshot") + } + return ret, nil +} diff --git a/replica/replica.go b/replica/replica.go index 3a15bb73..3d0c72b2 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -804,3 +804,7 @@ func (r *Replica) ListDisks() []string { func (r *Replica) ShowDiskChildrenMap() map[string]map[string]bool { return r.diskChildrenMap } + +func (r *Replica) GetRemainSnapshotCounts() int { + return maximumChainLength - len(r.activeDiskData) +} diff --git a/replica/rest/model.go b/replica/rest/model.go index ab9c6e79..62c8b699 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -20,6 +20,7 @@ type Replica struct { Chain []string `json:"chain"` Disks []string `json:"disks"` DiskChildrenMap map[string]map[string]bool `json:"diskchildrenmap"` + RemainSnapshots int `json:"remainsnapshots"` } type CreateInput struct { @@ -117,6 +118,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, r.Chain, _ = rep.DisplayChain() r.Disks = rep.ListDisks() r.DiskChildrenMap = rep.ShowDiskChildrenMap() + r.RemainSnapshots = rep.GetRemainSnapshotCounts() } return r diff --git a/types/types.go b/types/types.go index ab97e19a..081eadf6 100644 --- a/types/types.go +++ b/types/types.go @@ -28,6 +28,7 @@ type Backend interface { Snapshot(name string) error Size() (int64, error) SectorSize() (int64, error) + RemainSnapshots() (int, error) } type BackendFactory interface { From a3d9ef4cb141602b968e85be825d1f3ab30a5a5f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 23 Nov 2016 15:48:51 -0800 Subject: [PATCH 231/357] Fix golint issues --- agent/controller/controller.go | 6 +++--- agent/controller/rest/snapshot.go | 4 ++-- frontend/tcmu/frontend.go | 2 +- util/util.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/agent/controller/controller.go b/agent/controller/controller.go index a8de658b..1b2afc15 100644 --- a/agent/controller/controller.go +++ b/agent/controller/controller.go @@ -331,18 +331,18 @@ func (c *Controller) retryErroredReplicas() error { func (c *Controller) removeAndAdd(replica rest.Replica, replicaMD *replica) error { logrus.Infof("Removing errored replica %v for re-add.", replica.Address) if _, err := c.client.DeleteReplica(replica.Address); err != nil { - return fmt.Errorf("Error removing errored replica %v: %v.", replica.Address, err) + return fmt.Errorf("error removing errored replica %v: %v", replica.Address, err) } freshReplica, err := replicaMD.client.GetReplica() if err != nil { - return fmt.Errorf("Error getting replica %v during removeAndAdd: %v.", replica.Address, err) + return fmt.Errorf("error getting replica %v during removeAndAdd: %v", replica.Address, err) } if _, ok := freshReplica.Actions["close"]; ok { err := replicaMD.client.Close() if err != nil { - return fmt.Errorf("Error closing replica %v before adding: %v.", replica.Address, err) + return fmt.Errorf("error closing replica %v before adding: %v", replica.Address, err) } } diff --git a/agent/controller/rest/snapshot.go b/agent/controller/rest/snapshot.go index 9d30ffc9..e798a3df 100644 --- a/agent/controller/rest/snapshot.go +++ b/agent/controller/rest/snapshot.go @@ -32,7 +32,7 @@ func (s *Server) GetSnapshot(rw http.ResponseWriter, req *http.Request) error { vars := mux.Vars(req) id, ok := vars["id"] if !ok { - return fmt.Errorf("Snapshot id not supplied.") + return fmt.Errorf("snapshot id not supplied") } snap, err := s.getSnapshot(apiContext, id) @@ -71,7 +71,7 @@ func (s *Server) DeleteSnapshot(rw http.ResponseWriter, req *http.Request) error vars := mux.Vars(req) id, ok := vars["id"] if !ok { - return fmt.Errorf("Snapshot id not supplied.") + return fmt.Errorf("snapshot id not supplied") } snapshot, err := s.getSnapshot(apiContext, id) diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index 7fdae662..0055f947 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -301,7 +301,7 @@ func remove(path string) error { case err := <-done: return err case <-time.After(30 * time.Second): - return fmt.Errorf("Timeout trying to delete %s.", path) + return fmt.Errorf("timeout trying to delete %s", path) } } diff --git a/util/util.go b/util/util.go index 68f5e078..b3b7967d 100644 --- a/util/util.go +++ b/util/util.go @@ -342,6 +342,6 @@ func remove(path string) error { case err := <-done: return err case <-time.After(30 * time.Second): - return fmt.Errorf("Timeout trying to delete %s.", path) + return fmt.Errorf("timeout trying to delete %s", path) } } From 2f61099282a832542fe8ebbb188f0a26930219e7 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 28 Nov 2016 14:55:43 -0800 Subject: [PATCH 232/357] util: No longer create block dev node, use symbolic link instead It may caused a kernel bug before. And there isn't a point to create block dev node anyway. If the original device is gone, it won't be an accident so longhorn device needs to react as well. Fixes #253. --- util/util.go | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/util/util.go b/util/util.go index b3b7967d..f5e05865 100644 --- a/util/util.go +++ b/util/util.go @@ -15,7 +15,6 @@ import ( "github.com/satori/go.uuid" "github.com/yasker/go-iscsi-helper/iscsi" iutil "github.com/yasker/go-iscsi-helper/util" - "golang.org/x/sys/unix" ) var ( @@ -297,51 +296,22 @@ func DeleteTarget(target string) error { } func DuplicateDevice(src, dest string) error { - stat := unix.Stat_t{} - if err := unix.Stat(src, &stat); err != nil { + if st, err := os.Stat(src); err != nil { return fmt.Errorf("Cannot duplicate device because cannot find %s: %v", src, err) + } else if st.Mode()&os.ModeDevice == 0 { + return fmt.Errorf("Device %s is not a block device", src) } - major := int(stat.Rdev / 256) - minor := int(stat.Rdev % 256) - if err := mknod(dest, major, minor); err != nil { - return fmt.Errorf("Cannot duplicate device %s to %s", src, dest) + if err := os.Symlink(src, dest); err != nil { + return fmt.Errorf("Cannot duplicate device %s to %s: %v", src, dest, err) } return nil } -func mknod(device string, major, minor int) error { - var fileMode os.FileMode = 0600 - fileMode |= unix.S_IFBLK - dev := int((major << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)) - - logrus.Infof("Creating device %s %d:%d", device, major, minor) - return unix.Mknod(device, uint32(fileMode), dev) -} - func RemoveDevice(dev string) error { if _, err := os.Stat(dev); err == nil { - if err := remove(dev); err != nil { + if err := os.Remove(dev); err != nil { return fmt.Errorf("Failed to removing device %s, %v", dev, err) } } return nil } - -func removeAsync(path string, done chan<- error) { - if err := os.Remove(path); err != nil && !os.IsNotExist(err) { - logrus.Errorf("Unable to remove: %v", path) - done <- err - } - done <- nil -} - -func remove(path string) error { - done := make(chan error) - go removeAsync(path, done) - select { - case err := <-done: - return err - case <-time.After(30 * time.Second): - return fmt.Errorf("timeout trying to delete %s", path) - } -} From 7378037a293ca892e4ffe0f981f88c8916607383 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 28 Nov 2016 15:25:00 -0800 Subject: [PATCH 233/357] app: Don't panic when got unexpected result Handle error command gracefully. But also don't hide any serious issues. Fixes #223. --- main.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 24d82c28..dcb43660 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,8 @@ import ( "fmt" "log" "os" + "runtime" + "runtime/debug" "runtime/pprof" "github.com/Sirupsen/logrus" @@ -16,6 +18,7 @@ import ( ) func main() { + defer cleanup() reexec.Register("ssync", ssync.Main) reexec.Register("sfold", sfold.Main) reexec.Register("sbackup", backup.Main) @@ -25,6 +28,32 @@ func main() { } } +// ResponseLogAndError would log the error before call ResponseError() +func ResponseLogAndError(v interface{}) { + if e, ok := v.(*logrus.Entry); ok { + logrus.Errorln(e.Message) + fmt.Println(e.Message) + } else { + e, isErr := v.(error) + _, isRuntimeErr := e.(runtime.Error) + if isErr && !isRuntimeErr { + logrus.Errorln(fmt.Sprint(e)) + fmt.Println(fmt.Sprint(e)) + } else { + logrus.Errorln("Caught FATAL error: ", v) + debug.PrintStack() + fmt.Println("Caught FATAL error: ", v) + } + } +} + +func cleanup() { + if r := recover(); r != nil { + ResponseLogAndError(r) + os.Exit(1) + } +} + func cmdNotFound(c *cli.Context, command string) { panic(fmt.Errorf("Unrecognized command: %s", command)) } @@ -75,6 +104,6 @@ func longhornCli() { a.OnUsageError = onUsageError if err := a.Run(os.Args); err != nil { - logrus.Fatal(err) + logrus.Fatal("Error when executing command: ", err) } } From b2c0fe4bd61537d83a0db6c4c5dabfa6ec06d945 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 28 Nov 2016 15:43:54 -0800 Subject: [PATCH 234/357] app: Ignore chain for replica in ERR state when list replica Fixes #241. Notice if the replica isn't in ERR yet, it will still take maximum of 30 seconds for query to timeout. --- app/ls_replica.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/ls_replica.go b/app/ls_replica.go index ff48d907..4e625fad 100644 --- a/app/ls_replica.go +++ b/app/ls_replica.go @@ -41,6 +41,10 @@ func lsReplica(c *cli.Context) error { tw := tabwriter.NewWriter(os.Stdout, 0, 20, 1, ' ', 0) fmt.Fprintf(tw, format, "ADDRESS", "MODE", "CHAIN") for _, r := range reps { + if r.Mode == "ERR" { + fmt.Fprintf(tw, format, r.Address, r.Mode, "") + continue + } chain := interface{}("") chainList, err := getChain(r.Address) if err == nil { From 08c87134a7dd4bc7840feb669f202a88ed45fcb5 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 28 Nov 2016 17:36:59 -0800 Subject: [PATCH 235/357] util: Move iscsi related functions to iscsi.go --- util/scsi.go | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++ util/util.go | 211 ------------------------------------------------- 2 files changed, 218 insertions(+), 211 deletions(-) create mode 100644 util/scsi.go diff --git a/util/scsi.go b/util/scsi.go new file mode 100644 index 00000000..67bcf0df --- /dev/null +++ b/util/scsi.go @@ -0,0 +1,218 @@ +package util + +import ( + "fmt" + "os" + "strings" + "time" + + "github.com/Sirupsen/logrus" + "github.com/yasker/go-iscsi-helper/iscsi" + iutil "github.com/yasker/go-iscsi-helper/util" +) + +type ScsiDevice struct { + Target string + Device string + BackingFile string + BSType string + BSOpts string +} + +func NewScsiDevice(name, backingFile, bsType, bsOpts string) (*ScsiDevice, error) { + dev := &ScsiDevice{ + Target: GetTargetName(name), + BackingFile: backingFile, + BSType: bsType, + BSOpts: bsOpts, + } + return dev, nil +} + +func GetTargetName(name string) string { + return "iqn.2014-09.com.rancher:" + name +} + +func GetLocalIP() (string, error) { + ips, err := iutil.GetLocalIPs() + if err != nil { + return "", err + } + return ips[0], nil +} + +func StartScsi(dev *ScsiDevice) error { + ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + if err != nil { + return err + } + + if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + return err + } + + localIP, err := GetLocalIP() + if err != nil { + return err + } + + // Setup target + if err := iscsi.StartDaemon(false); err != nil { + return err + } + if err := iscsi.CreateTarget(TargetID, dev.Target); err != nil { + return err + } + if err := iscsi.AddLun(TargetID, TargetLunID, dev.BackingFile, dev.BSType, dev.BSOpts); err != nil { + return err + } + if err := iscsi.BindInitiator(TargetID, "ALL"); err != nil { + return err + } + + // Setup initiator + err = nil + for i := 0; i < RetryCounts; i++ { + err = iscsi.DiscoverTarget(localIP, dev.Target, ne) + if iscsi.IsTargetDiscovered(localIP, dev.Target, ne) { + break + } + + logrus.Warnf("FAIL to discover %v", err) + // This is a trick to recover from the case. Remove the + // empty entries in /etc/iscsi/nodes/. If one of the entry + // is empty it will triggered the issue. + if err := iscsi.CleanupScsiNodes(dev.Target, ne); err != nil { + logrus.Warnf("Fail to cleanup nodes for %v: %v", dev.Target, err) + } else { + logrus.Warnf("Nodes cleaned up for %v", dev.Target) + } + + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + if err := iscsi.LoginTarget(localIP, dev.Target, ne); err != nil { + return err + } + if dev.Device, err = iscsi.GetDevice(localIP, dev.Target, TargetLunID, ne); err != nil { + return err + } + + deviceFound := false + for i := 0; i < RetryCounts; i++ { + if st, err := os.Stat(dev.Device); err == nil && (st.Mode()&os.ModeDevice != 0) { + deviceFound = true + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + if !deviceFound { + return fmt.Errorf("Failed to wait for device %s to show up", dev.Device) + } + return nil +} + +func StopScsi(volumeName string) error { + target := GetTargetName(volumeName) + if err := LogoutTarget(target); err != nil { + return fmt.Errorf("Fail to logout target: %v", err) + } + if err := DeleteTarget(target); err != nil { + return fmt.Errorf("Fail to delete target: %v", err) + } + return nil +} + +func LogoutTarget(target string) error { + ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + if err != nil { + return err + } + ip, err := GetLocalIP() + if err != nil { + return err + } + + if err := iscsi.CheckForInitiatorExistence(ne); err != nil { + return err + } + if iscsi.IsTargetLoggedIn(ip, target, ne) { + var err error + loggingOut := false + + logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) + for i := 0; i < RetryCounts; i++ { + err = iscsi.LogoutTarget(ip, target, ne) + if err == nil { + break + } + // The timeout for response may return in the future, + // check session to know if it's logged out or not + if strings.Contains(err.Error(), "Timeout executing: ") { + loggingOut = true + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + // Wait for device to logout + if loggingOut { + logrus.Infof("Logout SCSI device timeout, waiting for logout complete") + for i := 0; i < RetryCounts; i++ { + if !iscsi.IsTargetLoggedIn(ip, target, ne) { + err = nil + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + } + if err != nil { + return fmt.Errorf("Failed to logout target: %v", err) + } + /* + * Immediately delete target after logout may result in error: + * + * "Could not execute operation on all records: encountered + * iSCSI database failure" in iscsiadm + * + * This happenes especially there are other iscsiadm db + * operations go on at the same time. + * Retry to workaround this issue. Also treat "exit status + * 21"(no record found) as valid result + */ + for i := 0; i < RetryCounts; i++ { + if !iscsi.IsTargetDiscovered(ip, target, ne) { + err = nil + break + } + + err = iscsi.DeleteDiscoveredTarget(ip, target, ne) + if err == nil || strings.Contains(err.Error(), "exit status 21") { + err = nil + break + } + time.Sleep(time.Duration(RetryInterval) * time.Second) + } + if err != nil { + return err + } + } + return nil +} + +func DeleteTarget(target string) error { + if tid, err := iscsi.GetTargetTid(target); err == nil && tid != -1 { + if tid != TargetID { + logrus.Fatalf("BUG: Invalid TID %v found for %v", tid, target) + } + logrus.Infof("Shutdown SCSI target %v", target) + if err := iscsi.UnbindInitiator(TargetID, "ALL"); err != nil { + return err + } + if err := iscsi.DeleteLun(TargetID, TargetLunID); err != nil { + return err + } + if err := iscsi.DeleteTarget(TargetID); err != nil { + return err + } + } + return nil +} diff --git a/util/util.go b/util/util.go index f5e05865..37e1f963 100644 --- a/util/util.go +++ b/util/util.go @@ -7,14 +7,9 @@ import ( "os" "regexp" "strconv" - "strings" - "time" - "github.com/Sirupsen/logrus" "github.com/gorilla/handlers" "github.com/satori/go.uuid" - "github.com/yasker/go-iscsi-helper/iscsi" - iutil "github.com/yasker/go-iscsi-helper/util" ) var ( @@ -89,212 +84,6 @@ func (h filteredLoggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque h.loggingHandler.ServeHTTP(w, req) } -type ScsiDevice struct { - Target string - Device string - BackingFile string - BSType string - BSOpts string -} - -func NewScsiDevice(name, backingFile, bsType, bsOpts string) (*ScsiDevice, error) { - dev := &ScsiDevice{ - Target: GetTargetName(name), - BackingFile: backingFile, - BSType: bsType, - BSOpts: bsOpts, - } - return dev, nil -} - -func GetTargetName(name string) string { - return "iqn.2014-09.com.rancher:" + name -} - -func GetLocalIP() (string, error) { - ips, err := iutil.GetLocalIPs() - if err != nil { - return "", err - } - return ips[0], nil -} - -func StartScsi(dev *ScsiDevice) error { - ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") - if err != nil { - return err - } - - if err := iscsi.CheckForInitiatorExistence(ne); err != nil { - return err - } - - localIP, err := GetLocalIP() - if err != nil { - return err - } - - // Setup target - if err := iscsi.StartDaemon(false); err != nil { - return err - } - if err := iscsi.CreateTarget(TargetID, dev.Target); err != nil { - return err - } - if err := iscsi.AddLun(TargetID, TargetLunID, dev.BackingFile, dev.BSType, dev.BSOpts); err != nil { - return err - } - if err := iscsi.BindInitiator(TargetID, "ALL"); err != nil { - return err - } - - // Setup initiator - err = nil - for i := 0; i < RetryCounts; i++ { - err = iscsi.DiscoverTarget(localIP, dev.Target, ne) - if iscsi.IsTargetDiscovered(localIP, dev.Target, ne) { - break - } - - logrus.Warnf("FAIL to discover %v", err) - // This is a trick to recover from the case. Remove the - // empty entries in /etc/iscsi/nodes/. If one of the entry - // is empty it will triggered the issue. - if err := iscsi.CleanupScsiNodes(dev.Target, ne); err != nil { - logrus.Warnf("Fail to cleanup nodes for %v: %v", dev.Target, err) - } else { - logrus.Warnf("Nodes cleaned up for %v", dev.Target) - } - - time.Sleep(time.Duration(RetryInterval) * time.Second) - } - if err := iscsi.LoginTarget(localIP, dev.Target, ne); err != nil { - return err - } - if dev.Device, err = iscsi.GetDevice(localIP, dev.Target, TargetLunID, ne); err != nil { - return err - } - - deviceFound := false - for i := 0; i < RetryCounts; i++ { - if st, err := os.Stat(dev.Device); err == nil && (st.Mode()&os.ModeDevice != 0) { - deviceFound = true - break - } - time.Sleep(time.Duration(RetryInterval) * time.Second) - } - if !deviceFound { - return fmt.Errorf("Failed to wait for device %s to show up", dev.Device) - } - return nil -} - -func StopScsi(volumeName string) error { - target := GetTargetName(volumeName) - if err := LogoutTarget(target); err != nil { - return fmt.Errorf("Fail to logout target: %v", err) - } - if err := DeleteTarget(target); err != nil { - return fmt.Errorf("Fail to delete target: %v", err) - } - return nil -} - -func LogoutTarget(target string) error { - ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") - if err != nil { - return err - } - ip, err := GetLocalIP() - if err != nil { - return err - } - - if err := iscsi.CheckForInitiatorExistence(ne); err != nil { - return err - } - if iscsi.IsTargetLoggedIn(ip, target, ne) { - var err error - loggingOut := false - - logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) - for i := 0; i < RetryCounts; i++ { - err = iscsi.LogoutTarget(ip, target, ne) - if err == nil { - break - } - // The timeout for response may return in the future, - // check session to know if it's logged out or not - if strings.Contains(err.Error(), "Timeout executing: ") { - loggingOut = true - break - } - time.Sleep(time.Duration(RetryInterval) * time.Second) - } - // Wait for device to logout - if loggingOut { - logrus.Infof("Logout SCSI device timeout, waiting for logout complete") - for i := 0; i < RetryCounts; i++ { - if !iscsi.IsTargetLoggedIn(ip, target, ne) { - err = nil - break - } - time.Sleep(time.Duration(RetryInterval) * time.Second) - } - } - if err != nil { - return fmt.Errorf("Failed to logout target: %v", err) - } - /* - * Immediately delete target after logout may result in error: - * - * "Could not execute operation on all records: encountered - * iSCSI database failure" in iscsiadm - * - * This happenes especially there are other iscsiadm db - * operations go on at the same time. - * Retry to workaround this issue. Also treat "exit status - * 21"(no record found) as valid result - */ - for i := 0; i < RetryCounts; i++ { - if !iscsi.IsTargetDiscovered(ip, target, ne) { - err = nil - break - } - - err = iscsi.DeleteDiscoveredTarget(ip, target, ne) - if err == nil || strings.Contains(err.Error(), "exit status 21") { - err = nil - break - } - time.Sleep(time.Duration(RetryInterval) * time.Second) - } - if err != nil { - return err - } - } - return nil -} - -func DeleteTarget(target string) error { - if tid, err := iscsi.GetTargetTid(target); err == nil && tid != -1 { - if tid != TargetID { - logrus.Fatalf("BUG: Invalid TID %v found for %v", tid, target) - } - logrus.Infof("Shutdown SCSI target %v", target) - if err := iscsi.UnbindInitiator(TargetID, "ALL"); err != nil { - return err - } - if err := iscsi.DeleteLun(TargetID, TargetLunID); err != nil { - return err - } - if err := iscsi.DeleteTarget(TargetID); err != nil { - return err - } - } - return nil -} - func DuplicateDevice(src, dest string) error { if st, err := os.Stat(src); err != nil { return fmt.Errorf("Cannot duplicate device because cannot find %s: %v", src, err) From ee4bd07566126b3a831b53c319b14971bd7df01d Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Thu, 1 Dec 2016 10:43:38 -0800 Subject: [PATCH 236/357] Use vendor.conf (and latest trash) to manage deps (#255) --- trash.yml | 60 ------ vendor.conf | 23 ++ vendor/github.com/aws/aws-sdk-go/.gitignore | 10 + vendor/github.com/aws/aws-sdk-go/.travis.yml | 22 ++ vendor/github.com/aws/aws-sdk-go/.yardopts | 7 + vendor/github.com/aws/aws-sdk-go/Gemfile | 6 + vendor/github.com/aws/aws-sdk-go/LICENSE.txt | 202 ++++++++++++++++++ vendor/github.com/aws/aws-sdk-go/Makefile | 98 +++++++++ vendor/github.com/aws/aws-sdk-go/NOTICE.txt | 3 + vendor/github.com/aws/aws-sdk-go/README.md | 96 +++++++++ .../aws/aws-sdk-go/private/README.md | 4 + vendor/golang.org/x/sys/.gitattributes | 10 + vendor/golang.org/x/sys/.gitignore | 2 + vendor/golang.org/x/sys/AUTHORS | 3 + vendor/golang.org/x/sys/CONTRIBUTING.md | 31 +++ vendor/golang.org/x/sys/CONTRIBUTORS | 3 + vendor/golang.org/x/sys/LICENSE | 27 +++ vendor/golang.org/x/sys/PATENTS | 22 ++ vendor/golang.org/x/sys/README | 3 + vendor/golang.org/x/sys/codereview.cfg | 1 + 20 files changed, 573 insertions(+), 60 deletions(-) delete mode 100644 trash.yml create mode 100644 vendor.conf create mode 100644 vendor/github.com/aws/aws-sdk-go/.gitignore create mode 100644 vendor/github.com/aws/aws-sdk-go/.travis.yml create mode 100644 vendor/github.com/aws/aws-sdk-go/.yardopts create mode 100644 vendor/github.com/aws/aws-sdk-go/Gemfile create mode 100644 vendor/github.com/aws/aws-sdk-go/LICENSE.txt create mode 100644 vendor/github.com/aws/aws-sdk-go/Makefile create mode 100644 vendor/github.com/aws/aws-sdk-go/NOTICE.txt create mode 100644 vendor/github.com/aws/aws-sdk-go/README.md create mode 100644 vendor/github.com/aws/aws-sdk-go/private/README.md create mode 100644 vendor/golang.org/x/sys/.gitattributes create mode 100644 vendor/golang.org/x/sys/.gitignore create mode 100644 vendor/golang.org/x/sys/AUTHORS create mode 100644 vendor/golang.org/x/sys/CONTRIBUTING.md create mode 100644 vendor/golang.org/x/sys/CONTRIBUTORS 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/README create mode 100644 vendor/golang.org/x/sys/codereview.cfg diff --git a/trash.yml b/trash.yml deleted file mode 100644 index 94ad32d9..00000000 --- a/trash.yml +++ /dev/null @@ -1,60 +0,0 @@ -import: -- package: gopkg.in/check.v1 - version: 4f90aeace3a26ad7021961c297b22c42160c7b25 -- package: github.com/gorilla/mux - version: 0eeaf8392f5b04950925b8a69fe70f110fa7cbfc -- package: github.com/gorilla/handlers - version: d0f261246491e3a8613039e90764460448dc05f5 -- package: github.com/gorilla/websocket - version: e2e3d8414d0fbae04004f151979f4e27c6747fe7 -- package: github.com/gorilla/context - version: 1ea25387ff6f684839d82767c1733ff4d4d15d0a -- package: github.com/frostschutz/go-fibmap - version: 5fc9f8c1ed479f20414771a17b9686ee77029676 - repo: https://github.com/rancher/go-fibmap.git -- package: github.com/Sirupsen/logrus - version: 446d1c146faa8ed3f4218f056fcd165f6bcfda81 -- package: github.com/rancher/go-rancher - version: 5ed452cd07a408bc6c96d10766a963c0d7585518 -- package: github.com/docker/go-units - version: 5d2041e26a699eaca682e2ea41c8f891e1060444 -- package: github.com/docker/docker - version: v1.11.1 -- package: github.com/codegangsta/cli - version: 71f57d300dd6a780ac1856c005c4b518cfd498ec -- package: github.com/satori/go.uuid - version: f9ab0dce87d815821e221626b772e3475a0d2749 -- package: github.com/rancher/sparse-tools - version: df7d04b769d34b52878e9e60ba22dabf7dc8b7ca -- package: github.com/rancher/go-rancher-metadata - version: 721b783c9983a17ec0d63d5530337610de9519ec -- package: github.com/rancher/convoy - version: 9e0fd9a3a77dc4b8ee7eab859a420b7764729271 -- package: github.com/mcuadros/go-version - version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 -- package: golang.org/x/sys/unix - version: 62bee037599929a6e9146f29d10dd5208c43507d -- package: github.com/aws/aws-sdk-go/aws - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/endpoints - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/protocol/query - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/protocol/rest - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/protocol/restxml - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/signer/v4 - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/waiter - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/service/s3 - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/go-ini/ini - version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 -- package: github.com/jmespath/go-jmespath - version: c01cf91b011868172fdcd9f41838e80c9d716264 -- package: github.com/yasker/go-iscsi-helper - version: a95ec6c0750d3426e3fd0b10f6f0f50721fe75cf diff --git a/vendor.conf b/vendor.conf new file mode 100644 index 00000000..406e6268 --- /dev/null +++ b/vendor.conf @@ -0,0 +1,23 @@ +github.com/rancher/longhorn + +gopkg.in/check.v1 4f90aeace3a26ad7021961c297b22c42160c7b25 +github.com/gorilla/mux 0eeaf8392f5b04950925b8a69fe70f110fa7cbfc +github.com/gorilla/handlers d0f261246491e3a8613039e90764460448dc05f5 +github.com/gorilla/websocket e2e3d8414d0fbae04004f151979f4e27c6747fe7 +github.com/gorilla/context 1ea25387ff6f684839d82767c1733ff4d4d15d0a +github.com/frostschutz/go-fibmap 5fc9f8c1ed479f20414771a17b9686ee77029676 https://github.com/rancher/go-fibmap.git +github.com/Sirupsen/logrus 446d1c146faa8ed3f4218f056fcd165f6bcfda81 +github.com/rancher/go-rancher 5ed452cd07a408bc6c96d10766a963c0d7585518 +github.com/docker/go-units 5d2041e26a699eaca682e2ea41c8f891e1060444 +github.com/docker/docker v1.11.1 +github.com/codegangsta/cli 71f57d300dd6a780ac1856c005c4b518cfd498ec +github.com/satori/go.uuid f9ab0dce87d815821e221626b772e3475a0d2749 +github.com/rancher/sparse-tools df7d04b769d34b52878e9e60ba22dabf7dc8b7ca +github.com/rancher/go-rancher-metadata 721b783c9983a17ec0d63d5530337610de9519ec +github.com/rancher/convoy 9e0fd9a3a77dc4b8ee7eab859a420b7764729271 +github.com/mcuadros/go-version d52711f8d6bea8dc01efafdb68ad95a4e2606630 +golang.org/x/sys 62bee037599929a6e9146f29d10dd5208c43507d +github.com/aws/aws-sdk-go c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc +github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 +github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 +github.com/yasker/go-iscsi-helper a95ec6c0750d3426e3fd0b10f6f0f50721fe75cf diff --git a/vendor/github.com/aws/aws-sdk-go/.gitignore b/vendor/github.com/aws/aws-sdk-go/.gitignore new file mode 100644 index 00000000..825218fd --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/.gitignore @@ -0,0 +1,10 @@ +dist +doc +.yardoc +Gemfile.lock +awstesting/integration/smoke/**/importmarker__.go +awstesting/integration/smoke/_test/ +/vendor/bin/ +/vendor/pkg/ +/vendor/src/ +/private/model/cli/gen-api/gen-api diff --git a/vendor/github.com/aws/aws-sdk-go/.travis.yml b/vendor/github.com/aws/aws-sdk-go/.travis.yml new file mode 100644 index 00000000..c8bf08b1 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/.travis.yml @@ -0,0 +1,22 @@ +language: go + +sudo: false + +go: + - 1.4 + - 1.5 + - tip + +# Use Go 1.5's vendoring experiment for 1.5 tests. 1.4 tests will use the tip of the dependencies repo. +env: + - GO15VENDOREXPERIMENT=1 + +install: + - make get-deps + +script: + - make unit + +matrix: + allow_failures: + - go: tip diff --git a/vendor/github.com/aws/aws-sdk-go/.yardopts b/vendor/github.com/aws/aws-sdk-go/.yardopts new file mode 100644 index 00000000..07724e4b --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/.yardopts @@ -0,0 +1,7 @@ +--plugin go +-e doc-src/plugin/plugin.rb +-m markdown +-o doc/api +--title "AWS SDK for Go" +aws/**/*.go +service/**/*.go diff --git a/vendor/github.com/aws/aws-sdk-go/Gemfile b/vendor/github.com/aws/aws-sdk-go/Gemfile new file mode 100644 index 00000000..4d6529bd --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'yard', git: 'git://github.com/lsegal/yard' +gem 'yard-go', git: 'git://github.com/lsegal/yard-go' +gem 'rdiscount' + 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 00000000..d6456956 --- /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/Makefile b/vendor/github.com/aws/aws-sdk-go/Makefile new file mode 100644 index 00000000..4b7570e9 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/Makefile @@ -0,0 +1,98 @@ +LINTIGNOREDOT='awstesting/integration.+should not use dot imports' +LINTIGNOREDOC='service/[^/]+/(api|service|waiters)\.go:.+(comment on exported|should have comment or be unexported)' +LINTIGNORECONST='service/[^/]+/(api|service|waiters)\.go:.+(type|struct field|const|func) ([^ ]+) should be ([^ ]+)' +LINTIGNORESTUTTER='service/[^/]+/(api|service)\.go:.+(and that stutters)' +LINTIGNOREINFLECT='service/[^/]+/(api|service)\.go:.+method .+ should be ' +LINTIGNOREDEPS='vendor/.+\.go' + +SDK_WITH_VENDOR_PKGS=$(shell go list ./... | grep -v "/vendor/src") +SDK_ONLY_PKGS=$(shell go list ./... | grep -v "/vendor/") + +all: get-deps generate unit + +help: + @echo "Please use \`make ' where is one of" + @echo " api_info to print a list of services and versions" + @echo " docs to build SDK documentation" + @echo " build to go build the SDK" + @echo " unit to run unit tests" + @echo " integration to run integration tests" + @echo " verify to verify tests" + @echo " lint to lint the SDK" + @echo " vet to vet the SDK" + @echo " generate to go generate and make services" + @echo " gen-test to generate protocol tests" + @echo " gen-services to generate services" + @echo " get-deps to go get the SDK dependencies" + @echo " get-deps-unit to get the SDK's unit test dependencies" + @echo " get-deps-integ to get the SDK's integration test dependencies" + @echo " get-deps-verify to get the SDK's verification dependencies" + +generate: gen-test gen-endpoints gen-services + +gen-test: gen-protocol-test + +gen-services: + go generate ./service + +gen-protocol-test: + go generate ./private/protocol/... + +gen-endpoints: + go generate ./private/endpoints + +build: + @echo "go build SDK and vendor packages" + @go build $(SDK_WITH_VENDOR_PKGS) + +unit: get-deps-unit build verify + @echo "go test SDK and vendor packages" + @go test $(SDK_WITH_VENDOR_PKGS) + +integration: get-deps-integ + go test -tags=integration ./awstesting/integration/customizations/... + gucumber ./awstesting/integration/smoke + +verify: get-deps-verify lint vet + +lint: + @echo "go lint SDK and vendor packages" + @lint=`golint ./...`; \ + lint=`echo "$$lint" | grep -E -v -e ${LINTIGNOREDOT} -e ${LINTIGNOREDOC} -e ${LINTIGNORECONST} -e ${LINTIGNORESTUTTER} -e ${LINTIGNOREINFLECT} -e ${LINTIGNOREDEPS}`; \ + echo "$$lint"; \ + if [ "$$lint" != "" ]; then exit 1; fi + +vet: + go tool vet -all -shadow $(shell ls -d */ | grep -v vendor) + +get-deps: get-deps-unit get-deps-integ get-deps-verify + @echo "go get SDK dependencies" + @go get -v $(SDK_ONLY_PKGS) + +get-deps-unit: + @echo "go get SDK unit testing dependencies" + go get github.com/stretchr/testify + go get github.com/smartystreets/goconvey + +get-deps-integ: get-deps-unit + @echo "go get SDK integration testing dependencies" + go get github.com/lsegal/gucumber/cmd/gucumber + +get-deps-verify: + @echo "go get SDK verification utilities" + go get github.com/golang/lint/golint + +bench: + @echo "go bench SDK packages" + @go test -run NONE -bench . -benchmem -tags 'bench' $(SDK_ONLY_PKGS) + +bench-protocol: + @echo "go bench SDK protocol marshallers" + @go test -run NONE -bench . -benchmem -tags 'bench' ./private/protocol/... + +docs: + @echo "generate SDK docs" + rm -rf doc && bundle install && bundle exec yard + +api_info: + @go run private/model/cli/api-info/api-info.go 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 00000000..5f14d116 --- /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/README.md b/vendor/github.com/aws/aws-sdk-go/README.md new file mode 100644 index 00000000..eeccb4b5 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/README.md @@ -0,0 +1,96 @@ +# AWS SDK for Go + +[![API Reference](http://img.shields.io/badge/api-reference-blue.svg)](http://docs.aws.amazon.com/sdk-for-go/api) +[![Join the chat at https://gitter.im/aws/aws-sdk-go](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aws/aws-sdk-go?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://img.shields.io/travis/aws/aws-sdk-go.svg)](https://travis-ci.org/aws/aws-sdk-go) +[![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/aws/aws-sdk-go/blob/master/LICENSE.txt) + +aws-sdk-go is the official AWS SDK for the Go programming language. + +Checkout our [release notes](https://github.com/aws/aws-sdk-go/releases) for information about the latest bug fixes, updates, and features added to the SDK. + +## Installing + +If you are using Go 1.5 with the `GO15VENDOREXPERIMENT=1` vendoring flag you can use the following to get the SDK as the SDK's runtime dependencies are vendored in the `vendor` folder. + + $ go get -u github.com/aws/aws-sdk-go + +Otherwise you'll need to tell Go to get the SDK and all of its dependencies. + + $ go get -u github.com/aws/aws-sdk-go/... + +## Configuring Credentials + +Before using the SDK, ensure that you've configured credentials. The best +way to configure credentials on a development machine is to use the +`~/.aws/credentials` file, which might look like: + +``` +[default] +aws_access_key_id = AKID1234567890 +aws_secret_access_key = MY-SECRET-KEY +``` + +You can learn more about the credentials file from this +[blog post](http://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs). + +Alternatively, you can set the following environment variables: + +``` +AWS_ACCESS_KEY_ID=AKID1234567890 +AWS_SECRET_ACCESS_KEY=MY-SECRET-KEY +``` + +### AWS CLI config file (`~/aws/config`) +The AWS SDK for Go does not support the AWS CLI's config file. The SDK will not use any contents from this file. The SDK only supports the shared credentials file (`~/aws/credentials`). #384 tracks this feature request discussion. + +## Using the Go SDK + +To use a service in the SDK, create a service variable by calling the `New()` +function. Once you have a service client, you can call API operations which each +return response data and a possible error. + +To list a set of instance IDs from EC2, you could run: + +```go +package main + +import ( + "fmt" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/ec2" +) + +func main() { + // Create an EC2 service object in the "us-west-2" region + // Note that you can also configure your region globally by + // exporting the AWS_REGION environment variable + svc := ec2.New(session.New(), &aws.Config{Region: aws.String("us-west-2")}) + + // Call the DescribeInstances Operation + resp, err := svc.DescribeInstances(nil) + if err != nil { + panic(err) + } + + // resp has all of the response data, pull out instance IDs: + fmt.Println("> Number of reservation sets: ", len(resp.Reservations)) + for idx, res := range resp.Reservations { + fmt.Println(" > Number of instances: ", len(res.Instances)) + for _, inst := range resp.Reservations[idx].Instances { + fmt.Println(" - Instance ID: ", *inst.InstanceId) + } + } +} +``` + +You can find more information and operations in our +[API documentation](http://docs.aws.amazon.com/sdk-for-go/api/). + +## License + +This SDK is distributed under the +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), +see LICENSE.txt and NOTICE.txt for more information. diff --git a/vendor/github.com/aws/aws-sdk-go/private/README.md b/vendor/github.com/aws/aws-sdk-go/private/README.md new file mode 100644 index 00000000..5bdb4c50 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/README.md @@ -0,0 +1,4 @@ +## AWS SDK for Go Private packages ## +`private` is a collection of packages used internally by the SDK, and is subject to have breaking changes. This package is not `internal` so that if you really need to use its functionality, and understand breaking changes will be made, you are able to. + +These packages will be refactored in the future so that the API generator and model parsers are exposed cleanly on their own. Making it easier for you to generate your own code based on the API models. diff --git a/vendor/golang.org/x/sys/.gitattributes b/vendor/golang.org/x/sys/.gitattributes new file mode 100644 index 00000000..d2f212e5 --- /dev/null +++ b/vendor/golang.org/x/sys/.gitattributes @@ -0,0 +1,10 @@ +# Treat all files in this repo as binary, with no git magic updating +# line endings. Windows users contributing to Go will need to use a +# modern version of git and editors capable of LF line endings. +# +# We'll prevent accidental CRLF line endings from entering the repo +# via the git-review gofmt checks. +# +# See golang.org/issue/9281 + +* -text diff --git a/vendor/golang.org/x/sys/.gitignore b/vendor/golang.org/x/sys/.gitignore new file mode 100644 index 00000000..8339fd61 --- /dev/null +++ b/vendor/golang.org/x/sys/.gitignore @@ -0,0 +1,2 @@ +# Add no patterns to .hgignore except for files generated by the build. +last-change diff --git a/vendor/golang.org/x/sys/AUTHORS b/vendor/golang.org/x/sys/AUTHORS new file mode 100644 index 00000000..15167cd7 --- /dev/null +++ b/vendor/golang.org/x/sys/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/sys/CONTRIBUTING.md b/vendor/golang.org/x/sys/CONTRIBUTING.md new file mode 100644 index 00000000..88dff59b --- /dev/null +++ b/vendor/golang.org/x/sys/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing to Go + +Go is an open source project. + +It is the work of hundreds of contributors. We appreciate your help! + + +## Filing issues + +When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: + +1. What version of Go are you using (`go version`)? +2. What operating system and processor architecture are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? + +General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. +The gophers there will answer or ask you to file an issue if you've tripped over a bug. + +## Contributing code + +Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) +before sending patches. + +**We do not accept GitHub pull requests** +(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). + +Unless otherwise noted, the Go source files are distributed under +the BSD-style license found in the LICENSE file. + diff --git a/vendor/golang.org/x/sys/CONTRIBUTORS b/vendor/golang.org/x/sys/CONTRIBUTORS new file mode 100644 index 00000000..1c4577e9 --- /dev/null +++ b/vendor/golang.org/x/sys/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE new file mode 100644 index 00000000..6a66aea5 --- /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 00000000..73309904 --- /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/README b/vendor/golang.org/x/sys/README new file mode 100644 index 00000000..bd422b40 --- /dev/null +++ b/vendor/golang.org/x/sys/README @@ -0,0 +1,3 @@ +This repository holds supplemental Go packages for low-level interactions with the operating system. + +To submit changes to this repository, see http://golang.org/doc/contribute.html. diff --git a/vendor/golang.org/x/sys/codereview.cfg b/vendor/golang.org/x/sys/codereview.cfg new file mode 100644 index 00000000..3f8b14b6 --- /dev/null +++ b/vendor/golang.org/x/sys/codereview.cfg @@ -0,0 +1 @@ +issuerepo: golang/go From eae8abab92e92a0941b811e02088b1cbb374e009 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 1 Dec 2016 15:50:52 -0800 Subject: [PATCH 237/357] tgt: Ignore "No match session found" error when logout It's possible that previous logout process delayed a bit and result in when start up frontend happens, previous logout already completed. So the second logout errors out with "No match session found" and "exit status 21". It's safe to ignore the error. --- util/scsi.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/scsi.go b/util/scsi.go index 67bcf0df..d7ede30e 100644 --- a/util/scsi.go +++ b/util/scsi.go @@ -142,7 +142,9 @@ func LogoutTarget(target string) error { logrus.Infof("Shutdown SCSI device for %v:%v", ip, target) for i := 0; i < RetryCounts; i++ { err = iscsi.LogoutTarget(ip, target, ne) - if err == nil { + // Ignore Not Found error + if err == nil || strings.Contains(err.Error(), "exit status 21") { + err = nil break } // The timeout for response may return in the future, @@ -185,6 +187,7 @@ func LogoutTarget(target string) error { } err = iscsi.DeleteDiscoveredTarget(ip, target, ne) + // Ignore Not Found error if err == nil || strings.Contains(err.Error(), "exit status 21") { err = nil break From f13651546e1763d446d3d5b3d63fa19e444c83fe Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 8 Dec 2016 17:47:31 -0800 Subject: [PATCH 238/357] tgt: Update liblonghorn and tgt Liblonghorn is the Longhorn C library for communcation. Also add TypeClose to message type, in order for server to prompt client of disconnecting connection. --- Dockerfile.dapper | 10 +++++++++- rpc/server.go | 5 +++++ rpc/types.go | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index e792593e..904093ad 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -64,11 +64,19 @@ RUN cd /usr/src/libqcow-20160123 && \ make -j$(nproc) && \ make install +# Build liblonghorn +RUN cd /usr/src && \ + git clone https://github.com/yasker/liblonghorn.git && \ + cd liblonghorn && \ + git checkout ab004d2a922bc7a2bbb0a2b3ac8e5f6ff389507f && \ + make deb && \ + dpkg -i ./pkg/liblonghorn_*.deb + # Build TGT RUN cd /usr/src && \ git clone https://github.com/yasker/tgt.git && \ cd tgt && \ - git checkout 1f116a1bf03c4ec16a0a1294189a5f802739f343 && \ + git checkout 6475d1ddf4ff0ac1421a96725f3d472cbb2985c7 && \ ./scripts/build-pkg.sh deb && \ dpkg -i ./pkg/tgt_*.deb diff --git a/rpc/server.go b/rpc/server.go index 3da2053f..e441accf 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -103,6 +103,11 @@ func (s *Server) write() { logrus.Errorf("Failed to write: %v", err) } case <-s.done: + msg := &Message{ + Type: TypeClose, + } + //Best effort to notify client to close connection + s.wire.Write(msg) break } } diff --git a/rpc/types.go b/rpc/types.go index 9faf27fd..41a83e6c 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -8,6 +8,7 @@ const ( TypeResponse TypeError TypeEOF + TypeClose messageSize = (32 + 32 + 32 + 64) / 8 //TODO: unused? readBufferSize = 8096 From aa239109047cfeef9163311add4c5084f60daeeb Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 14 Dec 2016 16:21:50 -0800 Subject: [PATCH 239/357] tgt: Add NSFileLock for iscsi related operations The iscsiadm is not thread-safe. longhorn-tests/stress/teardown_test proved that. --- util/scsi.go | 25 ++- vendor.conf | 1 + .../github.com/yasker/nsfilelock/.gitignore | 24 +++ .../yasker/nsfilelock/Dockerfile.dapper | 42 ++++ vendor/github.com/yasker/nsfilelock/LICENSE | 201 ++++++++++++++++++ vendor/github.com/yasker/nsfilelock/Makefile | 23 ++ vendor/github.com/yasker/nsfilelock/README.md | 37 ++++ .../yasker/nsfilelock/nsfilelock.go | 141 ++++++++++++ .../github.com/yasker/nsfilelock/vendor.conf | 6 + 9 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 vendor/github.com/yasker/nsfilelock/.gitignore create mode 100644 vendor/github.com/yasker/nsfilelock/Dockerfile.dapper create mode 100644 vendor/github.com/yasker/nsfilelock/LICENSE create mode 100644 vendor/github.com/yasker/nsfilelock/Makefile create mode 100644 vendor/github.com/yasker/nsfilelock/README.md create mode 100644 vendor/github.com/yasker/nsfilelock/nsfilelock.go create mode 100644 vendor/github.com/yasker/nsfilelock/vendor.conf diff --git a/util/scsi.go b/util/scsi.go index d7ede30e..c8ebb690 100644 --- a/util/scsi.go +++ b/util/scsi.go @@ -9,6 +9,13 @@ import ( "github.com/Sirupsen/logrus" "github.com/yasker/go-iscsi-helper/iscsi" iutil "github.com/yasker/go-iscsi-helper/util" + "github.com/yasker/nsfilelock" +) + +const ( + HostNamespace = "/host/proc/1/ns/" + LockFile = "/var/run/longhorn-iscsi.lock" + LockTimeout = 120 * time.Second ) type ScsiDevice struct { @@ -42,7 +49,13 @@ func GetLocalIP() (string, error) { } func StartScsi(dev *ScsiDevice) error { - ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + lock := nsfilelock.NewLockWithTimeout(HostNamespace, LockFile, LockTimeout) + if err := lock.Lock(); err != nil { + return fmt.Errorf("Fail to lock: %v", err) + } + defer lock.Unlock() + + ne, err := iutil.NewNamespaceExecutor(HostNamespace) if err != nil { return err } @@ -78,7 +91,7 @@ func StartScsi(dev *ScsiDevice) error { break } - logrus.Warnf("FAIL to discover %v", err) + logrus.Warnf("FAIL to discover due to %v", err) // This is a trick to recover from the case. Remove the // empty entries in /etc/iscsi/nodes/. If one of the entry // is empty it will triggered the issue. @@ -112,6 +125,12 @@ func StartScsi(dev *ScsiDevice) error { } func StopScsi(volumeName string) error { + lock := nsfilelock.NewLockWithTimeout(HostNamespace, LockFile, LockTimeout) + if err := lock.Lock(); err != nil { + return fmt.Errorf("Fail to lock: %v", err) + } + defer lock.Unlock() + target := GetTargetName(volumeName) if err := LogoutTarget(target); err != nil { return fmt.Errorf("Fail to logout target: %v", err) @@ -123,7 +142,7 @@ func StopScsi(volumeName string) error { } func LogoutTarget(target string) error { - ne, err := iutil.NewNamespaceExecutor("/host/proc/1/ns/") + ne, err := iutil.NewNamespaceExecutor(HostNamespace) if err != nil { return err } diff --git a/vendor.conf b/vendor.conf index 406e6268..dfed6772 100644 --- a/vendor.conf +++ b/vendor.conf @@ -21,3 +21,4 @@ github.com/aws/aws-sdk-go c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper a95ec6c0750d3426e3fd0b10f6f0f50721fe75cf +github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 diff --git a/vendor/github.com/yasker/nsfilelock/.gitignore b/vendor/github.com/yasker/nsfilelock/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/.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/vendor/github.com/yasker/nsfilelock/Dockerfile.dapper b/vendor/github.com/yasker/nsfilelock/Dockerfile.dapper new file mode 100644 index 00000000..1cccc742 --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/Dockerfile.dapper @@ -0,0 +1,42 @@ +FROM ubuntu:16.04 + +# Setup environment +ENV PATH /go/bin:$PATH +ENV DAPPER_DOCKER_SOCKET true +ENV DAPPER_ENV TAG REPO +ENV DAPPER_OUTPUT bin +ENV DAPPER_RUN_ARGS --privileged -v /proc:/host/proc +ENV DAPPER_SOURCE /go/src/github.com/yasker/nsfilelock +ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache +WORKDIR ${DAPPER_SOURCE} + +# Install packages +RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y cmake curl git + # \ + # libglib2.0-dev libkmod-dev libnl-genl-3-dev linux-libc-dev pkg-config psmisc python-tox qemu-utils fuse python-dev \ + # devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl \ + # libconfig-general-perl libaio-dev libc6-dev + +# Install Go +RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz +RUN echo '702ad90f705365227e902b42d91dd1a40e48ca7f67a2f4b2fd052aaa4295cd95 go.tar.gz' | sha256sum -c && \ + tar xzf go.tar.gz -C /usr/local && \ + rm go.tar.gz +RUN mkdir -p /go +ENV PATH $PATH:/usr/local/go/bin +ENV GOPATH=/go + +# Go tools +RUN go get github.com/rancher/trash +RUN go get github.com/golang/lint/golint + +# Docker +RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ + chmod +x /usr/bin/docker + +VOLUME /tmp +ENV TMPDIR /tmp +ENTRYPOINT ["./scripts/entry"] +CMD ["ci"] diff --git a/vendor/github.com/yasker/nsfilelock/LICENSE b/vendor/github.com/yasker/nsfilelock/LICENSE new file mode 100644 index 00000000..8dada3ed --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/LICENSE @@ -0,0 +1,201 @@ + 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/yasker/nsfilelock/Makefile b/vendor/github.com/yasker/nsfilelock/Makefile new file mode 100644 index 00000000..d7d72a16 --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/Makefile @@ -0,0 +1,23 @@ +TARGETS := $(shell ls scripts) + +.dapper: + @echo Downloading dapper + @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp + @@chmod +x .dapper.tmp + @./.dapper.tmp -v + @mv .dapper.tmp .dapper + +$(TARGETS): .dapper + ./.dapper $@ + +trash: .dapper + ./.dapper -m bind trash + +trash-keep: .dapper + ./.dapper -m bind trash -k + +deps: trash + +.DEFAULT_GOAL := ci + +.PHONY: $(TARGETS) diff --git a/vendor/github.com/yasker/nsfilelock/README.md b/vendor/github.com/yasker/nsfilelock/README.md new file mode 100644 index 00000000..f92a1024 --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/README.md @@ -0,0 +1,37 @@ +# NSFileLock +File lock (flock) in another namespace. + +# Motivation: + +I am working on various projects rely on a privileged container(Docker), in +which case the process running inside the container will have the ability to +switch namespace to the host. Sometimes, we want to make sure certain thing +won't happen simultaneously on the host in the case of multiple instances of the +container is running. But bind-mount an additional directory just for this +purpose seems unnecessarily cumbersome, and especially we already have the +ability to switch to the host namespace (especially mount namespace) for certain +operations. + +But as a Go program, it's hard to hold a file descriptor in another namespace to +perform flock operation, since `nsenter`, which is the easiest way to switch +namespace, is a bash program. Of course, you can call `setns` syscall used by +`nsenter` to get the process into the new namespace, though that means you got +to rewrite the `nsenter` just for grabbing a lock. + +This library provides a reliable way to do so without rewrite `nsenter`. + +# Target + +The target is simply: simulate the behavior of `flock` in another namespace. + +The most import behavior of `flock` is: + +The lock will expire immediately when the process holding file descriptor exits. + +It's the key reason why we don't want to create a file in the other +namespace to simulate the lock. In that case, the crash of process holding the +lock will result in infinitely blocking all the following processes. + +For `flock`, since it's only related to opened file descriptor, as soon as the +file descriptor is closed (e.g. unlock, or process crashed so OS release all its +resources), the lock will expire. diff --git a/vendor/github.com/yasker/nsfilelock/nsfilelock.go b/vendor/github.com/yasker/nsfilelock/nsfilelock.go new file mode 100644 index 00000000..626ee6df --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/nsfilelock.go @@ -0,0 +1,141 @@ +package nsfilelock + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" + "strings" + "syscall" + "time" +) + +const ( + MountNamespaceFD = "mnt" + MaximumMessageSize = 255 + + SuccessResponse = "NSFileLock LOCKED" +) + +var ( + DefaultTimeout = 15 * time.Second +) + +type NSFileLock struct { + Namespace string + FilePath string + Timeout time.Duration + + done chan struct{} +} + +func NewLock(ns string, filepath string) *NSFileLock { + return &NSFileLock{ + Namespace: ns, + FilePath: filepath, + Timeout: DefaultTimeout, + } +} + +func NewLockWithTimeout(ns string, filepath string, timeout time.Duration) *NSFileLock { + if timeout == 0 { + timeout = DefaultTimeout + } + return &NSFileLock{ + Namespace: ns, + FilePath: filepath, + Timeout: timeout, + } +} + +func (l *NSFileLock) Lock() error { + resp := "" + + l.done = make(chan struct{}) + result := make(chan string) + timeout := make(chan struct{}) + + cmdline := []string{} + if l.Namespace != "" { + nsFD := filepath.Join(l.Namespace, MountNamespaceFD) + if _, err := os.Stat(nsFD); err != nil { + return fmt.Errorf("Invalid namespace fd %s: %v", nsFD, err) + } + cmdline = []string{"nsenter", "--mount=" + nsFD} + } + + lockCmd := fmt.Sprintf("\"\"exec 314>%s && flock 314 && echo %s && exec sleep 65535\"\"", + l.FilePath, SuccessResponse) + + cmdline = append(cmdline, "bash", "-c", lockCmd) + cmd := exec.Command(cmdline[0], cmdline[1:]...) + cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGTERM} + stdout, err := cmd.StdoutPipe() + if err != nil { + return err + } + stderr, err := cmd.StderrPipe() + if err != nil { + return err + } + + err = cmd.Start() + if err != nil { + return err + } + + go func() { + var err error + buf := make([]byte, MaximumMessageSize) + n := 0 + for n == 0 { + n, err = stdout.Read(buf) + if err != nil { + result <- err.Error() + } + } + result <- strings.Trim(string(buf), "\n\x00") + }() + + go func() { + var err error + buf := make([]byte, MaximumMessageSize) + n := 0 + for n == 0 { + n, err = stderr.Read(buf) + if err != nil { + result <- err.Error() + } + } + result <- strings.Trim(string(buf), "\n\x00") + }() + + go func() { + time.Sleep(l.Timeout) + timeout <- struct{}{} + }() + + select { + case resp = <-result: + if resp != SuccessResponse { + return fmt.Errorf("Failed to lock, response: %s, expected %s", resp, SuccessResponse) + } + case <-timeout: + syscall.Kill(cmd.Process.Pid, syscall.SIGTERM) + return fmt.Errorf("Timeout waiting for lock") + } + + // Wait for unlock + go func() { + select { + case <-l.done: + syscall.Kill(cmd.Process.Pid, syscall.SIGTERM) + return + } + }() + return nil +} + +func (l *NSFileLock) Unlock() { + l.done <- struct{}{} +} diff --git a/vendor/github.com/yasker/nsfilelock/vendor.conf b/vendor/github.com/yasker/nsfilelock/vendor.conf new file mode 100644 index 00000000..f869d4c5 --- /dev/null +++ b/vendor/github.com/yasker/nsfilelock/vendor.conf @@ -0,0 +1,6 @@ +# trash.conf + +# package +github.com/yasker/nsfilelock + +gopkg.in/check.v1 20d25e2 From 3c19b4be3ad233756387a6bc95454a3aa8d2e540 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 15 Dec 2016 18:08:58 -0800 Subject: [PATCH 240/357] tgt: Move scsi related code back to TGT --- frontend/tgt/frontend.go | 8 ++++---- {util => frontend/tgt}/scsi.go | 10 ++++++++-- util/util.go | 6 ------ 3 files changed, 12 insertions(+), 12 deletions(-) rename {util => frontend/tgt}/scsi.go (98%) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 396c27eb..86526baf 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -31,7 +31,7 @@ type Tgt struct { isUp bool socketPath string socketServer *rpc.Server - scsiDevice *util.ScsiDevice + scsiDevice *ScsiDevice } func (t *Tgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { @@ -71,7 +71,7 @@ func (t *Tgt) Shutdown() error { t.socketServer.Stop() t.socketServer = nil } - if err := util.StopScsi(t.Volume); err != nil { + if err := StopScsi(t.Volume); err != nil { return fmt.Errorf("Fail to stop SCSI device: %v", err) } } @@ -146,13 +146,13 @@ func (t *Tgt) getDev() string { func (t *Tgt) startScsiDevice() error { if t.scsiDevice == nil { bsOpts := fmt.Sprintf("size=%v", t.Size) - scsiDev, err := util.NewScsiDevice(t.Volume, t.socketPath, "longhorn", bsOpts) + scsiDev, err := NewScsiDevice(t.Volume, t.socketPath, "longhorn", bsOpts) if err != nil { return err } t.scsiDevice = scsiDev } - if err := util.StartScsi(t.scsiDevice); err != nil { + if err := StartScsi(t.scsiDevice); err != nil { return err } logrus.Infof("SCSI device %s created", t.scsiDevice.Device) diff --git a/util/scsi.go b/frontend/tgt/scsi.go similarity index 98% rename from util/scsi.go rename to frontend/tgt/scsi.go index c8ebb690..a28fc697 100644 --- a/util/scsi.go +++ b/frontend/tgt/scsi.go @@ -1,4 +1,4 @@ -package util +package tgt import ( "fmt" @@ -12,10 +12,16 @@ import ( "github.com/yasker/nsfilelock" ) -const ( +var ( HostNamespace = "/host/proc/1/ns/" LockFile = "/var/run/longhorn-iscsi.lock" LockTimeout = 120 * time.Second + + TargetID = 1 + TargetLunID = 1 + + RetryCounts = 5 + RetryInterval = 3 ) type ScsiDevice struct { diff --git a/util/util.go b/util/util.go index 37e1f963..8deee3de 100644 --- a/util/util.go +++ b/util/util.go @@ -14,12 +14,6 @@ import ( var ( parsePattern = regexp.MustCompile(`(.*):(\d+)`) - - TargetID = 1 - TargetLunID = 1 - - RetryCounts = 5 - RetryInterval = 3 ) func ParseAddresses(name string) (string, string, string, error) { From d6940ab85c163c883779aa30a3b7ab6f177b7130 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 21 Dec 2016 15:49:31 -0800 Subject: [PATCH 241/357] snapshot: Don't count remaining snapshot if replica cannot snapshot Fixes #263 --- backend/remote/remote.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index e6a3ab73..e5acbba6 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -114,6 +114,9 @@ func (r *Remote) RemainSnapshots() (int, error) { if err != nil { return 0, err } + if replica.State != "open" && replica.State != "dirty" && replica.State != "rebuilding" { + return 0, fmt.Errorf("Invalid state %v for counting snapshots", replica.State) + } return replica.RemainSnapshots, nil } From ea544ad4edabb1e49c8464e7a1216075cae01882 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 21 Dec 2016 17:12:05 -0800 Subject: [PATCH 242/357] snapshot: Fix wrong address reported in error Fixes #262 --- controller/replicator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/replicator.go b/controller/replicator.go index 7505cccc..2ae56a98 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -181,12 +181,12 @@ func (r *replicator) Snapshot(name string) error { for addr, backend := range r.backends { if backend.mode != types.ERR { wg.Add(1) - go func(backend types.Backend) { + go func(address string, backend types.Backend) { if err := backend.Snapshot(name); err != nil { - retError.Errors[addr] = err + retError.Errors[address] = err } wg.Done() - }(backend.backend) + }(addr, backend.backend) } } From 926f3be76597767d1cc4d5c0d254e60d95441f0e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 21 Dec 2016 18:44:04 -0800 Subject: [PATCH 243/357] sync: Determine the volume head by looking into chain Rather than looking into all the present disks, since there is a gap between create the new head and remove the old head, which means there can be two heads in the same replica for a brief moment. Better check the chain for who's current head. --- sync/sync.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sync/sync.go b/sync/sync.go index 9f7053a2..72afcab8 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -282,7 +282,11 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl fromHead := "" toHead := "" - for _, disk := range from.Disks { + // Find the head from chain, since there is a gap between create the new + // head and remove the old head, which means there can be two heads in + // the same replica for a brief moment. Better check the chain for who's + // current head. + for _, disk := range from.Chain { if strings.Contains(disk, "volume-head") { if fromHead != "" { return fmt.Errorf("More than one head volume found in the from replica %s, %s", fromHead, disk) @@ -290,7 +294,12 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl fromHead = disk continue } + } + for _, disk := range from.Disks { + if strings.Contains(disk, "volume-head") { + continue + } if err := t.syncFile(disk, "", fromClient, toClient); err != nil { return err } @@ -329,7 +338,7 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl } fromHead = "" - for _, disk := range from.Disks { + for _, disk := range from.Chain { if strings.Contains(disk, "volume-head") { if fromHead != "" { return fmt.Errorf("More than one head volume found in the from replica %s, %s", From 78bacf63a48507167345e15bf687916aa0d66a0a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 22 Dec 2016 10:56:32 -0800 Subject: [PATCH 244/357] cli: Fix slice out of boundary when snapshot list Fixes #265 --- app/snapshot.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/snapshot.go b/app/snapshot.go index 77cba6eb..00e11932 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -144,6 +144,11 @@ func lsSnapshot(c *cli.Context) error { if err != nil { return err } + // Replica can just started and haven't prepare the head + // file yet + if len(chain) == 0 { + break + } snapshots = chain[1:] continue } From c87086037387a451602384ec79d41c37ef3f09e5 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Tue, 27 Dec 2016 16:14:55 -0800 Subject: [PATCH 245/357] move agent to longhorn-orc --- agent/controller/controller.go | 496 ----------------------------- agent/controller/rest/backup.go | 317 ------------------ agent/controller/rest/model.go | 111 ------- agent/controller/rest/router.go | 63 ---- agent/controller/rest/snapshot.go | 146 --------- agent/controller/rest/volume.go | 81 ----- agent/main.go | 111 ------- agent/replica/rest/backuptarget.go | 61 ---- agent/replica/rest/model.go | 34 -- agent/replica/rest/router.go | 39 --- agent/status/common.go | 25 -- agent/status/controller.go | 29 -- agent/status/replica.go | 92 ------ scripts/build | 8 +- scripts/build-agent | 9 - scripts/build-cli | 9 - 16 files changed, 5 insertions(+), 1626 deletions(-) delete mode 100644 agent/controller/controller.go delete mode 100644 agent/controller/rest/backup.go delete mode 100644 agent/controller/rest/model.go delete mode 100644 agent/controller/rest/router.go delete mode 100644 agent/controller/rest/snapshot.go delete mode 100644 agent/controller/rest/volume.go delete mode 100644 agent/main.go delete mode 100644 agent/replica/rest/backuptarget.go delete mode 100644 agent/replica/rest/model.go delete mode 100644 agent/replica/rest/router.go delete mode 100644 agent/status/common.go delete mode 100644 agent/status/controller.go delete mode 100644 agent/status/replica.go delete mode 100755 scripts/build-agent delete mode 100755 scripts/build-cli diff --git a/agent/controller/controller.go b/agent/controller/controller.go deleted file mode 100644 index 1b2afc15..00000000 --- a/agent/controller/controller.go +++ /dev/null @@ -1,496 +0,0 @@ -package controller - -import ( - "fmt" - "io/ioutil" - "net" - "net/http" - "os" - "os/exec" - "time" - - "github.com/Sirupsen/logrus" - - "github.com/rancher/go-rancher-metadata/metadata" - lclient "github.com/rancher/longhorn/controller/client" - "github.com/rancher/longhorn/controller/rest" - replicaClient "github.com/rancher/longhorn/replica/client" -) - -const ( - defaultVolumeSize = "10737418240" // 10 gb - MetadataURL = "http://rancher-metadata/2015-12-19" - errorRetryMax = 1 -) - -type replica struct { - client *replicaClient.ReplicaClient - host string - port int - healthState string - size string -} - -func ReplicaAddress(host string, port int) string { - return fmt.Sprintf("tcp://%s:%d", host, port) -} - -type Controller struct { - client *lclient.ControllerClient - errorRetries map[string]int -} - -func New() *Controller { - client := lclient.NewControllerClient("http://localhost:9501") - return &Controller{ - client: client, - errorRetries: map[string]int{}, - } -} - -func (c *Controller) Close() error { - logrus.Infof("Shutting down Longhorn.") - return nil -} - -func (c *Controller) Start() error { - logrus.Infof("Starting Longhorn.") - - volume, err := c.client.GetVolume() - if err != nil { - return fmt.Errorf("Error while getting volume: %v", err) - } - - if volume.ReplicaCount == 0 { - if err = c.getReplicasAndStart(); err != nil { - return err - } - } else { - logrus.Infof("Volume is started with %v replicas.", volume.ReplicaCount) - } - - return c.refresh() -} - -func (c *Controller) getReplicasAndStart() error { - var replicaMetadata map[string]*replica - var scale int - for { - var err error - if scale, replicaMetadata, err = c.replicaMetadataAndClient(); err != nil { - return err - } else if len(replicaMetadata) < scale { - logrus.Infof("Waiting for replicas. Current %v, expected: %v", len(replicaMetadata), scale) - time.Sleep(1 * time.Second) - } else { - break - } - } - - initializingReplicas := map[string]*replica{} - closedCleanReplicas := map[string]*replica{} - closedDirtyReplicas := map[string]*replica{} - openCleanReplicas := map[string]*replica{} - openDirtyReplicas := map[string]*replica{} - rebuildingClosedReplicas := map[string]*replica{} - rebuildingOpenReplicas := map[string]*replica{} - otherReplicas := map[string]*replica{} - - for address, replicaMd := range replicaMetadata { - replica, err := replicaMd.client.GetReplica() - if err != nil { - logrus.Errorf("Error getting replica %v. Removing from list of start replcias. Error: %v", address, err) - continue - } - - if replica.State == "initial" { - initializingReplicas[address] = replicaMd - - } else if replica.Rebuilding && replica.State == "closed" { - rebuildingClosedReplicas[address] = replicaMd - - } else if replica.Rebuilding { - rebuildingOpenReplicas[address] = replicaMd - - } else if replica.State == "closed" && replica.Dirty { - closedDirtyReplicas[address] = replicaMd - - } else if replica.State == "closed" { - closedCleanReplicas[address] = replicaMd - - } else if replica.State == "open" { - openCleanReplicas[address] = replicaMd - - } else if replica.State == "dirty" { - openDirtyReplicas[address] = replicaMd - - } else { - otherReplicas[address] = replicaMd - - } - } - logrus.Infof("Initializing replicas: %v", initializingReplicas) - logrus.Infof("Closed and clean replicas: %v", closedCleanReplicas) - logrus.Infof("Closed and dirty replicas: %v", closedDirtyReplicas) - logrus.Infof("Open and dirty replicas: %v", openDirtyReplicas) - logrus.Infof("Open and clean replicas: %v", openCleanReplicas) - logrus.Infof("Rebuilding and closed replicas: %v", rebuildingClosedReplicas) - logrus.Infof("Rebuilding and open replicas: %v", rebuildingOpenReplicas) - logrus.Infof("Other replicas (likely in error state)L %v", otherReplicas) - - // Closed and clean. Start with all replicas. - attemptedStart, err := c.startWithAll(closedCleanReplicas, false) - if attemptedStart { - return err - } - - // Closed and dirty. Start with one. - attemptedStart, err = c.startWithOne(closedDirtyReplicas, false) - if attemptedStart { - return err - } - - // Open and dirty. Close and start with one. - attemptedStart, err = c.startWithOne(openDirtyReplicas, true) - if attemptedStart { - return err - } - - // Open and clean. Close and start with one (because they could become dirty before we close). - attemptedStart, err = c.startWithOne(openCleanReplicas, true) - if attemptedStart { - return err - } - - // Rebuilding and closed. Start with one. - attemptedStart, err = c.startWithOne(rebuildingClosedReplicas, false) - if attemptedStart { - return err - } - - // Rebuilding and open. Close and start with one. - attemptedStart, err = c.startWithOne(rebuildingOpenReplicas, true) - if attemptedStart { - return err - } - - // Initial. Start with all - attemptedStart, err = c.startWithAll(initializingReplicas, true) - if attemptedStart { - return err - } - - return fmt.Errorf("Couldn't find any valid replicas to start with. Original replicas from metadata: %v", replicaMetadata) -} - -func (c *Controller) startWithAll(replicas map[string]*replica, create bool) (bool, error) { - addresses := []string{} - for address, replica := range replicas { - if create { - logrus.Infof("Create replica %v", address) - if err := replica.client.Create(replica.size); err != nil { - logrus.Errorf("Error creating replica %v: %v. It won't be used to start controller.", address, err) - continue - } - } - addresses = append(addresses, address) - } - if len(addresses) > 0 { - logrus.Infof("Starting controller with replicas: %v.", addresses) - return true, c.client.Start(addresses...) - } - return false, nil -} - -// Start the controller with a single replica from the provided map. If the map is bigger than one, will try with each replica. -// Return bool indicates if the controller attempted to start. -func (c *Controller) startWithOne(replicas map[string]*replica, close bool) (bool, error) { - returnErrors := []error{} - for addr, replica := range replicas { - if close { - logrus.Infof("Closing replica %v", addr) - if err := replica.client.Close(); err != nil { - logrus.Errorf("Error closing replica %v: %v. It won't be used to start controller.", addr, err) - continue - } - } - - logrus.Infof("Starting controller with replica: %v.", addr) - if err := c.client.Start(addr); err != nil { - returnErrors = append(returnErrors, fmt.Errorf("%v: %v", addr, err)) - } else { - return true, nil - } - } - - var err error - if len(returnErrors) > 0 { - err = fmt.Errorf("Enountered %v errors trying to start controller. Errors: %v", len(returnErrors), returnErrors) - } - return err != nil, err -} - -func (c *Controller) refresh() error { - for { - if err := c.syncReplicas(); err != nil { - logrus.Errorf("Failed to sync replicas: %v", err) - } - time.Sleep(5 * time.Second) - } -} - -func (c *Controller) syncReplicas() (retErr error) { - logrus.Debugf("Syncing replicas.") - - // Remove replicas from controller if they aren't in metadata - _, fromMetadata, err := c.replicaMetadataAndClient() - if err != nil { - return fmt.Errorf("Error listing replicas in metadata: %v", err) - } - if err := c.removeReplicasNotInMetadata(fromMetadata); err != nil { - return err - } - - // Retry replicas in error state - if err := c.retryErroredReplicas(); err != nil { - return err - } - - // Add new replicas - return c.addReplicasInMetadata() -} - -func (c *Controller) removeReplicasNotInMetadata(fromMetadata map[string]*replica) error { - replicasInController, err := c.client.ListReplicas() - if err != nil { - return fmt.Errorf("Error listing replicas in controller during remove: %v", err) - } - fromController := map[string]rest.Replica{} - for _, r := range replicasInController { - fromController[r.Address] = r - } - - if len(fromController) > 1 { - for address := range fromController { - if _, ok := fromMetadata[address]; !ok { - logrus.Infof("Replica %v not in metadata. Removing it.", address) - if _, err := c.client.DeleteReplica(address); err != nil { - return fmt.Errorf("Error removing replica %v: %v", address, err) - } - return c.removeReplicasNotInMetadata(fromMetadata) - } - } - } - - return nil -} - -func (c *Controller) retryErroredReplicas() error { - _, fromMetadata, err := c.replicaMetadataAndClient() - if err != nil { - return fmt.Errorf("Error listing replicas in metadata during retry: %v", err) - } - - replicasInController, err := c.client.ListReplicas() - if err != nil { - return fmt.Errorf("Error listing replicas in controller during retry: %v", err) - } - - for _, r := range replicasInController { - if r.Mode != "ERR" { - continue - } - - if retryCount, ok := c.errorRetries[r.Address]; ok && retryCount >= errorRetryMax { - logrus.Infof("Reached max retry count for replica %v. Ignoring it so that replica helthcheck failure destroys it.", r.Address) - } else { - logrus.Infof("Retrying errored replica %v", r.Address) - c.errorRetries[r.Address] = retryCount + 1 - replicaMD, ok := fromMetadata[r.Address] - if !ok { - logrus.Warnf("Cannot find errored replica %v in metadata. Won't attempt to re-add it.", r.Actions) - } else if err := c.removeAndAdd(r, replicaMD); err != nil { - return fmt.Errorf("Error performing remove and add for replica %v: %v", r.Address, err) - } else { - // remove and add was successful - delete(c.errorRetries, r.Address) - } - } - } - - // Cleanup error retires map - for address := range c.errorRetries { - if _, ok := fromMetadata[address]; !ok { - delete(c.errorRetries, address) - } - } - - return nil -} - -func (c *Controller) removeAndAdd(replica rest.Replica, replicaMD *replica) error { - logrus.Infof("Removing errored replica %v for re-add.", replica.Address) - if _, err := c.client.DeleteReplica(replica.Address); err != nil { - return fmt.Errorf("error removing errored replica %v: %v", replica.Address, err) - } - - freshReplica, err := replicaMD.client.GetReplica() - if err != nil { - return fmt.Errorf("error getting replica %v during removeAndAdd: %v", replica.Address, err) - } - - if _, ok := freshReplica.Actions["close"]; ok { - err := replicaMD.client.Close() - if err != nil { - return fmt.Errorf("error closing replica %v before adding: %v", replica.Address, err) - } - } - - return c.addReplica(replicaMD) -} - -func (c *Controller) addReplicasInMetadata() error { - _, fromMetadata, err := c.replicaMetadataAndClient() - if err != nil { - return fmt.Errorf("Error listing replicas in metadata during add: %v", err) - } - - replicasInController, err := c.client.ListReplicas() - if err != nil { - return fmt.Errorf("Error listing replicas in controller during add: %v", err) - } - - fromController := map[string]rest.Replica{} - for _, r := range replicasInController { - fromController[r.Address] = r - } - - for address, r := range fromMetadata { - if _, ok := fromController[address]; !ok { - logrus.Infof("Adding replica %v because it isn't in controller.", address) - if err := c.addReplica(r); err != nil { - return fmt.Errorf("Error adding replica %v: %v", address, err) - } - } - } - - return nil -} - -func (c *Controller) testSyncAgent(host string) error { - address := fmt.Sprintf("%v:%v", host, 9504) - conn, err := net.DialTimeout("tcp", address, time.Second*10) - if err != nil { - return err - } - conn.Close() - return nil -} - -func (c *Controller) addReplica(r *replica) error { - replica, err := r.client.GetReplica() - if err != nil { - return fmt.Errorf("Error getting replica %v before adding: %v", r.host, err) - } - - // Ensure sync-agent is up and running - if err := c.testSyncAgent(r.host); err != nil { - return fmt.Errorf("Error while testing sync agent connection: %v", err) - } - - if _, ok := replica.Actions["create"]; ok { - err := r.client.Create(r.size) - if err != nil { - return fmt.Errorf("Error opening replica %v before adding: %v", r.host, err) - } - } else if _, ok := replica.Actions["close"]; ok { - err := r.client.Close() - if err != nil { - return fmt.Errorf("Error closing replica %v before adding: %v", r.host, err) - } - } - - address := ReplicaAddress(r.host, r.port) - logrus.Infof("Calling longhorn add cli for replica %v.", address) - cmd := exec.Command("longhorn", "add", address) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - - if err := cmd.Run(); err != nil { - logrus.Warnf("longhorn add cli returned error %v while adding replica %v. Attempting to clean up.", err, address) - replicas, err2 := c.client.ListReplicas() - if err2 != nil { - logrus.Errorf("Error listing replicas while trying to clean up after failed add for replica %v: %v", address, err2) - } else { - for _, replica := range replicas { - if replica.Address == address && replica.Mode != "RW" { - logrus.Infof("Removing replica %v after having failed to add it. Add failure: %v", address, err) - if _, err := c.client.DeleteReplica(address); err != nil { - logrus.Errorf("Error while deleting replica as part of cleanup: %v", err) - } - } - } - } - return fmt.Errorf("Error executing add command %v: %v", cmd, err) - } - return nil -} - -func (c *Controller) replicaMetadataAndClient() (int, map[string]*replica, error) { - client, err := metadata.NewClientAndWait(MetadataURL) - if err != nil { - return 0, nil, err - } - service, err := client.GetSelfServiceByName("replica") - if err != nil { - return 0, nil, err - } - - // Unmarshalling the metadata as json is forcing it to a bad format - resp, err := http.Get(MetadataURL + "/self/service/metadata/volume/volume_config/size") - if err != nil { - return 0, nil, err - } - - size := "" - if resp.StatusCode == 200 { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return 0, nil, err - } - size = string(body) - } - - if size == "" { - size = defaultVolumeSize - } - - containers := map[string]metadata.Container{} - for _, container := range service.Containers { - if c, ok := containers[container.Name]; !ok { - containers[container.Name] = container - } else if container.CreateIndex > c.CreateIndex { - containers[container.Name] = container - } - } - - result := map[string]*replica{} - for _, container := range containers { - r := &replica{ - healthState: container.HealthState, - host: container.PrimaryIp, - port: 9502, - size: size, - } - - address := ReplicaAddress(r.host, r.port) - replicaClient, err := replicaClient.NewReplicaClient(address) - if err != nil { - return 0, nil, fmt.Errorf("Error getting client for replica %v: %v", address, err) - } - r.client = replicaClient - result[address] = r - } - - return service.Scale, result, nil -} diff --git a/agent/controller/rest/backup.go b/agent/controller/rest/backup.go deleted file mode 100644 index cd210ed9..00000000 --- a/agent/controller/rest/backup.go +++ /dev/null @@ -1,317 +0,0 @@ -package rest - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "os" - "os/exec" - "sync" - - "github.com/Sirupsen/logrus" - "github.com/gorilla/mux" - - "github.com/rancher/go-rancher-metadata/metadata" - "github.com/rancher/go-rancher/api" - "github.com/rancher/longhorn/agent/controller" - "github.com/rancher/longhorn/agent/replica/rest" - "regexp" -) - -// TODO Add logic to purge old entries from these maps -var restoreMutex = &sync.RWMutex{} -var restoreMap = make(map[string]*status) - -var backupMutex = &sync.RWMutex{} -var backupMap = make(map[string]*status) - -var doesntExistRegex = regexp.MustCompile("cannot find.*in objectstore") - -func (s *Server) CreateBackup(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Creating backup") - - apiContext := api.GetApiContext(req) - id := mux.Vars(req)["id"] - - snapshot, err := s.getSnapshot(apiContext, id) - if err != nil { - return err - } - - if snapshot == nil { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - var input backupInput - if err := apiContext.Read(&input); err != nil { - return err - } - - if input.UUID == "" { - rw.WriteHeader(http.StatusBadRequest) - return nil - } - - if status := checkStatus(input.UUID, backupMap, backupMutex); status != nil { - logrus.Infof("Found status %v for id %v for backup request.", status, input.UUID) - return apiContext.WriteResource(status) - } - - if err := prepareBackupTarget(input.BackupTarget); err != nil { - return err - } - - destination := fmt.Sprintf("vfs:///var/lib/rancher/longhorn/backups/%v/%v", input.BackupTarget.Name, input.BackupTarget.UUID) - status, err := backup(input.UUID, snapshot.Id, destination) - if err != nil { - return err - } - - return apiContext.WriteResource(status) -} - -func (s *Server) RemoveBackup(rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - - var input locationInput - if err := apiContext.Read(&input); err != nil { - return err - } - logrus.Infof("Removing backup %#v", input) - - if input.Location == "" { - rw.WriteHeader(http.StatusBadRequest) - return nil - } - - if err := prepareBackupTarget(input.BackupTarget); err != nil { - return err - } - - exists, err := backupExists(input) - if err != nil { - return fmt.Errorf("Error while determining if backup exists: %v", err) - } - - if !exists { - logrus.Infof("Backup [%v] doesn't exist. Nothing to remove.", input.Location) - rw.WriteHeader(http.StatusNoContent) - return nil - } - - cmd := exec.Command("longhorn", "backup", "rm", input.Location) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - logrus.Infof("Running %v", cmd.Args) - if err := cmd.Run(); err != nil { - return err - } - - rw.WriteHeader(http.StatusNoContent) - return nil -} - -func (s *Server) RestoreFromBackup(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Restoring from backup") - - apiContext := api.GetApiContext(req) - id := mux.Vars(req)["id"] - - if id != "1" { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - var input locationInput - if err := apiContext.Read(&input); err != nil { - return err - } - - if input.Location == "" || input.UUID == "" { - rw.WriteHeader(http.StatusBadRequest) - return nil - } - - if status := checkStatus(input.UUID, restoreMap, restoreMutex); status != nil { - logrus.Infof("Found status %v for id %v for restore request.", status, input.UUID) - return apiContext.WriteResource(status) - } - - if err := prepareBackupTarget(input.BackupTarget); err != nil { - return err - } - - restoreStatus, err := restore(input.UUID, input.Location) - if err != nil { - return err - } - - return apiContext.WriteResource(restoreStatus) -} - -func restore(uuid, location string) (*status, error) { - cmd := exec.Command("longhorn", "backup", "restore", location) - logrus.Infof("Running restore command: %v", cmd.Args) - return doStatusBackedCommand(uuid, "restorestatus", cmd, restoreMap, restoreMutex) -} - -func backup(uuid, snapshot, destination string) (*status, error) { - cmd := exec.Command("longhorn", "backup", "create", snapshot, "--dest", destination) - logrus.Infof("Running backup command: %v", cmd.Args) - return doStatusBackedCommand(uuid, "backupstatus", cmd, backupMap, backupMutex) -} - -func doStatusBackedCommand(id, resourceType string, command *exec.Cmd, statusMap map[string]*status, statusMutex *sync.RWMutex) (*status, error) { - output := new(bytes.Buffer) - command.Stdout = output - command.Stderr = os.Stderr - err := command.Start() - if err != nil { - return &status{}, err - } - - statusMutex.Lock() - defer statusMutex.Unlock() - status := newStatus(id, "running", "", resourceType) - statusMap[id] = status - - go func(id string, c *exec.Cmd) { - var message string - var state string - - err := c.Wait() - if err != nil { - logrus.Errorf("Error running command %v: %v", command.Args, err) - state = "error" - message = fmt.Sprintf("Error: %v", err) - } else { - logrus.Infof("Command %v completed successfuly.", command.Args) - state = "done" - message = output.String() - } - - statusMutex.Lock() - defer statusMutex.Unlock() - status, ok := statusMap[id] - if !ok { - status = newStatus(id, "", "", resourceType) - } - - status.State = state - status.Message = message - statusMap[id] = status - }(id, command) - - return status, nil -} - -func (s *Server) GetBackupStatus(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Getting backup status") - return getStatus(backupMap, backupMutex, rw, req) -} - -func (s *Server) GetRestoreStatus(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Getting restore status") - return getStatus(restoreMap, restoreMutex, rw, req) -} - -func checkStatus(id string, statusMap map[string]*status, statusMutex *sync.RWMutex) *status { - statusMutex.RLock() - defer statusMutex.RUnlock() - return statusMap[id] -} - -func getStatus(statusMap map[string]*status, statusMutex *sync.RWMutex, rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - id := mux.Vars(req)["id"] - - statusMutex.RLock() - defer statusMutex.RUnlock() - - status, ok := statusMap[id] - if !ok { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - return apiContext.WriteResource(status) -} - -func backupExists(input locationInput) (bool, error) { - cmd := exec.Command("longhorn", "backup", "inspect", input.Location) - stderr := new(bytes.Buffer) - cmd.Stderr = stderr - cmd.Stdout = os.Stdout - logrus.Infof("Running %v", cmd.Args) - if err := cmd.Run(); err != nil { - errOutput := stderr.String() - if doesntExistRegex.MatchString(errOutput) { - return false, nil - } - logrus.Errorf("Backup inspect error output: %v", errOutput) - return false, err - } - - return true, nil -} - -func prepareBackupTarget(target rest.BackupTarget) error { - replicas, err := replicRestEndpoints() - if err != nil { - return fmt.Errorf("Error getting replica endpoints: %v", err) - } - - b, err := json.Marshal(target) - if err != nil { - return err - } - - // This could be optimized with some goroutines and a waitgroup - for _, r := range replicas { - url := r + "/backuptargets" - resp, err := http.Post(url, "application/json", bytes.NewBuffer(b)) - if err != nil { - return err - } - - if resp.StatusCode >= 300 { - content, _ := ioutil.ReadAll(resp.Body) - resp.Body.Close() - return fmt.Errorf("Bad response preparing mount for %v: %v %v - %s", r, resp.StatusCode, resp.Status, content) - } - resp.Body.Close() - } - - return nil -} - -func replicRestEndpoints() ([]string, error) { - client, err := metadata.NewClientAndWait(controller.MetadataURL) - if err != nil { - return nil, err - } - service, err := client.GetSelfServiceByName("replica") - if err != nil { - return nil, err - } - - containers := map[string]metadata.Container{} - for _, container := range service.Containers { - if c, ok := containers[container.Name]; !ok { - containers[container.Name] = container - } else if container.CreateIndex > c.CreateIndex { - containers[container.Name] = container - } - } - - result := []string{} - for _, container := range containers { - endpoint := fmt.Sprintf("http://%s/v1", container.PrimaryIp) - result = append(result, endpoint) - } - - return result, nil -} diff --git a/agent/controller/rest/model.go b/agent/controller/rest/model.go deleted file mode 100644 index 16ff3d16..00000000 --- a/agent/controller/rest/model.go +++ /dev/null @@ -1,111 +0,0 @@ -package rest - -import ( - "github.com/rancher/go-rancher/api" - "github.com/rancher/go-rancher/client" - rrest "github.com/rancher/longhorn/agent/replica/rest" -) - -type snapshot struct { - client.Resource - Name string `json:"name"` -} - -type snapshotCollection struct { - client.Collection - Data []snapshot `json:"data"` -} - -type status struct { - client.Resource - State string `json:"state,omitempty"` - Message string `json:"message,omitempty"` -} - -type backupInput struct { - UUID string `json:"uuid,omitempty"` - BackupTarget rrest.BackupTarget `json:"backupTarget,omitempty"` -} - -type locationInput struct { - UUID string `json:"uuid,omitempty"` - Location string `json:"location,omitempty"` - BackupTarget rrest.BackupTarget `json:"backupTarget,omitempty"` -} - -type revertInput struct { - Name string `json:"name,omitempty"` -} - -type volume struct { - client.Resource - Name string `json:"name,omitempty"` -} - -func newSnapshot(context *api.ApiContext, name string) *snapshot { - snapshot := &snapshot{ - Resource: client.Resource{ - Id: name, - Type: "snapshot", - Actions: map[string]string{}, - }, - Name: name, - } - - return snapshot -} - -func newStatus(id string, state, message, resourceType string) *status { - return &status{ - Resource: client.Resource{Id: id, Type: resourceType}, - State: state, - Message: message, - } -} - -func newSchema() *client.Schemas { - schemas := &client.Schemas{} - - schemas.AddType("error", client.ServerApiError{}) - schemas.AddType("apiVersion", client.Resource{}) - schemas.AddType("schema", client.Schema{}) - - schemas.AddType("revertToSnapshotInput", revertInput{}) - schemas.AddType("locationInput", locationInput{}) - schemas.AddType("backupInput", backupInput{}) - - volume := schemas.AddType("volume", volume{}) - volume.CollectionMethods = []string{"GET"} - volume.ResourceMethods = []string{"GET"} - volume.ResourceActions = map[string]client.Action{ - "reverttosnapshot": client.Action{ - Input: "revertToSnapshotInput", - Output: "volume", - }, - "restoreFromBackup": client.Action{ - Input: "locationInput", - Output: "restoreStatus", - }, - } - - snapshot := schemas.AddType("snapshot", snapshot{}) - snapshot.CollectionMethods = []string{"GET", "POST"} - snapshot.ResourceMethods = []string{"GET", "PUT", "DELETE"} - snapshot.ResourceActions = map[string]client.Action{ - "backup": client.Action{ - Input: "backupInput", - Output: "backupStatus", - }, - "removeBackup": client.Action{ - Input: "locationInput", - }, - } - - restoreStatus := schemas.AddType("restorestatus", status{}) - restoreStatus.ResourceMethods = []string{"GET"} - - backupStatus := schemas.AddType("backupstatus", status{}) - backupStatus.ResourceMethods = []string{"GET"} - - return schemas -} diff --git a/agent/controller/rest/router.go b/agent/controller/rest/router.go deleted file mode 100644 index 1cfed008..00000000 --- a/agent/controller/rest/router.go +++ /dev/null @@ -1,63 +0,0 @@ -package rest - -import ( - "net/http" - - "github.com/gorilla/mux" - "github.com/rancher/go-rancher/api" - "github.com/rancher/go-rancher/client" - - lclient "github.com/rancher/longhorn/controller/client" -) - -func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { - return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - if err := t(rw, req); err != nil { - apiContext := api.GetApiContext(req) - apiContext.WriteErr(err) - } - })) -} - -func NewRouter(s *Server) *mux.Router { - schemas := newSchema() - router := mux.NewRouter().StrictSlash(true) - f := HandleError - - // API framework routes - router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) - router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) - router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) - router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) - - // Volume(s) - router.Methods("GET").Path("/v1/volumes").Handler(f(schemas, s.ListVolumes)) - router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) - router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "reverttosnapshot").Handler(f(schemas, s.RevertToSnapshot)) - router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "restorefrombackup").Handler(f(schemas, s.RestoreFromBackup)) - - // Snapshots - router.Methods("GET").Path("/v1/snapshots").Handler(f(schemas, s.ListSnapshots)) - router.Methods("GET").Path("/v1/snapshots/{id}").Handler(f(schemas, s.GetSnapshot)) - router.Methods("POST").Path("/v1/snapshots").Handler(f(schemas, s.CreateSnapshot)) - router.Methods("DELETE").Path("/v1/snapshots/{id}").Handler(f(schemas, s.DeleteSnapshot)) - router.Methods("POST").Path("/v1/snapshots/{id}").Queries("action", "backup").Handler(f(schemas, s.CreateBackup)) - router.Methods("POST").Path("/v1/snapshots/{id}").Queries("action", "removebackup").Handler(f(schemas, s.RemoveBackup)) - - // Restore status - router.Methods("GET").Path("/v1/backupstatuses/{id}").Handler(f(schemas, s.GetBackupStatus)) - router.Methods("GET").Path("/v1/restorestatuses/{id}").Handler(f(schemas, s.GetRestoreStatus)) - - return router -} - -type Server struct { - controllerClient *lclient.ControllerClient -} - -func NewServer() *Server { - contollerClient := lclient.NewControllerClient("http://localhost:9501") - return &Server{ - controllerClient: contollerClient, - } -} diff --git a/agent/controller/rest/snapshot.go b/agent/controller/rest/snapshot.go deleted file mode 100644 index e798a3df..00000000 --- a/agent/controller/rest/snapshot.go +++ /dev/null @@ -1,146 +0,0 @@ -package rest - -import ( - "bufio" - "fmt" - "net/http" - "os" - "os/exec" - - "github.com/gorilla/mux" - - "github.com/rancher/go-rancher/api" - "github.com/rancher/go-rancher/client" -) - -func (s *Server) ListSnapshots(rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - snapshots, err := s.listSnapshot(apiContext) - if err != nil { - return err - } - apiContext.Write(&client.GenericCollection{ - Data: []interface{}{ - snapshots, - }, - }) - return nil -} - -func (s *Server) GetSnapshot(rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - vars := mux.Vars(req) - id, ok := vars["id"] - if !ok { - return fmt.Errorf("snapshot id not supplied") - } - - snap, err := s.getSnapshot(apiContext, id) - if err != nil { - return err - } - - if snap == nil { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - apiContext.Write(snap) - return nil -} - -func (s *Server) CreateSnapshot(rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - var snapshot snapshot - if err := apiContext.Read(&snapshot); err != nil { - return err - } - - name, err := s.controllerClient.Snapshot(snapshot.Name) - if err != nil { - return err - } - - apiContext.Write(newSnapshot(apiContext, name)) - - return nil -} - -func (s *Server) DeleteSnapshot(rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - vars := mux.Vars(req) - id, ok := vars["id"] - if !ok { - return fmt.Errorf("snapshot id not supplied") - } - - snapshot, err := s.getSnapshot(apiContext, id) - if err != nil { - return err - } - - if snapshot == nil { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - cmd := exec.Command("longhorn", "snapshots", "rm", snapshot.Id) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - if err := cmd.Run(); err != nil { - return err - } - - rw.WriteHeader(http.StatusNoContent) - return nil -} - -func (s *Server) listSnapshot(context *api.ApiContext) ([]*snapshot, error) { - cmd := exec.Command("longhorn", "snapshots") - cmd.Stderr = os.Stderr - output, err := cmd.StdoutPipe() - if err != nil { - return nil, err - } - - if err := cmd.Start(); err != nil { - return nil, err - } - - scanner := bufio.NewScanner(output) - first := true - snapshots := []*snapshot{} - for scanner.Scan() { - if first { - first = false - continue - } - - name := scanner.Text() - snap := newSnapshot(context, name) - snapshots = append(snapshots, snap) - } - - if err := cmd.Wait(); err != nil { - return nil, err - } - - if err := scanner.Err(); err != nil { - return nil, err - } - - return snapshots, nil -} - -func (s *Server) getSnapshot(context *api.ApiContext, id string) (*snapshot, error) { - snapshots, err := s.listSnapshot(context) - if err != nil { - return nil, err - } - for _, s := range snapshots { - if s.Id == id { - return s, nil - } - } - return nil, nil -} diff --git a/agent/controller/rest/volume.go b/agent/controller/rest/volume.go deleted file mode 100644 index 33e88305..00000000 --- a/agent/controller/rest/volume.go +++ /dev/null @@ -1,81 +0,0 @@ -package rest - -import ( - "net/http" - - "github.com/Sirupsen/logrus" - "github.com/gorilla/mux" - - "github.com/rancher/go-rancher/api" - "github.com/rancher/go-rancher/client" -) - -func (s *Server) ListVolumes(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Listing volumes") - - apiContext := api.GetApiContext(req) - - apiContext.Write(&client.GenericCollection{ - Data: []interface{}{ - s.getVolume(apiContext), - }, - }) - return nil -} - -func (s *Server) GetVolume(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Getting volumes") - - apiContext := api.GetApiContext(req) - id := mux.Vars(req)["id"] - - if id != "1" { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - v := s.getVolume(apiContext) - apiContext.Write(v) - return nil -} - -func (s *Server) RevertToSnapshot(rw http.ResponseWriter, req *http.Request) error { - logrus.Infof("Reverting to snapshot") - - apiContext := api.GetApiContext(req) - id := mux.Vars(req)["id"] - - if id != "1" { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - var input revertInput - if err := apiContext.Read(&input); err != nil { - return err - } - - snap, err := s.getSnapshot(apiContext, input.Name) - if err != nil { - return err - } - - if snap == nil { - rw.WriteHeader(http.StatusBadRequest) - return nil - } - - _, err = s.controllerClient.RevertVolume(snap.Name) - if err != nil { - return err - } - - return s.GetVolume(rw, req) -} - -func (s *Server) getVolume(context *api.ApiContext) *volume { - return &volume{ - Resource: client.Resource{Id: "1"}, - Name: "volume", - } -} diff --git a/agent/main.go b/agent/main.go deleted file mode 100644 index ef3dbfc7..00000000 --- a/agent/main.go +++ /dev/null @@ -1,111 +0,0 @@ -package main - -import ( - "net/http" - "os" - - "github.com/Sirupsen/logrus" - "github.com/codegangsta/cli" - "github.com/gorilla/handlers" - "github.com/gorilla/mux" - "github.com/rancher/longhorn/agent/controller" - "github.com/rancher/longhorn/agent/controller/rest" - replica "github.com/rancher/longhorn/agent/replica/rest" - "github.com/rancher/longhorn/agent/status" -) - -var ( - VERSION = "0.0.0" -) - -func main() { - app := cli.NewApp() - app.Version = VERSION - app.Flags = []cli.Flag{ - cli.BoolFlag{ - Name: "controller", - }, - cli.BoolFlag{ - Name: "replica", - }, - cli.StringFlag{ - Name: "listen, l", - Value: ":8199", - }, - cli.StringFlag{ - Name: "log-level", - Value: "debug", - }, - } - app.Action = func(c *cli.Context) { - if err := runApp(c); err != nil { - logrus.Fatal(err) - } - } - app.Run(os.Args) -} - -func runApp(context *cli.Context) error { - logLevel := context.GlobalString("log-level") - lvl, err := logrus.ParseLevel(logLevel) - if err != nil { - return err - } - logrus.SetLevel(lvl) - - runController := context.GlobalBool("controller") - runReplica := context.GlobalBool("replica") - - if runController { - go runPing(context) - go runControllerAPI(context) - c := controller.New() - defer c.Close() - return c.Start() - } else if runReplica { - go runReplicaAPI(context) - return runPing(context) - } - - return nil -} - -func runControllerAPI(context *cli.Context) { - server := rest.NewServer() - router := http.Handler(rest.NewRouter(server)) - - router = handlers.LoggingHandler(os.Stdout, router) - router = handlers.ProxyHeaders(router) - listen := "0.0.0.0:80" - logrus.Infof("Listening on %s", listen) - err := http.ListenAndServe(listen, router) - logrus.Fatalf("API returned with error: %v", err) -} - -func runReplicaAPI(context *cli.Context) { - router := http.Handler(replica.NewRouter()) - router = handlers.LoggingHandler(os.Stdout, router) - router = handlers.ProxyHeaders(router) - listen := "0.0.0.0:80" - logrus.Infof("Listening on %s", listen) - err := http.ListenAndServe(listen, router) - logrus.Fatalf("API returned with error: %v", err) -} - -func runPing(context *cli.Context) error { - controller := status.NewControllerStatus() - - replica, err := status.NewReplicaStatus() - if err != nil { - return err - } - - r := mux.NewRouter() - r.Handle("/controller/status", controller) - r.Handle("/replica/status", replica) - http.Handle("/", r) - - listen := context.GlobalString("listen") - logrus.Info("Listening for healthcheck requests on ", listen) - return http.ListenAndServe(listen, nil) -} diff --git a/agent/replica/rest/backuptarget.go b/agent/replica/rest/backuptarget.go deleted file mode 100644 index 9488d17f..00000000 --- a/agent/replica/rest/backuptarget.go +++ /dev/null @@ -1,61 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - "os" - "os/exec" - "strconv" - - "github.com/Sirupsen/logrus" - - "github.com/rancher/go-rancher/api" -) - -func (s *server) ConfigureBackupTarget(rw http.ResponseWriter, req *http.Request) error { - apiContext := api.GetApiContext(req) - target := &BackupTarget{} - if err := apiContext.Read(target); err != nil { - return err - } - - if err := s.createNFSMount(target); err != nil { - return fmt.Errorf("Unable to create nfs mount for %#v. Error %v", target, err) - } - - return nil -} - -func (s *server) createNFSMount(target *BackupTarget) error { - mountDir := constructMountDir(target) - - grep := exec.Command("grep", mountDir, "/proc/mounts") - if err := grep.Run(); err == nil { - logrus.Infof("Found mount %v.", mountDir) - return nil - } - - if err := os.MkdirAll(mountDir, 0770); err != nil { - return err - } - - remoteTarget := fmt.Sprintf("%v:%v", target.NFSConfig.Server, target.NFSConfig.Share) - parentPid := strconv.Itoa(os.Getppid()) - - var mount *exec.Cmd - if target.NFSConfig.MountOptions == "" { - mount = exec.Command("nsenter", "-t", parentPid, "-n", "mount", "-t", "nfs", remoteTarget, mountDir) - } else { - mount = exec.Command("nsenter", "-t", parentPid, "-n", "mount", "-t", "nfs", "-o", target.NFSConfig.MountOptions, remoteTarget, mountDir) - } - - mount.Stdout = os.Stdout - mount.Stderr = os.Stderr - - logrus.Infof("Running %v", mount.Args) - return mount.Run() -} - -func constructMountDir(target *BackupTarget) string { - return fmt.Sprintf("/var/lib/rancher/longhorn/backups/%s/%s", target.Name, target.UUID) -} diff --git a/agent/replica/rest/model.go b/agent/replica/rest/model.go deleted file mode 100644 index 81c7b45b..00000000 --- a/agent/replica/rest/model.go +++ /dev/null @@ -1,34 +0,0 @@ -package rest - -import ( - "github.com/rancher/go-rancher/client" -) - -type BackupTarget struct { - client.Resource - UUID string `json:"uuid,omitempty"` - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` - NFSConfig NFSConfig `json:"nfsConfig,omitempty"` -} - -type NFSConfig struct { - Server string `json:"server"` - Share string `json:"share"` - MountOptions string `json:"mountOptions"` -} - -func newSchema() *client.Schemas { - schemas := &client.Schemas{} - - schemas.AddType("error", client.ServerApiError{}) - schemas.AddType("apiVersion", client.Resource{}) - schemas.AddType("schema", client.Schema{}) - - target := schemas.AddType("backupTarget", BackupTarget{}) - target.CollectionMethods = []string{"POST", "GET"} - - schemas.AddType("nfsConfig", NFSConfig{}) - - return schemas -} diff --git a/agent/replica/rest/router.go b/agent/replica/rest/router.go deleted file mode 100644 index 930a6ef5..00000000 --- a/agent/replica/rest/router.go +++ /dev/null @@ -1,39 +0,0 @@ -package rest - -import ( - "net/http" - - "github.com/gorilla/mux" - - "github.com/rancher/go-rancher/api" - "github.com/rancher/go-rancher/client" -) - -func HandleError(s *client.Schemas, t func(http.ResponseWriter, *http.Request) error) http.Handler { - return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - if err := t(rw, req); err != nil { - apiContext := api.GetApiContext(req) - apiContext.WriteErr(err) - } - })) -} - -func NewRouter() *mux.Router { - s := &server{} - schemas := newSchema() - router := mux.NewRouter().StrictSlash(true) - f := HandleError - - // API framework routes - router.Methods("GET").Path("/").Handler(api.VersionsHandler(schemas, "v1")) - router.Methods("GET").Path("/v1/schemas").Handler(api.SchemasHandler(schemas)) - router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) - router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) - - // Backup targets - router.Methods("POST").Path("/v1/backuptargets").Handler(f(schemas, s.ConfigureBackupTarget)) - - return router -} - -type server struct{} diff --git a/agent/status/common.go b/agent/status/common.go deleted file mode 100644 index f6d1d35f..00000000 --- a/agent/status/common.go +++ /dev/null @@ -1,25 +0,0 @@ -package status - -import ( - "net/http" - - "github.com/Sirupsen/logrus" -) - -func writeOK(rw http.ResponseWriter) { - rw.Write([]byte("OK")) -} - -func writeError(rw http.ResponseWriter, err error) { - writeErrorString(rw, err.Error()) -} - -func writeErrorString(rw http.ResponseWriter, msg string) { - if rw != nil { - logrus.Infof("Reporting unhealthy status: %v", msg) - rw.WriteHeader(http.StatusServiceUnavailable) - rw.Write([]byte(msg)) - } else { - logrus.Warn("Not reporting a status. ResponseWriter is null.") - } -} diff --git a/agent/status/controller.go b/agent/status/controller.go deleted file mode 100644 index 8393fe4d..00000000 --- a/agent/status/controller.go +++ /dev/null @@ -1,29 +0,0 @@ -package status - -import ( - "net/http" - - "github.com/rancher/longhorn/controller/client" -) - -type ControllerStatus struct { - controller *client.ControllerClient -} - -func NewControllerStatus() *ControllerStatus { - - controllerClient := client.NewControllerClient("http://localhost:9501/v1") - return &ControllerStatus{ - controller: controllerClient, - } -} - -func (s *ControllerStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - _, err := s.controller.GetVolume() - if err != nil { - writeError(rw, err) - return - } - - writeOK(rw) -} diff --git a/agent/status/replica.go b/agent/status/replica.go deleted file mode 100644 index 02efb256..00000000 --- a/agent/status/replica.go +++ /dev/null @@ -1,92 +0,0 @@ -package status - -import ( - "fmt" - "net/http" - - md "github.com/rancher/go-rancher-metadata/metadata" - "github.com/rancher/longhorn/controller/client" - replicaClient "github.com/rancher/longhorn/replica/client" - - "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/agent/controller" -) - -type ReplicaStatus struct { - controller *client.ControllerClient - replica *replicaClient.ReplicaClient - metadata *md.Client - address string - controllerLastError string -} - -func NewReplicaStatus() (*ReplicaStatus, error) { - metadata, err := md.NewClientAndWait(controller.MetadataURL) - if err != nil { - return nil, err - } - self, err := metadata.GetSelfContainer() - if err != nil { - return nil, err - } - addr := controller.ReplicaAddress(self.PrimaryIp, 9502) - - controllerClient := client.NewControllerClient("http://controller:9501/v1") - replicaClient, err := replicaClient.NewReplicaClient("http://localhost:9502/v1") - if err != nil { - return nil, err - } - - return &ReplicaStatus{ - controller: controllerClient, - replica: replicaClient, - address: addr, - }, nil -} - -func (s *ReplicaStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - // Checking against the replica is easy: just ensure that the API is responding. - _, err := s.replica.GetReplica() - if err != nil { - writeError(rw, err) - return - } - - if ok, msg := s.checkReplicaStatusInController(rw); !ok { - writeErrorString(rw, msg) - return - } - - writeOK(rw) -} - -func (s *ReplicaStatus) checkReplicaStatusInController(rw http.ResponseWriter) (bool, string) { - replicas, err := s.controller.ListReplicas() - if err != nil { - logrus.Warnf("Couldn't get replicas from controller. Reporting cached status.") - return s.reportCacheControllerResponse() - } - for _, replica := range replicas { - if replica.Address == s.address { - if replica.Mode == "ERR" { - return s.cacheControllerResponse(false, fmt.Sprintf("Replica %v is in error mode.", s.address)) - } - } - } - - return s.cacheControllerResponse(true, "") -} - -func (s *ReplicaStatus) reportCacheControllerResponse() (bool, string) { - healthy := len(s.controllerLastError) == 0 - return healthy, s.controllerLastError -} - -func (s *ReplicaStatus) cacheControllerResponse(ok bool, msg string) (bool, string) { - if ok { - s.controllerLastError = "" - } else { - s.controllerLastError = msg + " (cached response)" - } - return ok, msg -} diff --git a/scripts/build b/scripts/build index 0347cab2..24a50398 100755 --- a/scripts/build +++ b/scripts/build @@ -1,7 +1,9 @@ #!/bin/bash set -e -cd $(dirname $0) +source $(dirname $0)/version -./build-cli -./build-agent +cd $(dirname $0)/.. + +mkdir -p bin +go build -tags "tcmu qcow" -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn diff --git a/scripts/build-agent b/scripts/build-agent deleted file mode 100755 index 98739864..00000000 --- a/scripts/build-agent +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -source $(dirname $0)/version - -cd $(dirname $0)/.. - -mkdir -p bin -go build -tags tcmu -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn-agent ./agent diff --git a/scripts/build-cli b/scripts/build-cli deleted file mode 100755 index 24a50398..00000000 --- a/scripts/build-cli +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -source $(dirname $0)/version - -cd $(dirname $0)/.. - -mkdir -p bin -go build -tags "tcmu qcow" -ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/longhorn From 21ad7a1d460c63734f8c26262c0a645d1d3348c0 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Wed, 28 Dec 2016 13:41:53 -0800 Subject: [PATCH 246/357] remove driver related stuff also update dapper file, test and validation scripts --- Dockerfile.dapper | 42 ++++++++++++++++++------------------------ package/Dockerfile | 5 +---- package/launch-driver | 9 --------- scripts/package | 1 - scripts/test | 9 ++++----- scripts/validate | 3 ++- 6 files changed, 25 insertions(+), 44 deletions(-) delete mode 100755 package/launch-driver diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 904093ad..81fdf422 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,4 +1,8 @@ FROM ubuntu:16.04 +# FROM arm=armhf/ubuntu:16.04 + +ARG DAPPER_HOST_ARCH=amd64 +ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH} # Setup environment ENV PATH /go/bin:$PATH @@ -13,27 +17,26 @@ WORKDIR ${DAPPER_SOURCE} # Install packages RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ apt-get update && \ - apt-get install -y cmake curl git \ + apt-get install -y cmake wget curl git less file \ libglib2.0-dev libkmod-dev libnl-genl-3-dev linux-libc-dev pkg-config psmisc python-tox qemu-utils fuse python-dev \ devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl \ libconfig-general-perl libaio-dev libc6-dev -# Install Go -RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz -RUN echo '702ad90f705365227e902b42d91dd1a40e48ca7f67a2f4b2fd052aaa4295cd95 go.tar.gz' | sha256sum -c && \ - tar xzf go.tar.gz -C /usr/local && \ - rm go.tar.gz -RUN mkdir -p /go -ENV PATH $PATH:/usr/local/go/bin -ENV GOPATH=/go +# needed for ${!var} substitution +RUN rm -f /bin/sh && ln -s /bin/bash /bin/sh -# Go tools -RUN go get github.com/rancher/trash -RUN go get github.com/golang/lint/golint +# Install Go & tools +ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH=GOLANG_ARCH_${ARCH} \ + GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash +RUN wget -O - https://storage.googleapis.com/golang/go1.7.4.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local && \ + go get github.com/rancher/trash && go get github.com/golang/lint/golint # Docker -RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ - chmod +x /usr/bin/docker +ENV DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 \ + DOCKER_URL_arm=https://github.com/rancher/docker/releases/download/v1.10.3-ros1/docker-1.10.3_arm \ + DOCKER_URL=DOCKER_URL_${ARCH} + +RUN wget -O /usr/bin/docker ${!DOCKER_URL} && chmod +x /usr/bin/docker # Build TCMU RUN cd /usr/src && \ @@ -47,17 +50,8 @@ RUN cd /usr/src/tcmu-runner && \ cp scsi_defs.h /usr/local/include && \ cp libtcmu_static.a /usr/local/lib/libtcmu.a -# Install longhorn Docker driver -RUN GOPATH=/tmp/docker-longhorn-driver && \ - mkdir -p $GOPATH/src/github.com/rancher && \ - cd $GOPATH/src/github.com/rancher && \ - git clone https://github.com/rancher/docker-longhorn-driver.git && \ - cd docker-longhorn-driver && \ - git checkout ea7bf49977adb179a2d767f8a5dcf3ec380a34a2 && \ - go build -o /usr/local/bin/docker-longhorn-driver - # Install libqcow -RUN curl -sfL https://github.com/libyal/libqcow/releases/download/20160123/libqcow-alpha-20160123.tar.gz | tar xvzf - -C /usr/src +RUN wget -O - https://github.com/libyal/libqcow/releases/download/20160123/libqcow-alpha-20160123.tar.gz | tar xvzf - -C /usr/src RUN cd /usr/src/libqcow-20160123 && \ ./configure RUN cd /usr/src/libqcow-20160123 && \ diff --git a/package/Dockerfile b/package/Dockerfile index 7ca133f0..c119b732 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -3,10 +3,7 @@ RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.co apt-get update && apt-get install -y kmod curl nfs-common fuse \ libibverbs1 librdmacm1 libconfig-general-perl libaio1 -RUN curl -sSL -o share-mnt https://github.com/rancher/runc/releases/download/share-mnt-v0.1.2/share-mnt && \ - chmod u+x share-mnt && mv share-mnt /usr/bin - -COPY longhorn longhorn-agent launch launch-driver docker-longhorn-driver copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/bin/ +COPY longhorn launch copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/bin/ COPY tgt_*.deb /opt/ RUN dpkg -i /opt/tgt_*.deb CMD ["longhorn"] diff --git a/package/launch-driver b/package/launch-driver deleted file mode 100755 index d96ea421..00000000 --- a/package/launch-driver +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -e -x - -if [ "$1" == "volumedriver" ]; then - /usr/bin/share-mnt /var/lib/rancher/longhorn -- docker-longhorn-driver "$@" -else - docker-longhorn-driver "$@" -fi diff --git a/scripts/package b/scripts/package index 620899e2..bcf0ddf8 100755 --- a/scripts/package +++ b/scripts/package @@ -13,7 +13,6 @@ if [ ! -x ../bin/longhorn ]; then fi cp ../bin/longhorn* . -cp /usr/local/bin/docker-longhorn-driver . cp /usr/src/tgt/pkg/tgt_*.deb . docker build -t ${REPO}/longhorn:${TAG} . diff --git a/scripts/test b/scripts/test index d7f05fe1..365962b1 100755 --- a/scripts/test +++ b/scripts/test @@ -5,10 +5,9 @@ cd $(dirname $0)/.. echo Running tests -if [ ! -x ./bin/longhorn ]; then - ./scripts/build -fi +PACKAGES="$(find . -name '*.go' | xargs -I{} dirname {} | sort -u | grep -Ev '(.git|.trash-cache|vendor|bin)')" -PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" +echo Packages: ${PACKAGES} -go test -race -cover -tags=test ${PACKAGES} +[ "${ARCH}" == "amd64" ] && RACE=-race +go test ${RACE} -cover -tags="test qcow" ${PACKAGES} diff --git a/scripts/validate b/scripts/validate index 17f8372e..4e1fcc07 100755 --- a/scripts/validate +++ b/scripts/validate @@ -5,8 +5,9 @@ cd $(dirname $0)/.. echo Running validation -PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" +PACKAGES="$(find . -name '*.go' | xargs -I{} dirname {} | sort -u | grep -Ev '(.git|.trash-cache|vendor|bin|qcow)')" +echo Packages: ${PACKAGES} echo Running: go vet go vet ${PACKAGES} echo Running: golint From 7e86659db561c1e97fefa90d9d64aee2b0d6f1a0 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 3 Jan 2017 14:35:19 -0800 Subject: [PATCH 247/357] package: Support `--debug` and other global options --- package/launch | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/package/launch b/package/launch index 97d1a573..129b0165 100755 --- a/package/launch +++ b/package/launch @@ -1,25 +1,29 @@ #!/bin/bash -if [ "$1" == "controller" ]; then - mount --rbind /host/dev /dev +is_controller=0 +fe=0 +frontend= +for i in "$@" +do + if [ $fe -eq 1 ] + then + frontend=$i + break + fi + case $i in + controller) + is_controller=1 + ;; + --frontend) + fe=1 + ;; + *) + ;; + esac +done - frontend= - fe=0 - for i in "$@" - do - if [ $fe -eq 1 ] - then - frontend=$i - break - fi - case $i in - --frontend) - fe=1 - ;; - *) - ;; - esac - done +if [ $is_controller -eq 1 ]; then + mount --rbind /host/dev /dev if [ "$frontend" == "tcmu" ] then From 6c7652734cc77c02a9dba63b1db9fe1dc1748d34 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 30 Dec 2016 10:52:13 -0800 Subject: [PATCH 248/357] controller: Add apiContext into NewReplica() method --- controller/rest/model.go | 10 +++++----- controller/rest/replica.go | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/controller/rest/model.go b/controller/rest/model.go index 673049fe..6b38d7a2 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -76,7 +76,7 @@ func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { return v } -func NewReplica(address string, mode types.Mode) *Replica { +func NewReplica(context *api.ApiContext, address string, mode types.Mode) *Replica { return &Replica{ Resource: client.Resource{ Id: EncodeID(address), @@ -125,18 +125,18 @@ func NewSchema() *client.Schemas { volumes := schemas.AddType("volume", Volume{}) volumes.ResourceActions = map[string]client.Action{ - "revert": client.Action{ + "revert": { Input: "revertInput", Output: "volume", }, - "start": client.Action{ + "start": { Input: "startInput", Output: "volume", }, - "shutdown": client.Action{ + "shutdown": { Output: "volume", }, - "snapshot": client.Action{ + "snapshot": { Input: "snapshotInput", Output: "snapshotOutput", }, diff --git a/controller/rest/replica.go b/controller/rest/replica.go index 5d4663d6..2ab6638c 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -13,7 +13,7 @@ func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) resp := client.GenericCollection{} for _, r := range s.c.ListReplicas() { - resp.Data = append(resp.Data, NewReplica(r.Address, r.Mode)) + resp.Data = append(resp.Data, NewReplica(apiContext, r.Address, r.Mode)) } resp.ResourceType = "replica" @@ -34,7 +34,7 @@ func (s *Server) GetReplica(rw http.ResponseWriter, req *http.Request) error { return nil } - apiContext.Write(s.getReplica(id)) + apiContext.Write(s.getReplica(apiContext, id)) return nil } @@ -49,14 +49,14 @@ func (s *Server) CreateReplica(rw http.ResponseWriter, req *http.Request) error return err } - apiContext.Write(s.getReplica(replica.Address)) + apiContext.Write(s.getReplica(apiContext, replica.Address)) return nil } -func (s *Server) getReplica(id string) *Replica { +func (s *Server) getReplica(context *api.ApiContext, id string) *Replica { for _, r := range s.c.ListReplicas() { if r.Address == id { - return NewReplica(r.Address, r.Mode) + return NewReplica(context, r.Address, r.Mode) } } return nil @@ -89,6 +89,5 @@ func (s *Server) UpdateReplica(rw http.ResponseWriter, req *http.Request) error return err } - apiContext.Write(s.getReplica(id)) - return nil + return s.GetReplica(rw, req) } From ef3f210c745e2c8cf664c093175b91431c06c7d8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 30 Dec 2016 16:21:07 -0800 Subject: [PATCH 249/357] sync: The final check of sync completion will be done by controller Now snapshot can be done when rebuild is in process. So there will be race condition if snapshot and rebuild happenes at the same time. The final check to verify the successful of synchronization need to have a lock hold now, which can only done by controller. --- controller/client/controller_client.go | 14 +++++ controller/control.go | 80 ++++++++++++++++++++++++++ controller/rest/model.go | 9 ++- controller/rest/replica.go | 15 +++++ controller/rest/router.go | 1 + sync/sync.go | 40 +++---------- 6 files changed, 123 insertions(+), 36 deletions(-) diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index a2603338..6b1676c2 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -138,6 +138,20 @@ func (c *ControllerClient) UpdateReplica(replica rest.Replica) (rest.Replica, er return resp, err } +func (c *ControllerClient) GetReplica(address string) (*rest.Replica, error) { + resp := &rest.Replica{} + err := c.get("/replicas/"+address, &resp) + return resp, err +} + +func (c *ControllerClient) CheckReplica(address string) error { + replica, err := c.GetReplica(address) + if err != nil { + return err + } + return c.post(replica.Actions["check"], &replica, nil) +} + func (c *ControllerClient) GetVolume() (*rest.Volume, error) { var volumes rest.VolumeCollection diff --git a/controller/control.go b/controller/control.go index 77669918..19dc6312 100644 --- a/controller/control.go +++ b/controller/control.go @@ -2,9 +2,11 @@ package controller import ( "fmt" + "reflect" "sync" "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/replica/client" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" ) @@ -157,6 +159,84 @@ func (c *Controller) ListReplicas() []types.Replica { return c.replicas } +func getReplicaChain(address string) ([]string, error) { + repClient, err := client.NewReplicaClient(address) + if err != nil { + return nil, fmt.Errorf("Cannot get replica client for %v: %v", + address, err) + } + + rep, err := repClient.GetReplica() + if err != nil { + return nil, fmt.Errorf("Cannot get replica for %v: %v", + address, err) + } + return rep.Chain, nil +} + +func (c *Controller) getCurrentAndRWReplica(address string) (*types.Replica, *types.Replica, error) { + var ( + current, rwReplica *types.Replica + ) + + for i := range c.replicas { + if c.replicas[i].Address == address { + current = &c.replicas[i] + } else if c.replicas[i].Mode == types.RW { + rwReplica = &c.replicas[i] + } + } + if current == nil { + return nil, nil, fmt.Errorf("Cannot find replica %v", address) + } + if rwReplica == nil { + return nil, nil, fmt.Errorf("Cannot find any healthy replica") + } + + return current, rwReplica, nil +} + +func (c *Controller) CheckReplica(address string) error { + // Prevent snapshot happenes at the same time, well at least no + // controller involved + c.Lock() + defer c.Unlock() + + replica, rwReplica, err := c.getCurrentAndRWReplica(address) + if err != nil { + return err + } + + if replica.Mode == types.RW { + return nil + } + if replica.Mode != types.WO { + return fmt.Errorf("Invalid mode %v for replica %v to check", replica.Mode, address) + } + + rwChain, err := getReplicaChain(rwReplica.Address) + if err != nil { + return err + } + // Don't need to compare the volume head disk + rwChain = rwChain[1:] + + chain, err := getReplicaChain(address) + if err != nil { + return err + } + chain = chain[1:] + + if !reflect.DeepEqual(rwChain, chain) { + return fmt.Errorf("Replica %v's chain not equal to RW replica %v's chain", + address, rwReplica.Address) + } + + logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) + c.setReplicaModeNoLock(address, types.RW) + return nil +} + func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { switch mode { case types.ERR: diff --git a/controller/rest/model.go b/controller/rest/model.go index 6b38d7a2..6207c024 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -77,14 +77,17 @@ func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { } func NewReplica(context *api.ApiContext, address string, mode types.Mode) *Replica { - return &Replica{ + r := &Replica{ Resource: client.Resource{ - Id: EncodeID(address), - Type: "replica", + Id: EncodeID(address), + Type: "replica", + Actions: map[string]string{}, }, Address: address, Mode: string(mode), } + r.Actions["check"] = context.UrlBuilder.ActionLink(r.Resource, "check") + return r } func DencodeID(id string) (string, error) { diff --git a/controller/rest/replica.go b/controller/rest/replica.go index 2ab6638c..8e7aaf37 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -91,3 +91,18 @@ func (s *Server) UpdateReplica(rw http.ResponseWriter, req *http.Request) error return s.GetReplica(rw, req) } + +func (s *Server) CheckReplica(rw http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + id, err := DencodeID(vars["id"]) + if err != nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + if err := s.c.CheckReplica(id); err != nil { + return err + } + + return s.GetReplica(rw, req) +} diff --git a/controller/rest/router.go b/controller/rest/router.go index 69a6e784..96e4933d 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -29,6 +29,7 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) router.Methods("POST").Path("/v1/replicas").Handler(f(schemas, s.CreateReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "check").Handler(f(schemas, s.CheckReplica)) router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) router.Methods("PUT").Path("/v1/replicas/{id}").Handler(f(schemas, s.UpdateReplica)) diff --git a/sync/sync.go b/sync/sync.go index 72afcab8..72fdbda0 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -2,7 +2,6 @@ package sync import ( "fmt" - "reflect" "strings" "github.com/Sirupsen/logrus" @@ -190,11 +189,11 @@ func (t *Task) AddReplica(replica string) error { return err } - if err := t.reloadAndCheck(fromClient, toClient); err != nil { + if err := t.reloadAndCheck(replica, toClient); err != nil { return err } - return t.setRw(replica) + return nil } func (t *Task) checkAndResetFailedRebuild(address string) error { @@ -223,45 +222,20 @@ func (t *Task) checkAndResetFailedRebuild(address string) error { return nil } -func (t *Task) setRw(replica string) error { - to, err := t.getToReplica(replica) +func (t *Task) reloadAndCheck(address string, repClient *replicaClient.ReplicaClient) error { + _, err := repClient.ReloadReplica() if err != nil { return err } - to.Mode = "RW" - - to, err = t.client.UpdateReplica(to) - if err != nil { + if err := t.client.CheckReplica(rest.EncodeID(address)); err != nil { return err } - if to.Mode != "RW" { - return fmt.Errorf("Failed to set replica to RW, in mode %s", to.Mode) - } - - return nil -} - -func (t *Task) reloadAndCheck(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { - from, err := fromClient.GetReplica() - if err != nil { + if err := repClient.SetRebuilding(false); err != nil { return err } - - to, err := toClient.ReloadReplica() - if err != nil { - return err - } - - fromChain := from.Chain[1:] - toChain := to.Chain[1:] - - if !reflect.DeepEqual(fromChain, toChain) { - return fmt.Errorf("Chains are not equal: %v != %v", fromChain, toChain) - } - - return toClient.SetRebuilding(false) + return nil } func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { From 685efea5e0412805f649f0880b0223e0718e6ab8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 30 Dec 2016 15:20:03 -0800 Subject: [PATCH 250/357] controller: Introduce prepare_rebuild method in controller When we allow snapshot happens, it can racy against the rebuild process. prepare_rebuild call will provides a list to caller of which files need to be sync, while holding the lock to prevent snapshot happens in the period. --- controller/client/controller_client.go | 10 ++++++++++ controller/control.go | 20 ++++++++++++++++++++ controller/rest/model.go | 17 +++++++++++++++++ controller/rest/replica.go | 26 ++++++++++++++++++++++++++ controller/rest/router.go | 1 + sync/sync.go | 13 +++++++++---- 6 files changed, 83 insertions(+), 4 deletions(-) diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 6b1676c2..85117663 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -152,6 +152,16 @@ func (c *ControllerClient) CheckReplica(address string) error { return c.post(replica.Actions["check"], &replica, nil) } +func (c *ControllerClient) PrepareRebuild(address string) (*rest.PrepareRebuildOutput, error) { + var output rest.PrepareRebuildOutput + replica, err := c.GetReplica(address) + if err != nil { + return nil, err + } + err = c.post(replica.Actions["preparerebuild"], &replica, &output) + return &output, err +} + func (c *ControllerClient) GetVolume() (*rest.Volume, error) { var volumes rest.VolumeCollection diff --git a/controller/control.go b/controller/control.go index 19dc6312..445d5bc8 100644 --- a/controller/control.go +++ b/controller/control.go @@ -237,6 +237,26 @@ func (c *Controller) CheckReplica(address string) error { return nil } +func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { + c.Lock() + defer c.Unlock() + + replica, rwReplica, err := c.getCurrentAndRWReplica(address) + if err != nil { + return nil, err + } + if replica.Mode != types.WO { + return nil, fmt.Errorf("Invalid mode %v for replica %v to prepare rebuild", replica.Mode, address) + } + + rwChain, err := getReplicaChain(rwReplica.Address) + if err != nil { + return nil, err + } + + return rwChain[1:], nil +} + func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { switch mode { case types.ERR: diff --git a/controller/rest/model.go b/controller/rest/model.go index 6207c024..709e4b2c 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -31,6 +31,11 @@ type ReplicaCollection struct { Data []Replica `json:"data"` } +type DiskCollection struct { + client.Collection + Data []string `json:"data"` +} + type StartInput struct { client.Resource Replicas []string `json:"replicas"` @@ -55,6 +60,11 @@ type JournalInput struct { Limit int `json:"limit"` } +type PrepareRebuildOutput struct { + client.Resource + Disks []string `json:"disks"` +} + func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { v := &Volume{ Resource: client.Resource{ @@ -87,6 +97,7 @@ func NewReplica(context *api.ApiContext, address string, mode types.Mode) *Repli Mode: string(mode), } r.Actions["check"] = context.UrlBuilder.ActionLink(r.Resource, "check") + r.Actions["preparerebuild"] = context.UrlBuilder.ActionLink(r.Resource, "preparerebuild") return r } @@ -113,10 +124,16 @@ func NewSchema() *client.Schemas { schemas.AddType("snapshotInput", SnapshotInput{}) schemas.AddType("revertInput", RevertInput{}) schemas.AddType("journalInput", JournalInput{}) + schemas.AddType("prepareRebuildOutput", PrepareRebuildOutput{}) replica := schemas.AddType("replica", Replica{}) replica.CollectionMethods = []string{"GET", "POST"} replica.ResourceMethods = []string{"GET", "PUT"} + replica.ResourceActions = map[string]client.Action{ + "preparerebuild": { + Output: "prepareRebuildOutput", + }, + } f := replica.ResourceFields["address"] f.Create = true diff --git a/controller/rest/replica.go b/controller/rest/replica.go index 8e7aaf37..bd3b067b 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -106,3 +106,29 @@ func (s *Server) CheckReplica(rw http.ResponseWriter, req *http.Request) error { return s.GetReplica(rw, req) } + +func (s *Server) PrepareRebuildReplica(rw http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + id, err := DencodeID(vars["id"]) + if err != nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + disks, err := s.c.PrepareRebuildReplica(id) + if err != nil { + return err + } + + apiContext := api.GetApiContext(req) + resp := &PrepareRebuildOutput{ + Resource: client.Resource{ + Id: id, + Type: "prepareRebuildOutput", + }, + Disks: disks, + } + + apiContext.Write(&resp) + return nil +} diff --git a/controller/rest/router.go b/controller/rest/router.go index 96e4933d..15b81e7d 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -30,6 +30,7 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) router.Methods("POST").Path("/v1/replicas").Handler(f(schemas, s.CreateReplica)) router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "check").Handler(f(schemas, s.CheckReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "preparerebuild").Handler(f(schemas, s.PrepareRebuildReplica)) router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) router.Methods("PUT").Path("/v1/replicas/{id}").Handler(f(schemas, s.UpdateReplica)) diff --git a/sync/sync.go b/sync/sync.go index 72fdbda0..1d30d097 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -185,7 +185,12 @@ func (t *Task) AddReplica(replica string) error { return err } - if err = t.syncFiles(fromClient, toClient); err != nil { + output, err := t.client.PrepareRebuild(rest.EncodeID(replica)) + if err != nil { + return err + } + + if err = t.syncFiles(fromClient, toClient, output.Disks); err != nil { return err } @@ -238,7 +243,7 @@ func (t *Task) reloadAndCheck(address string, repClient *replicaClient.ReplicaCl return nil } -func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { +func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient, disks []string) error { from, err := fromClient.GetReplica() if err != nil { return err @@ -270,9 +275,9 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl } } - for _, disk := range from.Disks { + for _, disk := range disks { if strings.Contains(disk, "volume-head") { - continue + return fmt.Errorf("Disk list shouldn't contain volume-head") } if err := t.syncFile(disk, "", fromClient, toClient); err != nil { return err From 92c0b6ead6bfdea1fe3530064f103ca38d0e8619 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 30 Dec 2016 17:38:09 -0800 Subject: [PATCH 251/357] controller: Allow controller to sync disk head when prepare_rebuild Disk head file is tricky when we allow taking snapshot during rebuild process. It can be used as the parent of next snapshot, but still pointed to "" as it's own parent. We need to sync it holding the lock to avoid racy between rebuild and snapshot --- controller/control.go | 45 +++++++++++++++++++++++++++ sync/sync.go | 72 ++----------------------------------------- 2 files changed, 47 insertions(+), 70 deletions(-) diff --git a/controller/control.go b/controller/control.go index 445d5bc8..b071324c 100644 --- a/controller/control.go +++ b/controller/control.go @@ -237,6 +237,39 @@ func (c *Controller) CheckReplica(address string) error { return nil } +func syncFile(from, to string, fromReplica, toReplica *types.Replica) error { + if to == "" { + to = from + } + + fromClient, err := client.NewReplicaClient(fromReplica.Address) + if err != nil { + return fmt.Errorf("Cannot get replica client for %v: %v", + fromReplica.Address, err) + } + + toClient, err := client.NewReplicaClient(toReplica.Address) + if err != nil { + return fmt.Errorf("Cannot get replica client for %v: %v", + toReplica.Address, err) + } + + host, port, err := toClient.LaunchReceiver(to) + if err != nil { + return err + } + + logrus.Infof("Synchronizing %s to %s@%s:%d", from, to, host, port) + err = fromClient.SendFile(from, host, port) + if err != nil { + logrus.Infof("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err) + } else { + logrus.Infof("Done synchronizing %s to %s@%s:%d", from, to, host, port) + } + + return err +} + func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { c.Lock() defer c.Unlock() @@ -254,6 +287,18 @@ func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { return nil, err } + fromHead := rwChain[0] + + chain, err := getReplicaChain(address) + if err != nil { + return nil, err + } + toHead := chain[0] + + if err := syncFile(fromHead+".meta", toHead+".meta", rwReplica, replica); err != nil { + return nil, err + } + return rwChain[1:], nil } diff --git a/sync/sync.go b/sync/sync.go index 1d30d097..bed34c4d 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -244,37 +244,11 @@ func (t *Task) reloadAndCheck(address string, repClient *replicaClient.ReplicaCl } func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient, disks []string) error { - from, err := fromClient.GetReplica() - if err != nil { - return err - } - if err := toClient.SetRebuilding(true); err != nil { return err } - to, err := toClient.GetReplica() - if err != nil { - return err - } - - fromHead := "" - toHead := "" - - // Find the head from chain, since there is a gap between create the new - // head and remove the old head, which means there can be two heads in - // the same replica for a brief moment. Better check the chain for who's - // current head. - for _, disk := range from.Chain { - if strings.Contains(disk, "volume-head") { - if fromHead != "" { - return fmt.Errorf("More than one head volume found in the from replica %s, %s", fromHead, disk) - } - fromHead = disk - continue - } - } - + // volume head has been synced by PrepareRebuild() for _, disk := range disks { if strings.Contains(disk, "volume-head") { return fmt.Errorf("Disk list shouldn't contain volume-head") @@ -288,49 +262,7 @@ func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *repl } } - for _, i := range to.Chain { - if strings.Contains(i, "volume-head") { - if toHead != "" { - return fmt.Errorf("More than one head volume found in the to replica %s, %s", toHead, i) - } - toHead = i - continue - } - } - - if fromHead == "" || toHead == "" { - return fmt.Errorf("Failed to find both source and destination head volumes, %s, %s", fromHead, toHead) - } - - for i := 0; i < RetryCounts; i++ { - err = t.syncFile(fromHead+".meta", toHead+".meta", fromClient, toClient) - if err == nil { - break - } - - logrus.Warnf("Retry sync volume head since may caused by snapshot in progress: %v", - fromHead, toHead, err) - - from, ferr := fromClient.GetReplica() - if ferr != nil { - return ferr - } - - fromHead = "" - for _, disk := range from.Chain { - if strings.Contains(disk, "volume-head") { - if fromHead != "" { - return fmt.Errorf("More than one head volume found in the from replica %s, %s", - fromHead, disk) - } - fromHead = disk - continue - } - } - logrus.Warnf("Sync current volume head %s to %s", fromHead, toHead) - } - - return err + return nil } func (t *Task) syncFile(from, to string, fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient) error { From 409d2a189f468fe80fa88011c1e6b88ef4fe206c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 5 Jan 2017 10:06:26 -0800 Subject: [PATCH 252/357] Revert "util: No longer create block dev node, use symbolic link instead" This reverts commit 2f61099282a832542fe8ebbb188f0a26930219e7. We need block device node in order to show correct device in the mount table. Besides, even after this #233 still happens, so it's likely an isciadm issue. --- util/util.go | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/util/util.go b/util/util.go index 8deee3de..98834778 100644 --- a/util/util.go +++ b/util/util.go @@ -7,9 +7,12 @@ import ( "os" "regexp" "strconv" + "time" + "github.com/Sirupsen/logrus" "github.com/gorilla/handlers" "github.com/satori/go.uuid" + "golang.org/x/sys/unix" ) var ( @@ -79,22 +82,51 @@ func (h filteredLoggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque } func DuplicateDevice(src, dest string) error { - if st, err := os.Stat(src); err != nil { + stat := unix.Stat_t{} + if err := unix.Stat(src, &stat); err != nil { return fmt.Errorf("Cannot duplicate device because cannot find %s: %v", src, err) - } else if st.Mode()&os.ModeDevice == 0 { - return fmt.Errorf("Device %s is not a block device", src) } - if err := os.Symlink(src, dest); err != nil { - return fmt.Errorf("Cannot duplicate device %s to %s: %v", src, dest, err) + major := int(stat.Rdev / 256) + minor := int(stat.Rdev % 256) + if err := mknod(dest, major, minor); err != nil { + return fmt.Errorf("Cannot duplicate device %s to %s", src, dest) } return nil } +func mknod(device string, major, minor int) error { + var fileMode os.FileMode = 0600 + fileMode |= unix.S_IFBLK + dev := int((major << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)) + + logrus.Infof("Creating device %s %d:%d", device, major, minor) + return unix.Mknod(device, uint32(fileMode), dev) +} + func RemoveDevice(dev string) error { if _, err := os.Stat(dev); err == nil { - if err := os.Remove(dev); err != nil { + if err := remove(dev); err != nil { return fmt.Errorf("Failed to removing device %s, %v", dev, err) } } return nil } + +func removeAsync(path string, done chan<- error) { + if err := os.Remove(path); err != nil && !os.IsNotExist(err) { + logrus.Errorf("Unable to remove: %v", path) + done <- err + } + done <- nil +} + +func remove(path string) error { + done := make(chan error) + go removeAsync(path, done) + select { + case err := <-done: + return err + case <-time.After(30 * time.Second): + return fmt.Errorf("timeout trying to delete %s", path) + } +} From a16920c12ca5753682f43210f12e06dc1bc25acc Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Fri, 13 Jan 2017 11:12:18 -0800 Subject: [PATCH 253/357] copy binaries to /usr/local/bin and make it a volume in the image --- package/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/Dockerfile b/package/Dockerfile index c119b732..3a0ced22 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -3,7 +3,8 @@ RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.co apt-get update && apt-get install -y kmod curl nfs-common fuse \ libibverbs1 librdmacm1 libconfig-general-perl libaio1 -COPY longhorn launch copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/bin/ +COPY longhorn launch copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/local/bin/ COPY tgt_*.deb /opt/ RUN dpkg -i /opt/tgt_*.deb +VOLUME /usr/local/bin CMD ["longhorn"] From a22fa89eaa47de70ad4563f45293d31c64139aa7 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Tue, 17 Jan 2017 09:53:16 -0800 Subject: [PATCH 254/357] rm unnecessary go-rancher-metadata dependency --- vendor.conf | 1 - .../rancher/go-rancher-metadata/.gitignore | 1 - .../rancher/go-rancher-metadata/README.md | 40 ---- .../go-rancher-metadata/metadata/change.go | 27 --- .../go-rancher-metadata/metadata/metadata.go | 194 ------------------ .../go-rancher-metadata/metadata/types.go | 49 ----- .../go-rancher-metadata/metadata/utils.go | 19 -- 7 files changed, 331 deletions(-) delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/.gitignore delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/README.md delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/change.go delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/types.go delete mode 100644 vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go diff --git a/vendor.conf b/vendor.conf index dfed6772..c9d365af 100644 --- a/vendor.conf +++ b/vendor.conf @@ -13,7 +13,6 @@ github.com/docker/docker v1.11.1 github.com/codegangsta/cli 71f57d300dd6a780ac1856c005c4b518cfd498ec github.com/satori/go.uuid f9ab0dce87d815821e221626b772e3475a0d2749 github.com/rancher/sparse-tools df7d04b769d34b52878e9e60ba22dabf7dc8b7ca -github.com/rancher/go-rancher-metadata 721b783c9983a17ec0d63d5530337610de9519ec github.com/rancher/convoy 9e0fd9a3a77dc4b8ee7eab859a420b7764729271 github.com/mcuadros/go-version d52711f8d6bea8dc01efafdb68ad95a4e2606630 golang.org/x/sys 62bee037599929a6e9146f29d10dd5208c43507d diff --git a/vendor/github.com/rancher/go-rancher-metadata/.gitignore b/vendor/github.com/rancher/go-rancher-metadata/.gitignore deleted file mode 100644 index 11c2ad0c..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/.gitignore +++ /dev/null @@ -1 +0,0 @@ -go-rancher-metadata diff --git a/vendor/github.com/rancher/go-rancher-metadata/README.md b/vendor/github.com/rancher/go-rancher-metadata/README.md deleted file mode 100644 index 9ac7dede..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Go bindings for Rancher-metadata - -This library is incomplete, but implements a variety of calls against [rancher-metadata](https://github.com/rancher/rancher-metadata) service - -#Example usage - -```go -package main - -import ( - "time" - - "github.com/Sirupsen/logrus" - "github.com/rancher/go-rancher-metadata/metadata" -) - -const ( - metadataUrl = "http://rancher-metadata/2015-12-19" -) - -func main() { - - m := metadata.NewClient(metadataUrl) - - version := "init" - - for { - newVersion, err := m.GetVersion() - if err != nil { - logrus.Errorf("Error reading metadata version: %v", err) - } else if version == newVersion { - logrus.Debug("No changes in metadata version") - } else { - logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) - version = newVersion - } - time.Sleep(5 * time.Second) - } -} -``` diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/change.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/change.go deleted file mode 100644 index 80ca02cd..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/metadata/change.go +++ /dev/null @@ -1,27 +0,0 @@ -package metadata - -import ( - "time" - - "github.com/Sirupsen/logrus" -) - -func (m *Client) OnChange(intervalSeconds int, do func(string)) { - interval := time.Duration(intervalSeconds) - version := "init" - - for { - newVersion, err := m.GetVersion() - if err != nil { - logrus.Errorf("Error reading metadata version: %v", err) - time.Sleep(interval * time.Second) - } else if version == newVersion { - logrus.Debug("No changes in metadata version") - time.Sleep(interval * time.Second) - } else { - logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) - version = newVersion - do(newVersion) - } - } -} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go deleted file mode 100644 index 74e8e4d8..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/metadata/metadata.go +++ /dev/null @@ -1,194 +0,0 @@ -package metadata - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "net/http" -) - -type Client struct { - url string -} - -func NewClient(url string) *Client { - return &Client{url} -} - -func NewClientAndWait(url string) (*Client, error) { - client := &Client{url} - - if err := testConnection(client); err != nil { - return nil, err - } - - return client, nil -} - -func (m *Client) SendRequest(path string) ([]byte, error) { - client := &http.Client{} - req, err := http.NewRequest("GET", m.url+path, nil) - req.Header.Add("Accept", "application/json") - resp, err := client.Do(req) - if err != nil { - return nil, err - } - - if resp.StatusCode != 200 { - return nil, fmt.Errorf("Error %v accessing %v path", resp.StatusCode, path) - } - - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - return body, nil -} - -func (m *Client) GetVersion() (string, error) { - resp, err := m.SendRequest("/version") - if err != nil { - return "", err - } - return string(resp[:]), nil -} - -func (m *Client) GetSelfContainer() (Container, error) { - resp, err := m.SendRequest("/self/container") - var container Container - if err != nil { - return container, err - } - - if err = json.Unmarshal(resp, &container); err != nil { - return container, err - } - - return container, nil -} - -func (m *Client) GetSelfServiceByName(name string) (Service, error) { - resp, err := m.SendRequest("/self/stack/services/" + name) - var service Service - if err != nil { - return service, err - } - - if err = json.Unmarshal(resp, &service); err != nil { - return service, err - } - - return service, nil -} - -func (m *Client) GetSelfService() (Service, error) { - resp, err := m.SendRequest("/self/service") - var service Service - if err != nil { - return service, err - } - - if err = json.Unmarshal(resp, &service); err != nil { - return service, err - } - - return service, nil -} - -func (m *Client) GetSelfStack() (Stack, error) { - resp, err := m.SendRequest("/self/stack") - var stack Stack - if err != nil { - return stack, err - } - - if err = json.Unmarshal(resp, &stack); err != nil { - return stack, err - } - - return stack, nil -} - -func (m *Client) GetServices() ([]Service, error) { - resp, err := m.SendRequest("/services") - var services []Service - if err != nil { - return services, err - } - - if err = json.Unmarshal(resp, &services); err != nil { - return services, err - } - return services, nil -} - -func (m *Client) GetStacks() ([]Stack, error) { - resp, err := m.SendRequest("/stacks") - var stacks []Stack - if err != nil { - return stacks, err - } - - if err = json.Unmarshal(resp, &stacks); err != nil { - return stacks, err - } - return stacks, nil -} - -func (m *Client) GetContainers() ([]Container, error) { - resp, err := m.SendRequest("/containers") - var containers []Container - if err != nil { - return containers, err - } - - if err = json.Unmarshal(resp, &containers); err != nil { - return containers, err - } - return containers, nil -} - -func (m *Client) GetServiceContainers(serviceName string, stackName string) ([]Container, error) { - var serviceContainers = []Container{} - containers, err := m.GetContainers() - if err != nil { - return serviceContainers, err - } - - for _, container := range containers { - if container.StackName == stackName && container.ServiceName == serviceName { - serviceContainers = append(serviceContainers, container) - } - } - - return serviceContainers, nil -} - -func (m *Client) GetHosts() ([]Host, error) { - resp, err := m.SendRequest("/hosts") - var hosts []Host - if err != nil { - return hosts, err - } - - if err = json.Unmarshal(resp, &hosts); err != nil { - return hosts, err - } - return hosts, nil -} - -func (m *Client) GetHost(UUID string) (Host, error) { - var host Host - hosts, err := m.GetHosts() - if err != nil { - return host, err - } - for _, host := range hosts { - if host.UUID == UUID { - return host, nil - } - } - - return host, fmt.Errorf("could not find host by UUID %v", UUID) -} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/types.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/types.go deleted file mode 100644 index 2a1efc48..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/metadata/types.go +++ /dev/null @@ -1,49 +0,0 @@ -package metadata - -type Stack struct { - EnvironmentName string `json:"environment_name"` - Name string `json:"name"` - Services []Service `json:"services"` -} - -type Service struct { - Scale int `json:"scale"` - Name string `json:"name"` - StackName string `json:"stack_name"` - Kind string `json:"kind"` - Hostname string `json:"hostname"` - Vip string `json:"vip"` - CreateIndex int `json:"create_index"` - UUID string `json:"uuid"` - ExternalIps []string `json:"external_ips"` - Sidekicks []string `json:"sidekicks"` - Containers []Container `json:"containers"` - Ports []string `json:"ports"` - Labels map[string]string `json:"labels"` - Links map[string]string `json:"links"` - Metadata map[string]interface{} `json:"metadata"` - Token string `json:"token"` -} - -type Container struct { - Name string `json:"name"` - PrimaryIp string `json:"primary_ip"` - Ips []string `json:"ips"` - Ports []string `json:"ports"` - ServiceName string `json:"service_name"` - StackName string `json:"stack_name"` - Labels map[string]string `json:"labels"` - CreateIndex int `json:"create_index"` - HostUUID string `json:"host_uuid"` - UUID string `json:"uuid"` - HealthState string `json:"health_state"` -} - -type Host struct { - Name string `json:"name"` - AgentIP string `json:"agent_ip"` - HostId int `json:"host_id"` - Labels map[string]string `json:"labels"` - UUID string `json:"uuid"` - Hostname string `json:"hostname"` -} diff --git a/vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go b/vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go deleted file mode 100644 index d8048d0f..00000000 --- a/vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go +++ /dev/null @@ -1,19 +0,0 @@ -package metadata - -import ( - "time" -) - -func testConnection(mdClient *Client) error { - var err error - maxTime := 20 * time.Second - - for i := 1 * time.Second; i < maxTime; i *= time.Duration(2) { - if _, err = mdClient.GetVersion(); err != nil { - time.Sleep(i) - } else { - return nil - } - } - return err -} From e0e4e7e4c6e9642462709d013dea47551f60cf94 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 19 Jan 2017 17:30:17 -0800 Subject: [PATCH 255/357] Allow volume with underscore in name We need to additional handling in tgt frontend in order to swap `_` with `:`, because `_` isn't allowed in the iSCSI name. Also update test cases to include all valid name. As well as add check for volume name and limit the length of volume name to 64 bytes. Fixes #270 --- app/controller.go | 8 ++++++-- frontend/tgt/scsi.go | 3 ++- integration/core/test_cli.py | 8 +++++--- integration/data/common.py | 2 +- integration/data/test_backup.py | 2 +- scripts/integration-test | 2 +- util/util.go | 16 +++++++++++++++- 7 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/controller.go b/app/controller.go index c6305982..c01d6eaf 100644 --- a/app/controller.go +++ b/app/controller.go @@ -57,6 +57,10 @@ func startController(c *cli.Context) error { } name := c.Args()[0] + if !util.ValidVolumeName(name) { + return errors.New("invalid target name") + } + listen := c.String("listen") backends := c.StringSlice("enable-backend") replicas := c.StringSlice("replica") @@ -88,8 +92,8 @@ func startController(c *cli.Context) error { router := http.Handler(rest.NewRouter(server)) router = util.FilteredLoggingHandler(map[string]struct{}{ - "/v1/volumes": struct{}{}, - "/v1/replicas": struct{}{}, + "/v1/volumes": {}, + "/v1/replicas": {}, }, os.Stdout, router) router = handlers.ProxyHeaders(router) diff --git a/frontend/tgt/scsi.go b/frontend/tgt/scsi.go index a28fc697..e9cd85e6 100644 --- a/frontend/tgt/scsi.go +++ b/frontend/tgt/scsi.go @@ -7,6 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/util" "github.com/yasker/go-iscsi-helper/iscsi" iutil "github.com/yasker/go-iscsi-helper/util" "github.com/yasker/nsfilelock" @@ -43,7 +44,7 @@ func NewScsiDevice(name, backingFile, bsType, bsOpts string) (*ScsiDevice, error } func GetTargetName(name string) string { - return "iqn.2014-09.com.rancher:" + name + return "iqn.2014-09.com.rancher:" + util.Volume2ISCSIName(name) } func GetLocalIP() (string, error) { diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 1c737f6a..cf0e7ec2 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -14,7 +14,7 @@ BACKUP_DEST = '/tmp/longhorn-backup' -VOLUME_NAME = 'test-volume' +VOLUME_NAME = 'test-volume_1.0' VOLUME_SIZE = str(4 * 1024 * 1024) # 4M @@ -461,7 +461,8 @@ def test_backup_core(bin, controller_client, replica_client, assert backup2_info["SnapshotName"] == snapshot2 cmd = [bin, 'backup', 'inspect', - "vfs:///tmp/longhorn-backup?backup=backup-1234&volume=test-volume"] + "vfs:///tmp/longhorn-backup?backup=backup-1234" + + "&volume=test-volume_1.0"] with pytest.raises(subprocess.CalledProcessError) as e: subprocess.check_call(cmd) assert 'cannot find' in str(e.value) @@ -480,7 +481,8 @@ def test_backup_core(bin, controller_client, replica_client, assert os.path.exists(BACKUP_DEST) cmd = [bin, 'backup', 'inspect', - "vfs:///tmp/longhorn-backup?backup=backup-1234&volume=test-volume"] + "vfs:///tmp/longhorn-backup?backup=backup-1234" + + "&volume=test-volume_1.0"] with pytest.raises(subprocess.CalledProcessError) as e: subprocess.check_call(cmd) assert 'cannot find' in str(e.value) diff --git a/integration/data/common.py b/integration/data/common.py index e22c63dd..8a8d06ac 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -31,7 +31,7 @@ BACKING_FILE = 'backing_file.raw' -VOLUME_NAME = 'test-volume' +VOLUME_NAME = 'test-volume_1.0' def _file(f): diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index f94dc87b..481d25c8 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -7,7 +7,7 @@ from common import dev, backing_dev # NOQA from common import read_dev, read_from_backing_file, BACKUP_DEST -VOLUME_NAME = 'test-volume' +VOLUME_NAME = 'test-volume_1.0' VOLUME_SIZE = str(4 * 1024 * 1024) # 4M diff --git a/scripts/integration-test b/scripts/integration-test index 3a78753a..da687fc2 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -41,7 +41,7 @@ then mount --rbind /host/dev /dev fi -./bin/longhorn controller --frontend tgt --enable-backend file test-volume & +./bin/longhorn controller --frontend tgt --enable-backend file test-volume_1.0 & controller_pid=$! ./bin/longhorn replica $temp & replica1_pid=$! diff --git a/util/util.go b/util/util.go index 98834778..b3321442 100644 --- a/util/util.go +++ b/util/util.go @@ -7,6 +7,7 @@ import ( "os" "regexp" "strconv" + "strings" "time" "github.com/Sirupsen/logrus" @@ -16,7 +17,8 @@ import ( ) var ( - parsePattern = regexp.MustCompile(`(.*):(\d+)`) + MaximumVolumeNameSize = 64 + parsePattern = regexp.MustCompile(`(.*):(\d+)`) ) func ParseAddresses(name string) (string, string, string, error) { @@ -130,3 +132,15 @@ func remove(path string) error { return fmt.Errorf("timeout trying to delete %s", path) } } + +func ValidVolumeName(name string) bool { + if len(name) > MaximumVolumeNameSize { + return false + } + validName := regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`) + return validName.MatchString(name) +} + +func Volume2ISCSIName(name string) string { + return strings.Replace(name, "_", ":", -1) +} From 73576db46f47e7a1df717dff49947b6428f5d983 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Feb 2017 19:02:27 -0800 Subject: [PATCH 256/357] build: Remove the optimzation to speed up building from ubuntu mirrors Turns out using mirrors can result in inconsistent version of software sometime, which cause building failure. --- Dockerfile.dapper | 3 +-- package/Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 81fdf422..4a131079 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -15,8 +15,7 @@ ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} # Install packages -RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ - apt-get update && \ +RUN apt-get update && \ apt-get install -y cmake wget curl git less file \ libglib2.0-dev libkmod-dev libnl-genl-3-dev linux-libc-dev pkg-config psmisc python-tox qemu-utils fuse python-dev \ devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl \ diff --git a/package/Dockerfile b/package/Dockerfile index 3a0ced22..ab8dbc88 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,6 +1,5 @@ FROM ubuntu:16.04 -RUN sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list && \ - apt-get update && apt-get install -y kmod curl nfs-common fuse \ +RUN apt-get update && apt-get install -y kmod curl nfs-common fuse \ libibverbs1 librdmacm1 libconfig-general-perl libaio1 COPY longhorn launch copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/local/bin/ From f5b1b418e38b954ee69c687d60b16a3c09f5be82 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 25 Jan 2017 17:27:52 -0800 Subject: [PATCH 257/357] replica: Add revision counter field to replica It's a separate file in the replica directory. It will keep the revision (write) counter of the replica. The revision counter will increase by one everytime one write request is successfully processed. The revision counter file is 4k size and only use direct IO for accessing. --- replica/replica.go | 16 +++++- replica/revision_counter.go | 104 ++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 replica/revision_counter.go diff --git a/replica/replica.go b/replica/replica.go index 3d0c72b2..253e25b5 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -40,6 +40,10 @@ type Replica struct { diskChildrenMap map[string]map[string]bool activeDiskData []*disk readOnly bool + + revisionLock sync.Mutex + revisionCache int64 + revisionFile *sparse.DirectFileIoProcessor } type Info struct { @@ -121,6 +125,10 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF return nil, err } + if err := r.initRevisionCounter(); err != nil { + return nil, err + } + // Reference r.info.Size because it may have changed from reading // metadata locationSize := r.info.Size / r.volume.sectorSize @@ -783,7 +791,13 @@ func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { r.info.Dirty = true c, err := r.volume.WriteAt(buf, offset) r.RUnlock() - return c, err + if err != nil { + return c, err + } + if err := r.increaseRevisionCounter(); err != nil { + return c, err + } + return c, nil } func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { diff --git a/replica/revision_counter.go b/replica/revision_counter.go new file mode 100644 index 00000000..76927d84 --- /dev/null +++ b/replica/revision_counter.go @@ -0,0 +1,104 @@ +package replica + +import ( + "fmt" + "io" + "os" + "strconv" + "strings" + + "github.com/rancher/sparse-tools/sparse" +) + +const ( + revisionCacheFile = "revision.counter" + revisionFileMode os.FileMode = 0600 + revisionBlockSize = 4096 +) + +func (r *Replica) readRevisionCounter() (int64, error) { + buf := make([]byte, revisionBlockSize) + _, err := r.revisionFile.ReadAt(buf, 0) + if err != nil && err != io.EOF { + return 0, fmt.Errorf("fail to read from revision counter file: %v", err) + } + counter, err := strconv.ParseInt(strings.Trim(string(buf), "\x00"), 10, 64) + if err != nil { + return 0, fmt.Errorf("fail to parse revision counter file: %v", err) + } + return counter, nil +} + +func (r *Replica) writeRevisionCounter(counter int64) error { + buf := make([]byte, revisionBlockSize) + copy(buf, []byte(strconv.FormatInt(counter, 10))) + _, err := r.revisionFile.WriteAt(buf, 0) + if err != nil { + return fmt.Errorf("fail to write to revision counter file: %v", err) + } + return nil +} + +func (r *Replica) openRevisionFile(isCreate bool) error { + var err error + r.revisionFile, err = sparse.NewDirectFileIoProcessor(r.diskPath(revisionCacheFile), os.O_RDWR, revisionFileMode, isCreate) + return err +} + +func (r *Replica) initRevisionCounter() error { + r.revisionLock.Lock() + defer r.revisionLock.Unlock() + + if _, err := os.Stat(r.diskPath(revisionCacheFile)); err != nil { + if !os.IsNotExist(err) { + return err + } + // file doesn't exist yet + if err := r.openRevisionFile(true); err != nil { + return err + } + if err := r.writeRevisionCounter(0); err != nil { + return err + } + } else if err := r.openRevisionFile(false); err != nil { + return err + } + + counter, err := r.readRevisionCounter() + if err != nil { + return err + } + // Don't use r.revisionCache directly + // r.revisionCache is an internal cache, to avoid read from disk + // everytime when counter needs to be updated. + r.revisionCache = counter + return nil +} + +func (r *Replica) getRevisionCounter() (int64, error) { + r.revisionLock.Lock() + defer r.revisionLock.Unlock() + + counter, err := r.readRevisionCounter() + if err != nil { + return 0, err + } + r.revisionCache = counter + return counter, nil +} + +func (r *Replica) setRevisionCounter(counter int64) error { + r.revisionLock.Lock() + defer r.revisionLock.Unlock() + + if err := r.writeRevisionCounter(counter); err != nil { + return err + } + + r.revisionCache = counter + return nil +} + +func (r *Replica) increaseRevisionCounter() error { + return r.setRevisionCounter(r.revisionCache + 1) +} From 020e4cbc38ff80e41bac789b3808a73f061e58b4 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 31 Jan 2017 11:43:37 -0800 Subject: [PATCH 258/357] replica: Add RevisionCounter into REST API It will be a part of Replica object. SetRevisionCounter will be a separate call. --- replica/replica.go | 1 + replica/rest/model.go | 13 +++++++++++++ replica/rest/replica.go | 9 +++++++++ replica/rest/router.go | 19 ++++++++++--------- replica/revision_counter.go | 31 +++++++++++++++++++++---------- replica/server.go | 10 ++++++++++ 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 253e25b5..fd8c7c7e 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -765,6 +765,7 @@ func (r *Replica) Delete() error { } os.Remove(r.diskPath(volumeMetaData)) + os.Remove(r.diskPath(revisionCounterFile)) return nil } diff --git a/replica/rest/model.go b/replica/rest/model.go index 62c8b699..8a2f3e03 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -21,6 +21,7 @@ type Replica struct { Disks []string `json:"disks"` DiskChildrenMap map[string]map[string]bool `json:"diskchildrenmap"` RemainSnapshots int `json:"remainsnapshots"` + RevisionCounter int64 `json:"revisioncounter"` } type CreateInput struct { @@ -58,6 +59,11 @@ type PrepareRemoveDiskOutput struct { Operations []replica.PrepareRemoveAction `json:"operations"` } +type RevisionCounter struct { + client.Resource + Counter int64 `json:"counter"` +} + func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, rep *replica.Replica) *Replica { r := &Replica{ Resource: client.Resource{ @@ -82,6 +88,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["removedisk"] = true actions["revert"] = true actions["prepareremovedisk"] = true + actions["setrevisioncounter"] = true case replica.Closed: actions["open"] = true actions["removedisk"] = true @@ -100,6 +107,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["setrebuilding"] = true actions["close"] = true actions["reload"] = true + actions["setrevisioncounter"] = true case replica.Error: } @@ -119,6 +127,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, r.Disks = rep.ListDisks() r.DiskChildrenMap = rep.ShowDiskChildrenMap() r.RemainSnapshots = rep.GetRemainSnapshotCounts() + r.RevisionCounter = rep.GetRevisionCounter() } return r @@ -137,6 +146,7 @@ func NewSchema() *client.Schemas { schemas.AddType("revertInput", RevertInput{}) schemas.AddType("prepareRemoveDiskInput", PrepareRemoveDiskInput{}) schemas.AddType("prepareRemoveDiskOutput", PrepareRemoveDiskOutput{}) + schemas.AddType("revisionCounter", RevisionCounter{}) replica := schemas.AddType("replica", Replica{}) replica.ResourceMethods = []string{"GET", "DELETE"} @@ -174,6 +184,9 @@ func NewSchema() *client.Schemas { Input: "prepareRemoveDiskInput", Output: "prepareRemoveDiskOutput", }, + "setrevisioncounter": { + Input: "revisionCounter", + }, } return schemas diff --git a/replica/rest/replica.go b/replica/rest/replica.go index b514bc99..ba67714a 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -145,3 +145,12 @@ func (s *Server) CloseReplica(rw http.ResponseWriter, req *http.Request) error { func (s *Server) DeleteReplica(rw http.ResponseWriter, req *http.Request) error { return s.doOp(req, s.s.Delete()) } + +func (s *Server) SetRevisionCounter(rw http.ResponseWriter, req *http.Request) error { + var input RevisionCounter + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil && err != io.EOF { + return err + } + return s.doOp(req, s.s.SetRevisionCounter(input.Counter)) +} diff --git a/replica/rest/router.go b/replica/rest/router.go index 677587b4..94a9e826 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -50,15 +50,16 @@ func NewRouter(s *Server) *mux.Router { // Actions actions := map[string]func(http.ResponseWriter, *http.Request) error{ - "reload": s.ReloadReplica, - "snapshot": s.SnapshotReplica, - "open": s.OpenReplica, - "close": s.CloseReplica, - "removedisk": s.RemoveDisk, - "setrebuilding": s.SetRebuilding, - "create": s.Create, - "revert": s.RevertReplica, - "prepareremovedisk": s.PrepareRemoveDisk, + "reload": s.ReloadReplica, + "snapshot": s.SnapshotReplica, + "open": s.OpenReplica, + "close": s.CloseReplica, + "removedisk": s.RemoveDisk, + "setrebuilding": s.SetRebuilding, + "create": s.Create, + "revert": s.RevertReplica, + "prepareremovedisk": s.PrepareRemoveDisk, + "setrevisioncounter": s.SetRevisionCounter, } for name, action := range actions { diff --git a/replica/revision_counter.go b/replica/revision_counter.go index 76927d84..221630ea 100644 --- a/replica/revision_counter.go +++ b/replica/revision_counter.go @@ -7,16 +7,21 @@ import ( "strconv" "strings" + "github.com/Sirupsen/logrus" "github.com/rancher/sparse-tools/sparse" ) const ( - revisionCacheFile = "revision.counter" - revisionFileMode os.FileMode = 0600 - revisionBlockSize = 4096 + revisionCounterFile = "revision.counter" + revisionFileMode os.FileMode = 0600 + revisionBlockSize = 4096 ) func (r *Replica) readRevisionCounter() (int64, error) { + if r.revisionFile == nil { + return 0, fmt.Errorf("BUG: revision file wasn't initialized") + } + buf := make([]byte, revisionBlockSize) _, err := r.revisionFile.ReadAt(buf, 0) if err != nil && err != io.EOF { @@ -30,6 +35,10 @@ func (r *Replica) readRevisionCounter() (int64, error) { } func (r *Replica) writeRevisionCounter(counter int64) error { + if r.revisionFile == nil { + return fmt.Errorf("BUG: revision file wasn't initialized") + } + buf := make([]byte, revisionBlockSize) copy(buf, []byte(strconv.FormatInt(counter, 10))) _, err := r.revisionFile.WriteAt(buf, 0) @@ -41,7 +50,7 @@ func (r *Replica) writeRevisionCounter(counter int64) error { func (r *Replica) openRevisionFile(isCreate bool) error { var err error - r.revisionFile, err = sparse.NewDirectFileIoProcessor(r.diskPath(revisionCacheFile), os.O_RDWR, revisionFileMode, isCreate) + r.revisionFile, err = sparse.NewDirectFileIoProcessor(r.diskPath(revisionCounterFile), os.O_RDWR, revisionFileMode, isCreate) return err } @@ -49,7 +58,7 @@ func (r *Replica) initRevisionCounter() error { r.revisionLock.Lock() defer r.revisionLock.Unlock() - if _, err := os.Stat(r.diskPath(revisionCacheFile)); err != nil { + if _, err := os.Stat(r.diskPath(revisionCounterFile)); err != nil { if !os.IsNotExist(err) { return err } @@ -75,19 +84,21 @@ func (r *Replica) initRevisionCounter() error { return nil } -func (r *Replica) getRevisionCounter() (int64, error) { +func (r *Replica) GetRevisionCounter() int64 { r.revisionLock.Lock() defer r.revisionLock.Unlock() counter, err := r.readRevisionCounter() if err != nil { - return 0, err + logrus.Error("Fail to get revision counter: ", err) + // -1 will result in the replica to be discarded + return -1 } r.revisionCache = counter - return counter, nil + return counter } -func (r *Replica) setRevisionCounter(counter int64) error { +func (r *Replica) SetRevisionCounter(counter int64) error { r.revisionLock.Lock() defer r.revisionLock.Unlock() @@ -100,5 +111,5 @@ func (r *Replica) setRevisionCounter(counter int64) error { } func (r *Replica) increaseRevisionCounter() error { - return r.setRevisionCounter(r.revisionCache + 1) + return r.SetRevisionCounter(r.revisionCache + 1) } diff --git a/replica/server.go b/replica/server.go index 54e6b9fe..47364fe5 100644 --- a/replica/server.go +++ b/replica/server.go @@ -257,3 +257,13 @@ func (s *Server) ReadAt(buf []byte, offset int64) (int, error) { i, err := s.r.ReadAt(buf, offset) return i, err } + +func (s *Server) SetRevisionCounter(counter int64) error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + return s.r.SetRevisionCounter(counter) +} From e2847d2c5623533ade46489f5aa4b5f19aae8333 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 31 Jan 2017 12:02:35 -0800 Subject: [PATCH 259/357] controller: Update RevisionCounter for replicas For any new replica which is about to get rebuilt, the revision counter will be set as 0. It will be set to current revision when the rebuilding successes. --- backend/file/file.go | 8 ++++++++ backend/remote/remote.go | 36 ++++++++++++++++++++++++++++++++++++ controller/control.go | 10 ++++++++++ controller/replicator.go | 22 ++++++++++++++++++++++ types/types.go | 2 ++ 5 files changed, 78 insertions(+) diff --git a/backend/file/file.go b/backend/file/file.go index ad72783e..88a41ddb 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -43,6 +43,14 @@ func (f *Wrapper) RemainSnapshots() (int, error) { return 1, nil } +func (f *Wrapper) GetRevisionCounter() (int64, error) { + return 1, nil +} + +func (f *Wrapper) SetRevisionCounter(counter int64) error { + return nil +} + func (ff *Factory) Create(address string) (types.Backend, error) { logrus.Infof("Creating file: %s", address) file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE, 0600) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index e5acbba6..610a0e74 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -120,6 +120,42 @@ func (r *Remote) RemainSnapshots() (int, error) { return replica.RemainSnapshots, nil } +func (r *Remote) GetRevisionCounter() (int64, error) { + replica, err := r.info() + if err != nil { + return 0, err + } + if replica.State != "open" && replica.State != "dirty" { + return 0, fmt.Errorf("Invalid state %v for getting revision counter", replica.State) + } + return replica.RevisionCounter, nil +} + +func (r *Remote) SetRevisionCounter(counter int64) error { + body := &bytes.Buffer{} + if err := json.NewEncoder(body).Encode(&map[string]int64{"counter": counter}); err != nil { + return err + } + + req, err := http.NewRequest("POST", r.replicaURL+"?action=setrevisioncounter", body) + if err != nil { + return err + } + req.Header.Add("Content-Type", "application/json") + + resp, err := r.httpClient.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("Bad status: %d %s", resp.StatusCode, resp.Status) + } + + return nil +} + func (r *Remote) info() (rest.Replica, error) { var replica rest.Replica req, err := http.NewRequest("GET", r.replicaURL, nil) diff --git a/controller/control.go b/controller/control.go index b071324c..9f35ef18 100644 --- a/controller/control.go +++ b/controller/control.go @@ -232,6 +232,14 @@ func (c *Controller) CheckReplica(address string) error { address, rwReplica.Address) } + counter, err := c.backend.GetRevisionCounter(rwReplica.Address) + if err != nil || counter == -1 { + return fmt.Errorf("Failed to get revision counter of RW Replica %v: counter %v, err %v", + rwReplica.Address, counter, err) + + } + c.backend.SetRevisionCounter(address, counter) + logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) c.setReplicaModeNoLock(address, types.RW) return nil @@ -274,6 +282,8 @@ func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { c.Lock() defer c.Unlock() + c.backend.SetRevisionCounter(address, 0) + replica, rwReplica, err := c.getCurrentAndRWReplica(address) if err != nil { return nil, err diff --git a/controller/replicator.go b/controller/replicator.go index 2ae56a98..caec866d 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -254,3 +254,25 @@ func (r *replicator) RemainSnapshots() (int, error) { } return ret, nil } + +func (r *replicator) SetRevisionCounter(address string, counter int64) error { + backend, ok := r.backends[address] + if !ok { + return fmt.Errorf("Cannot find backend %v", address) + } + + logrus.Infof("Setting backend revision counter: %s", address) + + return backend.backend.SetRevisionCounter(counter) +} + +func (r *replicator) GetRevisionCounter(address string) (int64, error) { + backend, ok := r.backends[address] + if !ok { + return -1, fmt.Errorf("Cannot find backend %v", address) + } + + logrus.Infof("Getting backend revision counter: %s", address) + + return backend.backend.GetRevisionCounter() +} diff --git a/types/types.go b/types/types.go index 081eadf6..143e7ba9 100644 --- a/types/types.go +++ b/types/types.go @@ -29,6 +29,8 @@ type Backend interface { Size() (int64, error) SectorSize() (int64, error) RemainSnapshots() (int, error) + GetRevisionCounter() (int64, error) + SetRevisionCounter(counter int64) error } type BackendFactory interface { From bf2f3ebf60954d0f780a756c8a6b8c99035e45a4 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 31 Jan 2017 16:05:19 -0800 Subject: [PATCH 260/357] controller: Verify the revision counter of each replica added during start If replicas have different revision counters, only the ones with highest revision will be used. The others will be marked as ERR. It's used to rebuild a best-effect volume from potentially two failure replicas. --- controller/control.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/controller/control.go b/controller/control.go index 9f35ef18..7ff23191 100644 --- a/controller/control.go +++ b/controller/control.go @@ -351,6 +351,8 @@ func (c *Controller) startFrontend() error { } func (c *Controller) Start(addresses ...string) error { + var expectedRevision int64 + c.Lock() defer c.Unlock() @@ -396,9 +398,30 @@ func (c *Controller) Start(addresses ...string) error { if err := c.addReplicaNoLock(newBackend, address, false); err != nil { return err } + // We will validate this later c.setReplicaModeNoLock(address, types.RW) } + revisionCounters := make(map[string]int64) + for _, r := range c.replicas { + counter, err := c.backend.GetRevisionCounter(r.Address) + if err != nil { + return err + } + if counter > expectedRevision { + expectedRevision = counter + } + revisionCounters[r.Address] = counter + } + + for address, counter := range revisionCounters { + if counter != expectedRevision { + logrus.Errorf("Revision conflict detected! Expect %v, got %v in replica %v. Mark as ERR", + expectedRevision, counter, address) + c.setReplicaModeNoLock(address, types.ERR) + } + } + return nil } From 7e6354d0fc40344e61d31f5356fa0cd1d3371c96 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Feb 2017 10:38:11 -0800 Subject: [PATCH 261/357] integration test: Update pid names --- scripts/integration-test | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/integration-test b/scripts/integration-test index da687fc2..5ec37619 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -42,11 +42,11 @@ then fi ./bin/longhorn controller --frontend tgt --enable-backend file test-volume_1.0 & -controller_pid=$! +pid_controller=$! ./bin/longhorn replica $temp & -replica1_pid=$! +pid_replica1=$! ./bin/longhorn replica --listen localhost:9505 $temp2 & -replica2_pid=$! +pid_replica2=$! # replica with 4MB backing file backing_file=backing_file.raw @@ -59,18 +59,18 @@ cp $backing_qcow2 $temp3 cp $backing_qcow2 $temp4 ./bin/longhorn replica --listen localhost:9602 --backing-file $backing_qcow2 $temp3 & -backing_replica1_pid=$! +pid_backing_replica1=$! ./bin/longhorn replica --listen localhost:9605 --backing-file $backing_qcow2 $temp4 & -backing_replica2_pid=$! +pid_backing_replica2=$! # make sure everything is running before continue integration test -ps $controller_pid -ps $replica1_pid -ps $replica2_pid -ps $backing_replica1_pid -ps $backing_replica2_pid +ps $pid_controller +ps $pid_replica1 +ps $pid_replica2 +ps $pid_backing_replica1 +ps $pid_backing_replica2 -trap "kill $controller_pid $replica1_pid $replica2_pid $backing_replica1_pid $backing_replica2_pid" EXIT +trap "kill $pid_controller $pid_replica1 $pid_replica2 $pid_backing_replica1 $pid_backing_replica2" EXIT cd integration find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \; From e9f69d9392fff5dd4710ca33706d325c247f84b9 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Feb 2017 11:44:37 -0800 Subject: [PATCH 262/357] integration test: HA test cases Current cover three scenarios: 1. One replica down and verify volume still works. 2. One replica down, verify rebuild is fine and volume works in the meantime. 3. Two replicas both down, verify that the one has higher revision counter (more writes) should prevail in the best-effect volume rebuilding. --- integration/data/cmd.py | 5 + integration/data/common.py | 40 ++++++++ integration/data/test_ha.py | 194 ++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 integration/data/test_ha.py diff --git a/integration/data/cmd.py b/integration/data/cmd.py index 6c5f2d94..3cb94c75 100644 --- a/integration/data/cmd.py +++ b/integration/data/cmd.py @@ -55,3 +55,8 @@ def backup_restore(backup): def backup_inspect(backup): cmd = [_bin(), '--debug', 'backup', 'inspect', backup] return json.loads(subprocess.check_output(cmd)) + + +def add_replica(url): + cmd = [_bin(), '--debug', 'add', url] + return subprocess.check_output(cmd).strip() diff --git a/integration/data/common.py b/integration/data/common.py index 8a8d06ac..faac5e48 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -90,6 +90,11 @@ def backing_dev(request): return d +@pytest.fixture() +def controller(request): + return controller_client(request) + + def controller_client(request): url = 'http://localhost:9501/v1/schemas' c = cattle.from_env(url=url) @@ -108,6 +113,16 @@ def cleanup_controller(client): return client +@pytest.fixture() +def replica1(request): + return replica_client(request, REPLICA1_SCHEMA) + + +@pytest.fixture() +def replica2(request): + return replica_client(request, REPLICA2_SCHEMA) + + def replica_client(request, url): c = cattle.from_env(url=url) request.addfinalizer(lambda: cleanup_replica(c)) @@ -199,3 +214,28 @@ def read_from_backing_file(offset, length): def checksum_dev(dev): return hashlib.sha512(dev.readat(0, SIZE)).hexdigest() + + +def verify_loop(dev, times, offset, length): + for i in range(0, times): + data = random_string(length) + verify_data(dev, offset, data) + + +def verify_replica_state(c, index, state): + for i in range(10): + replicas = c.list_replica() + assert len(replicas) == 2 + + if replicas[index].mode == state: + break + + time.sleep(0.2) + + assert replicas[index].mode == state + + +def verify_read(dev, offset, data): + for i in range(10): + readed = read_dev(dev, offset, len(data)) + assert data == readed diff --git a/integration/data/test_ha.py b/integration/data/test_ha.py new file mode 100644 index 00000000..9a19b13a --- /dev/null +++ b/integration/data/test_ha.py @@ -0,0 +1,194 @@ +import threading + +import cmd +import common +from common import controller, replica1, replica2 # NOQA +from common import open_replica, get_blockdev, cleanup_replica +from common import verify_read, verify_data + +def test_ha_single_replica_failure(controller, replica1, replica2): # NOQA + open_replica(replica1) + open_replica(replica2) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + v = v.start(replicas=[ + common.REPLICA1, + common.REPLICA2 + ]) + assert v.replicaCount == 2 + + replicas = controller.list_replica() + assert len(replicas) == 2 + assert replicas[0].mode == "RW" + assert replicas[1].mode == "RW" + + dev = get_blockdev() + + data = common.random_string(128) + data_offset = 0 + verify_data(dev, data_offset, data) + + cleanup_replica(replica2) + + thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread.start() + + common.verify_replica_state(controller, 1, "ERR") + + thread.join() + + verify_read(dev, data_offset, data) + +def test_ha_single_replica_rebuild(controller, replica1, replica2): # NOQA + open_replica(replica1) + open_replica(replica2) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + v = v.start(replicas=[ + common.REPLICA1, + common.REPLICA2 + ]) + assert v.replicaCount == 2 + + replicas = controller.list_replica() + assert len(replicas) == 2 + assert replicas[0].mode == "RW" + assert replicas[1].mode == "RW" + + dev = get_blockdev() + + data = common.random_string(128) + data_offset = 0 + verify_data(dev, data_offset, data) + + # Cleanup replica2 + cleanup_replica(replica2) + + thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread.start() + + common.verify_replica_state(controller, 1, "ERR") + + thread.join() + + verify_read(dev, data_offset, data) + + controller.delete(replicas[1]) + + # Rebuild replica2 + common.open_replica(replica2) + cmd.add_replica(common.REPLICA2) + + thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread.start() + + common.verify_replica_state(controller, 1, "RW") + + thread.join() + + verify_read(dev, data_offset, data) + +def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA + open_replica(replica1) + open_replica(replica2) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + v = v.start(replicas=[ + common.REPLICA1, + common.REPLICA2 + ]) + assert v.replicaCount == 2 + + replicas = controller.list_replica() + assert len(replicas) == 2 + assert replicas[0].mode == "RW" + assert replicas[1].mode == "RW" + + dev = get_blockdev() + + data1 = common.random_string(128) + data1_offset = 0 + verify_data(dev, data1_offset, data1) + + # Close replica2 + r2 = replica2.list_replica()[0] + assert r2.revisioncounter == 1 + r2.close() + + thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread.start() + + common.verify_replica_state(controller, 1, "ERR") + + verify_read(dev, data1_offset, data1) + + thread.join() + + data2 = common.random_string(128) + data2_offset = 512 + verify_data(dev, data2_offset, data2) + + # Close replica1 + r1 = replica1.list_replica()[0] + assert r1.revisioncounter == 12 # 1 + 10 + 1 + r1.close() + + # Restart volume + common.cleanup_controller(controller) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + # NOTE the order is reversed here + v = v.start(replicas=[ + common.REPLICA2, + common.REPLICA1 + ]) + assert v.replicaCount == 2 + + # replica2 is out because of lower revision counter + replicas = controller.list_replica() + assert len(replicas) == 2 + assert replicas[0].mode == "ERR" + assert replicas[1].mode == "RW" + + verify_read(dev, data1_offset, data1) + verify_read(dev, data2_offset, data2) + + # Rebuild replica2 + r2 = replica2.list_replica()[0] + assert r2.revisioncounter == 1 + r2.close() + + controller.delete(replicas[0]) + + cmd.add_replica(common.REPLICA2) + + thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread.start() + + common.verify_replica_state(controller, 1, "RW") + + thread.join() + + verify_read(dev, data1_offset, data1) + verify_read(dev, data2_offset, data2) + + r1 = replica1.list_replica()[0] + r2 = replica2.list_replica()[0] + assert r1.revisioncounter == 22 # 1 + 10 + 1 + 10 + assert r2.revisioncounter == 22 # must be in sync with r1 + + +def data_verifier(dev, times): + common.verify_loop(dev, times, 1024, 128) From fcdabba474f535c6d5f26e4501a1a657a062ec58 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Feb 2017 19:40:02 -0800 Subject: [PATCH 263/357] rpc: Add version magic to data protocol We may need to change data version in the future. --- Dockerfile.dapper | 2 +- rpc/client.go | 1 + rpc/server.go | 1 + rpc/types.go | 5 +++++ rpc/wire.go | 10 ++++++++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 4a131079..dc61fc6a 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ RUN cd /usr/src/libqcow-20160123 && \ RUN cd /usr/src && \ git clone https://github.com/yasker/liblonghorn.git && \ cd liblonghorn && \ - git checkout ab004d2a922bc7a2bbb0a2b3ac8e5f6ff389507f && \ + git checkout 8ef0ed67bc882457ffe63ad0f1ae49cb59c01e57 && \ make deb && \ dpkg -i ./pkg/liblonghorn_*.deb diff --git a/rpc/client.go b/rpc/client.go index bbfe2b89..b7dc9ab6 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -165,6 +165,7 @@ func (c *Client) handleRequest(req *Message) { return } + req.MagicVersion = MagicVersion req.Seq = c.nextSeq() c.messages[req.Seq] = req c.send <- req diff --git a/rpc/server.go b/rpc/server.go index e441accf..d329a2b8 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -84,6 +84,7 @@ func (s *Server) handleWrite(msg *Message) { } func (s *Server) pushResponse(count int, msg *Message, err error) { + msg.MagicVersion = MagicVersion msg.Type = TypeResponse if err == io.EOF { msg.Data = msg.Data[:count] diff --git a/rpc/types.go b/rpc/types.go index 41a83e6c..254fef5f 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -15,9 +15,14 @@ const ( writeBufferSize = 8096 ) +const ( + MagicVersion = uint16(0x1b01) // LongHorn01 +) + type Message struct { Complete chan struct{} + MagicVersion uint16 Seq uint32 Type uint32 Offset int64 diff --git a/rpc/wire.go b/rpc/wire.go index a37357a3..f8865ea8 100644 --- a/rpc/wire.go +++ b/rpc/wire.go @@ -3,6 +3,7 @@ package rpc import ( "bufio" "encoding/binary" + "fmt" "io" "net" ) @@ -22,6 +23,9 @@ func NewWire(conn net.Conn) *Wire { } func (w *Wire) Write(msg *Message) error { + if err := binary.Write(w.writer, binary.LittleEndian, msg.MagicVersion); err != nil { + return err + } if err := binary.Write(w.writer, binary.LittleEndian, msg.Seq); err != nil { return err } @@ -48,6 +52,12 @@ func (w *Wire) Read() (*Message, error) { length uint32 ) + if err := binary.Read(w.reader, binary.LittleEndian, &msg.MagicVersion); err != nil { + return nil, err + } + if msg.MagicVersion != MagicVersion { + return nil, fmt.Errorf("Wrong API version received: 0x%x", &msg.MagicVersion) + } if err := binary.Read(w.reader, binary.LittleEndian, &msg.Seq); err != nil { return nil, err } From 91278643e56b9601602f5d83540bd42d609fbcbf Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Feb 2017 19:40:02 -0800 Subject: [PATCH 264/357] controller: Rename CheckReplica to VerifyRebuildReplica --- controller/client/controller_client.go | 4 ++-- controller/control.go | 2 +- controller/rest/model.go | 2 +- controller/rest/replica.go | 30 +++++++++++++------------- controller/rest/router.go | 2 +- sync/sync.go | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 85117663..4f56a229 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -144,12 +144,12 @@ func (c *ControllerClient) GetReplica(address string) (*rest.Replica, error) { return resp, err } -func (c *ControllerClient) CheckReplica(address string) error { +func (c *ControllerClient) VerifyRebuildReplica(address string) error { replica, err := c.GetReplica(address) if err != nil { return err } - return c.post(replica.Actions["check"], &replica, nil) + return c.post(replica.Actions["verifyrebuild"], &replica, nil) } func (c *ControllerClient) PrepareRebuild(address string) (*rest.PrepareRebuildOutput, error) { diff --git a/controller/control.go b/controller/control.go index 7ff23191..0d959791 100644 --- a/controller/control.go +++ b/controller/control.go @@ -196,7 +196,7 @@ func (c *Controller) getCurrentAndRWReplica(address string) (*types.Replica, *ty return current, rwReplica, nil } -func (c *Controller) CheckReplica(address string) error { +func (c *Controller) VerifyRebuildReplica(address string) error { // Prevent snapshot happenes at the same time, well at least no // controller involved c.Lock() diff --git a/controller/rest/model.go b/controller/rest/model.go index 709e4b2c..05ef98bc 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -96,8 +96,8 @@ func NewReplica(context *api.ApiContext, address string, mode types.Mode) *Repli Address: address, Mode: string(mode), } - r.Actions["check"] = context.UrlBuilder.ActionLink(r.Resource, "check") r.Actions["preparerebuild"] = context.UrlBuilder.ActionLink(r.Resource, "preparerebuild") + r.Actions["verifyrebuild"] = context.UrlBuilder.ActionLink(r.Resource, "verifyrebuild") return r } diff --git a/controller/rest/replica.go b/controller/rest/replica.go index bd3b067b..28b96a6e 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -92,21 +92,6 @@ func (s *Server) UpdateReplica(rw http.ResponseWriter, req *http.Request) error return s.GetReplica(rw, req) } -func (s *Server) CheckReplica(rw http.ResponseWriter, req *http.Request) error { - vars := mux.Vars(req) - id, err := DencodeID(vars["id"]) - if err != nil { - rw.WriteHeader(http.StatusNotFound) - return nil - } - - if err := s.c.CheckReplica(id); err != nil { - return err - } - - return s.GetReplica(rw, req) -} - func (s *Server) PrepareRebuildReplica(rw http.ResponseWriter, req *http.Request) error { vars := mux.Vars(req) id, err := DencodeID(vars["id"]) @@ -132,3 +117,18 @@ func (s *Server) PrepareRebuildReplica(rw http.ResponseWriter, req *http.Request apiContext.Write(&resp) return nil } + +func (s *Server) VerifyRebuildReplica(rw http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + id, err := DencodeID(vars["id"]) + if err != nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + if err := s.c.VerifyRebuildReplica(id); err != nil { + return err + } + + return s.GetReplica(rw, req) +} diff --git a/controller/rest/router.go b/controller/rest/router.go index 15b81e7d..2b772e07 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -29,8 +29,8 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) router.Methods("POST").Path("/v1/replicas").Handler(f(schemas, s.CreateReplica)) - router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "check").Handler(f(schemas, s.CheckReplica)) router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "preparerebuild").Handler(f(schemas, s.PrepareRebuildReplica)) + router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "verifyrebuild").Handler(f(schemas, s.VerifyRebuildReplica)) router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) router.Methods("PUT").Path("/v1/replicas/{id}").Handler(f(schemas, s.UpdateReplica)) diff --git a/sync/sync.go b/sync/sync.go index bed34c4d..d7c53bac 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -194,7 +194,7 @@ func (t *Task) AddReplica(replica string) error { return err } - if err := t.reloadAndCheck(replica, toClient); err != nil { + if err := t.reloadAndVerify(replica, toClient); err != nil { return err } @@ -227,13 +227,13 @@ func (t *Task) checkAndResetFailedRebuild(address string) error { return nil } -func (t *Task) reloadAndCheck(address string, repClient *replicaClient.ReplicaClient) error { +func (t *Task) reloadAndVerify(address string, repClient *replicaClient.ReplicaClient) error { _, err := repClient.ReloadReplica() if err != nil { return err } - if err := t.client.CheckReplica(rest.EncodeID(address)); err != nil { + if err := t.client.VerifyRebuildReplica(rest.EncodeID(address)); err != nil { return err } From ac1a583026982f989580ce6f0280c9014a23350e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Feb 2017 18:47:55 -0800 Subject: [PATCH 265/357] controller: Move PrepareRebuildReplica() and VerifyRebuildReplica() to rebuild.go controller should use backend interface to communicate with replicas, instead of using replica client directly. There are two places disobey this currently: revert.go and rebuild.go. This refactor is for the future change of backend API to include the necessary functionality for revert and rebuild operation. --- controller/control.go | 155 --------------------------------------- controller/rebuild.go | 163 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 155 deletions(-) create mode 100644 controller/rebuild.go diff --git a/controller/control.go b/controller/control.go index 0d959791..fd9ce273 100644 --- a/controller/control.go +++ b/controller/control.go @@ -2,11 +2,9 @@ package controller import ( "fmt" - "reflect" "sync" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/replica/client" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" ) @@ -159,159 +157,6 @@ func (c *Controller) ListReplicas() []types.Replica { return c.replicas } -func getReplicaChain(address string) ([]string, error) { - repClient, err := client.NewReplicaClient(address) - if err != nil { - return nil, fmt.Errorf("Cannot get replica client for %v: %v", - address, err) - } - - rep, err := repClient.GetReplica() - if err != nil { - return nil, fmt.Errorf("Cannot get replica for %v: %v", - address, err) - } - return rep.Chain, nil -} - -func (c *Controller) getCurrentAndRWReplica(address string) (*types.Replica, *types.Replica, error) { - var ( - current, rwReplica *types.Replica - ) - - for i := range c.replicas { - if c.replicas[i].Address == address { - current = &c.replicas[i] - } else if c.replicas[i].Mode == types.RW { - rwReplica = &c.replicas[i] - } - } - if current == nil { - return nil, nil, fmt.Errorf("Cannot find replica %v", address) - } - if rwReplica == nil { - return nil, nil, fmt.Errorf("Cannot find any healthy replica") - } - - return current, rwReplica, nil -} - -func (c *Controller) VerifyRebuildReplica(address string) error { - // Prevent snapshot happenes at the same time, well at least no - // controller involved - c.Lock() - defer c.Unlock() - - replica, rwReplica, err := c.getCurrentAndRWReplica(address) - if err != nil { - return err - } - - if replica.Mode == types.RW { - return nil - } - if replica.Mode != types.WO { - return fmt.Errorf("Invalid mode %v for replica %v to check", replica.Mode, address) - } - - rwChain, err := getReplicaChain(rwReplica.Address) - if err != nil { - return err - } - // Don't need to compare the volume head disk - rwChain = rwChain[1:] - - chain, err := getReplicaChain(address) - if err != nil { - return err - } - chain = chain[1:] - - if !reflect.DeepEqual(rwChain, chain) { - return fmt.Errorf("Replica %v's chain not equal to RW replica %v's chain", - address, rwReplica.Address) - } - - counter, err := c.backend.GetRevisionCounter(rwReplica.Address) - if err != nil || counter == -1 { - return fmt.Errorf("Failed to get revision counter of RW Replica %v: counter %v, err %v", - rwReplica.Address, counter, err) - - } - c.backend.SetRevisionCounter(address, counter) - - logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) - c.setReplicaModeNoLock(address, types.RW) - return nil -} - -func syncFile(from, to string, fromReplica, toReplica *types.Replica) error { - if to == "" { - to = from - } - - fromClient, err := client.NewReplicaClient(fromReplica.Address) - if err != nil { - return fmt.Errorf("Cannot get replica client for %v: %v", - fromReplica.Address, err) - } - - toClient, err := client.NewReplicaClient(toReplica.Address) - if err != nil { - return fmt.Errorf("Cannot get replica client for %v: %v", - toReplica.Address, err) - } - - host, port, err := toClient.LaunchReceiver(to) - if err != nil { - return err - } - - logrus.Infof("Synchronizing %s to %s@%s:%d", from, to, host, port) - err = fromClient.SendFile(from, host, port) - if err != nil { - logrus.Infof("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err) - } else { - logrus.Infof("Done synchronizing %s to %s@%s:%d", from, to, host, port) - } - - return err -} - -func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { - c.Lock() - defer c.Unlock() - - c.backend.SetRevisionCounter(address, 0) - - replica, rwReplica, err := c.getCurrentAndRWReplica(address) - if err != nil { - return nil, err - } - if replica.Mode != types.WO { - return nil, fmt.Errorf("Invalid mode %v for replica %v to prepare rebuild", replica.Mode, address) - } - - rwChain, err := getReplicaChain(rwReplica.Address) - if err != nil { - return nil, err - } - - fromHead := rwChain[0] - - chain, err := getReplicaChain(address) - if err != nil { - return nil, err - } - toHead := chain[0] - - if err := syncFile(fromHead+".meta", toHead+".meta", rwReplica, replica); err != nil { - return nil, err - } - - return rwChain[1:], nil -} - func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { switch mode { case types.ERR: diff --git a/controller/rebuild.go b/controller/rebuild.go new file mode 100644 index 00000000..87acb312 --- /dev/null +++ b/controller/rebuild.go @@ -0,0 +1,163 @@ +package controller + +import ( + "fmt" + "reflect" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/replica/client" + "github.com/rancher/longhorn/types" +) + +func getReplicaChain(address string) ([]string, error) { + repClient, err := client.NewReplicaClient(address) + if err != nil { + return nil, fmt.Errorf("Cannot get replica client for %v: %v", + address, err) + } + + rep, err := repClient.GetReplica() + if err != nil { + return nil, fmt.Errorf("Cannot get replica for %v: %v", + address, err) + } + return rep.Chain, nil +} + +func (c *Controller) getCurrentAndRWReplica(address string) (*types.Replica, *types.Replica, error) { + var ( + current, rwReplica *types.Replica + ) + + for i := range c.replicas { + if c.replicas[i].Address == address { + current = &c.replicas[i] + } else if c.replicas[i].Mode == types.RW { + rwReplica = &c.replicas[i] + } + } + if current == nil { + return nil, nil, fmt.Errorf("Cannot find replica %v", address) + } + if rwReplica == nil { + return nil, nil, fmt.Errorf("Cannot find any healthy replica") + } + + return current, rwReplica, nil +} + +func (c *Controller) VerifyRebuildReplica(address string) error { + // Prevent snapshot happenes at the same time, well at least no + // controller involved + c.Lock() + defer c.Unlock() + + replica, rwReplica, err := c.getCurrentAndRWReplica(address) + if err != nil { + return err + } + + if replica.Mode == types.RW { + return nil + } + if replica.Mode != types.WO { + return fmt.Errorf("Invalid mode %v for replica %v to check", replica.Mode, address) + } + + rwChain, err := getReplicaChain(rwReplica.Address) + if err != nil { + return err + } + // Don't need to compare the volume head disk + rwChain = rwChain[1:] + + chain, err := getReplicaChain(address) + if err != nil { + return err + } + chain = chain[1:] + + if !reflect.DeepEqual(rwChain, chain) { + return fmt.Errorf("Replica %v's chain not equal to RW replica %v's chain", + address, rwReplica.Address) + } + + counter, err := c.backend.GetRevisionCounter(rwReplica.Address) + if err != nil || counter == -1 { + return fmt.Errorf("Failed to get revision counter of RW Replica %v: counter %v, err %v", + rwReplica.Address, counter, err) + + } + c.backend.SetRevisionCounter(address, counter) + + logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) + c.setReplicaModeNoLock(address, types.RW) + return nil +} + +func syncFile(from, to string, fromReplica, toReplica *types.Replica) error { + if to == "" { + to = from + } + + fromClient, err := client.NewReplicaClient(fromReplica.Address) + if err != nil { + return fmt.Errorf("Cannot get replica client for %v: %v", + fromReplica.Address, err) + } + + toClient, err := client.NewReplicaClient(toReplica.Address) + if err != nil { + return fmt.Errorf("Cannot get replica client for %v: %v", + toReplica.Address, err) + } + + host, port, err := toClient.LaunchReceiver(to) + if err != nil { + return err + } + + logrus.Infof("Synchronizing %s to %s@%s:%d", from, to, host, port) + err = fromClient.SendFile(from, host, port) + if err != nil { + logrus.Infof("Failed synchronizing %s to %s@%s:%d: %v", from, to, host, port, err) + } else { + logrus.Infof("Done synchronizing %s to %s@%s:%d", from, to, host, port) + } + + return err +} + +func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { + c.Lock() + defer c.Unlock() + + c.backend.SetRevisionCounter(address, 0) + + replica, rwReplica, err := c.getCurrentAndRWReplica(address) + if err != nil { + return nil, err + } + if replica.Mode != types.WO { + return nil, fmt.Errorf("Invalid mode %v for replica %v to prepare rebuild", replica.Mode, address) + } + + rwChain, err := getReplicaChain(rwReplica.Address) + if err != nil { + return nil, err + } + + fromHead := rwChain[0] + + chain, err := getReplicaChain(address) + if err != nil { + return nil, err + } + toHead := chain[0] + + if err := syncFile(fromHead+".meta", toHead+".meta", rwReplica, replica); err != nil { + return nil, err + } + + return rwChain[1:], nil +} From 441b212a86fa2f36925849f97b90f89d78aa34a6 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 14 Feb 2017 13:43:37 -0800 Subject: [PATCH 266/357] replica: Fix racy revision counter Also add test cases --- integration/data/common.py | 21 ++++++++++++++++++- integration/data/test_ha.py | 42 ++++++++++++++++++++++++++++++------- replica/revision_counter.go | 11 +++++++++- 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index faac5e48..6d457306 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -3,6 +3,7 @@ import subprocess import hashlib import time +import threading import os from os import path @@ -216,8 +217,12 @@ def checksum_dev(dev): return hashlib.sha512(dev.readat(0, SIZE)).hexdigest() +def data_verifier(dev, times, offset, length): + verify_loop(dev, times, offset, length) + + def verify_loop(dev, times, offset, length): - for i in range(0, times): + for i in range(times): data = random_string(length) verify_data(dev, offset, data) @@ -239,3 +244,17 @@ def verify_read(dev, offset, data): for i in range(10): readed = read_dev(dev, offset, len(data)) assert data == readed + + +def verify_async(dev, times, length, count): + assert length * count < SIZE + + threads = [] + for i in range(count): + t = threading.Thread(target=data_verifier, + args=(dev, times, i * PAGE_SIZE, length)) + t.start() + threads.append(t) + + for i in range(count): + threads[i].join() diff --git a/integration/data/test_ha.py b/integration/data/test_ha.py index 9a19b13a..e84b2de5 100644 --- a/integration/data/test_ha.py +++ b/integration/data/test_ha.py @@ -4,7 +4,7 @@ import common from common import controller, replica1, replica2 # NOQA from common import open_replica, get_blockdev, cleanup_replica -from common import verify_read, verify_data +from common import verify_read, verify_data, data_verifier def test_ha_single_replica_failure(controller, replica1, replica2): # NOQA open_replica(replica1) @@ -33,7 +33,7 @@ def test_ha_single_replica_failure(controller, replica1, replica2): # NOQA cleanup_replica(replica2) - thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) thread.start() common.verify_replica_state(controller, 1, "ERR") @@ -70,7 +70,7 @@ def test_ha_single_replica_rebuild(controller, replica1, replica2): # NOQA # Cleanup replica2 cleanup_replica(replica2) - thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) thread.start() common.verify_replica_state(controller, 1, "ERR") @@ -85,7 +85,7 @@ def test_ha_single_replica_rebuild(controller, replica1, replica2): # NOQA common.open_replica(replica2) cmd.add_replica(common.REPLICA2) - thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) thread.start() common.verify_replica_state(controller, 1, "RW") @@ -124,7 +124,7 @@ def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA assert r2.revisioncounter == 1 r2.close() - thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) thread.start() common.verify_replica_state(controller, 1, "ERR") @@ -174,7 +174,7 @@ def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA cmd.add_replica(common.REPLICA2) - thread = threading.Thread(target=data_verifier, args=(dev, 10)) + thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) thread.start() common.verify_replica_state(controller, 1, "RW") @@ -190,5 +190,31 @@ def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA assert r2.revisioncounter == 22 # must be in sync with r1 -def data_verifier(dev, times): - common.verify_loop(dev, times, 1024, 128) +def test_ha_revision_counter_consistency(controller, replica1, replica2): # NOQA + open_replica(replica1) + open_replica(replica2) + + replicas = controller.list_replica() + assert len(replicas) == 0 + + v = controller.list_volume()[0] + v = v.start(replicas=[ + common.REPLICA1, + common.REPLICA2 + ]) + assert v.replicaCount == 2 + + replicas = controller.list_replica() + assert len(replicas) == 2 + assert replicas[0].mode == "RW" + assert replicas[1].mode == "RW" + + dev = get_blockdev() + + common.verify_async(dev, 10, 128, 100) + + r1 = replica1.list_replica()[0] + r2 = replica2.list_replica()[0] + # kernel can merge requests so backend may not receive 1000 writes + assert r1.revisioncounter > 0 + assert r1.revisioncounter == r2.revisioncounter diff --git a/replica/revision_counter.go b/replica/revision_counter.go index 221630ea..d64ff384 100644 --- a/replica/revision_counter.go +++ b/replica/revision_counter.go @@ -80,6 +80,7 @@ func (r *Replica) initRevisionCounter() error { // Don't use r.revisionCache directly // r.revisionCache is an internal cache, to avoid read from disk // everytime when counter needs to be updated. + // And it's protected by revisionLock r.revisionCache = counter return nil } @@ -111,5 +112,13 @@ func (r *Replica) SetRevisionCounter(counter int64) error { } func (r *Replica) increaseRevisionCounter() error { - return r.SetRevisionCounter(r.revisionCache + 1) + r.revisionLock.Lock() + defer r.revisionLock.Unlock() + + if err := r.writeRevisionCounter(r.revisionCache + 1); err != nil { + return err + } + + r.revisionCache++ + return nil } From bca578fe8a8c8aeb6765f5a1ada9dbb7cfeeb713 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 14 Feb 2017 18:57:03 -0800 Subject: [PATCH 267/357] test: Make sure exceptions happens in the threads are acknowledged as well --- integration/data/common.py | 14 +++++++++++++- integration/data/test_ha.py | 36 ++++++++++-------------------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/integration/data/common.py b/integration/data/common.py index 6d457306..7de19da3 100644 --- a/integration/data/common.py +++ b/integration/data/common.py @@ -34,6 +34,8 @@ VOLUME_NAME = 'test-volume_1.0' +thread_failed = False + def _file(f): return path.join(_base(), '../../{}'.format(f)) @@ -218,7 +220,12 @@ def checksum_dev(dev): def data_verifier(dev, times, offset, length): - verify_loop(dev, times, offset, length) + try: + verify_loop(dev, times, offset, length) + except Exception as ex: + global thread_failed + thread_failed = True + raise ex def verify_loop(dev, times, offset, length): @@ -258,3 +265,8 @@ def verify_async(dev, times, length, count): for i in range(count): threads[i].join() + + global thread_failed + if thread_failed: + thread_failed = False + raise Exception("data_verifier thread failed") diff --git a/integration/data/test_ha.py b/integration/data/test_ha.py index e84b2de5..5fb6ed08 100644 --- a/integration/data/test_ha.py +++ b/integration/data/test_ha.py @@ -1,10 +1,9 @@ -import threading - import cmd import common from common import controller, replica1, replica2 # NOQA from common import open_replica, get_blockdev, cleanup_replica -from common import verify_read, verify_data, data_verifier +from common import verify_read, verify_data, verify_async + def test_ha_single_replica_failure(controller, replica1, replica2): # NOQA open_replica(replica1) @@ -28,18 +27,15 @@ def test_ha_single_replica_failure(controller, replica1, replica2): # NOQA dev = get_blockdev() data = common.random_string(128) - data_offset = 0 + data_offset = 1024 verify_data(dev, data_offset, data) cleanup_replica(replica2) - thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) - thread.start() + verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "ERR") - thread.join() - verify_read(dev, data_offset, data) def test_ha_single_replica_rebuild(controller, replica1, replica2): # NOQA @@ -64,19 +60,16 @@ def test_ha_single_replica_rebuild(controller, replica1, replica2): # NOQA dev = get_blockdev() data = common.random_string(128) - data_offset = 0 + data_offset = 1024 verify_data(dev, data_offset, data) # Cleanup replica2 cleanup_replica(replica2) - thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) - thread.start() + verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "ERR") - thread.join() - verify_read(dev, data_offset, data) controller.delete(replicas[1]) @@ -85,13 +78,10 @@ def test_ha_single_replica_rebuild(controller, replica1, replica2): # NOQA common.open_replica(replica2) cmd.add_replica(common.REPLICA2) - thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) - thread.start() + verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "RW") - thread.join() - verify_read(dev, data_offset, data) def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA @@ -116,7 +106,7 @@ def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA dev = get_blockdev() data1 = common.random_string(128) - data1_offset = 0 + data1_offset = 1024 verify_data(dev, data1_offset, data1) # Close replica2 @@ -124,15 +114,12 @@ def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA assert r2.revisioncounter == 1 r2.close() - thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) - thread.start() + verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "ERR") verify_read(dev, data1_offset, data1) - thread.join() - data2 = common.random_string(128) data2_offset = 512 verify_data(dev, data2_offset, data2) @@ -174,13 +161,10 @@ def test_ha_double_replica_rebuild(controller, replica1, replica2): # NOQA cmd.add_replica(common.REPLICA2) - thread = threading.Thread(target=data_verifier, args=(dev, 10, 1024, 128)) - thread.start() + verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "RW") - thread.join() - verify_read(dev, data1_offset, data1) verify_read(dev, data2_offset, data2) From 647764d054bb47a9cda6abcbc6a33f299b812773 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Feb 2017 14:05:21 -0800 Subject: [PATCH 268/357] controller: Move monitorPing to controller, and mark replica as ERR upon ping failure --- backend/file/file.go | 4 ++++ backend/remote/remote.go | 24 +++++++++++++++++------- controller/control.go | 16 ++++++++++++++++ types/types.go | 3 +++ 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/backend/file/file.go b/backend/file/file.go index 88a41ddb..fc217ea6 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -61,3 +61,7 @@ func (ff *Factory) Create(address string) (types.Backend, error) { return &Wrapper{file}, nil } + +func (f *Wrapper) GetMonitorChannel() types.MonitorChannel { + return nil +} diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 610a0e74..e0ebb121 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -38,15 +38,15 @@ type Factory struct { type Remote struct { types.ReaderWriterAt - name string - pingURL string - replicaURL string - httpClient *http.Client - closeChan chan struct{} + name string + pingURL string + replicaURL string + httpClient *http.Client + closeChan chan struct{} + monitorChan types.MonitorChannel } func (r *Remote) Close() error { - r.closeChan <- struct{}{} logrus.Infof("Closing: %s", r.name) return r.doAction("close", "") } @@ -192,7 +192,8 @@ func (rf *Factory) Create(address string) (types.Backend, error) { httpClient: &http.Client{ Timeout: timeout, }, - closeChan: make(chan struct{}, 1), + closeChan: make(chan struct{}, 1), + monitorChan: make(types.MonitorChannel), } replica, err := r.info() @@ -225,10 +226,14 @@ func (r *Remote) monitorPing(client *rpc.Client) error { ticker := time.NewTicker(pingInveral) defer ticker.Stop() + //bug here, if replica was marked as ERR in normal situation, this + //thread still won't exit until it failed multiple times of ping + // at least the channel should be closed retry := 0 for { select { case <-r.closeChan: + r.monitorChan <- nil return nil case <-ticker.C: if err := r.Ping(client); err == nil { @@ -242,6 +247,7 @@ func (r *Remote) monitorPing(client *rpc.Client) error { logrus.Errorf("Failed to get ping response from replica %v; error: %v", r.replicaURL, err) journal.PrintLimited(1000) //flush automatically upon error client.SetError(err) + r.monitorChan <- err return err } } @@ -277,3 +283,7 @@ func (r *Remote) Ping(client *rpc.Client) error { return ErrPingTimeout } } + +func (r *Remote) GetMonitorChannel() types.MonitorChannel { + return r.monitorChan +} diff --git a/controller/control.go b/controller/control.go index fd9ce273..54ef6c28 100644 --- a/controller/control.go +++ b/controller/control.go @@ -220,6 +220,8 @@ func (c *Controller) Start(addresses ...string) error { return err } + go c.monitoring(address, newBackend) + newSize, err := newBackend.Size() if err != nil { return err @@ -378,3 +380,17 @@ func (c *Controller) Shutdown() error { func (c *Controller) Size() (int64, error) { return c.size, nil } + +func (c *Controller) monitoring(address string, backend types.Backend) { + monitorChan := backend.GetMonitorChannel() + + if monitorChan == nil { + return + } + + err := <-monitorChan + if err != nil { + logrus.Errorf("Backend %v monitoring failed, mark as ERR", address) + c.SetReplicaMode(address, types.ERR) + } +} diff --git a/types/types.go b/types/types.go index 143e7ba9..699395a3 100644 --- a/types/types.go +++ b/types/types.go @@ -22,6 +22,8 @@ type DiffDisk interface { Fd() uintptr } +type MonitorChannel chan error + type Backend interface { ReaderWriterAt io.Closer @@ -31,6 +33,7 @@ type Backend interface { RemainSnapshots() (int, error) GetRevisionCounter() (int64, error) SetRevisionCounter(counter int64) error + GetMonitorChannel() MonitorChannel } type BackendFactory interface { From 428d1610df849defa5eebf3cac935c1035e83e6c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Feb 2017 16:30:30 -0800 Subject: [PATCH 269/357] controller: Perform ping(monitor) over data path rather than API path Those are two separate things. For example, in testing API path may still open but data path can be closed. It's better to ping through data path instead. We will add a new type of message for this purpose. --- backend/remote/remote.go | 60 +++++----------------------------------- rpc/client.go | 26 ++++++++++++++--- rpc/server.go | 6 ++++ rpc/types.go | 1 + 4 files changed, 36 insertions(+), 57 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index e0ebb121..9fe52fbe 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -3,7 +3,6 @@ package remote import ( "bytes" "encoding/json" - "errors" "fmt" "io" "net" @@ -16,17 +15,12 @@ import ( "github.com/rancher/longhorn/rpc" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" - journal "github.com/rancher/sparse-tools/stats" ) var ( - pingRetries = 6 - pingTimeout = 20 * time.Second - pingInveral = 2 * time.Second - - timeout = 30 * time.Second - requestBuffer = 1024 - ErrPingTimeout = errors.New("Ping timeout") + pingInveral = 2 * time.Second + timeout = 30 * time.Second + requestBuffer = 1024 ) func New() types.BackendFactory { @@ -229,61 +223,21 @@ func (r *Remote) monitorPing(client *rpc.Client) error { //bug here, if replica was marked as ERR in normal situation, this //thread still won't exit until it failed multiple times of ping // at least the channel should be closed - retry := 0 for { select { case <-r.closeChan: r.monitorChan <- nil return nil case <-ticker.C: - if err := r.Ping(client); err == nil { - retry = 0 // reset on success - } else { - if retry < pingRetries { - retry++ - logrus.Errorf("Ping retry %v on replica %v; error: %v", retry, r.replicaURL, err) - journal.PrintLimited(1000) //flush automatically upon retry - } else { - logrus.Errorf("Failed to get ping response from replica %v; error: %v", r.replicaURL, err) - journal.PrintLimited(1000) //flush automatically upon error - client.SetError(err) - r.monitorChan <- err - return err - } + if err := client.Ping(); err != nil { + client.SetError(err) + r.monitorChan <- err + return err } } } } -func (r *Remote) Ping(client *rpc.Client) error { - ret := make(chan error, 1) - // use replica data addr for ping target tracking - opID := journal.InsertPendingOp(time.Now(), client.TargetID(), journal.OpPing, 0) - - go func() { - resp, err := r.httpClient.Get(r.pingURL) - if err != nil { - ret <- err - return - } - defer resp.Body.Close() - if resp.StatusCode != 200 { - ret <- fmt.Errorf("Non-200 response %d from ping to %s", resp.StatusCode, r.name) - return - } - ret <- nil - }() - - select { - case err := <-ret: - journal.RemovePendingOp(opID, err == nil) - return err - case <-time.After(pingTimeout): - journal.RemovePendingOp(opID, false) - return ErrPingTimeout - } -} - func (r *Remote) GetMonitorChannel() types.MonitorChannel { return r.monitorChan } diff --git a/rpc/client.go b/rpc/client.go index b7dc9ab6..772e8cb8 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -12,11 +12,13 @@ import ( var ( //ErrRWTimeout r/w operation timeout - ErrRWTimeout = errors.New("r/w timeout") + ErrRWTimeout = errors.New("r/w timeout") + ErrPingTimeout = errors.New("Ping timeout") opRetries = 4 opReadTimeout = 15 * time.Second // client read opWriteTimeout = 15 * time.Second // client write + opPingTimeout = 20 * time.Second ) //Client replica client @@ -71,6 +73,12 @@ func (c *Client) ReadAt(buf []byte, offset int64) (int, error) { return c.operation(TypeRead, buf, offset) } +//Ping replica client +func (c *Client) Ping() error { + _, err := c.operation(TypePing, nil, 0) + return err +} + func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { retry := 0 for { @@ -85,8 +93,10 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { switch op { case TypeRead: return time.After(opReadTimeout) + case TypeWrite: + return time.After(opWriteTimeout) } - return time.After(opWriteTimeout) + return time.After(opPingTimeout) }(msg.Type) c.requests <- &msg @@ -106,14 +116,20 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { logrus.Errorln("Read timeout on replcia", c.TargetID(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") case TypeWrite: logrus.Errorln("Write timeout on replica", c.TargetID(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") + case TypePing: + logrus.Errorln("Ping timeout on replica", c.TargetID(), "seq=", msg.Seq) } if retry < opRetries { retry++ logrus.Errorln("Retry ", retry, "on replica", c.TargetID(), "seq=", msg.Seq, "size=", len(msg.Data)/1024, "(kB)") } else { - c.SetError(ErrRWTimeout) + err := ErrRWTimeout + if msg.Type == TypePing { + err = ErrPingTimeout + } + c.SetError(err) journal.PrintLimited(1000) //flush automatically upon timeout - return 0, ErrRWTimeout + return 0, err } } } @@ -159,6 +175,8 @@ func (c *Client) handleRequest(req *Message) { req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpRead, len(req.Data)) case TypeWrite: req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpWrite, len(req.Data)) + case TypePing: + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpPing, 0) } if c.err != nil { c.replyError(req) diff --git a/rpc/server.go b/rpc/server.go index d329a2b8..6bc597f4 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -47,6 +47,8 @@ func (s *Server) readFromWire(ret chan<- error) { go s.handleRead(msg) case TypeWrite: go s.handleWrite(msg) + case TypePing: + go s.handlePing(msg) } ret <- nil } @@ -83,6 +85,10 @@ func (s *Server) handleWrite(msg *Message) { s.pushResponse(c, msg, err) } +func (s *Server) handlePing(msg *Message) { + s.pushResponse(0, msg, nil) +} + func (s *Server) pushResponse(count int, msg *Message, err error) { msg.MagicVersion = MagicVersion msg.Type = TypeResponse diff --git a/rpc/types.go b/rpc/types.go index 254fef5f..56127705 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -9,6 +9,7 @@ const ( TypeError TypeEOF TypeClose + TypePing messageSize = (32 + 32 + 32 + 64) / 8 //TODO: unused? readBufferSize = 8096 From e3fc4a578a30eecdcf38f1c351d909b7d7b13d9d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 21 Feb 2017 20:34:12 -0800 Subject: [PATCH 270/357] rpc: Make sure if response is TypeError, allocate enough buffer for it --- rpc/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rpc/client.go b/rpc/client.go index 772e8cb8..a2a73350 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -209,6 +209,9 @@ func (c *Client) handleResponse(resp *Message) { delete(c.messages, resp.Seq) // can probably optimize away this copy if len(resp.Data) > 0 { + if resp.Type == TypeError { + req.Data = make([]byte, len(resp.Data)) + } copy(req.Data, resp.Data) req.Data = req.Data[:len(resp.Data)] } From 21a46d57085956d299c5c0f8f126d8bc3962a729 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 21 Feb 2017 19:04:08 -0800 Subject: [PATCH 271/357] replica: Only reply to ping if replica is open/dirty/rebuilding In other situation, controller won't be able to read/write anyway --- backend/file/file.go | 4 ++++ controller/control.go | 2 +- frontend/tgt/frontend.go | 24 +++++++++++++++++++++++- replica/server.go | 8 ++++++++ rpc/server.go | 7 ++++--- types/types.go | 5 +++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/backend/file/file.go b/backend/file/file.go index fc217ea6..d0e57a27 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -65,3 +65,7 @@ func (ff *Factory) Create(address string) (types.Backend, error) { func (f *Wrapper) GetMonitorChannel() types.MonitorChannel { return nil } + +func (f *Wrapper) PingResponse() error { + return nil +} diff --git a/controller/control.go b/controller/control.go index 54ef6c28..7ae18bce 100644 --- a/controller/control.go +++ b/controller/control.go @@ -390,7 +390,7 @@ func (c *Controller) monitoring(address string, backend types.Backend) { err := <-monitorChan if err != nil { - logrus.Errorf("Backend %v monitoring failed, mark as ERR", address) + logrus.Errorf("Backend %v monitoring failed, mark as ERR: %v", address, err) c.SetReplicaMode(address, types.ERR) } } diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 86526baf..9ada5bc3 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -131,7 +131,7 @@ func (t *Tgt) startSocketServerListen(rw types.ReaderWriterAt) error { func (t *Tgt) handleServerConnection(c net.Conn, rw types.ReaderWriterAt) { defer c.Close() - server := rpc.NewServer(c, rw) + server := rpc.NewServer(c, NewDataProcessorWrapper(rw)) if err := server.Handle(); err != nil && err != io.EOF { logrus.Errorln("Fail to handle socket server connection due to ", err) } else if err == io.EOF { @@ -139,6 +139,28 @@ func (t *Tgt) handleServerConnection(c net.Conn, rw types.ReaderWriterAt) { } } +type DataProcessorWrapper struct { + rw types.ReaderWriterAt +} + +func NewDataProcessorWrapper(rw types.ReaderWriterAt) DataProcessorWrapper { + return DataProcessorWrapper{ + rw: rw, + } +} + +func (d DataProcessorWrapper) ReadAt(p []byte, off int64) (n int, err error) { + return d.rw.ReadAt(p, off) +} + +func (d DataProcessorWrapper) WriteAt(p []byte, off int64) (n int, err error) { + return d.rw.WriteAt(p, off) +} + +func (d DataProcessorWrapper) PingResponse() error { + return nil +} + func (t *Tgt) getDev() string { return filepath.Join(DevPath, t.Volume) } diff --git a/replica/server.go b/replica/server.go index 47364fe5..119a4e7f 100644 --- a/replica/server.go +++ b/replica/server.go @@ -267,3 +267,11 @@ func (s *Server) SetRevisionCounter(counter int64) error { } return s.r.SetRevisionCounter(counter) } + +func (s *Server) PingResponse() error { + state, _ := s.Status() + if state != Open && state != Dirty && state != Rebuilding { + return fmt.Errorf("ping failure: replica state %v", state) + } + return nil +} diff --git a/rpc/server.go b/rpc/server.go index 6bc597f4..69d997ad 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -12,10 +12,10 @@ type Server struct { wire *Wire responses chan *Message done chan struct{} - data types.ReaderWriterAt + data types.DataProcessor } -func NewServer(conn net.Conn, data types.ReaderWriterAt) *Server { +func NewServer(conn net.Conn, data types.DataProcessor) *Server { return &Server{ wire: NewWire(conn), responses: make(chan *Message, 1024), @@ -86,7 +86,8 @@ func (s *Server) handleWrite(msg *Message) { } func (s *Server) handlePing(msg *Message) { - s.pushResponse(0, msg, nil) + err := s.data.PingResponse() + s.pushResponse(0, msg, err) } func (s *Server) pushResponse(count int, msg *Message, err error) { diff --git a/types/types.go b/types/types.go index 699395a3..75a60360 100644 --- a/types/types.go +++ b/types/types.go @@ -68,3 +68,8 @@ type Frontend interface { Shutdown() error State() State } + +type DataProcessor interface { + ReaderWriterAt + PingResponse() error +} From 8f1b7b8a42827f60964b1c1083bccc173de383f3 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Feb 2017 16:29:04 -0800 Subject: [PATCH 272/357] test: Add test_replica_failure_detection Controller should detect replica failure and mark replica as ERR as result. --- integration/core/test_cli.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index cf0e7ec2..fd69ec22 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -203,6 +203,37 @@ def test_replica_add_after_rebuild_failed(bin, controller_client, assert r.mode == 'RW' +def test_replica_failure_detection(bin, controller_client, + replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + # wait for initial read/write period to pass + time.sleep(2) + + cleanup_replica(replica_client) + + detected = False + for i in range(10): + replicas = controller_client.list_replica() + assert len(replicas) == 2 + for r in replicas: + if r.address == REPLICA and r.mode == 'ERR': + detected = True + break + if detected: + break + time.sleep(1) + assert detected + + def test_revert(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) open_replica(replica_client2) From 05b9d2916799fad5194c27026522508d4df541fe Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 21 Feb 2017 22:04:43 -0800 Subject: [PATCH 273/357] controller: Add log whenever we set replica mode --- controller/control.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/controller/control.go b/controller/control.go index 7ae18bce..aa0beec4 100644 --- a/controller/control.go +++ b/controller/control.go @@ -175,10 +175,16 @@ func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { for i, r := range c.replicas { - if r.Mode != types.ERR && r.Address == address { - r.Mode = mode - c.replicas[i] = r - c.backend.SetMode(address, mode) + if r.Address == address { + if r.Mode != types.ERR { + logrus.Infof("Set replica %v to mode %v", address, mode) + r.Mode = mode + c.replicas[i] = r + c.backend.SetMode(address, mode) + } else { + logrus.Infof("Ignore set replica %v to mode %v due to it's ERR", + address, mode) + } } } } From 5ae4378782b7251a5215c5534891219e8ee3c039 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 23 Feb 2017 15:35:51 -0800 Subject: [PATCH 274/357] controller: Monitoring for new replicas --- controller/control.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/control.go b/controller/control.go index aa0beec4..96988173 100644 --- a/controller/control.go +++ b/controller/control.go @@ -120,6 +120,8 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, c.backend.AddBackend(address, newBackend) + go c.monitoring(address, newBackend) + return nil } @@ -226,8 +228,6 @@ func (c *Controller) Start(addresses ...string) error { return err } - go c.monitoring(address, newBackend) - newSize, err := newBackend.Size() if err != nil { return err From 794a9b64f2dda73a3a34bfebe0726bae73097eac Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 23 Feb 2017 14:31:10 -0800 Subject: [PATCH 275/357] controller: Stop monitoring if replica is closed or set in error --- backend/file/file.go | 3 +++ backend/remote/remote.go | 20 ++++++++++++-------- controller/control.go | 2 ++ controller/replicator.go | 4 ++++ types/types.go | 1 + 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/backend/file/file.go b/backend/file/file.go index d0e57a27..3e93358e 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -69,3 +69,6 @@ func (f *Wrapper) GetMonitorChannel() types.MonitorChannel { func (f *Wrapper) PingResponse() error { return nil } + +func (f *Wrapper) StopMonitoring() { +} diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 9fe52fbe..b3462a5f 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -42,6 +42,7 @@ type Remote struct { func (r *Remote) Close() error { logrus.Infof("Closing: %s", r.name) + r.StopMonitoring() return r.doAction("close", "") } @@ -186,8 +187,10 @@ func (rf *Factory) Create(address string) (types.Backend, error) { httpClient: &http.Client{ Timeout: timeout, }, - closeChan: make(chan struct{}, 1), - monitorChan: make(types.MonitorChannel), + // We don't want sender to wait for receiver, because receiver may + // has been already notified + closeChan: make(chan struct{}, 5), + monitorChan: make(types.MonitorChannel, 5), } replica, err := r.info() @@ -216,23 +219,20 @@ func (rf *Factory) Create(address string) (types.Backend, error) { return r, nil } -func (r *Remote) monitorPing(client *rpc.Client) error { +func (r *Remote) monitorPing(client *rpc.Client) { ticker := time.NewTicker(pingInveral) defer ticker.Stop() - //bug here, if replica was marked as ERR in normal situation, this - //thread still won't exit until it failed multiple times of ping - // at least the channel should be closed for { select { case <-r.closeChan: r.monitorChan <- nil - return nil + return case <-ticker.C: if err := client.Ping(); err != nil { client.SetError(err) r.monitorChan <- err - return err + return } } } @@ -241,3 +241,7 @@ func (r *Remote) monitorPing(client *rpc.Client) error { func (r *Remote) GetMonitorChannel() types.MonitorChannel { return r.monitorChan } + +func (r *Remote) StopMonitoring() { + r.closeChan <- struct{}{} +} diff --git a/controller/control.go b/controller/control.go index 96988173..5ddc27d9 100644 --- a/controller/control.go +++ b/controller/control.go @@ -394,9 +394,11 @@ func (c *Controller) monitoring(address string, backend types.Backend) { return } + logrus.Infof("Start monitoring %v", address) err := <-monitorChan if err != nil { logrus.Errorf("Backend %v monitoring failed, mark as ERR: %v", address, err) c.SetReplicaMode(address, types.ERR) } + logrus.Infof("Monitoring stopped %v", address) } diff --git a/controller/replicator.go b/controller/replicator.go index caec866d..9bd17737 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -169,6 +169,10 @@ func (r *replicator) SetMode(address string, mode types.Mode) { } b.mode = mode r.backends[address] = b + if mode == types.ERR { + b.backend.StopMonitoring() + } + r.buildReadWriters() } diff --git a/types/types.go b/types/types.go index 75a60360..0a8dad33 100644 --- a/types/types.go +++ b/types/types.go @@ -34,6 +34,7 @@ type Backend interface { GetRevisionCounter() (int64, error) SetRevisionCounter(counter int64) error GetMonitorChannel() MonitorChannel + StopMonitoring() } type BackendFactory interface { From 3fc6f445e7e7ec729f9e04c9840b4971c32fa92b Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 23 Feb 2017 17:17:46 -0800 Subject: [PATCH 276/357] rpc: Server stop channel needs buffer Otherwise sender will need to wait for receiver --- rpc/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/server.go b/rpc/server.go index 69d997ad..c165669d 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -19,7 +19,7 @@ func NewServer(conn net.Conn, data types.DataProcessor) *Server { return &Server{ wire: NewWire(conn), responses: make(chan *Message, 1024), - done: make(chan struct{}), + done: make(chan struct{}, 5), data: data, } } From 83c5eb15f4ebde1c656ea1ad74256f80f42c1d11 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 23 Feb 2017 20:02:26 -0800 Subject: [PATCH 277/357] controller: Don't wait for backend.Close() The calling is holding the controller lock and blocks all other RW. --- controller/replicator.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controller/replicator.go b/controller/replicator.go index 9bd17737..7e9cc963 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -75,7 +75,8 @@ func (r *replicator) RemoveBackend(address string) { logrus.Infof("Removing backend: %s", address) - backend.backend.Close() + // We cannot wait for it's return because peer may not exists anymore + go backend.backend.Close() delete(r.backends, address) r.buildReadWriters() } From 55cb9212aff65bf55a55a8e970adada68f42e30e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 24 Feb 2017 14:24:08 -0800 Subject: [PATCH 278/357] replica: Protect SetRebuilding() with lock SetRebuilding() need to be protected, and it will change volume.meta, which require protection agains race condition. --- replica/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/replica/server.go b/replica/server.go index 119a4e7f..e542a1f3 100644 --- a/replica/server.go +++ b/replica/server.go @@ -133,6 +133,9 @@ func (s *Server) Status() (State, Info) { } func (s *Server) SetRebuilding(rebuilding bool) error { + s.Lock() + defer s.Unlock() + state, _ := s.Status() // Must be Open/Dirty to set true or must be Rebuilding to set false if (rebuilding && state != Open && state != Dirty) || From 03f0f7c141297825079669841e82b0a21b1d1233 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 24 Feb 2017 15:51:10 -0800 Subject: [PATCH 279/357] replica: Read info with lock --- replica/replica.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/replica/replica.go b/replica/replica.go index fd8c7c7e..6f19d75b 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -364,6 +364,9 @@ func (r *Replica) Info() Info { } func (r *Replica) DisplayChain() ([]string, error) { + r.RLock() + defer r.RUnlock() + result := make([]string, 0, len(r.activeDiskData)) cur := r.info.Head @@ -382,6 +385,9 @@ func (r *Replica) DisplayChain() ([]string, error) { } func (r *Replica) Chain() ([]string, error) { + r.RLock() + defer r.RUnlock() + result := make([]string, 0, len(r.activeDiskData)) cur := r.info.Head @@ -809,6 +815,9 @@ func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { } func (r *Replica) ListDisks() []string { + r.RLock() + defer r.RUnlock() + result := []string{} for disk := range r.diskData { result = append(result, disk) @@ -817,9 +826,22 @@ func (r *Replica) ListDisks() []string { } func (r *Replica) ShowDiskChildrenMap() map[string]map[string]bool { - return r.diskChildrenMap + r.RLock() + defer r.RUnlock() + + result := make(map[string]map[string]bool) + for disk := range r.diskChildrenMap { + result[disk] = make(map[string]bool) + for child := range r.diskChildrenMap[disk] { + result[disk][child] = r.diskChildrenMap[disk][child] + } + } + return result } func (r *Replica) GetRemainSnapshotCounts() int { + r.RLock() + defer r.RUnlock() + return maximumChainLength - len(r.activeDiskData) } From f107fbf0d40a7ef8d82f690c4df51f111df6c15c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 27 Feb 2017 16:35:10 -0800 Subject: [PATCH 280/357] controller: Fix revision counter during rebuild Rebuild mode should be set earlier, otherwise it won't cover preparerebuild process. Also reports error if revision counter errors out. --- controller/rebuild.go | 12 ++++++++---- controller/replicator.go | 16 ++++++++++++---- sync/sync.go | 8 ++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/controller/rebuild.go b/controller/rebuild.go index 87acb312..1b55a917 100644 --- a/controller/rebuild.go +++ b/controller/rebuild.go @@ -47,8 +47,8 @@ func (c *Controller) getCurrentAndRWReplica(address string) (*types.Replica, *ty } func (c *Controller) VerifyRebuildReplica(address string) error { - // Prevent snapshot happenes at the same time, well at least no - // controller involved + // Prevent snapshot happenes at the same time, as well as prevent + // writing from happening since we're updating revision counter c.Lock() defer c.Unlock() @@ -88,7 +88,9 @@ func (c *Controller) VerifyRebuildReplica(address string) error { rwReplica.Address, counter, err) } - c.backend.SetRevisionCounter(address, counter) + if err := c.backend.SetRevisionCounter(address, counter); err != nil { + return fmt.Errorf("Fail to set revision counter for %v: %v", address, err) + } logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) c.setReplicaModeNoLock(address, types.RW) @@ -132,7 +134,9 @@ func (c *Controller) PrepareRebuildReplica(address string) ([]string, error) { c.Lock() defer c.Unlock() - c.backend.SetRevisionCounter(address, 0) + if err := c.backend.SetRevisionCounter(address, 0); err != nil { + return nil, fmt.Errorf("Fail to set revision counter for %v: %v", address, err) + } replica, rwReplica, err := c.getCurrentAndRWReplica(address) if err != nil { diff --git a/controller/replicator.go b/controller/replicator.go index 7e9cc963..3b87db69 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -266,9 +266,13 @@ func (r *replicator) SetRevisionCounter(address string, counter int64) error { return fmt.Errorf("Cannot find backend %v", address) } - logrus.Infof("Setting backend revision counter: %s", address) + if err := backend.backend.SetRevisionCounter(counter); err != nil { + return err + } + + logrus.Infof("Set backend %s revision counter to %v", address, counter) - return backend.backend.SetRevisionCounter(counter) + return nil } func (r *replicator) GetRevisionCounter(address string) (int64, error) { @@ -277,7 +281,11 @@ func (r *replicator) GetRevisionCounter(address string) (int64, error) { return -1, fmt.Errorf("Cannot find backend %v", address) } - logrus.Infof("Getting backend revision counter: %s", address) + counter, err := backend.backend.GetRevisionCounter() + if err != nil { + return 0, err + } + logrus.Infof("Get backend %s revision counter %v", address, counter) - return backend.backend.GetRevisionCounter() + return counter, nil } diff --git a/sync/sync.go b/sync/sync.go index d7c53bac..379c59f2 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -185,6 +185,10 @@ func (t *Task) AddReplica(replica string) error { return err } + if err := toClient.SetRebuilding(true); err != nil { + return err + } + output, err := t.client.PrepareRebuild(rest.EncodeID(replica)) if err != nil { return err @@ -244,10 +248,6 @@ func (t *Task) reloadAndVerify(address string, repClient *replicaClient.ReplicaC } func (t *Task) syncFiles(fromClient *replicaClient.ReplicaClient, toClient *replicaClient.ReplicaClient, disks []string) error { - if err := toClient.SetRebuilding(true); err != nil { - return err - } - // volume head has been synced by PrepareRebuild() for _, disk := range disks { if strings.Contains(disk, "volume-head") { From 0e593d953f3df207f34fdd011868597b4a5f3140 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Tue, 28 Feb 2017 09:46:49 -0800 Subject: [PATCH 281/357] readme: how to use with Rancher --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f0cc366..eb0f6d4c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,62 @@ A microservice that does micro things. `make` -## Running + +## Using Longhorn in Rancher + +You can use Longhorn to provide storage volumes to containers in Rancher. + +### Installation + +1. Make sure you are running Rancher v1.4 or higher. +2. In ADMIN -> Settings, click "Add Catalog": + - Name: `longhorn` + - URL: `https://github.com/rancher/rancher-catalog.git` + - Branch: `longhorn` + - (NOTE: Do not edit `library` catalog) +3. In STACKS → Infrastructure, click "Add from Catalog" +4. Choose "Longhorn" in the catalog, click "View Details" +5. Click "Launch" + +Once Longhorn storage driver is deployed, you can create Longhorn volumes and use them with your containers and services. + + +### Add a Longhorn Volume + +Go to INFRASTRUCTURE -> Storage: you'll see `rancher-longhorn` driver. + +Click "Add Volume" and fill in the "Name" field. + +**NOTE:** Volume names can use latin letters, numbers, `-` and `_`. Do not start or end the name with `-` or `_`. + + +You can also specify volume size (by default it is 10GB) with Driver Options (e.g. Key: `size` Value: `300G`) + +NOTE: volume size is automatically rounded up by 4096 bytes. + + +### Use a Longhorn Volume + +It's important to note, that a Longhorn volume can only be attached to a single host at a time. The volume can be used by multiple containers on the host, though. + +When creating a container or a service, you can specify the volume and the driver to mount into the container. + +For example, if we have created a Longhorn volume named `vol1`, we can use it to create a container: + +Volumes: `vol1:/any/mount/path` +Volume Driver: `rancher-longhorn` + + +### Rancher UI Note: Longhorn Volume components + +Longhorn driver creates and manages `controller` and `replica-` containers enabling the volumes. These will be shown in Rancher UI as part of the volume stacks in a future release. They are currently visible as standalone containers on your hosts. + +When a volume is mounted, a `controller` container is run on the same host as the client container and `replica-XXXX` containers are started. + +When the volume is not used, `replica-XXXX` containers are stopped and the `controller` container is removed. + + +## Running Standalone You can choose either TGT or TCMU frontend. TGT frontend is recommended. TGT can work with majority of the Linux distributions, while TCMU can work with From df147b17ad5fa6fe40d1266885d3a676eb64cd68 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 28 Feb 2017 10:51:24 -0800 Subject: [PATCH 282/357] Update README.md --- README.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index eb0f6d4c..8b7c962a 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,18 @@ -longhorn [![Build Status](https://drone.rancher.io/api/badges/rancher/longhorn/status.svg)](https://drone.rancher.io/rancher/longhorn) +Longhorn [![Build Status](https://drone.rancher.io/api/badges/rancher/longhorn/status.svg)](https://drone.rancher.io/rancher/longhorn) ======== A microservice that does micro things. -## Building - -`make` - - ## Using Longhorn in Rancher -You can use Longhorn to provide storage volumes to containers in Rancher. +Longhorn can provide EBS-style persistent storage to Rancher. It means one volumes can be attached to the different containers, but they cannot be accessed by two containers at the same time. + ### Installation 1. Make sure you are running Rancher v1.4 or higher. + - To work with Rancher, Longhorn requires `iscsiadm` executable on the host. If you don't have `iscsiadm` on the host, you need to install `open-iscsi` package. + - We recommend running Ubuntu 16.04 or later on your hosts. 2. In ADMIN -> Settings, click "Add Catalog": - Name: `longhorn` - URL: `https://github.com/rancher/rancher-catalog.git` @@ -29,23 +27,22 @@ Once Longhorn storage driver is deployed, you can create Longhorn volumes and us ### Add a Longhorn Volume -Go to INFRASTRUCTURE -> Storage: you'll see `rancher-longhorn` driver. - -Click "Add Volume" and fill in the "Name" field. +You don't need to create volume beforehand if you're fine with default volume size (10GB). -**NOTE:** Volume names can use latin letters, numbers, `-` and `_`. Do not start or end the name with `-` or `_`. +Otherwise, go to INFRASTRUCTURE -> Storage: you'll see `rancher-longhorn` driver. +Click "Add Volume" and fill in the "Name" field. -You can also specify volume size (by default it is 10GB) with Driver Options (e.g. Key: `size` Value: `300G`) +Specify volume size with Driver Options (e.g. Key: `size` Value: `300G`) -NOTE: volume size is automatically rounded up by 4096 bytes. +**NOTE:** Volume names can use latin letters, numbers, `-` and `_`. Do not start or end the name with `-` or `_`. ### Use a Longhorn Volume -It's important to note, that a Longhorn volume can only be attached to a single host at a time. The volume can be used by multiple containers on the host, though. +When creating a container or a service, you need to specify the volume name and the volume driver `rancher-longhorn` for the volume. -When creating a container or a service, you can specify the volume and the driver to mount into the container. +If volume wasn't created before, it will be created automatically with size of 10GB. For example, if we have created a Longhorn volume named `vol1`, we can use it to create a container: @@ -62,6 +59,11 @@ When a volume is mounted, a `controller` container is run on the same host as th When the volume is not used, `replica-XXXX` containers are stopped and the `controller` container is removed. +## Building from source code + +`make` + + ## Running Standalone You can choose either TGT or TCMU frontend. TGT frontend is recommended. TGT @@ -123,7 +125,7 @@ docker run --net longhorn-net --privileged -v /dev:/host/dev -v /proc:/host/proc Now you will have device `/dev/longhorn/vol-name`. ## License -Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) +Copyright (c) 2014-2017 [Rancher Labs, Inc.](http://rancher.com) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From c22e27791e8bdc18e8a1507613485da40b681b6d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 28 Feb 2017 11:49:58 -0800 Subject: [PATCH 283/357] Move Rancher related doc to docs/rancher.md --- README.md | 64 ++++++------------------------------------------- docs/rancher.md | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 57 deletions(-) create mode 100644 docs/rancher.md diff --git a/README.md b/README.md index 8b7c962a..6d234be5 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,7 @@ Longhorn [![Build Status](https://drone.rancher.io/api/badges/rancher/longhorn/status.svg)](https://drone.rancher.io/rancher/longhorn) ======== -A microservice that does micro things. - -## Using Longhorn in Rancher - -Longhorn can provide EBS-style persistent storage to Rancher. It means one volumes can be attached to the different containers, but they cannot be accessed by two containers at the same time. - - -### Installation - -1. Make sure you are running Rancher v1.4 or higher. - - To work with Rancher, Longhorn requires `iscsiadm` executable on the host. If you don't have `iscsiadm` on the host, you need to install `open-iscsi` package. - - We recommend running Ubuntu 16.04 or later on your hosts. -2. In ADMIN -> Settings, click "Add Catalog": - - Name: `longhorn` - - URL: `https://github.com/rancher/rancher-catalog.git` - - Branch: `longhorn` - - (NOTE: Do not edit `library` catalog) -3. In STACKS → Infrastructure, click "Add from Catalog" -4. Choose "Longhorn" in the catalog, click "View Details" -5. Click "Launch" - -Once Longhorn storage driver is deployed, you can create Longhorn volumes and use them with your containers and services. - - -### Add a Longhorn Volume - -You don't need to create volume beforehand if you're fine with default volume size (10GB). - -Otherwise, go to INFRASTRUCTURE -> Storage: you'll see `rancher-longhorn` driver. - -Click "Add Volume" and fill in the "Name" field. - -Specify volume size with Driver Options (e.g. Key: `size` Value: `300G`) - -**NOTE:** Volume names can use latin letters, numbers, `-` and `_`. Do not start or end the name with `-` or `_`. - - -### Use a Longhorn Volume - -When creating a container or a service, you need to specify the volume name and the volume driver `rancher-longhorn` for the volume. - -If volume wasn't created before, it will be created automatically with size of 10GB. - -For example, if we have created a Longhorn volume named `vol1`, we can use it to create a container: - -Volumes: `vol1:/any/mount/path` -Volume Driver: `rancher-longhorn` - - -### Rancher UI Note: Longhorn Volume components - -Longhorn driver creates and manages `controller` and `replica-` containers enabling the volumes. These will be shown in Rancher UI as part of the volume stacks in a future release. They are currently visible as standalone containers on your hosts. - -When a volume is mounted, a `controller` container is run on the same host as the client container and `replica-XXXX` containers are started. - -When the volume is not used, `replica-XXXX` containers are stopped and the `controller` container is removed. - +A micro-service block storage solution. ## Building from source code @@ -124,6 +68,12 @@ docker run --net longhorn-net --privileged -v /dev:/host/dev -v /proc:/host/proc ``` Now you will have device `/dev/longhorn/vol-name`. + +## Use Longhorn with container orchestration + +[Use it with Rancher](docs/rancher.md) + + ## License Copyright (c) 2014-2017 [Rancher Labs, Inc.](http://rancher.com) diff --git a/docs/rancher.md b/docs/rancher.md new file mode 100644 index 00000000..6a30b239 --- /dev/null +++ b/docs/rancher.md @@ -0,0 +1,54 @@ +## Using Longhorn in Rancher + +Longhorn can provide EBS-style persistent storage to Rancher. It means one volumes can be attached to the different containers, but they cannot be accessed by two containers at the same time. + + +### Installation + +1. Make sure you are running Rancher v1.4 or higher. + - To work with Rancher, Longhorn requires `iscsiadm` executable on the host. If you don't have `iscsiadm` on the host, you need to install `open-iscsi` package. + - We recommend running Ubuntu 16.04 or later on your hosts. +2. In ADMIN -> Settings, click "Add Catalog": + - Name: `longhorn` + - URL: `https://github.com/rancher/rancher-catalog.git` + - Branch: `longhorn` + - (NOTE: Do not edit `library` catalog) +3. In STACKS → Infrastructure, click "Add from Catalog" +4. Choose "Longhorn" in the catalog, click "View Details" +5. Click "Launch" + +Once Longhorn storage driver is deployed, you can create Longhorn volumes and use them with your containers and services. + + +### Add a Longhorn Volume + +You don't need to create volume beforehand if you're fine with default volume size (10GB). + +Otherwise, go to INFRASTRUCTURE -> Storage: you'll see `rancher-longhorn` driver. + +Click "Add Volume" and fill in the "Name" field. + +Specify volume size with Driver Options (e.g. Key: `size` Value: `300G`) + +**NOTE:** Volume names can use latin letters, numbers, `-` and `_`. Do not start or end the name with `-` or `_`. + + +### Use a Longhorn Volume + +When creating a container or a service, you need to specify the volume name and the volume driver `rancher-longhorn` for the volume. + +If volume wasn't created before, it will be created automatically with size of 10GB. + +For example, if we have created a Longhorn volume named `vol1`, we can use it to create a container: + +Volumes: `vol1:/any/mount/path` +Volume Driver: `rancher-longhorn` + + +### Rancher UI Note: Longhorn Volume components + +Longhorn driver creates and manages `controller` and `replica-` containers enabling the volumes. These will be shown in Rancher UI as part of the volume stacks in a future release. They are currently visible as standalone containers on your hosts. + +When a volume is mounted, a `controller` container is run on the same host as the client container and `replica-XXXX` containers are started. + +When the volume is not used, `replica-XXXX` containers are stopped and the `controller` container is removed. From 0cb5c36e0bbe23b8cd622002c06f6556a3bfd04a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Mar 2017 13:36:48 -0800 Subject: [PATCH 284/357] replica: Doesn't allow empty snapshot name Snapshot name should be passed in by controller, and consistent across different replicas. --- replica/rest/replica.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/replica/rest/replica.go b/replica/rest/replica.go index ba67714a..f0681cad 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -1,6 +1,7 @@ package rest import ( + "fmt" "io" "net/http" "strconv" @@ -8,7 +9,6 @@ import ( "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" - "github.com/rancher/longhorn/util" ) func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { @@ -118,7 +118,7 @@ func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) erro name := input.Name if name == "" { - name = util.UUID() + return fmt.Errorf("Cannot accept empty snapshot name") } return s.doOp(req, s.s.Snapshot(name)) From 1f5dab55a3987ad5e1699802b0717831aa265b40 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Mar 2017 13:55:16 -0800 Subject: [PATCH 285/357] replica: Rename disk.name to disk.Name --- replica/backup.go | 2 +- replica/replica.go | 30 +++++++++++----------- replica/replica_test.go | 56 ++++++++++++++++++++--------------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/replica/backup.go b/replica/backup.go index 5ee903e1..6be3c024 100644 --- a/replica/backup.go +++ b/replica/backup.go @@ -168,7 +168,7 @@ func (rb *Backup) findIndex(id string) int { if i == 0 { continue } - if disk.name == id { + if disk.Name == id { return i } } diff --git a/replica/replica.go b/replica/replica.go index 6f19d75b..dc34bf3a 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -58,7 +58,7 @@ type Info struct { } type disk struct { - name string + Name string Parent string Removed bool } @@ -178,10 +178,10 @@ func (r *Replica) insertBackingFile() { return } - d := disk{name: r.info.BackingFile.Name} + d := disk{Name: r.info.BackingFile.Name} r.activeDiskData = append([]*disk{{}, &d}, r.activeDiskData[1:]...) r.volume.files = append([]types.DiffDisk{nil, r.info.BackingFile.Disk}, r.volume.files[1:]...) - r.diskData[d.name] = &d + r.diskData[d.Name] = &d } func (r *Replica) SetRebuilding(rebuilding bool) error { @@ -207,7 +207,7 @@ func (r *Replica) findDisk(name string) int { if i == 0 { continue } - if d.name == name { + if d.Name == name { return i } } @@ -305,7 +305,7 @@ func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) return nil, fmt.Errorf("Can not find snapshot %v's parent %v", disk, data.Parent) } if parentData.Removed { - targetDisks = append(targetDisks, parentData.name) + targetDisks = append(targetDisks, parentData.Name) } } targetDisks = append(targetDisks, disk) @@ -484,7 +484,7 @@ func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, e return nil, disk{}, err } - newDisk := disk{Parent: parent, name: newHeadName, Removed: false} + newDisk := disk{Parent: parent, Name: newHeadName, Removed: false} err = r.encodeToFile(&newDisk, newHeadName+metadataSuffix) return f, newDisk, err } @@ -550,7 +550,7 @@ func (r *Replica) revertDisk(parent string) (*Replica, error) { defer f.Close() info := r.info - info.Head = newHeadDisk.name + info.Head = newHeadDisk.Name info.Dirty = true info.Parent = newHeadDisk.Parent @@ -592,7 +592,7 @@ func (r *Replica) createDisk(name string) error { } defer func() { if !done { - r.rmDisk(newHeadDisk.name) + r.rmDisk(newHeadDisk.Name) r.rmDisk(newHeadDisk.Parent) f.Close() return @@ -605,7 +605,7 @@ func (r *Replica) createDisk(name string) error { } info := r.info - info.Head = newHeadDisk.name + info.Head = newHeadDisk.Name info.Dirty = true info.Parent = newHeadDisk.Parent @@ -614,13 +614,13 @@ func (r *Replica) createDisk(name string) error { } done = true - r.diskData[newHeadDisk.name] = &newHeadDisk + r.diskData[newHeadDisk.Name] = &newHeadDisk if newHeadDisk.Parent != "" { - r.addChildDisk(newHeadDisk.Parent, newHeadDisk.name) + r.addChildDisk(newHeadDisk.Parent, newHeadDisk.Name) r.diskData[newHeadDisk.Parent] = r.diskData[oldHead] r.updateChildDisk(oldHead, newHeadDisk.Parent) - r.activeDiskData[len(r.activeDiskData)-1].name = newHeadDisk.Parent + r.activeDiskData[len(r.activeDiskData)-1].Name = newHeadDisk.Parent } delete(r.diskData, oldHead) @@ -672,7 +672,7 @@ func (r *Replica) updateParentDisk(name, oldParent string) error { child.Parent = "" } r.diskData[name] = child - return r.encodeToFile(child, child.name+metadataSuffix) + return r.encodeToFile(child, child.Name+metadataSuffix) } func (r *Replica) openLiveChain() error { @@ -733,10 +733,10 @@ func (r *Replica) readDiskData(file string) error { } name := file[:len(file)-len(metadataSuffix)] - data.name = name + data.Name = name r.diskData[name] = &data if data.Parent != "" { - r.addChildDisk(data.Parent, data.name) + r.addChildDisk(data.Parent, data.Name) } return nil } diff --git a/replica/replica_test.go b/replica/replica_test.go index ca07e00b..465efa40 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -52,11 +52,11 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(len(r.volume.files), Equals, 4) c.Assert(r.info.Head, Equals, "volume-head-002.img") - c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 3) @@ -199,13 +199,13 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(len(r.volume.files), Equals, 5) c.Assert(r.info.Head, Equals, "volume-head-003.img") - c.Assert(r.activeDiskData[4].name, Equals, "volume-head-003.img") + c.Assert(r.activeDiskData[4].Name, Equals, "volume-head-003.img") c.Assert(r.activeDiskData[4].Parent, Equals, "volume-snap-002.img") - c.Assert(r.activeDiskData[3].name, Equals, "volume-snap-002.img") + c.Assert(r.activeDiskData[3].Name, Equals, "volume-snap-002.img") c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 4) @@ -270,11 +270,11 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(len(r.volume.files), Equals, 4) c.Assert(r.info.Head, Equals, "volume-head-002.img") - c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") err = r.RemoveDiffDisk("volume-snap-000.img") @@ -282,9 +282,9 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) c.Assert(r.info.Head, Equals, "volume-head-002.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 2) @@ -315,11 +315,11 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(len(r.volume.files), Equals, 4) c.Assert(r.info.Head, Equals, "volume-head-002.img") - c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") err = r.RemoveDiffDisk("volume-snap-001.img") @@ -327,9 +327,9 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) c.Assert(r.info.Head, Equals, "volume-head-002.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 2) @@ -360,11 +360,11 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(len(r.volume.files), Equals, 4) c.Assert(r.info.Head, Equals, "volume-head-002.img") - c.Assert(r.activeDiskData[3].name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") err = r.RemoveDiffDisk("volume-head-002.img") @@ -393,13 +393,13 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(len(r.volume.files), Equals, 5) c.Assert(r.info.Head, Equals, "volume-head-003.img") - c.Assert(r.activeDiskData[4].name, Equals, "volume-head-003.img") + c.Assert(r.activeDiskData[4].Name, Equals, "volume-head-003.img") c.Assert(r.activeDiskData[4].Parent, Equals, "volume-snap-002.img") - c.Assert(r.activeDiskData[3].name, Equals, "volume-snap-002.img") + c.Assert(r.activeDiskData[3].Name, Equals, "volume-snap-002.img") c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") r, err = r.Revert("volume-snap-000.img") @@ -407,9 +407,9 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) c.Assert(r.info.Head, Equals, "volume-head-004.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-head-004.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-head-004.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 4) @@ -430,9 +430,9 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) c.Assert(r.info.Head, Equals, "volume-head-004.img") - c.Assert(r.activeDiskData[2].name, Equals, "volume-head-004.img") + c.Assert(r.activeDiskData[2].Name, Equals, "volume-head-004.img") c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") - c.Assert(r.activeDiskData[1].name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 3) From 2eed893e6ac5d9c083676aea49b2f899d6cf3017 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Mar 2017 16:57:43 -0800 Subject: [PATCH 286/357] controller: Update backend.doAction() to accept a interface rather than name --- backend/remote/remote.go | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/backend/remote/remote.go b/backend/remote/remote.go index b3462a5f..06fae813 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -43,24 +43,24 @@ type Remote struct { func (r *Remote) Close() error { logrus.Infof("Closing: %s", r.name) r.StopMonitoring() - return r.doAction("close", "") + return r.doAction("close", nil) } func (r *Remote) open() error { logrus.Infof("Opening: %s", r.name) - return r.doAction("open", "") + return r.doAction("open", nil) } func (r *Remote) Snapshot(name string) error { logrus.Infof("Snapshot: %s %s", r.name, name) - return r.doAction("snapshot", name) + return r.doAction("snapshot", &map[string]string{"name": name}) } -func (r *Remote) doAction(action, name string) error { +func (r *Remote) doAction(action string, obj interface{}) error { body := io.Reader(nil) - if name != "" { + if obj != nil { buffer := &bytes.Buffer{} - if err := json.NewEncoder(buffer).Encode(&map[string]string{"name": name}); err != nil { + if err := json.NewEncoder(buffer).Encode(obj); err != nil { return err } body = buffer @@ -71,7 +71,7 @@ func (r *Remote) doAction(action, name string) error { return err } - if name != "" { + if obj != nil { req.Header.Add("Content-Type", "application/json") } @@ -127,28 +127,8 @@ func (r *Remote) GetRevisionCounter() (int64, error) { } func (r *Remote) SetRevisionCounter(counter int64) error { - body := &bytes.Buffer{} - if err := json.NewEncoder(body).Encode(&map[string]int64{"counter": counter}); err != nil { - return err - } - - req, err := http.NewRequest("POST", r.replicaURL+"?action=setrevisioncounter", body) - if err != nil { - return err - } - req.Header.Add("Content-Type", "application/json") - - resp, err := r.httpClient.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("Bad status: %d %s", resp.StatusCode, resp.Status) - } - - return nil + logrus.Infof("Set revision counter of %s to : %v", r.name, counter) + return r.doAction("setrevisioncounter", &map[string]int64{"counter": counter}) } func (r *Remote) info() (rest.Replica, error) { From eba4a934a4ce55528dae38017474a26b8a877e8c Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Mar 2017 17:41:02 -0800 Subject: [PATCH 287/357] controller: Protect BackendError map with a lock The map is going to be accessed concurrently. --- controller/replicator.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/replicator.go b/controller/replicator.go index 3b87db69..96915386 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -178,6 +178,7 @@ func (r *replicator) SetMode(address string, mode types.Mode) { } func (r *replicator) Snapshot(name string) error { + retErrorLock := sync.Mutex{} retError := &BackendError{ Errors: map[string]error{}, } @@ -188,7 +189,9 @@ func (r *replicator) Snapshot(name string) error { wg.Add(1) go func(address string, backend types.Backend) { if err := backend.Snapshot(name); err != nil { + retErrorLock.Lock() retError.Errors[address] = err + retErrorLock.Unlock() } wg.Done() }(addr, backend.backend) From 5b976be1677e1b38405cae92d6104dce0adb8eca Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Mar 2017 19:26:42 -0800 Subject: [PATCH 288/357] replica: Code cleanup --- replica/replica.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index dc34bf3a..c84deb27 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -593,21 +593,21 @@ func (r *Replica) createDisk(name string) error { defer func() { if !done { r.rmDisk(newHeadDisk.Name) - r.rmDisk(newHeadDisk.Parent) + r.rmDisk(newSnapName) f.Close() return } r.rmDisk(oldHead) }() - if err := r.linkDisk(r.info.Head, newHeadDisk.Parent); err != nil { + if err := r.linkDisk(r.info.Head, newSnapName); err != nil { return err } info := r.info info.Head = newHeadDisk.Name info.Dirty = true - info.Parent = newHeadDisk.Parent + info.Parent = newSnapName if err := r.encodeToFile(&info, volumeMetaData); err != nil { return err @@ -615,12 +615,12 @@ func (r *Replica) createDisk(name string) error { done = true r.diskData[newHeadDisk.Name] = &newHeadDisk - if newHeadDisk.Parent != "" { - r.addChildDisk(newHeadDisk.Parent, newHeadDisk.Name) + if newSnapName != "" { + r.addChildDisk(newSnapName, newHeadDisk.Name) - r.diskData[newHeadDisk.Parent] = r.diskData[oldHead] - r.updateChildDisk(oldHead, newHeadDisk.Parent) - r.activeDiskData[len(r.activeDiskData)-1].Name = newHeadDisk.Parent + r.diskData[newSnapName] = r.diskData[oldHead] + r.updateChildDisk(oldHead, newSnapName) + r.activeDiskData[len(r.activeDiskData)-1].Name = newSnapName } delete(r.diskData, oldHead) From 72588882ff8c30a7b1a7ec96949951bd486dcc76 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 1 Mar 2017 13:33:22 -0800 Subject: [PATCH 289/357] replica: Add `UserCreated` tag to snapshot Some snapshots are generated during the rebuilding process, which is not initiated by the user. We're going to clean up them automatically later. --- backend/file/file.go | 2 +- backend/remote/remote.go | 7 +++-- controller/control.go | 6 ++-- controller/replicator.go | 4 +-- replica/backup_test.go | 6 ++-- replica/replica.go | 23 +++++++++------ replica/replica_test.go | 64 +++++++++++++++++++++++----------------- replica/rest/model.go | 3 +- replica/rest/replica.go | 2 +- replica/server.go | 6 ++-- types/types.go | 2 +- 11 files changed, 71 insertions(+), 54 deletions(-) diff --git a/backend/file/file.go b/backend/file/file.go index 3e93358e..e4982525 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -23,7 +23,7 @@ func (f *Wrapper) Close() error { return f.File.Close() } -func (f *Wrapper) Snapshot(name string) error { +func (f *Wrapper) Snapshot(name string, userCreated bool) error { return nil } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 06fae813..671e438c 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -51,9 +51,10 @@ func (r *Remote) open() error { return r.doAction("open", nil) } -func (r *Remote) Snapshot(name string) error { - logrus.Infof("Snapshot: %s %s", r.name, name) - return r.doAction("snapshot", &map[string]string{"name": name}) +func (r *Remote) Snapshot(name string, userCreated bool) error { + logrus.Infof("Snapshot: %s %s UserCreated %v", r.name, name, userCreated) + return r.doAction("snapshot", + &map[string]interface{}{"name": name, "usercreated": userCreated}) } func (r *Remote) doAction(action string, obj interface{}) error { diff --git a/controller/control.go b/controller/control.go index 5ddc27d9..3e5477ea 100644 --- a/controller/control.go +++ b/controller/control.go @@ -86,7 +86,7 @@ func (c *Controller) Snapshot(name string) (string, error) { return "", fmt.Errorf("Too many snapshots created") } - return name, c.handleErrorNoLock(c.backend.Snapshot(name)) + return name, c.handleErrorNoLock(c.backend.Snapshot(name, true)) } func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { @@ -103,11 +103,11 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, return fmt.Errorf("Too many snapshots created") } - if err := c.backend.Snapshot(uuid); err != nil { + if err := c.backend.Snapshot(uuid, false); err != nil { newBackend.Close() return err } - if err := newBackend.Snapshot(uuid); err != nil { + if err := newBackend.Snapshot(uuid, false); err != nil { newBackend.Close() return err } diff --git a/controller/replicator.go b/controller/replicator.go index 96915386..ead94a11 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -177,7 +177,7 @@ func (r *replicator) SetMode(address string, mode types.Mode) { r.buildReadWriters() } -func (r *replicator) Snapshot(name string) error { +func (r *replicator) Snapshot(name string, userCreated bool) error { retErrorLock := sync.Mutex{} retError := &BackendError{ Errors: map[string]error{}, @@ -188,7 +188,7 @@ func (r *replicator) Snapshot(name string) error { if backend.mode != types.ERR { wg.Add(1) go func(address string, backend types.Backend) { - if err := backend.Snapshot(name); err != nil { + if err := backend.Snapshot(name, userCreated); err != nil { retErrorLock.Lock() retError.Errors[address] = err retErrorLock.Unlock() diff --git a/replica/backup_test.go b/replica/backup_test.go index 683a8aad..191f9949 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -98,7 +98,7 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { fill(buf, 1) _, err = r.WriteAt(buf, mb) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) fill(buf, 2) @@ -106,7 +106,7 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(err, IsNil) _, err = r.WriteAt(buf, 4*mb) c.Assert(err, IsNil) - err = r.Snapshot("002") + err = r.Snapshot("002", true) c.Assert(err, IsNil) fill(buf, 3) @@ -114,7 +114,7 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(err, IsNil) _, err = r.WriteAt(buf, 8*mb) c.Assert(err, IsNil) - err = r.Snapshot("003") + err = r.Snapshot("003", true) c.Assert(err, IsNil) buf = make([]byte, 10*mb) diff --git a/replica/replica.go b/replica/replica.go index c84deb27..14d151d4 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -58,9 +58,10 @@ type Info struct { } type disk struct { - Name string - Parent string - Removed bool + Name string + Parent string + Removed bool + UserCreated bool } type BackingFile struct { @@ -153,7 +154,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF } else if size <= 0 { return nil, os.ErrNotExist } else { - if err := r.createDisk("000"); err != nil { + if err := r.createDisk("000", false); err != nil { return nil, err } } @@ -484,7 +485,7 @@ func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, e return nil, disk{}, err } - newDisk := disk{Parent: parent, Name: newHeadName, Removed: false} + newDisk := disk{Parent: parent, Name: newHeadName, Removed: false, UserCreated: false} err = r.encodeToFile(&newDisk, newHeadName+metadataSuffix) return f, newDisk, err } @@ -569,7 +570,7 @@ func (r *Replica) revertDisk(parent string) (*Replica, error) { return rNew, nil } -func (r *Replica) createDisk(name string) error { +func (r *Replica) createDisk(name string, userCreated bool) error { if r.readOnly { return fmt.Errorf("Can not create disk on read-only replica") } @@ -617,8 +618,12 @@ func (r *Replica) createDisk(name string) error { r.diskData[newHeadDisk.Name] = &newHeadDisk if newSnapName != "" { r.addChildDisk(newSnapName, newHeadDisk.Name) - r.diskData[newSnapName] = r.diskData[oldHead] + r.diskData[newSnapName].UserCreated = userCreated + if err := r.encodeToFile(r.diskData[newSnapName], newSnapName+metadataSuffix); err != nil { + return err + } + r.updateChildDisk(oldHead, newSnapName) r.activeDiskData[len(r.activeDiskData)-1].Name = newSnapName } @@ -775,11 +780,11 @@ func (r *Replica) Delete() error { return nil } -func (r *Replica) Snapshot(name string) error { +func (r *Replica) Snapshot(name string, userCreated bool) error { r.Lock() defer r.Unlock() - return r.createDisk(name) + return r.createDisk(name, userCreated) } func (r *Replica) Revert(name string) (*Replica, error) { diff --git a/replica/replica_test.go b/replica/replica_test.go index 465efa40..223df846 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -42,10 +42,10 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -53,16 +53,22 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.info.Head, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[3].Name, Equals, "volume-head-002.img") + c.Assert(r.activeDiskData[3].UserCreated, Equals, false) c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[2].UserCreated, Equals, true) c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[1].UserCreated, Equals, true) c.Assert(r.activeDiskData[1].Parent, Equals, "") c.Assert(len(r.diskData), Equals, 3) c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-000.img"].UserCreated, Equals, true) c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-001.img"].UserCreated, Equals, true) c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(r.diskData["volume-head-002.img"].UserCreated, Equals, false) c.Assert(len(r.diskChildrenMap), Equals, 3) c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 1) @@ -89,10 +95,10 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -126,7 +132,7 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) c.Assert(r.diskChildrenMap["volume-head-003.img"], IsNil) - err = r.Snapshot("003") + err = r.Snapshot("003", true) c.Assert(err, IsNil) c.Assert(len(r.diskData), Equals, 4) @@ -153,9 +159,13 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(len(r.diskData), Equals, 4) c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") + c.Assert(r.diskData["volume-snap-000.img"].UserCreated, Equals, true) c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-001.img"].UserCreated, Equals, true) c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-snap-003.img"].UserCreated, Equals, true) c.Assert(r.diskData["volume-head-005.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(r.diskData["volume-head-005.img"].UserCreated, Equals, false) disks := r.ListDisks() c.Assert(len(disks), Equals, 4) @@ -186,13 +196,13 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) - err = r.Snapshot("002") + err = r.Snapshot("002", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 5) @@ -260,10 +270,10 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -305,10 +315,10 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -350,10 +360,10 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -380,13 +390,13 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) - err = r.Snapshot("002") + err = r.Snapshot("002", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 5) @@ -455,10 +465,10 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -485,7 +495,7 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[1].Source, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Removed, Equals, true) - err = r.Snapshot("002") + err = r.Snapshot("002", true) c.Assert(err, IsNil) /* @@ -508,10 +518,10 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[1].Action, Equals, OpRemove) c.Assert(actions[1].Source, Equals, "volume-snap-001.img") - err = r.Snapshot("003") + err = r.Snapshot("003", true) c.Assert(err, IsNil) - err = r.Snapshot("004") + err = r.Snapshot("004", true) c.Assert(err, IsNil) /* @@ -621,19 +631,19 @@ func (s *TestSuite) TestSnapshotReadWrite(c *C) { count, err := r.WriteAt(buf, 0) c.Assert(err, IsNil) c.Assert(count, Equals, 3*b) - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) fill(buf[b:2*b], 2) count, err = r.WriteAt(buf[b:2*b], b) c.Assert(count, Equals, b) - err = r.Snapshot("001") + err = r.Snapshot("001", true) c.Assert(err, IsNil) fill(buf[:b], 1) count, err = r.WriteAt(buf[:b], 0) c.Assert(count, Equals, b) - err = r.Snapshot("002") + err = r.Snapshot("002", true) c.Assert(err, IsNil) readBuf := make([]byte, 3*b) @@ -712,7 +722,7 @@ func (s *TestSuite) partialWriteRead(c *C, totalLength, writeLength, writeOffset _, err = r.WriteAt(buf, 0) c.Assert(err, IsNil) - err = r.Snapshot("000") + err = r.Snapshot("000", true) c.Assert(err, IsNil) buf = make([]byte, writeLength) @@ -760,7 +770,7 @@ func (s *TestSuite) testPartialRead(c *C, totalLength int64, readBuf []byte, off for i := int64(0); i < totalLength; i += b { buf := make([]byte, totalLength-i) fill(buf, byte(i/b+1)) - err := r.Snapshot(strconv.Itoa(int(i))) + err := r.Snapshot(strconv.Itoa(int(i)), true) c.Assert(err, IsNil) _, err = r.WriteAt(buf, i) c.Assert(err, IsNil) diff --git a/replica/rest/model.go b/replica/rest/model.go index 8a2f3e03..a5026b6b 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -41,7 +41,8 @@ type RebuildingInput struct { type SnapshotInput struct { client.Resource - Name string `json:"Name"` + Name string `json:"name"` + UserCreated bool `json:"usercreated"` } type RemoveDiskInput struct { diff --git a/replica/rest/replica.go b/replica/rest/replica.go index f0681cad..17755172 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -121,7 +121,7 @@ func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) erro return fmt.Errorf("Cannot accept empty snapshot name") } - return s.doOp(req, s.s.Snapshot(name)) + return s.doOp(req, s.s.Snapshot(name, input.UserCreated)) } func (s *Server) RevertReplica(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/server.go b/replica/server.go index e542a1f3..36553088 100644 --- a/replica/server.go +++ b/replica/server.go @@ -168,7 +168,7 @@ func (s *Server) Revert(name string) error { return nil } -func (s *Server) Snapshot(name string) error { +func (s *Server) Snapshot(name string, userCreated bool) error { s.Lock() defer s.Unlock() @@ -176,8 +176,8 @@ func (s *Server) Snapshot(name string) error { return nil } - logrus.Infof("Snapshotting [%s] volume", name) - return s.r.Snapshot(name) + logrus.Infof("Snapshotting [%s] volume, user created %v", name, userCreated) + return s.r.Snapshot(name, userCreated) } func (s *Server) RemoveDiffDisk(name string) error { diff --git a/types/types.go b/types/types.go index 0a8dad33..8fcdacea 100644 --- a/types/types.go +++ b/types/types.go @@ -27,7 +27,7 @@ type MonitorChannel chan error type Backend interface { ReaderWriterAt io.Closer - Snapshot(name string) error + Snapshot(name string, userCreated bool) error Size() (int64, error) SectorSize() (int64, error) RemainSnapshots() (int, error) From d1aa2ab19218d51221a8e6bf6965310a8f7f23cc Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Mar 2017 11:13:58 -0800 Subject: [PATCH 290/357] cli: Only show snapshot of RW replicas If we merge the result of RW and WO replicas, we will only have the snapshots after rebuild starting, which is really weird. During rebuild process, we can only create snapshot. We cannot remove snapshot or revert to snapshot. So the list of snapshot can be used for backup purpose only - the backup should goes to RW replica in this case. --- app/snapshot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/snapshot.go b/app/snapshot.go index 00e11932..2609115c 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -134,7 +134,7 @@ func lsSnapshot(c *cli.Context) error { first := true snapshots := []string{} for _, r := range replicas { - if r.Mode == "ERR" { + if r.Mode != "RW" { continue } From 52f233e3e57bcdc039457ea7523aa3d1882b0e0d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Mar 2017 16:28:43 -0800 Subject: [PATCH 291/357] replica: Merge replica.DiskChildrenMap into replica.Disks for GetReplica replica.Disks will show all the status of the disk and relationship between them. --- replica/replica.go | 39 ++++++++++++++++++++++----------------- replica/replica_test.go | 31 +++++++++++++++++++++---------- replica/rest/model.go | 24 +++++++++++------------- 3 files changed, 54 insertions(+), 40 deletions(-) diff --git a/replica/replica.go b/replica/replica.go index 14d151d4..9f28a2f8 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -77,6 +77,14 @@ type PrepareRemoveAction struct { Target string `json:"target"` } +type DiskInfo struct { + Name string `json:"name"` + Parent string `json:"parent"` + Children []string `json:"children"` + Removed bool `json:"removed"` + UserCreated bool `json:"usercreated"` +} + const ( OpCoalesce = "coalesce" // Source is parent, target is child OpRemove = "remove" @@ -819,27 +827,24 @@ func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { return c, err } -func (r *Replica) ListDisks() []string { - r.RLock() - defer r.RUnlock() - - result := []string{} - for disk := range r.diskData { - result = append(result, disk) - } - return result -} - -func (r *Replica) ShowDiskChildrenMap() map[string]map[string]bool { +func (r *Replica) ListDisks() map[string]DiskInfo { r.RLock() defer r.RUnlock() - result := make(map[string]map[string]bool) - for disk := range r.diskChildrenMap { - result[disk] = make(map[string]bool) - for child := range r.diskChildrenMap[disk] { - result[disk][child] = r.diskChildrenMap[disk][child] + result := map[string]DiskInfo{} + for _, disk := range r.diskData { + diskInfo := DiskInfo{ + Name: disk.Name, + Parent: disk.Parent, + Removed: disk.Removed, + UserCreated: disk.UserCreated, + } + children := []string{} + for child := range r.diskChildrenMap[disk.Name] { + children = append(children, child) } + diskInfo.Children = children + result[disk.Name] = diskInfo } return result } diff --git a/replica/replica_test.go b/replica/replica_test.go index 223df846..16fe9111 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -77,13 +77,24 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.diskChildrenMap["volume-snap-001.img"]["volume-head-002.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) - dcm := r.ShowDiskChildrenMap() - c.Assert(len(dcm), Equals, 3) - c.Assert(len(dcm["volume-snap-000.img"]), Equals, 1) - c.Assert(dcm["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) - c.Assert(len(dcm["volume-snap-001.img"]), Equals, 1) - c.Assert(dcm["volume-snap-001.img"]["volume-head-002.img"], Equals, true) - c.Assert(dcm["volume-head-002.img"], IsNil) + disks := r.ListDisks() + c.Assert(len(disks), Equals, 3) + c.Assert(disks["volume-snap-000.img"].Parent, Equals, "") + c.Assert(disks["volume-snap-000.img"].UserCreated, Equals, true) + c.Assert(disks["volume-snap-000.img"].Removed, Equals, false) + c.Assert(len(disks["volume-snap-000.img"].Children), Equals, 1) + c.Assert(disks["volume-snap-000.img"].Children[0], Equals, "volume-snap-001.img") + + c.Assert(disks["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(disks["volume-snap-001.img"].UserCreated, Equals, true) + c.Assert(disks["volume-snap-001.img"].Removed, Equals, false) + c.Assert(len(disks["volume-snap-001.img"].Children), Equals, 1) + c.Assert(disks["volume-snap-001.img"].Children[0], Equals, "volume-head-002.img") + + c.Assert(disks["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") + c.Assert(disks["volume-head-002.img"].UserCreated, Equals, false) + c.Assert(disks["volume-head-002.img"].Removed, Equals, false) + c.Assert(len(disks["volume-head-002.img"].Children), Equals, 0) } func (s *TestSuite) TestRevert(c *C) { @@ -175,11 +186,11 @@ func (s *TestSuite) TestRevert(c *C) { "volume-snap-003.img": false, "volume-head-005.img": false, } - for _, disk := range disks { - value, exists := verifyDisks[disk] + for name := range disks { + value, exists := verifyDisks[name] c.Assert(exists, Equals, true) c.Assert(value, Equals, false) - verifyDisks[disk] = true + verifyDisks[name] = true } c.Assert(len(r.diskChildrenMap["volume-snap-001.img"]), Equals, 1) diff --git a/replica/rest/model.go b/replica/rest/model.go index a5026b6b..a7b572d8 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -10,18 +10,17 @@ import ( type Replica struct { client.Resource - Dirty bool `json:"dirty"` - Rebuilding bool `json:"rebuilding"` - Head string `json:"head"` - Parent string `json:"parent"` - Size string `json:"size"` - SectorSize int64 `json:"sectorSize"` - State string `json:"state"` - Chain []string `json:"chain"` - Disks []string `json:"disks"` - DiskChildrenMap map[string]map[string]bool `json:"diskchildrenmap"` - RemainSnapshots int `json:"remainsnapshots"` - RevisionCounter int64 `json:"revisioncounter"` + Dirty bool `json:"dirty"` + Rebuilding bool `json:"rebuilding"` + Head string `json:"head"` + Parent string `json:"parent"` + Size string `json:"size"` + SectorSize int64 `json:"sectorSize"` + State string `json:"state"` + Chain []string `json:"chain"` + Disks map[string]replica.DiskInfo `json:"disks"` + RemainSnapshots int `json:"remainsnapshots"` + RevisionCounter int64 `json:"revisioncounter"` } type CreateInput struct { @@ -126,7 +125,6 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, if rep != nil { r.Chain, _ = rep.DisplayChain() r.Disks = rep.ListDisks() - r.DiskChildrenMap = rep.ShowDiskChildrenMap() r.RemainSnapshots = rep.GetRemainSnapshotCounts() r.RevisionCounter = rep.GetRevisionCounter() } From f64d00262c2b78082faba6e30a537ba1488187cd Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Mar 2017 10:47:27 -0800 Subject: [PATCH 292/357] cli: Show snapshot details --- app/snapshot.go | 97 ++++++++++++++++++++++++++++++++++++ integration/core/test_cli.py | 39 +++++++++++++++ replica/replica.go | 24 ++++++++- 3 files changed, 158 insertions(+), 2 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index 2609115c..7fd598be 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -1,6 +1,7 @@ package app import ( + "encoding/json" "fmt" "os" "strings" @@ -8,6 +9,8 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/rancher/longhorn/replica" + replicaClient "github.com/rancher/longhorn/replica/client" "github.com/rancher/longhorn/sync" "github.com/rancher/longhorn/util" ) @@ -21,6 +24,7 @@ func SnapshotCmd() cli.Command { SnapshotRevertCmd(), SnapshotLsCmd(), SnapshotRmCmd(), + SnapshotDetailCmd(), }, Action: func(c *cli.Context) { if err := lsSnapshot(c); err != nil { @@ -74,6 +78,17 @@ func SnapshotLsCmd() cli.Command { } } +func SnapshotDetailCmd() cli.Command { + return cli.Command{ + Name: "detail", + Action: func(c *cli.Context) { + if err := detailSnapshot(c); err != nil { + logrus.Fatalf("Error running detail snapshot command: %v", err) + } + }, + } +} + func createSnapshot(c *cli.Context) error { cli := getCli(c) @@ -174,3 +189,85 @@ func lsSnapshot(c *cli.Context) error { return nil } + +func detailSnapshot(c *cli.Context) error { + var output []byte + + outputDisks := make(map[string]replica.DiskInfo) + cli := getCli(c) + + replicas, err := cli.ListReplicas() + if err != nil { + return err + } + + for _, r := range replicas { + if r.Mode != "RW" { + continue + } + + disks, err := getDisks(r.Address) + if err != nil { + return err + } + + for name, disk := range disks { + if replica.IsHeadDisk(name) { + continue + } + snapshot, err := replica.GetSnapshotNameFromDiskName(name) + if err != nil { + return err + } + children := []string{} + for _, childDisk := range disk.Children { + if !replica.IsHeadDisk(childDisk) { + child, err := replica.GetSnapshotNameFromDiskName(childDisk) + if err != nil { + return err + } + children = append(children, child) + } + } + parent := "" + if disk.Parent != "" { + parent, err = replica.GetSnapshotNameFromDiskName(disk.Parent) + if err != nil { + return err + } + } + outputDisks[snapshot] = replica.DiskInfo{ + Name: snapshot, + Parent: parent, + Removed: disk.Removed, + UserCreated: disk.UserCreated, + Children: children, + } + } + + output, err = json.MarshalIndent(outputDisks, "", "\t") + if err != nil { + return err + } + } + + if output == nil { + return fmt.Errorf("Cannot find suitable replica for snapshot details") + } + fmt.Println(string(output)) + return nil +} + +func getDisks(address string) (map[string]replica.DiskInfo, error) { + repClient, err := replicaClient.NewReplicaClient(address) + if err != nil { + return nil, err + } + + r, err := repClient.GetReplica() + if err != nil { + return nil, err + } + + return r.Disks, err +} diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index fd69ec22..fe4935b2 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -318,6 +318,45 @@ def test_snapshot_ls(bin, controller_client, replica_client, replica_client2): '''.format(snap2.id, snap.id) +def test_snapshot_detail(bin, controller_client, + replica_client, replica_client2): + open_replica(replica_client) + open_replica(replica_client2) + + v = controller_client.list_volume()[0] + v = v.start(replicas=[ + REPLICA, + REPLICA2, + ]) + assert v.replicaCount == 2 + + snap = v.snapshot() + assert snap.id != '' + + snap2 = v.snapshot() + assert snap2.id != '' + + cmd = [bin, '--debug', 'snapshot', 'detail'] + output = subprocess.check_output(cmd) + details = json.loads(output) + + assert len(details) == 2 + + snap2_details = details[snap2.id] + assert snap2_details["name"] == snap2.id + assert snap2_details["parent"] == snap.id + assert snap2_details["children"] == [] + assert snap2_details["removed"] is False + assert snap2_details["usercreated"] is True + + snap_details = details[snap.id] + assert snap_details["name"] == snap.id + assert snap_details["parent"] == "" + assert snap_details["children"] == [snap2.id] + assert snap_details["removed"] is False + assert snap_details["usercreated"] is True + + def test_snapshot_create(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) diff --git a/replica/replica.go b/replica/replica.go index 9f28a2f8..a201daae 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -22,8 +22,12 @@ const ( imgSuffix = ".img" volumeMetaData = "volume.meta" defaultSectorSize = 4096 - headName = "volume-head-%03d.img" - diskName = "volume-snap-%s.img" + headPrefix = "volume-head-" + headSuffix = ".img" + headName = headPrefix + "%03d" + headSuffix + diskPrefix = "volume-snap-" + diskSuffix = ".img" + diskName = diskPrefix + "%s" + diskSuffix maximumChainLength = 250 ) @@ -178,6 +182,22 @@ func GenerateSnapshotDiskName(name string) string { return fmt.Sprintf(diskName, name) } +func GetSnapshotNameFromDiskName(diskName string) (string, error) { + if !strings.HasPrefix(diskName, diskPrefix) || !strings.HasSuffix(diskName, diskSuffix) { + return "", fmt.Errorf("Invalid snapshot disk name %v", diskName) + } + result := strings.TrimPrefix(diskName, diskPrefix) + result = strings.TrimSuffix(result, diskSuffix) + return result, nil +} + +func IsHeadDisk(diskName string) bool { + if strings.HasPrefix(diskName, headPrefix) && strings.HasSuffix(diskName, headSuffix) { + return true + } + return false +} + func (r *Replica) diskPath(name string) string { return path.Join(r.dir, name) } From 8a948fe6fd61fb9b331b126b33277110656e0a86 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 2 Mar 2017 19:58:00 -0800 Subject: [PATCH 293/357] test: Add test case for UserCreated tag --- integration/core/test_cli.py | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index fe4935b2..cc62b8e6 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -134,10 +134,12 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, open_replica(replica_client) open_replica(replica_client2) + snap0 = "000" + snap1 = "001" r = replica_client.list_replica()[0] r = r.open() - r = r.snapshot(name='000') - r = r.snapshot(name='001') + r = r.snapshot(name=snap0) + r = r.snapshot(name=snap1, usercreated=True) l = replica_client2.list_replica()[0] @@ -168,6 +170,38 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, for r in replicas: assert r.mode == 'RW' + cmd = [bin, '--debug', 'snapshot', 'detail'] + output = subprocess.check_output(cmd) + details = json.loads(output) + + # two existing snapshots and one system snapshot due to rebuild + assert len(details) == 3 + for name in details: + if name != snap0 and name != snap1: + snapreb = name + break + + snapreb_details = details[snapreb] + assert snapreb_details["name"] == snapreb + assert snapreb_details["parent"] == snap1 + assert snapreb_details["children"] == [] + assert snapreb_details["removed"] is False + assert snapreb_details["usercreated"] is False + + snap1_details = details[snap1] + assert snap1_details["name"] == snap1 + assert snap1_details["parent"] == snap0 + assert snap1_details["children"] == [snapreb] + assert snap1_details["removed"] is False + assert snap1_details["usercreated"] is True + + snap0_details = details[snap0] + assert snap0_details["name"] == snap0 + assert snap0_details["parent"] == "" + assert snap0_details["children"] == [snap1] + assert snap0_details["removed"] is False + assert snap0_details["usercreated"] is False + def test_replica_add_after_rebuild_failed(bin, controller_client, replica_client, replica_client2): From e4814b09823631568d1a974d9b4aa7965a749b1a Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 3 Mar 2017 11:02:27 -0800 Subject: [PATCH 294/357] replica: Add `created`(time) field to snapshot The `created` is always set by controller. Also add `created` in `revert` call, since it will create a new head disk. --- app/snapshot.go | 1 + backend/file/file.go | 2 +- backend/remote/remote.go | 11 +++- controller/control.go | 8 ++- controller/replicator.go | 4 +- controller/revert.go | 6 +- integration/core/test_cli.py | 18 +++++- integration/core/test_replica.py | 21 ++++--- replica/backup_test.go | 12 +++- replica/client/client.go | 5 +- replica/replica.go | 33 ++++++---- replica/replica_test.go | 101 +++++++++++++++++++++---------- replica/rest/model.go | 4 +- replica/rest/replica.go | 19 ++++-- replica/server.go | 13 ++-- types/types.go | 2 +- util/util.go | 4 ++ 17 files changed, 181 insertions(+), 83 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index 7fd598be..4058d44d 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -242,6 +242,7 @@ func detailSnapshot(c *cli.Context) error { Removed: disk.Removed, UserCreated: disk.UserCreated, Children: children, + Created: disk.Created, } } diff --git a/backend/file/file.go b/backend/file/file.go index e4982525..7e97c41b 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -23,7 +23,7 @@ func (f *Wrapper) Close() error { return f.File.Close() } -func (f *Wrapper) Snapshot(name string, userCreated bool) error { +func (f *Wrapper) Snapshot(name string, userCreated bool, created string) error { return nil } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 671e438c..3b749e22 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -51,10 +51,15 @@ func (r *Remote) open() error { return r.doAction("open", nil) } -func (r *Remote) Snapshot(name string, userCreated bool) error { - logrus.Infof("Snapshot: %s %s UserCreated %v", r.name, name, userCreated) +func (r *Remote) Snapshot(name string, userCreated bool, created string) error { + logrus.Infof("Snapshot: %s %s UserCreated %v Created at %v", + r.name, name, userCreated, created) return r.doAction("snapshot", - &map[string]interface{}{"name": name, "usercreated": userCreated}) + &map[string]interface{}{ + "name": name, + "usercreated": userCreated, + "created": created, + }) } func (r *Remote) doAction(action string, obj interface{}) error { diff --git a/controller/control.go b/controller/control.go index 3e5477ea..601f7246 100644 --- a/controller/control.go +++ b/controller/control.go @@ -86,7 +86,8 @@ func (c *Controller) Snapshot(name string) (string, error) { return "", fmt.Errorf("Too many snapshots created") } - return name, c.handleErrorNoLock(c.backend.Snapshot(name, true)) + created := util.Now() + return name, c.handleErrorNoLock(c.backend.Snapshot(name, true, created)) } func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { @@ -96,6 +97,7 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, if snapshot { uuid := util.UUID() + created := util.Now() if remain, err := c.backend.RemainSnapshots(); err != nil { return err @@ -103,11 +105,11 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, return fmt.Errorf("Too many snapshots created") } - if err := c.backend.Snapshot(uuid, false); err != nil { + if err := c.backend.Snapshot(uuid, false, created); err != nil { newBackend.Close() return err } - if err := newBackend.Snapshot(uuid, false); err != nil { + if err := newBackend.Snapshot(uuid, false, created); err != nil { newBackend.Close() return err } diff --git a/controller/replicator.go b/controller/replicator.go index ead94a11..1520d450 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -177,7 +177,7 @@ func (r *replicator) SetMode(address string, mode types.Mode) { r.buildReadWriters() } -func (r *replicator) Snapshot(name string, userCreated bool) error { +func (r *replicator) Snapshot(name string, userCreated bool, created string) error { retErrorLock := sync.Mutex{} retError := &BackendError{ Errors: map[string]error{}, @@ -188,7 +188,7 @@ func (r *replicator) Snapshot(name string, userCreated bool) error { if backend.mode != types.ERR { wg.Add(1) go func(address string, backend types.Backend) { - if err := backend.Snapshot(name, userCreated); err != nil { + if err := backend.Snapshot(name, userCreated, created); err != nil { retErrorLock.Lock() retError.Errors[address] = err retErrorLock.Unlock() diff --git a/controller/revert.go b/controller/revert.go index b4519107..8b54f5ee 100644 --- a/controller/revert.go +++ b/controller/revert.go @@ -7,6 +7,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/replica/client" "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" ) func (c *Controller) Revert(name string) error { @@ -42,9 +43,10 @@ func (c *Controller) Revert(name string) error { defer c.Unlock() minimalSuccess := false + now := util.Now() for address, client := range clients { - logrus.Infof("Reverting to snapshot %s on %s", name, address) - if err := client.Revert(name); err != nil { + logrus.Infof("Reverting to snapshot %s on %s at %s", name, address, now) + if err := client.Revert(name, now); err != nil { logrus.Errorf("Error on reverting to %s on %s: %v", name, address, err) c.setReplicaModeNoLock(address, types.ERR) } else { diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index cc62b8e6..319f01e6 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -4,6 +4,7 @@ import os import subprocess import json +import datetime import pytest import cattle @@ -129,6 +130,11 @@ def test_replica_add_start(bin, controller_client, replica_client): assert volume.replicaCount == 1 +def getNow(): + time.sleep(1) + return datetime.datetime.utcnow().replace(microsecond=0).isoformat() + + def test_replica_add_rebuild(bin, controller_client, replica_client, replica_client2): open_replica(replica_client) @@ -138,8 +144,10 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, snap1 = "001" r = replica_client.list_replica()[0] r = r.open() - r = r.snapshot(name=snap0) - r = r.snapshot(name=snap1, usercreated=True) + createtime0 = getNow() + r = r.snapshot(name=snap0, created=createtime0) + createtime1 = getNow() + r = r.snapshot(name=snap1, usercreated=True, created=createtime1) l = replica_client2.list_replica()[0] @@ -194,6 +202,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert snap1_details["children"] == [snapreb] assert snap1_details["removed"] is False assert snap1_details["usercreated"] is True + assert snap1_details["created"] == createtime1 snap0_details = details[snap0] assert snap0_details["name"] == snap0 @@ -201,6 +210,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert snap0_details["children"] == [snap1] assert snap0_details["removed"] is False assert snap0_details["usercreated"] is False + assert snap0_details["created"] == createtime0 def test_replica_add_after_rebuild_failed(bin, controller_client, @@ -210,7 +220,7 @@ def test_replica_add_after_rebuild_failed(bin, controller_client, r = replica_client.list_replica()[0] r = r.open() - r = r.snapshot(name='000') + r = r.snapshot(name='000', created=datetime.datetime.utcnow().isoformat()) r.close() cmd = [bin, '--debug', 'add-replica', REPLICA] @@ -382,6 +392,7 @@ def test_snapshot_detail(bin, controller_client, assert snap2_details["children"] == [] assert snap2_details["removed"] is False assert snap2_details["usercreated"] is True + assert snap2_details["created"] != "" snap_details = details[snap.id] assert snap_details["name"] == snap.id @@ -389,6 +400,7 @@ def test_snapshot_detail(bin, controller_client, assert snap_details["children"] == [snap2.id] assert snap_details["removed"] is False assert snap_details["usercreated"] is True + assert snap_details["created"] != "" def test_snapshot_create(bin, controller_client, replica_client, diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index 0552e534..9f8d274e 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -1,5 +1,6 @@ import time import random +import datetime import pytest import cattle @@ -129,14 +130,14 @@ def test_snapshot(client): assert r.parent == '' assert r.head == 'volume-head-000.img' - r = r.snapshot(name='000') + r = r.snapshot(name='000', created=datetime.datetime.utcnow().isoformat()) assert r.state == 'dirty' assert r.dirty assert not r.rebuilding assert r.size == str(1024*4096) assert r.sectorSize == 512 - r = r.snapshot(name='001') + r = r.snapshot(name='001', created=datetime.datetime.utcnow().isoformat()) assert r.state == 'dirty' assert r.dirty @@ -156,8 +157,8 @@ def test_remove_disk(client): r = replicas[0] r = r.create(size=str(1024*4096)) r = r.open() - r = r.snapshot(name='000') - r = r.snapshot(name='001') + r = r.snapshot(name='000', created=datetime.datetime.utcnow().isoformat()) + r = r.snapshot(name='001', created=datetime.datetime.utcnow().isoformat()) assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] @@ -189,8 +190,8 @@ def test_remove_last_disk(client): r = replicas[0] r = r.create(size=str(1024*4096)) r = r.open() - r = r.snapshot(name='000') - r = r.snapshot(name='001') + r = r.snapshot(name='000', created=datetime.datetime.utcnow().isoformat()) + r = r.snapshot(name='001', created=datetime.datetime.utcnow().isoformat()) assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] @@ -220,9 +221,9 @@ def test_reload(client): r = r.create(size=str(1024*4096)) r = r.open() assert r.chain == ['volume-head-000.img'] - r = r.snapshot(name='000') + r = r.snapshot(name='000', created=datetime.datetime.utcnow().isoformat()) assert r.chain == ['volume-head-001.img', 'volume-snap-000.img'] - r = r.snapshot(name='001') + r = r.snapshot(name='001', created=datetime.datetime.utcnow().isoformat()) assert r.chain == ['volume-head-002.img', 'volume-snap-001.img', 'volume-snap-000.img'] @@ -280,7 +281,7 @@ def test_rebuilding(client): r = replicas[0] r = r.create(size=str(1024*4096)) r = r.open() - r = r.snapshot(name='001') + r = r.snapshot(name='001', created=datetime.datetime.utcnow().isoformat()) assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) @@ -324,7 +325,7 @@ def test_not_rebuilding(client): r = replicas[0] r = r.create(size=str(1024*4096)) r = r.open() - r = r.snapshot(name='001') + r = r.snapshot(name='001', created=datetime.datetime.utcnow().isoformat()) assert r.state == 'dirty' assert not r.rebuilding assert r.size == str(1024*4096) diff --git a/replica/backup_test.go b/replica/backup_test.go index 191f9949..7cd9f258 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -5,6 +5,7 @@ import ( "os" "path" + "github.com/rancher/longhorn/util" . "gopkg.in/check.v1" ) @@ -98,7 +99,9 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { fill(buf, 1) _, err = r.WriteAt(buf, mb) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + + createdTime1 := util.Now() + err = r.Snapshot("001", true, createdTime1) c.Assert(err, IsNil) fill(buf, 2) @@ -106,7 +109,9 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(err, IsNil) _, err = r.WriteAt(buf, 4*mb) c.Assert(err, IsNil) - err = r.Snapshot("002", true) + + createdTime2 := util.Now() + err = r.Snapshot("002", true, createdTime2) c.Assert(err, IsNil) fill(buf, 3) @@ -114,7 +119,8 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(err, IsNil) _, err = r.WriteAt(buf, 8*mb) c.Assert(err, IsNil) - err = r.Snapshot("003", true) + createdTime3 := util.Now() + err = r.Snapshot("003", true, createdTime3) c.Assert(err, IsNil) buf = make([]byte, 10*mb) diff --git a/replica/client/client.go b/replica/client/client.go index 5a80de75..8eabe1a1 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -77,14 +77,15 @@ func (c *ReplicaClient) Create(size string) error { }, nil) } -func (c *ReplicaClient) Revert(name string) error { +func (c *ReplicaClient) Revert(name, created string) error { r, err := c.GetReplica() if err != nil { return err } return c.post(r.Actions["revert"], rest.RevertInput{ - Name: name, + Name: name, + Created: created, }, nil) } diff --git a/replica/replica.go b/replica/replica.go index a201daae..e055d1c6 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -14,6 +14,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" "github.com/rancher/sparse-tools/sparse" ) @@ -66,6 +67,7 @@ type disk struct { Parent string Removed bool UserCreated bool + Created string } type BackingFile struct { @@ -87,6 +89,7 @@ type DiskInfo struct { Children []string `json:"children"` Removed bool `json:"removed"` UserCreated bool `json:"usercreated"` + Created string `json:"created"` } const ( @@ -166,7 +169,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF } else if size <= 0 { return nil, os.ErrNotExist } else { - if err := r.createDisk("000", false); err != nil { + if err := r.createDisk("000", false, util.Now()); err != nil { return nil, err } } @@ -495,7 +498,7 @@ func (r *Replica) openFile(name string, flag int) (types.DiffDisk, error) { return sparse.NewDirectFileIoProcessor(r.diskPath(name), os.O_RDWR|flag, 06666, true) } -func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, error) { +func (r *Replica) createNewHead(oldHead, parent, created string) (types.DiffDisk, disk, error) { newHeadName, err := r.nextFile(diskPattern, headName, oldHead) if err != nil { return nil, disk{}, err @@ -513,7 +516,13 @@ func (r *Replica) createNewHead(oldHead, parent string) (types.DiffDisk, disk, e return nil, disk{}, err } - newDisk := disk{Parent: parent, Name: newHeadName, Removed: false, UserCreated: false} + newDisk := disk{ + Parent: parent, + Name: newHeadName, + Removed: false, + UserCreated: false, + Created: created, + } err = r.encodeToFile(&newDisk, newHeadName+metadataSuffix) return f, newDisk, err } @@ -566,13 +575,13 @@ func (r *Replica) rmDisk(name string) error { return lastErr } -func (r *Replica) revertDisk(parent string) (*Replica, error) { +func (r *Replica) revertDisk(parent, created string) (*Replica, error) { if _, err := os.Stat(r.diskPath(parent)); err != nil { return nil, err } oldHead := r.info.Head - f, newHeadDisk, err := r.createNewHead(oldHead, parent) + f, newHeadDisk, err := r.createNewHead(oldHead, parent, created) if err != nil { return nil, err } @@ -598,7 +607,7 @@ func (r *Replica) revertDisk(parent string) (*Replica, error) { return rNew, nil } -func (r *Replica) createDisk(name string, userCreated bool) error { +func (r *Replica) createDisk(name string, userCreated bool, created string) error { if r.readOnly { return fmt.Errorf("Can not create disk on read-only replica") } @@ -615,7 +624,7 @@ func (r *Replica) createDisk(name string, userCreated bool) error { newSnapName = "" } - f, newHeadDisk, err := r.createNewHead(oldHead, newSnapName) + f, newHeadDisk, err := r.createNewHead(oldHead, newSnapName, created) if err != nil { return err } @@ -648,6 +657,7 @@ func (r *Replica) createDisk(name string, userCreated bool) error { r.addChildDisk(newSnapName, newHeadDisk.Name) r.diskData[newSnapName] = r.diskData[oldHead] r.diskData[newSnapName].UserCreated = userCreated + r.diskData[newSnapName].Created = created if err := r.encodeToFile(r.diskData[newSnapName], newSnapName+metadataSuffix); err != nil { return err } @@ -808,18 +818,18 @@ func (r *Replica) Delete() error { return nil } -func (r *Replica) Snapshot(name string, userCreated bool) error { +func (r *Replica) Snapshot(name string, userCreated bool, created string) error { r.Lock() defer r.Unlock() - return r.createDisk(name, userCreated) + return r.createDisk(name, userCreated, created) } -func (r *Replica) Revert(name string) (*Replica, error) { +func (r *Replica) Revert(name, created string) (*Replica, error) { r.Lock() defer r.Unlock() - return r.revertDisk(name) + return r.revertDisk(name, created) } func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { @@ -858,6 +868,7 @@ func (r *Replica) ListDisks() map[string]DiskInfo { Parent: disk.Parent, Removed: disk.Removed, UserCreated: disk.UserCreated, + Created: disk.Created, } children := []string{} for child := range r.diskChildrenMap[disk.Name] { diff --git a/replica/replica_test.go b/replica/replica_test.go index 16fe9111..37f33a77 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -8,7 +8,9 @@ import ( "path" "strconv" "testing" + "time" + "github.com/rancher/longhorn/util" . "gopkg.in/check.v1" ) @@ -33,6 +35,12 @@ func (s *TestSuite) TestCreate(c *C) { defer r.Close() } +func getNow() string { + // Make sure timestamp is unique + time.Sleep(1 * time.Second) + return util.Now() +} + func (s *TestSuite) TestSnapshot(c *C) { dir, err := ioutil.TempDir("", "replica") c.Assert(err, IsNil) @@ -42,10 +50,13 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + createdTime0 := getNow() + + err = r.Snapshot("000", true, createdTime0) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + createdTime1 := getNow() + err = r.Snapshot("001", true, createdTime1) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -55,20 +66,28 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(r.activeDiskData[3].Name, Equals, "volume-head-002.img") c.Assert(r.activeDiskData[3].UserCreated, Equals, false) c.Assert(r.activeDiskData[3].Parent, Equals, "volume-snap-001.img") + c.Assert(r.activeDiskData[3].Created, Equals, createdTime1) + c.Assert(r.activeDiskData[2].Name, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[2].UserCreated, Equals, true) c.Assert(r.activeDiskData[2].Parent, Equals, "volume-snap-000.img") + c.Assert(r.activeDiskData[2].Created, Equals, createdTime1) + c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].UserCreated, Equals, true) c.Assert(r.activeDiskData[1].Parent, Equals, "") + c.Assert(r.activeDiskData[1].Created, Equals, createdTime0) c.Assert(len(r.diskData), Equals, 3) c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") c.Assert(r.diskData["volume-snap-000.img"].UserCreated, Equals, true) + c.Assert(r.diskData["volume-snap-000.img"].Created, Equals, createdTime0) c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-001.img"].UserCreated, Equals, true) + c.Assert(r.diskData["volume-snap-001.img"].Created, Equals, createdTime1) c.Assert(r.diskData["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") c.Assert(r.diskData["volume-head-002.img"].UserCreated, Equals, false) + c.Assert(r.diskData["volume-head-002.img"].Created, Equals, createdTime1) c.Assert(len(r.diskChildrenMap), Equals, 3) c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 1) @@ -84,17 +103,20 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(disks["volume-snap-000.img"].Removed, Equals, false) c.Assert(len(disks["volume-snap-000.img"].Children), Equals, 1) c.Assert(disks["volume-snap-000.img"].Children[0], Equals, "volume-snap-001.img") + c.Assert(disks["volume-snap-000.img"].Created, Equals, createdTime0) c.Assert(disks["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(disks["volume-snap-001.img"].UserCreated, Equals, true) c.Assert(disks["volume-snap-001.img"].Removed, Equals, false) c.Assert(len(disks["volume-snap-001.img"].Children), Equals, 1) c.Assert(disks["volume-snap-001.img"].Children[0], Equals, "volume-head-002.img") + c.Assert(disks["volume-snap-001.img"].Created, Equals, createdTime1) c.Assert(disks["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") c.Assert(disks["volume-head-002.img"].UserCreated, Equals, false) c.Assert(disks["volume-head-002.img"].Removed, Equals, false) c.Assert(len(disks["volume-head-002.img"].Children), Equals, 0) + c.Assert(disks["volume-head-002.img"].Created, Equals, createdTime1) } func (s *TestSuite) TestRevert(c *C) { @@ -106,10 +128,12 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + createdTime0 := getNow() + err = r.Snapshot("000", true, createdTime0) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + createdTime1 := getNow() + err = r.Snapshot("001", true, createdTime1) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -122,7 +146,8 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(chain[1], Equals, "volume-snap-001.img") c.Assert(chain[2], Equals, "volume-snap-000.img") - r, err = r.Revert("volume-snap-000.img") + revertTime1 := getNow() + r, err = r.Revert("volume-snap-000.img", revertTime1) c.Assert(err, IsNil) chain, err = r.Chain() @@ -136,6 +161,8 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-head-003.img"].Parent, Equals, "volume-snap-000.img") + c.Assert(r.diskData["volume-head-003.img"].Created, Equals, revertTime1) + c.Assert(len(r.diskChildrenMap["volume-snap-000.img"]), Equals, 2) c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-snap-001.img"], Equals, true) c.Assert(r.diskChildrenMap["volume-snap-000.img"]["volume-head-003.img"], Equals, true) @@ -143,7 +170,8 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(r.diskChildrenMap["volume-head-002.img"], IsNil) c.Assert(r.diskChildrenMap["volume-head-003.img"], IsNil) - err = r.Snapshot("003", true) + createdTime3 := getNow() + err = r.Snapshot("003", true, createdTime3) c.Assert(err, IsNil) c.Assert(len(r.diskData), Equals, 4) @@ -158,7 +186,8 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(len(r.diskChildrenMap["volume-snap-003.img"]), Equals, 1) c.Assert(r.diskChildrenMap["volume-snap-003.img"]["volume-head-004.img"], Equals, true) - r, err = r.Revert("volume-snap-001.img") + revertTime2 := getNow() + r, err = r.Revert("volume-snap-001.img", revertTime2) c.Assert(err, IsNil) chain, err = r.Chain() @@ -171,12 +200,16 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(len(r.diskData), Equals, 4) c.Assert(r.diskData["volume-snap-000.img"].Parent, Equals, "") c.Assert(r.diskData["volume-snap-000.img"].UserCreated, Equals, true) + c.Assert(r.diskData["volume-snap-000.img"].Created, Equals, createdTime0) c.Assert(r.diskData["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-001.img"].UserCreated, Equals, true) + c.Assert(r.diskData["volume-snap-001.img"].Created, Equals, createdTime1) c.Assert(r.diskData["volume-snap-003.img"].Parent, Equals, "volume-snap-000.img") c.Assert(r.diskData["volume-snap-003.img"].UserCreated, Equals, true) + c.Assert(r.diskData["volume-snap-003.img"].Created, Equals, createdTime3) c.Assert(r.diskData["volume-head-005.img"].Parent, Equals, "volume-snap-001.img") c.Assert(r.diskData["volume-head-005.img"].UserCreated, Equals, false) + c.Assert(r.diskData["volume-head-005.img"].Created, Equals, revertTime2) disks := r.ListDisks() c.Assert(len(disks), Equals, 4) @@ -207,13 +240,14 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + now := getNow() + err = r.Snapshot("000", true, now) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, now) c.Assert(err, IsNil) - err = r.Snapshot("002", true) + err = r.Snapshot("002", true, now) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 5) @@ -235,7 +269,7 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(r.diskData["volume-snap-002.img"].Parent, Equals, "volume-snap-001.img") c.Assert(r.diskData["volume-head-003.img"].Parent, Equals, "volume-snap-002.img") - r, err = r.Revert("volume-snap-000.img") + r, err = r.Revert("volume-snap-000.img", getNow()) c.Assert(err, IsNil) c.Assert(len(r.diskData), Equals, 4) @@ -281,10 +315,11 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + now := getNow() + err = r.Snapshot("000", true, now) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, now) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -326,10 +361,11 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + now := getNow() + err = r.Snapshot("000", true, now) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, now) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -371,10 +407,11 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + now := getNow() + err = r.Snapshot("000", true, now) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, now) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -401,13 +438,14 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + now := getNow() + err = r.Snapshot("000", true, now) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, now) c.Assert(err, IsNil) - err = r.Snapshot("002", true) + err = r.Snapshot("002", true, now) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 5) @@ -423,7 +461,7 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(r.activeDiskData[1].Name, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Parent, Equals, "") - r, err = r.Revert("volume-snap-000.img") + r, err = r.Revert("volume-snap-000.img", getNow()) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 3) c.Assert(len(r.volume.files), Equals, 3) @@ -476,10 +514,11 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(err, IsNil) defer r.Close() - err = r.Snapshot("000", true) + now := getNow() + err = r.Snapshot("000", true, now) c.Assert(err, IsNil) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, now) c.Assert(err, IsNil) c.Assert(len(r.activeDiskData), Equals, 4) @@ -506,7 +545,7 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[1].Source, Equals, "volume-snap-000.img") c.Assert(r.activeDiskData[1].Removed, Equals, true) - err = r.Snapshot("002", true) + err = r.Snapshot("002", true, now) c.Assert(err, IsNil) /* @@ -529,10 +568,10 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[1].Action, Equals, OpRemove) c.Assert(actions[1].Source, Equals, "volume-snap-001.img") - err = r.Snapshot("003", true) + err = r.Snapshot("003", true, now) c.Assert(err, IsNil) - err = r.Snapshot("004", true) + err = r.Snapshot("004", true, now) c.Assert(err, IsNil) /* @@ -642,19 +681,19 @@ func (s *TestSuite) TestSnapshotReadWrite(c *C) { count, err := r.WriteAt(buf, 0) c.Assert(err, IsNil) c.Assert(count, Equals, 3*b) - err = r.Snapshot("000", true) + err = r.Snapshot("000", true, getNow()) c.Assert(err, IsNil) fill(buf[b:2*b], 2) count, err = r.WriteAt(buf[b:2*b], b) c.Assert(count, Equals, b) - err = r.Snapshot("001", true) + err = r.Snapshot("001", true, getNow()) c.Assert(err, IsNil) fill(buf[:b], 1) count, err = r.WriteAt(buf[:b], 0) c.Assert(count, Equals, b) - err = r.Snapshot("002", true) + err = r.Snapshot("002", true, getNow()) c.Assert(err, IsNil) readBuf := make([]byte, 3*b) @@ -733,7 +772,7 @@ func (s *TestSuite) partialWriteRead(c *C, totalLength, writeLength, writeOffset _, err = r.WriteAt(buf, 0) c.Assert(err, IsNil) - err = r.Snapshot("000", true) + err = r.Snapshot("000", true, getNow()) c.Assert(err, IsNil) buf = make([]byte, writeLength) @@ -781,7 +820,7 @@ func (s *TestSuite) testPartialRead(c *C, totalLength int64, readBuf []byte, off for i := int64(0); i < totalLength; i += b { buf := make([]byte, totalLength-i) fill(buf, byte(i/b+1)) - err := r.Snapshot(strconv.Itoa(int(i)), true) + err := r.Snapshot(strconv.Itoa(int(i)), true, getNow()) c.Assert(err, IsNil) _, err = r.WriteAt(buf, i) c.Assert(err, IsNil) diff --git a/replica/rest/model.go b/replica/rest/model.go index a7b572d8..ffba9fdc 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -30,7 +30,8 @@ type CreateInput struct { type RevertInput struct { client.Resource - Name string `json:"name"` + Name string `json:"name"` + Created string `json:"created"` } type RebuildingInput struct { @@ -42,6 +43,7 @@ type SnapshotInput struct { client.Resource Name string `json:"name"` UserCreated bool `json:"usercreated"` + Created string `json:"created"` } type RemoveDiskInput struct { diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 17755172..38a7bfee 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -116,12 +116,15 @@ func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) erro return err } - name := input.Name - if name == "" { + if input.Name == "" { return fmt.Errorf("Cannot accept empty snapshot name") } - return s.doOp(req, s.s.Snapshot(name, input.UserCreated)) + if input.Created == "" { + return fmt.Errorf("Need to specific created time") + } + + return s.doOp(req, s.s.Snapshot(input.Name, input.UserCreated, input.Created)) } func (s *Server) RevertReplica(rw http.ResponseWriter, req *http.Request) error { @@ -131,7 +134,15 @@ func (s *Server) RevertReplica(rw http.ResponseWriter, req *http.Request) error return err } - return s.doOp(req, s.s.Revert(input.Name)) + if input.Name == "" { + return fmt.Errorf("Cannot accept empty snapshot name") + } + + if input.Created == "" { + return fmt.Errorf("Need to specific created time") + } + + return s.doOp(req, s.s.Revert(input.Name, input.Created)) } func (s *Server) ReloadReplica(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/server.go b/replica/server.go index 36553088..84def95b 100644 --- a/replica/server.go +++ b/replica/server.go @@ -150,7 +150,7 @@ func (s *Server) Replica() *Replica { return s.r } -func (s *Server) Revert(name string) error { +func (s *Server) Revert(name, created string) error { s.Lock() defer s.Unlock() @@ -158,8 +158,8 @@ func (s *Server) Revert(name string) error { return nil } - logrus.Infof("Reverting to snapshot [%s] on volume", name) - r, err := s.r.Revert(name) + logrus.Infof("Reverting to snapshot [%s] on volume at %s", name, created) + r, err := s.r.Revert(name, created) if err != nil { return err } @@ -168,7 +168,7 @@ func (s *Server) Revert(name string) error { return nil } -func (s *Server) Snapshot(name string, userCreated bool) error { +func (s *Server) Snapshot(name string, userCreated bool, createdTime string) error { s.Lock() defer s.Unlock() @@ -176,8 +176,9 @@ func (s *Server) Snapshot(name string, userCreated bool) error { return nil } - logrus.Infof("Snapshotting [%s] volume, user created %v", name, userCreated) - return s.r.Snapshot(name, userCreated) + logrus.Infof("Snapshotting [%s] volume, user created %v, created time %v", + name, userCreated, createdTime) + return s.r.Snapshot(name, userCreated, createdTime) } func (s *Server) RemoveDiffDisk(name string) error { diff --git a/types/types.go b/types/types.go index 8fcdacea..8c80f552 100644 --- a/types/types.go +++ b/types/types.go @@ -27,7 +27,7 @@ type MonitorChannel chan error type Backend interface { ReaderWriterAt io.Closer - Snapshot(name string, userCreated bool) error + Snapshot(name string, userCreated bool, created string) error Size() (int64, error) SectorSize() (int64, error) RemainSnapshots() (int, error) diff --git a/util/util.go b/util/util.go index b3321442..6f3d9d9c 100644 --- a/util/util.go +++ b/util/util.go @@ -144,3 +144,7 @@ func ValidVolumeName(name string) bool { func Volume2ISCSIName(name string) string { return strings.Replace(name, "_", ":", -1) } + +func Now() string { + return time.Now().UTC().Format(time.RFC3339) +} From 5c3ade249473bb1728e8fa39b48fc06f42bd2e8e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 3 Mar 2017 17:12:51 -0800 Subject: [PATCH 295/357] cli: Change `snapshot detail` to `snapshot info` --- app/snapshot.go | 14 +++--- integration/core/test_cli.py | 96 ++++++++++++++++++------------------ 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index 4058d44d..cc1a7cb8 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -24,7 +24,7 @@ func SnapshotCmd() cli.Command { SnapshotRevertCmd(), SnapshotLsCmd(), SnapshotRmCmd(), - SnapshotDetailCmd(), + SnapshotInfoCmd(), }, Action: func(c *cli.Context) { if err := lsSnapshot(c); err != nil { @@ -78,12 +78,12 @@ func SnapshotLsCmd() cli.Command { } } -func SnapshotDetailCmd() cli.Command { +func SnapshotInfoCmd() cli.Command { return cli.Command{ - Name: "detail", + Name: "info", Action: func(c *cli.Context) { - if err := detailSnapshot(c); err != nil { - logrus.Fatalf("Error running detail snapshot command: %v", err) + if err := infoSnapshot(c); err != nil { + logrus.Fatalf("Error running snapshot info command: %v", err) } }, } @@ -190,7 +190,7 @@ func lsSnapshot(c *cli.Context) error { return nil } -func detailSnapshot(c *cli.Context) error { +func infoSnapshot(c *cli.Context) error { var output []byte outputDisks := make(map[string]replica.DiskInfo) @@ -253,7 +253,7 @@ func detailSnapshot(c *cli.Context) error { } if output == nil { - return fmt.Errorf("Cannot find suitable replica for snapshot details") + return fmt.Errorf("Cannot find suitable replica for snapshot info") } fmt.Println(string(output)) return nil diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 319f01e6..cd649933 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -178,39 +178,39 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, for r in replicas: assert r.mode == 'RW' - cmd = [bin, '--debug', 'snapshot', 'detail'] + cmd = [bin, '--debug', 'snapshot', 'info'] output = subprocess.check_output(cmd) - details = json.loads(output) + info = json.loads(output) # two existing snapshots and one system snapshot due to rebuild - assert len(details) == 3 - for name in details: + assert len(info) == 3 + for name in info: if name != snap0 and name != snap1: snapreb = name break - snapreb_details = details[snapreb] - assert snapreb_details["name"] == snapreb - assert snapreb_details["parent"] == snap1 - assert snapreb_details["children"] == [] - assert snapreb_details["removed"] is False - assert snapreb_details["usercreated"] is False - - snap1_details = details[snap1] - assert snap1_details["name"] == snap1 - assert snap1_details["parent"] == snap0 - assert snap1_details["children"] == [snapreb] - assert snap1_details["removed"] is False - assert snap1_details["usercreated"] is True - assert snap1_details["created"] == createtime1 - - snap0_details = details[snap0] - assert snap0_details["name"] == snap0 - assert snap0_details["parent"] == "" - assert snap0_details["children"] == [snap1] - assert snap0_details["removed"] is False - assert snap0_details["usercreated"] is False - assert snap0_details["created"] == createtime0 + snapreb_info = info[snapreb] + assert snapreb_info["name"] == snapreb + assert snapreb_info["parent"] == snap1 + assert snapreb_info["children"] == [] + assert snapreb_info["removed"] is False + assert snapreb_info["usercreated"] is False + + snap1_info = info[snap1] + assert snap1_info["name"] == snap1 + assert snap1_info["parent"] == snap0 + assert snap1_info["children"] == [snapreb] + assert snap1_info["removed"] is False + assert snap1_info["usercreated"] is True + assert snap1_info["created"] == createtime1 + + snap0_info = info[snap0] + assert snap0_info["name"] == snap0 + assert snap0_info["parent"] == "" + assert snap0_info["children"] == [snap1] + assert snap0_info["removed"] is False + assert snap0_info["usercreated"] is False + assert snap0_info["created"] == createtime0 def test_replica_add_after_rebuild_failed(bin, controller_client, @@ -362,8 +362,8 @@ def test_snapshot_ls(bin, controller_client, replica_client, replica_client2): '''.format(snap2.id, snap.id) -def test_snapshot_detail(bin, controller_client, - replica_client, replica_client2): +def test_snapshot_info(bin, controller_client, + replica_client, replica_client2): open_replica(replica_client) open_replica(replica_client2) @@ -380,27 +380,27 @@ def test_snapshot_detail(bin, controller_client, snap2 = v.snapshot() assert snap2.id != '' - cmd = [bin, '--debug', 'snapshot', 'detail'] + cmd = [bin, '--debug', 'snapshot', 'info'] output = subprocess.check_output(cmd) - details = json.loads(output) - - assert len(details) == 2 - - snap2_details = details[snap2.id] - assert snap2_details["name"] == snap2.id - assert snap2_details["parent"] == snap.id - assert snap2_details["children"] == [] - assert snap2_details["removed"] is False - assert snap2_details["usercreated"] is True - assert snap2_details["created"] != "" - - snap_details = details[snap.id] - assert snap_details["name"] == snap.id - assert snap_details["parent"] == "" - assert snap_details["children"] == [snap2.id] - assert snap_details["removed"] is False - assert snap_details["usercreated"] is True - assert snap_details["created"] != "" + info = json.loads(output) + + assert len(info) == 2 + + snap2_info = info[snap2.id] + assert snap2_info["name"] == snap2.id + assert snap2_info["parent"] == snap.id + assert snap2_info["children"] == [] + assert snap2_info["removed"] is False + assert snap2_info["usercreated"] is True + assert snap2_info["created"] != "" + + snap_info = info[snap.id] + assert snap_info["name"] == snap.id + assert snap_info["parent"] == "" + assert snap_info["children"] == [snap2.id] + assert snap_info["removed"] is False + assert snap_info["usercreated"] is True + assert snap_info["created"] != "" def test_snapshot_create(bin, controller_client, replica_client, From 2efc2a99642a2f048e62f420ad6af0b32426f666 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 7 Mar 2017 16:57:28 -0800 Subject: [PATCH 296/357] backup: remove reference of convoy/api --- backup/main.go | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/backup/main.go b/backup/main.go index dc5f2d91..93d9f05b 100644 --- a/backup/main.go +++ b/backup/main.go @@ -4,11 +4,12 @@ import ( "encoding/json" "fmt" "os" + "runtime" + "runtime/debug" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/convoy/api" "github.com/rancher/convoy/objectstore" "github.com/rancher/convoy/util" "github.com/rancher/longhorn/replica" @@ -32,7 +33,7 @@ var ( }, cli.StringFlag{ Name: "volume", - Usage: "volume path, the base name will be used as volume name", + Usage: "volume name", }, }, Action: cmdBackupCreate, @@ -77,7 +78,7 @@ var ( func cleanup() { if r := recover(); r != nil { - api.ResponseLogAndError(r) + ResponseLogAndError(r) os.Exit(1) } } @@ -105,6 +106,37 @@ func Main() { app.Run(os.Args) } +type ErrorResponse struct { + Error string +} + +func ResponseLogAndError(v interface{}) { + if e, ok := v.(*logrus.Entry); ok { + e.Error(e.Message) + fmt.Println(e.Message) + } else { + e, isErr := v.(error) + _, isRuntimeErr := e.(runtime.Error) + if isErr && !isRuntimeErr { + logrus.Errorf(fmt.Sprint(e)) + fmt.Println(fmt.Sprint(e)) + } else { + logrus.Errorf("Caught FATAL error: %s", v) + debug.PrintStack() + fmt.Println("Caught FATAL error: %s", v) + } + } +} + +// ResponseOutput would generate a JSON format byte array of object for output +func ResponseOutput(v interface{}) ([]byte, error) { + j, err := json.MarshalIndent(v, "", "\t") + if err != nil { + return nil, err + } + return j, nil +} + func getName(c *cli.Context, key string, required bool) (string, error) { var err error var name string @@ -126,14 +158,6 @@ func getName(c *cli.Context, key string, required bool) (string, error) { return name, nil } -func ResponseOutput(v interface{}) ([]byte, error) { - j, err := json.MarshalIndent(v, "", "\t") - if err != nil { - return nil, err - } - return j, nil -} - func cmdBackupCreate(c *cli.Context) { if err := doBackupCreate(c); err != nil { panic(err) @@ -313,7 +337,7 @@ func doBackupInspect(c *cli.Context) error { if err != nil { return err } - data, err := api.ResponseOutput(info) + data, err := ResponseOutput(info) if err != nil { return err } From a733c0d5c5344113cbf6a91d5b2965e2f4fd1163 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 7 Mar 2017 16:58:17 -0800 Subject: [PATCH 297/357] backup: remove reference of convoy/util --- backup/main.go | 117 ++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 54 deletions(-) diff --git a/backup/main.go b/backup/main.go index 93d9f05b..074c96cd 100644 --- a/backup/main.go +++ b/backup/main.go @@ -6,12 +6,13 @@ import ( "os" "runtime" "runtime/debug" + "strings" + "time" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/rancher/convoy/objectstore" - "github.com/rancher/convoy/util" "github.com/rancher/longhorn/replica" ) @@ -123,7 +124,7 @@ func ResponseLogAndError(v interface{}) { } else { logrus.Errorf("Caught FATAL error: %s", v) debug.PrintStack() - fmt.Println("Caught FATAL error: %s", v) + fmt.Println("Caught FATAL error: ", v) } } } @@ -137,25 +138,8 @@ func ResponseOutput(v interface{}) ([]byte, error) { return j, nil } -func getName(c *cli.Context, key string, required bool) (string, error) { - var err error - var name string - if key == "" { - name = c.Args().First() - } else { - name, err = util.GetFlag(c, key, required, err) - if err != nil { - return "", err - } - } - if name == "" && !required { - return "", nil - } - - if err := util.CheckName(name); err != nil { - return "", err - } - return name, nil +func RequiredMissingError(name string) error { + return fmt.Errorf("Cannot find valid required parameter: %v", name) } func cmdBackupCreate(c *cli.Context) { @@ -170,19 +154,22 @@ func doBackupCreate(c *cli.Context) error { backingFile *replica.BackingFile ) - destURL, err := util.GetFlag(c, "dest", true, err) - if err != nil { - return err + if c.NArg() == 0 { + return RequiredMissingError("snapshot name") + } + snapshotName := c.Args()[0] + if snapshotName == "" { + return RequiredMissingError("snapshot name") } - snapshotName, err := getName(c, "", true) - if err != nil { - return err + destURL := c.String("dest") + if destURL == "" { + return RequiredMissingError("dest") } - volumeName, err := util.GetFlag(c, "volume", true, err) - if err != nil { - return err + volumeName := c.String("volume") + if volumeName == "" { + return RequiredMissingError("volume") } dir, err := os.Getwd() @@ -211,11 +198,11 @@ func doBackupCreate(c *cli.Context) error { Name: volumeName, Driver: DRIVERNAME, Size: volumeInfo.Size, - CreatedTime: util.Now(), + CreatedTime: Now(), } snapshot := &objectstore.Snapshot{ Name: snapshotName, - CreatedTime: util.Now(), + CreatedTime: Now(), } log.Debugf("Starting backup for %v, snapshot %v, dest %v", volume, snapshot, destURL) @@ -234,12 +221,14 @@ func cmdBackupDelete(c *cli.Context) { } func doBackupDelete(c *cli.Context) error { - var err error - backupURL, err := util.GetFlag(c, "", true, err) - if err != nil { - return err + if c.NArg() == 0 { + return RequiredMissingError("backup URL") + } + backupURL := c.Args()[0] + if backupURL == "" { + return RequiredMissingError("backup URL") } - backupURL = util.UnescapeURL(backupURL) + backupURL = UnescapeURL(backupURL) if err := objectstore.DeleteDeltaBlockBackup(backupURL); err != nil { return err @@ -254,16 +243,18 @@ func cmdBackupRestore(c *cli.Context) { } func doBackupRestore(c *cli.Context) error { - var err error - backupURL, err := util.GetFlag(c, "", true, err) - if err != nil { - return err + if c.NArg() == 0 { + return RequiredMissingError("backup URL") } - backupURL = util.UnescapeURL(backupURL) + backupURL := c.Args()[0] + if backupURL == "" { + return RequiredMissingError("backup URL") + } + backupURL = UnescapeURL(backupURL) - toFile, err := util.GetFlag(c, "to", true, err) - if err != nil { - return err + toFile := c.String("to") + if toFile == "" { + return RequiredMissingError("to") } if err := objectstore.RestoreDeltaBlockBackup(backupURL, toFile); err != nil { @@ -304,12 +295,16 @@ func cmdBackupList(c *cli.Context) { func doBackupList(c *cli.Context) error { var err error - destURL, err := util.GetFlag(c, "", true, err) - volumeName, err := util.GetName(c, "volume", false, err) - if err != nil { - return err - + if c.NArg() == 0 { + return RequiredMissingError("dest URL") + } + destURL := c.Args()[0] + if destURL == "" { + return RequiredMissingError("dest URL") } + + volumeName := c.String("volume") + list, err := objectstore.List(volumeName, destURL, DRIVERNAME) if err != nil { return err @@ -327,11 +322,14 @@ func cmdBackupInspect(c *cli.Context) { func doBackupInspect(c *cli.Context) error { var err error - backupURL, err := util.GetFlag(c, "", true, err) - if err != nil { - return err + if c.NArg() == 0 { + return RequiredMissingError("backup URL") + } + backupURL := c.Args()[0] + if backupURL == "" { + return RequiredMissingError("backup URL") } - backupURL = util.UnescapeURL(backupURL) + backupURL = UnescapeURL(backupURL) info, err := objectstore.GetBackupInfo(backupURL) if err != nil { @@ -344,3 +342,14 @@ func doBackupInspect(c *cli.Context) error { fmt.Println(string(data)) return nil } + +func UnescapeURL(url string) string { + // Deal with escape in url inputed from bash + result := strings.Replace(url, "\\u0026", "&", 1) + result = strings.Replace(result, "u0026", "&", 1) + return result +} + +func Now() string { + return time.Now().UTC().Format(time.RFC3339) +} From c8de03ea78380e2af05d927fa0543727fa837a81 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Mon, 6 Mar 2017 15:52:44 -0800 Subject: [PATCH 298/357] replica: Use rancher/backupstore for backup It's a fork of convoy/objectstore, and will be the only place to host the backupstore code in the future. --- backup/import_objectstore.go | 6 +- backup/main.go | 22 +- replica/backup.go | 10 +- vendor.conf | 5 +- .../mcuadros/go-version/.travis.yml | 1 - vendor/github.com/mcuadros/go-version/LICENSE | 19 - .../github.com/mcuadros/go-version/README.md | 82 --- .../github.com/mcuadros/go-version/compare.go | 159 ----- .../mcuadros/go-version/constraint.go | 49 -- vendor/github.com/mcuadros/go-version/doc.go | 6 - .../github.com/mcuadros/go-version/group.go | 269 -------- .../mcuadros/go-version/normalize.go | 116 ---- vendor/github.com/mcuadros/go-version/sort.go | 36 -- .../mcuadros/go-version/stability.go | 83 --- vendor/github.com/rancher/convoy/.drone.yml | 4 - vendor/github.com/rancher/convoy/.gitignore | 26 - vendor/github.com/rancher/convoy/.package | 1 - .../rancher/convoy/.wrap-docker-args | 5 - .../rancher/convoy/Dockerfile.dapper | 59 -- vendor/github.com/rancher/convoy/Makefile | 23 - vendor/github.com/rancher/convoy/README.md | 214 ------- vendor/github.com/rancher/convoy/api/const.go | 10 - .../github.com/rancher/convoy/api/request.go | 62 -- .../github.com/rancher/convoy/api/response.go | 83 --- vendor/github.com/rancher/convoy/apply.sh | 14 - .../convoy/convoydriver/convoydriver.go | 130 ---- .../rancher/convoy/metadata/devmapper.go | 40 -- .../github.com/rancher/convoy/util/config.go | 155 ----- .../github.com/rancher/convoy/util/index.go | 55 -- vendor/github.com/rancher/convoy/util/util.go | 460 -------------- .../github.com/rancher/convoy/util/volume.go | 459 -------------- .../rancher/convoy/vfs/vfs_storage.go | 598 ------------------ .../backupstore}/.gitignore | 2 + .../convoy => yasker/backupstore}/LICENSE | 3 +- .../github.com/yasker/backupstore/README.md | 1 + .../backupstore/backupstore.go} | 24 +- .../backupstore}/config.go | 46 +- .../backupstore}/deltablock.go | 25 +- .../backupstore}/driver.go | 14 +- .../backupstore}/logging/logging.go | 0 .../convoy => yasker/backupstore}/s3/s3.go | 34 +- .../backupstore}/s3/s3_service.go | 0 .../backupstore}/singlefile.go | 16 +- .../convoy => yasker/backupstore}/trash.yml | 27 +- .../backupstore/types.go} | 2 +- .../yasker/backupstore/util/util.go | 121 ++++ .../backupstore/vfs/vfs.go} | 42 +- .../yasker/go-iscsi-helper/iscsi/target.go | 2 +- .../yasker/go-iscsi-helper/trash.conf | 6 - .../yasker/go-iscsi-helper/util/util.go | 48 +- 50 files changed, 292 insertions(+), 3382 deletions(-) delete mode 100644 vendor/github.com/mcuadros/go-version/.travis.yml delete mode 100644 vendor/github.com/mcuadros/go-version/LICENSE delete mode 100644 vendor/github.com/mcuadros/go-version/README.md delete mode 100644 vendor/github.com/mcuadros/go-version/compare.go delete mode 100644 vendor/github.com/mcuadros/go-version/constraint.go delete mode 100644 vendor/github.com/mcuadros/go-version/doc.go delete mode 100644 vendor/github.com/mcuadros/go-version/group.go delete mode 100644 vendor/github.com/mcuadros/go-version/normalize.go delete mode 100644 vendor/github.com/mcuadros/go-version/sort.go delete mode 100644 vendor/github.com/mcuadros/go-version/stability.go delete mode 100644 vendor/github.com/rancher/convoy/.drone.yml delete mode 100644 vendor/github.com/rancher/convoy/.gitignore delete mode 100644 vendor/github.com/rancher/convoy/.package delete mode 100644 vendor/github.com/rancher/convoy/.wrap-docker-args delete mode 100644 vendor/github.com/rancher/convoy/Dockerfile.dapper delete mode 100644 vendor/github.com/rancher/convoy/Makefile delete mode 100644 vendor/github.com/rancher/convoy/README.md delete mode 100644 vendor/github.com/rancher/convoy/api/const.go delete mode 100644 vendor/github.com/rancher/convoy/api/request.go delete mode 100644 vendor/github.com/rancher/convoy/api/response.go delete mode 100755 vendor/github.com/rancher/convoy/apply.sh delete mode 100644 vendor/github.com/rancher/convoy/convoydriver/convoydriver.go delete mode 100644 vendor/github.com/rancher/convoy/metadata/devmapper.go delete mode 100644 vendor/github.com/rancher/convoy/util/config.go delete mode 100644 vendor/github.com/rancher/convoy/util/index.go delete mode 100644 vendor/github.com/rancher/convoy/util/util.go delete mode 100644 vendor/github.com/rancher/convoy/util/volume.go delete mode 100644 vendor/github.com/rancher/convoy/vfs/vfs_storage.go rename vendor/github.com/{mcuadros/go-version => yasker/backupstore}/.gitignore (94%) rename vendor/github.com/{rancher/convoy => yasker/backupstore}/LICENSE (99%) create mode 100644 vendor/github.com/yasker/backupstore/README.md rename vendor/github.com/{rancher/convoy/objectstore/objectstore.go => yasker/backupstore/backupstore.go} (86%) rename vendor/github.com/{rancher/convoy/objectstore => yasker/backupstore}/config.go (75%) rename vendor/github.com/{rancher/convoy/objectstore => yasker/backupstore}/deltablock.go (94%) rename vendor/github.com/{rancher/convoy/objectstore => yasker/backupstore}/driver.go (78%) rename vendor/github.com/{rancher/convoy => yasker/backupstore}/logging/logging.go (100%) rename vendor/github.com/{rancher/convoy => yasker/backupstore}/s3/s3.go (76%) rename vendor/github.com/{rancher/convoy => yasker/backupstore}/s3/s3_service.go (100%) rename vendor/github.com/{rancher/convoy/objectstore => yasker/backupstore}/singlefile.go (88%) rename vendor/github.com/{rancher/convoy => yasker/backupstore}/trash.yml (63%) rename vendor/github.com/{rancher/convoy/metadata/metadata.go => yasker/backupstore/types.go} (85%) create mode 100644 vendor/github.com/yasker/backupstore/util/util.go rename vendor/github.com/{rancher/convoy/vfs/vfs_objectstore.go => yasker/backupstore/vfs/vfs.go} (72%) diff --git a/backup/import_objectstore.go b/backup/import_objectstore.go index 66387825..b1854365 100644 --- a/backup/import_objectstore.go +++ b/backup/import_objectstore.go @@ -2,7 +2,7 @@ package backup import ( // Involve S3 objecstore drivers for registeration - _ "github.com/rancher/convoy/s3" - // Involve VFS convoy driver/objectstore driver for registeration - _ "github.com/rancher/convoy/vfs" + _ "github.com/yasker/backupstore/s3" + // Involve VFS objectstore driver for registeration + _ "github.com/yasker/backupstore/vfs" ) diff --git a/backup/main.go b/backup/main.go index 074c96cd..09c17cde 100644 --- a/backup/main.go +++ b/backup/main.go @@ -12,8 +12,8 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/convoy/objectstore" "github.com/rancher/longhorn/replica" + "github.com/yasker/backupstore" ) const ( @@ -26,7 +26,7 @@ var ( backupCreateCmd = cli.Command{ Name: "create", - Usage: "create a backup in objectstore: create ", + Usage: "create a backup in backupstore: create ", Flags: []cli.Flag{ cli.StringFlag{ Name: "dest", @@ -54,13 +54,13 @@ var ( backupDeleteCmd = cli.Command{ Name: "delete", - Usage: "delete a backup in objectstore: delete ", + Usage: "delete a backup in backupstore: delete ", Action: cmdBackupDelete, } backupListCmd = cli.Command{ Name: "list", - Usage: "list backups in objectstore: list ", + Usage: "list backups in backupstore: list ", Flags: []cli.Flag{ cli.StringFlag{ Name: "volume", @@ -194,19 +194,19 @@ func doBackupCreate(c *cli.Context) error { } replicaBackup := replica.NewBackup(backingFile) - volume := &objectstore.Volume{ + volume := &backupstore.Volume{ Name: volumeName, Driver: DRIVERNAME, Size: volumeInfo.Size, CreatedTime: Now(), } - snapshot := &objectstore.Snapshot{ + snapshot := &backupstore.Snapshot{ Name: snapshotName, CreatedTime: Now(), } log.Debugf("Starting backup for %v, snapshot %v, dest %v", volume, snapshot, destURL) - backupURL, err := objectstore.CreateDeltaBlockBackup(volume, snapshot, destURL, replicaBackup) + backupURL, err := backupstore.CreateDeltaBlockBackup(volume, snapshot, destURL, replicaBackup) if err != nil { return err } @@ -230,7 +230,7 @@ func doBackupDelete(c *cli.Context) error { } backupURL = UnescapeURL(backupURL) - if err := objectstore.DeleteDeltaBlockBackup(backupURL); err != nil { + if err := backupstore.DeleteDeltaBlockBackup(backupURL); err != nil { return err } return nil @@ -257,7 +257,7 @@ func doBackupRestore(c *cli.Context) error { return RequiredMissingError("to") } - if err := objectstore.RestoreDeltaBlockBackup(backupURL, toFile); err != nil { + if err := backupstore.RestoreDeltaBlockBackup(backupURL, toFile); err != nil { return err } @@ -305,7 +305,7 @@ func doBackupList(c *cli.Context) error { volumeName := c.String("volume") - list, err := objectstore.List(volumeName, destURL, DRIVERNAME) + list, err := backupstore.List(volumeName, destURL, DRIVERNAME) if err != nil { return err } @@ -331,7 +331,7 @@ func doBackupInspect(c *cli.Context) error { } backupURL = UnescapeURL(backupURL) - info, err := objectstore.GetBackupInfo(backupURL) + info, err := backupstore.GetBackupInfo(backupURL) if err != nil { return err } diff --git a/replica/backup.go b/replica/backup.go index 6be3c024..84c8358e 100644 --- a/replica/backup.go +++ b/replica/backup.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/rancher/convoy/metadata" + "github.com/yasker/backupstore" ) const ( @@ -109,7 +109,7 @@ func (rb *Backup) CloseSnapshot(id, volumeID string) error { return err } -func (rb *Backup) CompareSnapshot(id, compareID, volumeID string) (*metadata.Mappings, error) { +func (rb *Backup) CompareSnapshot(id, compareID, volumeID string) (*backupstore.Mappings, error) { if err := rb.assertOpen(id, volumeID); err != nil { return nil, err } @@ -127,10 +127,10 @@ func (rb *Backup) CompareSnapshot(id, compareID, volumeID string) (*metadata.Map return nil, fmt.Errorf("Failed to find snapshot %s in chain", compareID) } - mappings := &metadata.Mappings{ + mappings := &backupstore.Mappings{ BlockSize: snapBlockSize, } - mapping := metadata.Mapping{ + mapping := backupstore.Mapping{ Offset: -1, } @@ -144,7 +144,7 @@ func (rb *Backup) CompareSnapshot(id, compareID, volumeID string) (*metadata.Map // align offset -= (offset % snapBlockSize) if mapping.Offset != offset { - mapping = metadata.Mapping{ + mapping = backupstore.Mapping{ Offset: offset, Size: snapBlockSize, } diff --git a/vendor.conf b/vendor.conf index c9d365af..535d466e 100644 --- a/vendor.conf +++ b/vendor.conf @@ -13,11 +13,10 @@ github.com/docker/docker v1.11.1 github.com/codegangsta/cli 71f57d300dd6a780ac1856c005c4b518cfd498ec github.com/satori/go.uuid f9ab0dce87d815821e221626b772e3475a0d2749 github.com/rancher/sparse-tools df7d04b769d34b52878e9e60ba22dabf7dc8b7ca -github.com/rancher/convoy 9e0fd9a3a77dc4b8ee7eab859a420b7764729271 -github.com/mcuadros/go-version d52711f8d6bea8dc01efafdb68ad95a4e2606630 golang.org/x/sys 62bee037599929a6e9146f29d10dd5208c43507d github.com/aws/aws-sdk-go c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 -github.com/yasker/go-iscsi-helper a95ec6c0750d3426e3fd0b10f6f0f50721fe75cf +github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 +github.com/yasker/backupstore accaaa6a7a2ff365d451b2894fe5c7eaabc9e497 diff --git a/vendor/github.com/mcuadros/go-version/.travis.yml b/vendor/github.com/mcuadros/go-version/.travis.yml deleted file mode 100644 index 4f2ee4d9..00000000 --- a/vendor/github.com/mcuadros/go-version/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: go diff --git a/vendor/github.com/mcuadros/go-version/LICENSE b/vendor/github.com/mcuadros/go-version/LICENSE deleted file mode 100644 index b3154896..00000000 --- a/vendor/github.com/mcuadros/go-version/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013 Máximo Cuadros - -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/mcuadros/go-version/README.md b/vendor/github.com/mcuadros/go-version/README.md deleted file mode 100644 index b6addcd0..00000000 --- a/vendor/github.com/mcuadros/go-version/README.md +++ /dev/null @@ -1,82 +0,0 @@ -go-version [![Build Status](https://travis-ci.org/mcuadros/go-version.png?branch=master)](https://travis-ci.org/mcuadros/go-version) [![GoDoc](https://godoc.org/github.com/mcuadros/go-version?status.png)](http://godoc.org/github.com/mcuadros/go-version) -============================== - -Version normalizer and comparison library for go, heavy based on PHP version_compare function and Version comparsion libs from [Composer](https://github.com/composer/composer) PHP project - -Installation ------------- - -The recommended way to install go-version - -``` -go get github.com/mcuadros/go-version -``` - -Examples --------- - -How import the package - -```go -import ( - "github.com/mcuadros/go-version" -) -``` - -`version.Normalize()`: Normalizes a version string to be able to perform comparisons on it - -```go -version.Normalize("10.4.13-b") -//Returns: 10.4.13.0-beta -``` - - -`version.CompareSimple()`: Compares two normalizated version number strings - -```go -version.CompareSimple("1.2", "1.0.1") -//Returns: 1 - -version.CompareSimple("1.0rc1", "1.0") -//Returns: -1 -``` - - -`version.Compare()`: Compares two normalizated version number strings, for a particular relationship - -```go -version.Compare("1.0-dev", "1.0", "<") -//Returns: true - -version.Compare("1.0rc1", "1.0", ">=") -//Returns: false - -version.Compare("2.3.4", "v3.1.2", "<") -//Returns: true -``` - -`version.ConstrainGroup.Match()`: Match a given version againts a group of constrains, read about constraint string format at [Composer documentation](http://getcomposer.org/doc/01-basic-usage.md#package-versions) - -```go -c := version.NewConstrainGroupFromString(">2.0,<=3.0") -c.Match("2.5.0beta") -//Returns: true - -c := version.NewConstrainGroupFromString("~1.2.3") -c.Match("1.2.3.5") -//Returns: true -``` - -`version.Sort()`: Sorts a string slice of version number strings using version.CompareSimple() - -```go -version.Sort([]string{"1.10-dev", "1.0rc1", "1.0", "1.0-dev"}) -//Returns []string{"1.0-dev", "1.0rc1", "1.0", "1.10-dev"} -``` - -License -------- - -MIT, see [LICENSE](LICENSE) - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mcuadros/go-version/trend.png)](https://bitdeli.com/free "Bitdeli Badge") diff --git a/vendor/github.com/mcuadros/go-version/compare.go b/vendor/github.com/mcuadros/go-version/compare.go deleted file mode 100644 index 84dc3fa1..00000000 --- a/vendor/github.com/mcuadros/go-version/compare.go +++ /dev/null @@ -1,159 +0,0 @@ -package version - -import ( - "regexp" - "strconv" - "strings" -) - -var regexpSigns = regexp.MustCompile(`[_\-+]`) -var regexpDotBeforeDigit = regexp.MustCompile(`([^.\d]+)`) -var regexpMultipleDots = regexp.MustCompile(`\.{2,}`) - -var specialForms = map[string]int{ - "dev": -6, - "alpha": -5, - "a": -5, - "beta": -4, - "b": -4, - "RC": -3, - "rc": -3, - "#": -2, - "p": 1, - "pl": 1, -} - -// Compares two version number strings, for a particular relationship -// -// Usage -// version.Compare("2.3.4", "v3.1.2", "<") -// Returns: true -// -// version.Compare("1.0rc1", "1.0", ">=") -// Returns: false -func Compare(version1, version2, operator string) bool { - version1N := Normalize(version1) - version2N := Normalize(version2) - - return CompareNormalized(version1N, version2N, operator) -} - -// Compares two normalizated version number strings, for a particular relationship -// -// The function first replaces _, - and + with a dot . in the version strings -// and also inserts dots . before and after any non number so that for example -// '4.3.2RC1' becomes '4.3.2.RC.1'. -// -// Then it splits the results like if you were using Split(version, '.'). -// Then it compares the parts starting from left to right. If a part contains -// special version strings these are handled in the following order: any string -// not found in this list: -// < dev < alpha = a < beta = b < RC = rc < # < pl = p. -// -// Usage -// version.CompareNormalized("1.0-dev", "1.0", "<") -// Returns: true -// -// version.CompareNormalized("1.0rc1", "1.0", ">=") -// Returns: false -// -// version.CompareNormalized("1.0", "1.0b1", "ge") -// Returns: true -func CompareNormalized(version1, version2, operator string) bool { - compare := CompareSimple(version1, version2) - - switch { - case operator == ">" || operator == "gt": - return compare > 0 - case operator == ">=" || operator == "ge": - return compare >= 0 - case operator == "<=" || operator == "le": - return compare <= 0 - case operator == "==" || operator == "=" || operator == "eq": - return compare == 0 - case operator == "<>" || operator == "!=" || operator == "ne": - return compare != 0 - case operator == "" || operator == "<" || operator == "lt": - return compare < 0 - } - - return false -} - -// Compares two normalizated version number strings -// -// Just the same of CompareVersion but return a int result, 0 if both version -// are equal, 1 if the right side is bigger and -1 if the right side is lower -// -// Usage -// version.CompareSimple("1.2", "1.0.1") -// Returns: 1 -// -// version.CompareSimple("1.0rc1", "1.0") -// Returns: -1 -func CompareSimple(version1, version2 string) int { - var x, r, l int = 0, 0, 0 - - v1, v2 := prepVersion(version1), prepVersion(version2) - len1, len2 := len(v1), len(v2) - - if len1 > len2 { - x = len1 - } else { - x = len2 - } - - for i := 0; i < x; i++ { - if i < len1 && i < len2 { - if v1[i] == v2[i] { - continue - } - } - - r = 0 - if i < len1 { - r = numVersion(v1[i]) - } - - l = 0 - if i < len2 { - l = numVersion(v2[i]) - } - - if r < l { - return -1 - } else if r > l { - return 1 - } - } - - return 0 -} - -func prepVersion(version string) []string { - if len(version) == 0 { - return []string{""} - } - - version = regexpSigns.ReplaceAllString(version, ".") - version = regexpDotBeforeDigit.ReplaceAllString(version, ".$1.") - version = regexpMultipleDots.ReplaceAllString(version, ".") - - return strings.Split(version, ".") -} - -func numVersion(value string) int { - if value == "" { - return 0 - } - - if number, err := strconv.Atoi(value); err == nil { - return number - } - - if special, ok := specialForms[value]; ok { - return special - } - - return -7 -} diff --git a/vendor/github.com/mcuadros/go-version/constraint.go b/vendor/github.com/mcuadros/go-version/constraint.go deleted file mode 100644 index 8dc2cfcc..00000000 --- a/vendor/github.com/mcuadros/go-version/constraint.go +++ /dev/null @@ -1,49 +0,0 @@ -package version - -import ( - "strings" -) - -type Constraint struct { - operator string - version string -} - -// Return a new Constrain and sets operator and version to compare -func NewConstrain(operator, version string) *Constraint { - constraint := new(Constraint) - constraint.SetOperator(operator) - constraint.SetVersion(version) - - return constraint -} - -// Sets operator to compare -func (self *Constraint) SetOperator(operator string) { - self.operator = operator -} - -// Get operator to compare -func (self *Constraint) GetOperator() string { - return self.operator -} - -// Sets version to compare -func (self *Constraint) SetVersion(version string) { - self.version = version -} - -// Get version to compare -func (self *Constraint) GetVersion() string { - return self.version -} - -// Match a given version againts the constraint -func (self *Constraint) Match(version string) bool { - return Compare(version, self.version, self.operator) -} - -// Return a string representation -func (self *Constraint) String() string { - return strings.Trim(self.operator+" "+self.version, " ") -} diff --git a/vendor/github.com/mcuadros/go-version/doc.go b/vendor/github.com/mcuadros/go-version/doc.go deleted file mode 100644 index 763f6183..00000000 --- a/vendor/github.com/mcuadros/go-version/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -/* -Version normalizer and comparison library for go, heavy based on PHP -version_compare function and Version comparsion libs from Composer -(https://github.com/composer/composer) PHP project -*/ -package version \ No newline at end of file diff --git a/vendor/github.com/mcuadros/go-version/group.go b/vendor/github.com/mcuadros/go-version/group.go deleted file mode 100644 index b25a30c0..00000000 --- a/vendor/github.com/mcuadros/go-version/group.go +++ /dev/null @@ -1,269 +0,0 @@ -package version - -import ( - "regexp" - "strconv" - "strings" -) - -type ConstraintGroup struct { - constraints []*Constraint -} - -// Return a new NewConstrainGroup -func NewConstrainGroup() *ConstraintGroup { - group := new(ConstraintGroup) - - return group -} - -// Return a new NewConstrainGroup and create the constraints based on a string -// -// Version constraints can be specified in a few different ways: -// -// Exact version: You can specify the exact version of a package, for -// example 1.0.2. -// -// Range: By using comparison operators you can specify ranges of valid versions. -// Valid operators are >, >=, <, <=, !=. An example range would be >=1.0. You can -// define multiple ranges, separated by a comma: >=1.0,<2.0. -// -// Wildcard: You can specify a pattern with a * wildcard. 1.0.* is the equivalent -// of >=1.0,<1.1. -// -// Next Significant Release (Tilde Operator): The ~ operator is best explained by -// example: ~1.2 is equivalent to >=1.2,<2.0, while ~1.2.3 is equivalent to -// >=1.2.3,<1.3. As you can see it is mostly useful for projects respecting -// semantic versioning. A common usage would be to mark the minimum minor -// version you depend on, like ~1.2 (which allows anything up to, but not -// including, 2.0). Since in theory there should be no backwards compatibility -// breaks until 2.0, that works well. Another way of looking at it is that -// using ~ specifies a minimum version, but allows the last digit specified -// to go up. -// -// By default only stable releases are taken into consideration. If you would like -// to also get RC, beta, alpha or dev versions of your dependencies you can do so -// using stability flags. To change that for all packages instead of doing per -// dependency you can also use the minimum-stability setting. -// -// From: http://getcomposer.org/doc/01-basic-usage.md#package-versions -func NewConstrainGroupFromString(name string) *ConstraintGroup { - group := new(ConstraintGroup) - group.fromString(name) - - return group -} - -// Adds a Contraint to the group -func (self *ConstraintGroup) AddConstraint(constraint ...*Constraint) { - if self.constraints == nil { - self.constraints = make([]*Constraint, 0) - } - - self.constraints = append(self.constraints, constraint...) -} - -// Return all the constraints -func (self *ConstraintGroup) GetConstraints() []*Constraint { - return self.constraints -} - -// Match a given version againts the group -// -// Usage -// c := version.NewConstrainGroupFromString(">2.0,<=3.0") -// c.Match("2.5.0beta") -// Returns: true -// -// c := version.NewConstrainGroupFromString("~1.2.3") -// c.Match("1.2.3.5") -// Returns: true -func (self *ConstraintGroup) Match(version string) bool { - for _, constraint := range self.constraints { - if constraint.Match(version) == false { - return false - } - } - - return true -} - -func (self *ConstraintGroup) fromString(constraint string) bool { - result := RegFind(`(?i)^([^,\s]*?)@(stable|RC|beta|alpha|dev)$`, constraint) - if result != nil { - constraint = result[1] - if constraint == "" { - constraint = "*" - } - } - - result = RegFind(`(?i)^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$`, constraint) - if result != nil { - if result[1] != "" { - constraint = result[1] - } - } - - constraints := RegSplit(`\s*,\s*`, strings.Trim(constraint, " ")) - - if len(constraints) > 1 { - for _, part := range constraints { - self.AddConstraint(self.parseConstraint(part)...) - } - - return true - } - - self.AddConstraint(self.parseConstraint(constraints[0])...) - - return true -} - -func (self *ConstraintGroup) parseConstraint(constraint string) []*Constraint { - - stabilityModifier := "" - - result := RegFind(`(?i)^([^,\s]+?)@(stable|RC|beta|alpha|dev)$`, constraint) - if result != nil { - constraint = result[1] - if result[2] != "stable" { - stabilityModifier = result[2] - } - } - - result = RegFind(`^[x*](\.[x*])*$`, constraint) - if result != nil { - return make([]*Constraint, 0) - } - - highVersion := "" - lowVersion := "" - - result = RegFind(`(?i)^~(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?`+modifierRegex+`?$`, constraint) - if result != nil { - if len(result) > 4 && result[4] != "" { - last, _ := strconv.Atoi(result[3]) - highVersion = result[1] + "." + result[2] + "." + strconv.Itoa(last+1) + ".0-dev" - lowVersion = result[1] + "." + result[2] + "." + result[3] + "." + result[4] - } else if len(result) > 3 && result[3] != "" { - last, _ := strconv.Atoi(result[2]) - highVersion = result[1] + "." + strconv.Itoa(last+1) + ".0.0-dev" - lowVersion = result[1] + "." + result[2] + "." + result[3] + ".0" - } else { - last, _ := strconv.Atoi(result[1]) - highVersion = strconv.Itoa(last+1) + ".0.0.0-dev" - if len(result) > 2 && result[2] != "" { - lowVersion = result[1] + "." + result[2] + ".0.0" - } else { - lowVersion = result[1] + ".0.0.0" - } - } - - if len(result) > 5 && result[5] != "" { - lowVersion = lowVersion + "-" + expandStability(result[5]) - - } - - if len(result) > 6 && result[6] != "" { - lowVersion = lowVersion + result[6] - } - - if len(result) > 7 && result[7] != "" { - lowVersion = lowVersion + "-dev" - } - - return []*Constraint{ - {">=", lowVersion}, - {"<", highVersion}, - } - } - - result = RegFind(`^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.[x*]$`, constraint) - if result != nil { - if len(result) > 3 && result[3] != "" { - highVersion = result[1] + "." + result[2] + "." + result[3] + ".9999999" - if result[3] == "0" { - last, _ := strconv.Atoi(result[2]) - lowVersion = result[1] + "." + strconv.Itoa(last-1) + ".9999999.9999999" - } else { - last, _ := strconv.Atoi(result[3]) - lowVersion = result[1] + "." + result[2] + "." + strconv.Itoa(last-1) + ".9999999" - } - - } else if len(result) > 2 && result[2] != "" { - highVersion = result[1] + "." + result[2] + ".9999999.9999999" - if result[2] == "0" { - last, _ := strconv.Atoi(result[1]) - lowVersion = strconv.Itoa(last-1) + ".9999999.9999999.9999999" - } else { - last, _ := strconv.Atoi(result[2]) - lowVersion = result[1] + "." + strconv.Itoa(last-1) + ".9999999.9999999" - } - - } else { - highVersion = result[1] + ".9999999.9999999.9999999" - if result[1] == "0" { - return []*Constraint{{"<", highVersion}} - } else { - last, _ := strconv.Atoi(result[1]) - lowVersion = strconv.Itoa(last-1) + ".9999999.9999999.9999999" - } - } - - return []*Constraint{ - {">", lowVersion}, - {"<", highVersion}, - } - } - - // match operators constraints - result = RegFind(`^(<>|!=|>=?|<=?|==?)?\s*(.*)`, constraint) - if result != nil { - version := Normalize(result[2]) - - if stabilityModifier != "" && parseStability(version) == "stable" { - version = version + "-" + stabilityModifier - } else if result[1] == "<" { - match := RegFind(`(?i)-stable$`, result[2]) - if match == nil { - version = version + "-dev" - } - } - - if len(result) > 1 && result[1] != "" { - return []*Constraint{{result[1], version}} - } else { - return []*Constraint{{"=", version}} - - } - } - - return []*Constraint{{constraint, stabilityModifier}} -} - -func RegFind(pattern, subject string) []string { - reg := regexp.MustCompile(pattern) - matched := reg.FindAllStringSubmatch(subject, -1) - - if matched != nil { - return matched[0] - } - - return nil -} - -func RegSplit(pattern, subject string) []string { - reg := regexp.MustCompile(pattern) - indexes := reg.FindAllStringIndex(subject, -1) - - laststart := 0 - result := make([]string, len(indexes)+1) - - for i, element := range indexes { - result[i] = subject[laststart:element[0]] - laststart = element[1] - } - - result[len(indexes)] = subject[laststart:len(subject)] - return result -} diff --git a/vendor/github.com/mcuadros/go-version/normalize.go b/vendor/github.com/mcuadros/go-version/normalize.go deleted file mode 100644 index e2945c9a..00000000 --- a/vendor/github.com/mcuadros/go-version/normalize.go +++ /dev/null @@ -1,116 +0,0 @@ -package version - -import ( - "regexp" - "strings" -) - -var modifierRegex = `[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?` - -var regexpMasterLikeBranches = regexp.MustCompile(`^(?:dev-)?(?:master|trunk|default)$`) -var regexpBranchNormalize = regexp.MustCompile(`(?i)^v?(\d+)(\.(?:\d+|[x*]))?(\.(?:\d+|[x*]))?(\.(?:\d+|[x*]))?$`) - -// Normalizes a version string to be able to perform comparisons on it -// -// Example: -// version.Normalize("10.4.13-b") -// Returns: 10.4.13.0-beta -// -func Normalize(version string) string { - - // ignore aliases and just assume the alias is required instead of the source - result := RegFind(`^([^,\s]+) +as +([^,\s]+)$`, version) - if result != nil { - version = result[1] - } - - // match master-like branches - if regexpMasterLikeBranches.MatchString(strings.ToLower(version)) { - return "9999999-dev" - } - - if strings.HasPrefix(strings.ToLower(version), "dev-") { - return "dev-" + version[4:len(version)] - } - - index := 0 - - // match classical versioning - result = RegFind(`(?i)^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?`+modifierRegex+`$`, version) - if result != nil { - version = "" - for _, val := range result[1:5] { - if val != "" { - version = version + val - } else { - version = version + ".0" - } - } - - index = 5 - } else { - // match date-based versioning - result = RegFind(`(?i)^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)`+modifierRegex+`$`, version) - if result != nil { - version = regexp.MustCompile(`\D`).ReplaceAllString(result[1], "-") - index = 2 - } - } - - if index != 0 { - if result[index] != "" { - if result[index] == "stable" { - return version - } - - version = version + "-" + expandStability(result[index]) - if result[index+1] != "" { - version = version + result[index+1] - } - } - - if result[index+2] != "" { - version = version + "-dev" - } - - return version - } - - result = RegFind(`(?i)(.*?)[.-]?dev$`, version) - if result != nil { - return normalizeBranch(result[1]) - } - - return version -} - -func normalizeBranch(name string) string { - name = strings.Trim(name, " ") - - if name == "master" || name == "trunk" || name == "default" { - return Normalize(name) - } - - replace := strings.NewReplacer("*", "9999999", "x", "9999999") - - matched := regexpBranchNormalize.FindAllStringSubmatch(name, -1) - if matched != nil { - name = "" - for _, val := range matched[0][1:5] { - if val != "" { - name = name + replace.Replace(val) - } else { - name = name + ".9999999" - } - } - - return name + "-dev" - - } - - if strings.HasSuffix(strings.ToLower(name), "-dev") { - return name - } - - return "dev-" + name -} diff --git a/vendor/github.com/mcuadros/go-version/sort.go b/vendor/github.com/mcuadros/go-version/sort.go deleted file mode 100644 index 70eb2ca9..00000000 --- a/vendor/github.com/mcuadros/go-version/sort.go +++ /dev/null @@ -1,36 +0,0 @@ -package version - -import ( - "sort" -) - -// Sorts a string slice of version number strings using version.CompareSimple() -// -// Example: -// version.Sort([]string{"1.10-dev", "1.0rc1", "1.0", "1.0-dev"}) -// Returns []string{"1.0-dev", "1.0rc1", "1.0", "1.10-dev"} -// -func Sort(versionStrings []string) { - versions := versionSlice(versionStrings) - sort.Sort(versions) -} - -type versionSlice []string - -func (s versionSlice) Len() int { - return len(s) -} - -func (s versionSlice) Less(i, j int) bool { - cmp := CompareSimple(Normalize(s[i]), Normalize(s[j])) - if cmp == 0 { - return s[i] < s[j] - } - return cmp < 0 -} - -func (s versionSlice) Swap(i, j int) { - tmp := s[j] - s[j] = s[i] - s[i] = tmp -} diff --git a/vendor/github.com/mcuadros/go-version/stability.go b/vendor/github.com/mcuadros/go-version/stability.go deleted file mode 100644 index 566f7d90..00000000 --- a/vendor/github.com/mcuadros/go-version/stability.go +++ /dev/null @@ -1,83 +0,0 @@ -package version - -import ( - "regexp" - "strings" -) - -const ( - Development = iota - Alpha - Beta - RC - Stable -) - -func expandStability(stability string) string { - stability = strings.ToLower(stability) - - switch stability { - case "a": - return "alpha" - case "b": - return "beta" - case "p": - return "patch" - case "pl": - return "patch" - case "rc": - return "RC" - } - - return stability -} - -func parseStability(version string) string { - version = regexp.MustCompile(`(?i)#.+$`).ReplaceAllString(version, " ") - version = strings.ToLower(version) - - if strings.HasPrefix(version, "dev-") || strings.HasSuffix(version, "-dev") { - return "dev" - } - - result := RegFind(`(?i)^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?`+modifierRegex+`$`, version) - if result != nil { - if len(result) > 3 { - return "dev" - } - } - - if result[1] != "" { - if "beta" == result[1] || "b" == result[1] { - return "beta" - } - if "alpha" == result[1] || "a" == result[1] { - return "alpha" - } - if "rc" == result[1] { - return "RC" - } - } - - return "stable" -} - -func GetStability(version string) int { - result := RegFind(`(?i)(stable|RC|beta|alpha|dev)`, Normalize(version)) - if len(result) == 0 { - return Stable - } - - switch result[1] { - case "dev": - return Development - case "alpha": - return Alpha - case "beta": - return Beta - case "RC": - return RC - } - - return Stable -} diff --git a/vendor/github.com/rancher/convoy/.drone.yml b/vendor/github.com/rancher/convoy/.drone.yml deleted file mode 100644 index b0f0e2eb..00000000 --- a/vendor/github.com/rancher/convoy/.drone.yml +++ /dev/null @@ -1,4 +0,0 @@ -image: rancher/dind:v1.10.0-rancher1 -script: - - wrapdocker - - make ci diff --git a/vendor/github.com/rancher/convoy/.gitignore b/vendor/github.com/rancher/convoy/.gitignore deleted file mode 100644 index 4eaf69ae..00000000 --- a/vendor/github.com/rancher/convoy/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -# 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 - -longhorn/template.go diff --git a/vendor/github.com/rancher/convoy/.package b/vendor/github.com/rancher/convoy/.package deleted file mode 100644 index 443ab7bf..00000000 --- a/vendor/github.com/rancher/convoy/.package +++ /dev/null @@ -1 +0,0 @@ -github.com/rancher/convoy diff --git a/vendor/github.com/rancher/convoy/.wrap-docker-args b/vendor/github.com/rancher/convoy/.wrap-docker-args deleted file mode 100644 index 6fe60d2a..00000000 --- a/vendor/github.com/rancher/convoy/.wrap-docker-args +++ /dev/null @@ -1,5 +0,0 @@ ---privileged \ --e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \ --e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \ --e CONVOY_TEST_AWS_REGION=${CONVOY_TEST_AWS_REGION} \ --e CONVOY_TEST_AWS_BUCKET=${CONVOY_TEST_AWS_BUCKET} diff --git a/vendor/github.com/rancher/convoy/Dockerfile.dapper b/vendor/github.com/rancher/convoy/Dockerfile.dapper deleted file mode 100644 index 0c465004..00000000 --- a/vendor/github.com/rancher/convoy/Dockerfile.dapper +++ /dev/null @@ -1,59 +0,0 @@ -FROM ubuntu:16.04 - -# Install packages -RUN apt-get update && \ - apt-get install -y \ - cmake \ - curl \ - git \ - libglib2.0-dev \ - libkmod-dev \ - libnl-genl-3-dev \ - linux-libc-dev \ - pkg-config \ - psmisc \ - python-tox - -# Install Go 1.6 -RUN curl -o go.tar.gz https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz -RUN echo 'e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a go.tar.gz' | sha256sum -c && \ - tar xzf go.tar.gz -C /usr/local && \ - rm go.tar.gz -RUN mkdir -p /go -ENV PATH $PATH:/usr/local/go/bin -ENV GOPATH=/go - -# Go tools -RUN go get github.com/rancher/trash -RUN go get github.com/golang/lint/golint - -# Docker -RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ - chmod +x /usr/bin/docker - -# Install liblvm2 -RUN curl -o lvm.tar.gz https://git.fedorahosted.org/cgit/lvm2.git/snapshot/lvm2-2_02_103.tar.gz && \ - tar xzf lvm.tar.gz -C /usr/local/ && \ - cd /usr/local/lvm2-2_02_103 && \ - ./configure --enable-static_link && \ - make device-mapper && \ - make install_device-mapper - -# Install convoy-pdata_tools -RUN curl -sL https://github.com/rancher/thin-provisioning-tools/releases/download/convoy-v0.2.1/convoy-pdata_tools > /usr/local/bin/convoy-pdata_tools && \ - chmod a+x /usr/local/bin/convoy-pdata_tools - -# Setup environment -ENV PATH /go/bin:$PATH -ENV DAPPER_DOCKER_SOCKET true -ENV DAPPER_ENV TAG REPO -ENV DAPPER_OUTPUT ./bin ./dist -ENV DAPPER_RUN_ARGS --privileged -ENV DAPPER_SOURCE /go/src/github.com/rancher/convoy -ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache -WORKDIR ${DAPPER_SOURCE} - -VOLUME /tmp -ENV TMPDIR /tmp -ENTRYPOINT ["./scripts/entry"] -CMD ["build"] diff --git a/vendor/github.com/rancher/convoy/Makefile b/vendor/github.com/rancher/convoy/Makefile deleted file mode 100644 index d7d72a16..00000000 --- a/vendor/github.com/rancher/convoy/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TARGETS := $(shell ls scripts) - -.dapper: - @echo Downloading dapper - @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp - @@chmod +x .dapper.tmp - @./.dapper.tmp -v - @mv .dapper.tmp .dapper - -$(TARGETS): .dapper - ./.dapper $@ - -trash: .dapper - ./.dapper -m bind trash - -trash-keep: .dapper - ./.dapper -m bind trash -k - -deps: trash - -.DEFAULT_GOAL := ci - -.PHONY: $(TARGETS) diff --git a/vendor/github.com/rancher/convoy/README.md b/vendor/github.com/rancher/convoy/README.md deleted file mode 100644 index 33a0a1a7..00000000 --- a/vendor/github.com/rancher/convoy/README.md +++ /dev/null @@ -1,214 +0,0 @@ -# Convoy [![Build Status](http://ci.rancher.io/api/badge/github.com/rancher/convoy/status.svg?branch=master)](http://ci.rancher.io/github.com/rancher/convoy) - -## Overview -Convoy is a Docker volume plugin for a variety of storage back-ends. It's designed to be a simple Docker volume plug-ins that supports vendor-specific extensions such as snapshots, backups and restore. It's written in Go and can be deployed as a standalone binary. - -[![Convoy_DEMO](https://asciinema.org/a/9y5nbp3h97vyyxnzuax9f568e.png)](https://asciinema.org/a/9y5nbp3h97vyyxnzuax9f568e?autoplay=1&loop=1&size=medium&speed=2) - -## Why we need Convoy? -Docker has various drivers(aufs, device mapper, etc) for container's root image, but not for volumes. User can create volume through ```docker run -v volname```, but it's disposable, cannot be easily reused for new containers or containers on the other hosts. For example, if you start a wordpress container with database, add some posts, remove the container, then the modified database would lost. - -Before volume plugin, the only way to reuse the volume is using host bind mount feature of Docker, as ```docker run -v /host_path:/container_path```, then maintain the content of the volume at ```/host_path```. You can also use ```--volume-from``` but that would require original container still exists on the same host. - -Convoy used Docker volume plugin mechanism to provide persistent volume for Docker containers, and supports various of backends(e.g. device mapper, NFS, EBS) and more features like snapshot/backup/restore. So user would able to migrate the volumes between the hosts, share the same volume across the hosts, make scheduled snapshots of as well as recover to previous version of volume. It's much easier for user to manage data with Docker volumes with Convoy. - -### Backends supported by Convoy currently -* Device Mapper -* Virtual File System(VFS)/Network File System(NFS) -* Amazon Elastic Block Store(EBS) - -## Quick Start Guide -First let's make sure we have Docker 1.8 or above running. -``` -docker --version -``` -If not, install the latest Docker daemon as follows: -``` -curl -sSL https://get.docker.com/ | sh -``` -Once we have made sure we have the right Docker daemon running, we can install and configure Convoy volume plugin as follows: -``` -wget https://github.com/rancher/convoy/releases/download/v0.4.3/convoy.tar.gz -tar xvf convoy.tar.gz -sudo cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/ -sudo mkdir -p /etc/docker/plugins/ -sudo bash -c 'echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec' -``` -We can use file-backed loopback device to test and demo Convoy Device Mapper driver. Loopback device, however, is known to be unstable and should not be used in production. -``` -truncate -s 100G data.vol -truncate -s 1G metadata.vol -sudo losetup /dev/loop5 data.vol -sudo losetup /dev/loop6 metadata.vol -``` -Once we have the data and metadata device setup, we can start the Convoy plugin daemon as follows: -``` -sudo convoy daemon --drivers devicemapper --driver-opts dm.datadev=/dev/loop5 --driver-opts dm.metadatadev=/dev/loop6 -``` -We can create a Docker container with a convoy volume. As a test, we create a file called `/vol1/foo` in the convoy volume: -``` -sudo docker run -v vol1:/vol1 --volume-driver=convoy ubuntu touch /vol1/foo -``` -Next we take a snapshot of the convoy volume. We backup the snapshot to a local directory: (Backup to NFS share or S3 objectore is also supported.) -``` -sudo convoy snapshot create vol1 --name snap1vol1 -sudo mkdir -p /opt/convoy/ -sudo convoy backup create snap1vol1 --dest vfs:///opt/convoy/ -``` -The `convoy backup` command returns a URL string representing backup dataset. You can use the same URL string to recover the volume to another host: -``` -sudo convoy create res1 --backup -``` -The following command creates a new container and mounts the recovered convoy volume into that container: -``` -sudo docker run -v res1:/res1 --volume-driver=convoy ubuntu ls /res1/foo -``` -You should see the recovered file ```/res1/foo```. - -## Installation -Ensure you have Docker 1.8 or above installed. - -Download latest version of [convoy](https://github.com/rancher/convoy/releases/download/v0.4.3/convoy.tar.gz) and unzip it. Put the binaries in a directory in the execution ```$PATH``` of sudo and root users (e.g. /usr/local/bin). -``` -wget https://github.com/rancher/convoy/releases/download/v0.4.3/convoy.tar.gz -tar xvf convoy.tar.gz -sudo cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/ -``` -Run the following commands to setup the Convoy volume plugin for Docker: -``` -sudo mkdir -p /etc/docker/plugins/ -sudo bash -c 'echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec' -``` - -## Start Convoy Daemon - -You need to pass different arguments to convoy daemon depending on the choice of backend implementation. - -#### Device Mapper -For production environment, it's recommended to attach a new empty block device to the host Convoy running on for using Device Mapper driver. Then you can make two partitions out of the device using [`dm_dev_partition.sh`](https://raw.githubusercontent.com/rancher/convoy/master/tools/dm_dev_partition.sh) to get two block devices fitting for Device Mapper driver. See [Device Mapper Partition Helper](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#device-mapper-partition-helper) for more details. - -Device Mapper requires two block devices to create storage pool for all volumes and snapshots. Assuming you have two devices created, one data device called `/dev/convoy-vg/data` and the other metadata device called `/dev/convoy-vg/metadata`. You run the following command to start the Convoy daemon: -``` -sudo convoy daemon --drivers devicemapper --driver-opts dm.datadev=/dev/convoy-vg/data --driver-opts dm.metadatadev=/dev/convoy-vg/metadata -``` -* A default Device Mapper volume size is 100G. You can override it with the `---driver-opts dm.defaultvolumesize` option. -* You can take a look at [here](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#calculate-the-size-you-need-for-metadata-block-device) if you want to know how much storage need to be allocated for metadata device. - -#### NFS -First, mount the NFS share to the root directory used to store volumes. Substitute `` to the appropriate directory of your choice: -``` -sudo mkdir -sudo mount -t nfs :/path -``` -The NFS-based Convoy daemon can be started as follows: -``` -sudo convoy daemon --drivers vfs --driver-opts vfs.path= -``` - -#### EBS -Make sure you're running on EC2 instance, and has already [configured AWS credentials](https://github.com/aws/aws-sdk-go#configuring-credentials) correctly. -``` -sudo convoy daemon --drivers ebs -``` - -## Volume Commands -#### Create a Volume - -Volumes can be created using the `convoy create` command: -``` -sudo convoy create volume_name -``` -* Device Mapper: Default volume size is 100G. `--size` [option](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#create) is supported. -* EBS: Default volume size is 4G. `--size` and [some other options](https://github.com/rancher/convoy/blob/master/docs/ebs.md#create) are supported. - -We can also create a volume using the [`docker run`](https://github.com/rancher/convoy/blob/master/docs/docker.md#create-container) command. If the volume does not yet exist, a new volume will be created. Otherwise the existing volume will be used. -``` -sudo docker run -it -v test_volume:/test --volume-driver=convoy ubuntu -``` - -#### Delete a Volume -``` -sudo convoy delete -``` -or -``` -sudo docker rm -v -``` -* NFS or EBS: The `-r/--reference` option instructs the `convoy delete` command to only delete the reference to the volume from the current host and leave the underlying files on [NFS server](https://github.com/rancher/convoy/blob/master/docs/vfs.md#delete) or [EBS volume](https://github.com/rancher/convoy/blob/master/docs/ebs.md#delete) unchanged. This is useful when the volume need to be reused later. -* [`docker rm -v`](https://github.com/rancher/convoy/blob/master/docs/docker.md#delete-container) would be treated as `convoy delete` with `-r/--reference`. -* If you use `--rm` with `docker run`, all the volumes associated with the container would be deleted in the same way as executing `docker rm -v` when exit. See [Docker run reference](https://docs.docker.com/engine/reference/run/) for details. - -#### List and Inspect a Volume -``` -sudo convoy list -sudo convoy inspect vol1 -``` - -#### Take Snapshot of a Volume -``` -sudo convoy snapshot create vol1 --name snap1vol1 -``` - -#### Delete a Snapshot -``` -sudo convoy snapshot delete snap1vol1 -``` -* Device Mapper: please make sure you keep [the latest backed-up snapshot](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md#backup-create) for the same volume available to enable incremental backup mechanism, since Convoy need it to calculate the differences between snapshots. - -#### Backup a Snapshot -* Device Mapper or VFS: We can backup a snapshot to S3 object store or an NFS mount/local directory: -``` -sudo convoy backup create snap1vol1 --dest s3://backup-bucket@us-west-2/ -``` -or -``` -sudo convoy backup create snap1vol1 --dest vfs:///opt/backup/ -``` - -The backup operation returns a URL string that uniquely idenfied the backup dataset. -``` -s3://backup-bucket@us-west-2/?backup=f98f9ea1-dd6e-4490-8212-6d50df1982ea\u0026volume=e0d386c5-6a24-446c-8111-1077d10356b0 -``` -If you're using S3, please make sure you have AWS credential ready either at ```~/.aws/credentials``` or as environment variables, as described [here](https://github.com/aws/aws-sdk-go#configuring-credentials). You may need to put credentials to ```/root/.aws/credentials``` or setup sudo environment variables in order to get S3 credential works. - -* EBS: `--dest` is [not needed](https://github.com/rancher/convoy/blob/master/docs/ebs.md#backup-create). Just do `convoy backup create snap1vol1`. - -#### Restore a Volume from Backup -``` -sudo convoy create res1 --backup -``` -* EBS: Current host must be in the [same region](https://github.com/rancher/convoy/blob/master/docs/ebs.md#create) of backup to be restored. - -#### Mount a Restored Volume into a Docker Container -We can use the standard `docker run` command to mount the restored volume into a Docker container: -``` -sudo docker run -it -v res1:/res1 --volume-driver convoy ubuntu -``` - -#### Mount an NFS-Backed Volume on Multiple Servers -You can mount an NFS-backed volume on multiple servers. You can use the standard `docker run` command to mount an existing NFS-backed mount into a Docker container. For example, if you have already created an NFS-based volume `vol1` on one host, you can run the following command to mount the existing `vol1` volume into a new container: -``` -sudo docker run -it -v vol1:/vol1 --volume-driver=convoy ubuntu -``` -## Support and Discussion -If you need any help with Convoy, please join us at either our [forum](http://forums.rancher.com/c/convoy) or [#rancher IRC channel](http://webchat.freenode.net/?channels=rancher). - -Feel free to submit any bugs, issues, and feature requests to [Convoy Issues](https://github.com/rancher/convoy/issues). - -## Contribution -Contribution are welcome! Please take a look at [Development Guide](https://github.com/rancher/convoy/blob/master/docs/development.md) if you want to how to build Convoy from source or running test cases. - -We love to hear new Convoy Driver ideas from you. Implemenations are most welcome! Please consider take a look at [enhancement ideas](https://github.com/rancher/convoy/labels/enhancement) if you want contribute. - -And of course, [bug fixes](https://github.com/rancher/convoy/issues) are always welcome! - -## References -[Convoy Command Line Reference](https://github.com/rancher/convoy/blob/master/docs/cli_reference.md) - -[Using Convoy with Docker](https://github.com/rancher/convoy/blob/master/docs/docker.md) -#### Driver Specific -[Device Mapper](https://github.com/rancher/convoy/blob/master/docs/devicemapper.md) - -[Amazon Elastic Block Store](https://github.com/rancher/convoy/blob/master/docs/ebs.md) - -[Virtual File System/Network File System](https://github.com/rancher/convoy/blob/master/docs/vfs.md) diff --git a/vendor/github.com/rancher/convoy/api/const.go b/vendor/github.com/rancher/convoy/api/const.go deleted file mode 100644 index a1eb5e5b..00000000 --- a/vendor/github.com/rancher/convoy/api/const.go +++ /dev/null @@ -1,10 +0,0 @@ -package api - -const ( - // API_VERSION is the API version of Convoy daemon - API_VERSION = "1" - - KEY_NAME = "name" - KEY_BACKUP_URL = "backup" - KEY_DEST_URL = "dest" -) diff --git a/vendor/github.com/rancher/convoy/api/request.go b/vendor/github.com/rancher/convoy/api/request.go deleted file mode 100644 index 0c5cd866..00000000 --- a/vendor/github.com/rancher/convoy/api/request.go +++ /dev/null @@ -1,62 +0,0 @@ -package api - -type VolumeMountRequest struct { - VolumeName string - MountPoint string - Verbose bool -} - -type VolumeUmountRequest struct { - VolumeName string -} - -type VolumeCreateRequest struct { - Name string - DriverName string - Size int64 - BackupURL string - DriverVolumeID string - Type string - IOPS int64 - PrepareForVM bool - Verbose bool -} - -type VolumeDeleteRequest struct { - VolumeName string - ReferenceOnly bool -} - -type VolumeInspectRequest struct { - VolumeName string -} - -type SnapshotCreateRequest struct { - Name string - VolumeName string - Verbose bool -} - -type SnapshotDeleteRequest struct { - SnapshotName string -} - -type SnapshotInspectRequest struct { - SnapshotName string -} - -type BackupListRequest struct { - URL string - VolumeName string - SnapshotName string -} - -type BackupCreateRequest struct { - URL string - SnapshotName string - Verbose bool -} - -type BackupDeleteRequest struct { - URL string -} diff --git a/vendor/github.com/rancher/convoy/api/response.go b/vendor/github.com/rancher/convoy/api/response.go deleted file mode 100644 index 964a4f58..00000000 --- a/vendor/github.com/rancher/convoy/api/response.go +++ /dev/null @@ -1,83 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "runtime" - "runtime/debug" - "strings" - - "github.com/Sirupsen/logrus" -) - -type ErrorResponse struct { - Error string -} - -type VolumeResponse struct { - Name string - Driver string - MountPoint string - CreatedTime string - DriverInfo map[string]string - Snapshots map[string]SnapshotResponse -} - -type SnapshotResponse struct { - Name string - VolumeName string `json:",omitempty"` - VolumeCreatedAt string `json:",omitempty"` - CreatedTime string - DriverInfo map[string]string -} - -type BackupURLResponse struct { - URL string -} - -// ResponseError would generate a error information in JSON format for output -func ResponseError(format string, a ...interface{}) { - response := ErrorResponse{Error: fmt.Sprintf(format, a...)} - j, err := json.MarshalIndent(&response, "", "\t") - if err != nil { - panic(fmt.Sprintf("Failed to generate response for error:", err)) - } - fmt.Println(string(j[:])) -} - -// ResponseLogAndError would log the error before call ResponseError() -func ResponseLogAndError(v interface{}) { - if e, ok := v.(*logrus.Entry); ok { - e.Error(e.Message) - oldFormatter := e.Logger.Formatter - logrus.SetFormatter(&logrus.JSONFormatter{}) - s, err := e.String() - logrus.SetFormatter(oldFormatter) - if err != nil { - ResponseError(err.Error()) - return - } - // Cosmetic since " would be escaped - ResponseError(strings.Replace(s, "\"", "'", -1)) - } else { - e, isErr := v.(error) - _, isRuntimeErr := e.(runtime.Error) - if isErr && !isRuntimeErr { - logrus.Errorf(fmt.Sprint(e)) - ResponseError(fmt.Sprint(e)) - } else { - logrus.Errorf("Caught FATAL error: %s", v) - debug.PrintStack() - ResponseError("Caught FATAL error: %s", v) - } - } -} - -// ResponseOutput would generate a JSON format byte array of object for output -func ResponseOutput(v interface{}) ([]byte, error) { - j, err := json.MarshalIndent(v, "", "\t") - if err != nil { - return nil, err - } - return j, nil -} diff --git a/vendor/github.com/rancher/convoy/apply.sh b/vendor/github.com/rancher/convoy/apply.sh deleted file mode 100755 index f8c86158..00000000 --- a/vendor/github.com/rancher/convoy/apply.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -source ${CATTLE_HOME:-/var/lib/cattle}/common/scripts.sh - -trap "touch $CATTLE_HOME/.pyagent-stamp" exit - -cd $(dirname $0) - -mkdir -p ${CATTLE_HOME}/bin - -cp bin/convoy bin/convoy-pdata_tools ${CATTLE_HOME}/bin - -chmod +x ${CATTLE_HOME}/bin/convoy -chmod +x ${CATTLE_HOME}/bin/convoy-pdata_tools diff --git a/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go b/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go deleted file mode 100644 index dd14d0d1..00000000 --- a/vendor/github.com/rancher/convoy/convoydriver/convoydriver.go +++ /dev/null @@ -1,130 +0,0 @@ -package convoydriver - -import ( - "fmt" - "path/filepath" - - "github.com/Sirupsen/logrus" -) - -/* -InitFunc is the initialize function for each ConvoyDriver. Each driver must -implement this function and register itself through Register(). - -The registered function would be called upon Convoy need a ConvoyDriver -instance, and it would return a valid ConvoyDriver for operation. - -The registered function would take a "root" path, used as driver's configuration -file path, and a map of configuration specified for the driver. -*/ -type InitFunc func(root string, config map[string]string) (ConvoyDriver, error) - -/* -ConvoyDriver interface would provide all the functionality needed for driver -specific handling. Driver can choose to implement some or all of the available -operations interfaces to provide different functionality to Convoy user. -xxxOps() should return error if the functionality is not implemented by the -driver. -*/ -type ConvoyDriver interface { - Name() string - Info() (map[string]string, error) - - VolumeOps() (VolumeOperations, error) - SnapshotOps() (SnapshotOperations, error) - BackupOps() (BackupOperations, error) -} - -type Request struct { - Name string - Options map[string]string -} - -/* -VolumeOperations is Convoy Driver volume related operations interface. Any -Convoy Driver must implement this interface. -*/ -type VolumeOperations interface { - Name() string - CreateVolume(req Request) error - DeleteVolume(req Request) error - MountVolume(req Request) (string, error) - UmountVolume(req Request) error - MountPoint(req Request) (string, error) - GetVolumeInfo(name string) (map[string]string, error) - ListVolume(opts map[string]string) (map[string]map[string]string, error) -} - -/* -SnapshotOperations is Convoy Driver snapshot related operations interface. Any -Convoy Driver want to operate snapshots must implement this interface. -*/ -type SnapshotOperations interface { - Name() string - CreateSnapshot(req Request) error - DeleteSnapshot(req Request) error - GetSnapshotInfo(req Request) (map[string]string, error) - ListSnapshot(opts map[string]string) (map[string]map[string]string, error) -} - -/* -BackupOperations is Convoy Driver backup related operations interface. Any -Convoy Driver want to provide backup functionality must implement this -interface. Restore would need to be implemented in -VolumeOperations.CreateVolume() with opts[OPT_BACKUP_URL] -*/ -type BackupOperations interface { - Name() string - CreateBackup(snapshotID, volumeID, destURL string, opts map[string]string) (string, error) - DeleteBackup(backupURL string) error - GetBackupInfo(backupURL string) (map[string]string, error) - ListBackup(destURL string, opts map[string]string) (map[string]map[string]string, error) -} - -const ( - OPT_MOUNT_POINT = "MountPoint" - OPT_SIZE = "Size" - OPT_FORMAT = "Format" - OPT_VOLUME_NAME = "VolumeName" - OPT_VOLUME_DRIVER_ID = "VolumeDriverID" - OPT_VOLUME_TYPE = "VolumeType" - OPT_VOLUME_IOPS = "VolumeIOPS" - OPT_VOLUME_CREATED_TIME = "VolumeCreatedAt" - OPT_SNAPSHOT_NAME = "SnapshotName" - OPT_SNAPSHOT_CREATED_TIME = "SnapshotCreatedAt" - OPT_BACKUP_URL = "BackupURL" - OPT_REFERENCE_ONLY = "ReferenceOnly" - OPT_PREPARE_FOR_VM = "PrepareForVM" - OPT_FILESYSTEM = "Filesystem" -) - -var ( - initializers map[string]InitFunc - log = logrus.WithFields(logrus.Fields{"pkg": "convoydriver"}) -) - -func init() { - initializers = make(map[string]InitFunc) -} - -/* -Register would add specified InitFunc of Convoy Driver to the known driver list. -*/ -func Register(name string, initFunc InitFunc) error { - if _, exists := initializers[name]; exists { - return fmt.Errorf("Driver %s has already been registered", name) - } - initializers[name] = initFunc - return nil -} - -/* -GetDriver would be called each time when a Convoy Driver instance is needed. -*/ -func GetDriver(name, root string, config map[string]string) (ConvoyDriver, error) { - if _, exists := initializers[name]; !exists { - return nil, fmt.Errorf("Driver %v is not supported!", name) - } - drvRoot := filepath.Join(root, name) - return initializers[name](drvRoot, config) -} diff --git a/vendor/github.com/rancher/convoy/metadata/devmapper.go b/vendor/github.com/rancher/convoy/metadata/devmapper.go deleted file mode 100644 index 77c994a8..00000000 --- a/vendor/github.com/rancher/convoy/metadata/devmapper.go +++ /dev/null @@ -1,40 +0,0 @@ -package metadata - -import ( - "encoding/xml" -) - -func DeviceMapperThinDeltaParser(data []byte, blockSize int64, includeSame bool) (*Mappings, error) { - type Entry struct { - XMLName xml.Name - Begin int64 `xml:"begin,attr"` - Length int64 `xml:"length,attr"` - } - - type Diff struct { - Entries []Entry `xml:",any"` - } - - type Superblock struct { - Diff Diff `xml:"diff"` - } - - superblock := &Superblock{} - if err := xml.Unmarshal(data, superblock); err != nil { - return nil, err - } - - mapping := &Mappings{} - for _, d := range superblock.Diff.Entries { - if !includeSame && d.XMLName.Local == "same" { - continue - } - var m Mapping - m.Offset = d.Begin * blockSize - m.Size = d.Length * blockSize - mapping.Mappings = append(mapping.Mappings, m) - } - mapping.BlockSize = blockSize - - return mapping, nil -} diff --git a/vendor/github.com/rancher/convoy/util/config.go b/vendor/github.com/rancher/convoy/util/config.go deleted file mode 100644 index 65c6ab9e..00000000 --- a/vendor/github.com/rancher/convoy/util/config.go +++ /dev/null @@ -1,155 +0,0 @@ -package util - -import ( - "encoding/json" - "errors" - "fmt" - "os" - "path" - "path/filepath" - "reflect" -) - -var errDoesNotExist = errors.New("No such volume") - -func LoadConfig(fileName string, v interface{}) error { - if _, err := os.Stat(fileName); err != nil { - return err - } - - file, err := os.Open(fileName) - if err != nil { - return err - } - - defer file.Close() - - if err = json.NewDecoder(file).Decode(v); err != nil { - return err - } - return nil -} - -func SaveConfig(fileName string, v interface{}) error { - tmpFileName := fileName + ".tmp" - - f, err := os.Create(tmpFileName) - if err != nil { - return err - } - - if err := json.NewEncoder(f).Encode(v); err != nil { - f.Close() - return err - } - f.Close() - - if _, err = os.Stat(fileName); err == nil { - if err = os.Remove(fileName); err != nil { - return err - } - } - - if err := os.Rename(tmpFileName, fileName); err != nil { - return err - } - - return nil -} - -func ConfigExists(fileName string) bool { - _, err := os.Stat(fileName) - return err == nil -} - -func RemoveConfig(fileName string) error { - if _, err := Execute("rm", []string{"-f", fileName}); err != nil { - return err - } - return nil -} - -func ListConfigIDs(root, prefix, suffix string) ([]string, error) { - pattern := path.Join(root, fmt.Sprintf("%s*%s", prefix, suffix)) - out, err := filepath.Glob(pattern) - if err != nil { - return nil, err - } - if len(out) == 0 { - return []string{}, nil - } - for i := range out { - out[i] = path.Base(out[i]) - } - return ExtractNames(out, prefix, suffix) -} - -type ObjectOperations interface { - ConfigFile() (string, error) -} - -func getObjectOps(obj interface{}) (ObjectOperations, error) { - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - return nil, fmt.Errorf("BUG: Non-pointer was passed in") - } - t := reflect.TypeOf(obj).Elem() - ops, ok := obj.(ObjectOperations) - if !ok { - return nil, fmt.Errorf("BUG: %v doesn't implement necessary methods for accessing object", t) - } - return ops, nil -} - -func ObjectConfig(obj interface{}) (string, error) { - ops, err := getObjectOps(obj) - if err != nil { - return "", err - } - config, err := ops.ConfigFile() - if err != nil { - return "", err - } - return config, nil -} - -func ObjectLoad(obj interface{}) error { - config, err := ObjectConfig(obj) - if err != nil { - return err - } - if !ConfigExists(config) { - return errDoesNotExist - } - if err := LoadConfig(config, obj); err != nil { - return err - } - return nil -} - -func ObjectExists(obj interface{}) (bool, error) { - config, err := ObjectConfig(obj) - if err != nil { - return false, err - } - return ConfigExists(config), nil -} - -func ObjectSave(obj interface{}) error { - config, err := ObjectConfig(obj) - if err != nil { - return err - } - return SaveConfig(config, obj) -} - -func ObjectDelete(obj interface{}) error { - config, err := ObjectConfig(obj) - if err != nil { - return err - } - return RemoveConfig(config) -} - -func IsNotExistsError(err error) bool { - return err == errDoesNotExist -} diff --git a/vendor/github.com/rancher/convoy/util/index.go b/vendor/github.com/rancher/convoy/util/index.go deleted file mode 100644 index 2b00e849..00000000 --- a/vendor/github.com/rancher/convoy/util/index.go +++ /dev/null @@ -1,55 +0,0 @@ -package util - -import ( - "fmt" - "sync" -) - -type Index struct { - data map[string]string - lock *sync.RWMutex -} - -func NewIndex() *Index { - return &Index{data: make(map[string]string), lock: &sync.RWMutex{}} -} - -func (idx *Index) Add(key, value string) error { - if key == "" { - return fmt.Errorf("BUG: Invalid empty index key") - } - if value == "" { - return fmt.Errorf("BUG: Invalid empty index value") - } - - idx.lock.Lock() - defer idx.lock.Unlock() - - if oldValue, exists := idx.data[key]; exists { - if oldValue != value { - return fmt.Errorf("BUG: Conflict when updating index, %v was mapped to %v, but %v want to be mapped too", key, oldValue, value) - } - return nil - } - idx.data[key] = value - return nil -} - -func (idx *Index) Delete(key string) error { - if key == "" { - return fmt.Errorf("BUG: Invalid empty index key") - } - - idx.lock.Lock() - defer idx.lock.Unlock() - - delete(idx.data, key) - return nil -} - -func (idx *Index) Get(key string) string { - idx.lock.RLock() - defer idx.lock.RUnlock() - - return idx.data[key] -} diff --git a/vendor/github.com/rancher/convoy/util/util.go b/vendor/github.com/rancher/convoy/util/util.go deleted file mode 100644 index f6eeecf9..00000000 --- a/vendor/github.com/rancher/convoy/util/util.go +++ /dev/null @@ -1,460 +0,0 @@ -package util - -import ( - "bytes" - "compress/gzip" - "crypto/sha512" - "encoding/hex" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "os" - "os/exec" - "regexp" - "strconv" - "strings" - "time" - - "github.com/Sirupsen/logrus" - "github.com/codegangsta/cli" - "github.com/mcuadros/go-version" - "github.com/satori/go.uuid" - "golang.org/x/sys/unix" -) - -const ( - PRESERVED_CHECKSUM_LENGTH = 64 -) - -var ( - log = logrus.WithFields(logrus.Fields{"pkg": "util"}) - - cmdTimeout time.Duration = time.Minute // one minute by default -) - -func InitTimeout(timeout string) { - if timeout == "" { - return - } - - duration, err := time.ParseDuration(timeout) - if err != nil || duration < cmdTimeout { - log.Errorf("Invalid timeout value %s specified, default to one minute", timeout) - return - } - - log.Debugf("Set command timeout value to: %s", duration.String()) - cmdTimeout = duration -} - -func EncodeData(v interface{}) (*bytes.Buffer, error) { - param := bytes.NewBuffer(nil) - j, err := json.Marshal(v) - if err != nil { - return nil, err - } - if _, err := param.Write(j); err != nil { - return nil, err - } - return param, nil -} - -func MkdirIfNotExists(path string) error { - if _, err := os.Stat(path); os.IsNotExist(err) { - if err := os.MkdirAll(path, os.ModeDir|0700); err != nil { - return err - } - } - return nil -} - -func GetChecksum(data []byte) string { - checksumBytes := sha512.Sum512(data) - checksum := hex.EncodeToString(checksumBytes[:])[:PRESERVED_CHECKSUM_LENGTH] - return checksum -} - -func LockFile(fileName string) (*os.File, error) { - f, err := os.Create(fileName) - if err != nil { - return nil, err - } - if err := unix.Flock(int(f.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil { - f.Close() - return nil, err - } - return f, nil -} - -func UnlockFile(f *os.File) error { - defer f.Close() - if err := unix.Flock(int(f.Fd()), unix.LOCK_UN); err != nil { - return err - } - if _, err := Execute("rm", []string{f.Name()}); err != nil { - return err - } - return nil -} - -func SliceToMap(slices []string) map[string]string { - result := map[string]string{} - for _, v := range slices { - pair := strings.Split(v, "=") - if len(pair) != 2 { - return nil - } - result[pair[0]] = pair[1] - } - return result -} - -func GetFileChecksum(filePath string) (string, error) { - output, err := Execute("sha512sum", []string{"-b", filePath}) - if err != nil { - return "", err - } - return strings.Split(string(output), " ")[0], nil -} - -func CompressFile(filePath string) error { - if _, err := Execute("gzip", []string{filePath}); err != nil { - return err - } - return nil -} - -func DecompressFile(filePath string) error { - if _, err := Execute("gunzip", []string{filePath}); err != nil { - return err - } - return nil -} - -func CompressDir(sourceDir, targetFile string) error { - tmpFile := targetFile + ".tmp" - if _, err := Execute("tar", []string{"cf", tmpFile, "-C", sourceDir, "."}); err != nil { - return err - } - if _, err := Execute("gzip", []string{tmpFile}); err != nil { - return err - } - if _, err := Execute("mv", []string{"-f", tmpFile + ".gz", targetFile}); err != nil { - return err - } - return nil -} - -// If sourceFile is inside targetDir, it would be deleted automatically -func DecompressDir(sourceFile, targetDir string) error { - tmpDir := targetDir + ".tmp" - if _, err := Execute("rm", []string{"-rf", tmpDir}); err != nil { - return err - } - if err := os.Mkdir(tmpDir, os.ModeDir|0700); err != nil { - return err - } - if _, err := Execute("tar", []string{"xf", sourceFile, "-C", tmpDir}); err != nil { - return err - } - if _, err := Execute("rm", []string{"-rf", targetDir}); err != nil { - return err - } - if _, err := Execute("mv", []string{"-f", tmpDir, targetDir}); err != nil { - return err - } - return nil -} - -func Copy(src, dst string) error { - if _, err := Execute("cp", []string{src, dst}); err != nil { - return err - } - return nil -} - -func AttachLoopbackDevice(file string, readonly bool) (string, error) { - params := []string{"--show", "-f"} - if readonly { - params = append(params, "-r") - } - params = append(params, file) - out, err := Execute("losetup", params) - if err != nil { - return "", err - } - if len(out) == 0 { - return "", fmt.Errorf("losetup --show doesn't return device name") - } - return strings.TrimSpace(out), nil -} - -func DetachLoopbackDevice(file, dev string) error { - output, err := Execute("losetup", []string{dev}) - if err != nil { - return err - } - out := strings.TrimSpace(string(output)) - suffix := "(" + file + ")" - if !strings.HasSuffix(out, suffix) { - return fmt.Errorf("Unmatched source file, output %v, suffix %v", out, suffix) - } - if _, err := Execute("losetup", []string{"-d", dev}); err != nil { - return err - } - return nil -} - -func ListLoopbackDevice(file string) ([]string, error) { - params := []string{"-O", "NAME", "-n", "-j"} - params = append(params, file) - out, err := Execute("losetup", params) - if err != nil { - return nil, err - } - out = strings.TrimSpace(out) - if len(out) == 0 { - return []string{}, nil - } - return strings.Split(out, "\n"), nil -} - -func DetachAnyLoopbackDevice(file string) error { - devices, err := ListLoopbackDevice(file) - if err != nil { - return err - } - for _, dev := range devices { - if err := DetachLoopbackDevice(file, dev); err != nil { - return err - } - } - return nil -} - -func ValidateName(name string) bool { - validName := regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`) - return validName.MatchString(name) -} - -func CheckName(name string) error { - if name == "" { - return nil - } - if !ValidateName(name) { - return fmt.Errorf("Invalid name %v", name) - } - return nil -} - -func ParseSize(size string) (int64, error) { - if size == "" { - return 0, nil - } - size = strings.ToLower(size) - readableSize := regexp.MustCompile(`^[0-9.]+[kmgt]$`) - if !readableSize.MatchString(size) { - value, err := strconv.ParseInt(size, 10, 64) - return value, err - } - - last := len(size) - 1 - unit := string(size[last]) - value, err := strconv.ParseInt(size[:last], 10, 64) - if err != nil { - return 0, err - } - - kb := int64(1024) - mb := 1024 * kb - gb := 1024 * mb - tb := 1024 * gb - switch unit { - case "k": - value *= kb - case "m": - value *= mb - case "g": - value *= gb - case "t": - value *= tb - default: - return 0, fmt.Errorf("Unrecongized size value %v", size) - } - return value, err -} - -func CheckBinaryVersion(binaryName, minVersion string, args []string) error { - output, err := exec.Command(binaryName, args...).CombinedOutput() - if err != nil { - return fmt.Errorf("Failed version check for %s, due to %s", binaryName, err.Error()) - } - v := strings.TrimSpace(string(output)) - if version.Compare(v, minVersion, "<") { - return fmt.Errorf("Minimal require version for %s is %s, detected %s", - binaryName, minVersion, v) - } - return nil -} - -func Execute(binary string, args []string) (string, error) { - var output []byte - var err error - cmd := exec.Command(binary, args...) - done := make(chan struct{}) - - go func() { - output, err = cmd.CombinedOutput() - done <- struct{}{} - }() - - select { - case <-done: - case <-time.After(cmdTimeout): - if cmd.Process != nil { - cmd.Process.Kill() - } - return "", fmt.Errorf("Timeout executing: %v %v, output %v, error %v", binary, args, string(output), err) - } - - if err != nil { - return "", fmt.Errorf("Failed to execute: %v %v, output %v, error %v", binary, args, string(output), err) - } - return string(output), nil -} - -func Now() string { - return time.Now().Format(time.RubyDate) -} - -func CompressData(data []byte) (io.ReadSeeker, error) { - var b bytes.Buffer - w := gzip.NewWriter(&b) - if _, err := w.Write(data); err != nil { - w.Close() - return nil, err - } - w.Close() - return bytes.NewReader(b.Bytes()), nil -} - -func DecompressAndVerify(src io.Reader, checksum string) (io.Reader, error) { - r, err := gzip.NewReader(src) - if err != nil { - return nil, err - } - block, err := ioutil.ReadAll(r) - if err != nil { - return nil, err - } - if GetChecksum(block) != checksum { - return nil, fmt.Errorf("Checksum verification failed for block!") - } - return bytes.NewReader(block), nil -} - -func GetName(v interface{}, key string, required bool, err error) (string, error) { - name, err := GetFlag(v, key, required, err) - if err != nil { - return name, err - } - if !required && name == "" { - return name, nil - } - if err := CheckName(name); err != nil { - return "", err - } - return name, nil -} - -func RequiredMissingError(name string) error { - return fmt.Errorf("Cannot find valid required parameter:", name) -} - -func GetFlag(v interface{}, key string, required bool, err error) (string, error) { - if err != nil { - return "", err - } - value := "" - switch v := v.(type) { - default: - return "", fmt.Errorf("Unexpected type for getLowerCaseFlag") - case *cli.Context: - if key == "" { - value = v.Args().First() - } else { - value = v.String(key) - } - case map[string]string: - value = v[key] - case *http.Request: - if err := v.ParseForm(); err != nil { - return "", err - } - value = v.FormValue(key) - } - if required && value == "" { - err = RequiredMissingError(key) - } - return value, err -} - -func UnescapeURL(url string) string { - // Deal with escape in url inputed from bash - result := strings.Replace(url, "\\u0026", "&", 1) - result = strings.Replace(result, "u0026", "&", 1) - return result -} - -func ValidNetworkAddr(addr string) bool { - //Is it a IP - ip := net.ParseIP(addr) - if ip != nil { - return true - } - //Or host - ips, err := net.LookupIP(addr) - if err != nil { - return false - } - if ips == nil || len(ips) == 0 { - return false - } - return true -} - -func GetFieldFromOpts(name string, opts map[string]string) (string, error) { - value, exists := opts[name] - if !exists { - return "", fmt.Errorf("Cannot find field named %v in options", name) - } - return value, nil -} - -func ExtractNames(names []string, prefix, suffix string) ([]string, error) { - result := []string{} - for i := range names { - f := names[i] - // Remove additional slash if exists - f = strings.TrimLeft(f, "/") - f = strings.TrimPrefix(f, prefix) - f = strings.TrimSuffix(f, suffix) - if !ValidateName(f) { - return nil, fmt.Errorf("Invalid name %v was processed to extract name with prefix %v surfix %v", names[i], prefix, suffix) - } - result = append(result, f) - } - return result, nil -} - -func GenerateName(prefix string) string { - suffix := strings.Replace(NewUUID(), "-", "", -1) - return prefix + "-" + suffix[:16] -} - -func NewUUID() string { - return uuid.NewV4().String() -} diff --git a/vendor/github.com/rancher/convoy/util/volume.go b/vendor/github.com/rancher/convoy/util/volume.go deleted file mode 100644 index e3afcaae..00000000 --- a/vendor/github.com/rancher/convoy/util/volume.go +++ /dev/null @@ -1,459 +0,0 @@ -package util - -import ( - "fmt" - "os" - "path/filepath" - "reflect" - "strconv" - "strings" -) - -const ( - MOUNT_BINARY = "mount" - UMOUNT_BINARY = "umount" - NSENTER_BINARY = "nsenter" - - IMAGE_FILE_NAME = "disk.img" - BLOCK_DEV_NAME = "disk.dev" - - FILE_TYPE_REGULAR = "regular file" - FILE_TYPE_DIRECTORY = "directory" - FILE_TYPE_BLOCKDEVICE = "block special file" - - FILE_STAT_FORMAT_SIZE = "%s" - FILE_STAT_FORMAT_TYPE = "%F" - FILE_STAT_FORMAT_MAJOR_MINOR = "%t %T" -) - -var ( - mountNamespaceFD = "" -) - -/* Caller must implement VolumeHelper interface, and must have fields "Name" and "MountPoint" */ -type VolumeHelper interface { - GetDevice() (string, error) - GetMountOpts() []string - GenerateDefaultMountPoint() string -} - -func getFieldString(obj interface{}, field string) (string, error) { - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - return "", fmt.Errorf("BUG: Non-pointer was passed in") - } - t := reflect.TypeOf(obj).Elem() - if _, found := t.FieldByName(field); !found { - return "", fmt.Errorf("BUG: %v doesn't have required field %v", t, field) - } - return reflect.ValueOf(obj).Elem().FieldByName(field).String(), nil -} - -func setFieldString(obj interface{}, field string, value string) error { - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - return fmt.Errorf("BUG: Non-pointer was passed in") - } - t := reflect.TypeOf(obj).Elem() - if _, found := t.FieldByName(field); !found { - return fmt.Errorf("BUG: %v doesn't have required field %v", t, field) - } - v := reflect.ValueOf(obj).Elem().FieldByName(field) - if !v.CanSet() { - return fmt.Errorf("BUG: %v doesn't have setable field %v", t, field) - } - v.SetString(value) - return nil -} - -func getVolumeName(v VolumeHelper) string { - // We should already pass the test in getVolumeOps - value, err := getFieldString(v, "Name") - if err != nil { - panic(err) - } - return value -} - -func getVolumeMountPoint(v VolumeHelper) string { - // We should already pass the test in getVolumeOps - value, err := getFieldString(v, "MountPoint") - if err != nil { - panic(err) - } - return value -} - -func setVolumeMountPoint(v VolumeHelper, value string) { - // We should already pass the test in getVolumeOps - if err := setFieldString(v, "MountPoint", value); err != nil { - panic(err) - } -} - -func getVolumeOps(obj interface{}) (VolumeHelper, error) { - var err error - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - return nil, fmt.Errorf("BUG: Non-pointer was passed in") - } - _, err = getFieldString(obj, "Name") - if err != nil { - return nil, err - } - mountpoint, err := getFieldString(obj, "MountPoint") - if err != nil { - return nil, err - } - if err = setFieldString(obj, "MountPoint", mountpoint); err != nil { - return nil, err - } - t := reflect.TypeOf(obj).Elem() - ops, ok := obj.(VolumeHelper) - if !ok { - return nil, fmt.Errorf("BUG: %v doesn't implement necessary methods for accessing volume", t) - } - return ops, nil -} - -func isMounted(mountPoint string) bool { - output, err := callMount([]string{}, []string{}) - if err != nil { - return false - } - lines := strings.Split(output, "\n") - for _, line := range lines { - if strings.Contains(line, mountPoint) { - return true - } - } - return false -} - -func VolumeMount(v interface{}, mountPoint string, remount bool) (string, error) { - vol, err := getVolumeOps(v) - if err != nil { - return "", err - } - dev, err := vol.GetDevice() - if err != nil { - return "", err - } - opts := vol.GetMountOpts() - createMountpoint := false - if mountPoint == "" { - mountPoint = vol.GenerateDefaultMountPoint() - // Create of directory cannot be done before umount, because it - // won't be recognized as a directory file when mounted sometime - createMountpoint = true - } - existMount := getVolumeMountPoint(vol) - if existMount != "" && existMount != mountPoint { - return "", fmt.Errorf("Volume %v was already mounted at %v, but asked to mount at %v", getVolumeName(vol), existMount, mountPoint) - } - if remount && isMounted(mountPoint) { - log.Debugf("Umount existing mountpoint %v", mountPoint) - if err := callUmount([]string{mountPoint}); err != nil { - return "", err - } - } - if createMountpoint { - if err := callMkdirIfNotExists(mountPoint); err != nil { - return "", err - } - } - if !isMounted(mountPoint) { - log.Debugf("Volume %v is being mounted it to %v, with option %v", getVolumeName(vol), mountPoint, opts) - _, err = callMount(opts, []string{dev, mountPoint}) - if err != nil { - return "", err - } - } - setVolumeMountPoint(vol, mountPoint) - return mountPoint, nil -} - -func VolumeUmount(v interface{}) error { - vol, err := getVolumeOps(v) - if err != nil { - return err - } - mountPoint := getVolumeMountPoint(vol) - if mountPoint == "" { - log.Debugf("Umount a umounted volume %v", getVolumeName(vol)) - return nil - } - if err := callUmount([]string{mountPoint}); err != nil { - return err - } - if mountPoint == vol.GenerateDefaultMountPoint() { - if err := os.Remove(mountPoint); err != nil { - log.Warnf("Cannot cleanup mount point directory %v due to %v\n", mountPoint, err) - } - } - setVolumeMountPoint(vol, "") - return nil -} - -func callMkdirIfNotExists(dirName string) error { - cmdName := "mkdir" - cmdArgs := []string{"-p", dirName} - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - _, err := Execute(cmdName, cmdArgs) - if err != nil { - return err - } - return nil -} - -func callMount(opts, args []string) (string, error) { - cmdName := MOUNT_BINARY - cmdArgs := opts - cmdArgs = append(cmdArgs, args...) - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - output, err := Execute(cmdName, cmdArgs) - if err != nil { - return "", err - } - return output, nil -} - -func callUmount(args []string) error { - cmdName := UMOUNT_BINARY - cmdArgs := args - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - if _, err := Execute(cmdName, cmdArgs); err != nil { - return err - } - return nil -} - -func InitMountNamespace(fd string) error { - if fd == "" { - return nil - } - if _, err := Execute(NSENTER_BINARY, []string{"-V"}); err != nil { - return fmt.Errorf("Cannot find nsenter for namespace switching") - } - if _, err := Execute(NSENTER_BINARY, []string{"--mount=" + fd, "mount"}); err != nil { - return fmt.Errorf("Invalid mount namespace %v, error %v", fd, err) - } - - mountNamespaceFD = fd - log.Debugf("Would mount volume in namespace %v", fd) - return nil -} - -func updateMountNamespace(name string, args []string) (string, []string) { - if mountNamespaceFD == "" { - return name, args - } - cmdArgs := []string{ - "--mount=" + mountNamespaceFD, - name, - } - cmdArgs = append(cmdArgs, args...) - cmdName := NSENTER_BINARY - log.Debugf("Execute in namespace %v: %v %v", mountNamespaceFD, cmdName, cmdArgs) - return cmdName, cmdArgs -} - -func getFileStat(file string, format string) (string, error) { - cmdName := "stat" - cmdArgs := []string{"-c", format, file} - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - output, err := Execute(cmdName, cmdArgs) - if err != nil { - return "", err - } - return strings.TrimSpace(output), nil -} - -func getFileType(file string) (string, error) { - return getFileStat(file, FILE_STAT_FORMAT_TYPE) -} - -func getDevMajorMinor(file string) (string, error) { - return getFileStat(file, FILE_STAT_FORMAT_MAJOR_MINOR) -} - -func getFileSize(file string) (int64, error) { - output, err := getFileStat(file, FILE_STAT_FORMAT_SIZE) - if err != nil { - return 0, err - } - size, err := strconv.ParseInt(strings.TrimSpace(output), 10, 64) - if err != nil { - return 0, err - } - return size, nil -} - -func VolumeMountPointFileExists(v interface{}, file string, expectType string) bool { - vol, err := getVolumeOps(v) - if err != nil { - panic("BUG: VolumeMountPointDirectoryExists was called with invalid variable") - } - mp := getVolumeMountPoint(vol) - if mp == "" { - panic("BUG: VolumeMountPointDirectoryExists was called before volume mounted") - } - path := filepath.Join(mp, file) - - fileType, err := getFileType(path) - if err != nil { - return false - } - - if fileType == expectType { - return true - } - fmt.Println(fileType, expectType) - return false -} - -func VolumeMountPointDirectoryCreate(v interface{}, dirName string) error { - vol, err := getVolumeOps(v) - if err != nil { - panic("BUG: VolumeMountPointDirectoryCreate was called with invalid variable") - } - mp := getVolumeMountPoint(vol) - if mp == "" { - panic("BUG: VolumeMountPointDirectoryCreate was called before volume mounted") - } - path := filepath.Join(mp, dirName) - - cmdName := "mkdir" - cmdArgs := []string{"-p", path} - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - if _, err := Execute(cmdName, cmdArgs); err != nil { - return err - } - return nil -} - -func VolumeMountPointDirectoryRemove(v interface{}, dirName string) error { - vol, err := getVolumeOps(v) - if err != nil { - panic("BUG: VolumeMountPointDirectoryRemove was called with invalid variable") - } - mp := getVolumeMountPoint(vol) - if mp == "" { - panic("BUG: VolumeMountPointDirectoryRemove was called before volume mounted") - } - path := filepath.Join(mp, dirName) - - cmdName := "rm" - cmdArgs := []string{"-rf", path} - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - if _, err := Execute(cmdName, cmdArgs); err != nil { - return err - } - return nil -} - -func createImage(file string, size int64) error { - cmdName := "truncate" - cmdArgs := []string{ - "-s", - strconv.FormatInt(size, 10), - file, - } - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - if _, err := Execute(cmdName, cmdArgs); err != nil { - return err - } - return nil -} - -func prepareImage(dir string, size int64) error { - file := filepath.Join(dir, IMAGE_FILE_NAME) - fileType, err := getFileType(file) - if err == nil { - if fileType != FILE_TYPE_REGULAR { - return fmt.Errorf("The image is already exists at %v, but not a file? It's %v", file, fileType) - } - // File already exists, don't need to do anything - fileSize, err := getFileSize(file) - if err != nil { - return err - } - if fileSize != size { - log.Warnf("The existing image file size %v is different from specified size %v", fileSize, size) - } - return nil - } - - if err := createImage(file, size); err != nil { - return err - } - return nil -} - -func MountPointPrepareImageFile(mp string, size int64) error { - fileType, err := getFileType(mp) - if err != nil { - return err - } - if fileType != FILE_TYPE_DIRECTORY { - return fmt.Errorf("Cannot prepare image for invalid file with type '%v' at %v", fileType, mp) - } - if err := prepareImage(mp, size); err != nil { - return err - } - return nil -} - -func makeBlockDeviceNode(file, major, minor string) error { - cmdName := "mknod" - cmdArgs := []string{ - "-m=600", - file, - "b", - major, - minor, - } - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - if _, err := Execute(cmdName, cmdArgs); err != nil { - return err - } - return nil -} - -func MountPointRemoveFile(file string) error { - cmdName := "rm" - cmdArgs := []string{ - "-f", - file, - } - cmdName, cmdArgs = updateMountNamespace(cmdName, cmdArgs) - if _, err := Execute(cmdName, cmdArgs); err != nil { - return err - } - return nil -} - -func MountPointPrepareBlockDevice(mp string, dev string) error { - file := filepath.Join(mp, BLOCK_DEV_NAME) - fileType, err := getFileType(file) - if err == nil { - if fileType != FILE_TYPE_BLOCKDEVICE { - return fmt.Errorf("The file is already exists at %v, but not a block device? It's %v", file, fileType) - } - // Old device should be cleaned up already, so it's a bug - log.Warnf("Old device wasn't cleaned up, clean it up now") - if err := MountPointRemoveFile(file); err != nil { - return fmt.Errorf("Fail to cleanup device file at %v", file) - } - } - - mm, err := getFileStat(dev, FILE_STAT_FORMAT_MAJOR_MINOR) - if err != nil { - return err - } - log.Debugf("Create block device at %v with major minor as %v", file, mm) - - major := strings.Split(mm, " ")[0] - minor := strings.Split(mm, " ")[1] - if err := makeBlockDeviceNode(file, major, minor); err != nil { - return err - } - return nil -} diff --git a/vendor/github.com/rancher/convoy/vfs/vfs_storage.go b/vendor/github.com/rancher/convoy/vfs/vfs_storage.go deleted file mode 100644 index a4cc3945..00000000 --- a/vendor/github.com/rancher/convoy/vfs/vfs_storage.go +++ /dev/null @@ -1,598 +0,0 @@ -package vfs - -import ( - "fmt" - "os" - "path/filepath" - "strconv" - "sync" - - . "github.com/rancher/convoy/convoydriver" - "github.com/rancher/convoy/objectstore" - "github.com/rancher/convoy/util" -) - -const ( - DRIVER_NAME = "vfs" - DRIVER_CONFIG_FILE = "vfs.cfg" - - VOLUME_CFG_PREFIX = "volume_" - VFS_CFG_PREFIX = DRIVER_NAME + "_" - CFG_POSTFIX = ".json" - - SNAPSHOT_PATH = "snapshots" - - VFS_DEFAULT_VOLUME_SIZE = "vfs.defaultvolumesize" - DEFAULT_VOLUME_SIZE = "100G" -) - -type Driver struct { - mutex *sync.RWMutex - Device -} - -func init() { - Register(DRIVER_NAME, Init) -} - -func (d *Driver) Name() string { - return DRIVER_NAME -} - -type Device struct { - Root string - Path string - ConfigPath string - DefaultVolumeSize int64 -} - -func (dev *Device) ConfigFile() (string, error) { - if dev.Root == "" { - return "", fmt.Errorf("BUG: Invalid empty device config path") - } - return filepath.Join(dev.Root, DRIVER_CONFIG_FILE), nil -} - -type Snapshot struct { - Name string - CreatedTime string - VolumeUUID string - FilePath string -} - -type Volume struct { - Name string - Size int64 - Path string - MountPoint string - PrepareForVM bool - CreatedTime string - Snapshots map[string]Snapshot - - configPath string -} - -func (v *Volume) ConfigFile() (string, error) { - if v.Name == "" { - return "", fmt.Errorf("BUG: Invalid empty volume name") - } - if v.configPath == "" { - return "", fmt.Errorf("BUG: Invalid empty volume config path") - } - return filepath.Join(v.configPath, VFS_CFG_PREFIX+VOLUME_CFG_PREFIX+v.Name+CFG_POSTFIX), nil -} - -func (device *Device) listVolumeNames() ([]string, error) { - return util.ListConfigIDs(device.ConfigPath, VFS_CFG_PREFIX+VOLUME_CFG_PREFIX, CFG_POSTFIX) -} - -func Init(root string, config map[string]string) (ConvoyDriver, error) { - dev := &Device{ - Root: root, - } - exists, err := util.ObjectExists(dev) - if err != nil { - return nil, err - } - if exists { - if err := util.ObjectLoad(dev); err != nil { - return nil, err - } - } else { - if err := util.MkdirIfNotExists(root); err != nil { - return nil, err - } - - path := config[VFS_PATH] - configPath := filepath.Join(path, "config") - if path == "" { - return nil, fmt.Errorf("VFS driver base path unspecified") - } - if err := util.MkdirIfNotExists(path); err != nil { - return nil, err - } - if err := util.MkdirIfNotExists(configPath); err != nil { - return nil, err - } - - dev = &Device{ - Root: root, - Path: path, - ConfigPath: configPath, - } - - if _, exists := config[VFS_DEFAULT_VOLUME_SIZE]; !exists { - config[VFS_DEFAULT_VOLUME_SIZE] = DEFAULT_VOLUME_SIZE - } - volumeSize, err := util.ParseSize(config[VFS_DEFAULT_VOLUME_SIZE]) - if err != nil || volumeSize == 0 { - return nil, fmt.Errorf("Illegal default volume size specified") - } - dev.DefaultVolumeSize = volumeSize - } - - // For upgrade case - if dev.DefaultVolumeSize == 0 { - dev.DefaultVolumeSize, err = util.ParseSize(DEFAULT_VOLUME_SIZE) - if err != nil || dev.DefaultVolumeSize == 0 { - return nil, fmt.Errorf("Illegal default volume size specified") - } - } - - if err := util.ObjectSave(dev); err != nil { - return nil, err - } - d := &Driver{ - mutex: &sync.RWMutex{}, - Device: *dev, - } - - return d, nil -} - -func (d *Driver) Info() (map[string]string, error) { - return map[string]string{ - "Root": d.Root, - "Path": d.Path, - "DefaultVolumeSize": strconv.FormatInt(d.DefaultVolumeSize, 10), - }, nil -} - -func (d *Driver) VolumeOps() (VolumeOperations, error) { - return d, nil -} - -func (d *Driver) blankVolume(id string) *Volume { - return &Volume{ - configPath: d.ConfigPath, - Name: id, - } -} - -func (d *Driver) getSize(opts map[string]string, defaultVolumeSize int64) (int64, error) { - size := opts[OPT_SIZE] - if size == "" || size == "0" { - size = strconv.FormatInt(defaultVolumeSize, 10) - } - return util.ParseSize(size) -} - -func (d *Driver) CreateVolume(req Request) error { - d.mutex.Lock() - defer d.mutex.Unlock() - - id := req.Name - opts := req.Options - volume := d.blankVolume(id) - - lockFile, err := flock(volume) - if err != nil { - return fmt.Errorf("Coudln't get flock. Error: %v", err) - } - defer util.UnlockFile(lockFile) - - backupURL := opts[OPT_BACKUP_URL] - if backupURL != "" { - objVolume, err := objectstore.LoadVolume(backupURL) - if err != nil { - return err - } - if objVolume.Driver != d.Name() { - return fmt.Errorf("Cannot restore backup of %v to %v", objVolume.Driver, d.Name()) - } - } - - exists, err := util.ObjectExists(volume) - if err != nil { - return err - } - if exists { - return nil - } - - volume.PrepareForVM, err = strconv.ParseBool(opts[OPT_PREPARE_FOR_VM]) - if err != nil { - return err - } - if volume.PrepareForVM { - volume.Size, err = d.getSize(opts, d.DefaultVolumeSize) - if err != nil { - return err - } - } - - volumePath := filepath.Join(d.Path, id) - if err := util.MkdirIfNotExists(volumePath); err != nil { - return err - } - volume.Path = volumePath - volume.CreatedTime = util.Now() - volume.Snapshots = make(map[string]Snapshot) - volume.Name = id - - if backupURL != "" { - file, err := objectstore.RestoreSingleFileBackup(backupURL, volumePath) - if err != nil { - return err - } - // file would be removed after this because it's under volumePath - if err := util.DecompressDir(file, volumePath); err != nil { - return err - } - } - return util.ObjectSave(volume) -} - -func (d *Driver) DeleteVolume(req Request) error { - d.mutex.Lock() - defer d.mutex.Unlock() - - id := req.Name - opts := req.Options - - volume := d.blankVolume(id) - - lockFile, err := flock(volume) - if err != nil { - return fmt.Errorf("Coudln't get flock. Error: %v", err) - } - defer util.UnlockFile(lockFile) - - if err := util.ObjectLoad(volume); err != nil { - return err - } - - if volume.MountPoint != "" { - return fmt.Errorf("Cannot delete volume %v. It is still mounted", id) - } - referenceOnly, _ := strconv.ParseBool(opts[OPT_REFERENCE_ONLY]) - if !referenceOnly { - log.Debugf("Cleaning up %v for volume %v", volume.Path, id) - if out, err := util.Execute("rm", []string{"-rf", volume.Path}); err != nil { - return fmt.Errorf("Fail to cleanup the volume, output: %v, error: %v", out, err.Error()) - } - } - return util.ObjectDelete(volume) -} - -func (d *Driver) MountVolume(req Request) (string, error) { - d.mutex.Lock() - defer d.mutex.Unlock() - - id := req.Name - opts := req.Options - - volume := d.blankVolume(id) - if err := util.ObjectLoad(volume); err != nil { - return "", err - } - - specifiedPoint := opts[OPT_MOUNT_POINT] - if specifiedPoint != "" { - return "", fmt.Errorf("VFS doesn't support specified mount point") - } - if volume.MountPoint == "" { - volume.MountPoint = volume.Path - } - if volume.PrepareForVM { - if err := util.MountPointPrepareImageFile(volume.MountPoint, volume.Size); err != nil { - return "", err - } - } - - lockFile, err := flock(volume) - if err != nil { - return "", fmt.Errorf("Coudln't get flock. Error: %v", err) - } - defer util.UnlockFile(lockFile) - - if err := util.ObjectSave(volume); err != nil { - return "", err - } - return volume.MountPoint, nil -} - -func (d *Driver) UmountVolume(req Request) error { - d.mutex.Lock() - defer d.mutex.Unlock() - - id := req.Name - - volume := d.blankVolume(id) - if err := util.ObjectLoad(volume); err != nil { - return err - } - - if volume.MountPoint != "" { - volume.MountPoint = "" - } - - lockFile, err := flock(volume) - if err != nil { - return fmt.Errorf("Coudln't get flock. Error: %v", err) - } - defer util.UnlockFile(lockFile) - return util.ObjectSave(volume) -} - -func (d *Driver) ListVolume(opts map[string]string) (map[string]map[string]string, error) { - d.mutex.RLock() - defer d.mutex.RUnlock() - - volumeIDs, err := d.listVolumeNames() - if err != nil { - return nil, err - } - result := map[string]map[string]string{} - for _, id := range volumeIDs { - result[id], err = d.getVolumeInfo(id) - if err != nil { - return nil, err - } - } - return result, nil -} - -func (d *Driver) GetVolumeInfo(name string) (map[string]string, error) { - d.mutex.RLock() - defer d.mutex.RUnlock() - return d.getVolumeInfo(name) -} - -func (d *Driver) getVolumeInfo(name string) (map[string]string, error) { - volume := d.blankVolume(name) - if err := util.ObjectLoad(volume); err != nil { - return nil, err - } - - size := "0" - prepareForVM := strconv.FormatBool(volume.PrepareForVM) - if volume.PrepareForVM { - size = strconv.FormatInt(volume.Size, 10) - } - return map[string]string{ - "Path": volume.Path, - OPT_MOUNT_POINT: volume.MountPoint, - OPT_SIZE: size, - OPT_PREPARE_FOR_VM: prepareForVM, - OPT_VOLUME_NAME: volume.Name, - OPT_VOLUME_CREATED_TIME: volume.CreatedTime, - }, nil -} - -func (d *Driver) MountPoint(req Request) (string, error) { - d.mutex.RLock() - defer d.mutex.RUnlock() - - id := req.Name - - volume := d.blankVolume(id) - if err := util.ObjectLoad(volume); err != nil { - return "", err - } - return volume.MountPoint, nil -} - -func (d *Driver) SnapshotOps() (SnapshotOperations, error) { - return d, nil -} - -func (d *Driver) getSnapshotFilePath(snapshotID, volumeID string) string { - return filepath.Join(d.Root, SNAPSHOT_PATH, volumeID+"_"+snapshotID+".tar.gz") -} - -func (d *Driver) CreateSnapshot(req Request) error { - d.mutex.Lock() - defer d.mutex.Unlock() - - id := req.Name - volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options) - if err != nil { - return err - } - - volume := d.blankVolume(volumeID) - if err := util.ObjectLoad(volume); err != nil { - return err - } - if _, exists := volume.Snapshots[id]; exists { - return fmt.Errorf("Snapshot %v already exists for volume %v", id, volumeID) - } - snapFile := d.getSnapshotFilePath(id, volumeID) - if err := util.MkdirIfNotExists(filepath.Dir(snapFile)); err != nil { - return err - } - if err := util.CompressDir(volume.Path, snapFile); err != nil { - return err - } - volume.Snapshots[id] = Snapshot{ - Name: id, - CreatedTime: util.Now(), - VolumeUUID: volumeID, - FilePath: snapFile, - } - - lockFile, err := flock(volume) - if err != nil { - return fmt.Errorf("Coudln't get flock. Error: %v", err) - } - defer util.UnlockFile(lockFile) - return util.ObjectSave(volume) -} - -func (d *Driver) DeleteSnapshot(req Request) error { - d.mutex.Lock() - defer d.mutex.Unlock() - - volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options) - if err != nil { - return err - } - return d.deleteSnapshot(req.Name, volumeID) -} - -func (d *Driver) deleteSnapshot(id, volumeID string) error { - volume := d.blankVolume(volumeID) - if err := util.ObjectLoad(volume); err != nil { - return err - } - snapshot, exists := volume.Snapshots[id] - if !exists { - return fmt.Errorf("Snapshot %v doesn't exists for volume %v", id, volumeID) - } - if err := os.Remove(snapshot.FilePath); err != nil { - return err - } - delete(volume.Snapshots, id) - - lockFile, err := flock(volume) - if err != nil { - return fmt.Errorf("Coudln't get flock. Error: %v", err) - } - defer util.UnlockFile(lockFile) - return util.ObjectSave(volume) -} - -func (d *Driver) GetSnapshotInfo(req Request) (map[string]string, error) { - d.mutex.Lock() - defer d.mutex.Unlock() - - volumeID, err := util.GetFieldFromOpts(OPT_VOLUME_NAME, req.Options) - if err != nil { - return nil, err - } - - return d.getSnapshotInfo(req.Name, volumeID) -} - -func (d *Driver) getSnapshotInfo(id, volumeID string) (map[string]string, error) { - volume := d.blankVolume(volumeID) - if err := util.ObjectLoad(volume); err != nil { - return nil, err - } - snapshot, exists := volume.Snapshots[id] - if !exists { - return nil, fmt.Errorf("Snapshot %v doesn't exists for volume %v", id, volumeID) - } - return map[string]string{ - OPT_SNAPSHOT_NAME: snapshot.Name, - OPT_SNAPSHOT_CREATED_TIME: snapshot.CreatedTime, - "VolumeUUID": snapshot.VolumeUUID, - "FilePath": snapshot.FilePath, - }, nil -} - -func (d *Driver) ListSnapshot(opts map[string]string) (map[string]map[string]string, error) { - d.mutex.Lock() - defer d.mutex.Unlock() - - var ( - volumeIDs []string - err error - ) - snapshots := make(map[string]map[string]string) - specifiedVolumeID, _ := util.GetFieldFromOpts(OPT_VOLUME_NAME, opts) - if specifiedVolumeID != "" { - volumeIDs = []string{ - specifiedVolumeID, - } - } else { - volumeIDs, err = d.listVolumeNames() - if err != nil { - return nil, err - } - } - for _, volumeID := range volumeIDs { - volume := d.blankVolume(volumeID) - if err := util.ObjectLoad(volume); err != nil { - return nil, err - } - for snapshotID := range volume.Snapshots { - snapshots[snapshotID], err = d.getSnapshotInfo(snapshotID, volumeID) - if err != nil { - return nil, err - } - } - } - return snapshots, nil -} - -func (d *Driver) BackupOps() (BackupOperations, error) { - return d, nil -} - -func (d *Driver) CreateBackup(snapshotID, volumeID, destURL string, opts map[string]string) (string, error) { - volume := d.blankVolume(volumeID) - if err := util.ObjectLoad(volume); err != nil { - return "", err - } - snapshot, exists := volume.Snapshots[snapshotID] - if !exists { - return "", fmt.Errorf("Cannot find snapshot %v for volume %v", snapshotID, volumeID) - } - objVolume := &objectstore.Volume{ - Name: volume.Name, - Driver: d.Name(), - CreatedTime: opts[OPT_VOLUME_CREATED_TIME], - } - objSnapshot := &objectstore.Snapshot{ - Name: snapshotID, - CreatedTime: opts[OPT_SNAPSHOT_CREATED_TIME], - } - return objectstore.CreateSingleFileBackup(objVolume, objSnapshot, snapshot.FilePath, destURL) -} - -func (d *Driver) DeleteBackup(backupURL string) error { - objVolume, err := objectstore.LoadVolume(backupURL) - if err != nil { - return err - } - if objVolume.Driver != d.Name() { - return fmt.Errorf("BUG: Wrong driver handling DeleteBackup(), driver should be %v but is %v", objVolume.Driver, d.Name()) - } - return objectstore.DeleteSingleFileBackup(backupURL) -} - -func (d *Driver) GetBackupInfo(backupURL string) (map[string]string, error) { - objVolume, err := objectstore.LoadVolume(backupURL) - if err != nil { - return nil, err - } - if objVolume.Driver != d.Name() { - return nil, fmt.Errorf("BUG: Wrong driver handling DeleteBackup(), driver should be %v but is %v", objVolume.Driver, d.Name()) - } - return objectstore.GetBackupInfo(backupURL) -} - -func (d *Driver) ListBackup(destURL string, opts map[string]string) (map[string]map[string]string, error) { - return objectstore.List(opts[OPT_VOLUME_NAME], destURL, d.Name()) -} - -func flock(volume *Volume) (*os.File, error) { - cf, err := volume.ConfigFile() - if err != nil { - return nil, err - } - lockPath := cf + ".lock" - return util.LockFile(lockPath) -} diff --git a/vendor/github.com/mcuadros/go-version/.gitignore b/vendor/github.com/yasker/backupstore/.gitignore similarity index 94% rename from vendor/github.com/mcuadros/go-version/.gitignore rename to vendor/github.com/yasker/backupstore/.gitignore index 00268614..daf913b1 100644 --- a/vendor/github.com/mcuadros/go-version/.gitignore +++ b/vendor/github.com/yasker/backupstore/.gitignore @@ -20,3 +20,5 @@ _cgo_export.* _testmain.go *.exe +*.test +*.prof diff --git a/vendor/github.com/rancher/convoy/LICENSE b/vendor/github.com/yasker/backupstore/LICENSE similarity index 99% rename from vendor/github.com/rancher/convoy/LICENSE rename to vendor/github.com/yasker/backupstore/LICENSE index e06d2081..8dada3ed 100644 --- a/vendor/github.com/rancher/convoy/LICENSE +++ b/vendor/github.com/yasker/backupstore/LICENSE @@ -1,4 +1,4 @@ -Apache License + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -199,4 +199,3 @@ Apache License WITHOUT 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/yasker/backupstore/README.md b/vendor/github.com/yasker/backupstore/README.md new file mode 100644 index 00000000..222ce840 --- /dev/null +++ b/vendor/github.com/yasker/backupstore/README.md @@ -0,0 +1 @@ +# backupstore \ No newline at end of file diff --git a/vendor/github.com/rancher/convoy/objectstore/objectstore.go b/vendor/github.com/yasker/backupstore/backupstore.go similarity index 86% rename from vendor/github.com/rancher/convoy/objectstore/objectstore.go rename to vendor/github.com/yasker/backupstore/backupstore.go index d3c5e376..d7c1f878 100644 --- a/vendor/github.com/rancher/convoy/objectstore/objectstore.go +++ b/vendor/github.com/yasker/backupstore/backupstore.go @@ -1,11 +1,11 @@ -package objectstore +package backupstore import ( "fmt" "net/url" "strconv" - "github.com/rancher/convoy/util" + "github.com/yasker/backupstore/util" ) type Volume struct { @@ -33,7 +33,7 @@ type Backup struct { SingleFile BackupFile `json:",omitempty"` } -func addVolume(volume *Volume, driver ObjectStoreDriver) error { +func addVolume(volume *Volume, driver BackupStoreDriver) error { if volumeExists(volume.Name, driver) { return nil } @@ -42,22 +42,22 @@ func addVolume(volume *Volume, driver ObjectStoreDriver) error { log.Error("Fail add volume ", volume.Name) return err } - log.Debug("Added objectstore volume ", volume.Name) + log.Debug("Added backupstore volume ", volume.Name) return nil } -func removeVolume(volumeName string, driver ObjectStoreDriver) error { +func removeVolume(volumeName string, driver BackupStoreDriver) error { if !volumeExists(volumeName, driver) { - return fmt.Errorf("Volume %v doesn't exist in objectstore", volumeName) + return fmt.Errorf("Volume %v doesn't exist in backupstore", volumeName) } volumeDir := getVolumePath(volumeName) if err := driver.Remove(volumeDir); err != nil { return err } - log.Debug("Removed volume directory in objectstore: ", volumeDir) - log.Debug("Removed objectstore volume ", volumeName) + log.Debug("Removed volume directory in backupstore: ", volumeDir) + log.Debug("Removed backupstore volume ", volumeName) return nil } @@ -83,7 +83,7 @@ func decodeBackupURL(backupURL string) (string, string, error) { return backupName, volumeName, nil } -func addListVolume(resp map[string]map[string]string, volumeName string, driver ObjectStoreDriver, storageDriverName string) error { +func addListVolume(resp map[string]map[string]string, volumeName string, driver BackupStoreDriver, storageDriverName string) error { if volumeName == "" { return fmt.Errorf("Invalid empty volume Name") } @@ -114,7 +114,7 @@ func addListVolume(resp map[string]map[string]string, volumeName string, driver } func List(volumeName, destURL, storageDriverName string) (map[string]map[string]string, error) { - driver, err := GetObjectStoreDriver(destURL) + driver, err := GetBackupStoreDriver(destURL) if err != nil { return nil, err } @@ -152,7 +152,7 @@ func fillBackupInfo(backup *Backup, volume *Volume, destURL string) map[string]s } func GetBackupInfo(backupURL string) (map[string]string, error) { - driver, err := GetObjectStoreDriver(backupURL) + driver, err := GetBackupStoreDriver(backupURL) if err != nil { return nil, err } @@ -178,7 +178,7 @@ func LoadVolume(backupURL string) (*Volume, error) { if err != nil { return nil, err } - driver, err := GetObjectStoreDriver(backupURL) + driver, err := GetBackupStoreDriver(backupURL) if err != nil { return nil, err } diff --git a/vendor/github.com/rancher/convoy/objectstore/config.go b/vendor/github.com/yasker/backupstore/config.go similarity index 75% rename from vendor/github.com/rancher/convoy/objectstore/config.go rename to vendor/github.com/yasker/backupstore/config.go index 0b39b854..cd390422 100644 --- a/vendor/github.com/rancher/convoy/objectstore/config.go +++ b/vendor/github.com/yasker/backupstore/config.go @@ -1,4 +1,4 @@ -package objectstore +package backupstore import ( "bytes" @@ -7,13 +7,13 @@ import ( "path/filepath" "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/util" + "github.com/yasker/backupstore/util" - . "github.com/rancher/convoy/logging" + . "github.com/yasker/backupstore/logging" ) const ( - OBJECTSTORE_BASE = "convoy-objectstore" + BACKUPSTORE_BASE = "convoy-objectstore" VOLUME_SEPARATE_LAYER1 = 2 VOLUME_SEPARATE_LAYER2 = 4 @@ -29,10 +29,10 @@ func getBackupConfigName(id string) string { return BACKUP_CONFIG_PREFIX + id + CFG_SUFFIX } -func loadConfigInObjectStore(filePath string, driver ObjectStoreDriver, v interface{}) error { +func loadConfigInBackupStore(filePath string, driver BackupStoreDriver, v interface{}) error { size := driver.FileSize(filePath) if size < 0 { - return fmt.Errorf("cannot find %v in objectstore", filePath) + return fmt.Errorf("cannot find %v in backupstore", filePath) } rc, err := driver.Read(filePath) if err != nil { @@ -58,7 +58,7 @@ func loadConfigInObjectStore(filePath string, driver ObjectStoreDriver, v interf return nil } -func saveConfigInObjectStore(filePath string, driver ObjectStoreDriver, v interface{}) error { +func saveConfigInBackupStore(filePath string, driver BackupStoreDriver, v interface{}) error { j, err := json.Marshal(v) if err != nil { return err @@ -81,7 +81,7 @@ func saveConfigInObjectStore(filePath string, driver ObjectStoreDriver, v interf return nil } -func volumeExists(volumeName string, driver ObjectStoreDriver) bool { +func volumeExists(volumeName string, driver BackupStoreDriver) bool { volumeFile := getVolumeFilePath(volumeName) return driver.FileExists(volumeFile) } @@ -94,7 +94,7 @@ func getVolumePath(volumeName string) string { } volumeLayer1 := name[0:VOLUME_SEPARATE_LAYER1] volumeLayer2 := name[VOLUME_SEPARATE_LAYER1:VOLUME_SEPARATE_LAYER2] - return filepath.Join(OBJECTSTORE_BASE, VOLUME_DIRECTORY, volumeLayer1, volumeLayer2, name) + return filepath.Join(BACKUPSTORE_BASE, VOLUME_DIRECTORY, volumeLayer1, volumeLayer2, name) } func getVolumeFilePath(volumeName string) string { @@ -103,10 +103,10 @@ func getVolumeFilePath(volumeName string) string { return filepath.Join(volumePath, volumeCfg) } -func getVolumeNames(driver ObjectStoreDriver) ([]string, error) { +func getVolumeNames(driver BackupStoreDriver) ([]string, error) { names := []string{} - volumePathBase := filepath.Join(OBJECTSTORE_BASE, VOLUME_DIRECTORY) + volumePathBase := filepath.Join(BACKUPSTORE_BASE, VOLUME_DIRECTORY) lv1Dirs, err := driver.List(volumePathBase) // Directory doesn't exist if err != nil { @@ -130,24 +130,24 @@ func getVolumeNames(driver ObjectStoreDriver) ([]string, error) { return names, nil } -func loadVolume(volumeName string, driver ObjectStoreDriver) (*Volume, error) { +func loadVolume(volumeName string, driver BackupStoreDriver) (*Volume, error) { v := &Volume{} file := getVolumeFilePath(volumeName) - if err := loadConfigInObjectStore(file, driver, v); err != nil { + if err := loadConfigInBackupStore(file, driver, v); err != nil { return nil, err } return v, nil } -func saveVolume(v *Volume, driver ObjectStoreDriver) error { +func saveVolume(v *Volume, driver BackupStoreDriver) error { file := getVolumeFilePath(v.Name) - if err := saveConfigInObjectStore(file, driver, v); err != nil { + if err := saveConfigInBackupStore(file, driver, v); err != nil { return err } return nil } -func getBackupNamesForVolume(volumeName string, driver ObjectStoreDriver) ([]string, error) { +func getBackupNamesForVolume(volumeName string, driver BackupStoreDriver) ([]string, error) { result := []string{} fileList, err := driver.List(getBackupPath(volumeName)) if err != nil { @@ -167,19 +167,19 @@ func getBackupConfigPath(backupName, volumeName string) string { return filepath.Join(path, fileName) } -func backupExists(backupName, volumeName string, bsDriver ObjectStoreDriver) bool { +func backupExists(backupName, volumeName string, bsDriver BackupStoreDriver) bool { return bsDriver.FileExists(getBackupConfigPath(backupName, volumeName)) } -func loadBackup(backupName, volumeName string, bsDriver ObjectStoreDriver) (*Backup, error) { +func loadBackup(backupName, volumeName string, bsDriver BackupStoreDriver) (*Backup, error) { backup := &Backup{} - if err := loadConfigInObjectStore(getBackupConfigPath(backupName, volumeName), bsDriver, backup); err != nil { + if err := loadConfigInBackupStore(getBackupConfigPath(backupName, volumeName), bsDriver, backup); err != nil { return nil, err } return backup, nil } -func saveBackup(backup *Backup, bsDriver ObjectStoreDriver) error { +func saveBackup(backup *Backup, bsDriver BackupStoreDriver) error { filePath := getBackupConfigPath(backup.Name, backup.VolumeName) if bsDriver.FileExists(filePath) { log.Warnf("Snapshot configuration file %v already exists, would remove it\n", filePath) @@ -187,17 +187,17 @@ func saveBackup(backup *Backup, bsDriver ObjectStoreDriver) error { return err } } - if err := saveConfigInObjectStore(filePath, bsDriver, backup); err != nil { + if err := saveConfigInBackupStore(filePath, bsDriver, backup); err != nil { return err } return nil } -func removeBackup(backup *Backup, bsDriver ObjectStoreDriver) error { +func removeBackup(backup *Backup, bsDriver BackupStoreDriver) error { filePath := getBackupConfigPath(backup.Name, backup.VolumeName) if err := bsDriver.Remove(filePath); err != nil { return err } - log.Debugf("Removed %v on objectstore", filePath) + log.Debugf("Removed %v on backupstore", filePath) return nil } diff --git a/vendor/github.com/rancher/convoy/objectstore/deltablock.go b/vendor/github.com/yasker/backupstore/deltablock.go similarity index 94% rename from vendor/github.com/rancher/convoy/objectstore/deltablock.go rename to vendor/github.com/yasker/backupstore/deltablock.go index 936b9774..5c39e1c2 100644 --- a/vendor/github.com/rancher/convoy/objectstore/deltablock.go +++ b/vendor/github.com/yasker/backupstore/deltablock.go @@ -1,4 +1,4 @@ -package objectstore +package backupstore import ( "fmt" @@ -7,10 +7,9 @@ import ( "path/filepath" "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/metadata" - "github.com/rancher/convoy/util" + "github.com/yasker/backupstore/util" - . "github.com/rancher/convoy/logging" + . "github.com/yasker/backupstore/logging" ) type BlockMapping struct { @@ -20,7 +19,7 @@ type BlockMapping struct { type DeltaBlockBackupOperations interface { HasSnapshot(id, volumeID string) bool - CompareSnapshot(id, compareID, volumeID string) (*metadata.Mappings, error) + CompareSnapshot(id, compareID, volumeID string) (*Mappings, error) OpenSnapshot(id, volumeID string) error ReadSnapshot(id, volumeID string, start int64, data []byte) error CloseSnapshot(id, volumeID string) error @@ -39,7 +38,7 @@ func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, return "", fmt.Errorf("Missing DeltaBlockBackupOperations") } - bsDriver, err := GetObjectStoreDriver(destURL) + bsDriver, err := GetBackupStoreDriver(destURL) if err != nil { return "", err } @@ -48,7 +47,7 @@ func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, return "", err } - // Update volume from objectstore + // Update volume from backupstore volume, err = loadVolume(volume.Name, bsDriver) if err != nil { return "", err @@ -75,7 +74,7 @@ func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, lastSnapshotName = "" log.Debug("Would create full snapshot metadata") } else if !deltaOps.HasSnapshot(lastSnapshotName, volume.Name) { - // It's possible that the snapshot in objectstore doesn't exist + // It's possible that the snapshot in backupstore doesn't exist // in local storage lastSnapshotName = "" log.WithFields(logrus.Fields{ @@ -230,7 +229,7 @@ func mergeSnapshotMap(deltaBackup, lastBackup *Backup) *Backup { } func RestoreDeltaBlockBackup(backupURL, volDevName string) error { - bsDriver, err := GetObjectStoreDriver(backupURL) + bsDriver, err := GetBackupStoreDriver(backupURL) if err != nil { return err } @@ -245,7 +244,7 @@ func RestoreDeltaBlockBackup(backupURL, volDevName string) error { return generateError(logrus.Fields{ LOG_FIELD_VOLUME: srcVolumeName, LOG_FIELD_BACKUP_URL: backupURL, - }, "Volume doesn't exist in objectstore: %v", err) + }, "Volume doesn't exist in backupstore: %v", err) } if vol.Size == 0 || vol.Size%DEFAULT_BLOCK_SIZE != 0 { @@ -310,7 +309,7 @@ func RestoreDeltaBlockBackup(backupURL, volDevName string) error { } func DeleteDeltaBlockBackup(backupURL string) error { - bsDriver, err := GetObjectStoreDriver(backupURL) + bsDriver, err := GetBackupStoreDriver(backupURL) if err != nil { return err } @@ -322,7 +321,7 @@ func DeleteDeltaBlockBackup(backupURL string) error { v, err := loadVolume(volumeName, bsDriver) if err != nil { - return fmt.Errorf("Cannot find volume %v in objectstore", volumeName, err) + return fmt.Errorf("Cannot find volume %v in backupstore", volumeName, err) } backup, err := loadBackup(backupName, volumeName, bsDriver) @@ -389,7 +388,7 @@ func DeleteDeltaBlockBackup(backupURL string) error { log.Debug("Removed unused blocks for volume ", volumeName) log.Debug("GC completed") - log.Debug("Removed objectstore backup ", backupName) + log.Debug("Removed backupstore backup ", backupName) return nil } diff --git a/vendor/github.com/rancher/convoy/objectstore/driver.go b/vendor/github.com/yasker/backupstore/driver.go similarity index 78% rename from vendor/github.com/rancher/convoy/objectstore/driver.go rename to vendor/github.com/yasker/backupstore/driver.go index 6d7428e2..1dfeaefd 100644 --- a/vendor/github.com/rancher/convoy/objectstore/driver.go +++ b/vendor/github.com/yasker/backupstore/driver.go @@ -1,4 +1,4 @@ -package objectstore +package backupstore import ( "fmt" @@ -7,12 +7,12 @@ import ( "github.com/Sirupsen/logrus" - . "github.com/rancher/convoy/logging" + . "github.com/yasker/backupstore/logging" ) -type InitFunc func(destURL string) (ObjectStoreDriver, error) +type InitFunc func(destURL string) (BackupStoreDriver, error) -type ObjectStoreDriver interface { +type BackupStoreDriver interface { Kind() string GetURL() string FileExists(filePath string) bool @@ -30,11 +30,11 @@ var ( ) var ( - log = logrus.WithFields(logrus.Fields{"pkg": "objectstore"}) + log = logrus.WithFields(logrus.Fields{"pkg": "backupstore"}) ) func generateError(fields logrus.Fields, format string, v ...interface{}) error { - return ErrorWithFields("objectstore", fields, format, v) + return ErrorWithFields("backupstore", fields, format, v) } func init() { @@ -49,7 +49,7 @@ func RegisterDriver(kind string, initFunc InitFunc) error { return nil } -func GetObjectStoreDriver(destURL string) (ObjectStoreDriver, error) { +func GetBackupStoreDriver(destURL string) (BackupStoreDriver, error) { if destURL == "" { return nil, fmt.Errorf("Destination URL hasn't been specified") } diff --git a/vendor/github.com/rancher/convoy/logging/logging.go b/vendor/github.com/yasker/backupstore/logging/logging.go similarity index 100% rename from vendor/github.com/rancher/convoy/logging/logging.go rename to vendor/github.com/yasker/backupstore/logging/logging.go diff --git a/vendor/github.com/rancher/convoy/s3/s3.go b/vendor/github.com/yasker/backupstore/s3/s3.go similarity index 76% rename from vendor/github.com/rancher/convoy/s3/s3.go rename to vendor/github.com/yasker/backupstore/s3/s3.go index 99795b88..2c1fea42 100644 --- a/vendor/github.com/rancher/convoy/s3/s3.go +++ b/vendor/github.com/yasker/backupstore/s3/s3.go @@ -9,14 +9,14 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/objectstore" + "github.com/yasker/backupstore" ) var ( log = logrus.WithFields(logrus.Fields{"pkg": "s3"}) ) -type S3ObjectStoreDriver struct { +type S3BackupStoreDriver struct { destURL string path string service S3Service @@ -27,11 +27,13 @@ const ( ) func init() { - objectstore.RegisterDriver(KIND, initFunc) + if err := backupstore.RegisterDriver(KIND, initFunc); err != nil { + panic(err) + } } -func initFunc(destURL string) (objectstore.ObjectStoreDriver, error) { - b := &S3ObjectStoreDriver{} +func initFunc(destURL string) (backupstore.BackupStoreDriver, error) { + b := &S3BackupStoreDriver{} u, err := url.Parse(destURL) if err != nil { @@ -72,19 +74,19 @@ func initFunc(destURL string) (objectstore.ObjectStoreDriver, error) { return b, nil } -func (s *S3ObjectStoreDriver) Kind() string { +func (s *S3BackupStoreDriver) Kind() string { return KIND } -func (s *S3ObjectStoreDriver) GetURL() string { +func (s *S3BackupStoreDriver) GetURL() string { return s.destURL } -func (s *S3ObjectStoreDriver) updatePath(path string) string { +func (s *S3BackupStoreDriver) updatePath(path string) string { return filepath.Join(s.path, path) } -func (s *S3ObjectStoreDriver) List(listPath string) ([]string, error) { +func (s *S3BackupStoreDriver) List(listPath string) ([]string, error) { var result []string path := s.updatePath(listPath) + "/" @@ -117,11 +119,11 @@ func (s *S3ObjectStoreDriver) List(listPath string) ([]string, error) { return result, nil } -func (s *S3ObjectStoreDriver) FileExists(filePath string) bool { +func (s *S3BackupStoreDriver) FileExists(filePath string) bool { return s.FileSize(filePath) >= 0 } -func (s *S3ObjectStoreDriver) FileSize(filePath string) int64 { +func (s *S3BackupStoreDriver) FileSize(filePath string) int64 { path := s.updatePath(filePath) head, err := s.service.HeadObject(path) if err != nil { @@ -133,7 +135,7 @@ func (s *S3ObjectStoreDriver) FileSize(filePath string) int64 { return *head.ContentLength } -func (s *S3ObjectStoreDriver) Remove(names ...string) error { +func (s *S3BackupStoreDriver) Remove(names ...string) error { if len(names) == 0 { return nil } @@ -144,7 +146,7 @@ func (s *S3ObjectStoreDriver) Remove(names ...string) error { return s.service.DeleteObjects(paths) } -func (s *S3ObjectStoreDriver) Read(src string) (io.ReadCloser, error) { +func (s *S3BackupStoreDriver) Read(src string) (io.ReadCloser, error) { path := s.updatePath(src) rc, err := s.service.GetObject(path) if err != nil { @@ -153,12 +155,12 @@ func (s *S3ObjectStoreDriver) Read(src string) (io.ReadCloser, error) { return rc, nil } -func (s *S3ObjectStoreDriver) Write(dst string, rs io.ReadSeeker) error { +func (s *S3BackupStoreDriver) Write(dst string, rs io.ReadSeeker) error { path := s.updatePath(dst) return s.service.PutObject(path, rs) } -func (s *S3ObjectStoreDriver) Upload(src, dst string) error { +func (s *S3BackupStoreDriver) Upload(src, dst string) error { file, err := os.Open(src) if err != nil { return nil @@ -168,7 +170,7 @@ func (s *S3ObjectStoreDriver) Upload(src, dst string) error { return s.service.PutObject(path, file) } -func (s *S3ObjectStoreDriver) Download(src, dst string) error { +func (s *S3BackupStoreDriver) Download(src, dst string) error { if _, err := os.Stat(dst); err != nil { os.Remove(dst) } diff --git a/vendor/github.com/rancher/convoy/s3/s3_service.go b/vendor/github.com/yasker/backupstore/s3/s3_service.go similarity index 100% rename from vendor/github.com/rancher/convoy/s3/s3_service.go rename to vendor/github.com/yasker/backupstore/s3/s3_service.go diff --git a/vendor/github.com/rancher/convoy/objectstore/singlefile.go b/vendor/github.com/yasker/backupstore/singlefile.go similarity index 88% rename from vendor/github.com/rancher/convoy/objectstore/singlefile.go rename to vendor/github.com/yasker/backupstore/singlefile.go index ac070123..a5ed285f 100644 --- a/vendor/github.com/rancher/convoy/objectstore/singlefile.go +++ b/vendor/github.com/yasker/backupstore/singlefile.go @@ -1,13 +1,13 @@ -package objectstore +package backupstore import ( "fmt" "path/filepath" "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/util" + "github.com/yasker/backupstore/util" - . "github.com/rancher/convoy/logging" + . "github.com/yasker/backupstore/logging" ) const ( @@ -24,7 +24,7 @@ func getSingleFileBackupFilePath(sfBackup *Backup) string { } func CreateSingleFileBackup(volume *Volume, snapshot *Snapshot, filePath, destURL string) (string, error) { - driver, err := GetObjectStoreDriver(destURL) + driver, err := GetBackupStoreDriver(destURL) if err != nil { return "", err } @@ -74,7 +74,7 @@ func CreateSingleFileBackup(volume *Volume, snapshot *Snapshot, filePath, destUR } func RestoreSingleFileBackup(backupURL, path string) (string, error) { - driver, err := GetObjectStoreDriver(backupURL) + driver, err := GetBackupStoreDriver(backupURL) if err != nil { return "", err } @@ -88,7 +88,7 @@ func RestoreSingleFileBackup(backupURL, path string) (string, error) { return "", generateError(logrus.Fields{ LOG_FIELD_VOLUME: srcVolumeName, LOG_FIELD_BACKUP_URL: backupURL, - }, "Volume doesn't exist in objectstore: %v", err) + }, "Volume doesn't exist in backupstore: %v", err) } backup, err := loadBackup(srcBackupName, srcVolumeName, driver) @@ -105,7 +105,7 @@ func RestoreSingleFileBackup(backupURL, path string) (string, error) { } func DeleteSingleFileBackup(backupURL string) error { - driver, err := GetObjectStoreDriver(backupURL) + driver, err := GetBackupStoreDriver(backupURL) if err != nil { return err } @@ -117,7 +117,7 @@ func DeleteSingleFileBackup(backupURL string) error { _, err = loadVolume(volumeName, driver) if err != nil { - return fmt.Errorf("Cannot find volume %v in objectstore", volumeName, err) + return fmt.Errorf("Cannot find volume %v in backupstore", volumeName, err) } backup, err := loadBackup(backupName, volumeName, driver) diff --git a/vendor/github.com/rancher/convoy/trash.yml b/vendor/github.com/yasker/backupstore/trash.yml similarity index 63% rename from vendor/github.com/rancher/convoy/trash.yml rename to vendor/github.com/yasker/backupstore/trash.yml index e543d0ab..3a1acecc 100644 --- a/vendor/github.com/rancher/convoy/trash.yml +++ b/vendor/github.com/yasker/backupstore/trash.yml @@ -1,4 +1,4 @@ -package: github.com/rancher/convoy +package: github.com/yasker/backupstore import: - package: github.com/Sirupsen/logrus @@ -10,9 +10,6 @@ import: - package: github.com/aws/aws-sdk-go/private/endpoints version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/private/protocol/ec2query - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc - - package: github.com/aws/aws-sdk-go/private/protocol/query version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc @@ -31,39 +28,17 @@ import: - package: github.com/aws/aws-sdk-go/private/waiter version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/aws/aws-sdk-go/service/ec2 - version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc - - package: github.com/aws/aws-sdk-go/service/s3 version: c924893c38ecc04b18d7aab8a7aa561cb8b4c4cc -- package: github.com/codegangsta/cli - version: c31a7975863e7810c92e2e288a9ab074f9a88f29 - -- package: github.com/docker/docker/pkg/devicemapper - version: ea65c38ac0972709cdb371ce6b1886eb252a126e - - package: github.com/go-ini/ini version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 -- package: github.com/gorilla/context - version: 215affda49addc4c8ef7e2534915df2c8c35c6cd - -- package: github.com/gorilla/mux - version: e444e69cbd2e2e3e0749a2f3c717cec491552bbf - - package: github.com/jmespath/go-jmespath version: c01cf91b011868172fdcd9f41838e80c9d716264 -- package: github.com/mcuadros/go-version - version: d52711f8d6bea8dc01efafdb68ad95a4e2606630 - - package: github.com/satori/go.uuid version: d41af8bb6a7704f00bc3b7cba9355ae6a5a80048 -- package: golang.org/x/sys/unix - version: 442cd600860ce722f6615730eb008a37a87b13ee - - package: gopkg.in/check.v1 version: 4f90aeace3a26ad7021961c297b22c42160c7b25 - diff --git a/vendor/github.com/rancher/convoy/metadata/metadata.go b/vendor/github.com/yasker/backupstore/types.go similarity index 85% rename from vendor/github.com/rancher/convoy/metadata/metadata.go rename to vendor/github.com/yasker/backupstore/types.go index 28c33dbc..71b3255e 100644 --- a/vendor/github.com/rancher/convoy/metadata/metadata.go +++ b/vendor/github.com/yasker/backupstore/types.go @@ -1,4 +1,4 @@ -package metadata +package backupstore type Mapping struct { Offset int64 diff --git a/vendor/github.com/yasker/backupstore/util/util.go b/vendor/github.com/yasker/backupstore/util/util.go new file mode 100644 index 00000000..c678c2a8 --- /dev/null +++ b/vendor/github.com/yasker/backupstore/util/util.go @@ -0,0 +1,121 @@ +package util + +import ( + "bytes" + "compress/gzip" + "crypto/sha512" + "encoding/hex" + "fmt" + "io" + "io/ioutil" + "os/exec" + "regexp" + "strings" + "time" + + "github.com/Sirupsen/logrus" + "github.com/satori/go.uuid" +) + +const ( + PRESERVED_CHECKSUM_LENGTH = 64 +) + +var ( + cmdTimeout time.Duration = time.Minute // one minute by default +) + +func GenerateName(prefix string) string { + suffix := strings.Replace(NewUUID(), "-", "", -1) + return prefix + "-" + suffix[:16] +} + +func NewUUID() string { + return uuid.NewV4().String() +} + +func GetChecksum(data []byte) string { + checksumBytes := sha512.Sum512(data) + checksum := hex.EncodeToString(checksumBytes[:])[:PRESERVED_CHECKSUM_LENGTH] + return checksum +} + +func CompressData(data []byte) (io.ReadSeeker, error) { + var b bytes.Buffer + w := gzip.NewWriter(&b) + if _, err := w.Write(data); err != nil { + w.Close() + return nil, err + } + w.Close() + return bytes.NewReader(b.Bytes()), nil +} + +func DecompressAndVerify(src io.Reader, checksum string) (io.Reader, error) { + r, err := gzip.NewReader(src) + if err != nil { + return nil, err + } + block, err := ioutil.ReadAll(r) + if err != nil { + return nil, err + } + if GetChecksum(block) != checksum { + return nil, fmt.Errorf("Checksum verification failed for block!") + } + return bytes.NewReader(block), nil +} + +func Now() string { + return time.Now().UTC().Format(time.RFC3339) +} + +func ExtractNames(names []string, prefix, suffix string) ([]string, error) { + result := []string{} + for i := range names { + f := names[i] + // Remove additional slash if exists + f = strings.TrimLeft(f, "/") + f = strings.TrimPrefix(f, prefix) + f = strings.TrimSuffix(f, suffix) + if !ValidateName(f) { + return nil, fmt.Errorf("Invalid name %v was processed to extract name with prefix %v surfix %v", names[i], prefix, suffix) + } + result = append(result, f) + } + return result, nil +} + +func ValidateName(name string) bool { + validName := regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`) + return validName.MatchString(name) +} + +func Execute(binary string, args []string) (string, error) { + var output []byte + var err error + cmd := exec.Command(binary, args...) + done := make(chan struct{}) + + go func() { + output, err = cmd.CombinedOutput() + done <- struct{}{} + }() + + select { + case <-done: + case <-time.After(cmdTimeout): + if cmd.Process != nil { + if err := cmd.Process.Kill(); err != nil { + logrus.Warnf("Problem killing process pid=%v: %s", cmd.Process.Pid, err) + } + + } + return "", fmt.Errorf("Timeout executing: %v %v, output %v, error %v", binary, args, string(output), err) + } + + if err != nil { + return "", fmt.Errorf("Failed to execute: %v %v, output %v, error %v", binary, args, string(output), err) + } + return string(output), nil +} diff --git a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go b/vendor/github.com/yasker/backupstore/vfs/vfs.go similarity index 72% rename from vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go rename to vendor/github.com/yasker/backupstore/vfs/vfs.go index 4f23d900..acf3e5bd 100644 --- a/vendor/github.com/rancher/convoy/vfs/vfs_objectstore.go +++ b/vendor/github.com/yasker/backupstore/vfs/vfs.go @@ -9,15 +9,15 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/rancher/convoy/objectstore" - "github.com/rancher/convoy/util" + "github.com/yasker/backupstore" + "github.com/yasker/backupstore/util" ) var ( log = logrus.WithFields(logrus.Fields{"pkg": "vfs"}) ) -type VfsObjectStoreDriver struct { +type VfsBackupStoreDriver struct { destURL string path string } @@ -31,11 +31,13 @@ const ( ) func init() { - objectstore.RegisterDriver(KIND, initFunc) + if err := backupstore.RegisterDriver(KIND, initFunc); err != nil { + panic(err) + } } -func initFunc(destURL string) (objectstore.ObjectStoreDriver, error) { - b := &VfsObjectStoreDriver{} +func initFunc(destURL string) (backupstore.BackupStoreDriver, error) { + b := &VfsBackupStoreDriver{} u, err := url.Parse(destURL) if err != nil { return nil, err @@ -63,26 +65,26 @@ func initFunc(destURL string) (objectstore.ObjectStoreDriver, error) { return b, nil } -func (v *VfsObjectStoreDriver) updatePath(path string) string { +func (v *VfsBackupStoreDriver) updatePath(path string) string { return filepath.Join(v.path, path) } -func (v *VfsObjectStoreDriver) preparePath(file string) error { +func (v *VfsBackupStoreDriver) preparePath(file string) error { if err := os.MkdirAll(filepath.Dir(v.updatePath(file)), os.ModeDir|0700); err != nil { return err } return nil } -func (v *VfsObjectStoreDriver) Kind() string { +func (v *VfsBackupStoreDriver) Kind() string { return KIND } -func (v *VfsObjectStoreDriver) GetURL() string { +func (v *VfsBackupStoreDriver) GetURL() string { return v.destURL } -func (v *VfsObjectStoreDriver) FileSize(filePath string) int64 { +func (v *VfsBackupStoreDriver) FileSize(filePath string) int64 { file := v.updatePath(filePath) st, err := os.Stat(file) if err != nil || st.IsDir() { @@ -91,11 +93,11 @@ func (v *VfsObjectStoreDriver) FileSize(filePath string) int64 { return st.Size() } -func (v *VfsObjectStoreDriver) FileExists(filePath string) bool { +func (v *VfsBackupStoreDriver) FileExists(filePath string) bool { return v.FileSize(filePath) >= 0 } -func (v *VfsObjectStoreDriver) Remove(names ...string) error { +func (v *VfsBackupStoreDriver) Remove(names ...string) error { for _, name := range names { if err := os.RemoveAll(v.updatePath(name)); err != nil { return err @@ -104,8 +106,8 @@ func (v *VfsObjectStoreDriver) Remove(names ...string) error { dir := v.updatePath(name) for i := 0; i < MAX_CLEANUP_LEVEL; i++ { dir = filepath.Dir(dir) - // Don't clean above OBJECTSTORE_BASE - if strings.HasSuffix(dir, objectstore.OBJECTSTORE_BASE) { + // Don't clean above BACKUPSTORE_BASE + if strings.HasSuffix(dir, backupstore.BACKUPSTORE_BASE) { break } // If directory is not empty, then we don't need to continue @@ -117,7 +119,7 @@ func (v *VfsObjectStoreDriver) Remove(names ...string) error { return nil } -func (v *VfsObjectStoreDriver) Read(src string) (io.ReadCloser, error) { +func (v *VfsBackupStoreDriver) Read(src string) (io.ReadCloser, error) { file, err := os.Open(v.updatePath(src)) if err != nil { return nil, err @@ -125,7 +127,7 @@ func (v *VfsObjectStoreDriver) Read(src string) (io.ReadCloser, error) { return file, nil } -func (v *VfsObjectStoreDriver) Write(dst string, rs io.ReadSeeker) error { +func (v *VfsBackupStoreDriver) Write(dst string, rs io.ReadSeeker) error { tmpFile := dst + ".tmp" if v.FileExists(tmpFile) { v.Remove(tmpFile) @@ -149,7 +151,7 @@ func (v *VfsObjectStoreDriver) Write(dst string, rs io.ReadSeeker) error { return os.Rename(v.updatePath(tmpFile), v.updatePath(dst)) } -func (v *VfsObjectStoreDriver) List(path string) ([]string, error) { +func (v *VfsBackupStoreDriver) List(path string) ([]string, error) { out, err := util.Execute("ls", []string{"-1", v.updatePath(path)}) if err != nil { return nil, err @@ -162,7 +164,7 @@ func (v *VfsObjectStoreDriver) List(path string) ([]string, error) { return result, nil } -func (v *VfsObjectStoreDriver) Upload(src, dst string) error { +func (v *VfsBackupStoreDriver) Upload(src, dst string) error { tmpDst := dst + ".tmp" if v.FileExists(tmpDst) { v.Remove(tmpDst) @@ -181,7 +183,7 @@ func (v *VfsObjectStoreDriver) Upload(src, dst string) error { return nil } -func (v *VfsObjectStoreDriver) Download(src, dst string) error { +func (v *VfsBackupStoreDriver) Download(src, dst string) error { _, err := util.Execute("cp", []string{v.updatePath(src), dst}) if err != nil { return err diff --git a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go index dc080bf9..01111891 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go +++ b/vendor/github.com/yasker/go-iscsi-helper/iscsi/target.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/rancher/convoy/util" + "github.com/yasker/go-iscsi-helper/util" ) var ( diff --git a/vendor/github.com/yasker/go-iscsi-helper/trash.conf b/vendor/github.com/yasker/go-iscsi-helper/trash.conf index dc2e0cc7..bb08cbd0 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/trash.conf +++ b/vendor/github.com/yasker/go-iscsi-helper/trash.conf @@ -3,10 +3,4 @@ # package github.com/yasker/go-iscsi-helper -github.com/Sirupsen/logrus v0.10.0-38-g3ec0642 -github.com/codegangsta/cli v1.18.0-65-g61f519f -github.com/mcuadros/go-version d52711f -github.com/rancher/convoy v0.5.0-rc2-1-g0eda7c7 -github.com/satori/go.uuid v1.1.0-1-g0aa62d5 -golang.org/x/sys 30de6d1 gopkg.in/check.v1 4f90aea diff --git a/vendor/github.com/yasker/go-iscsi-helper/util/util.go b/vendor/github.com/yasker/go-iscsi-helper/util/util.go index 5353df94..042807a8 100644 --- a/vendor/github.com/yasker/go-iscsi-helper/util/util.go +++ b/vendor/github.com/yasker/go-iscsi-helper/util/util.go @@ -2,16 +2,21 @@ package util import ( "fmt" + "log" "net" + "os/exec" "path/filepath" - - cutil "github.com/rancher/convoy/util" + "time" ) const ( NSBinary = "nsenter" ) +var ( + cmdTimeout = time.Minute // one minute by default +) + func GetLocalIPs() ([]string, error) { results := []string{} addrs, err := net.InterfaceAddrs() @@ -42,13 +47,13 @@ func NewNamespaceExecutor(ns string) (*NamespaceExecutor, error) { } mntNS := filepath.Join(ns, "mnt") netNS := filepath.Join(ns, "net") - if _, err := cutil.Execute(NSBinary, []string{"-V"}); err != nil { + if _, err := Execute(NSBinary, []string{"-V"}); err != nil { return nil, fmt.Errorf("Cannot find nsenter for namespace switching") } - if _, err := cutil.Execute(NSBinary, []string{"--mount=" + mntNS, "mount"}); err != nil { + if _, err := Execute(NSBinary, []string{"--mount=" + mntNS, "mount"}); err != nil { return nil, fmt.Errorf("Invalid mount namespace %v, error %v", mntNS, err) } - if _, err := cutil.Execute(NSBinary, []string{"--net=" + netNS, "ip", "addr"}); err != nil { + if _, err := Execute(NSBinary, []string{"--net=" + netNS, "ip", "addr"}); err != nil { return nil, fmt.Errorf("Invalid net namespace %v, error %v", netNS, err) } return ne, nil @@ -56,7 +61,7 @@ func NewNamespaceExecutor(ns string) (*NamespaceExecutor, error) { func (ne *NamespaceExecutor) Execute(name string, args []string) (string, error) { if ne.ns == "" { - return cutil.Execute(name, args) + return Execute(name, args) } cmdArgs := []string{ "--mount=" + filepath.Join(ne.ns, "mnt"), @@ -64,5 +69,34 @@ func (ne *NamespaceExecutor) Execute(name string, args []string) (string, error) name, } cmdArgs = append(cmdArgs, args...) - return cutil.Execute(NSBinary, cmdArgs) + return Execute(NSBinary, cmdArgs) +} + +func Execute(binary string, args []string) (string, error) { + var output []byte + var err error + cmd := exec.Command(binary, args...) + done := make(chan struct{}) + + go func() { + output, err = cmd.CombinedOutput() + done <- struct{}{} + }() + + select { + case <-done: + case <-time.After(cmdTimeout): + if cmd.Process != nil { + if err := cmd.Process.Kill(); err != nil { + log.Printf("Problem killing process pid=%v: %s", cmd.Process.Pid, err) + } + + } + return "", fmt.Errorf("Timeout executing: %v %v, output %v, error %v", binary, args, string(output), err) + } + + if err != nil { + return "", fmt.Errorf("Failed to execute: %v %v, output %v, error %v", binary, args, string(output), err) + } + return string(output), nil } From 88687e735cb43cf720021bfadf1fe16cc9e1511d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 7 Mar 2017 19:33:49 -0800 Subject: [PATCH 299/357] backup: Named the backupstore directory as `longhorn-backupstore` --- backup/main.go | 4 ++++ vendor.conf | 2 +- vendor/github.com/yasker/backupstore/backupstore.go | 12 ++++++++++++ vendor/github.com/yasker/backupstore/config.go | 5 ++--- vendor/github.com/yasker/backupstore/vfs/vfs.go | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/backup/main.go b/backup/main.go index 09c17cde..1df8c5a1 100644 --- a/backup/main.go +++ b/backup/main.go @@ -18,6 +18,8 @@ import ( const ( DRIVERNAME = "longhorn" + + BackupstoreBase = "longhorn-backupstore" ) var ( @@ -95,6 +97,8 @@ func Main() { } log.Debugf("Currently running at %v, assume as volume dir", dir) + backupstore.SetBackupstoreBase(BackupstoreBase) + app := cli.NewApp() app.Version = VERSION app.Commands = []cli.Command{ diff --git a/vendor.conf b/vendor.conf index 535d466e..f4b2d740 100644 --- a/vendor.conf +++ b/vendor.conf @@ -19,4 +19,4 @@ github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 -github.com/yasker/backupstore accaaa6a7a2ff365d451b2894fe5c7eaabc9e497 +github.com/yasker/backupstore a9ff4c767a8d5a64afa57b4603714fc85071ced6 diff --git a/vendor/github.com/yasker/backupstore/backupstore.go b/vendor/github.com/yasker/backupstore/backupstore.go index d7c1f878..c2dcb74f 100644 --- a/vendor/github.com/yasker/backupstore/backupstore.go +++ b/vendor/github.com/yasker/backupstore/backupstore.go @@ -33,6 +33,18 @@ type Backup struct { SingleFile BackupFile `json:",omitempty"` } +var ( + backupstoreBase = "backupstore" +) + +func SetBackupstoreBase(base string) { + backupstoreBase = base +} + +func GetBackupstoreBase() string { + return backupstoreBase +} + func addVolume(volume *Volume, driver BackupStoreDriver) error { if volumeExists(volume.Name, driver) { return nil diff --git a/vendor/github.com/yasker/backupstore/config.go b/vendor/github.com/yasker/backupstore/config.go index cd390422..b45bf50c 100644 --- a/vendor/github.com/yasker/backupstore/config.go +++ b/vendor/github.com/yasker/backupstore/config.go @@ -13,7 +13,6 @@ import ( ) const ( - BACKUPSTORE_BASE = "convoy-objectstore" VOLUME_SEPARATE_LAYER1 = 2 VOLUME_SEPARATE_LAYER2 = 4 @@ -94,7 +93,7 @@ func getVolumePath(volumeName string) string { } volumeLayer1 := name[0:VOLUME_SEPARATE_LAYER1] volumeLayer2 := name[VOLUME_SEPARATE_LAYER1:VOLUME_SEPARATE_LAYER2] - return filepath.Join(BACKUPSTORE_BASE, VOLUME_DIRECTORY, volumeLayer1, volumeLayer2, name) + return filepath.Join(backupstoreBase, VOLUME_DIRECTORY, volumeLayer1, volumeLayer2, name) } func getVolumeFilePath(volumeName string) string { @@ -106,7 +105,7 @@ func getVolumeFilePath(volumeName string) string { func getVolumeNames(driver BackupStoreDriver) ([]string, error) { names := []string{} - volumePathBase := filepath.Join(BACKUPSTORE_BASE, VOLUME_DIRECTORY) + volumePathBase := filepath.Join(backupstoreBase, VOLUME_DIRECTORY) lv1Dirs, err := driver.List(volumePathBase) // Directory doesn't exist if err != nil { diff --git a/vendor/github.com/yasker/backupstore/vfs/vfs.go b/vendor/github.com/yasker/backupstore/vfs/vfs.go index acf3e5bd..cfac3f93 100644 --- a/vendor/github.com/yasker/backupstore/vfs/vfs.go +++ b/vendor/github.com/yasker/backupstore/vfs/vfs.go @@ -106,8 +106,8 @@ func (v *VfsBackupStoreDriver) Remove(names ...string) error { dir := v.updatePath(name) for i := 0; i < MAX_CLEANUP_LEVEL; i++ { dir = filepath.Dir(dir) - // Don't clean above BACKUPSTORE_BASE - if strings.HasSuffix(dir, backupstore.BACKUPSTORE_BASE) { + // Don't clean above backupstore base + if strings.HasSuffix(dir, backupstore.GetBackupstoreBase()) { break } // If directory is not empty, then we don't need to continue From 0bfcd061e97314f89df5577ab9ce8fbd95c25095 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 7 Mar 2017 20:21:42 -0800 Subject: [PATCH 300/357] backup: Add `backup ls` command It will list the backups in the backupstore for this volume --- app/backup.go | 32 +++++++++++++++++++++++ backup/main.go | 6 ++++- integration/core/test_cli.py | 6 +++++ replica/client/client.go | 34 ++++++++++++++++++++++++ sync/agent/process.go | 41 +++++++++++++++++++++++++++++ sync/backup.go | 50 ++++++++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+), 1 deletion(-) diff --git a/app/backup.go b/app/backup.go index 036fe8b6..495d212f 100644 --- a/app/backup.go +++ b/app/backup.go @@ -17,6 +17,7 @@ func BackupCmd() cli.Command { BackupRestoreCmd(), BackupRmCmd(), BackupInspectCmd(), + BackupListCmd(), }, } } @@ -75,6 +76,19 @@ func BackupInspectCmd() cli.Command { } } +func BackupListCmd() cli.Command { + return cli.Command{ + Name: "list", + ShortName: "ls", + Usage: "list backup: list ", + Action: func(c *cli.Context) { + if err := listBackup(c); err != nil { + logrus.Fatalf("Error running inspect backup command: %v", err) + } + }, + } +} + func createBackup(c *cli.Context) error { url := c.GlobalString("url") task := sync.NewTask(url) @@ -147,3 +161,21 @@ func inspectBackup(c *cli.Context) error { return nil } + +func listBackup(c *cli.Context) error { + url := c.GlobalString("url") + task := sync.NewTask(url) + + destURL := c.Args().First() + if destURL == "" { + return fmt.Errorf("Missing required parameter ") + } + + output, err := task.ListBackup(destURL) + if err != nil { + return err + } + fmt.Println(output) + + return nil +} diff --git a/backup/main.go b/backup/main.go index 1df8c5a1..27720602 100644 --- a/backup/main.go +++ b/backup/main.go @@ -313,7 +313,11 @@ func doBackupList(c *cli.Context) error { if err != nil { return err } - fmt.Println(list) + data, err := ResponseOutput(list) + if err != nil { + return err + } + fmt.Println(string(data)) return nil } diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index cd649933..e62febf7 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -576,6 +576,12 @@ def test_backup_core(bin, controller_client, replica_client, assert backup2_info["VolumeSize"] == VOLUME_SIZE assert backup2_info["SnapshotName"] == snapshot2 + cmd = [bin, 'backup', 'ls', "vfs://" + BACKUP_DEST] + data = subprocess.check_output(cmd).strip() + backup_list = json.loads(data) + assert backup_list[backup1] == backup1_info + assert backup_list[backup2] == backup2_info + cmd = [bin, 'backup', 'inspect', "vfs:///tmp/longhorn-backup?backup=backup-1234" + "&volume=test-volume_1.0"] diff --git a/replica/client/client.go b/replica/client/client.go index 8eabe1a1..f5ac3625 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -371,6 +371,40 @@ func (c *ReplicaClient) InspectBackup(backup string) (string, error) { } } +func (c *ReplicaClient) ListBackup(destURL, volume string) (string, error) { + var running agent.Process + err := c.post(c.syncAgent+"/processes", &agent.Process{ + ProcessType: "listbackup", + SrcFile: destURL, + DestFile: volume, + }, &running) + if err != nil { + return "", err + } + + start := 250 * time.Millisecond + for { + err := c.get(running.Links["self"], &running) + if err != nil { + return "", err + } + + switch running.ExitCode { + case -2: + time.Sleep(start) + start = start * 2 + if start > 1*time.Second { + start = 1 * time.Second + } + case 0: + return running.Output, nil + default: + return "", fmt.Errorf("ExitCode: %d, output: %v", + running.ExitCode, running.Output) + } + } +} + func (c *ReplicaClient) get(url string, obj interface{}) error { if !strings.HasPrefix(url, "http") { url = c.address + url diff --git a/sync/agent/process.go b/sync/agent/process.go index 67387339..c3f29689 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -129,6 +129,8 @@ func (s *Server) launch(p *Process) error { return s.launchRestore(p) case "inspectbackup": return s.launchInspectBackup(p) + case "listbackup": + return s.launchListBackup(p) case "hardlink": return s.launchHardLink(p) } @@ -404,3 +406,42 @@ func (s *Server) launchInspectBackup(p *Process) error { logrus.Infof("Done running %s %v", "sbackup", cmd.Args) return nil } + +func (s *Server) launchListBackup(p *Process) error { + buf := new(bytes.Buffer) + + cmdline := []string{"sbackup", "list", p.SrcFile} + if p.DestFile != "" { + cmdline = append(cmdline, "--volume", p.DestFile) + } + cmd := reexec.Command(cmdline...) + cmd.SysProcAttr = &syscall.SysProcAttr{ + Pdeathsig: syscall.SIGKILL, + } + cmd.Stdout = buf + cmd.Stderr = os.Stderr + if err := cmd.Start(); err != nil { + return err + } + + logrus.Infof("Running %s %v", cmd.Path, cmd.Args) + err := cmd.Wait() + + p.Output = buf.String() + fmt.Fprintf(os.Stdout, p.Output) + if err != nil { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, err) + p.ExitCode = 1 + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + logrus.Infof("Error running %s %v: %v", "sbackup", cmd.Args, waitStatus.ExitStatus()) + p.ExitCode = waitStatus.ExitStatus() + } + } + return err + } + + p.ExitCode = 0 + logrus.Infof("Done running %s %v", "sbackup", cmd.Args) + return nil +} diff --git a/sync/backup.go b/sync/backup.go index 4c32506e..ecd4e47f 100644 --- a/sync/backup.go +++ b/sync/backup.go @@ -210,3 +210,53 @@ func (t *Task) inspectBackup(replicaInController *rest.Replica, backup string) ( } return result, nil } + +func (t *Task) ListBackup(destURL string) (string, error) { + var replica *rest.Replica + + volume, err := t.client.GetVolume() + if err != nil { + return "", err + } + + replicas, err := t.client.ListReplicas() + if err != nil { + return "", err + } + + for _, r := range replicas { + if r.Mode == "RW" { + replica = &r + break + } + } + + if replica == nil { + return "", fmt.Errorf("Cannot find a suitable replica for list backup") + } + + result, err := t.listBackup(replica, destURL, volume.Name) + if err != nil { + return "", err + } + return result, nil +} + +func (t *Task) listBackup(replicaInController *rest.Replica, destURL, volume string) (string, error) { + if replicaInController.Mode != "RW" { + return "", fmt.Errorf("Can only list backup from replica in mode RW, got %s", replicaInController.Mode) + } + + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) + if err != nil { + return "", err + } + + result, err := repClient.ListBackup(destURL, volume) + if err != nil { + logrus.Errorf("Failed to list backup %s with volume %s on %s", + destURL, volume, replicaInController.Address) + return "", err + } + return result, nil +} From b4aec2536cead430297e1c6ba4c513efc3929f7f Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Mar 2017 15:28:35 -0800 Subject: [PATCH 301/357] replica: Introduce "replace" operation in remove snapshot process Original hard-link has a small race window between remove the previous disk and hard-link the new disk. Move the operation along with `remove` into `replace` operation and protect it from race condition. --- integration/core/test_replica.py | 3 +- replica/client/client.go | 12 ++++++++ replica/replica.go | 47 +++++++++++++++++++++++++++++++- replica/replica_test.go | 12 +++++--- replica/rest/model.go | 14 ++++++++++ replica/rest/replica.go | 10 +++++++ replica/rest/router.go | 1 + replica/server.go | 12 ++++++++ sync/agent/process.go | 29 -------------------- sync/sync.go | 16 +++++++++-- 10 files changed, 118 insertions(+), 38 deletions(-) diff --git a/integration/core/test_replica.py b/integration/core/test_replica.py index 9f8d274e..4816aee3 100644 --- a/integration/core/test_replica.py +++ b/integration/core/test_replica.py @@ -200,8 +200,9 @@ def test_remove_last_disk(client): assert ops[0].action == "coalesce" assert ops[0].source == "volume-snap-000.img" assert ops[0].target == "volume-snap-001.img" - assert ops[1].action == "remove" + assert ops[1].action == "replace" assert ops[1].source == "volume-snap-000.img" + assert ops[1].target == "volume-snap-001.img" r = r.removedisk(name='volume-snap-000.img') assert r.state == 'dirty' diff --git a/replica/client/client.go b/replica/client/client.go index f5ac3625..0be5d6f1 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -120,6 +120,18 @@ func (c *ReplicaClient) RemoveDisk(disk string) error { }, nil) } +func (c *ReplicaClient) ReplaceDisk(target, source string) error { + r, err := c.GetReplica() + if err != nil { + return err + } + + return c.post(r.Actions["replacedisk"], &rest.ReplaceDiskInput{ + Target: target, + Source: source, + }, nil) +} + func (c *ReplicaClient) PrepareRemoveDisk(disk string) (rest.PrepareRemoveDiskOutput, error) { var output rest.PrepareRemoveDiskOutput r, err := c.GetReplica() diff --git a/replica/replica.go b/replica/replica.go index e055d1c6..f8869755 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -95,6 +95,7 @@ type DiskInfo struct { const ( OpCoalesce = "coalesce" // Source is parent, target is child OpRemove = "remove" + OpReplace = "replace" ) func ReadInfo(dir string) (Info, error) { @@ -265,6 +266,49 @@ func (r *Replica) RemoveDiffDisk(name string) error { return nil } +func (r *Replica) hardlinkDisk(target, source string) error { + if _, err := os.Stat(r.diskPath(source)); err != nil { + return fmt.Errorf("Cannot find source of replacing: %v", source) + } + + if _, err := os.Stat(r.diskPath(target)); err == nil { + logrus.Infof("Old file %s exists, deleting", target) + if err := os.Remove(r.diskPath(target)); err != nil { + return fmt.Errorf("Fail to remove %s: %v", target, err) + } + } + + if err := os.Link(r.diskPath(source), r.diskPath(target)); err != nil { + return fmt.Errorf("Fail to link %s to %s", source, target) + } + return nil +} + +func (r *Replica) ReplaceDisk(target, source string) error { + r.Lock() + defer r.Unlock() + + if target == r.info.Head { + return fmt.Errorf("Can not replace the active differencing disk") + } + + if err := r.hardlinkDisk(target, source); err != nil { + return err + } + + if err := r.removeDiskNode(source); err != nil { + return err + } + + if err := r.rmDisk(source); err != nil { + return err + } + + logrus.Infof("Done replacing %v with %v", target, source) + + return nil +} + func (r *Replica) removeDiskNode(name string) error { // If snapshot has no child, then we can safely delete it // And it's definitely not in the live chain @@ -380,8 +424,9 @@ func (r *Replica) processPrepareRemoveDisks(disks []string) ([]PrepareRemoveActi Target: child, }, PrepareRemoveAction{ - Action: OpRemove, + Action: OpReplace, Source: disk, + Target: child, }) continue } diff --git a/replica/replica_test.go b/replica/replica_test.go index 37f33a77..1a74f9fe 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -541,8 +541,9 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[0].Action, Equals, OpCoalesce) c.Assert(actions[0].Source, Equals, "volume-snap-000.img") c.Assert(actions[0].Target, Equals, "volume-snap-001.img") - c.Assert(actions[1].Action, Equals, OpRemove) + c.Assert(actions[1].Action, Equals, OpReplace) c.Assert(actions[1].Source, Equals, "volume-snap-000.img") + c.Assert(actions[1].Target, Equals, "volume-snap-001.img") c.Assert(r.activeDiskData[1].Removed, Equals, true) err = r.Snapshot("002", true, now) @@ -565,8 +566,9 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[0].Action, Equals, OpCoalesce) c.Assert(actions[0].Source, Equals, "volume-snap-001.img") c.Assert(actions[0].Target, Equals, "volume-snap-002.img") - c.Assert(actions[1].Action, Equals, OpRemove) + c.Assert(actions[1].Action, Equals, OpReplace) c.Assert(actions[1].Source, Equals, "volume-snap-001.img") + c.Assert(actions[1].Target, Equals, "volume-snap-002.img") err = r.Snapshot("003", true, now) c.Assert(err, IsNil) @@ -592,13 +594,15 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(actions[0].Action, Equals, OpCoalesce) c.Assert(actions[0].Source, Equals, "volume-snap-002.img") c.Assert(actions[0].Target, Equals, "volume-snap-003.img") - c.Assert(actions[1].Action, Equals, OpRemove) + c.Assert(actions[1].Action, Equals, OpReplace) c.Assert(actions[1].Source, Equals, "volume-snap-002.img") + c.Assert(actions[1].Target, Equals, "volume-snap-003.img") c.Assert(actions[2].Action, Equals, OpCoalesce) c.Assert(actions[2].Source, Equals, "volume-snap-003.img") c.Assert(actions[2].Target, Equals, "volume-snap-004.img") - c.Assert(actions[3].Action, Equals, OpRemove) + c.Assert(actions[3].Action, Equals, OpReplace) c.Assert(actions[3].Source, Equals, "volume-snap-003.img") + c.Assert(actions[3].Target, Equals, "volume-snap-004.img") c.Assert(r.activeDiskData[4].Removed, Equals, true) } diff --git a/replica/rest/model.go b/replica/rest/model.go index ffba9fdc..a9a6f37f 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -51,6 +51,12 @@ type RemoveDiskInput struct { Name string `json:"name"` } +type ReplaceDiskInput struct { + client.Resource + Target string `json:"target"` + Source string `json:"source"` +} + type PrepareRemoveDiskInput struct { client.Resource Name string `json:"name"` @@ -88,12 +94,14 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["snapshot"] = true actions["reload"] = true actions["removedisk"] = true + actions["replacedisk"] = true actions["revert"] = true actions["prepareremovedisk"] = true actions["setrevisioncounter"] = true case replica.Closed: actions["open"] = true actions["removedisk"] = true + actions["replacedisk"] = true actions["revert"] = true actions["prepareremovedisk"] = true case replica.Dirty: @@ -102,6 +110,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["snapshot"] = true actions["reload"] = true actions["removedisk"] = true + actions["replacedisk"] = true actions["revert"] = true actions["prepareremovedisk"] = true case replica.Rebuilding: @@ -148,6 +157,7 @@ func NewSchema() *client.Schemas { schemas.AddType("prepareRemoveDiskInput", PrepareRemoveDiskInput{}) schemas.AddType("prepareRemoveDiskOutput", PrepareRemoveDiskOutput{}) schemas.AddType("revisionCounter", RevisionCounter{}) + schemas.AddType("replacediskInput", ReplaceDiskInput{}) replica := schemas.AddType("replica", Replica{}) replica.ResourceMethods = []string{"GET", "DELETE"} @@ -188,6 +198,10 @@ func NewSchema() *client.Schemas { "setrevisioncounter": { Input: "revisionCounter", }, + "replacedisk": { + Input: "replacediskinput", + Output: "replica", + }, } return schemas diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 38a7bfee..73cdc0c7 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -89,6 +89,16 @@ func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { return s.doOp(req, s.s.RemoveDiffDisk(input.Name)) } +func (s *Server) ReplaceDisk(rw http.ResponseWriter, req *http.Request) error { + var input ReplaceDiskInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil { + return err + } + + return s.doOp(req, s.s.ReplaceDisk(input.Target, input.Source)) +} + func (s *Server) PrepareRemoveDisk(rw http.ResponseWriter, req *http.Request) error { var input PrepareRemoveDiskInput apiContext := api.GetApiContext(req) diff --git a/replica/rest/router.go b/replica/rest/router.go index 94a9e826..5098a54d 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -55,6 +55,7 @@ func NewRouter(s *Server) *mux.Router { "open": s.OpenReplica, "close": s.CloseReplica, "removedisk": s.RemoveDisk, + "replacedisk": s.ReplaceDisk, "setrebuilding": s.SetRebuilding, "create": s.Create, "revert": s.RevertReplica, diff --git a/replica/server.go b/replica/server.go index 84def95b..481d158d 100644 --- a/replica/server.go +++ b/replica/server.go @@ -193,6 +193,18 @@ func (s *Server) RemoveDiffDisk(name string) error { return s.r.RemoveDiffDisk(name) } +func (s *Server) ReplaceDisk(target, source string) error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + + logrus.Infof("Replacing disk %v with %v", target, source) + return s.r.ReplaceDisk(target, source) +} + func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error) { s.Lock() defer s.Unlock() diff --git a/sync/agent/process.go b/sync/agent/process.go index c3f29689..d3c9f67d 100644 --- a/sync/agent/process.go +++ b/sync/agent/process.go @@ -131,8 +131,6 @@ func (s *Server) launch(p *Process) error { return s.launchInspectBackup(p) case "listbackup": return s.launchListBackup(p) - case "hardlink": - return s.launchHardLink(p) } return fmt.Errorf("Unknown process type %s", p.ProcessType) } @@ -345,33 +343,6 @@ func (s *Server) launchRestore(p *Process) error { return nil } -func (s *Server) launchHardLink(p *Process) error { - oldName := p.SrcFile - newName := p.DestFile - - if oldName == "" { - p.ExitCode = 0 - return nil - } - - if _, err := os.Stat(newName); err == nil { - logrus.Infof("Old file %s exists, deleting", newName) - if err := os.Remove(newName); err != nil { - p.ExitCode = 1 - return err - } - } - - if err := os.Link(oldName, newName); err != nil { - p.ExitCode = 1 - return err - } - - p.ExitCode = 0 - logrus.Infof("Done running %s %v %v", "hardlink", oldName, newName) - return nil -} - func (s *Server) launchInspectBackup(p *Process) error { buf := new(bytes.Buffer) diff --git a/sync/sync.go b/sync/sync.go index 379c59f2..583d417c 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -67,6 +67,15 @@ func (t *Task) rmDisk(replicaInController *rest.Replica, disk string) error { return repClient.RemoveDisk(disk) } +func (t *Task) replaceDisk(replicaInController *rest.Replica, target, source string) error { + repClient, err := replicaClient.NewReplicaClient(replicaInController.Address) + if err != nil { + return err + } + + return repClient.ReplaceDisk(target, source) +} + func getNameAndIndex(chain []string, snapshot string) (string, int) { index := find(chain, snapshot) if index < 0 { @@ -140,9 +149,10 @@ func (t *Task) processRemoveSnapshot(replicaInController *rest.Replica, snapshot logrus.Errorf("Failed to coalesce %s on %s: %v", snapshot, replicaInController.Address, err) return err } - logrus.Infof("Hard-link %v to %v on %v", op.Source, op.Target, replicaInController.Address) - if err = repClient.HardLink(op.Source, op.Target); err != nil { - logrus.Errorf("Failed to hard-link %v to %v on %v", op.Source, op.Target, replicaInController.Address) + case replica.OpReplace: + logrus.Infof("Replace %v with %v on %v", op.Target, op.Source, replicaInController.Address) + if err = t.replaceDisk(replicaInController, op.Target, op.Source); err != nil { + logrus.Errorf("Failed to replace %v with %v on %v", op.Target, op.Source, replicaInController.Address) return err } } From 2d3509948fec3aa819ad065e04e0e1d1b577bf87 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 8 Mar 2017 23:25:36 -0800 Subject: [PATCH 302/357] backup: Enforce volume name format --- backup/main.go | 7 +++++++ vendor.conf | 2 +- vendor/github.com/yasker/backupstore/backupstore.go | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/backup/main.go b/backup/main.go index 27720602..c27e3957 100644 --- a/backup/main.go +++ b/backup/main.go @@ -13,6 +13,7 @@ import ( "github.com/codegangsta/cli" "github.com/rancher/longhorn/replica" + "github.com/rancher/longhorn/util" "github.com/yasker/backupstore" ) @@ -175,6 +176,9 @@ func doBackupCreate(c *cli.Context) error { if volumeName == "" { return RequiredMissingError("volume") } + if !util.ValidVolumeName(volumeName) { + return fmt.Errorf("Invalid volume name %v for backup", volumeName) + } dir, err := os.Getwd() if err != nil { @@ -308,6 +312,9 @@ func doBackupList(c *cli.Context) error { } volumeName := c.String("volume") + if volumeName != "" && !util.ValidVolumeName(volumeName) { + return fmt.Errorf("Invalid volume name %v for backup", volumeName) + } list, err := backupstore.List(volumeName, destURL, DRIVERNAME) if err != nil { diff --git a/vendor.conf b/vendor.conf index f4b2d740..7b339e0d 100644 --- a/vendor.conf +++ b/vendor.conf @@ -19,4 +19,4 @@ github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 -github.com/yasker/backupstore a9ff4c767a8d5a64afa57b4603714fc85071ced6 +github.com/yasker/backupstore 9b9021c6d62642bb57ff8fb45c41cd1917768757 diff --git a/vendor/github.com/yasker/backupstore/backupstore.go b/vendor/github.com/yasker/backupstore/backupstore.go index c2dcb74f..d120d257 100644 --- a/vendor/github.com/yasker/backupstore/backupstore.go +++ b/vendor/github.com/yasker/backupstore/backupstore.go @@ -50,6 +50,10 @@ func addVolume(volume *Volume, driver BackupStoreDriver) error { return nil } + if !util.ValidateName(volume.Name) { + return fmt.Errorf("Invalid volume name %v", volume.Name) + } + if err := saveVolume(volume, driver); err != nil { log.Error("Fail add volume ", volume.Name) return err @@ -60,6 +64,10 @@ func addVolume(volume *Volume, driver BackupStoreDriver) error { } func removeVolume(volumeName string, driver BackupStoreDriver) error { + if !util.ValidateName(volumeName) { + return fmt.Errorf("Invalid volume name %v", volumeName) + } + if !volumeExists(volumeName, driver) { return fmt.Errorf("Volume %v doesn't exist in backupstore", volumeName) } @@ -100,6 +108,10 @@ func addListVolume(resp map[string]map[string]string, volumeName string, driver return fmt.Errorf("Invalid empty volume Name") } + if !util.ValidateName(volumeName) { + return fmt.Errorf("Invalid volume name %v", volumeName) + } + backupNames, err := getBackupNamesForVolume(volumeName, driver) if err != nil { return err From 825494f4236db4f661d72f5453b5ad22b18490a9 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 9 Mar 2017 15:35:38 -0800 Subject: [PATCH 303/357] cli: `snapshot info` mark any snapshot with `Removed` tag from any replica as `Removed` There is possibility that the removing process as in progress and only one replica shows one snapshot as `Removed`. The information needed to be consolidated, and `UserCreated` non-`Removed` snapshot should be able to be used in backup. --- app/snapshot.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index cc1a7cb8..fe054ce9 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -236,7 +236,7 @@ func infoSnapshot(c *cli.Context) error { return err } } - outputDisks[snapshot] = replica.DiskInfo{ + info := replica.DiskInfo{ Name: snapshot, Parent: parent, Removed: disk.Removed, @@ -244,12 +244,23 @@ func infoSnapshot(c *cli.Context) error { Children: children, Created: disk.Created, } + if _, exists := outputDisks[snapshot]; !exists { + outputDisks[snapshot] = info + } else { + // Consolidate the result of snapshot in removing process + if info.Removed && !outputDisks[snapshot].Removed { + t := outputDisks[snapshot] + t.Removed = true + outputDisks[snapshot] = t + } + } } - output, err = json.MarshalIndent(outputDisks, "", "\t") - if err != nil { - return err - } + } + + output, err = json.MarshalIndent(outputDisks, "", "\t") + if err != nil { + return err } if output == nil { From ad2d82de6361223b655e8900411d1da4320c1ef8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 9 Mar 2017 17:25:14 -0800 Subject: [PATCH 304/357] cli: Include `volume-head` into the `snapshot info` Instead of have different name poped up, the key word for volume head is `volume-head`. --- app/snapshot.go | 24 ++++++++++++++++-------- integration/core/test_cli.py | 29 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/app/snapshot.go b/app/snapshot.go index fe054ce9..ca1a963a 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -15,6 +15,8 @@ import ( "github.com/rancher/longhorn/util" ) +const VolumeHeadName = "volume-head" + func SnapshotCmd() cli.Command { return cli.Command{ Name: "snapshots", @@ -212,22 +214,28 @@ func infoSnapshot(c *cli.Context) error { } for name, disk := range disks { - if replica.IsHeadDisk(name) { - continue - } - snapshot, err := replica.GetSnapshotNameFromDiskName(name) - if err != nil { - return err + snapshot := "" + + if !replica.IsHeadDisk(name) { + snapshot, err = replica.GetSnapshotNameFromDiskName(name) + if err != nil { + return err + } + } else { + snapshot = VolumeHeadName } children := []string{} for _, childDisk := range disk.Children { + child := "" if !replica.IsHeadDisk(childDisk) { - child, err := replica.GetSnapshotNameFromDiskName(childDisk) + child, err = replica.GetSnapshotNameFromDiskName(childDisk) if err != nil { return err } - children = append(children, child) + } else { + child = VolumeHeadName } + children = append(children, child) } parent := "" if disk.Parent != "" { diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index e62febf7..630969dc 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -183,16 +183,25 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, info = json.loads(output) # two existing snapshots and one system snapshot due to rebuild - assert len(info) == 3 + # and volume-head + volumehead = "volume-head" + assert len(info) == 4 for name in info: - if name != snap0 and name != snap1: + if name != snap0 and name != snap1 and name != volumehead: snapreb = name break + head_info = info[volumehead] + assert head_info["name"] == volumehead + assert head_info["parent"] == snapreb + assert head_info["children"] == [] + assert head_info["removed"] is False + assert head_info["usercreated"] is False + snapreb_info = info[snapreb] assert snapreb_info["name"] == snapreb assert snapreb_info["parent"] == snap1 - assert snapreb_info["children"] == [] + assert snapreb_info["children"] == [volumehead] assert snapreb_info["removed"] is False assert snapreb_info["usercreated"] is False @@ -384,12 +393,22 @@ def test_snapshot_info(bin, controller_client, output = subprocess.check_output(cmd) info = json.loads(output) - assert len(info) == 2 + assert len(info) == 3 + + volumehead = "volume-head" + + head_info = info[volumehead] + assert head_info["name"] == volumehead + assert head_info["parent"] == snap2.id + assert head_info["children"] == [] + assert head_info["removed"] is False + assert head_info["usercreated"] is False + assert head_info["created"] != "" snap2_info = info[snap2.id] assert snap2_info["name"] == snap2.id assert snap2_info["parent"] == snap.id - assert snap2_info["children"] == [] + assert snap2_info["children"] == [volumehead] assert snap2_info["removed"] is False assert snap2_info["usercreated"] is True assert snap2_info["created"] != "" From dc31bcbbb07a278b80e6e2240b5d61566155c79d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 9 Mar 2017 18:22:36 -0800 Subject: [PATCH 305/357] replica: Add actual size field to disk info Now `snapshot info` will show the actual size of each snapshot, in bytes. --- app/snapshot.go | 1 + integration/core/test_cli.py | 4 ++++ integration/data/cmd.py | 5 +++++ integration/data/test_snapshot.py | 7 +++++++ replica/replica.go | 7 +++++++ replica/replica_test.go | 3 +++ util/util.go | 14 ++++++++++++++ 7 files changed, 41 insertions(+) diff --git a/app/snapshot.go b/app/snapshot.go index ca1a963a..5ae2e354 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -251,6 +251,7 @@ func infoSnapshot(c *cli.Context) error { UserCreated: disk.UserCreated, Children: children, Created: disk.Created, + Size: disk.Size, } if _, exists := outputDisks[snapshot]; !exists { outputDisks[snapshot] = info diff --git a/integration/core/test_cli.py b/integration/core/test_cli.py index 630969dc..22c3ee6c 100644 --- a/integration/core/test_cli.py +++ b/integration/core/test_cli.py @@ -197,6 +197,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert head_info["children"] == [] assert head_info["removed"] is False assert head_info["usercreated"] is False + assert head_info["size"] == "0" snapreb_info = info[snapreb] assert snapreb_info["name"] == snapreb @@ -204,6 +205,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert snapreb_info["children"] == [volumehead] assert snapreb_info["removed"] is False assert snapreb_info["usercreated"] is False + assert snapreb_info["size"] == "0" snap1_info = info[snap1] assert snap1_info["name"] == snap1 @@ -212,6 +214,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert snap1_info["removed"] is False assert snap1_info["usercreated"] is True assert snap1_info["created"] == createtime1 + assert snap1_info["size"] == "0" snap0_info = info[snap0] assert snap0_info["name"] == snap0 @@ -220,6 +223,7 @@ def test_replica_add_rebuild(bin, controller_client, replica_client, assert snap0_info["removed"] is False assert snap0_info["usercreated"] is False assert snap0_info["created"] == createtime0 + assert snap0_info["size"] == "0" def test_replica_add_after_rebuild_failed(bin, controller_client, diff --git a/integration/data/cmd.py b/integration/data/cmd.py index 3cb94c75..2f58a174 100644 --- a/integration/data/cmd.py +++ b/integration/data/cmd.py @@ -37,6 +37,11 @@ def snapshot_ls(): return subprocess.check_output(cmd) +def snapshot_info(): + cmd = [_bin(), '--debug', 'snapshot', 'info'] + return subprocess.check_output(cmd) + + def backup_create(snapshot, dest): cmd = [_bin(), '--debug', 'backup', 'create', snapshot, '--dest', dest] return subprocess.check_output(cmd).strip() diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index 42daab97..cd963c23 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -1,3 +1,4 @@ +import json import cmd import common from common import dev, backing_dev # NOQA @@ -124,6 +125,12 @@ def test_snapshot_rm_rolling(dev): # NOQA assert snap3 in snapList assert snap4 in snapList + output = cmd.snapshot_info() + info = json.loads(output) + + assert info[snap3]["size"] == "4096" + assert info[snap4]["size"] == "4096" + # this should trigger real deletion of snap2 and snap3 cmd.snapshot_rm(snap3) diff --git a/replica/replica.go b/replica/replica.go index f8869755..3cd9c87d 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -90,6 +90,7 @@ type DiskInfo struct { Removed bool `json:"removed"` UserCreated bool `json:"usercreated"` Created string `json:"created"` + Size string `json:"size"` } const ( @@ -908,12 +909,14 @@ func (r *Replica) ListDisks() map[string]DiskInfo { result := map[string]DiskInfo{} for _, disk := range r.diskData { + diskSize := strconv.FormatInt(r.getDiskSize(disk.Name), 10) diskInfo := DiskInfo{ Name: disk.Name, Parent: disk.Parent, Removed: disk.Removed, UserCreated: disk.UserCreated, Created: disk.Created, + Size: diskSize, } children := []string{} for child := range r.diskChildrenMap[disk.Name] { @@ -931,3 +934,7 @@ func (r *Replica) GetRemainSnapshotCounts() int { return maximumChainLength - len(r.activeDiskData) } + +func (r *Replica) getDiskSize(disk string) int64 { + return util.GetFileActualSize(r.diskPath(disk)) +} diff --git a/replica/replica_test.go b/replica/replica_test.go index 1a74f9fe..b26920d2 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -104,6 +104,7 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(len(disks["volume-snap-000.img"].Children), Equals, 1) c.Assert(disks["volume-snap-000.img"].Children[0], Equals, "volume-snap-001.img") c.Assert(disks["volume-snap-000.img"].Created, Equals, createdTime0) + c.Assert(disks["volume-snap-000.img"].Size, Equals, "0") c.Assert(disks["volume-snap-001.img"].Parent, Equals, "volume-snap-000.img") c.Assert(disks["volume-snap-001.img"].UserCreated, Equals, true) @@ -111,12 +112,14 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(len(disks["volume-snap-001.img"].Children), Equals, 1) c.Assert(disks["volume-snap-001.img"].Children[0], Equals, "volume-head-002.img") c.Assert(disks["volume-snap-001.img"].Created, Equals, createdTime1) + c.Assert(disks["volume-snap-001.img"].Size, Equals, "0") c.Assert(disks["volume-head-002.img"].Parent, Equals, "volume-snap-001.img") c.Assert(disks["volume-head-002.img"].UserCreated, Equals, false) c.Assert(disks["volume-head-002.img"].Removed, Equals, false) c.Assert(len(disks["volume-head-002.img"].Children), Equals, 0) c.Assert(disks["volume-head-002.img"].Created, Equals, createdTime1) + c.Assert(disks["volume-head-002.img"].Size, Equals, "0") } func (s *TestSuite) TestRevert(c *C) { diff --git a/util/util.go b/util/util.go index 6f3d9d9c..cb26b76d 100644 --- a/util/util.go +++ b/util/util.go @@ -8,6 +8,7 @@ import ( "regexp" "strconv" "strings" + "syscall" "time" "github.com/Sirupsen/logrus" @@ -21,6 +22,10 @@ var ( parsePattern = regexp.MustCompile(`(.*):(\d+)`) ) +const ( + BlockSizeLinux = 512 +) + func ParseAddresses(name string) (string, string, string, error) { matches := parsePattern.FindStringSubmatch(name) if matches == nil { @@ -148,3 +153,12 @@ func Volume2ISCSIName(name string) string { func Now() string { return time.Now().UTC().Format(time.RFC3339) } + +func GetFileActualSize(file string) int64 { + var st syscall.Stat_t + if err := syscall.Stat(file, &st); err != nil { + logrus.Errorf("Fail to get size of file %v", file) + return -1 + } + return st.Blocks * BlockSizeLinux +} From 0b665afc80a7e77df700984da25040e3b26d74b2 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 10 Mar 2017 19:48:20 -0800 Subject: [PATCH 306/357] backup: Show size of backup in `backup inspect` It's the amount of space backup will occupy if restored to volume. --- integration/data/test_backup.py | 4 ++++ vendor.conf | 2 +- vendor/github.com/yasker/backupstore/backupstore.go | 4 +++- vendor/github.com/yasker/backupstore/deltablock.go | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/integration/data/test_backup.py b/integration/data/test_backup.py index 481d25c8..19cab367 100644 --- a/integration/data/test_backup.py +++ b/integration/data/test_backup.py @@ -9,6 +9,7 @@ VOLUME_NAME = 'test-volume_1.0' VOLUME_SIZE = str(4 * 1024 * 1024) # 4M +BLOCK_SIZE = str(2 * 1024 * 1024) # 2M def test_backup(dev): # NOQA @@ -25,6 +26,7 @@ def test_backup(dev): # NOQA assert backup1_info["BackupURL"] == backup1 assert backup1_info["VolumeName"] == VOLUME_NAME assert backup1_info["VolumeSize"] == VOLUME_SIZE + assert backup1_info["Size"] == BLOCK_SIZE assert snap1 in backup1_info["SnapshotName"] snap2_data = common.random_string(length) @@ -37,6 +39,7 @@ def test_backup(dev): # NOQA assert backup2_info["BackupURL"] == backup2 assert backup2_info["VolumeName"] == VOLUME_NAME assert backup2_info["VolumeSize"] == VOLUME_SIZE + assert backup2_info["Size"] == BLOCK_SIZE assert snap2 in backup2_info["SnapshotName"] snap3_data = common.random_string(length) @@ -49,6 +52,7 @@ def test_backup(dev): # NOQA assert backup3_info["BackupURL"] == backup3 assert backup3_info["VolumeName"] == VOLUME_NAME assert backup3_info["VolumeSize"] == VOLUME_SIZE + assert backup3_info["Size"] == BLOCK_SIZE assert snap3 in backup3_info["SnapshotName"] cmd.backup_restore(backup3) diff --git a/vendor.conf b/vendor.conf index 7b339e0d..35fb68d4 100644 --- a/vendor.conf +++ b/vendor.conf @@ -19,4 +19,4 @@ github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3 github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 -github.com/yasker/backupstore 9b9021c6d62642bb57ff8fb45c41cd1917768757 +github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 diff --git a/vendor/github.com/yasker/backupstore/backupstore.go b/vendor/github.com/yasker/backupstore/backupstore.go index d120d257..d4288955 100644 --- a/vendor/github.com/yasker/backupstore/backupstore.go +++ b/vendor/github.com/yasker/backupstore/backupstore.go @@ -11,7 +11,7 @@ import ( type Volume struct { Name string Driver string - Size int64 + Size int64 `json:",string"` CreatedTime string LastBackupName string } @@ -28,6 +28,7 @@ type Backup struct { SnapshotName string SnapshotCreatedAt string CreatedTime string + Size int64 `json:",string"` Blocks []BlockMapping `json:",omitempty"` SingleFile BackupFile `json:",omitempty"` @@ -172,6 +173,7 @@ func fillBackupInfo(backup *Backup, volume *Volume, destURL string) map[string]s "SnapshotName": backup.SnapshotName, "SnapshotCreatedAt": backup.SnapshotCreatedAt, "CreatedTime": backup.CreatedTime, + "Size": strconv.FormatInt(backup.Size, 10), } } diff --git a/vendor/github.com/yasker/backupstore/deltablock.go b/vendor/github.com/yasker/backupstore/deltablock.go index 5c39e1c2..3d3393ad 100644 --- a/vendor/github.com/yasker/backupstore/deltablock.go +++ b/vendor/github.com/yasker/backupstore/deltablock.go @@ -178,6 +178,7 @@ func CreateDeltaBlockBackup(volume *Volume, snapshot *Snapshot, destURL string, backup.SnapshotName = snapshot.Name backup.SnapshotCreatedAt = snapshot.CreatedTime backup.CreatedTime = util.Now() + backup.Size = int64(len(backup.Blocks)) * DEFAULT_BLOCK_SIZE if err := saveBackup(backup, bsDriver); err != nil { return "", err From da503549c988ecd5a5520f3bc86ef9af539e3b69 Mon Sep 17 00:00:00 2001 From: ajkumar Date: Fri, 11 Nov 2016 09:22:03 +0530 Subject: [PATCH 307/357] crude first cut integration of longhorn with gotgt --- app/controller_gotgt.go | 9 +++ frontend/gotgt/frontend.go | 122 +++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 app/controller_gotgt.go create mode 100644 frontend/gotgt/frontend.go diff --git a/app/controller_gotgt.go b/app/controller_gotgt.go new file mode 100644 index 00000000..0558a96f --- /dev/null +++ b/app/controller_gotgt.go @@ -0,0 +1,9 @@ +package app + +import ( + "github.com/openebs/longhorn/frontend/gotgt" +) + +func init() { + frontends["gotgt"] = gotgt.New() +} diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go new file mode 100644 index 00000000..873163a4 --- /dev/null +++ b/frontend/gotgt/frontend.go @@ -0,0 +1,122 @@ +package gotgt + +import ( + "github.com/Sirupsen/logrus" + + "github.com/openebs/longhorn/types" + "github.com/openebs/longhorn/util" + + "github.com/openebs/gotgt/pkg/config" + "github.com/openebs/gotgt/pkg/port/iscsit" + "github.com/openebs/gotgt/pkg/scsi" + _ "github.com/openebs/gotgt/pkg/scsi/backingstore" +) + +func New() types.Frontend { + return &goTgt{} +} + +type goTgt struct { + Volume string + Size int64 + SectorSize int + + isUp bool + rw types.ReaderWriterAt + + tgtName string + lhbsName string + cfg *config.Config + scsiDevice *util.ScsiDevice +} + +func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { + /*if err := t.Shutdown(); err != nil { + return err + }*/ + + t.tgtName = "iqn.2016-09.com.openebs.jiva:" + name + t.lhbsName = "RemBs:" + name + t.cfg = &config.Config{ + Storages: []config.BackendStorage{ + config.BackendStorage{ + DeviceID: 1000, + Path: t.lhbsName, + Online: true, + }, + }, + ISCSIPortals: []config.ISCSIPortalInfo{ + config.ISCSIPortalInfo{ + ID: 0, + Portal: "127.0.0.1:3260", + }, + }, + ISCSITargets: map[string]config.ISCSITarget{ + t.tgtName: config.ISCSITarget{ + TPGTs: map[string][]uint64{ + "1": []uint64{0}, + }, + LUNs: map[string]uint64{ + "1": uint64(1000), + }, + }, + }, + } + + t.Volume = name + t.Size = size + t.SectorSize = int(sectorSize) + t.rw = rw + if err := t.startScsiDevice(t.cfg); err != nil { + return err + } + + t.isUp = true + + return nil +} + +func (t *goTgt) Shutdown() error { + if t.Volume != "" { + t.Volume = "" + } + + if t.scsiDevice != nil { + logrus.Infof("Shutdown SCSI device at %v", t.scsiDevice.Device) + /*if err := t.scsiDevice.Shutdown(); err != nil { + return err + }*/ + t.scsiDevice = nil + } + t.stopScsiDevice() + t.isUp = false + + return nil +} + +func (t *goTgt) State() types.State { + if t.isUp { + return types.StateUp + } + return types.StateDown +} + +func (t *goTgt) startScsiDevice(cfg *config.Config) error { + scsiTarget := scsi.NewSCSITargetService() + targetDriver, err := iscsit.NewISCSITargetService(scsiTarget) + if err != nil { + logrus.Errorf("iscsi target driver error") + return err + } + scsi.InitSCSILUMapEx(t.tgtName, t.Volume, 1, 1, uint64(t.Size), uint64(t.SectorSize), t.rw) + targetDriver.NewTarget(t.tgtName, cfg) + go targetDriver.Run() + + logrus.Infof("SCSI device created") + return nil +} + +func (t *goTgt) stopScsiDevice() error { + logrus.Infof("SCSI device stop...") + return nil +} From 1d236d154b81bdf6f0bfe912a9d9fde556bbb3cc Mon Sep 17 00:00:00 2001 From: payes Date: Fri, 11 Nov 2016 06:51:25 +0000 Subject: [PATCH 308/357] Listen on the Container IP --- frontend/gotgt/frontend.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index 873163a4..8bf7a523 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -1,6 +1,8 @@ package gotgt import ( + "os" + "net" "github.com/Sirupsen/logrus" "github.com/openebs/longhorn/types" @@ -37,6 +39,16 @@ func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWrit t.tgtName = "iqn.2016-09.com.openebs.jiva:" + name t.lhbsName = "RemBs:" + name + host, _ := os.Hostname() + addrs, _ := net.LookupIP(host) + var ip string + for _, addr := range addrs { + if ipv4 := addr.To4(); ipv4 != nil { + ip = ipv4.String() + break + //fmt.Println("IPv4: ", ipv4) + } + } t.cfg = &config.Config{ Storages: []config.BackendStorage{ config.BackendStorage{ @@ -48,7 +60,7 @@ func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWrit ISCSIPortals: []config.ISCSIPortalInfo{ config.ISCSIPortalInfo{ ID: 0, - Portal: "127.0.0.1:3260", + Portal: ip+":3260", }, }, ISCSITargets: map[string]config.ISCSITarget{ From de7381e93ffa51400993eb8e523e1c7906d6e64a Mon Sep 17 00:00:00 2001 From: payes Date: Fri, 11 Nov 2016 06:54:23 +0000 Subject: [PATCH 309/357] initial packaging of gotgt --- scripts/ci | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci b/scripts/ci index 502224c5..2136a773 100755 --- a/scripts/ci +++ b/scripts/ci @@ -4,7 +4,7 @@ set -e cd $(dirname $0) ./build -./test -./validate -./integration-test +#./test +#./validate +#./integration-test ./package From 3ba6d7b9d340fcb4b6ad3d457dc3cd3de32d698a Mon Sep 17 00:00:00 2001 From: payes Date: Fri, 11 Nov 2016 06:55:14 +0000 Subject: [PATCH 310/357] Image name changed to openebs --- scripts/package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package b/scripts/package index bcf0ddf8..8ceb25f9 100755 --- a/scripts/package +++ b/scripts/package @@ -6,7 +6,7 @@ source $(dirname $0)/version cd $(dirname $0)/../package TAG=${TAG:-${VERSION}} -REPO=${REPO:-rancher} +REPO=${REPO:-openebs} if [ ! -x ../bin/longhorn ]; then ../scripts/build From 0998f0dae1882d0ae6a47c6394afef1362306e06 Mon Sep 17 00:00:00 2001 From: payes Date: Thu, 17 Nov 2016 03:48:33 +0000 Subject: [PATCH 311/357] Removing the exposed /dev of the host and renaming the launch program to launch-simple-jiva --- package/{launch-simple-longhorn => launch-simple-jiva} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename package/{launch-simple-longhorn => launch-simple-jiva} (95%) diff --git a/package/launch-simple-longhorn b/package/launch-simple-jiva similarity index 95% rename from package/launch-simple-longhorn rename to package/launch-simple-jiva index e744ac5a..a3859261 100755 --- a/package/launch-simple-longhorn +++ b/package/launch-simple-jiva @@ -2,7 +2,7 @@ set -x set -e -mount --rbind /host/dev /dev +#mount --rbind /host/dev /dev volume=$1 size=$2 From 81f3c6160eea35ed7ee24e8e084eb68a62e9c07a Mon Sep 17 00:00:00 2001 From: ajkumar Date: Thu, 17 Nov 2016 11:25:12 +0530 Subject: [PATCH 312/357] golint fix --- frontend/gotgt/frontend.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index 8bf7a523..c2557160 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -1,8 +1,9 @@ package gotgt import ( - "os" "net" + "os" + "github.com/Sirupsen/logrus" "github.com/openebs/longhorn/types" @@ -11,7 +12,7 @@ import ( "github.com/openebs/gotgt/pkg/config" "github.com/openebs/gotgt/pkg/port/iscsit" "github.com/openebs/gotgt/pkg/scsi" - _ "github.com/openebs/gotgt/pkg/scsi/backingstore" + _ "github.com/openebs/gotgt/pkg/scsi/backingstore" /* init lib */ ) func New() types.Frontend { @@ -60,7 +61,7 @@ func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWrit ISCSIPortals: []config.ISCSIPortalInfo{ config.ISCSIPortalInfo{ ID: 0, - Portal: ip+":3260", + Portal: ip + ":3260", }, }, ISCSITargets: map[string]config.ISCSITarget{ From 026fd93d59ee9dba0a03bcb492b64ae617d8839b Mon Sep 17 00:00:00 2001 From: ajkumar Date: Thu, 17 Nov 2016 11:25:24 +0530 Subject: [PATCH 313/357] enable tests --- scripts/ci | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci b/scripts/ci index 2136a773..502224c5 100755 --- a/scripts/ci +++ b/scripts/ci @@ -4,7 +4,7 @@ set -e cd $(dirname $0) ./build -#./test -#./validate -#./integration-test +./test +./validate +./integration-test ./package From 3f34a0c1688d3673ea1751c4674cb5ef7c8e3fd8 Mon Sep 17 00:00:00 2001 From: ajkumar Date: Thu, 17 Nov 2016 11:27:27 +0530 Subject: [PATCH 314/357] golint fix --- frontend/tcmu/frontend.go | 2 +- util/util.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index 0055f947..d5a24878 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -301,7 +301,7 @@ func remove(path string) error { case err := <-done: return err case <-time.After(30 * time.Second): - return fmt.Errorf("timeout trying to delete %s", path) + return fmt.Errorf("Timeout trying to delete %s", path) } } diff --git a/util/util.go b/util/util.go index cb26b76d..53c05a5d 100644 --- a/util/util.go +++ b/util/util.go @@ -134,7 +134,7 @@ func remove(path string) error { case err := <-done: return err case <-time.After(30 * time.Second): - return fmt.Errorf("timeout trying to delete %s", path) + return fmt.Errorf("Timeout trying to delete %s", path) } } From 1027f748a0072721f1c35e2356d8efef93c7457a Mon Sep 17 00:00:00 2001 From: ajkumar Date: Thu, 17 Nov 2016 15:48:35 +0530 Subject: [PATCH 315/357] fix the package build --- package/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Dockerfile b/package/Dockerfile index ab8dbc88..6a9fd83a 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get install -y kmod curl nfs-common fuse \ libibverbs1 librdmacm1 libconfig-general-perl libaio1 -COPY longhorn launch copy-binary launch-with-vm-backing-file launch-simple-longhorn /usr/local/bin/ +COPY longhorn launch copy-binary launch-with-vm-backing-file launch-simple-jiva /usr/local/bin/ COPY tgt_*.deb /opt/ RUN dpkg -i /opt/tgt_*.deb VOLUME /usr/local/bin From 602054681e974bd3789251388d6bbc096023d3d8 Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Tue, 22 Nov 2016 16:00:34 +0530 Subject: [PATCH 316/357] Update ci --- scripts/ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci b/scripts/ci index 502224c5..8b0f3ac3 100755 --- a/scripts/ci +++ b/scripts/ci @@ -6,5 +6,5 @@ cd $(dirname $0) ./build ./test ./validate -./integration-test +#./integration-test ./package From 7a7c1027736524bd2c8f83027b1fe82ecfb6d6f7 Mon Sep 17 00:00:00 2001 From: ajkumar Date: Wed, 23 Nov 2016 22:22:05 +0530 Subject: [PATCH 317/357] issue #3 stop/re-start iscsi listener --- frontend/gotgt/frontend.go | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index c2557160..e76775e1 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -7,9 +7,9 @@ import ( "github.com/Sirupsen/logrus" "github.com/openebs/longhorn/types" - "github.com/openebs/longhorn/util" "github.com/openebs/gotgt/pkg/config" + "github.com/openebs/gotgt/pkg/port" "github.com/openebs/gotgt/pkg/port/iscsit" "github.com/openebs/gotgt/pkg/scsi" _ "github.com/openebs/gotgt/pkg/scsi/backingstore" /* init lib */ @@ -30,7 +30,7 @@ type goTgt struct { tgtName string lhbsName string cfg *config.Config - scsiDevice *util.ScsiDevice + targetDriver port.SCSITargetService } func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { @@ -80,7 +80,7 @@ func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWrit t.Size = size t.SectorSize = int(sectorSize) t.rw = rw - if err := t.startScsiDevice(t.cfg); err != nil { + if err := t.startScsiTarget(t.cfg); err != nil { return err } @@ -94,14 +94,7 @@ func (t *goTgt) Shutdown() error { t.Volume = "" } - if t.scsiDevice != nil { - logrus.Infof("Shutdown SCSI device at %v", t.scsiDevice.Device) - /*if err := t.scsiDevice.Shutdown(); err != nil { - return err - }*/ - t.scsiDevice = nil - } - t.stopScsiDevice() + t.stopScsiTarget() t.isUp = false return nil @@ -114,22 +107,25 @@ func (t *goTgt) State() types.State { return types.StateDown } -func (t *goTgt) startScsiDevice(cfg *config.Config) error { +func (t *goTgt) startScsiTarget(cfg *config.Config) error { scsiTarget := scsi.NewSCSITargetService() - targetDriver, err := iscsit.NewISCSITargetService(scsiTarget) + var err error + t.targetDriver, err = iscsit.NewISCSITargetService(scsiTarget) if err != nil { logrus.Errorf("iscsi target driver error") return err } scsi.InitSCSILUMapEx(t.tgtName, t.Volume, 1, 1, uint64(t.Size), uint64(t.SectorSize), t.rw) - targetDriver.NewTarget(t.tgtName, cfg) - go targetDriver.Run() + t.targetDriver.NewTarget(t.tgtName, cfg) + go t.targetDriver.Run() logrus.Infof("SCSI device created") return nil } -func (t *goTgt) stopScsiDevice() error { - logrus.Infof("SCSI device stop...") +func (t *goTgt) stopScsiTarget() error { + logrus.Infof("stopping target %v ...", t.tgtName) + t.targetDriver.Stop() + logrus.Infof("target %v stopped", t.tgtName) return nil } From 1ec52055cb747e1af7760f7cab136f40084a54ae Mon Sep 17 00:00:00 2001 From: ajkumar Date: Mon, 12 Dec 2016 12:24:24 +0530 Subject: [PATCH 318/357] golint started failing here! --- frontend/gotgt/frontend.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index e76775e1..5ed91a1d 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -15,6 +15,7 @@ import ( _ "github.com/openebs/gotgt/pkg/scsi/backingstore" /* init lib */ ) +/*New is called on module load */ func New() types.Frontend { return &goTgt{} } @@ -27,9 +28,9 @@ type goTgt struct { isUp bool rw types.ReaderWriterAt - tgtName string - lhbsName string - cfg *config.Config + tgtName string + lhbsName string + cfg *config.Config targetDriver port.SCSITargetService } From 3acbfb055b180eb3c3a253fb75e98af5b92d2615 Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Tue, 13 Dec 2016 13:03:19 +0530 Subject: [PATCH 319/357] Setup travis ci for commits on openebs/longhorn --- .travis.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..0309e3d8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: go +dist: trusty +sudo: required +install: true +go: + - 1.7.1 +env: + global: + - GOARCH=amd64 + - GO_FOR_RELEASE=1.7.1 +before_install: + - sleep 15 + - sudo apt-get install -y + - sudo apt-get install -y curl + - go env && pwd + - mkdir -p $HOME/gopath/bin + - mkdir -p $HOME/gopath/src/github/openebs + - cd $HOME/gopath/src/github/openebs && git clone https://github.com/openebs/jiva.git +script: + - cd $HOME/gopath/src/github/openebs/jiva && make build From a87df6ec276012c484e7ce14732fb33cc3b0b9fd Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Tue, 13 Dec 2016 13:10:12 +0530 Subject: [PATCH 320/357] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0309e3d8..9dee2242 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ before_install: - sleep 15 - sudo apt-get install -y - sudo apt-get install -y curl - - go env && pwd - mkdir -p $HOME/gopath/bin - mkdir -p $HOME/gopath/src/github/openebs - cd $HOME/gopath/src/github/openebs && git clone https://github.com/openebs/jiva.git From 155cc583b4ed2f98589c6d4b4737577bdf65c6ec Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Tue, 13 Dec 2016 13:19:07 +0530 Subject: [PATCH 321/357] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9dee2242..7faddbb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,6 @@ before_install: - sudo apt-get install -y curl - mkdir -p $HOME/gopath/bin - mkdir -p $HOME/gopath/src/github/openebs - - cd $HOME/gopath/src/github/openebs && git clone https://github.com/openebs/jiva.git + - cd $HOME/gopath/src/github.com/openebs && git clone https://github.com/openebs/jiva.git script: - - cd $HOME/gopath/src/github/openebs/jiva && make build + - cd $HOME/gopath/src/github.com/openebs/jiva && make build From 6a80221acc1c760706d960fd4d9ad300f731257f Mon Sep 17 00:00:00 2001 From: payes Date: Tue, 13 Dec 2016 09:32:50 +0000 Subject: [PATCH 322/357] Adding an option to provide frontendIP --- app/controller.go | 11 +++++++++-- controller/control.go | 12 +++++++----- frontend/gotgt/frontend.go | 17 ++--------------- frontend/rest/frontend.go | 2 +- frontend/tcmu/frontend.go | 2 +- frontend/tgt/frontend.go | 2 +- types/types.go | 2 +- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app/controller.go b/app/controller.go index c01d6eaf..ee72d69d 100644 --- a/app/controller.go +++ b/app/controller.go @@ -35,6 +35,10 @@ func ControllerCmd() cli.Command { Name: "frontend", Value: "", }, + cli.StringFlag{ + Name: "frontendIP", + Value: "", + }, cli.StringSliceFlag{ Name: "enable-backend", Value: (*cli.StringSlice)(&[]string{"tcp"}), @@ -52,6 +56,7 @@ func ControllerCmd() cli.Command { } func startController(c *cli.Context) error { + var frontendIP string if c.NArg() == 0 { return errors.New("volume name is required") } @@ -65,7 +70,9 @@ func startController(c *cli.Context) error { backends := c.StringSlice("enable-backend") replicas := c.StringSlice("replica") frontendName := c.String("frontend") - + if frontendName == "gotgt" { + frontendIP = c.String("frontendIP") + } factories := map[string]types.BackendFactory{} for _, backend := range backends { switch backend { @@ -87,7 +94,7 @@ func startController(c *cli.Context) error { frontend = f } - control := controller.NewController(name, dynamic.New(factories), frontend) + control := controller.NewController(name, frontendIP, dynamic.New(factories), frontend) server := rest.NewServer(control) router := http.Handler(rest.NewRouter(server)) diff --git a/controller/control.go b/controller/control.go index 601f7246..e4ebd2ff 100644 --- a/controller/control.go +++ b/controller/control.go @@ -12,6 +12,7 @@ import ( type Controller struct { sync.RWMutex Name string + frontendIP string size int64 sectorSize int64 replicas []types.Replica @@ -20,11 +21,12 @@ type Controller struct { frontend types.Frontend } -func NewController(name string, factory types.BackendFactory, frontend types.Frontend) *Controller { +func NewController(name string, frontendIP string, factory types.BackendFactory, frontend types.Frontend) *Controller { c := &Controller{ - factory: factory, - Name: name, - frontend: frontend, + factory: factory, + Name: name, + frontend: frontend, + frontendIP: frontendIP, } c.reset() return c @@ -195,7 +197,7 @@ func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { func (c *Controller) startFrontend() error { if len(c.replicas) > 0 && c.frontend != nil { - if err := c.frontend.Startup(c.Name, c.size, c.sectorSize, c); err != nil { + if err := c.frontend.Startup(c.Name, c.frontendIP, c.size, c.sectorSize, c); err != nil { // FATAL logrus.Fatalf("Failed to start up frontend: %v", err) // This will never be reached diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index 5ed91a1d..91fb2aa9 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -1,9 +1,6 @@ package gotgt import ( - "net" - "os" - "github.com/Sirupsen/logrus" "github.com/openebs/longhorn/types" @@ -34,23 +31,13 @@ type goTgt struct { targetDriver port.SCSITargetService } -func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *goTgt) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { /*if err := t.Shutdown(); err != nil { return err }*/ t.tgtName = "iqn.2016-09.com.openebs.jiva:" + name t.lhbsName = "RemBs:" + name - host, _ := os.Hostname() - addrs, _ := net.LookupIP(host) - var ip string - for _, addr := range addrs { - if ipv4 := addr.To4(); ipv4 != nil { - ip = ipv4.String() - break - //fmt.Println("IPv4: ", ipv4) - } - } t.cfg = &config.Config{ Storages: []config.BackendStorage{ config.BackendStorage{ @@ -62,7 +49,7 @@ func (t *goTgt) Startup(name string, size, sectorSize int64, rw types.ReaderWrit ISCSIPortals: []config.ISCSIPortalInfo{ config.ISCSIPortalInfo{ ID: 0, - Portal: ip + ":3260", + Portal: frontendIP + ":3260", }, }, ISCSITargets: map[string]config.ISCSITarget{ diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go index 924e84b0..4f9d7d88 100644 --- a/frontend/rest/frontend.go +++ b/frontend/rest/frontend.go @@ -26,7 +26,7 @@ func New() types.Frontend { return &Device{} } -func (d *Device) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (d *Device) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { d.Name = name d.backend = rw d.Size = size diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index d5a24878..d92af61a 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -35,7 +35,7 @@ type Tcmu struct { isUp bool } -func (t *Tcmu) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *Tcmu) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { t.volume = name t.Shutdown() diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 9ada5bc3..f1e9026f 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -34,7 +34,7 @@ type Tgt struct { scsiDevice *ScsiDevice } -func (t *Tgt) Startup(name string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *Tgt) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { t.Volume = name t.Size = size t.SectorSize = int(sectorSize) diff --git a/types/types.go b/types/types.go index 8c80f552..458bbb9e 100644 --- a/types/types.go +++ b/types/types.go @@ -65,7 +65,7 @@ type Replica struct { } type Frontend interface { - Startup(name string, size, sectorSize int64, rw ReaderWriterAt) error + Startup(name string, frontendIP string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error State() State } From f4e01b6f9fc6f9cbc1cff67b4e2cf523172f64dd Mon Sep 17 00:00:00 2001 From: payes Date: Tue, 13 Dec 2016 10:06:11 +0000 Subject: [PATCH 323/357] Listening on *:9501 instead of localhost:9501 --- app/controller.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controller.go b/app/controller.go index ee72d69d..62e943ba 100644 --- a/app/controller.go +++ b/app/controller.go @@ -66,7 +66,6 @@ func startController(c *cli.Context) error { return errors.New("invalid target name") } - listen := c.String("listen") backends := c.StringSlice("enable-backend") replicas := c.StringSlice("replica") frontendName := c.String("frontend") @@ -111,11 +110,11 @@ func startController(c *cli.Context) error { } } - logrus.Infof("Listening on %s", listen) + logrus.Infof("Listening on %s", "*:9501") addShutdown(func() { control.Shutdown() }) - return http.ListenAndServe(listen, router) + return http.ListenAndServe(":9501", router) } From fe63927c6b0b7c9c9a2058710e8f00ef4014c242 Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Wed, 14 Dec 2016 10:07:11 +0530 Subject: [PATCH 324/357] Setup gitter and email notifications --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7faddbb9..4b8cbaf0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,3 +17,10 @@ before_install: - cd $HOME/gopath/src/github.com/openebs && git clone https://github.com/openebs/jiva.git script: - cd $HOME/gopath/src/github.com/openebs/jiva && make build +notifications: + email: + recipients: + - kiran.mova@cloudbyte.com + webhooks: + urls: + - https://webhooks.gitter.im/e/d885a0beef16020c3878 From 96738adf22a243f31efbead76e590ef8edcd05ae Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Wed, 14 Dec 2016 11:03:31 +0530 Subject: [PATCH 325/357] Change to travis ci --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d234be5..6d931fc5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -Longhorn [![Build Status](https://drone.rancher.io/api/badges/rancher/longhorn/status.svg)](https://drone.rancher.io/rancher/longhorn) -======== +longhorn + +[![Build Status](https://travis-ci.org/openebs/longhorn.svg?branch=master)](https://travis-ci.org/openebs/longhorn) A micro-service block storage solution. From f2e858811a37f2daa62e52333311d12ba9ec0c23 Mon Sep 17 00:00:00 2001 From: ajkumar Date: Wed, 28 Dec 2016 12:11:29 +0530 Subject: [PATCH 326/357] listen on the frontendIP only --- app/controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controller.go b/app/controller.go index 62e943ba..93e9f916 100644 --- a/app/controller.go +++ b/app/controller.go @@ -110,11 +110,11 @@ func startController(c *cli.Context) error { } } - logrus.Infof("Listening on %s", "*:9501") + logrus.Infof("Listening on %s:%s", frontendIP, "9501") addShutdown(func() { control.Shutdown() }) - return http.ListenAndServe(":9501", router) + return http.ListenAndServe(frontendIP+":9501", router) } From cff0b875af1eb9966f990614eb6e507556cc73d8 Mon Sep 17 00:00:00 2001 From: ajkumar Date: Wed, 28 Dec 2016 17:15:00 +0530 Subject: [PATCH 327/357] instead of using frontendIP we will use the --listen option format is: --listen ip:port --- app/controller.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controller.go b/app/controller.go index 93e9f916..27220720 100644 --- a/app/controller.go +++ b/app/controller.go @@ -29,7 +29,7 @@ func ControllerCmd() cli.Command { Flags: []cli.Flag{ cli.StringFlag{ Name: "listen", - Value: "localhost:9501", + Value: ":9501", }, cli.StringFlag{ Name: "frontend", @@ -57,6 +57,7 @@ func ControllerCmd() cli.Command { func startController(c *cli.Context) error { var frontendIP string + var controlListener string if c.NArg() == 0 { return errors.New("volume name is required") } @@ -72,6 +73,7 @@ func startController(c *cli.Context) error { if frontendName == "gotgt" { frontendIP = c.String("frontendIP") } + controlListener = c.String("listen") factories := map[string]types.BackendFactory{} for _, backend := range backends { switch backend { @@ -110,11 +112,11 @@ func startController(c *cli.Context) error { } } - logrus.Infof("Listening on %s:%s", frontendIP, "9501") + logrus.Infof("Listening on %s", controlListener) addShutdown(func() { control.Shutdown() }) - return http.ListenAndServe(frontendIP+":9501", router) + return http.ListenAndServe(controlListener, router) } From f99f56969f00561368ad2594c79a76651006de3d Mon Sep 17 00:00:00 2001 From: payes Date: Thu, 23 Feb 2017 14:05:33 +0530 Subject: [PATCH 328/357] Resolving compilation issues --- app/controller_gotgt.go | 2 +- frontend/gotgt/frontend.go | 2 +- vendor.conf | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controller_gotgt.go b/app/controller_gotgt.go index 0558a96f..febdb0d3 100644 --- a/app/controller_gotgt.go +++ b/app/controller_gotgt.go @@ -1,7 +1,7 @@ package app import ( - "github.com/openebs/longhorn/frontend/gotgt" + "github.com/rancher/longhorn/frontend/gotgt" ) func init() { diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index 91fb2aa9..a788a7fb 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -3,7 +3,7 @@ package gotgt import ( "github.com/Sirupsen/logrus" - "github.com/openebs/longhorn/types" + "github.com/rancher/longhorn/types" "github.com/openebs/gotgt/pkg/config" "github.com/openebs/gotgt/pkg/port" diff --git a/vendor.conf b/vendor.conf index 35fb68d4..c38939ae 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,3 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 +github.com/openebs/gotgt 811e4cb07af7180f3d920b903fc8658f9ba01b46 From 60a35d8ffb87c13b5a751ded15623938b68f44be Mon Sep 17 00:00:00 2001 From: payes Date: Thu, 23 Feb 2017 15:27:18 +0530 Subject: [PATCH 329/357] Automatic Registration of replica at controller when replica starts --- app/add_replica.go | 13 +++++++++++++ app/replica.go | 12 ++++++++++++ app/rm_replica.go | 8 ++++++++ 3 files changed, 33 insertions(+) diff --git a/app/add_replica.go b/app/add_replica.go index e1067d04..c6f7bc3c 100644 --- a/app/add_replica.go +++ b/app/add_replica.go @@ -2,6 +2,7 @@ package app import ( "errors" + "time" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" @@ -30,3 +31,15 @@ func addReplica(c *cli.Context) error { task := sync.NewTask(url) return task.AddReplica(replica) } +func AutoAddReplica(frontendIP string, replica string) error { + url := "http://" + frontendIP + ":9501" + task := sync.NewTask(url) + for { + err := task.AddReplica(replica) + if err != nil { + time.Sleep(2 * time.Second) + continue + } + return err + } +} diff --git a/app/replica.go b/app/replica.go index 878e50ee..6d65658e 100644 --- a/app/replica.go +++ b/app/replica.go @@ -26,6 +26,10 @@ func ReplicaCmd() cli.Command { Name: "listen", Value: "localhost:9502", }, + cli.StringFlag{ + Name: "frontendIP", + Value: "", + }, cli.StringFlag{ Name: "backing-file", Usage: "qcow file to use as the base image of this disk", @@ -45,6 +49,10 @@ func ReplicaCmd() cli.Command { }, } } +func AutoConfigureReplica(frontendIP string, address string) { + AutoRmReplica(frontendIP, address) + AutoAddReplica(frontendIP, address) +} func startReplica(c *cli.Context) error { if c.NArg() != 1 { @@ -60,6 +68,7 @@ func startReplica(c *cli.Context) error { s := replica.NewServer(dir, backingFile, 512) address := c.String("listen") + frontendIP := c.String("frontendIP") size := c.String("size") if size != "" { size, err := units.RAMInBytes(size) @@ -118,6 +127,9 @@ func startReplica(c *cli.Context) error { resp <- cmd.Run() }() } + if frontendIP != "" { + go AutoConfigureReplica(frontendIP, "tcp://"+address) + } return <-resp } diff --git a/app/rm_replica.go b/app/rm_replica.go index 027e3bda..ba051f90 100644 --- a/app/rm_replica.go +++ b/app/rm_replica.go @@ -5,6 +5,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/rancher/longhorn/controller/client" ) func RmReplicaCmd() cli.Command { @@ -29,3 +30,10 @@ func rmReplica(c *cli.Context) error { _, err := controllerClient.DeleteReplica(replica) return err } + +func AutoRmReplica(frontendIP string, replica string) error { + url := "http://" + frontendIP + ":9501" + controllerClient := client.NewControllerClient(url) + _, err := controllerClient.DeleteReplica(replica) + return err +} From 397ade9434d4a94af60bac7a955b6763ec7dde2d Mon Sep 17 00:00:00 2001 From: ajkumar Date: Tue, 21 Feb 2017 09:21:16 +0530 Subject: [PATCH 330/357] publish profiler paths in the http listeners --- app/controller.go | 1 - controller/rest/router.go | 5 +++++ replica/rest/router.go | 2 ++ sync/agent/router.go | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controller.go b/app/controller.go index 27220720..3e84a35e 100644 --- a/app/controller.go +++ b/app/controller.go @@ -117,6 +117,5 @@ func startController(c *cli.Context) error { addShutdown(func() { control.Shutdown() }) - return http.ListenAndServe(controlListener, router) } diff --git a/controller/rest/router.go b/controller/rest/router.go index 2b772e07..9e62961b 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -1,6 +1,9 @@ package rest import ( + "net/http" + _ "net/http/pprof" /* for profiling */ + "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/longhorn/replica/rest" @@ -37,5 +40,7 @@ func NewRouter(s *Server) *mux.Router { // Journal router.Methods("POST").Path("/v1/journal").Handler(f(schemas, s.ListJournal)) + router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux) + return router } diff --git a/replica/rest/router.go b/replica/rest/router.go index 5098a54d..50c4dd69 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -2,6 +2,7 @@ package rest import ( "net/http" + _ "net/http/pprof" /* for profiling */ "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" @@ -66,6 +67,7 @@ func NewRouter(s *Server) *mux.Router { for name, action := range actions { router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", name).Handler(f(schemas, checkAction(s, action))) } + router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux) return router } diff --git a/sync/agent/router.go b/sync/agent/router.go index f8b80cb4..81dead3f 100644 --- a/sync/agent/router.go +++ b/sync/agent/router.go @@ -2,6 +2,7 @@ package agent import ( "net/http" + _ "net/http/pprof" /* for profiling */ "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" @@ -33,5 +34,6 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/processes/{id}").Handler(f(schemas, s.GetProcess)) router.Methods("POST").Path("/v1/processes").Handler(f(schemas, s.CreateProcess)) + router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux) return router } From 139ed5638b82bc1ae4868f7b0cf03ec72de5ec1c Mon Sep 17 00:00:00 2001 From: ajkumar Date: Mon, 13 Mar 2017 15:02:16 +0530 Subject: [PATCH 331/357] use the latest gotgt with sync.Pool for writes --- vendor.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor.conf b/vendor.conf index c38939ae..8af24bd6 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt 811e4cb07af7180f3d920b903fc8658f9ba01b46 +github.com/openebs/gotgt 94366023c985593a771f1e51b64888b2ced15825 From f203b39316e25ca89414909cdc51f229371a9565 Mon Sep 17 00:00:00 2001 From: Payes Date: Fri, 17 Mar 2017 15:54:44 +0530 Subject: [PATCH 332/357] Check replica status at controller before rerigtration --- app/replica.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/replica.go b/app/replica.go index 6d65658e..3c79cb05 100644 --- a/app/replica.go +++ b/app/replica.go @@ -2,15 +2,18 @@ package app import ( "errors" + "fmt" "net/http" "os" "os/exec" "path/filepath" "syscall" + "time" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/docker/go-units" + "github.com/rancher/longhorn/controller/client" "github.com/rancher/longhorn/replica" "github.com/rancher/longhorn/replica/rest" "github.com/rancher/longhorn/replica/rpc" @@ -49,7 +52,32 @@ func ReplicaCmd() cli.Command { }, } } + +func CheckReplicaState(frontendIP string, replicaIP string) (string, error) { + url := "http://" + frontendIP + ":9501" + ControllerClient := client.NewControllerClient(url) + reps, err := ControllerClient.ListReplicas() + if err != nil { + return "", err + } + + for _, rep := range reps { + if rep.Address == replicaIP { + return rep.Mode, nil + } + } + return "", err +} + func AutoConfigureReplica(frontendIP string, address string) { +checkagain: + state, err := CheckReplicaState(frontendIP, address) + if err == nil && (state == "" || state == "ERR") { + fmt.Println("Removing Replica") + } else { + time.Sleep(5 * time.Second) + goto checkagain + } AutoRmReplica(frontendIP, address) AutoAddReplica(frontendIP, address) } From 10aae050bf206757d3b7cf7facb09f2edb67f045 Mon Sep 17 00:00:00 2001 From: Payes Date: Fri, 17 Mar 2017 16:20:06 +0530 Subject: [PATCH 333/357] Closing the frontend to remove the last replica if replica is in error state --- controller/control.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controller/control.go b/controller/control.go index e4ebd2ff..a468d339 100644 --- a/controller/control.go +++ b/controller/control.go @@ -149,7 +149,13 @@ func (c *Controller) RemoveReplica(address string) error { for i, r := range c.replicas { if r.Address == address { if len(c.replicas) == 1 && c.frontend.State() == types.StateUp { - return fmt.Errorf("Cannot remove last replica if volume is up") + if r.Mode == "ERR" { + if c.frontend != nil { + c.frontend.Shutdown() + } + } else { + return fmt.Errorf("Cannot remove last replica if volume is up") + } } c.replicas = append(c.replicas[:i], c.replicas[i+1:]...) c.backend.RemoveBackend(r.Address) From fa2d3121bef9c73ac73ccd64ff716f4161fff2ae Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Fri, 17 Mar 2017 16:33:36 +0530 Subject: [PATCH 334/357] include iscsiadm package for running CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4b8cbaf0..3072c63a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ env: before_install: - sleep 15 - sudo apt-get install -y - - sudo apt-get install -y curl + - sudo apt-get install -y curl open-iscsi - mkdir -p $HOME/gopath/bin - mkdir -p $HOME/gopath/src/github/openebs - cd $HOME/gopath/src/github.com/openebs && git clone https://github.com/openebs/jiva.git From afd71f5530139ba31d86d1c2198b70213f400bad Mon Sep 17 00:00:00 2001 From: Payes Date: Sat, 18 Mar 2017 03:29:12 +0530 Subject: [PATCH 335/357] Auto ReRegistration of replica at controller in case of controller going down or network failures --- app/replica.go | 9 +++++++-- replica/rpc/server.go | 14 ++++++++++++++ replica/server.go | 1 + rpc/server.go | 15 ++++++++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/replica.go b/app/replica.go index 3c79cb05..a41d166b 100644 --- a/app/replica.go +++ b/app/replica.go @@ -69,7 +69,7 @@ func CheckReplicaState(frontendIP string, replicaIP string) (string, error) { return "", err } -func AutoConfigureReplica(frontendIP string, address string) { +func AutoConfigureReplica(s *replica.Server, frontendIP string, address string) { checkagain: state, err := CheckReplicaState(frontendIP, address) if err == nil && (state == "" || state == "ERR") { @@ -78,8 +78,13 @@ checkagain: time.Sleep(5 * time.Second) goto checkagain } + s.Close() AutoRmReplica(frontendIP, address) AutoAddReplica(frontendIP, address) + select { + case <-s.MonitorChannel: + goto checkagain + } } func startReplica(c *cli.Context) error { @@ -156,7 +161,7 @@ func startReplica(c *cli.Context) error { }() } if frontendIP != "" { - go AutoConfigureReplica(frontendIP, "tcp://"+address) + go AutoConfigureReplica(s, frontendIP, "tcp://"+address) } return <-resp diff --git a/replica/rpc/server.go b/replica/rpc/server.go index 9d60d4e7..6e3f9b70 100644 --- a/replica/rpc/server.go +++ b/replica/rpc/server.go @@ -2,6 +2,7 @@ package rpc import ( "net" + "time" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/replica" @@ -38,10 +39,23 @@ func (s *Server) ListenAndServe() error { continue } + err = conn.SetKeepAlive(true) + if err != nil { + logrus.Errorf("failed to accept connection %v", err) + continue + } + + err = conn.SetKeepAlivePeriod(10 * time.Second) + if err != nil { + logrus.Errorf("failed to accept connection %v", err) + continue + } + logrus.Infof("New connection from: %v", conn.RemoteAddr()) go func(conn net.Conn) { server := rpc.NewServer(conn, s.s) + s.s.MonitorChannel = server.CreateMonitorChannel() server.Handle() }(conn) } diff --git a/replica/server.go b/replica/server.go index 481d158d..dbbda9be 100644 --- a/replica/server.go +++ b/replica/server.go @@ -25,6 +25,7 @@ type Server struct { dir string defaultSectorSize int64 backing *BackingFile + MonitorChannel chan struct{} } func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { diff --git a/rpc/server.go b/rpc/server.go index c165669d..5ccb6625 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -24,12 +24,25 @@ func NewServer(conn net.Conn, data types.DataProcessor) *Server { } } +var monitorChan chan struct{} + +func (s *Server) CreateMonitorChannel() chan struct{} { + monitorChan = make(chan struct{}, 5) + return monitorChan +} + +func (s *Server) GetMonitorChannel() chan struct{} { + return monitorChan +} + func (s *Server) Handle() error { go s.write() defer func() { s.done <- struct{}{} }() - return s.read() + err := s.read() + monitorChan <- struct{}{} + return err } func (s *Server) readFromWire(ret chan<- error) { From ac123b4a03776650d03500d0be874e4cfa9bfb73 Mon Sep 17 00:00:00 2001 From: Payes Date: Fri, 24 Mar 2017 21:57:46 +0530 Subject: [PATCH 336/357] Removing replica from controller when the replica goes into error state --- controller/control.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/controller/control.go b/controller/control.go index a468d339..cf2483bf 100644 --- a/controller/control.go +++ b/controller/control.go @@ -298,7 +298,15 @@ func (c *Controller) WriteAt(b []byte, off int64) (int, error) { n, err := c.backend.WriteAt(b, off) c.RUnlock() if err != nil { - return n, c.handleError(err) + errh := c.handleError(err) + if bErr, ok := err.(*BackendError); ok { + if len(bErr.Errors) > 0 { + for address := range bErr.Errors { + c.RemoveReplica(address) + } + } + } + return n, errh } return n, err } @@ -313,7 +321,15 @@ func (c *Controller) ReadAt(b []byte, off int64) (int, error) { n, err := c.backend.ReadAt(b, off) c.RUnlock() if err != nil { - return n, c.handleError(err) + errh := c.handleError(err) + if bErr, ok := err.(*BackendError); ok { + if len(bErr.Errors) > 0 { + for address := range bErr.Errors { + c.RemoveReplica(address) + } + } + } + return n, errh } return n, err } @@ -411,4 +427,5 @@ func (c *Controller) monitoring(address string, backend types.Backend) { c.SetReplicaMode(address, types.ERR) } logrus.Infof("Monitoring stopped %v", address) + c.RemoveReplica(address) } From 94c7c38959b3e1172e01f6935d5be0c2164d5940 Mon Sep 17 00:00:00 2001 From: Payes Date: Sun, 26 Mar 2017 21:37:01 +0530 Subject: [PATCH 337/357] Resiliency against component failures --- app/replica.go | 3 +- backend/dynamic/dynamic.go | 7 ++ backend/file/file.go | 8 ++ backend/remote/remote.go | 20 ++++ controller/client/controller_client.go | 10 ++ controller/control.go | 69 +++++++++++--- controller/rebuild.go | 5 + controller/replicator.go | 15 +++ controller/rest/model.go | 7 ++ controller/rest/replica.go | 15 +++ controller/rest/router.go | 1 + replica/peer_counter.go | 124 +++++++++++++++++++++++++ replica/replica.go | 25 +++++ replica/rest/model.go | 19 ++++ replica/rest/replica.go | 18 ++++ replica/rest/router.go | 2 + replica/server.go | 24 +++++ sync/sync.go | 27 ++++-- types/types.go | 8 ++ 19 files changed, 384 insertions(+), 23 deletions(-) create mode 100644 replica/peer_counter.go diff --git a/app/replica.go b/app/replica.go index a41d166b..f37dd420 100644 --- a/app/replica.go +++ b/app/replica.go @@ -2,7 +2,6 @@ package app import ( "errors" - "fmt" "net/http" "os" "os/exec" @@ -73,7 +72,7 @@ func AutoConfigureReplica(s *replica.Server, frontendIP string, address string) checkagain: state, err := CheckReplicaState(frontendIP, address) if err == nil && (state == "" || state == "ERR") { - fmt.Println("Removing Replica") + logrus.Infof("Removing Replica") } else { time.Sleep(5 * time.Second) goto checkagain diff --git a/backend/dynamic/dynamic.go b/backend/dynamic/dynamic.go index 310a4426..9888e15a 100644 --- a/backend/dynamic/dynamic.go +++ b/backend/dynamic/dynamic.go @@ -28,3 +28,10 @@ func (d *Factory) Create(address string) (types.Backend, error) { return nil, fmt.Errorf("Failed to find factory for %s", address) } + +func (d *Factory) SignalToAdd(address string, action string) error { + if factory, ok := d.factories["tcp"]; ok { + return factory.SignalToAdd(address, action) + } + return nil +} diff --git a/backend/file/file.go b/backend/file/file.go index 7e97c41b..5446fa9f 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -51,6 +51,10 @@ func (f *Wrapper) SetRevisionCounter(counter int64) error { return nil } +func (f *Wrapper) SetReplicaCounter(counter int64) error { + return nil +} + func (ff *Factory) Create(address string) (types.Backend, error) { logrus.Infof("Creating file: %s", address) file, err := os.OpenFile(address, os.O_RDWR|os.O_CREATE, 0600) @@ -62,6 +66,10 @@ func (ff *Factory) Create(address string) (types.Backend, error) { return &Wrapper{file}, nil } +func (ff *Factory) SignalToAdd(address string, action string) error { + return nil +} + func (f *Wrapper) GetMonitorChannel() types.MonitorChannel { return nil } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 3b749e22..d519bcae 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -137,6 +137,11 @@ func (r *Remote) SetRevisionCounter(counter int64) error { return r.doAction("setrevisioncounter", &map[string]int64{"counter": counter}) } +func (r *Remote) SetReplicaCounter(counter int64) error { + logrus.Infof("Set replica counter of %s to : %v", r.name, counter) + return r.doAction("setreplicacounter", &map[string]int64{"counter": counter}) +} + func (r *Remote) info() (rest.Replica, error) { var replica rest.Replica req, err := http.NewRequest("GET", r.replicaURL, nil) @@ -205,6 +210,21 @@ func (rf *Factory) Create(address string) (types.Backend, error) { return r, nil } +func (rf *Factory) SignalToAdd(address string, action string) error { + controlAddress, _, _, err := util.ParseAddresses(address + ":9502") + if err != nil { + return err + } + r := &Remote{ + name: address, + replicaURL: fmt.Sprintf("http://%s/v1/replicas/1", controlAddress), + httpClient: &http.Client{ + Timeout: timeout, + }, + } + return r.doAction("start", &map[string]string{"Action": action}) +} + func (r *Remote) monitorPing(client *rpc.Client) { ticker := time.NewTicker(pingInveral) defer ticker.Stop() diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 4f56a229..117d27a4 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -11,6 +11,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/controller/rest" + "github.com/rancher/longhorn/types" ) type ControllerClient struct { @@ -177,6 +178,15 @@ func (c *ControllerClient) GetVolume() (*rest.Volume, error) { return &volumes.Data[0], nil } +func (c *ControllerClient) Register(address string, revisionCount int64, replicaCount int64) error { + err := c.post("/register", &types.RegReplica{ + Address: address, + RevCount: revisionCount, + RepCount: replicaCount, + }, nil) + return err +} + func (c *ControllerClient) post(path string, req, resp interface{}) error { return c.do("POST", path, req, resp) } diff --git a/controller/control.go b/controller/control.go index cf2483bf..c4005102 100644 --- a/controller/control.go +++ b/controller/control.go @@ -2,6 +2,7 @@ package controller import ( "fmt" + "strings" "sync" "github.com/Sirupsen/logrus" @@ -11,22 +12,25 @@ import ( type Controller struct { sync.RWMutex - Name string - frontendIP string - size int64 - sectorSize int64 - replicas []types.Replica - factory types.BackendFactory - backend *replicator - frontend types.Frontend + Name string + frontendIP string + size int64 + sectorSize int64 + replicas []types.Replica + factory types.BackendFactory + backend *replicator + frontend types.Frontend + RegisteredReplicas map[string]types.RegReplica + MaxRevReplica string } func NewController(name string, frontendIP string, factory types.BackendFactory, frontend types.Frontend) *Controller { c := &Controller{ - factory: factory, - Name: name, - frontend: frontend, - frontendIP: frontendIP, + factory: factory, + Name: name, + frontend: frontend, + frontendIP: frontendIP, + RegisteredReplicas: map[string]types.RegReplica{}, } c.reset() return c @@ -36,6 +40,10 @@ func (c *Controller) AddReplica(address string) error { return c.addReplica(address, true) } +func (c *Controller) RegisterReplica(register types.RegReplica) error { + return c.registerReplica(register) +} + func (c *Controller) hasWOReplica() bool { for _, i := range c.replicas { if i.Mode == types.WO { @@ -74,6 +82,30 @@ func (c *Controller) addReplica(address string, snapshot bool) error { return c.addReplicaNoLock(newBackend, address, snapshot) } +func (c *Controller) signalToAdd() { + c.factory.SignalToAdd(c.MaxRevReplica, "start") +} + +func (c *Controller) registerReplica(register types.RegReplica) error { + c.Lock() + defer c.Unlock() + + c.RegisteredReplicas[register.Address] = register + if c.MaxRevReplica == "" { + c.MaxRevReplica = register.Address + } + if c.RegisteredReplicas[c.MaxRevReplica].RevCount < register.RevCount { + c.MaxRevReplica = register.Address + } + if c.RegisteredReplicas[c.MaxRevReplica].RepCount == int64(len(c.RegisteredReplicas)) { + c.signalToAdd() + } + if c.RegisteredReplicas[c.MaxRevReplica].RepCount == 0 { + c.signalToAdd() + } + return nil +} + func (c *Controller) Snapshot(name string) (string, error) { c.Lock() defer c.Unlock() @@ -215,6 +247,7 @@ func (c *Controller) startFrontend() error { func (c *Controller) Start(addresses ...string) error { var expectedRevision int64 + var sendSignal int c.Lock() defer c.Unlock() @@ -284,6 +317,18 @@ func (c *Controller) Start(addresses ...string) error { c.setReplicaModeNoLock(address, types.ERR) } } + for regrep := range c.RegisteredReplicas { + sendSignal = 1 + for _, tmprep := range c.replicas { + if strings.Contains(tmprep.Address, regrep) { + sendSignal = 0 + break + } + } + if sendSignal == 1 { + c.factory.SignalToAdd(regrep, "add") + } + } return nil } diff --git a/controller/rebuild.go b/controller/rebuild.go index 1b55a917..bccb75c9 100644 --- a/controller/rebuild.go +++ b/controller/rebuild.go @@ -91,6 +91,11 @@ func (c *Controller) VerifyRebuildReplica(address string) error { if err := c.backend.SetRevisionCounter(address, counter); err != nil { return fmt.Errorf("Fail to set revision counter for %v: %v", address, err) } + for _, temprep := range c.replicas { + if err := c.backend.SetReplicaCounter(temprep.Address, int64(len(c.replicas))); err != nil { + return fmt.Errorf("Fail to set replica counter for %v: %v", address, err) + } + } logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) c.setReplicaModeNoLock(address, types.RW) diff --git a/controller/replicator.go b/controller/replicator.go index 1520d450..2c1b58af 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -292,3 +292,18 @@ func (r *replicator) GetRevisionCounter(address string) (int64, error) { return counter, nil } + +func (r *replicator) SetReplicaCounter(address string, counter int64) error { + backend, ok := r.backends[address] + if !ok { + return fmt.Errorf("Cannot find backend %v", address) + } + + if err := backend.backend.SetReplicaCounter(counter); err != nil { + return err + } + + logrus.Infof("Set backend %s replica counter to %v", address, counter) + + return nil +} diff --git a/controller/rest/model.go b/controller/rest/model.go index 05ef98bc..e5e0a390 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -65,6 +65,13 @@ type PrepareRebuildOutput struct { Disks []string `json:"disks"` } +type RegReplica struct { + client.Resource + Address string `json:"Address"` + RevCount int64 `json:"RevCount"` + RepCount int64 `json:"RepCount"` +} + func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { v := &Volume{ Resource: client.Resource{ diff --git a/controller/rest/replica.go b/controller/rest/replica.go index 28b96a6e..59df891e 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -38,6 +38,21 @@ func (s *Server) GetReplica(rw http.ResponseWriter, req *http.Request) error { return nil } +func (s *Server) RegisterReplica(rw http.ResponseWriter, req *http.Request) error { + var regReplica RegReplica + apiContext := api.GetApiContext(req) + if err := apiContext.Read(®Replica); err != nil { + return err + } + + local := types.RegReplica{Address: regReplica.Address, RevCount: regReplica.RevCount, RepCount: regReplica.RepCount} + if err := s.c.RegisterReplica(local); err != nil { + return err + } + + return nil +} + func (s *Server) CreateReplica(rw http.ResponseWriter, req *http.Request) error { var replica Replica apiContext := api.GetApiContext(req) diff --git a/controller/rest/router.go b/controller/rest/router.go index 9e62961b..1268ba49 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -31,6 +31,7 @@ func NewRouter(s *Server) *mux.Router { // Replicas router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) + router.Methods("POST").Path("/v1/register").Handler(f(schemas, s.RegisterReplica)) router.Methods("POST").Path("/v1/replicas").Handler(f(schemas, s.CreateReplica)) router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "preparerebuild").Handler(f(schemas, s.PrepareRebuildReplica)) router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "verifyrebuild").Handler(f(schemas, s.VerifyRebuildReplica)) diff --git a/replica/peer_counter.go b/replica/peer_counter.go new file mode 100644 index 00000000..259c2169 --- /dev/null +++ b/replica/peer_counter.go @@ -0,0 +1,124 @@ +package replica + +import ( + "fmt" + "io" + "os" + "strconv" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/rancher/sparse-tools/sparse" +) + +const ( + peerCounterFile = "peer.counter" + peerFileMode os.FileMode = 0600 + peerBlockSize = 4096 +) + +func (r *Replica) readPeerCounter() (int64, error) { + if r.peerFile == nil { + return 0, fmt.Errorf("BUG: peer file wasn't initialized") + } + + buf := make([]byte, peerBlockSize) + _, err := r.peerFile.ReadAt(buf, 0) + if err != nil && err != io.EOF { + return 0, fmt.Errorf("fail to read from peer counter file: %v", err) + } + counter, err := strconv.ParseInt(strings.Trim(string(buf), "\x00"), 10, 64) + if err != nil { + return 0, fmt.Errorf("fail to parse peer counter file: %v", err) + } + return counter, nil +} + +func (r *Replica) writePeerCounter(counter int64) error { + if r.peerFile == nil { + return fmt.Errorf("BUG: peer file wasn't initialized") + } + + buf := make([]byte, peerBlockSize) + copy(buf, []byte(strconv.FormatInt(counter, 10))) + _, err := r.peerFile.WriteAt(buf, 0) + if err != nil { + return fmt.Errorf("fail to write to peer counter file: %v", err) + } + return nil +} + +func (r *Replica) openPeerFile(isCreate bool) error { + var err error + r.peerFile, err = sparse.NewDirectFileIoProcessor(r.diskPath(peerCounterFile), os.O_RDWR, peerFileMode, isCreate) + return err +} + +func (r *Replica) initPeerCounter() error { + r.peerLock.Lock() + defer r.peerLock.Unlock() + + if _, err := os.Stat(r.diskPath(peerCounterFile)); err != nil { + if !os.IsNotExist(err) { + return err + } + // file doesn't exist yet + if err := r.openPeerFile(true); err != nil { + return err + } + if err := r.writePeerCounter(0); err != nil { + return err + } + } else if err := r.openPeerFile(false); err != nil { + return err + } + + counter, err := r.readPeerCounter() + if err != nil { + return err + } + // Don't use r.peerCache directly + // r.peerCache is an internal cache, to avoid read from disk + // everytime when counter needs to be updated. + // And it's protected by peerLock + r.peerCache = counter + return nil +} + +func (r *Replica) GetPeerCounter() int64 { + r.peerLock.Lock() + defer r.peerLock.Unlock() + + counter, err := r.readPeerCounter() + if err != nil { + logrus.Error("Fail to get peer counter: ", err) + // -1 will result in the replica to be discarded + return -1 + } + r.peerCache = counter + return counter +} + +func (r *Replica) SetPeerCounter(counter int64) error { + r.peerLock.Lock() + defer r.peerLock.Unlock() + + if err := r.writePeerCounter(counter); err != nil { + return err + } + + r.peerCache = counter + return nil +} + +func (r *Replica) increasePeerCounter() error { + r.peerLock.Lock() + defer r.peerLock.Unlock() + + if err := r.writePeerCounter(r.peerCache + 1); err != nil { + return err + } + + r.peerCache++ + return nil +} diff --git a/replica/replica.go b/replica/replica.go index 3cd9c87d..0203bd93 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -49,6 +49,10 @@ type Replica struct { revisionLock sync.Mutex revisionCache int64 revisionFile *sparse.DirectFileIoProcessor + + peerLock sync.Mutex + peerCache int64 + peerFile *sparse.DirectFileIoProcessor } type Info struct { @@ -99,6 +103,23 @@ const ( OpReplace = "replace" ) +func CreateTempReplica() (*Replica, error) { + if err := os.Mkdir(Dir, 0700); err != nil && !os.IsExist(err) { + return nil, err + } + + r := &Replica{ + dir: Dir, + } + if err := r.initRevisionCounter(); err != nil { + return nil, err + } + if err := r.initPeerCounter(); err != nil { + return nil, err + } + return r, nil +} + func ReadInfo(dir string) (Info, error) { var info Info err := (&Replica{dir: dir}).unmarshalFile(volumeMetaData, &info) @@ -147,6 +168,10 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF return nil, err } + if err := r.initPeerCounter(); err != nil { + return nil, err + } + // Reference r.info.Size because it may have changed from reading // metadata locationSize := r.info.Size / r.volume.sectorSize diff --git a/replica/rest/model.go b/replica/rest/model.go index a9a6f37f..18ee7475 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -72,6 +72,16 @@ type RevisionCounter struct { Counter int64 `json:"counter"` } +type ReplicaCounter struct { + client.Resource + Counter int64 `json:"counter"` +} + +type Action struct { + client.Resource + Value string `json:"Action"` +} + func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, rep *replica.Replica) *Replica { r := &Replica{ Resource: client.Resource{ @@ -87,8 +97,10 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, switch state { case replica.Initial: + actions["start"] = true actions["create"] = true case replica.Open: + actions["start"] = true actions["close"] = true actions["setrebuilding"] = true actions["snapshot"] = true @@ -98,13 +110,17 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["revert"] = true actions["prepareremovedisk"] = true actions["setrevisioncounter"] = true + actions["setreplicacounter"] = true case replica.Closed: + actions["start"] = true actions["open"] = true actions["removedisk"] = true actions["replacedisk"] = true actions["revert"] = true actions["prepareremovedisk"] = true + actions["setreplicacounter"] = true case replica.Dirty: + actions["start"] = true actions["setrebuilding"] = true actions["close"] = true actions["snapshot"] = true @@ -113,12 +129,15 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["replacedisk"] = true actions["revert"] = true actions["prepareremovedisk"] = true + actions["setreplicacounter"] = true case replica.Rebuilding: + actions["start"] = true actions["snapshot"] = true actions["setrebuilding"] = true actions["close"] = true actions["reload"] = true actions["setrevisioncounter"] = true + actions["setreplicacounter"] = true case replica.Error: } diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 73cdc0c7..4eeb0d8b 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -167,6 +167,15 @@ func (s *Server) DeleteReplica(rw http.ResponseWriter, req *http.Request) error return s.doOp(req, s.s.Delete()) } +func (s *Server) StartReplica(rw http.ResponseWriter, req *http.Request) error { + var action Action + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&action); err != nil && err != io.EOF { + return err + } + return s.doOp(req, s.s.Start(action.Value)) +} + func (s *Server) SetRevisionCounter(rw http.ResponseWriter, req *http.Request) error { var input RevisionCounter apiContext := api.GetApiContext(req) @@ -175,3 +184,12 @@ func (s *Server) SetRevisionCounter(rw http.ResponseWriter, req *http.Request) e } return s.doOp(req, s.s.SetRevisionCounter(input.Counter)) } + +func (s *Server) SetReplicaCounter(rw http.ResponseWriter, req *http.Request) error { + var input ReplicaCounter + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil && err != io.EOF { + return err + } + return s.doOp(req, s.s.SetReplicaCounter(input.Counter)) +} diff --git a/replica/rest/router.go b/replica/rest/router.go index 50c4dd69..46d29ece 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -51,6 +51,7 @@ func NewRouter(s *Server) *mux.Router { // Actions actions := map[string]func(http.ResponseWriter, *http.Request) error{ + "start": s.StartReplica, "reload": s.ReloadReplica, "snapshot": s.SnapshotReplica, "open": s.OpenReplica, @@ -62,6 +63,7 @@ func NewRouter(s *Server) *mux.Router { "revert": s.RevertReplica, "prepareremovedisk": s.PrepareRemoveDisk, "setrevisioncounter": s.SetRevisionCounter, + "setreplicacounter": s.SetReplicaCounter, } for name, action := range actions { diff --git a/replica/server.go b/replica/server.go index dbbda9be..ab0c0ed3 100644 --- a/replica/server.go +++ b/replica/server.go @@ -19,6 +19,9 @@ const ( type State string +var ActionChannel chan string +var Dir string + type Server struct { sync.RWMutex r *Replica @@ -29,6 +32,8 @@ type Server struct { } func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { + ActionChannel = make(chan string, 5) + Dir = dir return &Server{ dir: dir, backing: backing, @@ -36,6 +41,14 @@ func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { } } +func (s *Server) Start(action string) error { + s.Lock() + defer s.Unlock() + ActionChannel <- action + + return nil +} + func (s *Server) getSectorSize() int64 { if s.backing != nil && s.backing.SectorSize > 0 { return s.backing.SectorSize @@ -86,6 +99,7 @@ func (s *Server) Open() error { logrus.Infof("Opening volume %s, size %d/%d", s.dir, size, sectorSize) r, err := New(size, sectorSize, s.dir, s.backing) if err != nil { + fmt.Println("ERROR OPENING VOLUME") return err } s.r = r @@ -285,6 +299,16 @@ func (s *Server) SetRevisionCounter(counter int64) error { return s.r.SetRevisionCounter(counter) } +func (s *Server) SetReplicaCounter(counter int64) error { + s.Lock() + defer s.Unlock() + + if s.r == nil { + return nil + } + return s.r.SetPeerCounter(counter) +} + func (s *Server) PingResponse() error { state, _ := s.Status() if state != Open && state != Dirty && state != Rebuilding { diff --git a/sync/sync.go b/sync/sync.go index 583d417c..23befe85 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -170,27 +170,36 @@ func find(list []string, item string) int { return -1 } -func (t *Task) AddReplica(replica string) error { +func (t *Task) AddReplica(replicaAddress string) error { + var action string volume, err := t.client.GetVolume() if err != nil { return err } + addr := strings.Split(replicaAddress, "://") + parts := strings.Split(addr[1], ":") + Replica, _ := replica.CreateTempReplica() if volume.ReplicaCount == 0 { - return t.client.Start(replica) + revisionCount := Replica.GetRevisionCounter() + replicaCount := Replica.GetPeerCounter() + t.client.Register(parts[0], revisionCount, replicaCount) + action = <-replica.ActionChannel } - - if err := t.checkAndResetFailedRebuild(replica); err != nil { + if action == "start" { + return t.client.Start(replicaAddress) + } + if err := t.checkAndResetFailedRebuild(replicaAddress); err != nil { return err } - logrus.Infof("Adding replica %s in WO mode", replica) - _, err = t.client.CreateReplica(replica) + logrus.Infof("Adding replica %s in WO mode", replicaAddress) + _, err = t.client.CreateReplica(replicaAddress) if err != nil { return err } - fromClient, toClient, err := t.getTransferClients(replica) + fromClient, toClient, err := t.getTransferClients(replicaAddress) if err != nil { return err } @@ -199,7 +208,7 @@ func (t *Task) AddReplica(replica string) error { return err } - output, err := t.client.PrepareRebuild(rest.EncodeID(replica)) + output, err := t.client.PrepareRebuild(rest.EncodeID(replicaAddress)) if err != nil { return err } @@ -208,7 +217,7 @@ func (t *Task) AddReplica(replica string) error { return err } - if err := t.reloadAndVerify(replica, toClient); err != nil { + if err := t.reloadAndVerify(replicaAddress, toClient); err != nil { return err } diff --git a/types/types.go b/types/types.go index 458bbb9e..69aff0c4 100644 --- a/types/types.go +++ b/types/types.go @@ -33,12 +33,14 @@ type Backend interface { RemainSnapshots() (int, error) GetRevisionCounter() (int64, error) SetRevisionCounter(counter int64) error + SetReplicaCounter(counter int64) error GetMonitorChannel() MonitorChannel StopMonitoring() } type BackendFactory interface { Create(address string) (Backend, error) + SignalToAdd(string, string) error } type Controller interface { @@ -64,6 +66,12 @@ type Replica struct { Mode Mode } +type RegReplica struct { + Address string + RevCount int64 + RepCount int64 +} + type Frontend interface { Startup(name string, frontendIP string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error From c07008d22ec75798b344ee3cb5da980b8dd3d585 Mon Sep 17 00:00:00 2001 From: Payes Date: Mon, 27 Mar 2017 15:59:49 +0530 Subject: [PATCH 338/357] Removing registration entries when the replica goes down --- controller/control.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controller/control.go b/controller/control.go index c4005102..8f87d12c 100644 --- a/controller/control.go +++ b/controller/control.go @@ -189,6 +189,11 @@ func (c *Controller) RemoveReplica(address string) error { return fmt.Errorf("Cannot remove last replica if volume is up") } } + for regrep := range c.RegisteredReplicas { + if strings.Contains(address, regrep) { + delete(c.RegisteredReplicas, regrep) + } + } c.replicas = append(c.replicas[:i], c.replicas[i+1:]...) c.backend.RemoveBackend(r.Address) } From 523953a3812e55c29be553868a91d171c5905c2d Mon Sep 17 00:00:00 2001 From: Payes Date: Fri, 31 Mar 2017 22:23:57 +0530 Subject: [PATCH 339/357] If atleast 2 replicas come up with the same revision count, frontend can be started --- controller/control.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/controller/control.go b/controller/control.go index 8f87d12c..6496fffb 100644 --- a/controller/control.go +++ b/controller/control.go @@ -87,22 +87,45 @@ func (c *Controller) signalToAdd() { } func (c *Controller) registerReplica(register types.RegReplica) error { + + var ( + revisionConflict int64 + revCount int64 + ) + c.Lock() defer c.Unlock() c.RegisteredReplicas[register.Address] = register + if c.MaxRevReplica == "" { c.MaxRevReplica = register.Address } + if c.RegisteredReplicas[c.MaxRevReplica].RevCount < register.RevCount { c.MaxRevReplica = register.Address } + if c.RegisteredReplicas[c.MaxRevReplica].RepCount == int64(len(c.RegisteredReplicas)) { c.signalToAdd() } if c.RegisteredReplicas[c.MaxRevReplica].RepCount == 0 { c.signalToAdd() } + if len(c.RegisteredReplicas) >= 2 { + for _, tmprep := range c.RegisteredReplicas { + if revCount == 0 { + revCount = tmprep.RevCount + } else { + if revCount != tmprep.RevCount { + revisionConflict = 1 + } + } + } + if revisionConflict == 0 { + c.signalToAdd() + } + } return nil } From b10277f44da470d4d3e882646ec83037734393a2 Mon Sep 17 00:00:00 2001 From: Payes Date: Sat, 1 Apr 2017 15:06:08 +0530 Subject: [PATCH 340/357] Handling error cases during HA --- controller/client/controller_client.go | 4 +++- controller/control.go | 33 +++++++++++++++++++++++--- controller/rest/model.go | 8 ++++--- controller/rest/replica.go | 2 +- replica/replica.go | 19 ++++++++------- replica/server.go | 3 +++ sync/sync.go | 13 ++++++++-- types/types.go | 6 ++++- 8 files changed, 69 insertions(+), 19 deletions(-) diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 117d27a4..f3cf4645 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "net/http" "strings" + "time" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/controller/rest" @@ -178,11 +179,12 @@ func (c *ControllerClient) GetVolume() (*rest.Volume, error) { return &volumes.Data[0], nil } -func (c *ControllerClient) Register(address string, revisionCount int64, replicaCount int64) error { +func (c *ControllerClient) Register(address string, revisionCount int64, replicaCount int64, upTime time.Duration) error { err := c.post("/register", &types.RegReplica{ Address: address, RevCount: revisionCount, RepCount: replicaCount, + UpTime: upTime, }, nil) return err } diff --git a/controller/control.go b/controller/control.go index 6496fffb..d13aa33c 100644 --- a/controller/control.go +++ b/controller/control.go @@ -2,12 +2,12 @@ package controller import ( "fmt" - "strings" - "sync" - "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" + "strings" + "sync" + "time" ) type Controller struct { @@ -22,6 +22,8 @@ type Controller struct { frontend types.Frontend RegisteredReplicas map[string]types.RegReplica MaxRevReplica string + StartTime time.Time + StartSignalled bool } func NewController(name string, frontendIP string, factory types.BackendFactory, frontend types.Frontend) *Controller { @@ -31,6 +33,7 @@ func NewController(name string, frontendIP string, factory types.BackendFactory, frontend: frontend, frontendIP: frontendIP, RegisteredReplicas: map[string]types.RegReplica{}, + StartTime: time.Now(), } c.reset() return c @@ -97,6 +100,16 @@ func (c *Controller) registerReplica(register types.RegReplica) error { defer c.Unlock() c.RegisteredReplicas[register.Address] = register + if len(c.replicas) > 0 { + return nil + } + if c.StartSignalled == true { + if c.MaxRevReplica == register.Address { + c.signalToAdd() + } else { + return nil + } + } if c.MaxRevReplica == "" { c.MaxRevReplica = register.Address @@ -108,9 +121,19 @@ func (c *Controller) registerReplica(register types.RegReplica) error { if c.RegisteredReplicas[c.MaxRevReplica].RepCount == int64(len(c.RegisteredReplicas)) { c.signalToAdd() + c.StartSignalled = true + return nil } if c.RegisteredReplicas[c.MaxRevReplica].RepCount == 0 { c.signalToAdd() + c.StartSignalled = true + return nil + } + //TODO Improve on this logic for HA + if register.UpTime > time.Since(c.StartTime) && (c.StartSignalled == false || c.MaxRevReplica == register.Address) { + c.signalToAdd() + c.StartSignalled = true + return nil } if len(c.RegisteredReplicas) >= 2 { for _, tmprep := range c.RegisteredReplicas { @@ -124,6 +147,8 @@ func (c *Controller) registerReplica(register types.RegReplica) error { } if revisionConflict == 0 { c.signalToAdd() + c.StartSignalled = true + return nil } } return nil @@ -206,6 +231,8 @@ func (c *Controller) RemoveReplica(address string) error { if len(c.replicas) == 1 && c.frontend.State() == types.StateUp { if r.Mode == "ERR" { if c.frontend != nil { + c.StartSignalled = false + c.MaxRevReplica = "" c.frontend.Shutdown() } } else { diff --git a/controller/rest/model.go b/controller/rest/model.go index e5e0a390..da111e39 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -2,6 +2,7 @@ package rest import ( "encoding/base64" + "time" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" @@ -67,9 +68,10 @@ type PrepareRebuildOutput struct { type RegReplica struct { client.Resource - Address string `json:"Address"` - RevCount int64 `json:"RevCount"` - RepCount int64 `json:"RepCount"` + Address string `json:"Address"` + RevCount int64 `json:"RevCount"` + RepCount int64 `json:"RepCount"` + UpTime time.Duration `json:"UpTime"` } func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { diff --git a/controller/rest/replica.go b/controller/rest/replica.go index 59df891e..7b8dbd4c 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -45,7 +45,7 @@ func (s *Server) RegisterReplica(rw http.ResponseWriter, req *http.Request) erro return err } - local := types.RegReplica{Address: regReplica.Address, RevCount: regReplica.RevCount, RepCount: regReplica.RepCount} + local := types.RegReplica{Address: regReplica.Address, RevCount: regReplica.RevCount, RepCount: regReplica.RepCount, UpTime: regReplica.UpTime} if err := s.c.RegisterReplica(local); err != nil { return err } diff --git a/replica/replica.go b/replica/replica.go index 0203bd93..40558520 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -11,6 +11,7 @@ import ( "strings" "sync" "syscall" + "time" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" @@ -38,13 +39,14 @@ var ( type Replica struct { sync.RWMutex - volume diffDisk - dir string - info Info - diskData map[string]*disk - diskChildrenMap map[string]map[string]bool - activeDiskData []*disk - readOnly bool + volume diffDisk + dir string + ReplicaStartTime time.Time + info Info + diskData map[string]*disk + diskChildrenMap map[string]map[string]bool + activeDiskData []*disk + readOnly bool revisionLock sync.Mutex revisionCache int64 @@ -109,7 +111,8 @@ func CreateTempReplica() (*Replica, error) { } r := &Replica{ - dir: Dir, + dir: Dir, + ReplicaStartTime: StartTime, } if err := r.initRevisionCounter(); err != nil { return nil, err diff --git a/replica/server.go b/replica/server.go index ab0c0ed3..cb400dd4 100644 --- a/replica/server.go +++ b/replica/server.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "sync" + "time" "github.com/Sirupsen/logrus" ) @@ -21,6 +22,7 @@ type State string var ActionChannel chan string var Dir string +var StartTime time.Time type Server struct { sync.RWMutex @@ -34,6 +36,7 @@ type Server struct { func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { ActionChannel = make(chan string, 5) Dir = dir + StartTime = time.Now() return &Server{ dir: dir, backing: backing, diff --git a/sync/sync.go b/sync/sync.go index 23befe85..21536c06 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -3,6 +3,7 @@ package sync import ( "fmt" "strings" + "time" "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/controller/client" @@ -172,6 +173,9 @@ func find(list []string, item string) int { func (t *Task) AddReplica(replicaAddress string) error { var action string + ticker := time.NewTicker(5 * time.Second) + defer ticker.Stop() +Register: volume, err := t.client.GetVolume() if err != nil { return err @@ -183,8 +187,13 @@ func (t *Task) AddReplica(replicaAddress string) error { if volume.ReplicaCount == 0 { revisionCount := Replica.GetRevisionCounter() replicaCount := Replica.GetPeerCounter() - t.client.Register(parts[0], revisionCount, replicaCount) - action = <-replica.ActionChannel + upTime := time.Since(Replica.ReplicaStartTime) + t.client.Register(parts[0], revisionCount, replicaCount, upTime) + select { + case <-ticker.C: + goto Register + case action = <-replica.ActionChannel: + } } if action == "start" { return t.client.Start(replicaAddress) diff --git a/types/types.go b/types/types.go index 69aff0c4..27afdc9a 100644 --- a/types/types.go +++ b/types/types.go @@ -1,6 +1,9 @@ package types -import "io" +import ( + "io" + "time" +) const ( WO = Mode("WO") @@ -68,6 +71,7 @@ type Replica struct { type RegReplica struct { Address string + UpTime time.Duration RevCount int64 RepCount int64 } From 97e94317fd8746c559e6f863b5bf49fcfb0fcd3d Mon Sep 17 00:00:00 2001 From: Payes Date: Mon, 3 Apr 2017 12:05:14 +0530 Subject: [PATCH 341/357] Adding a rest api to get runtime stats from replica --- replica/rest/model.go | 11 +++++++++++ replica/rest/replica.go | 25 +++++++++++++++++++++++++ replica/rest/router.go | 3 +++ replica/server.go | 8 ++++++++ types/types.go | 5 +++++ 5 files changed, 52 insertions(+) diff --git a/replica/rest/model.go b/replica/rest/model.go index 18ee7475..5c709519 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -21,6 +21,13 @@ type Replica struct { Disks map[string]replica.DiskInfo `json:"disks"` RemainSnapshots int `json:"remainsnapshots"` RevisionCounter int64 `json:"revisioncounter"` + ReplicaCounter int64 `json:"replicacounter"` +} + +type Stats struct { + client.Resource + ReplicaCounter int64 `json:"replicacounter"` + RevisionCounter int64 `json:"revisioncounter"` } type CreateInput struct { @@ -176,6 +183,7 @@ func NewSchema() *client.Schemas { schemas.AddType("prepareRemoveDiskInput", PrepareRemoveDiskInput{}) schemas.AddType("prepareRemoveDiskOutput", PrepareRemoveDiskOutput{}) schemas.AddType("revisionCounter", RevisionCounter{}) + schemas.AddType("replicaCounter", ReplicaCounter{}) schemas.AddType("replacediskInput", ReplaceDiskInput{}) replica := schemas.AddType("replica", Replica{}) @@ -217,6 +225,9 @@ func NewSchema() *client.Schemas { "setrevisioncounter": { Input: "revisionCounter", }, + "setreplicacounter": { + Input: "replicaCounter", + }, "replacedisk": { Input: "replacediskinput", Output: "replica", diff --git a/replica/rest/replica.go b/replica/rest/replica.go index 4eeb0d8b..b7114da0 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -9,6 +9,7 @@ import ( "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" + "github.com/rancher/longhorn/types" ) func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { @@ -36,6 +37,30 @@ func (s *Server) GetReplica(rw http.ResponseWriter, req *http.Request) error { return nil } +func (s *Server) GetReplicaStats(apiContext *api.ApiContext) *types.Stats { + return s.s.Stats() +} + +func (s *Server) GetStats(rw http.ResponseWriter, req *http.Request) error { + var stats *types.Stats + apiContext := api.GetApiContext(req) + stats = s.GetReplicaStats(apiContext) + + resp := &Stats{ + Resource: client.Resource{ + Type: "replica", + Id: "1", + Actions: map[string]string{}, + Links: map[string]string{}, + }, + RevisionCounter: stats.RevisionCounter, + ReplicaCounter: stats.ReplicaCounter, + } + + apiContext.Write(resp) + return nil +} + func (s *Server) doOp(req *http.Request, err error) error { if err != nil { return err diff --git a/replica/rest/router.go b/replica/rest/router.go index 46d29ece..c4c29248 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -44,6 +44,9 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/schemas/{id}").Handler(api.SchemaHandler(schemas)) router.Methods("GET").Path("/v1").Handler(api.VersionHandler(schemas, "v1")) + // Stats + router.Methods("GET").Path("/v1/stats").Handler(f(schemas, s.GetStats)) + // Replicas router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) diff --git a/replica/server.go b/replica/server.go index cb400dd4..88353a00 100644 --- a/replica/server.go +++ b/replica/server.go @@ -7,6 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" ) const ( @@ -149,7 +150,14 @@ func (s *Server) Status() (State, Info) { return Open, info } } +func (s *Server) Stats() *types.Stats { + r := s.r + return &types.Stats{ + RevisionCounter: r.revisionCache, + ReplicaCounter: r.peerCache, + } +} func (s *Server) SetRebuilding(rebuilding bool) error { s.Lock() defer s.Unlock() diff --git a/types/types.go b/types/types.go index 27afdc9a..56c421ba 100644 --- a/types/types.go +++ b/types/types.go @@ -76,6 +76,11 @@ type RegReplica struct { RepCount int64 } +type Stats struct { + RevisionCounter int64 + ReplicaCounter int64 +} + type Frontend interface { Startup(name string, frontendIP string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error From b504791cdb8c41da67138a6d0145a397cd424cef Mon Sep 17 00:00:00 2001 From: Payes Date: Wed, 5 Apr 2017 16:10:33 +0530 Subject: [PATCH 342/357] Updating with latest iscsi version --- vendor.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor.conf b/vendor.conf index 8af24bd6..27df6196 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt 94366023c985593a771f1e51b64888b2ced15825 +github.com/openebs/gotgt 7b407745a808751ea86f3a0b4b342817c8c841ea From 6138cdcf3d0bd961e523356d374df83c0c7657cf Mon Sep 17 00:00:00 2001 From: Payes Date: Sun, 11 Jun 2017 17:25:51 +0530 Subject: [PATCH 343/357] Add IO stats --- controller/control.go | 18 +++++++++++++++--- controller/rest/model.go | 22 ++++++++++++++++++++++ controller/rest/router.go | 1 + controller/rest/volume.go | 24 ++++++++++++++++++++++++ frontend/gotgt/frontend.go | 8 ++++++++ frontend/rest/frontend.go | 4 ++++ frontend/tcmu/frontend.go | 5 +++++ frontend/tgt/frontend.go | 4 ++++ types/types.go | 19 +++++++++++++++++++ vendor.conf | 2 +- 10 files changed, 103 insertions(+), 4 deletions(-) diff --git a/controller/control.go b/controller/control.go index d13aa33c..e3d1868c 100644 --- a/controller/control.go +++ b/controller/control.go @@ -2,12 +2,13 @@ package controller import ( "fmt" - "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" "strings" "sync" "time" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" + "github.com/rancher/longhorn/util" ) type Controller struct { @@ -483,6 +484,17 @@ func (c *Controller) shutdownFrontend() error { return nil } +func (c *Controller) Stats() types.Stats { + // Make sure writing data won't be blocked + c.RLock() + defer c.RUnlock() + + if c.frontend != nil { + return (types.Stats)(c.frontend.Stats()) + } + return types.Stats{} +} + func (c *Controller) shutdownBackend() error { c.Lock() defer c.Unlock() diff --git a/controller/rest/model.go b/controller/rest/model.go index da111e39..34baefdb 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -46,6 +46,23 @@ type SnapshotOutput struct { client.Resource } +type VolumeStats struct { + client.Resource + RevisionCounter int64 `json:"RevisionCounter"` + ReplicaCounter int64 `json:"ReplicaCounter"` + SCSIIOCount map[int]int64 `json:"SCSIIOCount"` + + ReadIOPS int64 `json:"ReadIOPS"` + ReadThroughput int64 `json:"ReadThroughput"` + ReadLatency int64 `json:"ReadLatency"` + AvgReadBlockSize int64 `json:"AvgReadBlockSize"` + + WriteIOPS int64 `json:"WriteIOPS"` + WriteThroughput int64 `json:"WriteThroughput"` + WriteLatency int64 `json:"WriteLatency"` + AvgWriteBlockSize int64 `json:"AvgWriteBlockSize"` +} + type SnapshotInput struct { client.Resource Name string `json:"name"` @@ -152,6 +169,11 @@ func NewSchema() *client.Schemas { f.Update = true replica.ResourceFields["mode"] = f + stats := schemas.AddType("stats", VolumeStats{}) + f = stats.ResourceFields["Stats"] + f.Default = true + stats.ResourceFields["Stats"] = f + volumes := schemas.AddType("volume", Volume{}) volumes.ResourceActions = map[string]client.Action{ "revert": { diff --git a/controller/rest/router.go b/controller/rest/router.go index 1268ba49..36c8542d 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -23,6 +23,7 @@ func NewRouter(s *Server) *mux.Router { // Volumes router.Methods("GET").Path("/v1/volumes").Handler(f(schemas, s.ListVolumes)) router.Methods("GET").Path("/v1/volumes/{id}").Handler(f(schemas, s.GetVolume)) + router.Methods("GET").Path("/v1/stats").Handler(f(schemas, s.GetVolumeStats)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "start").Handler(f(schemas, s.StartVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "shutdown").Handler(f(schemas, s.ShutdownVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "snapshot").Handler(f(schemas, s.SnapshotVolume)) diff --git a/controller/rest/volume.go b/controller/rest/volume.go index f38e2e7d..a4792dde 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -32,6 +32,30 @@ func (s *Server) GetVolume(rw http.ResponseWriter, req *http.Request) error { return nil } +func (s *Server) GetVolumeStats(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + // id := mux.Vars(req)["id"] + stats := s.c.Stats() + volumeStats := &VolumeStats{ + Resource: client.Resource{Type: "stats"}, + RevisionCounter: stats.RevisionCounter, + ReplicaCounter: stats.ReplicaCounter, + SCSIIOCount: stats.SCSIIOCount, + + ReadIOPS: stats.ReadIOPS, + ReadThroughput: stats.ReadThroughput, + ReadLatency: stats.ReadLatency, + AvgReadBlockSize: stats.AvgReadBlockSize, + + WriteIOPS: stats.WriteIOPS, + WriteThroughput: stats.WriteThroughput, + WriteLatency: stats.WriteLatency, + AvgWriteBlockSize: stats.AvgWriteBlockSize, + } + apiContext.Write(volumeStats) + return nil +} + func (s *Server) ShutdownVolume(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) id := mux.Vars(req)["id"] diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index a788a7fb..139f8c18 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -29,6 +29,7 @@ type goTgt struct { lhbsName string cfg *config.Config targetDriver port.SCSITargetService + stats port.Stats } func (t *goTgt) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { @@ -95,6 +96,13 @@ func (t *goTgt) State() types.State { return types.StateDown } +func (t *goTgt) Stats() types.Stats { + if !t.isUp { + return types.Stats{} + } + return (types.Stats)(t.targetDriver.Stats()) +} + func (t *goTgt) startScsiTarget(cfg *config.Config) error { scsiTarget := scsi.NewSCSITargetService() var err error diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go index 4f9d7d88..137c65aa 100644 --- a/frontend/rest/frontend.go +++ b/frontend/rest/frontend.go @@ -70,3 +70,7 @@ func (d *Device) State() types.State { } return types.StateDown } + +func (d *Device) Stats() types.Stats { + return types.Stats{} +} diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index d92af61a..da59ed00 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -33,6 +33,7 @@ func New() types.Frontend { type Tcmu struct { volume string isUp bool + stats map[int]int64 } func (t *Tcmu) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { @@ -70,6 +71,10 @@ func (t *Tcmu) State() types.State { return types.StateDown } +func (t *Tcmu) Stats() types.Stats { + return types.Stats{} +} + func PreEnableTcmu(volume string, size, sectorSize int64) error { err := writeLines(path.Join(configDir, volume, "control"), []string{ fmt.Sprintf("dev_size=%d", size), diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index f1e9026f..beecf7a6 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -87,6 +87,10 @@ func (t *Tgt) State() types.State { return types.StateDown } +func (t *Tgt) Stats() types.Stats { + return types.Stats{} +} + func (t *Tgt) getSocketPath() string { if t.Volume == "" { panic("Invalid volume name") diff --git a/types/types.go b/types/types.go index 56c421ba..e7d792db 100644 --- a/types/types.go +++ b/types/types.go @@ -76,15 +76,34 @@ type RegReplica struct { RepCount int64 } +type IOStats struct { + IOPS int64 + Throughput int64 + Latency float32 + AvBlockSize float32 +} type Stats struct { RevisionCounter int64 ReplicaCounter int64 + SCSIIOCount map[int]int64 + + ReadIOPS int64 + ReadThroughput int64 + ReadLatency int64 + AvgReadBlockSize int64 + + WriteIOPS int64 + WriteThroughput int64 + WriteLatency int64 + AvgWriteBlockSize int64 } +type Interface interface{} type Frontend interface { Startup(name string, frontendIP string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error State() State + Stats() Stats } type DataProcessor interface { diff --git a/vendor.conf b/vendor.conf index 27df6196..c7ea5d7f 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt 7b407745a808751ea86f3a0b4b342817c8c841ea +github.com/openebs/gotgt de50a533c2db559ee93864c1506151a523608949 From aece2ee0b7035496fb27914a302c3a663e5ab3c6 Mon Sep 17 00:00:00 2001 From: Payes Date: Mon, 12 Jun 2017 00:46:57 +0530 Subject: [PATCH 344/357] Add functionality to increase size of volume --- backend/file/file.go | 4 ++++ backend/remote/remote.go | 10 ++++++++++ controller/control.go | 26 ++++++++++++++++++++++++++ controller/replicator.go | 27 +++++++++++++++++++++++++++ controller/rest/model.go | 6 ++++++ controller/rest/router.go | 1 + controller/rest/volume.go | 22 ++++++++++++++++++++++ replica/replica.go | 25 +++++++++++++++++++++++++ replica/rest/model.go | 11 +++++++++++ replica/rest/replica.go | 10 ++++++++++ replica/rest/router.go | 1 + replica/server.go | 6 ++++++ types/types.go | 1 + 13 files changed, 150 insertions(+) diff --git a/backend/file/file.go b/backend/file/file.go index 5446fa9f..0bb9a74a 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -27,6 +27,10 @@ func (f *Wrapper) Snapshot(name string, userCreated bool, created string) error return nil } +func (f *Wrapper) Resize(name string, size string) error { + return nil +} + func (f *Wrapper) Size() (int64, error) { stat, err := f.Stat() if err != nil { diff --git a/backend/remote/remote.go b/backend/remote/remote.go index d519bcae..af0b76c1 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -62,6 +62,16 @@ func (r *Remote) Snapshot(name string, userCreated bool, created string) error { }) } +func (r *Remote) Resize(name string, size string) error { + logrus.Infof("Resize: %s to %s", + name, size) + return r.doAction("resize", + &map[string]interface{}{ + "name": name, + "size": size, + }) +} + func (r *Remote) doAction(action string, obj interface{}) error { body := io.Reader(nil) if obj != nil { diff --git a/controller/control.go b/controller/control.go index e3d1868c..ce469f83 100644 --- a/controller/control.go +++ b/controller/control.go @@ -7,6 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" + units "github.com/docker/go-units" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" ) @@ -173,6 +174,31 @@ func (c *Controller) Snapshot(name string) (string, error) { return name, c.handleErrorNoLock(c.backend.Snapshot(name, true, created)) } +func (c *Controller) Resize(name string, size string) error { + var ( + sizeInBytes int64 + err error + ) + c.Lock() + defer c.Unlock() + + if name != c.Name { + return fmt.Errorf("Volume name didn't match") + } + if size != "" { + sizeInBytes, err = units.RAMInBytes(size) + if err != nil { + return err + } + } + if sizeInBytes < c.size { + return fmt.Errorf("Size can only be increased, not reduced") + } else if sizeInBytes == c.size { + return fmt.Errorf("Volume size same as size mentioned") + } + return c.handleErrorNoLock(c.backend.Resize(name, size)) +} + func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { if ok, err := c.canAdd(address); !ok { return err diff --git a/controller/replicator.go b/controller/replicator.go index 2c1b58af..9a1aeaf5 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -205,7 +205,34 @@ func (r *replicator) Snapshot(name string, userCreated bool, created string) err } return nil } +func (r *replicator) Resize(name string, size string) error { + retErrorLock := sync.Mutex{} + retError := &BackendError{ + Errors: map[string]error{}, + } + wg := sync.WaitGroup{} + for addr, backend := range r.backends { + if backend.mode != types.ERR { + wg.Add(1) + go func(address string, backend types.Backend) { + if err := backend.Resize(name, size); err != nil { + retErrorLock.Lock() + retError.Errors[address] = err + retErrorLock.Unlock() + } + wg.Done() + }(addr, backend.backend) + } + } + + wg.Wait() + + if len(retError.Errors) != 0 { + return retError + } + return nil +} func (r *replicator) Close() error { var lastErr error for _, backend := range r.backends { diff --git a/controller/rest/model.go b/controller/rest/model.go index 34baefdb..1f7a7687 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -73,6 +73,12 @@ type RevertInput struct { Name string `json:"name"` } +type ResizeInput struct { + client.Resource + Name string `json:"name"` + Size string `json:"size"` +} + type JournalInput struct { client.Resource Limit int `json:"limit"` diff --git a/controller/rest/router.go b/controller/rest/router.go index 36c8542d..2d57708e 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -28,6 +28,7 @@ func NewRouter(s *Server) *mux.Router { router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "shutdown").Handler(f(schemas, s.ShutdownVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "snapshot").Handler(f(schemas, s.SnapshotVolume)) router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "revert").Handler(f(schemas, s.RevertVolume)) + router.Methods("POST").Path("/v1/volumes/{id}").Queries("action", "resize").Handler(f(schemas, s.ResizeVolume)) // Replicas router.Methods("GET").Path("/v1/replicas").Handler(f(schemas, s.ListReplicas)) diff --git a/controller/rest/volume.go b/controller/rest/volume.go index a4792dde..0d622f31 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -95,6 +95,28 @@ func (s *Server) RevertVolume(rw http.ResponseWriter, req *http.Request) error { return s.GetVolume(rw, req) } +func (s *Server) ResizeVolume(rw http.ResponseWriter, req *http.Request) error { + apiContext := api.GetApiContext(req) + id := mux.Vars(req)["id"] + + v := s.getVolume(apiContext, id) + if v == nil { + rw.WriteHeader(http.StatusNotFound) + return nil + } + + var input ResizeInput + if err := apiContext.Read(&input); err != nil { + return err + } + + if err := s.c.Resize(input.Name, input.Size); err != nil { + return err + } + + return s.GetVolume(rw, req) +} + func (s *Server) SnapshotVolume(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) id := mux.Vars(req)["id"] diff --git a/replica/replica.go b/replica/replica.go index 40558520..8ccb80c9 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -14,6 +14,7 @@ import ( "time" "github.com/Sirupsen/logrus" + units "github.com/docker/go-units" "github.com/rancher/longhorn/types" "github.com/rancher/longhorn/util" "github.com/rancher/sparse-tools/sparse" @@ -255,6 +256,30 @@ func (r *Replica) SetRebuilding(rebuilding bool) error { return nil } +func (r *Replica) Resize(size string) error { + var sizeInBytes int64 + chain, err := r.Chain() + if err != nil { + return err + } + if size != "" { + sizeInBytes, err = units.RAMInBytes(size) + if err != nil { + return err + } + } + if r.info.Size <= sizeInBytes { + return fmt.Errorf("Previous size %d is greater than %d", r.info.Size, sizeInBytes) + } + for _, file := range chain { + if err := syscall.Truncate(r.diskPath(file), sizeInBytes); err != nil { + return err + } + } + r.info.Size = sizeInBytes + return nil +} + func (r *Replica) Reload() (*Replica, error) { newReplica, err := New(r.info.Size, r.info.SectorSize, r.dir, r.info.BackingFile) if err != nil { diff --git a/replica/rest/model.go b/replica/rest/model.go index 5c709519..f608759c 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -58,6 +58,12 @@ type RemoveDiskInput struct { Name string `json:"name"` } +type ResizeInput struct { + client.Resource + Name string `json:"name"` + Size string `json:"size"` +} + type ReplaceDiskInput struct { client.Resource Target string `json:"target"` @@ -106,8 +112,10 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, case replica.Initial: actions["start"] = true actions["create"] = true + actions["resize"] = true case replica.Open: actions["start"] = true + actions["resize"] = true actions["close"] = true actions["setrebuilding"] = true actions["snapshot"] = true @@ -121,6 +129,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, case replica.Closed: actions["start"] = true actions["open"] = true + actions["resize"] = true actions["removedisk"] = true actions["replacedisk"] = true actions["revert"] = true @@ -128,6 +137,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["setreplicacounter"] = true case replica.Dirty: actions["start"] = true + actions["resize"] = true actions["setrebuilding"] = true actions["close"] = true actions["snapshot"] = true @@ -139,6 +149,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["setreplicacounter"] = true case replica.Rebuilding: actions["start"] = true + actions["resize"] = true actions["snapshot"] = true actions["setrebuilding"] = true actions["close"] = true diff --git a/replica/rest/replica.go b/replica/rest/replica.go index b7114da0..e2119969 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -104,6 +104,16 @@ func (s *Server) OpenReplica(rw http.ResponseWriter, req *http.Request) error { return s.doOp(req, s.s.Open()) } +func (s *Server) Resize(rw http.ResponseWriter, req *http.Request) error { + var input ResizeInput + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&input); err != nil { + return err + } + + return s.doOp(req, s.s.Resize(input.Size)) +} + func (s *Server) RemoveDisk(rw http.ResponseWriter, req *http.Request) error { var input RemoveDiskInput apiContext := api.GetApiContext(req) diff --git a/replica/rest/router.go b/replica/rest/router.go index c4c29248..a7af2728 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -59,6 +59,7 @@ func NewRouter(s *Server) *mux.Router { "snapshot": s.SnapshotReplica, "open": s.OpenReplica, "close": s.CloseReplica, + "resize": s.Resize, "removedisk": s.RemoveDisk, "replacedisk": s.ReplaceDisk, "setrebuilding": s.SetRebuilding, diff --git a/replica/server.go b/replica/server.go index 88353a00..d5d9c2d3 100644 --- a/replica/server.go +++ b/replica/server.go @@ -172,6 +172,12 @@ func (s *Server) SetRebuilding(rebuilding bool) error { return s.r.SetRebuilding(rebuilding) } +func (s *Server) Resize(size string) error { + s.Lock() + defer s.Unlock() + return s.r.Resize(size) +} + func (s *Server) Replica() *Replica { return s.r } diff --git a/types/types.go b/types/types.go index e7d792db..62ec0cfb 100644 --- a/types/types.go +++ b/types/types.go @@ -31,6 +31,7 @@ type Backend interface { ReaderWriterAt io.Closer Snapshot(name string, userCreated bool, created string) error + Resize(name string, size string) error Size() (int64, error) SectorSize() (int64, error) RemainSnapshots() (int, error) From 248028b6070c024c4bc371a5e7e40a057e469d74 Mon Sep 17 00:00:00 2001 From: Payes Date: Tue, 13 Jun 2017 16:21:34 +0530 Subject: [PATCH 345/357] Add Quorum Replica functionality --- app/add_replica.go | 9 +- app/replica.go | 13 +- backend/file/file.go | 6 +- backend/remote/remote.go | 14 +- controller/client/controller_client.go | 19 +- controller/control.go | 298 +++++++++++++++++++++---- controller/multi_writer_at.go | 54 +++-- controller/rebuild.go | 6 - controller/replicator.go | 109 +++++++-- controller/rest/model.go | 9 +- controller/rest/replica.go | 26 ++- controller/rest/router.go | 1 + frontend/tgt/frontend.go | 4 + replica/backup_test.go | 4 +- replica/peer_counter.go | 124 ---------- replica/peer_details.go | 102 +++++++++ replica/replica.go | 50 +++-- replica/replica_test.go | 30 +-- replica/rest/model.go | 10 + replica/rest/replica.go | 10 +- replica/rest/router.go | 2 +- replica/server.go | 29 ++- rpc/client.go | 45 +++- rpc/server.go | 11 + rpc/types.go | 1 + sync/sync.go | 39 +++- types/types.go | 19 +- 27 files changed, 762 insertions(+), 282 deletions(-) delete mode 100644 replica/peer_counter.go create mode 100644 replica/peer_details.go diff --git a/app/add_replica.go b/app/add_replica.go index c6f7bc3c..40ab03cc 100644 --- a/app/add_replica.go +++ b/app/add_replica.go @@ -31,11 +31,16 @@ func addReplica(c *cli.Context) error { task := sync.NewTask(url) return task.AddReplica(replica) } -func AutoAddReplica(frontendIP string, replica string) error { +func AutoAddReplica(frontendIP string, replica string, replicaType string) error { + var err error url := "http://" + frontendIP + ":9501" task := sync.NewTask(url) for { - err := task.AddReplica(replica) + if replicaType == "quorum" { + err = task.AddQuorumReplica(replica) + } else { + err = task.AddReplica(replica) + } if err != nil { time.Sleep(2 * time.Second) continue diff --git a/app/replica.go b/app/replica.go index f37dd420..2fbba646 100644 --- a/app/replica.go +++ b/app/replica.go @@ -43,6 +43,10 @@ func ReplicaCmd() cli.Command { Name: "size", Usage: "Volume size in bytes or human readable 42kb, 42mb, 42gb", }, + cli.StringFlag{ + Name: "type", + Value: "", + }, }, Action: func(c *cli.Context) { if err := startReplica(c); err != nil { @@ -68,7 +72,7 @@ func CheckReplicaState(frontendIP string, replicaIP string) (string, error) { return "", err } -func AutoConfigureReplica(s *replica.Server, frontendIP string, address string) { +func AutoConfigureReplica(s *replica.Server, frontendIP string, address string, replicaType string) { checkagain: state, err := CheckReplicaState(frontendIP, address) if err == nil && (state == "" || state == "ERR") { @@ -79,7 +83,7 @@ checkagain: } s.Close() AutoRmReplica(frontendIP, address) - AutoAddReplica(frontendIP, address) + AutoAddReplica(frontendIP, address, replicaType) select { case <-s.MonitorChannel: goto checkagain @@ -97,7 +101,8 @@ func startReplica(c *cli.Context) error { return err } - s := replica.NewServer(dir, backingFile, 512) + replicaType := c.String("type") + s := replica.NewServer(dir, backingFile, 512, replicaType) address := c.String("listen") frontendIP := c.String("frontendIP") @@ -160,7 +165,7 @@ func startReplica(c *cli.Context) error { }() } if frontendIP != "" { - go AutoConfigureReplica(s, frontendIP, "tcp://"+address) + go AutoConfigureReplica(s, frontendIP, "tcp://"+address, replicaType) } return <-resp diff --git a/backend/file/file.go b/backend/file/file.go index 0bb9a74a..62d22772 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -55,7 +55,11 @@ func (f *Wrapper) SetRevisionCounter(counter int64) error { return nil } -func (f *Wrapper) SetReplicaCounter(counter int64) error { +func (f *Wrapper) UpdatePeerDetails(replicaCount int64, quorumReplicaCount int64) error { + return nil +} + +func (f *Wrapper) SetRebuilding(rebuilding bool) error { return nil } diff --git a/backend/remote/remote.go b/backend/remote/remote.go index af0b76c1..528fd417 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -71,6 +71,10 @@ func (r *Remote) Resize(name string, size string) error { "size": size, }) } +func (r *Remote) SetRebuilding(rebuilding bool) error { + logrus.Infof("SetRebuilding: %v", rebuilding) + return r.doAction("setrebuilding", &map[string]bool{"rebuilding": rebuilding}) +} func (r *Remote) doAction(action string, obj interface{}) error { body := io.Reader(nil) @@ -147,9 +151,13 @@ func (r *Remote) SetRevisionCounter(counter int64) error { return r.doAction("setrevisioncounter", &map[string]int64{"counter": counter}) } -func (r *Remote) SetReplicaCounter(counter int64) error { - logrus.Infof("Set replica counter of %s to : %v", r.name, counter) - return r.doAction("setreplicacounter", &map[string]int64{"counter": counter}) +func (r *Remote) UpdatePeerDetails(replicaCount int64, quorumReplicaCount int64) error { + logrus.Infof("Update peer details of %s ", r.name) + return r.doAction("updatepeerdetails", + &map[string]interface{}{ + "replicacount": replicaCount, + "quorumreplicacount": quorumReplicaCount, + }) } func (r *Remote) info() (rest.Replica, error) { diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index f3cf4645..05d738d2 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -107,6 +107,14 @@ func (c *ControllerClient) CreateReplica(address string) (*rest.Replica, error) return &resp, err } +func (c *ControllerClient) CreateQuorumReplica(address string) (*rest.Replica, error) { + var resp rest.Replica + err := c.post("/quorumreplicas", &rest.Replica{ + Address: address, + }, &resp) + return &resp, err +} + func (c *ControllerClient) DeleteReplica(address string) (*rest.Replica, error) { reps, err := c.ListReplicas() if err != nil { @@ -179,12 +187,13 @@ func (c *ControllerClient) GetVolume() (*rest.Volume, error) { return &volumes.Data[0], nil } -func (c *ControllerClient) Register(address string, revisionCount int64, replicaCount int64, upTime time.Duration) error { +func (c *ControllerClient) Register(address string, revisionCount int64, peerDetails types.PeerDetails, replicaType string, upTime time.Duration) error { err := c.post("/register", &types.RegReplica{ - Address: address, - RevCount: revisionCount, - RepCount: replicaCount, - UpTime: upTime, + Address: address, + RevCount: revisionCount, + PeerDetail: peerDetails, + RepType: replicaType, + UpTime: upTime, }, nil) return err } diff --git a/controller/control.go b/controller/control.go index ce469f83..d22ff5de 100644 --- a/controller/control.go +++ b/controller/control.go @@ -14,33 +14,43 @@ import ( type Controller struct { sync.RWMutex - Name string - frontendIP string - size int64 - sectorSize int64 - replicas []types.Replica - factory types.BackendFactory - backend *replicator - frontend types.Frontend - RegisteredReplicas map[string]types.RegReplica - MaxRevReplica string - StartTime time.Time - StartSignalled bool + Name string + frontendIP string + size int64 + sectorSize int64 + replicas []types.Replica + replicaCount int64 + quorumReplicas []types.Replica + quorumReplicaCount int64 + factory types.BackendFactory + backend *replicator + frontend types.Frontend + RegisteredReplicas map[string]types.RegReplica + RegisteredQuorumReplicas map[string]types.RegReplica + MaxRevReplica string + StartTime time.Time + StartSignalled bool + ReadOnly bool } func NewController(name string, frontendIP string, factory types.BackendFactory, frontend types.Frontend) *Controller { c := &Controller{ - factory: factory, - Name: name, - frontend: frontend, - frontendIP: frontendIP, - RegisteredReplicas: map[string]types.RegReplica{}, - StartTime: time.Now(), + factory: factory, + Name: name, + frontend: frontend, + frontendIP: frontendIP, + RegisteredReplicas: map[string]types.RegReplica{}, + RegisteredQuorumReplicas: map[string]types.RegReplica{}, + StartTime: time.Now(), } c.reset() return c } +func (c *Controller) AddQuorumReplica(address string) error { + return c.addQuorumReplica(address, false) +} + func (c *Controller) AddReplica(address string) error { return c.addReplica(address, true) } @@ -68,6 +78,85 @@ func (c *Controller) canAdd(address string) (bool, error) { return true, nil } +func (c *Controller) getRWReplica() (*types.Replica, error) { + var ( + rwReplica *types.Replica + ) + + for i := range c.replicas { + if c.replicas[i].Mode == types.RW { + rwReplica = &c.replicas[i] + } + } + if rwReplica == nil { + return nil, fmt.Errorf("Cannot find any healthy replica") + } + + return rwReplica, nil +} + +func (c *Controller) addQuorumReplica(address string, snapshot bool) error { + c.Lock() + if ok, err := c.canAdd(address); !ok { + c.Unlock() + return err + } + c.Unlock() + + newBackend, err := c.factory.Create(address) + if err != nil { + return err + } + + c.Lock() + defer c.Unlock() + + err = c.addQuorumReplicaNoLock(newBackend, address, snapshot) + if err != nil { + return err + } + + if err := c.backend.SetRebuilding(address, true); err != nil { + return fmt.Errorf("Failed to set rebuild : %v", true) + } + rwReplica, err := c.getRWReplica() + if err != nil { + return err + } + + counter, err := c.backend.GetRevisionCounter(rwReplica.Address) + if err != nil || counter == -1 { + return fmt.Errorf("Failed to get revision counter of RW Replica %v: counter %v, err %v", + rwReplica.Address, counter, err) + + } + + if err := c.backend.SetQuorumRevisionCounter(address, counter); err != nil { + return fmt.Errorf("Fail to set revision counter for %v: %v", address, err) + } + + if err := c.backend.UpdatePeerDetails(c.replicaCount, c.quorumReplicaCount); err != nil { + return fmt.Errorf("Fail to set revision counter for %v: %v", address, err) + } + + if err := c.backend.SetRebuilding(address, false); err != nil { + return fmt.Errorf("Failed to set rebuild : %v", true) + } + + if (len(c.replicas)+len(c.quorumReplicas) >= 2) && (c.ReadOnly == true) { + c.ReadOnly = false + } + + /* + for _, temprep := range c.replicas { + if err := c.backend.SetQuorumReplicaCounter(temprep.Address, int64(len(c.replicas))); err != nil { + return fmt.Errorf("Fail to set replica counter for %v: %v", address, err) + } + } + */ + return nil +} + func (c *Controller) addReplica(address string, snapshot bool) error { c.Lock() if ok, err := c.canAdd(address); !ok { @@ -84,7 +173,11 @@ func (c *Controller) addReplica(address string, snapshot bool) error { c.Lock() defer c.Unlock() - return c.addReplicaNoLock(newBackend, address, snapshot) + err = c.addReplicaNoLock(newBackend, address, snapshot) + if (len(c.replicas)+len(c.quorumReplicas) >= 2) && (c.ReadOnly == true) { + c.ReadOnly = false + } + return err } func (c *Controller) signalToAdd() { @@ -92,16 +185,29 @@ func (c *Controller) signalToAdd() { } func (c *Controller) registerReplica(register types.RegReplica) error { - - var ( - revisionConflict int64 - revCount int64 - ) - c.Lock() defer c.Unlock() + _, ok := c.RegisteredReplicas[register.Address] + if !ok { + _, ok = c.RegisteredQuorumReplicas[register.Address] + if ok { + return nil + } + } + if c.quorumReplicaCount < register.PeerDetail.QuorumReplicaCount { + c.quorumReplicaCount = register.PeerDetail.QuorumReplicaCount + } + if c.replicaCount < register.PeerDetail.ReplicaCount { + c.replicaCount = register.PeerDetail.ReplicaCount + } + + if register.RepType == "quorum" { + c.RegisteredQuorumReplicas[register.Address] = register + return nil + } c.RegisteredReplicas[register.Address] = register + if len(c.replicas) > 0 { return nil } @@ -121,38 +227,44 @@ func (c *Controller) registerReplica(register types.RegReplica) error { c.MaxRevReplica = register.Address } - if c.RegisteredReplicas[c.MaxRevReplica].RepCount == int64(len(c.RegisteredReplicas)) { - c.signalToAdd() - c.StartSignalled = true - return nil - } - if c.RegisteredReplicas[c.MaxRevReplica].RepCount == 0 { + if ((int64)(len(c.RegisteredReplicas)) >= c.replicaCount/2) && ((int64)(len(c.RegisteredReplicas)+len(c.RegisteredQuorumReplicas)) > (c.quorumReplicaCount+c.replicaCount)/2) { c.signalToAdd() c.StartSignalled = true return nil } - //TODO Improve on this logic for HA - if register.UpTime > time.Since(c.StartTime) && (c.StartSignalled == false || c.MaxRevReplica == register.Address) { + + if c.RegisteredReplicas[c.MaxRevReplica].PeerDetail.ReplicaCount == 0 { c.signalToAdd() c.StartSignalled = true return nil } - if len(c.RegisteredReplicas) >= 2 { - for _, tmprep := range c.RegisteredReplicas { - if revCount == 0 { - revCount = tmprep.RevCount - } else { - if revCount != tmprep.RevCount { - revisionConflict = 1 - } - } - } - if revisionConflict == 0 { + + /* + //TODO Improve on this logic for HA + if register.UpTime > time.Since(c.StartTime) && (c.StartSignalled == false || c.MaxRevReplica == register.Address) { c.signalToAdd() c.StartSignalled = true return nil } - } + */ + /* + if len(c.RegisteredReplicas) >= 2 { + for _, tmprep := range c.RegisteredReplicas { + if revCount == 0 { + revCount = tmprep.RevCount + } else { + if revCount != tmprep.RevCount { + revisionConflict = 1 + } + } + } + if revisionConflict == 0 { + c.signalToAdd() + c.StartSignalled = true + return nil + } + } + */ return nil } @@ -199,6 +311,44 @@ func (c *Controller) Resize(name string, size string) error { return c.handleErrorNoLock(c.backend.Resize(name, size)) } +func (c *Controller) addQuorumReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { + if ok, err := c.canAdd(address); !ok { + return err + } + + if snapshot { + uuid := util.UUID() + created := util.Now() + + if remain, err := c.backend.RemainSnapshots(); err != nil { + return err + } else if remain <= 0 { + return fmt.Errorf("Too many snapshots created") + } + + if err := c.backend.Snapshot(uuid, false, created); err != nil { + newBackend.Close() + return err + } + if err := newBackend.Snapshot(uuid, false, created); err != nil { + newBackend.Close() + return err + } + } + + c.quorumReplicas = append(c.quorumReplicas, types.Replica{ + Address: address, + Mode: types.WO, + }) + c.quorumReplicaCount++ + + c.backend.AddQuorumBackend(address, newBackend) + + go c.monitoring(address, newBackend) + + return nil +} + func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { if ok, err := c.canAdd(address); !ok { return err @@ -228,6 +378,7 @@ func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, Address: address, Mode: types.WO, }) + c.replicaCount++ c.backend.AddBackend(address, newBackend) @@ -242,6 +393,11 @@ func (c *Controller) hasReplica(address string) bool { return true } } + for _, i := range c.quorumReplicas { + if i.Address == address { + return true + } + } return false } @@ -252,7 +408,6 @@ func (c *Controller) RemoveReplica(address string) error { if !c.hasReplica(address) { return nil } - for i, r := range c.replicas { if r.Address == address { if len(c.replicas) == 1 && c.frontend.State() == types.StateUp { @@ -276,6 +431,21 @@ func (c *Controller) RemoveReplica(address string) error { } } + for i, r := range c.quorumReplicas { + if r.Address == address { + for regrep := range c.RegisteredQuorumReplicas { + if strings.Contains(address, regrep) { + delete(c.RegisteredQuorumReplicas, regrep) + } + } + c.quorumReplicas = append(c.quorumReplicas[:i], c.quorumReplicas[i+1:]...) + c.backend.RemoveBackend(r.Address) + } + } + + if len(c.replicas)+len(c.quorumReplicas) < 2 { + c.ReadOnly = true + } return nil } @@ -283,6 +453,10 @@ func (c *Controller) ListReplicas() []types.Replica { return c.replicas } +func (c *Controller) ListQuorumReplicas() []types.Replica { + return c.quorumReplicas +} + func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { switch mode { case types.ERR: @@ -294,7 +468,6 @@ func (c *Controller) SetReplicaMode(address string, mode types.Mode) error { default: return fmt.Errorf("Can not set to mode %s", mode) } - c.setReplicaModeNoLock(address, mode) return nil } @@ -313,6 +486,19 @@ func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { } } } + for i, r := range c.quorumReplicas { + if r.Address == address { + if r.Mode != types.ERR { + logrus.Infof("Set replica %v to mode %v", address, mode) + r.Mode = mode + c.quorumReplicas[i] = r + c.backend.SetMode(address, mode) + } else { + logrus.Infof("Ignore set replica %v to mode %v due to it's ERR", + address, mode) + } + } + } } func (c *Controller) startFrontend() error { @@ -411,12 +597,29 @@ func (c *Controller) Start(addresses ...string) error { c.factory.SignalToAdd(regrep, "add") } } + for regrep := range c.RegisteredQuorumReplicas { + sendSignal = 1 + for _, tmprep := range c.quorumReplicas { + if strings.Contains(tmprep.Address, regrep) { + sendSignal = 0 + break + } + } + if sendSignal == 1 { + c.factory.SignalToAdd(regrep, "add") + } + } return nil } func (c *Controller) WriteAt(b []byte, off int64) (int, error) { c.RLock() + if c.ReadOnly == true { + err := fmt.Errorf("Mode: ReadOnly") + c.RUnlock() + return 0, err + } if off < 0 || off+int64(len(b)) > c.size { err := fmt.Errorf("EOF: Write of %v bytes at offset %v is beyond volume size %v", len(b), off, c.size) c.RUnlock() @@ -492,6 +695,7 @@ func (c *Controller) handleError(err error) error { func (c *Controller) reset() { c.replicas = []types.Replica{} + c.quorumReplicas = []types.Replica{} c.backend = &replicator{} } diff --git a/controller/multi_writer_at.go b/controller/multi_writer_at.go index e980ae68..2a01e1d0 100644 --- a/controller/multi_writer_at.go +++ b/controller/multi_writer_at.go @@ -7,17 +7,26 @@ import ( ) type MultiWriterAt struct { - writers []io.WriterAt + writers []io.WriterAt + updaters []io.WriterAt } type MultiWriterError struct { - Writers []io.WriterAt - Errors []error + Writers []io.WriterAt + Updaters []io.WriterAt + ReplicaErrors []error + QuorumErrors []error } func (m *MultiWriterError) Error() string { errors := []string{} - for _, err := range m.Errors { + for _, err := range m.ReplicaErrors { + if err != nil { + errors = append(errors, err.Error()) + } + } + + for _, err := range m.QuorumErrors { if err != nil { errors = append(errors, err.Error()) } @@ -34,29 +43,46 @@ func (m *MultiWriterError) Error() string { } func (m *MultiWriterAt) WriteAt(p []byte, off int64) (n int, err error) { - errs := make([]error, len(m.writers)) - errored := false + quorumErrs := make([]error, len(m.writers)) + replicaErrs := make([]error, len(m.writers)) + quorumErrored := false + replicaErrored := false wg := sync.WaitGroup{} + var errors MultiWriterError for i, w := range m.writers { wg.Add(1) go func(index int, w io.WriterAt) { _, err := w.WriteAt(p, off) if err != nil { - errored = true - errs[index] = err + replicaErrored = true + replicaErrs[index] = err + } + wg.Done() + }(i, w) + } + for i, w := range m.updaters { + wg.Add(1) + go func(index int, w io.WriterAt) { + _, err := w.WriteAt(nil, 0) + if err != nil { + quorumErrored = true + quorumErrs[index] = err } wg.Done() }(i, w) } - wg.Wait() - if errored { - return 0, &MultiWriterError{ - Writers: m.writers, - Errors: errs, - } + if replicaErrored { + errors.Writers = m.writers + errors.ReplicaErrors = replicaErrs + } else if quorumErrored { + errors.Updaters = m.updaters + errors.QuorumErrors = quorumErrs } + if replicaErrored || quorumErrored { + return 0, &errors + } return len(p), nil } diff --git a/controller/rebuild.go b/controller/rebuild.go index bccb75c9..29bef71d 100644 --- a/controller/rebuild.go +++ b/controller/rebuild.go @@ -91,12 +91,6 @@ func (c *Controller) VerifyRebuildReplica(address string) error { if err := c.backend.SetRevisionCounter(address, counter); err != nil { return fmt.Errorf("Fail to set revision counter for %v: %v", address, err) } - for _, temprep := range c.replicas { - if err := c.backend.SetReplicaCounter(temprep.Address, int64(len(c.replicas))); err != nil { - return fmt.Errorf("Fail to set replica counter for %v: %v", address, err) - } - } - logrus.Debugf("WO replica %v's chain verified, update mode to RW", address) c.setReplicaModeNoLock(address, types.RW) return nil diff --git a/controller/replicator.go b/controller/replicator.go index 9a1aeaf5..8cf67ca4 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -19,7 +19,9 @@ var ( type replicator struct { backendsAvailable bool backends map[string]backendWrapper + quorumBackends map[string]backendWrapper writerIndex map[int]string + updaterIndex map[int]string readerIndex map[int]string readers []io.ReaderAt writer io.WriterAt @@ -48,6 +50,25 @@ func (b *BackendError) Error() string { } } +func (r *replicator) AddQuorumBackend(address string, backend types.Backend) { + if _, ok := r.quorumBackends[address]; ok { + return + } + + logrus.Infof("Adding quorum backend: %s", address) + + if r.quorumBackends == nil { + r.quorumBackends = map[string]backendWrapper{} + } + + r.quorumBackends[address] = backendWrapper{ + backend: backend, + mode: types.WO, + } + + r.buildReadWriters() +} + func (r *replicator) AddBackend(address string, backend types.Backend) { if _, ok := r.backends[address]; ok { return @@ -58,6 +79,9 @@ func (r *replicator) AddBackend(address string, backend types.Backend) { if r.backends == nil { r.backends = map[string]backendWrapper{} } + if r.quorumBackends == nil { + r.quorumBackends = map[string]backendWrapper{} + } r.backends[address] = backendWrapper{ backend: backend, @@ -70,7 +94,10 @@ func (r *replicator) AddBackend(address string, backend types.Backend) { func (r *replicator) RemoveBackend(address string) { backend, ok := r.backends[address] if !ok { - return + backend, ok = r.quorumBackends[address] + if !ok { + return + } } logrus.Infof("Removing backend: %s", address) @@ -125,7 +152,7 @@ func (r *replicator) WriteAt(p []byte, off int64) (int, error) { } if mErr, ok := err.(*MultiWriterError); ok { errors = map[string]error{} - for index, err := range mErr.Errors { + for index, err := range mErr.ReplicaErrors { if err != nil { errors[r.writerIndex[index]] = err } @@ -141,6 +168,7 @@ func (r *replicator) buildReadWriters() { readers := []io.ReaderAt{} writers := []io.WriterAt{} + updaters := []io.WriterAt{} for address, b := range r.backends { if b.mode != types.ERR { @@ -152,9 +180,16 @@ func (r *replicator) buildReadWriters() { readers = append(readers, b.backend) } } + for address, b := range r.quorumBackends { + if b.mode != types.ERR { + r.updaterIndex[len(updaters)] = address + updaters = append(updaters, b.backend) + } + } r.writer = &MultiWriterAt{ - writers: writers, + writers: writers, + updaters: updaters, } r.readers = readers @@ -244,6 +279,15 @@ func (r *replicator) Close() error { } } + for _, backend := range r.quorumBackends { + if backend.mode == types.ERR { + continue + } + if err := backend.backend.Close(); err != nil { + lastErr = err + } + } + r.reset(true) return lastErr @@ -254,6 +298,7 @@ func (r *replicator) reset(full bool) { r.writer = nil r.writerIndex = map[int]string{} r.readerIndex = map[int]string{} + r.updaterIndex = map[int]string{} if full { r.backends = nil @@ -305,32 +350,66 @@ func (r *replicator) SetRevisionCounter(address string, counter int64) error { return nil } -func (r *replicator) GetRevisionCounter(address string) (int64, error) { - backend, ok := r.backends[address] +func (r *replicator) SetQuorumRevisionCounter(address string, counter int64) error { + backend, ok := r.quorumBackends[address] if !ok { - return -1, fmt.Errorf("Cannot find backend %v", address) + return fmt.Errorf("Cannot find backend %v", address) } - counter, err := backend.backend.GetRevisionCounter() - if err != nil { - return 0, err + if err := backend.backend.SetRevisionCounter(counter); err != nil { + return err } - logrus.Infof("Get backend %s revision counter %v", address, counter) - return counter, nil + logrus.Infof("Set backend %s revision counter to %v", address, counter) + + return nil +} + +func (r *replicator) UpdatePeerDetails(replicaCount int64, quorumReplicaCount int64) error { + + for _, backend := range r.backends { + if err := backend.backend.UpdatePeerDetails(replicaCount, quorumReplicaCount); err != nil { + return err + } + } + + for _, backend := range r.quorumBackends { + if err := backend.backend.UpdatePeerDetails(replicaCount, quorumReplicaCount); err != nil { + return err + } + } + return nil } -func (r *replicator) SetReplicaCounter(address string, counter int64) error { +func (r *replicator) SetRebuilding(address string, rebuilding bool) error { backend, ok := r.backends[address] if !ok { - return fmt.Errorf("Cannot find backend %v", address) + backend, ok = r.quorumBackends[address] + if !ok { + return fmt.Errorf("Cannot find backend %v", address) + } } - if err := backend.backend.SetReplicaCounter(counter); err != nil { + if err := backend.backend.SetRebuilding(rebuilding); err != nil { return err } - logrus.Infof("Set backend %s replica counter to %v", address, counter) + logrus.Infof("Set backend %s rebuilding %v", address, rebuilding) return nil + +} +func (r *replicator) GetRevisionCounter(address string) (int64, error) { + backend, ok := r.backends[address] + if !ok { + return -1, fmt.Errorf("Cannot find backend %v", address) + } + + counter, err := backend.backend.GetRevisionCounter() + if err != nil { + return 0, err + } + logrus.Infof("Get backend %s revision counter %v", address, counter) + + return counter, nil } diff --git a/controller/rest/model.go b/controller/rest/model.go index 1f7a7687..2c11c467 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -91,10 +91,11 @@ type PrepareRebuildOutput struct { type RegReplica struct { client.Resource - Address string `json:"Address"` - RevCount int64 `json:"RevCount"` - RepCount int64 `json:"RepCount"` - UpTime time.Duration `json:"UpTime"` + Address string `json:"Address"` + RevCount int64 `json:"RevCount"` + PeerDetails types.PeerDetails `json:"PeerDetails"` + RepType string `json:"RepType"` + UpTime time.Duration `json:"UpTime"` } func NewVolume(context *api.ApiContext, name string, replicas int) *Volume { diff --git a/controller/rest/replica.go b/controller/rest/replica.go index 7b8dbd4c..d9db2261 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -45,7 +45,7 @@ func (s *Server) RegisterReplica(rw http.ResponseWriter, req *http.Request) erro return err } - local := types.RegReplica{Address: regReplica.Address, RevCount: regReplica.RevCount, RepCount: regReplica.RepCount, UpTime: regReplica.UpTime} + local := types.RegReplica{Address: regReplica.Address, RevCount: regReplica.RevCount, PeerDetail: regReplica.PeerDetails, RepType: regReplica.RepType, UpTime: regReplica.UpTime} if err := s.c.RegisterReplica(local); err != nil { return err } @@ -68,6 +68,21 @@ func (s *Server) CreateReplica(rw http.ResponseWriter, req *http.Request) error return nil } +func (s *Server) CreateQuorumReplica(rw http.ResponseWriter, req *http.Request) error { + var replica Replica + apiContext := api.GetApiContext(req) + if err := apiContext.Read(&replica); err != nil { + return err + } + + if err := s.c.AddQuorumReplica(replica.Address); err != nil { + return err + } + + apiContext.Write(s.getQuorumReplica(apiContext, replica.Address)) + return nil +} + func (s *Server) getReplica(context *api.ApiContext, id string) *Replica { for _, r := range s.c.ListReplicas() { if r.Address == id { @@ -77,6 +92,15 @@ func (s *Server) getReplica(context *api.ApiContext, id string) *Replica { return nil } +func (s *Server) getQuorumReplica(context *api.ApiContext, id string) *Replica { + for _, r := range s.c.ListQuorumReplicas() { + if r.Address == id { + return NewReplica(context, r.Address, r.Mode) + } + } + return nil +} + func (s *Server) DeleteReplica(rw http.ResponseWriter, req *http.Request) error { vars := mux.Vars(req) id, err := DencodeID(vars["id"]) diff --git a/controller/rest/router.go b/controller/rest/router.go index 2d57708e..21a6c4e0 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -35,6 +35,7 @@ func NewRouter(s *Server) *mux.Router { router.Methods("GET").Path("/v1/replicas/{id}").Handler(f(schemas, s.GetReplica)) router.Methods("POST").Path("/v1/register").Handler(f(schemas, s.RegisterReplica)) router.Methods("POST").Path("/v1/replicas").Handler(f(schemas, s.CreateReplica)) + router.Methods("POST").Path("/v1/quorumreplicas").Handler(f(schemas, s.CreateQuorumReplica)) router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "preparerebuild").Handler(f(schemas, s.PrepareRebuildReplica)) router.Methods("POST").Path("/v1/replicas/{id}").Queries("action", "verifyrebuild").Handler(f(schemas, s.VerifyRebuildReplica)) router.Methods("DELETE").Path("/v1/replicas/{id}").Handler(f(schemas, s.DeleteReplica)) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index beecf7a6..4544b381 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -165,6 +165,10 @@ func (d DataProcessorWrapper) PingResponse() error { return nil } +func (d DataProcessorWrapper) Update() error { + return nil +} + func (t *Tgt) getDev() string { return filepath.Join(DevPath, t.Volume) } diff --git a/replica/backup_test.go b/replica/backup_test.go index 7cd9f258..b5edfee8 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -21,7 +21,7 @@ func (s *TestSuite) TestBackup(c *C) { err = os.Chdir(dir) c.Assert(err, IsNil) - r, err := New(10*mb, bs, dir, nil) + r, err := New(10*mb, bs, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -84,7 +84,7 @@ func (s *TestSuite) testBackupWithBackups(c *C, backingFile *BackingFile) { c.Assert(err, IsNil) volume := "test" - r, err := New(10*mb, bs, dir, backingFile) + r, err := New(10*mb, bs, dir, backingFile, "Backend") c.Assert(err, IsNil) defer r.Close() diff --git a/replica/peer_counter.go b/replica/peer_counter.go deleted file mode 100644 index 259c2169..00000000 --- a/replica/peer_counter.go +++ /dev/null @@ -1,124 +0,0 @@ -package replica - -import ( - "fmt" - "io" - "os" - "strconv" - "strings" - - "github.com/Sirupsen/logrus" - "github.com/rancher/sparse-tools/sparse" -) - -const ( - peerCounterFile = "peer.counter" - peerFileMode os.FileMode = 0600 - peerBlockSize = 4096 -) - -func (r *Replica) readPeerCounter() (int64, error) { - if r.peerFile == nil { - return 0, fmt.Errorf("BUG: peer file wasn't initialized") - } - - buf := make([]byte, peerBlockSize) - _, err := r.peerFile.ReadAt(buf, 0) - if err != nil && err != io.EOF { - return 0, fmt.Errorf("fail to read from peer counter file: %v", err) - } - counter, err := strconv.ParseInt(strings.Trim(string(buf), "\x00"), 10, 64) - if err != nil { - return 0, fmt.Errorf("fail to parse peer counter file: %v", err) - } - return counter, nil -} - -func (r *Replica) writePeerCounter(counter int64) error { - if r.peerFile == nil { - return fmt.Errorf("BUG: peer file wasn't initialized") - } - - buf := make([]byte, peerBlockSize) - copy(buf, []byte(strconv.FormatInt(counter, 10))) - _, err := r.peerFile.WriteAt(buf, 0) - if err != nil { - return fmt.Errorf("fail to write to peer counter file: %v", err) - } - return nil -} - -func (r *Replica) openPeerFile(isCreate bool) error { - var err error - r.peerFile, err = sparse.NewDirectFileIoProcessor(r.diskPath(peerCounterFile), os.O_RDWR, peerFileMode, isCreate) - return err -} - -func (r *Replica) initPeerCounter() error { - r.peerLock.Lock() - defer r.peerLock.Unlock() - - if _, err := os.Stat(r.diskPath(peerCounterFile)); err != nil { - if !os.IsNotExist(err) { - return err - } - // file doesn't exist yet - if err := r.openPeerFile(true); err != nil { - return err - } - if err := r.writePeerCounter(0); err != nil { - return err - } - } else if err := r.openPeerFile(false); err != nil { - return err - } - - counter, err := r.readPeerCounter() - if err != nil { - return err - } - // Don't use r.peerCache directly - // r.peerCache is an internal cache, to avoid read from disk - // everytime when counter needs to be updated. - // And it's protected by peerLock - r.peerCache = counter - return nil -} - -func (r *Replica) GetPeerCounter() int64 { - r.peerLock.Lock() - defer r.peerLock.Unlock() - - counter, err := r.readPeerCounter() - if err != nil { - logrus.Error("Fail to get peer counter: ", err) - // -1 will result in the replica to be discarded - return -1 - } - r.peerCache = counter - return counter -} - -func (r *Replica) SetPeerCounter(counter int64) error { - r.peerLock.Lock() - defer r.peerLock.Unlock() - - if err := r.writePeerCounter(counter); err != nil { - return err - } - - r.peerCache = counter - return nil -} - -func (r *Replica) increasePeerCounter() error { - r.peerLock.Lock() - defer r.peerLock.Unlock() - - if err := r.writePeerCounter(r.peerCache + 1); err != nil { - return err - } - - r.peerCache++ - return nil -} diff --git a/replica/peer_details.go b/replica/peer_details.go new file mode 100644 index 00000000..29337572 --- /dev/null +++ b/replica/peer_details.go @@ -0,0 +1,102 @@ +package replica + +import ( + "fmt" + "os" + + "github.com/Sirupsen/logrus" + "github.com/rancher/longhorn/types" + "github.com/rancher/sparse-tools/sparse" +) + +const ( + peerDetailsFile = "peer.details" + peerFilMode os.FileMode = 0600 +) + +func (r *Replica) readPeerDetails() (types.PeerDetails, error) { + if r.peerFile == nil { + return types.PeerDetails{}, fmt.Errorf("BUG: peer file wasn't initialized") + } + var peerDetails types.PeerDetails + + if err := r.unmarshalFile(peerDetailsFile, &peerDetails); err != nil { + return types.PeerDetails{}, err + } + + return peerDetails, nil +} + +func (r *Replica) writePeerDetails(peerDetails types.PeerDetails) error { + if r.peerFile == nil { + return fmt.Errorf("BUG: peer file wasn't initialized") + } + if err := r.encodeToFile(&peerDetails, peerDetailsFile); err != nil { + return err + } + return nil +} + +func (r *Replica) openPeerFile(isCreate bool) error { + var err error + r.peerFile, err = sparse.NewDirectFileIoProcessor(r.diskPath(peerDetailsFile), os.O_RDWR, peerFilMode, isCreate) + return err +} + +func (r *Replica) initPeerDetails() error { + var peerDetails types.PeerDetails + r.peerLock.Lock() + defer r.peerLock.Unlock() + + if _, err := os.Stat(r.diskPath(peerDetailsFile)); err != nil { + if !os.IsNotExist(err) { + return err + } + // file doesn't exist yet + if err := r.openPeerFile(true); err != nil { + return err + } + if err := r.writePeerDetails(peerDetails); err != nil { + return err + } + } else if err := r.openPeerFile(false); err != nil { + return err + } + + peerDetails, err := r.readPeerDetails() + if err != nil { + return err + } + // Don't use r.peerCache directly + // r.peerCache is an internal cache, to avoid read from disk + // everytime when counter needs to be updated. + // And it's protected by peerLock + r.peerCache = peerDetails + return nil +} + +func (r *Replica) GetPeerDetails() (types.PeerDetails, error) { + r.peerLock.Lock() + defer r.peerLock.Unlock() + + peerDetails, err := r.readPeerDetails() + if err != nil { + logrus.Error("Fail to get peerDetails: ", err) + // -1 will result in the replica to be discarded + return types.PeerDetails{}, err + } + r.peerCache = peerDetails + return peerDetails, nil +} + +func (r *Replica) UpdatePeerDetails(peerDetails types.PeerDetails) error { + r.peerLock.Lock() + defer r.peerLock.Unlock() + + if err := r.writePeerDetails(peerDetails); err != nil { + return err + } + + r.peerCache = peerDetails + return nil +} diff --git a/replica/replica.go b/replica/replica.go index 8ccb80c9..b9809761 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -43,6 +43,7 @@ type Replica struct { volume diffDisk dir string ReplicaStartTime time.Time + ReplicaType string info Info diskData map[string]*disk diskChildrenMap map[string]map[string]bool @@ -54,7 +55,7 @@ type Replica struct { revisionFile *sparse.DirectFileIoProcessor peerLock sync.Mutex - peerCache int64 + peerCache types.PeerDetails peerFile *sparse.DirectFileIoProcessor } @@ -118,7 +119,7 @@ func CreateTempReplica() (*Replica, error) { if err := r.initRevisionCounter(); err != nil { return nil, err } - if err := r.initPeerCounter(); err != nil { + if err := r.initPeerDetails(); err != nil { return nil, err } return r, nil @@ -130,16 +131,16 @@ func ReadInfo(dir string) (Info, error) { return info, err } -func New(size, sectorSize int64, dir string, backingFile *BackingFile) (*Replica, error) { - return construct(false, size, sectorSize, dir, "", backingFile) +func New(size, sectorSize int64, dir string, backingFile *BackingFile, replicaType string) (*Replica, error) { + return construct(false, size, sectorSize, dir, "", backingFile, replicaType) } func NewReadOnly(dir, head string, backingFile *BackingFile) (*Replica, error) { // size and sectorSize don't matter because they will be read from metadata - return construct(true, 0, 512, dir, head, backingFile) + return construct(true, 0, 512, dir, head, backingFile, "") } -func construct(readonly bool, size, sectorSize int64, dir, head string, backingFile *BackingFile) (*Replica, error) { +func construct(readonly bool, size, sectorSize int64, dir, head string, backingFile *BackingFile, replicaType string) (*Replica, error) { if size%sectorSize != 0 { return nil, fmt.Errorf("Size %d not a multiple of sector size %d", size, sectorSize) } @@ -172,7 +173,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF return nil, err } - if err := r.initPeerCounter(); err != nil { + if err := r.initPeerDetails(); err != nil { return nil, err } @@ -208,6 +209,7 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF r.info.Parent = r.diskData[r.info.Head].Parent r.insertBackingFile() + r.ReplicaType = replicaType return r, r.writeVolumeMetaData(true, r.info.Rebuilding) } @@ -281,7 +283,7 @@ func (r *Replica) Resize(size string) error { } func (r *Replica) Reload() (*Replica, error) { - newReplica, err := New(r.info.Size, r.info.SectorSize, r.dir, r.info.BackingFile) + newReplica, err := New(r.info.Size, r.info.SectorSize, r.dir, r.info.BackingFile, r.ReplicaType) if err != nil { return nil, err } @@ -932,16 +934,22 @@ func (r *Replica) Revert(name, created string) (*Replica, error) { } func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { + var ( + c int + err error + ) if r.readOnly { return 0, fmt.Errorf("Can not write on read-only replica") } - r.RLock() - r.info.Dirty = true - c, err := r.volume.WriteAt(buf, offset) - r.RUnlock() - if err != nil { - return c, err + if r.ReplicaType != "quorum" { + r.RLock() + r.info.Dirty = true + c, err = r.volume.WriteAt(buf, offset) + r.RUnlock() + if err != nil { + return c, err + } } if err := r.increaseRevisionCounter(); err != nil { return c, err @@ -949,6 +957,20 @@ func (r *Replica) WriteAt(buf []byte, offset int64) (int, error) { return c, nil } +/* +func (r *Replica) Update() error { + if r.readOnly { + return fmt.Errorf("Can not write on read-only replica") + } + + r.info.Dirty = true + if err := r.increaseRevisionCounter(); err != nil { + return err + } + return nil +} +*/ + func (r *Replica) ReadAt(buf []byte, offset int64) (int, error) { r.RLock() c, err := r.volume.ReadAt(buf, offset) diff --git a/replica/replica_test.go b/replica/replica_test.go index b26920d2..9b88e4b3 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -30,7 +30,7 @@ func (s *TestSuite) TestCreate(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() } @@ -46,7 +46,7 @@ func (s *TestSuite) TestSnapshot(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -127,7 +127,7 @@ func (s *TestSuite) TestRevert(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -239,7 +239,7 @@ func (s *TestSuite) TestRemoveLeafNode(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -314,7 +314,7 @@ func (s *TestSuite) TestRemoveLast(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -360,7 +360,7 @@ func (s *TestSuite) TestRemoveMiddle(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -406,7 +406,7 @@ func (s *TestSuite) TestRemoveFirst(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -437,7 +437,7 @@ func (s *TestSuite) TestRemoveOutOfChain(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -513,7 +513,7 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9, 3, dir, nil) + r, err := New(9, 3, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -642,7 +642,7 @@ func (s *TestSuite) TestRead(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9*b, b, dir, nil) + r, err := New(9*b, b, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -657,7 +657,7 @@ func (s *TestSuite) TestWrite(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(9*b, b, dir, nil) + r, err := New(9*b, b, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -679,7 +679,7 @@ func (s *TestSuite) TestSnapshotReadWrite(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(dir) - r, err := New(3*b, b, dir, nil) + r, err := New(3*b, b, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -739,7 +739,7 @@ func (s *TestSuite) TestBackingFile(c *C) { Disk: f, } - r, err := New(3*b, b, dir, backing) + r, err := New(3*b, b, dir, backing, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -772,7 +772,7 @@ func (s *TestSuite) partialWriteRead(c *C, totalLength, writeLength, writeOffset buf := make([]byte, totalLength) fill(buf, 3) - r, err := New(totalLength, b, dir, nil) + r, err := New(totalLength, b, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() @@ -820,7 +820,7 @@ func (s *TestSuite) testPartialRead(c *C, totalLength int64, readBuf []byte, off buf := make([]byte, totalLength) fill(buf, 3) - r, err := New(totalLength, b, dir, nil) + r, err := New(totalLength, b, dir, nil, "Backend") c.Assert(err, IsNil) defer r.Close() diff --git a/replica/rest/model.go b/replica/rest/model.go index f608759c..815aff91 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -90,6 +90,12 @@ type ReplicaCounter struct { Counter int64 `json:"counter"` } +type PeerDetails struct { + client.Resource + ReplicaCount int64 `json:"replicacount"` + QuorumReplicaCount int64 `json:"quorumreplicacount"` +} + type Action struct { client.Resource Value string `json:"Action"` @@ -117,6 +123,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["start"] = true actions["resize"] = true actions["close"] = true + actions["resize"] = true actions["setrebuilding"] = true actions["snapshot"] = true actions["reload"] = true @@ -126,6 +133,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["prepareremovedisk"] = true actions["setrevisioncounter"] = true actions["setreplicacounter"] = true + actions["updatepeerdetails"] = true case replica.Closed: actions["start"] = true actions["open"] = true @@ -147,6 +155,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["revert"] = true actions["prepareremovedisk"] = true actions["setreplicacounter"] = true + actions["updatepeerdetails"] = true case replica.Rebuilding: actions["start"] = true actions["resize"] = true @@ -156,6 +165,7 @@ func NewReplica(context *api.ApiContext, state replica.State, info replica.Info, actions["reload"] = true actions["setrevisioncounter"] = true actions["setreplicacounter"] = true + actions["updatepeerdetails"] = true case replica.Error: } diff --git a/replica/rest/replica.go b/replica/rest/replica.go index e2119969..e680e5e6 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -220,11 +220,15 @@ func (s *Server) SetRevisionCounter(rw http.ResponseWriter, req *http.Request) e return s.doOp(req, s.s.SetRevisionCounter(input.Counter)) } -func (s *Server) SetReplicaCounter(rw http.ResponseWriter, req *http.Request) error { - var input ReplicaCounter +func (s *Server) UpdatePeerDetails(rw http.ResponseWriter, req *http.Request) error { + var input PeerDetails + var details types.PeerDetails apiContext := api.GetApiContext(req) if err := apiContext.Read(&input); err != nil && err != io.EOF { return err } - return s.doOp(req, s.s.SetReplicaCounter(input.Counter)) + details.ReplicaCount = input.ReplicaCount + details.QuorumReplicaCount = input.QuorumReplicaCount + + return s.doOp(req, s.s.UpdatePeerDetails(details)) } diff --git a/replica/rest/router.go b/replica/rest/router.go index a7af2728..b39da680 100644 --- a/replica/rest/router.go +++ b/replica/rest/router.go @@ -67,7 +67,7 @@ func NewRouter(s *Server) *mux.Router { "revert": s.RevertReplica, "prepareremovedisk": s.PrepareRemoveDisk, "setrevisioncounter": s.SetRevisionCounter, - "setreplicacounter": s.SetReplicaCounter, + "updatepeerdetails": s.UpdatePeerDetails, } for name, action := range actions { diff --git a/replica/server.go b/replica/server.go index d5d9c2d3..c85c37fe 100644 --- a/replica/server.go +++ b/replica/server.go @@ -28,13 +28,14 @@ var StartTime time.Time type Server struct { sync.RWMutex r *Replica + ServerType string dir string defaultSectorSize int64 backing *BackingFile MonitorChannel chan struct{} } -func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { +func NewServer(dir string, backing *BackingFile, sectorSize int64, serverType string) *Server { ActionChannel = make(chan string, 5) Dir = dir StartTime = time.Now() @@ -42,6 +43,7 @@ func NewServer(dir string, backing *BackingFile, sectorSize int64) *Server { dir: dir, backing: backing, defaultSectorSize: sectorSize, + ServerType: serverType, } } @@ -80,7 +82,7 @@ func (s *Server) Create(size int64) error { sectorSize := s.getSectorSize() logrus.Infof("Creating volume %s, size %d/%d", s.dir, size, sectorSize) - r, err := New(size, sectorSize, s.dir, s.backing) + r, err := New(size, sectorSize, s.dir, s.backing, s.ServerType) if err != nil { return err } @@ -101,9 +103,8 @@ func (s *Server) Open() error { sectorSize := s.getSectorSize() logrus.Infof("Opening volume %s, size %d/%d", s.dir, size, sectorSize) - r, err := New(size, sectorSize, s.dir, s.backing) + r, err := New(size, sectorSize, s.dir, s.backing, s.ServerType) if err != nil { - fmt.Println("ERROR OPENING VOLUME") return err } s.r = r @@ -154,7 +155,7 @@ func (s *Server) Stats() *types.Stats { r := s.r return &types.Stats{ RevisionCounter: r.revisionCache, - ReplicaCounter: r.peerCache, + ReplicaCounter: r.peerCache.ReplicaCount, } } @@ -295,6 +296,19 @@ func (s *Server) WriteAt(buf []byte, offset int64) (int, error) { return i, err } +/* +func (s *Server) Update() error { + s.RLock() + defer s.RUnlock() + + if s.r == nil { + return fmt.Errorf("Volume no longer exist") + } + err := s.r.Update() + return err +} +*/ + func (s *Server) ReadAt(buf []byte, offset int64) (int, error) { s.RLock() defer s.RUnlock() @@ -316,14 +330,15 @@ func (s *Server) SetRevisionCounter(counter int64) error { return s.r.SetRevisionCounter(counter) } -func (s *Server) SetReplicaCounter(counter int64) error { +func (s *Server) UpdatePeerDetails(peerDetails types.PeerDetails) error { + s.Lock() defer s.Unlock() if s.r == nil { return nil } - return s.r.SetPeerCounter(counter) + return s.r.UpdatePeerDetails(peerDetails) } func (s *Server) PingResponse() error { diff --git a/rpc/client.go b/rpc/client.go index a2a73350..ecebecc5 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -15,10 +15,27 @@ var ( ErrRWTimeout = errors.New("r/w timeout") ErrPingTimeout = errors.New("Ping timeout") - opRetries = 4 - opReadTimeout = 15 * time.Second // client read - opWriteTimeout = 15 * time.Second // client write - opPingTimeout = 20 * time.Second + opRetries = 4 + opReadTimeout = 15 * time.Second // client read + opWriteTimeout = 15 * time.Second // client write + opPingTimeout = 20 * time.Second + opUpdateTimeout = 15 * time.Second // client update +) + +//SampleOp operation +type SampleOp int + +const ( + // OpNone unitialized operation + OpNone SampleOp = iota + // OpRead read from replica + OpRead + // OpWrite write to replica + OpWrite + // OpPing ping replica + OpPing + // OpUpdate update replica + OpUpdate ) //Client replica client @@ -61,6 +78,13 @@ func (c *Client) WriteAt(buf []byte, offset int64) (int, error) { return c.operation(TypeWrite, buf, offset) } +/* +//Update Quorum replica client +func (c *Client) Update() (int, error) { + return c.operation(TypeUpdate, nil, 0) +} +*/ + //SetError replica client transport error func (c *Client) SetError(err error) { c.responses <- &Message{ @@ -95,7 +119,12 @@ func (c *Client) operation(op uint32, buf []byte, offset int64) (int, error) { return time.After(opReadTimeout) case TypeWrite: return time.After(opWriteTimeout) + /* + case TypeUpdate: + return time.After(opUpdateTimeout) + */ } + return time.After(opPingTimeout) }(msg.Type) @@ -172,11 +201,13 @@ func (c *Client) replyError(req *Message) { func (c *Client) handleRequest(req *Message) { switch req.Type { case TypeRead: - req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpRead, len(req.Data)) + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.SampleOp(OpRead), len(req.Data)) case TypeWrite: - req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpWrite, len(req.Data)) + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.SampleOp(OpWrite), len(req.Data)) case TypePing: - req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.OpPing, 0) + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.SampleOp(OpPing), 0) + case TypeUpdate: + req.ID = journal.InsertPendingOp(time.Now(), c.TargetID(), journal.SampleOp(OpUpdate), 0) } if c.err != nil { c.replyError(req) diff --git a/rpc/server.go b/rpc/server.go index 5ccb6625..c10f1cb7 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -62,6 +62,10 @@ func (s *Server) readFromWire(ret chan<- error) { go s.handleWrite(msg) case TypePing: go s.handlePing(msg) + /* + case TypeUpdate: + go s.handleUpdate(msg) + */ } ret <- nil } @@ -103,6 +107,13 @@ func (s *Server) handlePing(msg *Message) { s.pushResponse(0, msg, err) } +/* +func (s *Server) handleUpdate(msg *Message) { + err := s.data.Update() + s.pushResponse(0, msg, err) +} +*/ + func (s *Server) pushResponse(count int, msg *Message, err error) { msg.MagicVersion = MagicVersion msg.Type = TypeResponse diff --git a/rpc/types.go b/rpc/types.go index 56127705..3b58fe3b 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -10,6 +10,7 @@ const ( TypeEOF TypeClose TypePing + TypeUpdate messageSize = (32 + 32 + 32 + 64) / 8 //TODO: unused? readBufferSize = 8096 diff --git a/sync/sync.go b/sync/sync.go index 21536c06..8cc1a298 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -171,6 +171,40 @@ func find(list []string, item string) int { return -1 } +func (t *Task) AddQuorumReplica(replicaAddress string) error { + ticker := time.NewTicker(5 * time.Second) + defer ticker.Stop() +Register: + volume, err := t.client.GetVolume() + if err != nil { + return err + } + addr := strings.Split(replicaAddress, "://") + parts := strings.Split(addr[1], ":") + Replica, _ := replica.CreateTempReplica() + + if volume.ReplicaCount == 0 { + revisionCount := Replica.GetRevisionCounter() + peerDetails, _ := Replica.GetPeerDetails() + replicaType := "quorum" + upTime := time.Since(Replica.ReplicaStartTime) + _ = t.client.Register(parts[0], revisionCount, peerDetails, replicaType, upTime) + select { + case <-ticker.C: + goto Register + case _ = <-replica.ActionChannel: + } + } + + logrus.Infof("Adding quorum replica %s in WO mode", replicaAddress) + _, err = t.client.CreateQuorumReplica(replicaAddress) + if err != nil { + return err + } + + return nil +} + func (t *Task) AddReplica(replicaAddress string) error { var action string ticker := time.NewTicker(5 * time.Second) @@ -186,9 +220,10 @@ Register: if volume.ReplicaCount == 0 { revisionCount := Replica.GetRevisionCounter() - replicaCount := Replica.GetPeerCounter() + peerDetails, _ := Replica.GetPeerDetails() + replicaType := "Backend" upTime := time.Since(Replica.ReplicaStartTime) - t.client.Register(parts[0], revisionCount, replicaCount, upTime) + t.client.Register(parts[0], revisionCount, peerDetails, replicaType, upTime) select { case <-ticker.C: goto Register diff --git a/types/types.go b/types/types.go index 62ec0cfb..33d9681c 100644 --- a/types/types.go +++ b/types/types.go @@ -37,7 +37,8 @@ type Backend interface { RemainSnapshots() (int, error) GetRevisionCounter() (int64, error) SetRevisionCounter(counter int64) error - SetReplicaCounter(counter int64) error + UpdatePeerDetails(replicaCount int64, quorumReplicaCount int64) error + SetRebuilding(rebuilding bool) error GetMonitorChannel() MonitorChannel StopMonitoring() } @@ -71,10 +72,11 @@ type Replica struct { } type RegReplica struct { - Address string - UpTime time.Duration - RevCount int64 - RepCount int64 + Address string + UpTime time.Duration + RevCount int64 + RepType string + PeerDetail PeerDetails } type IOStats struct { @@ -100,6 +102,12 @@ type Stats struct { } type Interface interface{} + +type PeerDetails struct { + ReplicaCount int64 + QuorumReplicaCount int64 +} + type Frontend interface { Startup(name string, frontendIP string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error @@ -110,4 +118,5 @@ type Frontend interface { type DataProcessor interface { ReaderWriterAt PingResponse() error + //Update() error } From de7094a19f14fc8689cdeddc1a628ec1faa3351a Mon Sep 17 00:00:00 2001 From: Payes Date: Tue, 13 Jun 2017 16:41:15 +0530 Subject: [PATCH 346/357] Resize: Update volume size in frontend --- controller/control.go | 14 +++++++++++++- frontend/gotgt/frontend.go | 9 +++++++++ frontend/rest/frontend.go | 4 ++++ frontend/tcmu/frontend.go | 3 +++ frontend/tgt/frontend.go | 3 +++ replica/replica.go | 25 ++++++++++++++++++------- replica/server.go | 1 + types/types.go | 1 + vendor.conf | 2 +- 9 files changed, 53 insertions(+), 9 deletions(-) diff --git a/controller/control.go b/controller/control.go index d22ff5de..9887ae8e 100644 --- a/controller/control.go +++ b/controller/control.go @@ -308,7 +308,19 @@ func (c *Controller) Resize(name string, size string) error { } else if sizeInBytes == c.size { return fmt.Errorf("Volume size same as size mentioned") } - return c.handleErrorNoLock(c.backend.Resize(name, size)) + err = c.handleErrorNoLock(c.backend.Resize(name, size)) + if err != nil { + return err + } + + if c.frontend != nil { + err = c.frontend.Resize(uint64(sizeInBytes)) + if err != nil { + return err + } + } + c.size = sizeInBytes + return nil } func (c *Controller) addQuorumReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error { diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index 139f8c18..ad7e7f6f 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -1,6 +1,8 @@ package gotgt import ( + "fmt" + "github.com/Sirupsen/logrus" "github.com/rancher/longhorn/types" @@ -103,6 +105,13 @@ func (t *goTgt) Stats() types.Stats { return (types.Stats)(t.targetDriver.Stats()) } +func (t *goTgt) Resize(size uint64) error { + if !t.isUp { + return fmt.Errorf("Volume is not up") + } + return t.targetDriver.Resize(size) +} + func (t *goTgt) startScsiTarget(cfg *config.Config) error { scsiTarget := scsi.NewSCSITargetService() var err error diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go index 137c65aa..cf3a8962 100644 --- a/frontend/rest/frontend.go +++ b/frontend/rest/frontend.go @@ -74,3 +74,7 @@ func (d *Device) State() types.State { func (d *Device) Stats() types.Stats { return types.Stats{} } + +func (d *Device) Resize(size uint64) error { + return nil +} diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index da59ed00..86f3d241 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -75,6 +75,9 @@ func (t *Tcmu) Stats() types.Stats { return types.Stats{} } +func (t *Tcmu) Resize(size uint64) error { + return nil +} func PreEnableTcmu(volume string, size, sectorSize int64) error { err := writeLines(path.Join(configDir, volume, "control"), []string{ fmt.Sprintf("dev_size=%d", size), diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 4544b381..2b673ab6 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -91,6 +91,9 @@ func (t *Tgt) Stats() types.Stats { return types.Stats{} } +func (t *Tgt) Resize(size uint64) error { + return nil +} func (t *Tgt) getSocketPath() string { if t.Volume == "" { panic("Invalid volume name") diff --git a/replica/replica.go b/replica/replica.go index b9809761..7a703b3d 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -168,7 +168,6 @@ func construct(readonly bool, size, sectorSize int64, dir, head string, backingF if err != nil { return nil, err } - if err := r.initRevisionCounter(); err != nil { return nil, err } @@ -258,19 +257,28 @@ func (r *Replica) SetRebuilding(rebuilding bool) error { return nil } -func (r *Replica) Resize(size string) error { +func (r *Replica) Resize(obj interface{}) error { var sizeInBytes int64 chain, err := r.Chain() if err != nil { return err } - if size != "" { - sizeInBytes, err = units.RAMInBytes(size) - if err != nil { - return err + switch obj.(type) { + case string: + if obj != "" { + sizeInBytes, err = units.RAMInBytes(obj.(string)) + if err != nil { + return err + } + } + case int64: + if obj != 0 { + sizeInBytes = obj.(int64) + } else { + return nil } } - if r.info.Size <= sizeInBytes { + if r.info.Size > sizeInBytes { return fmt.Errorf("Previous size %d is greater than %d", r.info.Size, sizeInBytes) } for _, file := range chain { @@ -279,6 +287,9 @@ func (r *Replica) Resize(size string) error { } } r.info.Size = sizeInBytes + if err := r.encodeToFile(&r.info, volumeMetaData); err != nil { + return err + } return nil } diff --git a/replica/server.go b/replica/server.go index c85c37fe..5d0781a5 100644 --- a/replica/server.go +++ b/replica/server.go @@ -74,6 +74,7 @@ func (s *Server) Create(size int64) error { defer s.Unlock() state, _ := s.Status() + if state != Initial { return nil } diff --git a/types/types.go b/types/types.go index 33d9681c..a945678f 100644 --- a/types/types.go +++ b/types/types.go @@ -113,6 +113,7 @@ type Frontend interface { Shutdown() error State() State Stats() Stats + Resize(uint64) error } type DataProcessor interface { diff --git a/vendor.conf b/vendor.conf index c7ea5d7f..e3591bd4 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt de50a533c2db559ee93864c1506151a523608949 +github.com/openebs/gotgt e86615913ba9c066be23860b5c1182c7fb585bc8 From 640f1e71d2804f0605ce82f96f70b87b7e2b6e69 Mon Sep 17 00:00:00 2001 From: Payes Date: Tue, 13 Jun 2017 16:55:01 +0530 Subject: [PATCH 347/357] Change default listen address of replica from localhost to all IPs --- app/replica.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/replica.go b/app/replica.go index 2fbba646..8aa6de3d 100644 --- a/app/replica.go +++ b/app/replica.go @@ -26,7 +26,7 @@ func ReplicaCmd() cli.Command { Flags: []cli.Flag{ cli.StringFlag{ Name: "listen", - Value: "localhost:9502", + Value: ":9502", }, cli.StringFlag{ Name: "frontendIP", From 2504c04124df068594947d9069676268f19f8b40 Mon Sep 17 00:00:00 2001 From: Payes Date: Tue, 13 Jun 2017 18:20:06 +0530 Subject: [PATCH 348/357] Listen on replica's host IP if listener IP is not passed to replica as argument --- app/replica.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/replica.go b/app/replica.go index 8aa6de3d..8952fb76 100644 --- a/app/replica.go +++ b/app/replica.go @@ -2,6 +2,7 @@ package app import ( "errors" + "net" "net/http" "os" "os/exec" @@ -118,6 +119,21 @@ func startReplica(c *cli.Context) error { } } + if address == ":9502" { + host, _ := os.Hostname() + addrs, _ := net.LookupIP(host) + for _, addr := range addrs { + if ipv4 := addr.To4(); ipv4 != nil { + address = ipv4.String() + if address == "127.0.0.1" { + address = address + ":9502" + continue + } + address = address + ":9502" + break + } + } + } controlAddress, dataAddress, syncAddress, err := util.ParseAddresses(address) if err != nil { return err @@ -165,6 +181,9 @@ func startReplica(c *cli.Context) error { }() } if frontendIP != "" { + if address == ":9502" { + address = "localhost:9502" + } go AutoConfigureReplica(s, frontendIP, "tcp://"+address, replicaType) } From c88f7012a0b1a16c0f95ce6f57933ba5365200b4 Mon Sep 17 00:00:00 2001 From: Payes Date: Tue, 13 Jun 2017 21:53:07 +0530 Subject: [PATCH 349/357] Start iSCSI Target on controller's host IP if frontendIP is not passed to controller as argument --- frontend/gotgt/frontend.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index ad7e7f6f..32c4a450 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -2,6 +2,8 @@ package gotgt import ( "fmt" + "net" + "os" "github.com/Sirupsen/logrus" @@ -39,6 +41,20 @@ func (t *goTgt) Startup(name string, frontendIP string, size, sectorSize int64, return err }*/ + if frontendIP == "" { + host, _ := os.Hostname() + addrs, _ := net.LookupIP(host) + for _, addr := range addrs { + if ipv4 := addr.To4(); ipv4 != nil { + frontendIP = ipv4.String() + if frontendIP == "127.0.0.1" { + continue + } + break + } + } + } + t.tgtName = "iqn.2016-09.com.openebs.jiva:" + name t.lhbsName = "RemBs:" + name t.cfg = &config.Config{ From 4a4cd2c2cdd5103842a711bc1c1fd1cb8916005e Mon Sep 17 00:00:00 2001 From: Payes Date: Wed, 14 Jun 2017 15:58:49 +0530 Subject: [PATCH 350/357] Initial support for having LB/NAT infront of controller --- app/controller.go | 9 +++++++-- controller/control.go | 6 ++++-- frontend/gotgt/frontend.go | 5 ++++- frontend/rest/frontend.go | 2 +- frontend/tcmu/frontend.go | 2 +- frontend/tgt/frontend.go | 2 +- types/types.go | 2 +- vendor.conf | 2 +- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/controller.go b/app/controller.go index 3e84a35e..b041481e 100644 --- a/app/controller.go +++ b/app/controller.go @@ -39,6 +39,10 @@ func ControllerCmd() cli.Command { Name: "frontendIP", Value: "", }, + cli.StringFlag{ + Name: "clusterIP", + Value: "", + }, cli.StringSliceFlag{ Name: "enable-backend", Value: (*cli.StringSlice)(&[]string{"tcp"}), @@ -56,7 +60,7 @@ func ControllerCmd() cli.Command { } func startController(c *cli.Context) error { - var frontendIP string + var frontendIP, clusterIP string var controlListener string if c.NArg() == 0 { return errors.New("volume name is required") @@ -72,6 +76,7 @@ func startController(c *cli.Context) error { frontendName := c.String("frontend") if frontendName == "gotgt" { frontendIP = c.String("frontendIP") + clusterIP = c.String("clusterIP") } controlListener = c.String("listen") factories := map[string]types.BackendFactory{} @@ -95,7 +100,7 @@ func startController(c *cli.Context) error { frontend = f } - control := controller.NewController(name, frontendIP, dynamic.New(factories), frontend) + control := controller.NewController(name, frontendIP, clusterIP, dynamic.New(factories), frontend) server := rest.NewServer(control) router := http.Handler(rest.NewRouter(server)) diff --git a/controller/control.go b/controller/control.go index 9887ae8e..fa2ef2d7 100644 --- a/controller/control.go +++ b/controller/control.go @@ -16,6 +16,7 @@ type Controller struct { sync.RWMutex Name string frontendIP string + clusterIP string size int64 sectorSize int64 replicas []types.Replica @@ -33,12 +34,13 @@ type Controller struct { ReadOnly bool } -func NewController(name string, frontendIP string, factory types.BackendFactory, frontend types.Frontend) *Controller { +func NewController(name string, frontendIP string, clusterIP string, factory types.BackendFactory, frontend types.Frontend) *Controller { c := &Controller{ factory: factory, Name: name, frontend: frontend, frontendIP: frontendIP, + clusterIP: clusterIP, RegisteredReplicas: map[string]types.RegReplica{}, RegisteredQuorumReplicas: map[string]types.RegReplica{}, StartTime: time.Now(), @@ -515,7 +517,7 @@ func (c *Controller) setReplicaModeNoLock(address string, mode types.Mode) { func (c *Controller) startFrontend() error { if len(c.replicas) > 0 && c.frontend != nil { - if err := c.frontend.Startup(c.Name, c.frontendIP, c.size, c.sectorSize, c); err != nil { + if err := c.frontend.Startup(c.Name, c.frontendIP, c.clusterIP, c.size, c.sectorSize, c); err != nil { // FATAL logrus.Fatalf("Failed to start up frontend: %v", err) // This will never be reached diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index 32c4a450..ef443659 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -31,12 +31,13 @@ type goTgt struct { tgtName string lhbsName string + clusterIP string cfg *config.Config targetDriver port.SCSITargetService stats port.Stats } -func (t *goTgt) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *goTgt) Startup(name string, frontendIP string, clusterIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { /*if err := t.Shutdown(); err != nil { return err }*/ @@ -87,6 +88,7 @@ func (t *goTgt) Startup(name string, frontendIP string, size, sectorSize int64, t.Size = size t.SectorSize = int(sectorSize) t.rw = rw + t.clusterIP = clusterIP if err := t.startScsiTarget(t.cfg); err != nil { return err } @@ -138,6 +140,7 @@ func (t *goTgt) startScsiTarget(cfg *config.Config) error { } scsi.InitSCSILUMapEx(t.tgtName, t.Volume, 1, 1, uint64(t.Size), uint64(t.SectorSize), t.rw) t.targetDriver.NewTarget(t.tgtName, cfg) + t.targetDriver.SetClusterIP(t.clusterIP) go t.targetDriver.Run() logrus.Infof("SCSI device created") diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go index cf3a8962..77866446 100644 --- a/frontend/rest/frontend.go +++ b/frontend/rest/frontend.go @@ -26,7 +26,7 @@ func New() types.Frontend { return &Device{} } -func (d *Device) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (d *Device) Startup(name string, frontendIP string, clusterIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { d.Name = name d.backend = rw d.Size = size diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index 86f3d241..9a1bf578 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -36,7 +36,7 @@ type Tcmu struct { stats map[int]int64 } -func (t *Tcmu) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *Tcmu) Startup(name string, frontendIP string, clusterIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { t.volume = name t.Shutdown() diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index 2b673ab6..a84ec3c5 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -34,7 +34,7 @@ type Tgt struct { scsiDevice *ScsiDevice } -func (t *Tgt) Startup(name string, frontendIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { +func (t *Tgt) Startup(name string, frontendIP string, clusterIP string, size, sectorSize int64, rw types.ReaderWriterAt) error { t.Volume = name t.Size = size t.SectorSize = int(sectorSize) diff --git a/types/types.go b/types/types.go index a945678f..c66fffe9 100644 --- a/types/types.go +++ b/types/types.go @@ -109,7 +109,7 @@ type PeerDetails struct { } type Frontend interface { - Startup(name string, frontendIP string, size, sectorSize int64, rw ReaderWriterAt) error + Startup(name string, frontendIP string, clusterIP string, size, sectorSize int64, rw ReaderWriterAt) error Shutdown() error State() State Stats() Stats diff --git a/vendor.conf b/vendor.conf index e3591bd4..2eb21588 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt e86615913ba9c066be23860b5c1182c7fb585bc8 +github.com/openebs/gotgt 55164877602ddd26d783170c51989a1a41cf8818 From 0368a3f5cacdc59bb599304cfb0e7757b283710b Mon Sep 17 00:00:00 2001 From: Payes Date: Thu, 15 Jun 2017 02:44:51 +0530 Subject: [PATCH 351/357] Rectify json encoding for stats command --- controller/rest/model.go | 18 +++++++++--------- controller/rest/volume.go | 18 ++++++++++-------- types/types.go | 4 ++-- vendor.conf | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/controller/rest/model.go b/controller/rest/model.go index 2c11c467..7136226c 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -52,15 +52,15 @@ type VolumeStats struct { ReplicaCounter int64 `json:"ReplicaCounter"` SCSIIOCount map[int]int64 `json:"SCSIIOCount"` - ReadIOPS int64 `json:"ReadIOPS"` - ReadThroughput int64 `json:"ReadThroughput"` - ReadLatency int64 `json:"ReadLatency"` - AvgReadBlockSize int64 `json:"AvgReadBlockSize"` - - WriteIOPS int64 `json:"WriteIOPS"` - WriteThroughput int64 `json:"WriteThroughput"` - WriteLatency int64 `json:"WriteLatency"` - AvgWriteBlockSize int64 `json:"AvgWriteBlockSize"` + ReadIOPS string `json:"ReadIOPS"` + ReadThroughput string `json:"ReadThroughput"` + ReadLatency string `json:"ReadLatency"` + AvgReadBlockSize string `json:"AvgReadBlockSize"` + + WriteIOPS string `json:"WriteIOPS"` + WriteThroughput string `json:"WriteThroughput"` + WriteLatency string `json:"WriteLatency"` + AvgWriteBlockSize string `json:"AvgWriteBlockSize"` } type SnapshotInput struct { diff --git a/controller/rest/volume.go b/controller/rest/volume.go index 0d622f31..d504c9fa 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -2,7 +2,9 @@ package rest import ( "net/http" + "strconv" + units "github.com/docker/go-units" "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" @@ -42,15 +44,15 @@ func (s *Server) GetVolumeStats(rw http.ResponseWriter, req *http.Request) error ReplicaCounter: stats.ReplicaCounter, SCSIIOCount: stats.SCSIIOCount, - ReadIOPS: stats.ReadIOPS, - ReadThroughput: stats.ReadThroughput, - ReadLatency: stats.ReadLatency, - AvgReadBlockSize: stats.AvgReadBlockSize, + ReadIOPS: strconv.FormatInt(stats.ReadIOPS, 10), + ReadThroughput: units.HumanSize(float64(stats.ReadThroughput)), + ReadLatency: (stats.ReadLatency).String(), + AvgReadBlockSize: units.HumanSize(float64(stats.AvgReadBlockSize)), - WriteIOPS: stats.WriteIOPS, - WriteThroughput: stats.WriteThroughput, - WriteLatency: stats.WriteLatency, - AvgWriteBlockSize: stats.AvgWriteBlockSize, + WriteIOPS: strconv.FormatInt(stats.WriteIOPS, 10), + WriteThroughput: units.HumanSize(float64(stats.WriteThroughput)), + WriteLatency: (stats.WriteLatency).String(), + AvgWriteBlockSize: units.HumanSize(float64(stats.AvgWriteBlockSize)), } apiContext.Write(volumeStats) return nil diff --git a/types/types.go b/types/types.go index c66fffe9..31df29d7 100644 --- a/types/types.go +++ b/types/types.go @@ -92,12 +92,12 @@ type Stats struct { ReadIOPS int64 ReadThroughput int64 - ReadLatency int64 + ReadLatency time.Duration AvgReadBlockSize int64 WriteIOPS int64 WriteThroughput int64 - WriteLatency int64 + WriteLatency time.Duration AvgWriteBlockSize int64 } diff --git a/vendor.conf b/vendor.conf index 2eb21588..a96ffad1 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt 55164877602ddd26d783170c51989a1a41cf8818 +github.com/openebs/gotgt cf2025c5fab5c3b62b81d93c7a558ce939ea7e4a From 18362ce975d1178cf39d1e260ddb07975124b8f8 Mon Sep 17 00:00:00 2001 From: Payes Date: Thu, 15 Jun 2017 19:33:05 +0530 Subject: [PATCH 352/357] Add support to return cumulative stats --- controller/rest/model.go | 16 +++++++--------- controller/rest/volume.go | 16 ++++++---------- types/types.go | 15 +++++++-------- vendor.conf | 2 +- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/controller/rest/model.go b/controller/rest/model.go index 7136226c..1f33ee94 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -52,15 +52,13 @@ type VolumeStats struct { ReplicaCounter int64 `json:"ReplicaCounter"` SCSIIOCount map[int]int64 `json:"SCSIIOCount"` - ReadIOPS string `json:"ReadIOPS"` - ReadThroughput string `json:"ReadThroughput"` - ReadLatency string `json:"ReadLatency"` - AvgReadBlockSize string `json:"AvgReadBlockSize"` - - WriteIOPS string `json:"WriteIOPS"` - WriteThroughput string `json:"WriteThroughput"` - WriteLatency string `json:"WriteLatency"` - AvgWriteBlockSize string `json:"AvgWriteBlockSize"` + ReadIOPS string `json:"ReadIOPS"` + TotalReadTime string `json:"TotalReadTime"` + TotalReadBlockCount string `json:"TotalReadBlockCount"` + + WriteIOPS string `json:"WriteIOPS"` + TotalWriteTime string `json:"TotalWriteTime"` + TotalWriteBlockCount string `json:"TotatWriteBlockCount"` } type SnapshotInput struct { diff --git a/controller/rest/volume.go b/controller/rest/volume.go index d504c9fa..1a673046 100644 --- a/controller/rest/volume.go +++ b/controller/rest/volume.go @@ -4,7 +4,6 @@ import ( "net/http" "strconv" - units "github.com/docker/go-units" "github.com/gorilla/mux" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" @@ -36,7 +35,6 @@ func (s *Server) GetVolume(rw http.ResponseWriter, req *http.Request) error { func (s *Server) GetVolumeStats(rw http.ResponseWriter, req *http.Request) error { apiContext := api.GetApiContext(req) - // id := mux.Vars(req)["id"] stats := s.c.Stats() volumeStats := &VolumeStats{ Resource: client.Resource{Type: "stats"}, @@ -44,15 +42,13 @@ func (s *Server) GetVolumeStats(rw http.ResponseWriter, req *http.Request) error ReplicaCounter: stats.ReplicaCounter, SCSIIOCount: stats.SCSIIOCount, - ReadIOPS: strconv.FormatInt(stats.ReadIOPS, 10), - ReadThroughput: units.HumanSize(float64(stats.ReadThroughput)), - ReadLatency: (stats.ReadLatency).String(), - AvgReadBlockSize: units.HumanSize(float64(stats.AvgReadBlockSize)), + ReadIOPS: strconv.FormatInt(stats.ReadIOPS, 10), + TotalReadTime: strconv.FormatInt(stats.TotalReadTime, 10), + TotalReadBlockCount: strconv.FormatInt(stats.TotalReadBlockCount, 10), - WriteIOPS: strconv.FormatInt(stats.WriteIOPS, 10), - WriteThroughput: units.HumanSize(float64(stats.WriteThroughput)), - WriteLatency: (stats.WriteLatency).String(), - AvgWriteBlockSize: units.HumanSize(float64(stats.AvgWriteBlockSize)), + WriteIOPS: strconv.FormatInt(stats.WriteIOPS, 10), + TotalWriteTime: strconv.FormatInt(stats.TotalWriteTime, 10), + TotalWriteBlockCount: strconv.FormatInt(stats.TotalWriteBlockCount, 10), } apiContext.Write(volumeStats) return nil diff --git a/types/types.go b/types/types.go index 31df29d7..9a4c1c56 100644 --- a/types/types.go +++ b/types/types.go @@ -85,20 +85,19 @@ type IOStats struct { Latency float32 AvBlockSize float32 } + type Stats struct { RevisionCounter int64 ReplicaCounter int64 SCSIIOCount map[int]int64 - ReadIOPS int64 - ReadThroughput int64 - ReadLatency time.Duration - AvgReadBlockSize int64 + ReadIOPS int64 + TotalReadTime int64 + TotalReadBlockCount int64 - WriteIOPS int64 - WriteThroughput int64 - WriteLatency time.Duration - AvgWriteBlockSize int64 + WriteIOPS int64 + TotalWriteTime int64 + TotalWriteBlockCount int64 } type Interface interface{} diff --git a/vendor.conf b/vendor.conf index a96ffad1..8159793d 100644 --- a/vendor.conf +++ b/vendor.conf @@ -20,4 +20,4 @@ github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264 github.com/yasker/go-iscsi-helper 9910689ad7c88f650262e01557b16bdc0d5b6a94 github.com/yasker/nsfilelock 90eff0ebb9e2e0ee2f22519cfb8404f9fdd9c008 github.com/yasker/backupstore 39c822e19eb3d54eca4dc5f75205e426c8357ac1 -github.com/openebs/gotgt cf2025c5fab5c3b62b81d93c7a558ce939ea7e4a +github.com/openebs/gotgt d9485c5a0cc80beccb0496dfb9a72a9b0518971e From fc3a4e7c708aa153d3cbeea0dae12b581d0e048c Mon Sep 17 00:00:00 2001 From: Payes Anand Date: Tue, 20 Jun 2017 21:45:00 +0530 Subject: [PATCH 353/357] Update import paths to openebs/jiva --- Dockerfile.dapper | 4 ++-- app/add_replica.go | 2 +- app/backing_disable.go | 2 +- app/backing_qcow.go | 4 ++-- app/backup.go | 2 +- app/controller.go | 14 +++++++------- app/controller_gotgt.go | 2 +- app/controller_rest.go | 2 +- app/controller_tcmu.go | 2 +- app/controller_tgt.go | 2 +- app/ls_replica.go | 4 ++-- app/replica.go | 10 +++++----- app/rm_replica.go | 2 +- app/snapshot.go | 8 ++++---- app/sync_agent.go | 2 +- backend/dynamic/dynamic.go | 2 +- backend/file/file.go | 2 +- backend/remote/remote.go | 8 ++++---- backup/backing_disable.go | 2 +- backup/backing_qcow.go | 4 ++-- backup/main.go | 4 ++-- controller/client/controller_client.go | 4 ++-- controller/control.go | 4 ++-- controller/rebuild.go | 4 ++-- controller/replicator.go | 2 +- controller/rest/model.go | 4 ++-- controller/rest/replica.go | 2 +- controller/rest/router.go | 2 +- controller/revert.go | 6 +++--- frontend/gotgt/frontend.go | 2 +- frontend/rest/frontend.go | 2 +- frontend/tcmu/frontend.go | 2 +- frontend/tcmu/main.go | 2 +- frontend/tgt/frontend.go | 6 +++--- frontend/tgt/scsi.go | 2 +- integration/data/test_basic_ops.py | 2 +- integration/data/test_snapshot.py | 2 +- main.go | 4 ++-- replica/backup_test.go | 2 +- replica/client/client.go | 4 ++-- replica/diff_disk.go | 2 +- replica/extents.go | 2 +- replica/peer_details.go | 2 +- replica/replica.go | 4 ++-- replica/replica_test.go | 4 ++-- replica/rest/model.go | 2 +- replica/rest/replica.go | 2 +- replica/rpc/server.go | 4 ++-- replica/server.go | 2 +- rpc/server.go | 2 +- sync/backup.go | 8 ++++---- sync/sync.go | 8 ++++---- vendor.conf | 2 +- 53 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index dc61fc6a..551f05a2 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -9,8 +9,8 @@ ENV PATH /go/bin:$PATH ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_ENV TAG REPO ENV DAPPER_OUTPUT bin -ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/rancher/longhorn/integration/.venv:exec --tmpfs /go/src/github.com/rancher/longhorn/integration/.tox:exec -v /dev:/host/dev -v /proc:/host/proc -ENV DAPPER_SOURCE /go/src/github.com/rancher/longhorn +ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/openebs/jiva/integration/.venv:exec --tmpfs /go/src/github.com/openebs/jiva/integration/.tox:exec -v /dev:/host/dev -v /proc:/host/proc +ENV DAPPER_SOURCE /go/src/github.com/openebs/jiva ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache WORKDIR ${DAPPER_SOURCE} diff --git a/app/add_replica.go b/app/add_replica.go index 40ab03cc..9fc222f4 100644 --- a/app/add_replica.go +++ b/app/add_replica.go @@ -6,7 +6,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/sync" + "github.com/openebs/jiva/sync" ) func AddReplicaCmd() cli.Command { diff --git a/app/backing_disable.go b/app/backing_disable.go index ab1917ca..27e0b352 100644 --- a/app/backing_disable.go +++ b/app/backing_disable.go @@ -5,7 +5,7 @@ package app import ( "fmt" - "github.com/rancher/longhorn/replica" + "github.com/openebs/jiva/replica" ) func openBackingFile(file string) (*replica.BackingFile, error) { diff --git a/app/backing_qcow.go b/app/backing_qcow.go index fbee64d5..84d0c729 100644 --- a/app/backing_qcow.go +++ b/app/backing_qcow.go @@ -3,8 +3,8 @@ package app import ( - "github.com/rancher/longhorn/qcow" - "github.com/rancher/longhorn/replica" + "github.com/openebs/jiva/qcow" + "github.com/openebs/jiva/replica" ) func openBackingFile(file string) (*replica.BackingFile, error) { diff --git a/app/backup.go b/app/backup.go index 495d212f..a4286789 100644 --- a/app/backup.go +++ b/app/backup.go @@ -5,7 +5,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/sync" + "github.com/openebs/jiva/sync" ) func BackupCmd() cli.Command { diff --git a/app/controller.go b/app/controller.go index b041481e..8b4213c0 100644 --- a/app/controller.go +++ b/app/controller.go @@ -10,13 +10,13 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/gorilla/handlers" - "github.com/rancher/longhorn/backend/dynamic" - "github.com/rancher/longhorn/backend/file" - "github.com/rancher/longhorn/backend/remote" - "github.com/rancher/longhorn/controller" - "github.com/rancher/longhorn/controller/rest" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/backend/dynamic" + "github.com/openebs/jiva/backend/file" + "github.com/openebs/jiva/backend/remote" + "github.com/openebs/jiva/controller" + "github.com/openebs/jiva/controller/rest" + "github.com/openebs/jiva/types" + "github.com/openebs/jiva/util" ) var ( diff --git a/app/controller_gotgt.go b/app/controller_gotgt.go index febdb0d3..60b87f78 100644 --- a/app/controller_gotgt.go +++ b/app/controller_gotgt.go @@ -1,7 +1,7 @@ package app import ( - "github.com/rancher/longhorn/frontend/gotgt" + "github.com/openebs/jiva/frontend/gotgt" ) func init() { diff --git a/app/controller_rest.go b/app/controller_rest.go index 03a3b420..a1d09275 100644 --- a/app/controller_rest.go +++ b/app/controller_rest.go @@ -1,7 +1,7 @@ package app import ( - "github.com/rancher/longhorn/frontend/rest" + "github.com/openebs/jiva/frontend/rest" ) func init() { diff --git a/app/controller_tcmu.go b/app/controller_tcmu.go index 62097083..89e2c122 100644 --- a/app/controller_tcmu.go +++ b/app/controller_tcmu.go @@ -3,7 +3,7 @@ package app import ( - "github.com/rancher/longhorn/frontend/tcmu" + "github.com/openebs/jiva/frontend/tcmu" ) func init() { diff --git a/app/controller_tgt.go b/app/controller_tgt.go index 2e987957..696e6e90 100644 --- a/app/controller_tgt.go +++ b/app/controller_tgt.go @@ -1,7 +1,7 @@ package app import ( - "github.com/rancher/longhorn/frontend/tgt" + "github.com/openebs/jiva/frontend/tgt" ) func init() { diff --git a/app/ls_replica.go b/app/ls_replica.go index 4e625fad..d58d4064 100644 --- a/app/ls_replica.go +++ b/app/ls_replica.go @@ -7,8 +7,8 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/controller/client" - replicaClient "github.com/rancher/longhorn/replica/client" + "github.com/openebs/jiva/controller/client" + replicaClient "github.com/openebs/jiva/replica/client" ) func LsReplicaCmd() cli.Command { diff --git a/app/replica.go b/app/replica.go index 8952fb76..13e05f3c 100644 --- a/app/replica.go +++ b/app/replica.go @@ -13,11 +13,11 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/docker/go-units" - "github.com/rancher/longhorn/controller/client" - "github.com/rancher/longhorn/replica" - "github.com/rancher/longhorn/replica/rest" - "github.com/rancher/longhorn/replica/rpc" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/controller/client" + "github.com/openebs/jiva/replica" + "github.com/openebs/jiva/replica/rest" + "github.com/openebs/jiva/replica/rpc" + "github.com/openebs/jiva/util" ) func ReplicaCmd() cli.Command { diff --git a/app/rm_replica.go b/app/rm_replica.go index ba051f90..2546b0a9 100644 --- a/app/rm_replica.go +++ b/app/rm_replica.go @@ -5,7 +5,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/controller/client" + "github.com/openebs/jiva/controller/client" ) func RmReplicaCmd() cli.Command { diff --git a/app/snapshot.go b/app/snapshot.go index 5ae2e354..48b28e8b 100644 --- a/app/snapshot.go +++ b/app/snapshot.go @@ -9,10 +9,10 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/replica" - replicaClient "github.com/rancher/longhorn/replica/client" - "github.com/rancher/longhorn/sync" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/replica" + replicaClient "github.com/openebs/jiva/replica/client" + "github.com/openebs/jiva/sync" + "github.com/openebs/jiva/util" ) const VolumeHeadName = "volume-head" diff --git a/app/sync_agent.go b/app/sync_agent.go index f7ebe1a8..137980a9 100644 --- a/app/sync_agent.go +++ b/app/sync_agent.go @@ -8,7 +8,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/sync/agent" + "github.com/openebs/jiva/sync/agent" ) func SyncAgentCmd() cli.Command { diff --git a/backend/dynamic/dynamic.go b/backend/dynamic/dynamic.go index 9888e15a..62adb3d9 100644 --- a/backend/dynamic/dynamic.go +++ b/backend/dynamic/dynamic.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) type Factory struct { diff --git a/backend/file/file.go b/backend/file/file.go index 62d22772..a03a4fd8 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -4,7 +4,7 @@ import ( "os" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) func New() types.BackendFactory { diff --git a/backend/remote/remote.go b/backend/remote/remote.go index 528fd417..2837787d 100644 --- a/backend/remote/remote.go +++ b/backend/remote/remote.go @@ -11,10 +11,10 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/replica/rest" - "github.com/rancher/longhorn/rpc" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/replica/rest" + "github.com/openebs/jiva/rpc" + "github.com/openebs/jiva/types" + "github.com/openebs/jiva/util" ) var ( diff --git a/backup/backing_disable.go b/backup/backing_disable.go index 7f65969d..4a6b71d9 100644 --- a/backup/backing_disable.go +++ b/backup/backing_disable.go @@ -5,7 +5,7 @@ package backup import ( "fmt" - "github.com/rancher/longhorn/replica" + "github.com/openebs/jiva/replica" ) func openBackingFile(file string) (*replica.BackingFile, error) { diff --git a/backup/backing_qcow.go b/backup/backing_qcow.go index 25c765e9..c25b65aa 100644 --- a/backup/backing_qcow.go +++ b/backup/backing_qcow.go @@ -3,8 +3,8 @@ package backup import ( - "github.com/rancher/longhorn/qcow" - "github.com/rancher/longhorn/replica" + "github.com/openebs/jiva/qcow" + "github.com/openebs/jiva/replica" ) func openBackingFile(file string) (*replica.BackingFile, error) { diff --git a/backup/main.go b/backup/main.go index c27e3957..2f33ce36 100644 --- a/backup/main.go +++ b/backup/main.go @@ -12,8 +12,8 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/rancher/longhorn/replica" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/replica" + "github.com/openebs/jiva/util" "github.com/yasker/backupstore" ) diff --git a/controller/client/controller_client.go b/controller/client/controller_client.go index 05d738d2..95f6932c 100644 --- a/controller/client/controller_client.go +++ b/controller/client/controller_client.go @@ -11,8 +11,8 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/controller/rest" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/controller/rest" + "github.com/openebs/jiva/types" ) type ControllerClient struct { diff --git a/controller/control.go b/controller/control.go index fa2ef2d7..c8b75d35 100644 --- a/controller/control.go +++ b/controller/control.go @@ -8,8 +8,8 @@ import ( "github.com/Sirupsen/logrus" units "github.com/docker/go-units" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/types" + "github.com/openebs/jiva/util" ) type Controller struct { diff --git a/controller/rebuild.go b/controller/rebuild.go index 29bef71d..2a61a644 100644 --- a/controller/rebuild.go +++ b/controller/rebuild.go @@ -5,8 +5,8 @@ import ( "reflect" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/replica/client" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/replica/client" + "github.com/openebs/jiva/types" ) func getReplicaChain(address string) ([]string, error) { diff --git a/controller/replicator.go b/controller/replicator.go index 8cf67ca4..0c0068df 100644 --- a/controller/replicator.go +++ b/controller/replicator.go @@ -9,7 +9,7 @@ import ( "sync" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) var ( diff --git a/controller/rest/model.go b/controller/rest/model.go index 1f33ee94..ec0a9be0 100644 --- a/controller/rest/model.go +++ b/controller/rest/model.go @@ -4,10 +4,10 @@ import ( "encoding/base64" "time" + "github.com/openebs/jiva/controller" + "github.com/openebs/jiva/types" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" - "github.com/rancher/longhorn/controller" - "github.com/rancher/longhorn/types" ) type Replica struct { diff --git a/controller/rest/replica.go b/controller/rest/replica.go index d9db2261..85548383 100644 --- a/controller/rest/replica.go +++ b/controller/rest/replica.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/openebs/jiva/types" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" - "github.com/rancher/longhorn/types" ) func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { diff --git a/controller/rest/router.go b/controller/rest/router.go index 21a6c4e0..89514538 100644 --- a/controller/rest/router.go +++ b/controller/rest/router.go @@ -5,8 +5,8 @@ import ( _ "net/http/pprof" /* for profiling */ "github.com/gorilla/mux" + "github.com/openebs/jiva/replica/rest" "github.com/rancher/go-rancher/api" - "github.com/rancher/longhorn/replica/rest" ) func NewRouter(s *Server) *mux.Router { diff --git a/controller/revert.go b/controller/revert.go index 8b54f5ee..5f1c0e22 100644 --- a/controller/revert.go +++ b/controller/revert.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/replica/client" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/replica/client" + "github.com/openebs/jiva/types" + "github.com/openebs/jiva/util" ) func (c *Controller) Revert(name string) error { diff --git a/frontend/gotgt/frontend.go b/frontend/gotgt/frontend.go index ef443659..6e4689f6 100644 --- a/frontend/gotgt/frontend.go +++ b/frontend/gotgt/frontend.go @@ -7,7 +7,7 @@ import ( "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" "github.com/openebs/gotgt/pkg/config" "github.com/openebs/gotgt/pkg/port" diff --git a/frontend/rest/frontend.go b/frontend/rest/frontend.go index 77866446..6d759247 100644 --- a/frontend/rest/frontend.go +++ b/frontend/rest/frontend.go @@ -6,7 +6,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/gorilla/handlers" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) var ( diff --git a/frontend/tcmu/frontend.go b/frontend/tcmu/frontend.go index 9a1bf578..b11d2a23 100644 --- a/frontend/tcmu/frontend.go +++ b/frontend/tcmu/frontend.go @@ -14,7 +14,7 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) const ( diff --git a/frontend/tcmu/main.go b/frontend/tcmu/main.go index f0c9875f..6b2d51ce 100644 --- a/frontend/tcmu/main.go +++ b/frontend/tcmu/main.go @@ -24,7 +24,7 @@ import ( "unsafe" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" "golang.org/x/sys/unix" ) diff --git a/frontend/tgt/frontend.go b/frontend/tgt/frontend.go index a84ec3c5..3bd44159 100644 --- a/frontend/tgt/frontend.go +++ b/frontend/tgt/frontend.go @@ -9,9 +9,9 @@ import ( "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/rpc" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/rpc" + "github.com/openebs/jiva/types" + "github.com/openebs/jiva/util" ) const ( diff --git a/frontend/tgt/scsi.go b/frontend/tgt/scsi.go index e9cd85e6..11e73d86 100644 --- a/frontend/tgt/scsi.go +++ b/frontend/tgt/scsi.go @@ -7,7 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/util" "github.com/yasker/go-iscsi-helper/iscsi" iutil "github.com/yasker/go-iscsi-helper/util" "github.com/yasker/nsfilelock" diff --git a/integration/data/test_basic_ops.py b/integration/data/test_basic_ops.py index cd108832..e3c39c75 100644 --- a/integration/data/test_basic_ops.py +++ b/integration/data/test_basic_ops.py @@ -18,7 +18,7 @@ def test_basic_rw(dev): # NOQA common.verify_data(dev, offset, data) -# See also BUG: https://github.com/rancher/longhorn/issues/131 +# See also BUG: https://github.com/openebs/jiva/issues/131 def test_beyond_boundary(dev): # NOQA # check write at the boundary data = common.random_string(128) diff --git a/integration/data/test_snapshot.py b/integration/data/test_snapshot.py index cd963c23..45e1ae04 100644 --- a/integration/data/test_snapshot.py +++ b/integration/data/test_snapshot.py @@ -35,7 +35,7 @@ def test_snapshot_revert(dev): # NOQA assert readed == snap1_data -# BUG: https://github.com/rancher/longhorn/issues/108 +# BUG: https://github.com/openebs/jiva/issues/108 def test_snapshot_rm(dev): # NOQA offset = 0 length = 128 diff --git a/main.go b/main.go index dcb43660..e450f239 100644 --- a/main.go +++ b/main.go @@ -11,8 +11,8 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/docker/docker/pkg/reexec" - "github.com/rancher/longhorn/app" - "github.com/rancher/longhorn/backup" + "github.com/openebs/jiva/app" + "github.com/openebs/jiva/backup" "github.com/rancher/sparse-tools/cli/sfold" "github.com/rancher/sparse-tools/cli/ssync" ) diff --git a/replica/backup_test.go b/replica/backup_test.go index b5edfee8..11334b8f 100644 --- a/replica/backup_test.go +++ b/replica/backup_test.go @@ -5,7 +5,7 @@ import ( "os" "path" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/util" . "gopkg.in/check.v1" ) diff --git a/replica/client/client.go b/replica/client/client.go index 0be5d6f1..e03eea95 100644 --- a/replica/client/client.go +++ b/replica/client/client.go @@ -12,8 +12,8 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/replica/rest" - "github.com/rancher/longhorn/sync/agent" + "github.com/openebs/jiva/replica/rest" + "github.com/openebs/jiva/sync/agent" ) type ReplicaClient struct { diff --git a/replica/diff_disk.go b/replica/diff_disk.go index 0c6124d2..67ae39c7 100644 --- a/replica/diff_disk.go +++ b/replica/diff_disk.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/frostschutz/go-fibmap" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) type diffDisk struct { diff --git a/replica/extents.go b/replica/extents.go index ce80872d..50df4faf 100644 --- a/replica/extents.go +++ b/replica/extents.go @@ -2,7 +2,7 @@ package replica import ( "github.com/frostschutz/go-fibmap" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) type UsedGenerator struct { diff --git a/replica/peer_details.go b/replica/peer_details.go index 29337572..f890e1ad 100644 --- a/replica/peer_details.go +++ b/replica/peer_details.go @@ -5,7 +5,7 @@ import ( "os" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" "github.com/rancher/sparse-tools/sparse" ) diff --git a/replica/replica.go b/replica/replica.go index 7a703b3d..06922390 100644 --- a/replica/replica.go +++ b/replica/replica.go @@ -15,8 +15,8 @@ import ( "github.com/Sirupsen/logrus" units "github.com/docker/go-units" - "github.com/rancher/longhorn/types" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/types" + "github.com/openebs/jiva/util" "github.com/rancher/sparse-tools/sparse" ) diff --git a/replica/replica_test.go b/replica/replica_test.go index 9b88e4b3..9b3b1376 100644 --- a/replica/replica_test.go +++ b/replica/replica_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/util" . "gopkg.in/check.v1" ) @@ -562,7 +562,7 @@ func (s *TestSuite) TestPrepareRemove(c *C) { c.Assert(len(r.activeDiskData), Equals, 5) c.Assert(len(r.volume.files), Equals, 5) - /* https://github.com/rancher/longhorn/issues/184 */ + /* https://github.com/openebs/jiva/issues/184 */ actions, err = r.PrepareRemoveDisk("002") c.Assert(err, IsNil) c.Assert(actions, HasLen, 2) diff --git a/replica/rest/model.go b/replica/rest/model.go index 815aff91..bf3ac44a 100644 --- a/replica/rest/model.go +++ b/replica/rest/model.go @@ -3,9 +3,9 @@ package rest import ( "strconv" + "github.com/openebs/jiva/replica" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" - "github.com/rancher/longhorn/replica" ) type Replica struct { diff --git a/replica/rest/replica.go b/replica/rest/replica.go index e680e5e6..ddd7bb1e 100644 --- a/replica/rest/replica.go +++ b/replica/rest/replica.go @@ -7,9 +7,9 @@ import ( "strconv" "github.com/gorilla/mux" + "github.com/openebs/jiva/types" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" - "github.com/rancher/longhorn/types" ) func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error { diff --git a/replica/rpc/server.go b/replica/rpc/server.go index 6e3f9b70..3797ab2c 100644 --- a/replica/rpc/server.go +++ b/replica/rpc/server.go @@ -5,8 +5,8 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/replica" - "github.com/rancher/longhorn/rpc" + "github.com/openebs/jiva/replica" + "github.com/openebs/jiva/rpc" ) type Server struct { diff --git a/replica/server.go b/replica/server.go index 5d0781a5..63bfcb29 100644 --- a/replica/server.go +++ b/replica/server.go @@ -7,7 +7,7 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) const ( diff --git a/rpc/server.go b/rpc/server.go index c10f1cb7..35c27a64 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -5,7 +5,7 @@ import ( "net" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/types" + "github.com/openebs/jiva/types" ) type Server struct { diff --git a/sync/backup.go b/sync/backup.go index ecd4e47f..524ead55 100644 --- a/sync/backup.go +++ b/sync/backup.go @@ -4,10 +4,10 @@ import ( "fmt" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/controller/rest" - "github.com/rancher/longhorn/replica" - replicaClient "github.com/rancher/longhorn/replica/client" - "github.com/rancher/longhorn/util" + "github.com/openebs/jiva/controller/rest" + "github.com/openebs/jiva/replica" + replicaClient "github.com/openebs/jiva/replica/client" + "github.com/openebs/jiva/util" ) func (t *Task) CreateBackup(snapshot, dest string) (string, error) { diff --git a/sync/sync.go b/sync/sync.go index 8cc1a298..eef72743 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -6,10 +6,10 @@ import ( "time" "github.com/Sirupsen/logrus" - "github.com/rancher/longhorn/controller/client" - "github.com/rancher/longhorn/controller/rest" - "github.com/rancher/longhorn/replica" - replicaClient "github.com/rancher/longhorn/replica/client" + "github.com/openebs/jiva/controller/client" + "github.com/openebs/jiva/controller/rest" + "github.com/openebs/jiva/replica" + replicaClient "github.com/openebs/jiva/replica/client" ) var ( diff --git a/vendor.conf b/vendor.conf index 8159793d..4e376056 100644 --- a/vendor.conf +++ b/vendor.conf @@ -1,4 +1,4 @@ -github.com/rancher/longhorn +github.com/openebs/jiva gopkg.in/check.v1 4f90aeace3a26ad7021961c297b22c42160c7b25 github.com/gorilla/mux 0eeaf8392f5b04950925b8a69fe70f110fa7cbfc From d8b25a32e70b39a8c85bd38654d1bb350cda746f Mon Sep 17 00:00:00 2001 From: Payes Anand Date: Thu, 22 Jun 2017 01:26:47 +0530 Subject: [PATCH 354/357] Reorganize script directories --- Makefile | 2 +- buildscripts/package | 19 ------------------- buildscripts/version | 6 ------ scripts/package | 4 ++-- {buildscripts => scripts}/push | 0 scripts/version | 12 ++---------- 6 files changed, 5 insertions(+), 38 deletions(-) delete mode 100755 buildscripts/package delete mode 100755 buildscripts/version rename {buildscripts => scripts}/push (100%) diff --git a/Makefile b/Makefile index 8694b94a..8d2e55c4 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ _run_ci: ./ci/start_init_test.sh _push_image: - cd $(GOPATH)/src/github.com/openebs/longhorn && ./scripts/push + cd $(GOPATH)/src/github.com/openebs/jiva && ./scripts/push # # Will build the go based binaries diff --git a/buildscripts/package b/buildscripts/package deleted file mode 100755 index b89671cd..00000000 --- a/buildscripts/package +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -e - -source $(dirname $0)/version - -cd $(dirname $0)/../package - -TAG=${TAG:-${VERSION}} -REPO=${REPO:-openebs} - -if [ ! -x ../bin/longhorn ]; then - ../scripts/build -fi - -cp ../bin/longhorn* . -cp /usr/src/tgt/pkg/tgt_*.deb . -docker build -t ${REPO}/jiva:${TAG} . - -echo Built ${REPO}/jiva:${TAG} diff --git a/buildscripts/version b/buildscripts/version deleted file mode 100755 index a10dfdd0..00000000 --- a/buildscripts/version +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -RELEASE_TAG="dev" -COMMIT=$(git rev-parse --short HEAD) -VERSION="${RELEASE_TAG}-${COMMIT}" - diff --git a/scripts/package b/scripts/package index 8ceb25f9..b89671cd 100755 --- a/scripts/package +++ b/scripts/package @@ -14,6 +14,6 @@ fi cp ../bin/longhorn* . cp /usr/src/tgt/pkg/tgt_*.deb . -docker build -t ${REPO}/longhorn:${TAG} . +docker build -t ${REPO}/jiva:${TAG} . -echo Built ${REPO}/longhorn:${TAG} +echo Built ${REPO}/jiva:${TAG} diff --git a/buildscripts/push b/scripts/push similarity index 100% rename from buildscripts/push rename to scripts/push diff --git a/scripts/version b/scripts/version index 983b02b3..a10dfdd0 100755 --- a/scripts/version +++ b/scripts/version @@ -1,14 +1,6 @@ #!/bin/bash -if [ -n "$(git status --porcelain --untracked-files=no)" ]; then - DIRTY="-dirty" -fi - +RELEASE_TAG="dev" COMMIT=$(git rev-parse --short HEAD) -GIT_TAG=$(git tag -l --contains HEAD | head -n 1) +VERSION="${RELEASE_TAG}-${COMMIT}" -if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then - VERSION=$GIT_TAG -else - VERSION="${COMMIT}${DIRTY}" -fi From 089ced891b4352a488b15abd7ed4e6d3e8dd0292 Mon Sep 17 00:00:00 2001 From: Payes Date: Tue, 4 Jul 2017 12:35:23 +0530 Subject: [PATCH 355/357] Remove duplicate LICENSE file --- LICENCE | 201 -------------------------------------------------------- 1 file changed, 201 deletions(-) delete mode 100644 LICENCE diff --git a/LICENCE b/LICENCE deleted file mode 100644 index 43d11e06..00000000 --- a/LICENCE +++ /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 2016-2017 CloudByte, 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. From 6d7cd8f24956975705a3cc148a6e887a7c1f10d4 Mon Sep 17 00:00:00 2001 From: Payes Anand Date: Wed, 5 Jul 2017 22:46:26 +0530 Subject: [PATCH 356/357] Rename build script to resolve clash with build label in Makefile --- scripts/{build => build_binaries} | 0 scripts/ci | 2 +- scripts/integration-test | 2 +- scripts/package | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{build => build_binaries} (100%) diff --git a/scripts/build b/scripts/build_binaries similarity index 100% rename from scripts/build rename to scripts/build_binaries diff --git a/scripts/ci b/scripts/ci index 8b0f3ac3..4d1d0308 100755 --- a/scripts/ci +++ b/scripts/ci @@ -3,7 +3,7 @@ set -e cd $(dirname $0) -./build +./build_binaries ./test ./validate #./integration-test diff --git a/scripts/integration-test b/scripts/integration-test index 5ec37619..b12faafd 100755 --- a/scripts/integration-test +++ b/scripts/integration-test @@ -32,7 +32,7 @@ trap "rm -rf $temp $temp2 $temp3 $temp4" EXIT cd $(dirname $0)/.. if [ ! -x ./bin/longhorn ]; then - ./scripts/build + ./scripts/build_binaries fi diff --git a/scripts/package b/scripts/package index b89671cd..2393edad 100755 --- a/scripts/package +++ b/scripts/package @@ -9,7 +9,7 @@ TAG=${TAG:-${VERSION}} REPO=${REPO:-openebs} if [ ! -x ../bin/longhorn ]; then - ../scripts/build + ../scripts/build_binaries fi cp ../bin/longhorn* . From f85ddbd25da016f9cb08d519d030d6c4f0fd426e Mon Sep 17 00:00:00 2001 From: Payes Anand Date: Thu, 6 Jul 2017 01:20:51 +0530 Subject: [PATCH 357/357] Specify correct docker image name for init_test --- ci/start_init_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/start_init_test.sh b/ci/start_init_test.sh index 568c07de..1f7c6e8f 100755 --- a/ci/start_init_test.sh +++ b/ci/start_init_test.sh @@ -1,6 +1,6 @@ #!/bin/bash -JI=$(sudo docker images | grep jiva | awk '{print $1":"$2}') +JI=$(sudo docker images | grep openebs/jiva | awk '{print $1":"$2}') echo "Run CI tests on $JI" mkdir /tmp/vol1