mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c988c927d | ||
|
|
bde9af44ea | ||
|
|
eee4d05642 | ||
|
|
9144594d77 | ||
|
|
1cb15242fd | ||
|
|
08498600d1 | ||
|
|
88c0c7779b | ||
|
|
67454d109e | ||
|
|
ce603c73b4 | ||
|
|
55218fc8f8 | ||
|
|
5d81c650e8 | ||
|
|
0726209172 | ||
|
|
bfec8aca51 | ||
|
|
a9b30edb06 | ||
|
|
cc6d698e63 | ||
|
|
2ba97d0fa3 | ||
|
|
d299b5aa7f | ||
|
|
0a209b60a5 | ||
|
|
fe8c6271f2 | ||
|
|
42fb085684 | ||
|
|
3faec00bf9 | ||
|
|
93669f1ee8 | ||
|
|
fad98cbde2 | ||
|
|
8eb28cbb4c | ||
|
|
9dc9a8e62a | ||
|
|
e6caef0d94 | ||
|
|
5e289ed0cc | ||
|
|
d99588fe19 | ||
|
|
a7ccb7a9d1 | ||
|
|
f32abb921d | ||
|
|
e8851c1f99 | ||
|
|
f3a8359ac0 | ||
|
|
829e8fed8c | ||
|
|
c7e3605bff | ||
|
|
c1774b1596 | ||
|
|
35710a7428 | ||
|
|
c7ba4d8bbf | ||
|
|
5585e10933 | ||
|
|
23d5bf0b51 | ||
|
|
b1c7a84fae | ||
|
|
60801b336a | ||
|
|
851ea3df3c | ||
|
|
d482577e47 | ||
|
|
94e7a25b5b | ||
|
|
45d94fa013 | ||
|
|
b4e69ecd37 | ||
|
|
1c2820b4f1 | ||
|
|
215c3f6623 |
No files matched your search
+114
@@ -0,0 +1,114 @@
|
|||||||
|
CHANGELOG
|
||||||
|
=========
|
||||||
|
|
||||||
|
1.10.0
|
||||||
|
-----
|
||||||
|
- Add entropy option
|
||||||
|
1.9.0
|
||||||
|
-----
|
||||||
|
- exclude fork option
|
||||||
|
|
||||||
|
1.8.0
|
||||||
|
-----
|
||||||
|
- whitelist repos
|
||||||
|
- sample config option
|
||||||
|
|
||||||
|
1.7.3
|
||||||
|
-----
|
||||||
|
- style points
|
||||||
|
|
||||||
|
1.7.2
|
||||||
|
-----
|
||||||
|
- Fixing dangling goroutines, removing channel messaging
|
||||||
|
|
||||||
|
1.7.1
|
||||||
|
-----
|
||||||
|
- Fixing bug where single repos were not being audited
|
||||||
|
|
||||||
|
1.7.0
|
||||||
|
-----
|
||||||
|
- Exit code == 2 on error
|
||||||
|
- Cleaning up some logs
|
||||||
|
- Removing some unreachable code
|
||||||
|
|
||||||
|
1.6.1
|
||||||
|
-----
|
||||||
|
- Recover from panic when diffing
|
||||||
|
|
||||||
|
1.6.0
|
||||||
|
-----
|
||||||
|
- Default maximum goroutines spawned is number of cores your cpu run with. See benchmarks in wiki.
|
||||||
|
- Cleanup after each repo audit for organizations rather than waiting for the entire organization to complete. Eliminates risk of running out of disk space.
|
||||||
|
|
||||||
|
|
||||||
|
1.5.0
|
||||||
|
-----
|
||||||
|
- Support for CSV reporting
|
||||||
|
- Refactoring github user/owner audits
|
||||||
|
|
||||||
|
1.4.0
|
||||||
|
-----
|
||||||
|
- Support for single commit repos
|
||||||
|
- Bumped go-git version from 4.5.0 to 4.7.0
|
||||||
|
|
||||||
|
1.3.0
|
||||||
|
-----
|
||||||
|
- Target specific branch
|
||||||
|
|
||||||
|
1.2.1
|
||||||
|
-----
|
||||||
|
- Check errors when generating commit patch
|
||||||
|
|
||||||
|
1.2.0
|
||||||
|
-----
|
||||||
|
- Added support for providing an alternate GitHub URL to support scanning GitHub Enteprise repositories
|
||||||
|
|
||||||
|
1.1.2
|
||||||
|
-----
|
||||||
|
- Added version option
|
||||||
|
- Introduced changelog
|
||||||
|
|
||||||
|
1.1.1
|
||||||
|
-----
|
||||||
|
- Fixed commit patch order
|
||||||
|
- Updated Readme
|
||||||
|
|
||||||
|
1.1.0
|
||||||
|
-----
|
||||||
|
- Fixed Twitter typo
|
||||||
|
- Fixed sample docker command
|
||||||
|
- Default clone option to "in-memory"
|
||||||
|
- Added clone option for "disk"
|
||||||
|
- Updated Makefile
|
||||||
|
|
||||||
|
1.0.0
|
||||||
|
-----
|
||||||
|
- Rewrite, see Readme.md: https://github.com/zricethezav/gitleaks/releases/tag/v1.0.0
|
||||||
|
|
||||||
|
0.4.0
|
||||||
|
-----
|
||||||
|
- Added support for external regexes
|
||||||
|
|
||||||
|
0.3.0
|
||||||
|
-----
|
||||||
|
- Added local scan
|
||||||
|
- Meaningful exit codes
|
||||||
|
- Timestamped logs
|
||||||
|
- Refactored for some maintainability
|
||||||
|
|
||||||
|
0.2.0
|
||||||
|
-----
|
||||||
|
- Additionally regex checking
|
||||||
|
- $HOME/.gitleaks/ directory for clones and reports
|
||||||
|
- Pagination for Org/User list... no more partial repo lists
|
||||||
|
- Persistent repos for Orgs and Users (no more re-cloning)
|
||||||
|
- Updated README
|
||||||
|
- Multi-staged Docker build
|
||||||
|
- Travis CI
|
||||||
|
|
||||||
|
0.1.0
|
||||||
|
-----
|
||||||
|
- full git history search
|
||||||
|
- regex/entropy checks
|
||||||
|
- report generation
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Contributing Guidelines
|
||||||
|
|
||||||
|
The gitleaks project is under [GNU General Public License v3.0](LICENSE.md) and accepts
|
||||||
|
contributions via GitHub pull requests.
|
||||||
|
|
||||||
|
## How to Contribute
|
||||||
|
|
||||||
|
Open a PR. Give the PR a descriptive title. Add some comments describing whats the purpose of the PR.
|
||||||
|
|
||||||
|
__BUT before you do that!__
|
||||||
|
|
||||||
|
Make sure you pass this list of requirements.
|
||||||
|
|
||||||
|
- You've ran `go fmt`.
|
||||||
|
- You've ran `golint`.
|
||||||
|
- Your Go changes are confined to `gitleaks_test.go` and `main.go`. This is subject to change as the project evolves. Stylistically, I like having a single go file considering the size of this project (its tiny).
|
||||||
|
- You've added test cases for your changes.
|
||||||
|
- You've updated [the changelog](CHANGELOG.md).
|
||||||
|
- Your tests pass.
|
||||||
|
|
||||||
Generated
+136
-35
@@ -4,14 +4,21 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/BurntSushi/toml"
|
name = "github.com/BurntSushi/toml"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
|
revision = "3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005"
|
||||||
version = "v0.3.0"
|
version = "v0.3.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/emirpasic/gods"
|
name = "github.com/emirpasic/gods"
|
||||||
packages = ["containers","lists","lists/arraylist","trees","trees/binaryheap","utils"]
|
packages = [
|
||||||
revision = "f6c17b524822278a87e3b3bd809fec33b51f5b46"
|
"containers",
|
||||||
version = "v1.9.0"
|
"lists",
|
||||||
|
"lists/arraylist",
|
||||||
|
"trees",
|
||||||
|
"trees/binaryheap",
|
||||||
|
"utils"
|
||||||
|
]
|
||||||
|
revision = "1615341f118ae12f353cc8a983f35b584342c9b3"
|
||||||
|
version = "v1.12.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/franela/goblin"
|
name = "github.com/franela/goblin"
|
||||||
@@ -22,8 +29,8 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/golang/protobuf"
|
name = "github.com/golang/protobuf"
|
||||||
packages = ["proto"]
|
packages = ["proto"]
|
||||||
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
|
||||||
version = "v1.1.0"
|
version = "v1.2.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/google/go-github"
|
name = "github.com/google/go-github"
|
||||||
@@ -32,10 +39,10 @@
|
|||||||
version = "v15.0.0"
|
version = "v15.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/google/go-querystring"
|
name = "github.com/google/go-querystring"
|
||||||
packages = ["query"]
|
packages = ["query"]
|
||||||
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
|
revision = "44c6ddd0a2342c386950e880b658017258da92fc"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
@@ -52,14 +59,14 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/kevinburke/ssh_config"
|
name = "github.com/kevinburke/ssh_config"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "9fc7bb800b555d63157c65a904c86a2cc7b4e795"
|
revision = "81db2a75821ed34e682567d48be488a1c3121088"
|
||||||
version = "0.4"
|
version = "0.5"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/mitchellh/go-homedir"
|
name = "github.com/mitchellh/go-homedir"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66"
|
revision = "ae18d6b8b3205b561c79e8e5f69bff09736185f4"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/pelletier/go-buffruneio"
|
name = "github.com/pelletier/go-buffruneio"
|
||||||
@@ -76,12 +83,17 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/sirupsen/logrus"
|
name = "github.com/sirupsen/logrus"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
|
revision = "3e01752db0189b9157070a0e1668a620f9a85da2"
|
||||||
version = "v1.0.5"
|
version = "v1.0.6"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/src-d/gcfg"
|
name = "github.com/src-d/gcfg"
|
||||||
packages = [".","scanner","token","types"]
|
packages = [
|
||||||
|
".",
|
||||||
|
"scanner",
|
||||||
|
"token",
|
||||||
|
"types"
|
||||||
|
]
|
||||||
revision = "f187355171c936ac84a82793659ebb4936bc1c23"
|
revision = "f187355171c936ac84a82793659ebb4936bc1c23"
|
||||||
version = "v1.3.0"
|
version = "v1.3.0"
|
||||||
|
|
||||||
@@ -94,50 +106,139 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = ["cast5","curve25519","ed25519","ed25519/internal/edwards25519","internal/chacha20","internal/subtle","openpgp","openpgp/armor","openpgp/elgamal","openpgp/errors","openpgp/packet","openpgp/s2k","poly1305","ssh","ssh/agent","ssh/knownhosts","ssh/terminal"]
|
packages = [
|
||||||
revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602"
|
"cast5",
|
||||||
|
"curve25519",
|
||||||
|
"ed25519",
|
||||||
|
"ed25519/internal/edwards25519",
|
||||||
|
"internal/chacha20",
|
||||||
|
"internal/subtle",
|
||||||
|
"openpgp",
|
||||||
|
"openpgp/armor",
|
||||||
|
"openpgp/elgamal",
|
||||||
|
"openpgp/errors",
|
||||||
|
"openpgp/packet",
|
||||||
|
"openpgp/s2k",
|
||||||
|
"poly1305",
|
||||||
|
"ssh",
|
||||||
|
"ssh/agent",
|
||||||
|
"ssh/knownhosts",
|
||||||
|
"ssh/terminal"
|
||||||
|
]
|
||||||
|
revision = "0e37d006457bf46f9e6692014ba72ef82c33022c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/net"
|
name = "golang.org/x/net"
|
||||||
packages = ["context","context/ctxhttp"]
|
packages = [
|
||||||
revision = "d0887baf81f4598189d4e12a37c6da86f0bba4d0"
|
"context",
|
||||||
|
"context/ctxhttp"
|
||||||
|
]
|
||||||
|
revision = "f04abc6bdfa7a0171a8a0c9fd2ada9391044d056"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/oauth2"
|
name = "golang.org/x/oauth2"
|
||||||
packages = [".","internal"]
|
packages = [
|
||||||
revision = "ef147856a6ddbb60760db74283d2424e98c87bff"
|
".",
|
||||||
|
"internal"
|
||||||
|
]
|
||||||
|
revision = "d2e6202438beef2727060aa7cabdd924d92ebfd9"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
packages = ["unix","windows"]
|
packages = [
|
||||||
revision = "ac767d655b305d4e9612f5f6e33120b9176c4ad4"
|
"unix",
|
||||||
|
"windows"
|
||||||
|
]
|
||||||
|
revision = "b09afc3d579e346c4a7e4705953acaf6f9e551bd"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "golang.org/x/text"
|
name = "golang.org/x/text"
|
||||||
packages = ["internal/gen","internal/triegen","internal/ucd","transform","unicode/cldr","unicode/norm"]
|
packages = [
|
||||||
|
"internal/gen",
|
||||||
|
"internal/triegen",
|
||||||
|
"internal/ucd",
|
||||||
|
"transform",
|
||||||
|
"unicode/cldr",
|
||||||
|
"unicode/norm"
|
||||||
|
]
|
||||||
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||||
version = "v0.3.0"
|
version = "v0.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "google.golang.org/appengine"
|
name = "google.golang.org/appengine"
|
||||||
packages = ["internal","internal/base","internal/datastore","internal/log","internal/remote_api","internal/urlfetch","urlfetch"]
|
packages = [
|
||||||
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
|
"internal",
|
||||||
version = "v1.1.0"
|
"internal/base",
|
||||||
|
"internal/datastore",
|
||||||
|
"internal/log",
|
||||||
|
"internal/remote_api",
|
||||||
|
"internal/urlfetch",
|
||||||
|
"urlfetch"
|
||||||
|
]
|
||||||
|
revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06"
|
||||||
|
version = "v1.2.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/src-d/go-billy.v4"
|
name = "gopkg.in/src-d/go-billy.v4"
|
||||||
packages = [".","helper/chroot","helper/polyfill","osfs","util"]
|
packages = [
|
||||||
revision = "83cf655d40b15b427014d7875d10850f96edba14"
|
".",
|
||||||
version = "v4.2.0"
|
"helper/chroot",
|
||||||
|
"helper/polyfill",
|
||||||
|
"osfs",
|
||||||
|
"util"
|
||||||
|
]
|
||||||
|
revision = "982626487c60a5252e7d0b695ca23fb0fa2fd670"
|
||||||
|
version = "v4.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/src-d/go-git.v4"
|
name = "gopkg.in/src-d/go-git.v4"
|
||||||
packages = [".","config","internal/revision","plumbing","plumbing/cache","plumbing/filemode","plumbing/format/config","plumbing/format/diff","plumbing/format/gitignore","plumbing/format/idxfile","plumbing/format/index","plumbing/format/objfile","plumbing/format/packfile","plumbing/format/pktline","plumbing/object","plumbing/protocol/packp","plumbing/protocol/packp/capability","plumbing/protocol/packp/sideband","plumbing/revlist","plumbing/storer","plumbing/transport","plumbing/transport/client","plumbing/transport/file","plumbing/transport/git","plumbing/transport/http","plumbing/transport/internal/common","plumbing/transport/server","plumbing/transport/ssh","storage","storage/filesystem","storage/filesystem/dotgit","storage/memory","utils/binary","utils/diff","utils/ioutil","utils/merkletrie","utils/merkletrie/filesystem","utils/merkletrie/index","utils/merkletrie/internal/frame","utils/merkletrie/noder"]
|
packages = [
|
||||||
revision = "3bd5e82b2512d85becae9677fa06b5a973fd4cfb"
|
".",
|
||||||
version = "v4.5.0"
|
"config",
|
||||||
|
"internal/revision",
|
||||||
|
"plumbing",
|
||||||
|
"plumbing/cache",
|
||||||
|
"plumbing/filemode",
|
||||||
|
"plumbing/format/config",
|
||||||
|
"plumbing/format/diff",
|
||||||
|
"plumbing/format/gitignore",
|
||||||
|
"plumbing/format/idxfile",
|
||||||
|
"plumbing/format/index",
|
||||||
|
"plumbing/format/objfile",
|
||||||
|
"plumbing/format/packfile",
|
||||||
|
"plumbing/format/pktline",
|
||||||
|
"plumbing/object",
|
||||||
|
"plumbing/protocol/packp",
|
||||||
|
"plumbing/protocol/packp/capability",
|
||||||
|
"plumbing/protocol/packp/sideband",
|
||||||
|
"plumbing/revlist",
|
||||||
|
"plumbing/storer",
|
||||||
|
"plumbing/transport",
|
||||||
|
"plumbing/transport/client",
|
||||||
|
"plumbing/transport/file",
|
||||||
|
"plumbing/transport/git",
|
||||||
|
"plumbing/transport/http",
|
||||||
|
"plumbing/transport/internal/common",
|
||||||
|
"plumbing/transport/server",
|
||||||
|
"plumbing/transport/ssh",
|
||||||
|
"storage",
|
||||||
|
"storage/filesystem",
|
||||||
|
"storage/filesystem/dotgit",
|
||||||
|
"storage/memory",
|
||||||
|
"utils/binary",
|
||||||
|
"utils/diff",
|
||||||
|
"utils/ioutil",
|
||||||
|
"utils/merkletrie",
|
||||||
|
"utils/merkletrie/filesystem",
|
||||||
|
"utils/merkletrie/index",
|
||||||
|
"utils/merkletrie/internal/frame",
|
||||||
|
"utils/merkletrie/noder"
|
||||||
|
]
|
||||||
|
revision = "d3cec13ac0b195bfb897ed038a08b5130ab9969e"
|
||||||
|
version = "v4.7.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/warnings.v0"
|
name = "gopkg.in/warnings.v0"
|
||||||
@@ -148,6 +249,6 @@
|
|||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "5af7c639081bd99afc4a673e96079d2ed9e76d0e1bf0d2cc5ad9c71274beaa86"
|
inputs-digest = "8185a08afcb3ad854f58b49061fb70c57e7b64244abb43a08714d55cac7a97f9"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
+1
-1
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "gopkg.in/src-d/go-git.v4"
|
name = "gopkg.in/src-d/go-git.v4"
|
||||||
version = "4.5.0"
|
version = "4.7.0"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
|
|||||||
+674
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
.PHONY: test build-all release
|
.PHONY: test build-all deploy
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go get github.com/golang/lint/golint
|
go get github.com/golang/lint/golint
|
||||||
go fmt
|
go fmt
|
||||||
golint
|
golint
|
||||||
go test --race -cover
|
go test --race --cover -run=Test$
|
||||||
deploy:
|
deploy:
|
||||||
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
||||||
docker build -f Dockerfile -t $(REPO):$(TAG) .
|
docker build -f Dockerfile -t $(REPO):$(TAG) .
|
||||||
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
||||||
docker push $(REPO)
|
docker push $(REPO)
|
||||||
|
|
||||||
build-all:
|
build-all:
|
||||||
|
rm -rf build
|
||||||
mkdir build
|
mkdir build
|
||||||
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe"
|
env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe"
|
||||||
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe"
|
env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe"
|
||||||
@@ -20,3 +20,8 @@ build-all:
|
|||||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
||||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
||||||
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64"
|
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64"
|
||||||
|
benchmark:
|
||||||
|
go test -run=Benchmark -bench=. -benchtime=5s
|
||||||
|
benchmark-fast:
|
||||||
|
go test -bench=BenchmarkAuditLeakRepo -run=BenchmarkAuditLeakRepo$
|
||||||
|
|
||||||
@@ -5,8 +5,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Audit git repos for secrets, keys, and whatever.
|
## Audit git repos for secrets
|
||||||
### Powered by src-d's [go-git](https://github.com/src-d/go-git)
|
### Powered by src-d's [go-git](https://github.com/src-d/go-git)
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://cdn.rawgit.com/zricethezav/5bf8259b7fea0170becffc06b8588edb/raw/f762769fe20ef3669bff34612b1bede6457631e6/termtosvg_je8bp82s.svg">
|
||||||
|
</p>
|
||||||
|
|
||||||
#### Installing
|
#### Installing
|
||||||
|
|
||||||
@@ -25,7 +28,9 @@ Application Options:
|
|||||||
-r, --repo= Repo url to audit
|
-r, --repo= Repo url to audit
|
||||||
--github-user= User url to audit
|
--github-user= User url to audit
|
||||||
--github-org= Organization url to audit
|
--github-org= Organization url to audit
|
||||||
|
--github-url= GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/ (default: https://api.github.com/)
|
||||||
-p, --private Include private repos in audit
|
-p, --private Include private repos in audit
|
||||||
|
-b, --branch= branch name to audit (defaults to HEAD)
|
||||||
-c, --commit= sha of commit to stop at
|
-c, --commit= sha of commit to stop at
|
||||||
--repo-path= Path to repo
|
--repo-path= Path to repo
|
||||||
--owner-path= Path to owner directory (repos discovered)
|
--owner-path= Path to owner directory (repos discovered)
|
||||||
@@ -38,15 +43,19 @@ Application Options:
|
|||||||
-l, --log= log level
|
-l, --log= log level
|
||||||
-v, --verbose Show verbose output from gitleaks audit
|
-v, --verbose Show verbose output from gitleaks audit
|
||||||
--report= path to write report file
|
--report= path to write report file
|
||||||
|
--csv report output to csv
|
||||||
--redact redact secrets from log messages and report
|
--redact redact secrets from log messages and report
|
||||||
|
--version version number
|
||||||
|
--sample-config prints a sample config file
|
||||||
|
|
||||||
Help Options:
|
Help Options:
|
||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
```
|
```
|
||||||
#### Exit Codes
|
#### Exit Codes
|
||||||
```
|
```
|
||||||
1: leaks present
|
|
||||||
0: no leaks
|
0: no leaks
|
||||||
|
1: leaks present
|
||||||
|
2: error encountered
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Additional Examples and Explanations
|
#### Additional Examples and Explanations
|
||||||
|
|||||||
+3
-3
@@ -18,13 +18,13 @@ regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
|
|||||||
description = "Facebook"
|
description = "Facebook"
|
||||||
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
|
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
|
||||||
[[regexes]]
|
[[regexes]]
|
||||||
description = "Facebook"
|
description = "Twitter"
|
||||||
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
regexes = [
|
regexes = [
|
||||||
"AKIA.*",
|
# "AKIA.*EXAMPLE",
|
||||||
]
|
]
|
||||||
files = [
|
files = [
|
||||||
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
|
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
|
||||||
]
|
]
|
||||||
+361
-41
@@ -56,6 +56,46 @@ regexes= [
|
|||||||
]
|
]
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testWhitelistRepo = `
|
||||||
|
[[regexes]]
|
||||||
|
description = "AWS"
|
||||||
|
regex = '''AKIA[0-9A-Z]{16}'''
|
||||||
|
|
||||||
|
[whitelist]
|
||||||
|
repos = [
|
||||||
|
"gronit",
|
||||||
|
]
|
||||||
|
`
|
||||||
|
|
||||||
|
var benchmarkRepo *RepoDescriptor
|
||||||
|
var benchmarkLeaksRepo *RepoDescriptor
|
||||||
|
|
||||||
|
func getBenchmarkLeaksRepo() *RepoDescriptor {
|
||||||
|
if benchmarkLeaksRepo != nil {
|
||||||
|
return benchmarkLeaksRepo
|
||||||
|
}
|
||||||
|
leaksR, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
|
URL: "https://github.com/gitleakstest/gronit.git",
|
||||||
|
})
|
||||||
|
benchmarkLeaksRepo = &RepoDescriptor{
|
||||||
|
repository: leaksR,
|
||||||
|
}
|
||||||
|
return benchmarkLeaksRepo
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBenchmarkRepo() *RepoDescriptor {
|
||||||
|
if benchmarkRepo != nil {
|
||||||
|
return benchmarkRepo
|
||||||
|
}
|
||||||
|
bmRepo, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
|
URL: "https://github.com/apple/swift-package-manager.git",
|
||||||
|
})
|
||||||
|
benchmarkRepo = &RepoDescriptor{
|
||||||
|
repository: bmRepo,
|
||||||
|
}
|
||||||
|
return benchmarkRepo
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetRepo(t *testing.T) {
|
func TestGetRepo(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
dir, err = ioutil.TempDir("", "gitleaksTestRepo")
|
dir, err = ioutil.TempDir("", "gitleaksTestRepo")
|
||||||
@@ -128,7 +168,7 @@ func TestGetRepo(t *testing.T) {
|
|||||||
g.Describe("TestGetRepo", func() {
|
g.Describe("TestGetRepo", func() {
|
||||||
g.It(test.description, func() {
|
g.It(test.description, func() {
|
||||||
opts = test.testOpts
|
opts = test.testOpts
|
||||||
_, err := getRepo()
|
_, err := cloneRepo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||||
}
|
}
|
||||||
@@ -136,9 +176,10 @@ func TestGetRepo(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func TestRun(t *testing.T) {
|
||||||
func TestGetOwnerRepo(t *testing.T) {
|
|
||||||
var err error
|
var err error
|
||||||
|
configsDir := testTomlLoader()
|
||||||
|
|
||||||
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -154,14 +195,16 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
testOpts Options
|
testOpts Options
|
||||||
description string
|
description string
|
||||||
expectedErrMsg string
|
expectedErrMsg string
|
||||||
numRepos int
|
whiteListRepos []string
|
||||||
|
numLeaks int
|
||||||
|
configPath string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubUser: "gitleakstest",
|
GithubUser: "gitleakstest",
|
||||||
},
|
},
|
||||||
description: "test github user",
|
description: "test github user",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -170,7 +213,7 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
Disk: true,
|
Disk: true,
|
||||||
},
|
},
|
||||||
description: "test github user on disk ",
|
description: "test github user on disk ",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -178,56 +221,92 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
},
|
},
|
||||||
description: "test github org",
|
description: "test github org",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
OwnerPath: dir,
|
|
||||||
},
|
|
||||||
description: "test plain clone remote repo",
|
|
||||||
numRepos: 2,
|
|
||||||
expectedErrMsg: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
GithubOrg: "gitleakstestorg",
|
|
||||||
IncludePrivate: true,
|
|
||||||
},
|
|
||||||
description: "test private org no ssh",
|
|
||||||
numRepos: 0,
|
|
||||||
expectedErrMsg: "no ssh auth available",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
Disk: true,
|
Disk: true,
|
||||||
},
|
},
|
||||||
description: "test org on disk",
|
description: "test org on disk",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
OwnerPath: dir,
|
||||||
|
},
|
||||||
|
description: "test owner path",
|
||||||
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
IncludePrivate: true,
|
IncludePrivate: true,
|
||||||
Disk: true,
|
SSHKey: "reallyreallyreallyreallywrongpath",
|
||||||
},
|
},
|
||||||
description: "test private org on disk no ssh",
|
description: "test private org no ssh",
|
||||||
numRepos: 0,
|
numLeaks: 0,
|
||||||
expectedErrMsg: "no ssh auth available",
|
expectedErrMsg: "unable to generate ssh key: open reallyreallyreallyreallywrongpath: no such file or directory",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/gronit.git",
|
||||||
|
},
|
||||||
|
description: "test leak",
|
||||||
|
numLeaks: 2,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/h1domains.git",
|
||||||
|
},
|
||||||
|
description: "test clean",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/empty.git",
|
||||||
|
},
|
||||||
|
description: "test empty",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "reference not found",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
GithubOrg: "gitleakstestorg",
|
||||||
|
},
|
||||||
|
description: "test github org, whitelist repo",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
configPath: path.Join(configsDir, "repo"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
GithubOrg: "gitleakstestorg",
|
||||||
|
ExcludeForks: true,
|
||||||
|
},
|
||||||
|
description: "test github org, exclude forks",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
g := goblin.Goblin(t)
|
g := goblin.Goblin(t)
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
g.Describe("TestGetOwnerRepo", func() {
|
g.Describe("TestRun", func() {
|
||||||
g.It(test.description, func() {
|
g.It(test.description, func() {
|
||||||
|
if test.configPath != "" {
|
||||||
|
os.Setenv("GITLEAKS_CONFIG", test.configPath)
|
||||||
|
}
|
||||||
opts = test.testOpts
|
opts = test.testOpts
|
||||||
repos, err := getOwnerRepos()
|
leaks, err := run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||||
}
|
}
|
||||||
g.Assert(len(repos)).Equal(test.numRepos)
|
g.Assert(len(leaks)).Equal(test.numLeaks)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -235,7 +314,8 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
|
|
||||||
func TestWriteReport(t *testing.T) {
|
func TestWriteReport(t *testing.T) {
|
||||||
tmpDir, _ := ioutil.TempDir("", "reportDir")
|
tmpDir, _ := ioutil.TempDir("", "reportDir")
|
||||||
reportFile := path.Join(tmpDir, "report.json")
|
reportJSON := path.Join(tmpDir, "report.json")
|
||||||
|
reportCSV := path.Join(tmpDir, "report.csv")
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
leaks := []Leak{
|
leaks := []Leak{
|
||||||
{
|
{
|
||||||
@@ -259,11 +339,21 @@ func TestWriteReport(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
leaks: leaks,
|
leaks: leaks,
|
||||||
reportFile: reportFile,
|
reportFile: reportJSON,
|
||||||
fileName: "report.json",
|
fileName: "report.json",
|
||||||
description: "can we write a file",
|
description: "can we write a file",
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
Report: reportFile,
|
Report: reportJSON,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
leaks: leaks,
|
||||||
|
reportFile: reportCSV,
|
||||||
|
fileName: "report.csv",
|
||||||
|
description: "can we write a file",
|
||||||
|
testOpts: Options{
|
||||||
|
Report: reportCSV,
|
||||||
|
CSV: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -287,6 +377,7 @@ func testTomlLoader() string {
|
|||||||
ioutil.WriteFile(path.Join(tmpDir, "branch"), []byte(testWhitelistBranch), 0644)
|
ioutil.WriteFile(path.Join(tmpDir, "branch"), []byte(testWhitelistBranch), 0644)
|
||||||
ioutil.WriteFile(path.Join(tmpDir, "commit"), []byte(testWhitelistCommit), 0644)
|
ioutil.WriteFile(path.Join(tmpDir, "commit"), []byte(testWhitelistCommit), 0644)
|
||||||
ioutil.WriteFile(path.Join(tmpDir, "file"), []byte(testWhitelistFile), 0644)
|
ioutil.WriteFile(path.Join(tmpDir, "file"), []byte(testWhitelistFile), 0644)
|
||||||
|
ioutil.WriteFile(path.Join(tmpDir, "repo"), []byte(testWhitelistRepo), 0644)
|
||||||
return tmpDir
|
return tmpDir
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,29 +390,38 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
leaksRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
leaksR, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: "https://github.com/gitleakstest/gronit.git",
|
URL: "https://github.com/gitleakstest/gronit.git",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
leaksRepo := &RepoDescriptor{
|
||||||
|
repository: leaksR,
|
||||||
|
name: "gronit",
|
||||||
|
}
|
||||||
|
|
||||||
cleanRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
cleanR, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: "https://github.com/gitleakstest/h1domains.git",
|
URL: "https://github.com/gitleakstest/h1domains.git",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
cleanRepo := &RepoDescriptor{
|
||||||
|
repository: cleanR,
|
||||||
|
name: "h1domains",
|
||||||
|
}
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
testOpts Options
|
testOpts Options
|
||||||
description string
|
description string
|
||||||
expectedErrMsg string
|
expectedErrMsg string
|
||||||
numLeaks int
|
numLeaks int
|
||||||
repo *git.Repository
|
repo *RepoDescriptor
|
||||||
whiteListFiles []*regexp.Regexp
|
whiteListFiles []*regexp.Regexp
|
||||||
whiteListCommits map[string]bool
|
whiteListCommits map[string]bool
|
||||||
whiteListBranches []string
|
whiteListBranches []string
|
||||||
|
whiteListRepos []string
|
||||||
whiteListRegexes []*regexp.Regexp
|
whiteListRegexes []*regexp.Regexp
|
||||||
configPath string
|
configPath string
|
||||||
}{
|
}{
|
||||||
@@ -335,7 +435,23 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
description: "two leaks present limit goroutines",
|
description: "two leaks present limit goroutines",
|
||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
MaxGoRoutines: 2,
|
MaxGoRoutines: 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "audit specific bad branch",
|
||||||
|
numLeaks: 2,
|
||||||
|
testOpts: Options{
|
||||||
|
Branch: "master",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "audit specific good branch",
|
||||||
|
numLeaks: 0,
|
||||||
|
testOpts: Options{
|
||||||
|
Branch: "dev",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -384,12 +500,14 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
numLeaks: 0,
|
numLeaks: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// note this double counts the first commit since we are whitelisting
|
||||||
|
// a "bad" first commit
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "two leaks present whitelist bad commit",
|
description: "two leaks present whitelist bad commit",
|
||||||
whiteListCommits: map[string]bool{
|
whiteListCommits: map[string]bool{
|
||||||
"eaeffdc65b4c73ccb67e75d96bd8743be2c85973": true,
|
"eaeffdc65b4c73ccb67e75d96bd8743be2c85973": true,
|
||||||
},
|
},
|
||||||
numLeaks: 1,
|
numLeaks: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
@@ -421,10 +539,42 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
numLeaks: 0,
|
numLeaks: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// note this double counts the first commit since we are whitelisting
|
||||||
|
// a "bad" first commit
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "toml whitelist commit",
|
description: "toml whitelist commit",
|
||||||
configPath: path.Join(configsDir, "commit"),
|
configPath: path.Join(configsDir, "commit"),
|
||||||
|
numLeaks: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "audit whitelist repo",
|
||||||
|
numLeaks: 0,
|
||||||
|
whiteListRepos: []string{
|
||||||
|
"gronit",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "toml whitelist repo",
|
||||||
|
numLeaks: 0,
|
||||||
|
configPath: path.Join(configsDir, "repo"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "leaks present with entropy",
|
||||||
|
testOpts: Options{
|
||||||
|
Entropy: 4.7,
|
||||||
|
},
|
||||||
|
numLeaks: 7,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "Audit until specific commit",
|
||||||
numLeaks: 1,
|
numLeaks: 1,
|
||||||
|
testOpts: Options{
|
||||||
|
Commit: "f6839959b7bbdcd23008f1fb16f797f35bcd3a0c",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,6 +605,11 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
whiteListRegexes = nil
|
whiteListRegexes = nil
|
||||||
}
|
}
|
||||||
|
if test.whiteListRepos != nil {
|
||||||
|
whiteListRepos = test.whiteListRepos
|
||||||
|
} else {
|
||||||
|
whiteListRepos = nil
|
||||||
|
}
|
||||||
|
|
||||||
// config paths
|
// config paths
|
||||||
if test.configPath != "" {
|
if test.configPath != "" {
|
||||||
@@ -462,7 +617,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
loadToml()
|
loadToml()
|
||||||
}
|
}
|
||||||
|
|
||||||
leaks, err = auditRepo(test.repo)
|
leaks, err = auditGitRepo(test.repo)
|
||||||
|
|
||||||
if opts.Redact {
|
if opts.Redact {
|
||||||
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
||||||
@@ -547,6 +702,14 @@ func TestOptionGuard(t *testing.T) {
|
|||||||
description: "single search regex gaurd",
|
description: "single search regex gaurd",
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
GithubOrg: "fakeOrg",
|
||||||
|
Entropy: 9,
|
||||||
|
},
|
||||||
|
description: "Invalid entropy level guard",
|
||||||
|
expectedErrMsg: "The maximum level of entropy is 8",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
g := goblin.Goblin(t)
|
g := goblin.Goblin(t)
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
@@ -648,3 +811,160 @@ func TestLoadToml(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo1Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo2Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 2
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo4Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 4
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo8Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 8
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo10Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo100Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo1000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1000
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditRepo10000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10000
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditRepo100000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100000
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditLeakRepo1Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo2Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 2
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo4Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 4
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo8Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 8
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo10Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditLeakRepo100Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditLeakRepo1000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1000
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo10000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10000
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo100000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100000
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-10
@@ -1,14 +1,21 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The MIT License (MIT)
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (c) 2013 TOML authors
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
copies of this license document, and changing it is allowed as long
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
as the name is changed.
|
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:
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The above copyright notice and this permission notice shall be included in
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
||||||
|
|
||||||
|
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.
|
||||||
+17
-10
@@ -1,14 +1,21 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The MIT License (MIT)
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (c) 2013 TOML authors
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
copies of this license document, and changing it is allowed as long
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
as the name is changed.
|
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:
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The above copyright notice and this permission notice shall be included in
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
||||||
|
|
||||||
|
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.
|
||||||
+17
-10
@@ -1,14 +1,21 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The MIT License (MIT)
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (c) 2013 TOML authors
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
copies of this license document, and changing it is allowed as long
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
as the name is changed.
|
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:
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The above copyright notice and this permission notice shall be included in
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
||||||
|
|
||||||
|
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.
|
||||||
+17
-10
@@ -1,14 +1,21 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The MIT License (MIT)
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (c) 2013 TOML authors
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
copies of this license document, and changing it is allowed as long
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
as the name is changed.
|
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:
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
The above copyright notice and this permission notice shall be included in
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
||||||
|
|
||||||
|
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.
|
||||||
+1
-1
@@ -775,7 +775,7 @@ func lexDatetime(lx *lexer) stateFn {
|
|||||||
return lexDatetime
|
return lexDatetime
|
||||||
}
|
}
|
||||||
switch r {
|
switch r {
|
||||||
case '-', 'T', ':', '.', 'Z':
|
case '-', 'T', ':', '.', 'Z', '+':
|
||||||
return lexDatetime
|
return lexDatetime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ type EnumerableWithIndex interface {
|
|||||||
|
|
||||||
// Map invokes the given function once for each element and returns a
|
// Map invokes the given function once for each element and returns a
|
||||||
// container containing the values returned by the given function.
|
// container containing the values returned by the given function.
|
||||||
// TODO need help on how to enforce this in containers (don't want to type assert when chaining)
|
// TODO would appreciate help on how to enforce this in containers (don't want to type assert when chaining)
|
||||||
// Map(func(index int, value interface{}) interface{}) Container
|
// Map(func(index int, value interface{}) interface{}) Container
|
||||||
|
|
||||||
// Select returns a new container containing all elements for which the given function returns a true value.
|
// Select returns a new container containing all elements for which the given function returns a true value.
|
||||||
|
|||||||
+40
-12
@@ -11,9 +11,10 @@ package arraylist
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/emirpasic/gods/lists"
|
"github.com/emirpasic/gods/lists"
|
||||||
"github.com/emirpasic/gods/utils"
|
"github.com/emirpasic/gods/utils"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func assertListImplementation() {
|
func assertListImplementation() {
|
||||||
@@ -31,9 +32,13 @@ const (
|
|||||||
shrinkFactor = float32(0.25) // shrink when size is 25% of capacity (0 means never shrink)
|
shrinkFactor = float32(0.25) // shrink when size is 25% of capacity (0 means never shrink)
|
||||||
)
|
)
|
||||||
|
|
||||||
// New instantiates a new empty list
|
// New instantiates a new list and adds the passed values, if any, to the list
|
||||||
func New() *List {
|
func New(values ...interface{}) *List {
|
||||||
return &List{}
|
list := &List{}
|
||||||
|
if len(values) > 0 {
|
||||||
|
list.Add(values...)
|
||||||
|
}
|
||||||
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add appends a value at the end of the list
|
// Add appends a value at the end of the list
|
||||||
@@ -56,7 +61,7 @@ func (list *List) Get(index int) (interface{}, bool) {
|
|||||||
return list.elements[index], true
|
return list.elements[index], true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove removes one or more elements from the list with the supplied indices.
|
// Remove removes the element at the given index from the list.
|
||||||
func (list *List) Remove(index int) {
|
func (list *List) Remove(index int) {
|
||||||
|
|
||||||
if !list.withinRange(index) {
|
if !list.withinRange(index) {
|
||||||
@@ -98,6 +103,19 @@ func (list *List) Values() []interface{} {
|
|||||||
return newElements
|
return newElements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//IndexOf returns index of provided element
|
||||||
|
func (list *List) IndexOf(value interface{}) int {
|
||||||
|
if list.size == 0 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
for index, element := range list.elements {
|
||||||
|
if element == value {
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
// Empty returns true if list does not contain any elements.
|
// Empty returns true if list does not contain any elements.
|
||||||
func (list *List) Empty() bool {
|
func (list *List) Empty() bool {
|
||||||
return list.size == 0
|
return list.size == 0
|
||||||
@@ -145,14 +163,24 @@ func (list *List) Insert(index int, values ...interface{}) {
|
|||||||
l := len(values)
|
l := len(values)
|
||||||
list.growBy(l)
|
list.growBy(l)
|
||||||
list.size += l
|
list.size += l
|
||||||
// Shift old to right
|
copy(list.elements[index+l:], list.elements[index:list.size-l])
|
||||||
for i := list.size - 1; i >= index+l; i-- {
|
copy(list.elements[index:], values)
|
||||||
list.elements[i] = list.elements[i-l]
|
}
|
||||||
}
|
|
||||||
// Insert new
|
// Set the value at specified index
|
||||||
for i, value := range values {
|
// Does not do anything if position is negative or bigger than list's size
|
||||||
list.elements[index+i] = value
|
// Note: position equal to list's size is valid, i.e. append.
|
||||||
|
func (list *List) Set(index int, value interface{}) {
|
||||||
|
|
||||||
|
if !list.withinRange(index) {
|
||||||
|
// Append
|
||||||
|
if index == list.size {
|
||||||
|
list.Add(value)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.elements[index] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a string representation of container
|
// String returns a string representation of container
|
||||||
|
|||||||
+1
@@ -23,6 +23,7 @@ type List interface {
|
|||||||
Sort(comparator utils.Comparator)
|
Sort(comparator utils.Comparator)
|
||||||
Swap(index1, index2 int)
|
Swap(index1, index2 int)
|
||||||
Insert(index int, values ...interface{})
|
Insert(index int, values ...interface{})
|
||||||
|
Set(index int, value interface{})
|
||||||
|
|
||||||
containers.Container
|
containers.Container
|
||||||
// Empty() bool
|
// Empty() bool
|
||||||
|
|||||||
+2
-2
@@ -11,12 +11,12 @@ func assertSerializationImplementation() {
|
|||||||
var _ containers.JSONDeserializer = (*Heap)(nil)
|
var _ containers.JSONDeserializer = (*Heap)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of list's elements.
|
// ToJSON outputs the JSON representation of the heap.
|
||||||
func (heap *Heap) ToJSON() ([]byte, error) {
|
func (heap *Heap) ToJSON() ([]byte, error) {
|
||||||
return heap.list.ToJSON()
|
return heap.list.ToJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromJSON populates list's elements from the input JSON representation.
|
// FromJSON populates the heap from the input JSON representation.
|
||||||
func (heap *Heap) FromJSON(data []byte) error {
|
func (heap *Heap) FromJSON(data []byte) error {
|
||||||
return heap.list.FromJSON(data)
|
return heap.list.FromJSON(data)
|
||||||
}
|
}
|
||||||
-3
@@ -1,7 +1,4 @@
|
|||||||
Go support for Protocol Buffers - Google's data interchange format
|
|
||||||
|
|
||||||
Copyright 2010 The Go Authors. All rights reserved.
|
Copyright 2010 The Go Authors. All rights reserved.
|
||||||
https://github.com/golang/protobuf
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
|||||||
-18
@@ -37,27 +37,9 @@ package proto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RequiredNotSetError is the error returned if Marshal is called with
|
|
||||||
// a protocol buffer struct whose required fields have not
|
|
||||||
// all been initialized. It is also the error returned if Unmarshal is
|
|
||||||
// called with an encoded protocol buffer that does not include all the
|
|
||||||
// required fields.
|
|
||||||
//
|
|
||||||
// When printed, RequiredNotSetError reports the first unset required field in a
|
|
||||||
// message. If the field cannot be precisely determined, it is reported as
|
|
||||||
// "{Unknown}".
|
|
||||||
type RequiredNotSetError struct {
|
|
||||||
field string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *RequiredNotSetError) Error() string {
|
|
||||||
return fmt.Sprintf("proto: required field %q not set", e.field)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// errRepeatedHasNil is the error returned if Marshal is called with
|
// errRepeatedHasNil is the error returned if Marshal is called with
|
||||||
// a struct with a repeated field containing a nil element.
|
// a struct with a repeated field containing a nil element.
|
||||||
|
|||||||
+60
-2
@@ -265,7 +265,6 @@ package proto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -274,7 +273,66 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errInvalidUTF8 = errors.New("proto: invalid UTF-8 string")
|
// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
|
||||||
|
// Marshal reports this when a required field is not initialized.
|
||||||
|
// Unmarshal reports this when a required field is missing from the wire data.
|
||||||
|
type RequiredNotSetError struct{ field string }
|
||||||
|
|
||||||
|
func (e *RequiredNotSetError) Error() string {
|
||||||
|
if e.field == "" {
|
||||||
|
return fmt.Sprintf("proto: required field not set")
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("proto: required field %q not set", e.field)
|
||||||
|
}
|
||||||
|
func (e *RequiredNotSetError) RequiredNotSet() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
type invalidUTF8Error struct{ field string }
|
||||||
|
|
||||||
|
func (e *invalidUTF8Error) Error() string {
|
||||||
|
if e.field == "" {
|
||||||
|
return "proto: invalid UTF-8 detected"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field)
|
||||||
|
}
|
||||||
|
func (e *invalidUTF8Error) InvalidUTF8() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8.
|
||||||
|
// This error should not be exposed to the external API as such errors should
|
||||||
|
// be recreated with the field information.
|
||||||
|
var errInvalidUTF8 = &invalidUTF8Error{}
|
||||||
|
|
||||||
|
// isNonFatal reports whether the error is either a RequiredNotSet error
|
||||||
|
// or a InvalidUTF8 error.
|
||||||
|
func isNonFatal(err error) bool {
|
||||||
|
if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type nonFatal struct{ E error }
|
||||||
|
|
||||||
|
// Merge merges err into nf and reports whether it was successful.
|
||||||
|
// Otherwise it returns false for any fatal non-nil errors.
|
||||||
|
func (nf *nonFatal) Merge(err error) (ok bool) {
|
||||||
|
if err == nil {
|
||||||
|
return true // not an error
|
||||||
|
}
|
||||||
|
if !isNonFatal(err) {
|
||||||
|
return false // fatal error
|
||||||
|
}
|
||||||
|
if nf.E == nil {
|
||||||
|
nf.E = err // store first instance of non-fatal error
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Message is implemented by generated protocol buffer messages.
|
// Message is implemented by generated protocol buffer messages.
|
||||||
type Message interface {
|
type Message interface {
|
||||||
|
|||||||
+8
-8
@@ -139,7 +139,7 @@ type Properties struct {
|
|||||||
Repeated bool
|
Repeated bool
|
||||||
Packed bool // relevant for repeated primitives only
|
Packed bool // relevant for repeated primitives only
|
||||||
Enum string // set for enum types only
|
Enum string // set for enum types only
|
||||||
proto3 bool // whether this is known to be a proto3 field; set for []byte only
|
proto3 bool // whether this is known to be a proto3 field
|
||||||
oneof bool // whether this is a oneof field
|
oneof bool // whether this is a oneof field
|
||||||
|
|
||||||
Default string // default value
|
Default string // default value
|
||||||
@@ -148,9 +148,9 @@ type Properties struct {
|
|||||||
stype reflect.Type // set for struct types only
|
stype reflect.Type // set for struct types only
|
||||||
sprop *StructProperties // set for struct types only
|
sprop *StructProperties // set for struct types only
|
||||||
|
|
||||||
mtype reflect.Type // set for map types only
|
mtype reflect.Type // set for map types only
|
||||||
mkeyprop *Properties // set for map types only
|
MapKeyProp *Properties // set for map types only
|
||||||
mvalprop *Properties // set for map types only
|
MapValProp *Properties // set for map types only
|
||||||
}
|
}
|
||||||
|
|
||||||
// String formats the properties in the protobuf struct field tag style.
|
// String formats the properties in the protobuf struct field tag style.
|
||||||
@@ -275,16 +275,16 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc
|
|||||||
|
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
p.mtype = t1
|
p.mtype = t1
|
||||||
p.mkeyprop = &Properties{}
|
p.MapKeyProp = &Properties{}
|
||||||
p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
|
p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
|
||||||
p.mvalprop = &Properties{}
|
p.MapValProp = &Properties{}
|
||||||
vtype := p.mtype.Elem()
|
vtype := p.mtype.Elem()
|
||||||
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
|
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
|
||||||
// The value type is not a message (*T) or bytes ([]byte),
|
// The value type is not a message (*T) or bytes ([]byte),
|
||||||
// so we need encoders for the pointer to this type.
|
// so we need encoders for the pointer to this type.
|
||||||
vtype = reflect.PtrTo(vtype)
|
vtype = reflect.PtrTo(vtype)
|
||||||
}
|
}
|
||||||
p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
|
p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.stype != nil {
|
if p.stype != nil {
|
||||||
|
|||||||
+138
-52
@@ -231,7 +231,7 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
|
|||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var err, errreq error
|
var err, errLater error
|
||||||
// The old marshaler encodes extensions at beginning.
|
// The old marshaler encodes extensions at beginning.
|
||||||
if u.extensions.IsValid() {
|
if u.extensions.IsValid() {
|
||||||
e := ptr.offset(u.extensions).toExtensions()
|
e := ptr.offset(u.extensions).toExtensions()
|
||||||
@@ -252,11 +252,13 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, f := range u.fields {
|
for _, f := range u.fields {
|
||||||
if f.required && errreq == nil {
|
if f.required {
|
||||||
if ptr.offset(f.field).getPointer().isNil() {
|
if ptr.offset(f.field).getPointer().isNil() {
|
||||||
// Required field is not set.
|
// Required field is not set.
|
||||||
// We record the error but keep going, to give a complete marshaling.
|
// We record the error but keep going, to give a complete marshaling.
|
||||||
errreq = &RequiredNotSetError{f.name}
|
if errLater == nil {
|
||||||
|
errLater = &RequiredNotSetError{f.name}
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,14 +271,21 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
|
|||||||
if err1, ok := err.(*RequiredNotSetError); ok {
|
if err1, ok := err.(*RequiredNotSetError); ok {
|
||||||
// Required field in submessage is not set.
|
// Required field in submessage is not set.
|
||||||
// We record the error but keep going, to give a complete marshaling.
|
// We record the error but keep going, to give a complete marshaling.
|
||||||
if errreq == nil {
|
if errLater == nil {
|
||||||
errreq = &RequiredNotSetError{f.name + "." + err1.field}
|
errLater = &RequiredNotSetError{f.name + "." + err1.field}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err == errRepeatedHasNil {
|
if err == errRepeatedHasNil {
|
||||||
err = errors.New("proto: repeated field " + f.name + " has nil element")
|
err = errors.New("proto: repeated field " + f.name + " has nil element")
|
||||||
}
|
}
|
||||||
|
if err == errInvalidUTF8 {
|
||||||
|
if errLater == nil {
|
||||||
|
fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name
|
||||||
|
errLater = &invalidUTF8Error{fullName}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +293,7 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
|
|||||||
s := *ptr.offset(u.unrecognized).toBytes()
|
s := *ptr.offset(u.unrecognized).toBytes()
|
||||||
b = append(b, s...)
|
b = append(b, s...)
|
||||||
}
|
}
|
||||||
return b, errreq
|
return b, errLater
|
||||||
}
|
}
|
||||||
|
|
||||||
// computeMarshalInfo initializes the marshal info.
|
// computeMarshalInfo initializes the marshal info.
|
||||||
@@ -530,6 +539,7 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma
|
|||||||
|
|
||||||
packed := false
|
packed := false
|
||||||
proto3 := false
|
proto3 := false
|
||||||
|
validateUTF8 := true
|
||||||
for i := 2; i < len(tags); i++ {
|
for i := 2; i < len(tags); i++ {
|
||||||
if tags[i] == "packed" {
|
if tags[i] == "packed" {
|
||||||
packed = true
|
packed = true
|
||||||
@@ -538,6 +548,7 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma
|
|||||||
proto3 = true
|
proto3 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
validateUTF8 = validateUTF8 && proto3
|
||||||
|
|
||||||
switch t.Kind() {
|
switch t.Kind() {
|
||||||
case reflect.Bool:
|
case reflect.Bool:
|
||||||
@@ -735,6 +746,18 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma
|
|||||||
}
|
}
|
||||||
return sizeFloat64Value, appendFloat64Value
|
return sizeFloat64Value, appendFloat64Value
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
|
if validateUTF8 {
|
||||||
|
if pointer {
|
||||||
|
return sizeStringPtr, appendUTF8StringPtr
|
||||||
|
}
|
||||||
|
if slice {
|
||||||
|
return sizeStringSlice, appendUTF8StringSlice
|
||||||
|
}
|
||||||
|
if nozero {
|
||||||
|
return sizeStringValueNoZero, appendUTF8StringValueNoZero
|
||||||
|
}
|
||||||
|
return sizeStringValue, appendUTF8StringValue
|
||||||
|
}
|
||||||
if pointer {
|
if pointer {
|
||||||
return sizeStringPtr, appendStringPtr
|
return sizeStringPtr, appendStringPtr
|
||||||
}
|
}
|
||||||
@@ -1984,9 +2007,6 @@ func appendBoolPackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byt
|
|||||||
}
|
}
|
||||||
func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
v := *ptr.toString()
|
v := *ptr.toString()
|
||||||
if !utf8.ValidString(v) {
|
|
||||||
return nil, errInvalidUTF8
|
|
||||||
}
|
|
||||||
b = appendVarint(b, wiretag)
|
b = appendVarint(b, wiretag)
|
||||||
b = appendVarint(b, uint64(len(v)))
|
b = appendVarint(b, uint64(len(v)))
|
||||||
b = append(b, v...)
|
b = append(b, v...)
|
||||||
@@ -1997,9 +2017,6 @@ func appendStringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]b
|
|||||||
if v == "" {
|
if v == "" {
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
if !utf8.ValidString(v) {
|
|
||||||
return nil, errInvalidUTF8
|
|
||||||
}
|
|
||||||
b = appendVarint(b, wiretag)
|
b = appendVarint(b, wiretag)
|
||||||
b = appendVarint(b, uint64(len(v)))
|
b = appendVarint(b, uint64(len(v)))
|
||||||
b = append(b, v...)
|
b = append(b, v...)
|
||||||
@@ -2011,24 +2028,83 @@ func appendStringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, err
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
v := *p
|
v := *p
|
||||||
if !utf8.ValidString(v) {
|
|
||||||
return nil, errInvalidUTF8
|
|
||||||
}
|
|
||||||
b = appendVarint(b, wiretag)
|
b = appendVarint(b, wiretag)
|
||||||
b = appendVarint(b, uint64(len(v)))
|
b = appendVarint(b, uint64(len(v)))
|
||||||
b = append(b, v...)
|
b = append(b, v...)
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
|
s := *ptr.toStringSlice()
|
||||||
|
for _, v := range s {
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(v)))
|
||||||
|
b = append(b, v...)
|
||||||
|
}
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
func appendUTF8StringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
|
var invalidUTF8 bool
|
||||||
|
v := *ptr.toString()
|
||||||
|
if !utf8.ValidString(v) {
|
||||||
|
invalidUTF8 = true
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(v)))
|
||||||
|
b = append(b, v...)
|
||||||
|
if invalidUTF8 {
|
||||||
|
return b, errInvalidUTF8
|
||||||
|
}
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
func appendUTF8StringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
|
var invalidUTF8 bool
|
||||||
|
v := *ptr.toString()
|
||||||
|
if v == "" {
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
if !utf8.ValidString(v) {
|
||||||
|
invalidUTF8 = true
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(v)))
|
||||||
|
b = append(b, v...)
|
||||||
|
if invalidUTF8 {
|
||||||
|
return b, errInvalidUTF8
|
||||||
|
}
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
func appendUTF8StringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
|
var invalidUTF8 bool
|
||||||
|
p := *ptr.toStringPtr()
|
||||||
|
if p == nil {
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
v := *p
|
||||||
|
if !utf8.ValidString(v) {
|
||||||
|
invalidUTF8 = true
|
||||||
|
}
|
||||||
|
b = appendVarint(b, wiretag)
|
||||||
|
b = appendVarint(b, uint64(len(v)))
|
||||||
|
b = append(b, v...)
|
||||||
|
if invalidUTF8 {
|
||||||
|
return b, errInvalidUTF8
|
||||||
|
}
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
func appendUTF8StringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
|
var invalidUTF8 bool
|
||||||
s := *ptr.toStringSlice()
|
s := *ptr.toStringSlice()
|
||||||
for _, v := range s {
|
for _, v := range s {
|
||||||
if !utf8.ValidString(v) {
|
if !utf8.ValidString(v) {
|
||||||
return nil, errInvalidUTF8
|
invalidUTF8 = true
|
||||||
}
|
}
|
||||||
b = appendVarint(b, wiretag)
|
b = appendVarint(b, wiretag)
|
||||||
b = appendVarint(b, uint64(len(v)))
|
b = appendVarint(b, uint64(len(v)))
|
||||||
b = append(b, v...)
|
b = append(b, v...)
|
||||||
}
|
}
|
||||||
|
if invalidUTF8 {
|
||||||
|
return b, errInvalidUTF8
|
||||||
|
}
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
|
||||||
@@ -2107,7 +2183,8 @@ func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
|||||||
},
|
},
|
||||||
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
s := ptr.getPointerSlice()
|
s := ptr.getPointerSlice()
|
||||||
var err, errreq error
|
var err error
|
||||||
|
var nerr nonFatal
|
||||||
for _, v := range s {
|
for _, v := range s {
|
||||||
if v.isNil() {
|
if v.isNil() {
|
||||||
return b, errRepeatedHasNil
|
return b, errRepeatedHasNil
|
||||||
@@ -2115,22 +2192,14 @@ func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
|||||||
b = appendVarint(b, wiretag) // start group
|
b = appendVarint(b, wiretag) // start group
|
||||||
b, err = u.marshal(b, v, deterministic)
|
b, err = u.marshal(b, v, deterministic)
|
||||||
b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
|
b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
if _, ok := err.(*RequiredNotSetError); ok {
|
|
||||||
// Required field in submessage is not set.
|
|
||||||
// We record the error but keep going, to give a complete marshaling.
|
|
||||||
if errreq == nil {
|
|
||||||
errreq = err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err == ErrNil {
|
if err == ErrNil {
|
||||||
err = errRepeatedHasNil
|
err = errRepeatedHasNil
|
||||||
}
|
}
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, errreq
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2174,7 +2243,8 @@ func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
|||||||
},
|
},
|
||||||
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
|
||||||
s := ptr.getPointerSlice()
|
s := ptr.getPointerSlice()
|
||||||
var err, errreq error
|
var err error
|
||||||
|
var nerr nonFatal
|
||||||
for _, v := range s {
|
for _, v := range s {
|
||||||
if v.isNil() {
|
if v.isNil() {
|
||||||
return b, errRepeatedHasNil
|
return b, errRepeatedHasNil
|
||||||
@@ -2184,22 +2254,14 @@ func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
|
|||||||
b = appendVarint(b, uint64(siz))
|
b = appendVarint(b, uint64(siz))
|
||||||
b, err = u.marshal(b, v, deterministic)
|
b, err = u.marshal(b, v, deterministic)
|
||||||
|
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
if _, ok := err.(*RequiredNotSetError); ok {
|
|
||||||
// Required field in submessage is not set.
|
|
||||||
// We record the error but keep going, to give a complete marshaling.
|
|
||||||
if errreq == nil {
|
|
||||||
errreq = err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err == ErrNil {
|
if err == ErrNil {
|
||||||
err = errRepeatedHasNil
|
err = errRepeatedHasNil
|
||||||
}
|
}
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, errreq
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2223,6 +2285,25 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) {
|
|||||||
// value.
|
// value.
|
||||||
// Key cannot be pointer-typed.
|
// Key cannot be pointer-typed.
|
||||||
valIsPtr := valType.Kind() == reflect.Ptr
|
valIsPtr := valType.Kind() == reflect.Ptr
|
||||||
|
|
||||||
|
// If value is a message with nested maps, calling
|
||||||
|
// valSizer in marshal may be quadratic. We should use
|
||||||
|
// cached version in marshal (but not in size).
|
||||||
|
// If value is not message type, we don't have size cache,
|
||||||
|
// but it cannot be nested either. Just use valSizer.
|
||||||
|
valCachedSizer := valSizer
|
||||||
|
if valIsPtr && valType.Elem().Kind() == reflect.Struct {
|
||||||
|
u := getMarshalInfo(valType.Elem())
|
||||||
|
valCachedSizer = func(ptr pointer, tagsize int) int {
|
||||||
|
// Same as message sizer, but use cache.
|
||||||
|
p := ptr.getPointer()
|
||||||
|
if p.isNil() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
siz := u.cachedsize(p)
|
||||||
|
return siz + SizeVarint(uint64(siz)) + tagsize
|
||||||
|
}
|
||||||
|
}
|
||||||
return func(ptr pointer, tagsize int) int {
|
return func(ptr pointer, tagsize int) int {
|
||||||
m := ptr.asPointerTo(t).Elem() // the map
|
m := ptr.asPointerTo(t).Elem() // the map
|
||||||
n := 0
|
n := 0
|
||||||
@@ -2243,24 +2324,26 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) {
|
|||||||
if len(keys) > 1 && deterministic {
|
if len(keys) > 1 && deterministic {
|
||||||
sort.Sort(mapKeys(keys))
|
sort.Sort(mapKeys(keys))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nerr nonFatal
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
ki := k.Interface()
|
ki := k.Interface()
|
||||||
vi := m.MapIndex(k).Interface()
|
vi := m.MapIndex(k).Interface()
|
||||||
kaddr := toAddrPointer(&ki, false) // pointer to key
|
kaddr := toAddrPointer(&ki, false) // pointer to key
|
||||||
vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value
|
vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value
|
||||||
b = appendVarint(b, tag)
|
b = appendVarint(b, tag)
|
||||||
siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
|
siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
|
||||||
b = appendVarint(b, uint64(siz))
|
b = appendVarint(b, uint64(siz))
|
||||||
b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic)
|
b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
b, err = valMarshaler(b, vaddr, valWireTag, deterministic)
|
b, err = valMarshaler(b, vaddr, valWireTag, deterministic)
|
||||||
if err != nil && err != ErrNil { // allow nil value in map
|
if err != ErrNil && !nerr.Merge(err) { // allow nil value in map
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2333,6 +2416,7 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de
|
|||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
var nerr nonFatal
|
||||||
|
|
||||||
// Fast-path for common cases: zero or one extensions.
|
// Fast-path for common cases: zero or one extensions.
|
||||||
// Don't bother sorting the keys.
|
// Don't bother sorting the keys.
|
||||||
@@ -2352,11 +2436,11 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de
|
|||||||
v := e.value
|
v := e.value
|
||||||
p := toAddrPointer(&v, ei.isptr)
|
p := toAddrPointer(&v, ei.isptr)
|
||||||
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
|
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the keys to provide a deterministic encoding.
|
// Sort the keys to provide a deterministic encoding.
|
||||||
@@ -2383,11 +2467,11 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de
|
|||||||
v := e.value
|
v := e.value
|
||||||
p := toAddrPointer(&v, ei.isptr)
|
p := toAddrPointer(&v, ei.isptr)
|
||||||
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
|
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
|
|
||||||
// message set format is:
|
// message set format is:
|
||||||
@@ -2444,6 +2528,7 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de
|
|||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
var nerr nonFatal
|
||||||
|
|
||||||
// Fast-path for common cases: zero or one extensions.
|
// Fast-path for common cases: zero or one extensions.
|
||||||
// Don't bother sorting the keys.
|
// Don't bother sorting the keys.
|
||||||
@@ -2470,12 +2555,12 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de
|
|||||||
v := e.value
|
v := e.value
|
||||||
p := toAddrPointer(&v, ei.isptr)
|
p := toAddrPointer(&v, ei.isptr)
|
||||||
b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
|
b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
b = append(b, 1<<3|WireEndGroup)
|
b = append(b, 1<<3|WireEndGroup)
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the keys to provide a deterministic encoding.
|
// Sort the keys to provide a deterministic encoding.
|
||||||
@@ -2509,11 +2594,11 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de
|
|||||||
p := toAddrPointer(&v, ei.isptr)
|
p := toAddrPointer(&v, ei.isptr)
|
||||||
b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
|
b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
|
||||||
b = append(b, 1<<3|WireEndGroup)
|
b = append(b, 1<<3|WireEndGroup)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
|
|
||||||
// sizeV1Extensions computes the size of encoded data for a V1-API extension field.
|
// sizeV1Extensions computes the size of encoded data for a V1-API extension field.
|
||||||
@@ -2556,6 +2641,7 @@ func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, determ
|
|||||||
sort.Ints(keys)
|
sort.Ints(keys)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
var nerr nonFatal
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
e := m[int32(k)]
|
e := m[int32(k)]
|
||||||
if e.value == nil || e.desc == nil {
|
if e.value == nil || e.desc == nil {
|
||||||
@@ -2572,11 +2658,11 @@ func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, determ
|
|||||||
v := e.value
|
v := e.value
|
||||||
p := toAddrPointer(&v, ei.isptr)
|
p := toAddrPointer(&v, ei.isptr)
|
||||||
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
|
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
|
|
||||||
// newMarshaler is the interface representing objects that can marshal themselves.
|
// newMarshaler is the interface representing objects that can marshal themselves.
|
||||||
|
|||||||
+115
-31
@@ -97,6 +97,8 @@ type unmarshalFieldInfo struct {
|
|||||||
|
|
||||||
// if a required field, contains a single set bit at this field's index in the required field list.
|
// if a required field, contains a single set bit at this field's index in the required field list.
|
||||||
reqMask uint64
|
reqMask uint64
|
||||||
|
|
||||||
|
name string // name of the field, for error reporting
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -136,8 +138,8 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error {
|
|||||||
if u.isMessageSet {
|
if u.isMessageSet {
|
||||||
return UnmarshalMessageSet(b, m.offset(u.extensions).toExtensions())
|
return UnmarshalMessageSet(b, m.offset(u.extensions).toExtensions())
|
||||||
}
|
}
|
||||||
var reqMask uint64 // bitmask of required fields we've seen.
|
var reqMask uint64 // bitmask of required fields we've seen.
|
||||||
var rnse *RequiredNotSetError // an instance of a RequiredNotSetError returned by a submessage.
|
var errLater error
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
// Read tag and wire type.
|
// Read tag and wire type.
|
||||||
// Special case 1 and 2 byte varints.
|
// Special case 1 and 2 byte varints.
|
||||||
@@ -176,11 +178,20 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error {
|
|||||||
if r, ok := err.(*RequiredNotSetError); ok {
|
if r, ok := err.(*RequiredNotSetError); ok {
|
||||||
// Remember this error, but keep parsing. We need to produce
|
// Remember this error, but keep parsing. We need to produce
|
||||||
// a full parse even if a required field is missing.
|
// a full parse even if a required field is missing.
|
||||||
rnse = r
|
if errLater == nil {
|
||||||
|
errLater = r
|
||||||
|
}
|
||||||
reqMask |= f.reqMask
|
reqMask |= f.reqMask
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != errInternalBadWireType {
|
if err != errInternalBadWireType {
|
||||||
|
if err == errInvalidUTF8 {
|
||||||
|
if errLater == nil {
|
||||||
|
fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name
|
||||||
|
errLater = &invalidUTF8Error{fullName}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Fragments with bad wire type are treated as unknown fields.
|
// Fragments with bad wire type are treated as unknown fields.
|
||||||
@@ -239,20 +250,16 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error {
|
|||||||
emap[int32(tag)] = e
|
emap[int32(tag)] = e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if rnse != nil {
|
if reqMask != u.reqMask && errLater == nil {
|
||||||
// A required field of a submessage/group is missing. Return that error.
|
|
||||||
return rnse
|
|
||||||
}
|
|
||||||
if reqMask != u.reqMask {
|
|
||||||
// A required field of this message is missing.
|
// A required field of this message is missing.
|
||||||
for _, n := range u.reqFields {
|
for _, n := range u.reqFields {
|
||||||
if reqMask&1 == 0 {
|
if reqMask&1 == 0 {
|
||||||
return &RequiredNotSetError{n}
|
errLater = &RequiredNotSetError{n}
|
||||||
}
|
}
|
||||||
reqMask >>= 1
|
reqMask >>= 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return errLater
|
||||||
}
|
}
|
||||||
|
|
||||||
// computeUnmarshalInfo fills in u with information for use
|
// computeUnmarshalInfo fills in u with information for use
|
||||||
@@ -351,7 +358,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store the info in the correct slot in the message.
|
// Store the info in the correct slot in the message.
|
||||||
u.setTag(tag, toField(&f), unmarshal, reqMask)
|
u.setTag(tag, toField(&f), unmarshal, reqMask, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find any types associated with oneof fields.
|
// Find any types associated with oneof fields.
|
||||||
@@ -366,10 +373,17 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
|
|||||||
|
|
||||||
f := typ.Field(0) // oneof implementers have one field
|
f := typ.Field(0) // oneof implementers have one field
|
||||||
baseUnmarshal := fieldUnmarshaler(&f)
|
baseUnmarshal := fieldUnmarshaler(&f)
|
||||||
tagstr := strings.Split(f.Tag.Get("protobuf"), ",")[1]
|
tags := strings.Split(f.Tag.Get("protobuf"), ",")
|
||||||
tag, err := strconv.Atoi(tagstr)
|
fieldNum, err := strconv.Atoi(tags[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("protobuf tag field not an integer: " + tagstr)
|
panic("protobuf tag field not an integer: " + tags[1])
|
||||||
|
}
|
||||||
|
var name string
|
||||||
|
for _, tag := range tags {
|
||||||
|
if strings.HasPrefix(tag, "name=") {
|
||||||
|
name = strings.TrimPrefix(tag, "name=")
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the oneof field that this struct implements.
|
// Find the oneof field that this struct implements.
|
||||||
@@ -380,7 +394,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
|
|||||||
// That lets us know where this struct should be stored
|
// That lets us know where this struct should be stored
|
||||||
// when we encounter it during unmarshaling.
|
// when we encounter it during unmarshaling.
|
||||||
unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal)
|
unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal)
|
||||||
u.setTag(tag, of.field, unmarshal, 0)
|
u.setTag(fieldNum, of.field, unmarshal, 0, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,7 +415,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
|
|||||||
// [0 0] is [tag=0/wiretype=varint varint-encoded-0].
|
// [0 0] is [tag=0/wiretype=varint varint-encoded-0].
|
||||||
u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) {
|
u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w)
|
return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w)
|
||||||
}, 0)
|
}, 0, "")
|
||||||
|
|
||||||
// Set mask for required field check.
|
// Set mask for required field check.
|
||||||
u.reqMask = uint64(1)<<uint(len(u.reqFields)) - 1
|
u.reqMask = uint64(1)<<uint(len(u.reqFields)) - 1
|
||||||
@@ -413,8 +427,9 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
|
|||||||
// tag = tag # for field
|
// tag = tag # for field
|
||||||
// field/unmarshal = unmarshal info for that field.
|
// field/unmarshal = unmarshal info for that field.
|
||||||
// reqMask = if required, bitmask for field position in required field list. 0 otherwise.
|
// reqMask = if required, bitmask for field position in required field list. 0 otherwise.
|
||||||
func (u *unmarshalInfo) setTag(tag int, field field, unmarshal unmarshaler, reqMask uint64) {
|
// name = short name of the field.
|
||||||
i := unmarshalFieldInfo{field: field, unmarshal: unmarshal, reqMask: reqMask}
|
func (u *unmarshalInfo) setTag(tag int, field field, unmarshal unmarshaler, reqMask uint64, name string) {
|
||||||
|
i := unmarshalFieldInfo{field: field, unmarshal: unmarshal, reqMask: reqMask, name: name}
|
||||||
n := u.typ.NumField()
|
n := u.typ.NumField()
|
||||||
if tag >= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here?
|
if tag >= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here?
|
||||||
for len(u.dense) <= tag {
|
for len(u.dense) <= tag {
|
||||||
@@ -442,11 +457,17 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler {
|
|||||||
tagArray := strings.Split(tags, ",")
|
tagArray := strings.Split(tags, ",")
|
||||||
encoding := tagArray[0]
|
encoding := tagArray[0]
|
||||||
name := "unknown"
|
name := "unknown"
|
||||||
|
proto3 := false
|
||||||
|
validateUTF8 := true
|
||||||
for _, tag := range tagArray[3:] {
|
for _, tag := range tagArray[3:] {
|
||||||
if strings.HasPrefix(tag, "name=") {
|
if strings.HasPrefix(tag, "name=") {
|
||||||
name = tag[5:]
|
name = tag[5:]
|
||||||
}
|
}
|
||||||
|
if tag == "proto3" {
|
||||||
|
proto3 = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
validateUTF8 = validateUTF8 && proto3
|
||||||
|
|
||||||
// Figure out packaging (pointer, slice, or both)
|
// Figure out packaging (pointer, slice, or both)
|
||||||
slice := false
|
slice := false
|
||||||
@@ -594,6 +615,15 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler {
|
|||||||
}
|
}
|
||||||
return unmarshalBytesValue
|
return unmarshalBytesValue
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
|
if validateUTF8 {
|
||||||
|
if pointer {
|
||||||
|
return unmarshalUTF8StringPtr
|
||||||
|
}
|
||||||
|
if slice {
|
||||||
|
return unmarshalUTF8StringSlice
|
||||||
|
}
|
||||||
|
return unmarshalUTF8StringValue
|
||||||
|
}
|
||||||
if pointer {
|
if pointer {
|
||||||
return unmarshalStringPtr
|
return unmarshalStringPtr
|
||||||
}
|
}
|
||||||
@@ -1448,9 +1478,6 @@ func unmarshalStringValue(b []byte, f pointer, w int) ([]byte, error) {
|
|||||||
return nil, io.ErrUnexpectedEOF
|
return nil, io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
v := string(b[:x])
|
v := string(b[:x])
|
||||||
if !utf8.ValidString(v) {
|
|
||||||
return nil, errInvalidUTF8
|
|
||||||
}
|
|
||||||
*f.toString() = v
|
*f.toString() = v
|
||||||
return b[x:], nil
|
return b[x:], nil
|
||||||
}
|
}
|
||||||
@@ -1468,9 +1495,6 @@ func unmarshalStringPtr(b []byte, f pointer, w int) ([]byte, error) {
|
|||||||
return nil, io.ErrUnexpectedEOF
|
return nil, io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
v := string(b[:x])
|
v := string(b[:x])
|
||||||
if !utf8.ValidString(v) {
|
|
||||||
return nil, errInvalidUTF8
|
|
||||||
}
|
|
||||||
*f.toStringPtr() = &v
|
*f.toStringPtr() = &v
|
||||||
return b[x:], nil
|
return b[x:], nil
|
||||||
}
|
}
|
||||||
@@ -1488,14 +1512,72 @@ func unmarshalStringSlice(b []byte, f pointer, w int) ([]byte, error) {
|
|||||||
return nil, io.ErrUnexpectedEOF
|
return nil, io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
v := string(b[:x])
|
v := string(b[:x])
|
||||||
if !utf8.ValidString(v) {
|
|
||||||
return nil, errInvalidUTF8
|
|
||||||
}
|
|
||||||
s := f.toStringSlice()
|
s := f.toStringSlice()
|
||||||
*s = append(*s, v)
|
*s = append(*s, v)
|
||||||
return b[x:], nil
|
return b[x:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unmarshalUTF8StringValue(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return b, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
v := string(b[:x])
|
||||||
|
*f.toString() = v
|
||||||
|
if !utf8.ValidString(v) {
|
||||||
|
return b[x:], errInvalidUTF8
|
||||||
|
}
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func unmarshalUTF8StringPtr(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return b, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
v := string(b[:x])
|
||||||
|
*f.toStringPtr() = &v
|
||||||
|
if !utf8.ValidString(v) {
|
||||||
|
return b[x:], errInvalidUTF8
|
||||||
|
}
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func unmarshalUTF8StringSlice(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
|
if w != WireBytes {
|
||||||
|
return b, errInternalBadWireType
|
||||||
|
}
|
||||||
|
x, n := decodeVarint(b)
|
||||||
|
if n == 0 {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b = b[n:]
|
||||||
|
if x > uint64(len(b)) {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
v := string(b[:x])
|
||||||
|
s := f.toStringSlice()
|
||||||
|
*s = append(*s, v)
|
||||||
|
if !utf8.ValidString(v) {
|
||||||
|
return b[x:], errInvalidUTF8
|
||||||
|
}
|
||||||
|
return b[x:], nil
|
||||||
|
}
|
||||||
|
|
||||||
var emptyBuf [0]byte
|
var emptyBuf [0]byte
|
||||||
|
|
||||||
func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) {
|
func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) {
|
||||||
@@ -1674,6 +1756,7 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
|
|||||||
// Maps will be somewhat slow. Oh well.
|
// Maps will be somewhat slow. Oh well.
|
||||||
|
|
||||||
// Read key and value from data.
|
// Read key and value from data.
|
||||||
|
var nerr nonFatal
|
||||||
k := reflect.New(kt)
|
k := reflect.New(kt)
|
||||||
v := reflect.New(vt)
|
v := reflect.New(vt)
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
@@ -1694,7 +1777,7 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
|
|||||||
err = errInternalBadWireType // skip unknown tag
|
err = errInternalBadWireType // skip unknown tag
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if nerr.Merge(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != errInternalBadWireType {
|
if err != errInternalBadWireType {
|
||||||
@@ -1717,7 +1800,7 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
|
|||||||
// Insert into map.
|
// Insert into map.
|
||||||
m.SetMapIndex(k.Elem(), v.Elem())
|
m.SetMapIndex(k.Elem(), v.Elem())
|
||||||
|
|
||||||
return r, nil
|
return r, nerr.E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1743,15 +1826,16 @@ func makeUnmarshalOneof(typ, ityp reflect.Type, unmarshal unmarshaler) unmarshal
|
|||||||
// Unmarshal data into holder.
|
// Unmarshal data into holder.
|
||||||
// We unmarshal into the first field of the holder object.
|
// We unmarshal into the first field of the holder object.
|
||||||
var err error
|
var err error
|
||||||
|
var nerr nonFatal
|
||||||
b, err = unmarshal(b, valToPointer(v).offset(field0), w)
|
b, err = unmarshal(b, valToPointer(v).offset(field0), w)
|
||||||
if err != nil {
|
if !nerr.Merge(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write pointer to holder into target field.
|
// Write pointer to holder into target field.
|
||||||
f.asPointerTo(ityp).Elem().Set(v)
|
f.asPointerTo(ityp).Elem().Set(v)
|
||||||
|
|
||||||
return b, nil
|
return b, nerr.E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -353,7 +353,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := tm.writeAny(w, key, props.mkeyprop); err != nil {
|
if err := tm.writeAny(w, key, props.MapKeyProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.WriteByte('\n'); err != nil {
|
if err := w.WriteByte('\n'); err != nil {
|
||||||
@@ -370,7 +370,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := tm.writeAny(w, val, props.mvalprop); err != nil {
|
if err := tm.writeAny(w, val, props.MapValProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.WriteByte('\n'); err != nil {
|
if err := w.WriteByte('\n'); err != nil {
|
||||||
|
|||||||
+3
-3
@@ -630,17 +630,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
|
|||||||
if err := p.consumeToken(":"); err != nil {
|
if err := p.consumeToken(":"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.readAny(key, props.mkeyprop); err != nil {
|
if err := p.readAny(key, props.MapKeyProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.consumeOptionalSeparator(); err != nil {
|
if err := p.consumeOptionalSeparator(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "value":
|
case "value":
|
||||||
if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
|
if err := p.checkForColon(props.MapValProp, dst.Type().Elem()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.readAny(val, props.mvalprop); err != nil {
|
if err := p.readAny(val, props.MapValProp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.consumeOptionalSeparator(); err != nil {
|
if err := p.consumeOptionalSeparator(); err != nil {
|
||||||
|
|||||||
+5
-4
@@ -3,12 +3,13 @@ go_import_path: github.com/kevinburke/ssh_config
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.7
|
- 1.9.x
|
||||||
- 1.8
|
- 1.10.x
|
||||||
- tip
|
- 1.11.x
|
||||||
|
- master
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- go get -u ./...
|
- go get -u ./...
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make test
|
- make race-test
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
Eugene Terentev <eugene@terentev.net>
|
Eugene Terentev <eugene@terentev.net>
|
||||||
Kevin Burke <kev@inburke.com>
|
Kevin Burke <kev@inburke.com>
|
||||||
Sergey Lukjanov <me@slukjanov.name>
|
Sergey Lukjanov <me@slukjanov.name>
|
||||||
|
Wayne Ashley Berry <wayneashleyberry@gmail.com>
|
||||||
+6
-3
@@ -13,12 +13,15 @@ lint: $(MEGACHECK)
|
|||||||
|
|
||||||
test: lint
|
test: lint
|
||||||
@# the timeout helps guard against infinite recursion
|
@# the timeout helps guard against infinite recursion
|
||||||
go test -timeout=50ms ./...
|
go test -timeout=250ms ./...
|
||||||
|
|
||||||
|
race-test: lint
|
||||||
|
go test -timeout=500ms -race ./...
|
||||||
|
|
||||||
$(BUMP_VERSION):
|
$(BUMP_VERSION):
|
||||||
go get github.com/Shyp/bump_version
|
go get -u github.com/kevinburke/bump_version
|
||||||
|
|
||||||
release: $(BUMP_VERSION)
|
release: test | $(BUMP_VERSION)
|
||||||
$(BUMP_VERSION) minor config.go
|
$(BUMP_VERSION) minor config.go
|
||||||
|
|
||||||
force: ;
|
force: ;
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4"
|
const version = "0.5"
|
||||||
|
|
||||||
type configFinder func() string
|
type configFinder func() string
|
||||||
|
|
||||||
|
|||||||
+3
@@ -96,6 +96,9 @@ func (p *sshParser) parseKV() sshParserStateFn {
|
|||||||
}
|
}
|
||||||
comment := ""
|
comment := ""
|
||||||
tok := p.peek()
|
tok := p.peek()
|
||||||
|
if tok == nil {
|
||||||
|
tok = &token{typ: tokenEOF}
|
||||||
|
}
|
||||||
if tok.typ == tokenComment && tok.Position.Line == val.Position.Line {
|
if tok.typ == tokenComment && tok.Position.Line == val.Position.Line {
|
||||||
tok = p.getToken()
|
tok = p.getToken()
|
||||||
comment = tok.val
|
comment = tok.val
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
module github.com/mitchellh/go-homedir
|
||||||
+6
-4
@@ -141,14 +141,16 @@ func dirWindows() (string, error) {
|
|||||||
return home, nil
|
return home, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefer standard environment variable USERPROFILE
|
||||||
|
if home := os.Getenv("USERPROFILE"); home != "" {
|
||||||
|
return home, nil
|
||||||
|
}
|
||||||
|
|
||||||
drive := os.Getenv("HOMEDRIVE")
|
drive := os.Getenv("HOMEDRIVE")
|
||||||
path := os.Getenv("HOMEPATH")
|
path := os.Getenv("HOMEPATH")
|
||||||
home := drive + path
|
home := drive + path
|
||||||
if drive == "" || path == "" {
|
if drive == "" || path == "" {
|
||||||
home = os.Getenv("USERPROFILE")
|
return "", errors.New("HOMEDRIVE, HOMEPATH, or USERPROFILE are blank")
|
||||||
}
|
|
||||||
if home == "" {
|
|
||||||
return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return home, nil
|
return home, nil
|
||||||
|
|||||||
+2
-4
@@ -1,9 +1,7 @@
|
|||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.6.x
|
- 1.9.x
|
||||||
- 1.7.x
|
- 1.10.x
|
||||||
- 1.8.x
|
|
||||||
- tip
|
|
||||||
env:
|
env:
|
||||||
- GOMAXPROCS=4 GORACE=halt_on_error=1
|
- GOMAXPROCS=4 GORACE=halt_on_error=1
|
||||||
install:
|
install:
|
||||||
|
|||||||
+5
-55
@@ -241,60 +241,8 @@ func init() {
|
|||||||
```
|
```
|
||||||
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).
|
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 |
|
A list of currently known of service hook can be found in this wiki [page](https://github.com/sirupsen/logrus/wiki/Hooks)
|
||||||
| ----- | ----------- |
|
|
||||||
| [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. |
|
|
||||||
| [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. |
|
|
||||||
| [Amazon Kinesis](https://github.com/evalphobia/logrus_kinesis) | Hook for logging to [Amazon Kinesis](https://aws.amazon.com/kinesis/) |
|
|
||||||
| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) |
|
|
||||||
| [Application Insights](https://github.com/jjcollinge/logrus-appinsights) | Hook for logging to [Application Insights](https://azure.microsoft.com/en-us/services/application-insights/)
|
|
||||||
| [AzureTableHook](https://github.com/kpfaulkner/azuretablehook/) | Hook for logging to Azure Table Storage|
|
|
||||||
| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
|
|
||||||
| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic |
|
|
||||||
| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) |
|
|
||||||
| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch|
|
|
||||||
| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/)
|
|
||||||
| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
|
|
||||||
| [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) |
|
|
||||||
| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) |
|
|
||||||
| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
|
|
||||||
| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
|
|
||||||
| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb |
|
|
||||||
| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) |
|
|
||||||
| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
|
|
||||||
| [KafkaLogrus](https://github.com/tracer0tong/kafkalogrus) | Hook for logging to Kafka |
|
|
||||||
| [Kafka REST Proxy](https://github.com/Nordstrom/logrus-kafka-rest-proxy) | Hook for logging to [Kafka REST Proxy](https://docs.confluent.io/current/kafka-rest/docs) |
|
|
||||||
| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
|
|
||||||
| [Logbeat](https://github.com/macandmia/logbeat) | Hook for logging to [Opbeat](https://opbeat.com/) |
|
|
||||||
| [Logentries](https://github.com/jcftang/logentriesrus) | Hook for logging to [Logentries](https://logentries.com/) |
|
|
||||||
| [Logentrus](https://github.com/puddingfactory/logentrus) | Hook for logging to [Logentries](https://logentries.com/) |
|
|
||||||
| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) |
|
|
||||||
| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
|
|
||||||
| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) |
|
|
||||||
| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
|
|
||||||
| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) |
|
|
||||||
| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
|
|
||||||
| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) |
|
|
||||||
| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
|
|
||||||
| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. |
|
|
||||||
| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) |
|
|
||||||
| [Promrus](https://github.com/weaveworks/promrus) | Expose number of log messages as [Prometheus](https://prometheus.io/) metrics |
|
|
||||||
| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) |
|
|
||||||
| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
|
|
||||||
| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) |
|
|
||||||
| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
|
|
||||||
| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)|
|
|
||||||
| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. |
|
|
||||||
| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
|
|
||||||
| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) |
|
|
||||||
| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)|
|
|
||||||
| [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. |
|
|
||||||
| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. |
|
|
||||||
| [Telegram](https://github.com/rossmcdonald/telegram_hook) | Hook for logging errors to [Telegram](https://telegram.org/) |
|
|
||||||
| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) |
|
|
||||||
| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) |
|
|
||||||
| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash |
|
|
||||||
| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) |
|
|
||||||
|
|
||||||
#### Level logging
|
#### Level logging
|
||||||
|
|
||||||
@@ -372,6 +320,8 @@ The built-in logging formatters are:
|
|||||||
field to `true`. To force no colored output even if there is a TTY set the
|
field to `true`. To force no colored output even if there is a TTY set the
|
||||||
`DisableColors` field to `true`. For Windows, see
|
`DisableColors` field to `true`. For Windows, see
|
||||||
[github.com/mattn/go-colorable](https://github.com/mattn/go-colorable).
|
[github.com/mattn/go-colorable](https://github.com/mattn/go-colorable).
|
||||||
|
* When colors are enabled, levels are truncated to 4 characters by default. To disable
|
||||||
|
truncation set the `DisableLevelTruncation` field to `true`.
|
||||||
* All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter).
|
* All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter).
|
||||||
* `logrus.JSONFormatter`. Logs fields as JSON.
|
* `logrus.JSONFormatter`. Logs fields as JSON.
|
||||||
* All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter).
|
* All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter).
|
||||||
@@ -495,7 +445,7 @@ logrus.RegisterExitHandler(handler)
|
|||||||
|
|
||||||
#### Thread safety
|
#### Thread safety
|
||||||
|
|
||||||
By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs.
|
By default, Logger is protected by a mutex for concurrent writes. The mutex is held when calling hooks and writing logs.
|
||||||
If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking.
|
If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking.
|
||||||
|
|
||||||
Situation when locking is not needed includes:
|
Situation when locking is not needed includes:
|
||||||
|
|||||||
+19
-7
@@ -48,7 +48,7 @@ type Entry struct {
|
|||||||
func NewEntry(logger *Logger) *Entry {
|
func NewEntry(logger *Logger) *Entry {
|
||||||
return &Entry{
|
return &Entry{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
// Default is three fields, give a little extra room
|
// Default is five fields, give a little extra room
|
||||||
Data: make(Fields, 5),
|
Data: make(Fields, 5),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,14 +83,28 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
|
|||||||
for k, v := range fields {
|
for k, v := range fields {
|
||||||
data[k] = v
|
data[k] = v
|
||||||
}
|
}
|
||||||
return &Entry{Logger: entry.Logger, Data: data}
|
return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overrides the time of the Entry.
|
||||||
|
func (entry *Entry) WithTime(t time.Time) *Entry {
|
||||||
|
return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is not declared with a pointer value because otherwise
|
// This function is not declared with a pointer value because otherwise
|
||||||
// race conditions will occur when using multiple goroutines
|
// race conditions will occur when using multiple goroutines
|
||||||
func (entry Entry) log(level Level, msg string) {
|
func (entry Entry) log(level Level, msg string) {
|
||||||
var buffer *bytes.Buffer
|
var buffer *bytes.Buffer
|
||||||
entry.Time = time.Now()
|
|
||||||
|
// Default to now, but allow users to override if they want.
|
||||||
|
//
|
||||||
|
// We don't have to worry about polluting future calls to Entry#log()
|
||||||
|
// with this assignment because this function is declared with a
|
||||||
|
// non-pointer receiver.
|
||||||
|
if entry.Time.IsZero() {
|
||||||
|
entry.Time = time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
entry.Level = level
|
entry.Level = level
|
||||||
entry.Message = msg
|
entry.Message = msg
|
||||||
|
|
||||||
@@ -113,12 +127,10 @@ func (entry Entry) log(level Level, msg string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is not declared with a pointer value because otherwise
|
func (entry *Entry) fireHooks() {
|
||||||
// race conditions will occur when using multiple goroutines
|
|
||||||
func (entry Entry) fireHooks() {
|
|
||||||
entry.Logger.mu.Lock()
|
entry.Logger.mu.Lock()
|
||||||
defer entry.Logger.mu.Unlock()
|
defer entry.Logger.mu.Unlock()
|
||||||
err := entry.Logger.Hooks.Fire(entry.Level, &entry)
|
err := entry.Logger.Hooks.Fire(entry.Level, entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-6
@@ -2,6 +2,7 @@ package logrus
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -15,9 +16,7 @@ func StandardLogger() *Logger {
|
|||||||
|
|
||||||
// SetOutput sets the standard logger output.
|
// SetOutput sets the standard logger output.
|
||||||
func SetOutput(out io.Writer) {
|
func SetOutput(out io.Writer) {
|
||||||
std.mu.Lock()
|
std.SetOutput(out)
|
||||||
defer std.mu.Unlock()
|
|
||||||
std.Out = out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFormatter sets the standard logger formatter.
|
// SetFormatter sets the standard logger formatter.
|
||||||
@@ -72,6 +71,15 @@ func WithFields(fields Fields) *Entry {
|
|||||||
return std.WithFields(fields)
|
return std.WithFields(fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithTime creats an entry from the standard logger and overrides the time of
|
||||||
|
// logs generated with it.
|
||||||
|
//
|
||||||
|
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
||||||
|
// or Panic on the Entry it returns.
|
||||||
|
func WithTime(t time.Time) *Entry {
|
||||||
|
return std.WithTime(t)
|
||||||
|
}
|
||||||
|
|
||||||
// Debug logs a message at level Debug on the standard logger.
|
// Debug logs a message at level Debug on the standard logger.
|
||||||
func Debug(args ...interface{}) {
|
func Debug(args ...interface{}) {
|
||||||
std.Debug(args...)
|
std.Debug(args...)
|
||||||
@@ -107,7 +115,7 @@ func Panic(args ...interface{}) {
|
|||||||
std.Panic(args...)
|
std.Panic(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatal logs a message at level Fatal on the standard logger.
|
// Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
|
||||||
func Fatal(args ...interface{}) {
|
func Fatal(args ...interface{}) {
|
||||||
std.Fatal(args...)
|
std.Fatal(args...)
|
||||||
}
|
}
|
||||||
@@ -147,7 +155,7 @@ func Panicf(format string, args ...interface{}) {
|
|||||||
std.Panicf(format, args...)
|
std.Panicf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatalf logs a message at level Fatal on the standard logger.
|
// Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
|
||||||
func Fatalf(format string, args ...interface{}) {
|
func Fatalf(format string, args ...interface{}) {
|
||||||
std.Fatalf(format, args...)
|
std.Fatalf(format, args...)
|
||||||
}
|
}
|
||||||
@@ -187,7 +195,7 @@ func Panicln(args ...interface{}) {
|
|||||||
std.Panicln(args...)
|
std.Panicln(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatalln logs a message at level Fatal on the standard logger.
|
// Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
|
||||||
func Fatalln(args ...interface{}) {
|
func Fatalln(args ...interface{}) {
|
||||||
std.Fatalln(args...)
|
std.Fatalln(args...)
|
||||||
}
|
}
|
||||||
+13
-7
@@ -30,16 +30,22 @@ type Formatter interface {
|
|||||||
//
|
//
|
||||||
// It's not exported because it's still using Data in an opinionated way. It's to
|
// 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.
|
// avoid code duplication between the two default formatters.
|
||||||
func prefixFieldClashes(data Fields) {
|
func prefixFieldClashes(data Fields, fieldMap FieldMap) {
|
||||||
if t, ok := data["time"]; ok {
|
timeKey := fieldMap.resolve(FieldKeyTime)
|
||||||
data["fields.time"] = t
|
if t, ok := data[timeKey]; ok {
|
||||||
|
data["fields."+timeKey] = t
|
||||||
|
delete(data, timeKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if m, ok := data["msg"]; ok {
|
msgKey := fieldMap.resolve(FieldKeyMsg)
|
||||||
data["fields.msg"] = m
|
if m, ok := data[msgKey]; ok {
|
||||||
|
data["fields."+msgKey] = m
|
||||||
|
delete(data, msgKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if l, ok := data["level"]; ok {
|
levelKey := fieldMap.resolve(FieldKeyLevel)
|
||||||
data["fields.level"] = l
|
if l, ok := data[levelKey]; ok {
|
||||||
|
data["fields."+levelKey] = l
|
||||||
|
delete(data, levelKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-1
@@ -33,6 +33,9 @@ type JSONFormatter struct {
|
|||||||
// DisableTimestamp allows disabling automatic timestamps in output
|
// DisableTimestamp allows disabling automatic timestamps in output
|
||||||
DisableTimestamp bool
|
DisableTimestamp bool
|
||||||
|
|
||||||
|
// DataKey allows users to put all the log entry parameters into a nested dictionary at a given key.
|
||||||
|
DataKey string
|
||||||
|
|
||||||
// FieldMap allows users to customize the names of keys for default fields.
|
// FieldMap allows users to customize the names of keys for default fields.
|
||||||
// As an example:
|
// As an example:
|
||||||
// formatter := &JSONFormatter{
|
// formatter := &JSONFormatter{
|
||||||
@@ -58,7 +61,14 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
|
|||||||
data[k] = v
|
data[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefixFieldClashes(data)
|
|
||||||
|
if f.DataKey != "" {
|
||||||
|
newData := make(Fields, 4)
|
||||||
|
newData[f.DataKey] = data
|
||||||
|
data = newData
|
||||||
|
}
|
||||||
|
|
||||||
|
prefixFieldClashes(data, f.FieldMap)
|
||||||
|
|
||||||
timestampFormat := f.TimestampFormat
|
timestampFormat := f.TimestampFormat
|
||||||
if timestampFormat == "" {
|
if timestampFormat == "" {
|
||||||
|
|||||||
+15
-1
@@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
@@ -88,7 +89,7 @@ func (logger *Logger) releaseEntry(entry *Entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adds a field to the log entry, note that it doesn't log until you call
|
// Adds a field to the log entry, note that it doesn't log until you call
|
||||||
// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
|
// Debug, Print, Info, Warn, Error, Fatal or Panic. It only creates a log entry.
|
||||||
// If you want multiple fields, use `WithFields`.
|
// If you want multiple fields, use `WithFields`.
|
||||||
func (logger *Logger) WithField(key string, value interface{}) *Entry {
|
func (logger *Logger) WithField(key string, value interface{}) *Entry {
|
||||||
entry := logger.newEntry()
|
entry := logger.newEntry()
|
||||||
@@ -112,6 +113,13 @@ func (logger *Logger) WithError(err error) *Entry {
|
|||||||
return entry.WithError(err)
|
return entry.WithError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overrides the time of the log entry.
|
||||||
|
func (logger *Logger) WithTime(t time.Time) *Entry {
|
||||||
|
entry := logger.newEntry()
|
||||||
|
defer logger.releaseEntry(entry)
|
||||||
|
return entry.WithTime(t)
|
||||||
|
}
|
||||||
|
|
||||||
func (logger *Logger) Debugf(format string, args ...interface{}) {
|
func (logger *Logger) Debugf(format string, args ...interface{}) {
|
||||||
if logger.level() >= DebugLevel {
|
if logger.level() >= DebugLevel {
|
||||||
entry := logger.newEntry()
|
entry := logger.newEntry()
|
||||||
@@ -316,6 +324,12 @@ func (logger *Logger) SetLevel(level Level) {
|
|||||||
atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
|
atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (logger *Logger) SetOutput(out io.Writer) {
|
||||||
|
logger.mu.Lock()
|
||||||
|
defer logger.mu.Unlock()
|
||||||
|
logger.Out = out
|
||||||
|
}
|
||||||
|
|
||||||
func (logger *Logger) AddHook(hook Hook) {
|
func (logger *Logger) AddHook(hook Hook) {
|
||||||
logger.mu.Lock()
|
logger.mu.Lock()
|
||||||
defer logger.mu.Unlock()
|
defer logger.mu.Unlock()
|
||||||
|
|||||||
+24
-7
@@ -20,6 +20,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
baseTimestamp time.Time
|
baseTimestamp time.Time
|
||||||
|
emptyFieldMap FieldMap
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -50,12 +51,24 @@ type TextFormatter struct {
|
|||||||
// be desired.
|
// be desired.
|
||||||
DisableSorting bool
|
DisableSorting bool
|
||||||
|
|
||||||
|
// Disables the truncation of the level text to 4 characters.
|
||||||
|
DisableLevelTruncation bool
|
||||||
|
|
||||||
// QuoteEmptyFields will wrap empty fields in quotes if true
|
// QuoteEmptyFields will wrap empty fields in quotes if true
|
||||||
QuoteEmptyFields bool
|
QuoteEmptyFields bool
|
||||||
|
|
||||||
// Whether the logger's out is to a terminal
|
// Whether the logger's out is to a terminal
|
||||||
isTerminal bool
|
isTerminal bool
|
||||||
|
|
||||||
|
// FieldMap allows users to customize the names of keys for default fields.
|
||||||
|
// As an example:
|
||||||
|
// formatter := &TextFormatter{
|
||||||
|
// FieldMap: FieldMap{
|
||||||
|
// FieldKeyTime: "@timestamp",
|
||||||
|
// FieldKeyLevel: "@level",
|
||||||
|
// FieldKeyMsg: "@message"}}
|
||||||
|
FieldMap FieldMap
|
||||||
|
|
||||||
sync.Once
|
sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +80,8 @@ func (f *TextFormatter) init(entry *Entry) {
|
|||||||
|
|
||||||
// Format renders a single log entry
|
// Format renders a single log entry
|
||||||
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
var b *bytes.Buffer
|
prefixFieldClashes(entry.Data, f.FieldMap)
|
||||||
|
|
||||||
keys := make([]string, 0, len(entry.Data))
|
keys := make([]string, 0, len(entry.Data))
|
||||||
for k := range entry.Data {
|
for k := range entry.Data {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
@@ -76,14 +90,14 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
|||||||
if !f.DisableSorting {
|
if !f.DisableSorting {
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var b *bytes.Buffer
|
||||||
if entry.Buffer != nil {
|
if entry.Buffer != nil {
|
||||||
b = entry.Buffer
|
b = entry.Buffer
|
||||||
} else {
|
} else {
|
||||||
b = &bytes.Buffer{}
|
b = &bytes.Buffer{}
|
||||||
}
|
}
|
||||||
|
|
||||||
prefixFieldClashes(entry.Data)
|
|
||||||
|
|
||||||
f.Do(func() { f.init(entry) })
|
f.Do(func() { f.init(entry) })
|
||||||
|
|
||||||
isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors
|
isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors
|
||||||
@@ -96,11 +110,11 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
|||||||
f.printColored(b, entry, keys, timestampFormat)
|
f.printColored(b, entry, keys, timestampFormat)
|
||||||
} else {
|
} else {
|
||||||
if !f.DisableTimestamp {
|
if !f.DisableTimestamp {
|
||||||
f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat))
|
f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyTime), entry.Time.Format(timestampFormat))
|
||||||
}
|
}
|
||||||
f.appendKeyValue(b, "level", entry.Level.String())
|
f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyLevel), entry.Level.String())
|
||||||
if entry.Message != "" {
|
if entry.Message != "" {
|
||||||
f.appendKeyValue(b, "msg", entry.Message)
|
f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyMsg), entry.Message)
|
||||||
}
|
}
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
f.appendKeyValue(b, key, entry.Data[key])
|
f.appendKeyValue(b, key, entry.Data[key])
|
||||||
@@ -124,7 +138,10 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin
|
|||||||
levelColor = blue
|
levelColor = blue
|
||||||
}
|
}
|
||||||
|
|
||||||
levelText := strings.ToUpper(entry.Level.String())[0:4]
|
levelText := strings.ToUpper(entry.Level.String())
|
||||||
|
if !f.DisableLevelTruncation {
|
||||||
|
levelText = levelText[0:4]
|
||||||
|
}
|
||||||
|
|
||||||
if f.DisableTimestamp {
|
if f.DisableTimestamp {
|
||||||
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message)
|
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message)
|
||||||
|
|||||||
+69
-41
@@ -32,6 +32,30 @@ func New(key [8]uint32, nonce [3]uint32) *Cipher {
|
|||||||
return &Cipher{key: key, nonce: nonce}
|
return &Cipher{key: key, nonce: nonce}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChaCha20 constants spelling "expand 32-byte k"
|
||||||
|
const (
|
||||||
|
j0 uint32 = 0x61707865
|
||||||
|
j1 uint32 = 0x3320646e
|
||||||
|
j2 uint32 = 0x79622d32
|
||||||
|
j3 uint32 = 0x6b206574
|
||||||
|
)
|
||||||
|
|
||||||
|
func quarterRound(a, b, c, d uint32) (uint32, uint32, uint32, uint32) {
|
||||||
|
a += b
|
||||||
|
d ^= a
|
||||||
|
d = (d << 16) | (d >> 16)
|
||||||
|
c += d
|
||||||
|
b ^= c
|
||||||
|
b = (b << 12) | (b >> 20)
|
||||||
|
a += b
|
||||||
|
d ^= a
|
||||||
|
d = (d << 8) | (d >> 24)
|
||||||
|
c += d
|
||||||
|
b ^= c
|
||||||
|
b = (b << 7) | (b >> 25)
|
||||||
|
return a, b, c, d
|
||||||
|
}
|
||||||
|
|
||||||
// XORKeyStream XORs each byte in the given slice with a byte from the
|
// XORKeyStream XORs each byte in the given slice with a byte from the
|
||||||
// cipher's key stream. Dst and src must overlap entirely or not at all.
|
// cipher's key stream. Dst and src must overlap entirely or not at all.
|
||||||
//
|
//
|
||||||
@@ -73,6 +97,9 @@ func (s *Cipher) XORKeyStream(dst, src []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if haveAsm {
|
if haveAsm {
|
||||||
|
if uint64(len(src))+uint64(s.counter)*64 > (1<<38)-64 {
|
||||||
|
panic("chacha20: counter overflow")
|
||||||
|
}
|
||||||
s.xorKeyStreamAsm(dst, src)
|
s.xorKeyStreamAsm(dst, src)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -85,59 +112,34 @@ func (s *Cipher) XORKeyStream(dst, src []byte) {
|
|||||||
copy(s.buf[len(s.buf)-64:], src[fin:])
|
copy(s.buf[len(s.buf)-64:], src[fin:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// qr calculates a quarter round
|
|
||||||
qr := func(a, b, c, d uint32) (uint32, uint32, uint32, uint32) {
|
|
||||||
a += b
|
|
||||||
d ^= a
|
|
||||||
d = (d << 16) | (d >> 16)
|
|
||||||
c += d
|
|
||||||
b ^= c
|
|
||||||
b = (b << 12) | (b >> 20)
|
|
||||||
a += b
|
|
||||||
d ^= a
|
|
||||||
d = (d << 8) | (d >> 24)
|
|
||||||
c += d
|
|
||||||
b ^= c
|
|
||||||
b = (b << 7) | (b >> 25)
|
|
||||||
return a, b, c, d
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChaCha20 constants
|
|
||||||
const (
|
|
||||||
j0 = 0x61707865
|
|
||||||
j1 = 0x3320646e
|
|
||||||
j2 = 0x79622d32
|
|
||||||
j3 = 0x6b206574
|
|
||||||
)
|
|
||||||
|
|
||||||
// pre-calculate most of the first round
|
// pre-calculate most of the first round
|
||||||
s1, s5, s9, s13 := qr(j1, s.key[1], s.key[5], s.nonce[0])
|
s1, s5, s9, s13 := quarterRound(j1, s.key[1], s.key[5], s.nonce[0])
|
||||||
s2, s6, s10, s14 := qr(j2, s.key[2], s.key[6], s.nonce[1])
|
s2, s6, s10, s14 := quarterRound(j2, s.key[2], s.key[6], s.nonce[1])
|
||||||
s3, s7, s11, s15 := qr(j3, s.key[3], s.key[7], s.nonce[2])
|
s3, s7, s11, s15 := quarterRound(j3, s.key[3], s.key[7], s.nonce[2])
|
||||||
|
|
||||||
n := len(src)
|
n := len(src)
|
||||||
src, dst = src[:n:n], dst[:n:n] // BCE hint
|
src, dst = src[:n:n], dst[:n:n] // BCE hint
|
||||||
for i := 0; i < n; i += 64 {
|
for i := 0; i < n; i += 64 {
|
||||||
// calculate the remainder of the first round
|
// calculate the remainder of the first round
|
||||||
s0, s4, s8, s12 := qr(j0, s.key[0], s.key[4], s.counter)
|
s0, s4, s8, s12 := quarterRound(j0, s.key[0], s.key[4], s.counter)
|
||||||
|
|
||||||
// execute the second round
|
// execute the second round
|
||||||
x0, x5, x10, x15 := qr(s0, s5, s10, s15)
|
x0, x5, x10, x15 := quarterRound(s0, s5, s10, s15)
|
||||||
x1, x6, x11, x12 := qr(s1, s6, s11, s12)
|
x1, x6, x11, x12 := quarterRound(s1, s6, s11, s12)
|
||||||
x2, x7, x8, x13 := qr(s2, s7, s8, s13)
|
x2, x7, x8, x13 := quarterRound(s2, s7, s8, s13)
|
||||||
x3, x4, x9, x14 := qr(s3, s4, s9, s14)
|
x3, x4, x9, x14 := quarterRound(s3, s4, s9, s14)
|
||||||
|
|
||||||
// execute the remaining 18 rounds
|
// execute the remaining 18 rounds
|
||||||
for i := 0; i < 9; i++ {
|
for i := 0; i < 9; i++ {
|
||||||
x0, x4, x8, x12 = qr(x0, x4, x8, x12)
|
x0, x4, x8, x12 = quarterRound(x0, x4, x8, x12)
|
||||||
x1, x5, x9, x13 = qr(x1, x5, x9, x13)
|
x1, x5, x9, x13 = quarterRound(x1, x5, x9, x13)
|
||||||
x2, x6, x10, x14 = qr(x2, x6, x10, x14)
|
x2, x6, x10, x14 = quarterRound(x2, x6, x10, x14)
|
||||||
x3, x7, x11, x15 = qr(x3, x7, x11, x15)
|
x3, x7, x11, x15 = quarterRound(x3, x7, x11, x15)
|
||||||
|
|
||||||
x0, x5, x10, x15 = qr(x0, x5, x10, x15)
|
x0, x5, x10, x15 = quarterRound(x0, x5, x10, x15)
|
||||||
x1, x6, x11, x12 = qr(x1, x6, x11, x12)
|
x1, x6, x11, x12 = quarterRound(x1, x6, x11, x12)
|
||||||
x2, x7, x8, x13 = qr(x2, x7, x8, x13)
|
x2, x7, x8, x13 = quarterRound(x2, x7, x8, x13)
|
||||||
x3, x4, x9, x14 = qr(x3, x4, x9, x14)
|
x3, x4, x9, x14 = quarterRound(x3, x4, x9, x14)
|
||||||
}
|
}
|
||||||
|
|
||||||
x0 += j0
|
x0 += j0
|
||||||
@@ -234,3 +236,29 @@ func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
|
|||||||
}
|
}
|
||||||
s.XORKeyStream(out, in)
|
s.XORKeyStream(out, in)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HChaCha20 uses the ChaCha20 core to generate a derived key from a key and a
|
||||||
|
// nonce. It should only be used as part of the XChaCha20 construction.
|
||||||
|
func HChaCha20(key *[8]uint32, nonce *[4]uint32) [8]uint32 {
|
||||||
|
x0, x1, x2, x3 := j0, j1, j2, j3
|
||||||
|
x4, x5, x6, x7 := key[0], key[1], key[2], key[3]
|
||||||
|
x8, x9, x10, x11 := key[4], key[5], key[6], key[7]
|
||||||
|
x12, x13, x14, x15 := nonce[0], nonce[1], nonce[2], nonce[3]
|
||||||
|
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
x0, x4, x8, x12 = quarterRound(x0, x4, x8, x12)
|
||||||
|
x1, x5, x9, x13 = quarterRound(x1, x5, x9, x13)
|
||||||
|
x2, x6, x10, x14 = quarterRound(x2, x6, x10, x14)
|
||||||
|
x3, x7, x11, x15 = quarterRound(x3, x7, x11, x15)
|
||||||
|
|
||||||
|
x0, x5, x10, x15 = quarterRound(x0, x5, x10, x15)
|
||||||
|
x1, x6, x11, x12 = quarterRound(x1, x6, x11, x12)
|
||||||
|
x2, x7, x8, x13 = quarterRound(x2, x7, x8, x13)
|
||||||
|
x3, x4, x9, x14 = quarterRound(x3, x4, x9, x14)
|
||||||
|
}
|
||||||
|
|
||||||
|
var out [8]uint32
|
||||||
|
out[0], out[1], out[2], out[3] = x0, x1, x2, x3
|
||||||
|
out[4], out[5], out[6], out[7] = x12, x13, x14, x15
|
||||||
|
return out
|
||||||
|
}
|
||||||
Generated
Vendored
File renamed without changes.
+38
-22
@@ -333,7 +333,6 @@ func ReadEntity(packets *packet.Reader) (*Entity, error) {
|
|||||||
return nil, errors.StructuralError("primary key cannot be used for signatures")
|
return nil, errors.StructuralError("primary key cannot be used for signatures")
|
||||||
}
|
}
|
||||||
|
|
||||||
var current *Identity
|
|
||||||
var revocations []*packet.Signature
|
var revocations []*packet.Signature
|
||||||
EachPacket:
|
EachPacket:
|
||||||
for {
|
for {
|
||||||
@@ -349,7 +348,7 @@ EachPacket:
|
|||||||
// Make a new Identity object, that we might wind up throwing away.
|
// Make a new Identity object, that we might wind up throwing away.
|
||||||
// We'll only add it if we get a valid self-signature over this
|
// We'll only add it if we get a valid self-signature over this
|
||||||
// userID.
|
// userID.
|
||||||
current = new(Identity)
|
current := new(Identity)
|
||||||
current.Name = pkt.Id
|
current.Name = pkt.Id
|
||||||
current.UserId = pkt
|
current.UserId = pkt
|
||||||
|
|
||||||
@@ -384,11 +383,9 @@ EachPacket:
|
|||||||
// TODO: RFC4880 5.2.1 permits signatures
|
// TODO: RFC4880 5.2.1 permits signatures
|
||||||
// directly on keys (eg. to bind additional
|
// directly on keys (eg. to bind additional
|
||||||
// revocation keys).
|
// revocation keys).
|
||||||
} else if current == nil {
|
|
||||||
return nil, errors.StructuralError("signature packet found before user id packet")
|
|
||||||
} else {
|
|
||||||
current.Signatures = append(current.Signatures, pkt)
|
|
||||||
}
|
}
|
||||||
|
// Else, ignoring the signature as it does not follow anything
|
||||||
|
// we would know to attach it to.
|
||||||
case *packet.PrivateKey:
|
case *packet.PrivateKey:
|
||||||
if pkt.IsSubkey == false {
|
if pkt.IsSubkey == false {
|
||||||
packets.Unread(p)
|
packets.Unread(p)
|
||||||
@@ -433,26 +430,45 @@ func addSubkey(e *Entity, packets *packet.Reader, pub *packet.PublicKey, priv *p
|
|||||||
var subKey Subkey
|
var subKey Subkey
|
||||||
subKey.PublicKey = pub
|
subKey.PublicKey = pub
|
||||||
subKey.PrivateKey = priv
|
subKey.PrivateKey = priv
|
||||||
p, err := packets.Next()
|
|
||||||
if err == io.EOF {
|
for {
|
||||||
return io.ErrUnexpectedEOF
|
p, err := packets.Next()
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
} else if err != nil {
|
||||||
|
return errors.StructuralError("subkey signature invalid: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
sig, ok := p.(*packet.Signature)
|
||||||
|
if !ok {
|
||||||
|
packets.Unread(p)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if sig.SigType != packet.SigTypeSubkeyBinding && sig.SigType != packet.SigTypeSubkeyRevocation {
|
||||||
|
return errors.StructuralError("subkey signature with wrong type")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := e.PrimaryKey.VerifyKeySignature(subKey.PublicKey, sig); err != nil {
|
||||||
|
return errors.StructuralError("subkey signature invalid: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
switch sig.SigType {
|
||||||
|
case packet.SigTypeSubkeyRevocation:
|
||||||
|
subKey.Sig = sig
|
||||||
|
case packet.SigTypeSubkeyBinding:
|
||||||
|
if subKey.Sig == nil {
|
||||||
|
subKey.Sig = sig
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return errors.StructuralError("subkey signature invalid: " + err.Error())
|
if subKey.Sig == nil {
|
||||||
}
|
|
||||||
var ok bool
|
|
||||||
subKey.Sig, ok = p.(*packet.Signature)
|
|
||||||
if !ok {
|
|
||||||
return errors.StructuralError("subkey packet not followed by signature")
|
return errors.StructuralError("subkey packet not followed by signature")
|
||||||
}
|
}
|
||||||
if subKey.Sig.SigType != packet.SigTypeSubkeyBinding && subKey.Sig.SigType != packet.SigTypeSubkeyRevocation {
|
|
||||||
return errors.StructuralError("subkey signature with wrong type")
|
|
||||||
}
|
|
||||||
err = e.PrimaryKey.VerifyKeySignature(subKey.PublicKey, subKey.Sig)
|
|
||||||
if err != nil {
|
|
||||||
return errors.StructuralError("subkey signature invalid: " + err.Error())
|
|
||||||
}
|
|
||||||
e.Subkeys = append(e.Subkeys, subKey)
|
e.Subkeys = append(e.Subkeys, subKey)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+106
-68
@@ -164,12 +164,12 @@ func hashToHashId(h crypto.Hash) uint8 {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt encrypts a message to a number of recipients and, optionally, signs
|
// writeAndSign writes the data as a payload package and, optionally, signs
|
||||||
// it. hints contains optional information, that is also encrypted, that aids
|
// it. hints contains optional information, that is also encrypted,
|
||||||
// the recipients in processing the message. The resulting WriteCloser must
|
// that aids the recipients in processing the message. The resulting
|
||||||
// be closed after the contents of the file have been written.
|
// WriteCloser must be closed after the contents of the file have been
|
||||||
// If config is nil, sensible defaults will be used.
|
// written. If config is nil, sensible defaults will be used.
|
||||||
func Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHints, config *packet.Config) (plaintext io.WriteCloser, err error) {
|
func writeAndSign(payload io.WriteCloser, candidateHashes []uint8, signed *Entity, hints *FileHints, config *packet.Config) (plaintext io.WriteCloser, err error) {
|
||||||
var signer *packet.PrivateKey
|
var signer *packet.PrivateKey
|
||||||
if signed != nil {
|
if signed != nil {
|
||||||
signKey, ok := signed.signingKey(config.Now())
|
signKey, ok := signed.signingKey(config.Now())
|
||||||
@@ -185,6 +185,83 @@ func Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hash crypto.Hash
|
||||||
|
for _, hashId := range candidateHashes {
|
||||||
|
if h, ok := s2k.HashIdToHash(hashId); ok && h.Available() {
|
||||||
|
hash = h
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the hash specified by config is a candidate, we'll use that.
|
||||||
|
if configuredHash := config.Hash(); configuredHash.Available() {
|
||||||
|
for _, hashId := range candidateHashes {
|
||||||
|
if h, ok := s2k.HashIdToHash(hashId); ok && h == configuredHash {
|
||||||
|
hash = h
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if hash == 0 {
|
||||||
|
hashId := candidateHashes[0]
|
||||||
|
name, ok := s2k.HashIdToString(hashId)
|
||||||
|
if !ok {
|
||||||
|
name = "#" + strconv.Itoa(int(hashId))
|
||||||
|
}
|
||||||
|
return nil, errors.InvalidArgumentError("cannot encrypt because no candidate hash functions are compiled in. (Wanted " + name + " in this case.)")
|
||||||
|
}
|
||||||
|
|
||||||
|
if signer != nil {
|
||||||
|
ops := &packet.OnePassSignature{
|
||||||
|
SigType: packet.SigTypeBinary,
|
||||||
|
Hash: hash,
|
||||||
|
PubKeyAlgo: signer.PubKeyAlgo,
|
||||||
|
KeyId: signer.KeyId,
|
||||||
|
IsLast: true,
|
||||||
|
}
|
||||||
|
if err := ops.Serialize(payload); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if hints == nil {
|
||||||
|
hints = &FileHints{}
|
||||||
|
}
|
||||||
|
|
||||||
|
w := payload
|
||||||
|
if signer != nil {
|
||||||
|
// If we need to write a signature packet after the literal
|
||||||
|
// data then we need to stop literalData from closing
|
||||||
|
// encryptedData.
|
||||||
|
w = noOpCloser{w}
|
||||||
|
|
||||||
|
}
|
||||||
|
var epochSeconds uint32
|
||||||
|
if !hints.ModTime.IsZero() {
|
||||||
|
epochSeconds = uint32(hints.ModTime.Unix())
|
||||||
|
}
|
||||||
|
literalData, err := packet.SerializeLiteral(w, hints.IsBinary, hints.FileName, epochSeconds)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if signer != nil {
|
||||||
|
return signatureWriter{payload, literalData, hash, hash.New(), signer, config}, nil
|
||||||
|
}
|
||||||
|
return literalData, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encrypt encrypts a message to a number of recipients and, optionally, signs
|
||||||
|
// it. hints contains optional information, that is also encrypted, that aids
|
||||||
|
// the recipients in processing the message. The resulting WriteCloser must
|
||||||
|
// be closed after the contents of the file have been written.
|
||||||
|
// If config is nil, sensible defaults will be used.
|
||||||
|
func Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHints, config *packet.Config) (plaintext io.WriteCloser, err error) {
|
||||||
|
if len(to) == 0 {
|
||||||
|
return nil, errors.InvalidArgumentError("no encryption recipient provided")
|
||||||
|
}
|
||||||
|
|
||||||
// These are the possible ciphers that we'll use for the message.
|
// These are the possible ciphers that we'll use for the message.
|
||||||
candidateCiphers := []uint8{
|
candidateCiphers := []uint8{
|
||||||
uint8(packet.CipherAES128),
|
uint8(packet.CipherAES128),
|
||||||
@@ -241,33 +318,6 @@ func Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var hash crypto.Hash
|
|
||||||
for _, hashId := range candidateHashes {
|
|
||||||
if h, ok := s2k.HashIdToHash(hashId); ok && h.Available() {
|
|
||||||
hash = h
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the hash specified by config is a candidate, we'll use that.
|
|
||||||
if configuredHash := config.Hash(); configuredHash.Available() {
|
|
||||||
for _, hashId := range candidateHashes {
|
|
||||||
if h, ok := s2k.HashIdToHash(hashId); ok && h == configuredHash {
|
|
||||||
hash = h
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if hash == 0 {
|
|
||||||
hashId := candidateHashes[0]
|
|
||||||
name, ok := s2k.HashIdToString(hashId)
|
|
||||||
if !ok {
|
|
||||||
name = "#" + strconv.Itoa(int(hashId))
|
|
||||||
}
|
|
||||||
return nil, errors.InvalidArgumentError("cannot encrypt because no candidate hash functions are compiled in. (Wanted " + name + " in this case.)")
|
|
||||||
}
|
|
||||||
|
|
||||||
symKey := make([]byte, cipher.KeySize())
|
symKey := make([]byte, cipher.KeySize())
|
||||||
if _, err := io.ReadFull(config.Random(), symKey); err != nil {
|
if _, err := io.ReadFull(config.Random(), symKey); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -279,49 +329,37 @@ func Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
encryptedData, err := packet.SerializeSymmetricallyEncrypted(ciphertext, cipher, symKey, config)
|
payload, err := packet.SerializeSymmetricallyEncrypted(ciphertext, cipher, symKey, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if signer != nil {
|
return writeAndSign(payload, candidateHashes, signed, hints, config)
|
||||||
ops := &packet.OnePassSignature{
|
}
|
||||||
SigType: packet.SigTypeBinary,
|
|
||||||
Hash: hash,
|
// Sign signs a message. The resulting WriteCloser must be closed after the
|
||||||
PubKeyAlgo: signer.PubKeyAlgo,
|
// contents of the file have been written. hints contains optional information
|
||||||
KeyId: signer.KeyId,
|
// that aids the recipients in processing the message.
|
||||||
IsLast: true,
|
// If config is nil, sensible defaults will be used.
|
||||||
}
|
func Sign(output io.Writer, signed *Entity, hints *FileHints, config *packet.Config) (input io.WriteCloser, err error) {
|
||||||
if err := ops.Serialize(encryptedData); err != nil {
|
if signed == nil {
|
||||||
return nil, err
|
return nil, errors.InvalidArgumentError("no signer provided")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if hints == nil {
|
// These are the possible hash functions that we'll use for the signature.
|
||||||
hints = &FileHints{}
|
candidateHashes := []uint8{
|
||||||
|
hashToHashId(crypto.SHA256),
|
||||||
|
hashToHashId(crypto.SHA512),
|
||||||
|
hashToHashId(crypto.SHA1),
|
||||||
|
hashToHashId(crypto.RIPEMD160),
|
||||||
}
|
}
|
||||||
|
defaultHashes := candidateHashes[len(candidateHashes)-1:]
|
||||||
w := encryptedData
|
preferredHashes := signed.primaryIdentity().SelfSignature.PreferredHash
|
||||||
if signer != nil {
|
if len(preferredHashes) == 0 {
|
||||||
// If we need to write a signature packet after the literal
|
preferredHashes = defaultHashes
|
||||||
// data then we need to stop literalData from closing
|
|
||||||
// encryptedData.
|
|
||||||
w = noOpCloser{encryptedData}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
var epochSeconds uint32
|
candidateHashes = intersectPreferences(candidateHashes, preferredHashes)
|
||||||
if !hints.ModTime.IsZero() {
|
return writeAndSign(noOpCloser{output}, candidateHashes, signed, hints, config)
|
||||||
epochSeconds = uint32(hints.ModTime.Unix())
|
|
||||||
}
|
|
||||||
literalData, err := packet.SerializeLiteral(w, hints.IsBinary, hints.FileName, epochSeconds)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if signer != nil {
|
|
||||||
return signatureWriter{encryptedData, literalData, hash, hash.New(), signer, config}, nil
|
|
||||||
}
|
|
||||||
return literalData, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// signatureWriter hashes the contents of a message while passing it along to
|
// signatureWriter hashes the contents of a message while passing it along to
|
||||||
|
|||||||
+6
-3
@@ -803,7 +803,7 @@ func encryptedBlock(block *pem.Block) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseRawPrivateKey returns a private key from a PEM encoded private key. It
|
// ParseRawPrivateKey returns a private key from a PEM encoded private key. It
|
||||||
// supports RSA (PKCS#1), DSA (OpenSSL), and ECDSA private keys.
|
// supports RSA (PKCS#1), PKCS#8, DSA (OpenSSL), and ECDSA private keys.
|
||||||
func ParseRawPrivateKey(pemBytes []byte) (interface{}, error) {
|
func ParseRawPrivateKey(pemBytes []byte) (interface{}, error) {
|
||||||
block, _ := pem.Decode(pemBytes)
|
block, _ := pem.Decode(pemBytes)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
@@ -817,6 +817,9 @@ func ParseRawPrivateKey(pemBytes []byte) (interface{}, error) {
|
|||||||
switch block.Type {
|
switch block.Type {
|
||||||
case "RSA PRIVATE KEY":
|
case "RSA PRIVATE KEY":
|
||||||
return x509.ParsePKCS1PrivateKey(block.Bytes)
|
return x509.ParsePKCS1PrivateKey(block.Bytes)
|
||||||
|
// RFC5208 - https://tools.ietf.org/html/rfc5208
|
||||||
|
case "PRIVATE KEY":
|
||||||
|
return x509.ParsePKCS8PrivateKey(block.Bytes)
|
||||||
case "EC PRIVATE KEY":
|
case "EC PRIVATE KEY":
|
||||||
return x509.ParseECPrivateKey(block.Bytes)
|
return x509.ParseECPrivateKey(block.Bytes)
|
||||||
case "DSA PRIVATE KEY":
|
case "DSA PRIVATE KEY":
|
||||||
@@ -900,8 +903,8 @@ func ParseDSAPrivateKey(der []byte) (*dsa.PrivateKey, error) {
|
|||||||
// Implemented based on the documentation at
|
// Implemented based on the documentation at
|
||||||
// https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
|
// https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
|
||||||
func parseOpenSSHPrivateKey(key []byte) (crypto.PrivateKey, error) {
|
func parseOpenSSHPrivateKey(key []byte) (crypto.PrivateKey, error) {
|
||||||
magic := append([]byte("openssh-key-v1"), 0)
|
const magic = "openssh-key-v1\x00"
|
||||||
if !bytes.Equal(magic, key[0:len(magic)]) {
|
if len(key) < len(magic) || string(key[:len(magic)]) != magic {
|
||||||
return nil, errors.New("ssh: invalid openssh private key format")
|
return nil, errors.New("ssh: invalid openssh private key format")
|
||||||
}
|
}
|
||||||
remaining := key[len(magic):]
|
remaining := key[len(magic):]
|
||||||
|
|||||||
+2
@@ -103,6 +103,7 @@ var brokenAuthHeaderProviders = []string{
|
|||||||
"https://api.twitch.tv/",
|
"https://api.twitch.tv/",
|
||||||
"https://id.twitch.tv/",
|
"https://id.twitch.tv/",
|
||||||
"https://app.box.com/",
|
"https://app.box.com/",
|
||||||
|
"https://api.box.com/",
|
||||||
"https://connect.stripe.com/",
|
"https://connect.stripe.com/",
|
||||||
"https://login.mailchimp.com/",
|
"https://login.mailchimp.com/",
|
||||||
"https://login.microsoftonline.com/",
|
"https://login.microsoftonline.com/",
|
||||||
@@ -130,6 +131,7 @@ var brokenAuthHeaderProviders = []string{
|
|||||||
"https://multisport.todaysplan.com.au/rest/oauth/access_token",
|
"https://multisport.todaysplan.com.au/rest/oauth/access_token",
|
||||||
"https://whats.todaysplan.com.au/rest/oauth/access_token",
|
"https://whats.todaysplan.com.au/rest/oauth/access_token",
|
||||||
"https://stackoverflow.com/oauth/access_token",
|
"https://stackoverflow.com/oauth/access_token",
|
||||||
|
"https://account.health.nokia.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
// brokenAuthHeaderDomains lists broken providers that issue dynamic endpoints.
|
// brokenAuthHeaderDomains lists broken providers that issue dynamic endpoints.
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
// +build go1.9
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
type Signal = syscall.Signal
|
||||||
|
type Errno = syscall.Errno
|
||||||
|
type SysProcAttr = syscall.SysProcAttr
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix
|
||||||
|
// +build ppc
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used by AIX.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Linux device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 16) & 0xffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Linux device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Linux device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return uint64(((major) << 16) | (minor))
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix
|
||||||
|
// +build ppc64
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used AIX.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Linux device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x3fffffff00000000) >> 32)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Linux device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x00000000ffffffff) >> 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Linux device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
var DEVNO64 uint64
|
||||||
|
DEVNO64 = 0x8000000000000000
|
||||||
|
return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64)
|
||||||
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// Unix environment variables.
|
// Unix environment variables.
|
||||||
|
|
||||||
|
|||||||
+1
@@ -3,6 +3,7 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build gccgo
|
// +build gccgo
|
||||||
|
// +build !aix
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+1
@@ -3,6 +3,7 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build gccgo
|
// +build gccgo
|
||||||
|
// +build !aix
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
||||||
|
//
|
||||||
|
// To change fd's window size, the req argument should be TIOCSWINSZ.
|
||||||
|
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
|
// TODO: if we get the chance, remove the req parameter and
|
||||||
|
// hardcode TIOCSWINSZ.
|
||||||
|
err := ioctlSetWinsize(fd, req, value)
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlSetTermios performs an ioctl on fd with a *Termios.
|
||||||
|
//
|
||||||
|
// The req value will usually be TCSETA or TIOCSETA.
|
||||||
|
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
|
// TODO: if we get the chance, remove the req parameter.
|
||||||
|
err := ioctlSetTermios(fd, req, value)
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
+10
@@ -59,6 +59,16 @@ _* | *_ | _)
|
|||||||
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
|
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
aix_ppc)
|
||||||
|
mkerrors="$mkerrors -maix32"
|
||||||
|
mksyscall="perl mksyscall_aix.pl -aix"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
|
aix_ppc64)
|
||||||
|
mkerrors="$mkerrors -maix64"
|
||||||
|
mksyscall="perl mksyscall_aix.pl -aix"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
darwin_386)
|
darwin_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="./mksyscall.pl -l32"
|
mksyscall="./mksyscall.pl -l32"
|
||||||
|
|||||||
+55
-7
@@ -25,7 +25,11 @@ if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CC=${CC:-cc}
|
if [[ "$GOOS" = "aix" ]]; then
|
||||||
|
CC=${CC:-gcc}
|
||||||
|
else
|
||||||
|
CC=${CC:-cc}
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$GOOS" = "solaris" ]]; then
|
if [[ "$GOOS" = "solaris" ]]; then
|
||||||
# Assumes GNU versions of utilities in PATH.
|
# Assumes GNU versions of utilities in PATH.
|
||||||
@@ -34,6 +38,21 @@ fi
|
|||||||
|
|
||||||
uname=$(uname)
|
uname=$(uname)
|
||||||
|
|
||||||
|
includes_AIX='
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/netopt.h>
|
||||||
|
#include <netinet/ip_mroute.h>
|
||||||
|
#include <sys/protosw.h>
|
||||||
|
#include <sys/stropts.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#include <sys/termio.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#define AF_LOCAL AF_UNIX
|
||||||
|
'
|
||||||
|
|
||||||
includes_Darwin='
|
includes_Darwin='
|
||||||
#define _DARWIN_C_SOURCE
|
#define _DARWIN_C_SOURCE
|
||||||
#define KERNEL
|
#define KERNEL
|
||||||
@@ -65,8 +84,10 @@ includes_DragonFly='
|
|||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
@@ -86,6 +107,7 @@ includes_FreeBSD='
|
|||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
@@ -173,8 +195,10 @@ struct ltchars {
|
|||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/keyctl.h>
|
#include <linux/keyctl.h>
|
||||||
#include <linux/magic.h>
|
#include <linux/magic.h>
|
||||||
|
#include <linux/memfd.h>
|
||||||
#include <linux/netfilter/nfnetlink.h>
|
#include <linux/netfilter/nfnetlink.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/net_namespace.h>
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
@@ -190,10 +214,11 @@ struct ltchars {
|
|||||||
#include <linux/vm_sockets.h>
|
#include <linux/vm_sockets.h>
|
||||||
#include <linux/taskstats.h>
|
#include <linux/taskstats.h>
|
||||||
#include <linux/genetlink.h>
|
#include <linux/genetlink.h>
|
||||||
#include <linux/stat.h>
|
|
||||||
#include <linux/watchdog.h>
|
#include <linux/watchdog.h>
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
#include <linux/rtc.h>
|
#include <linux/rtc.h>
|
||||||
|
#include <linux/if_xdp.h>
|
||||||
|
#include <mtd/ubi-user.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
#include <asm/termbits.h>
|
#include <asm/termbits.h>
|
||||||
|
|
||||||
@@ -223,13 +248,25 @@ struct ltchars {
|
|||||||
#define FS_KEY_DESC_PREFIX "fscrypt:"
|
#define FS_KEY_DESC_PREFIX "fscrypt:"
|
||||||
#define FS_KEY_DESC_PREFIX_SIZE 8
|
#define FS_KEY_DESC_PREFIX_SIZE 8
|
||||||
#define FS_MAX_KEY_SIZE 64
|
#define FS_MAX_KEY_SIZE 64
|
||||||
|
|
||||||
|
// XDP socket constants do not appear to be picked up otherwise.
|
||||||
|
// Copied from samples/bpf/xdpsock_user.c.
|
||||||
|
#ifndef SOL_XDP
|
||||||
|
#define SOL_XDP 283
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AF_XDP
|
||||||
|
#define AF_XDP 44
|
||||||
|
#endif
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_NetBSD='
|
includes_NetBSD='
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
|
#include <sys/extattr.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@@ -255,11 +292,14 @@ includes_OpenBSD='
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
#include <sys/ttycom.h>
|
#include <sys/ttycom.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@@ -291,6 +331,7 @@ includes_SunOS='
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@@ -353,6 +394,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
|
$2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
|
||||||
$2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
|
$2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
|
||||||
|
|
||||||
|
$2 !~ /^ECCAPBITS/ &&
|
||||||
$2 !~ /^ETH_/ &&
|
$2 !~ /^ETH_/ &&
|
||||||
$2 !~ /^EPROC_/ &&
|
$2 !~ /^EPROC_/ &&
|
||||||
$2 !~ /^EQUIV_/ &&
|
$2 !~ /^EQUIV_/ &&
|
||||||
@@ -388,7 +430,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
||||||
$2 ~ /^IN_/ ||
|
$2 ~ /^IN_/ ||
|
||||||
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
||||||
$2 ~ /^TP_STATUS_/ ||
|
$2 ~ /^TP_STATUS_/ ||
|
||||||
$2 ~ /^FALLOC_/ ||
|
$2 ~ /^FALLOC_/ ||
|
||||||
$2 == "ICMPV6_FILTER" ||
|
$2 == "ICMPV6_FILTER" ||
|
||||||
@@ -399,13 +441,14 @@ ccflags="$@"
|
|||||||
$2 ~ /^KERN_(HOSTNAME|OS(RELEASE|TYPE)|VERSION)$/ ||
|
$2 ~ /^KERN_(HOSTNAME|OS(RELEASE|TYPE)|VERSION)$/ ||
|
||||||
$2 ~ /^HW_MACHINE$/ ||
|
$2 ~ /^HW_MACHINE$/ ||
|
||||||
$2 ~ /^SYSCTL_VERS/ ||
|
$2 ~ /^SYSCTL_VERS/ ||
|
||||||
|
$2 !~ "MNT_BITS" &&
|
||||||
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
||||||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
||||||
$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
|
$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
||||||
$2 !~ "NLA_TYPE_MASK" &&
|
$2 !~ "NLA_TYPE_MASK" &&
|
||||||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
||||||
$2 ~ /^SIOC/ ||
|
$2 ~ /^SIOC/ ||
|
||||||
$2 ~ /^TIOC/ ||
|
$2 ~ /^TIOC/ ||
|
||||||
$2 ~ /^TCGET/ ||
|
$2 ~ /^TCGET/ ||
|
||||||
@@ -431,20 +474,25 @@ ccflags="$@"
|
|||||||
$2 ~ /^PERF_EVENT_IOC_/ ||
|
$2 ~ /^PERF_EVENT_IOC_/ ||
|
||||||
$2 ~ /^SECCOMP_MODE_/ ||
|
$2 ~ /^SECCOMP_MODE_/ ||
|
||||||
$2 ~ /^SPLICE_/ ||
|
$2 ~ /^SPLICE_/ ||
|
||||||
|
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
||||||
$2 !~ /^AUDIT_RECORD_MAGIC/ &&
|
$2 !~ /^AUDIT_RECORD_MAGIC/ &&
|
||||||
$2 ~ /^[A-Z0-9_]+_MAGIC2?$/ ||
|
$2 !~ /IOC_MAGIC/ &&
|
||||||
|
$2 ~ /^[A-Z][A-Z0-9_]+_MAGIC2?$/ ||
|
||||||
$2 ~ /^(VM|VMADDR)_/ ||
|
$2 ~ /^(VM|VMADDR)_/ ||
|
||||||
$2 ~ /^IOCTL_VM_SOCKETS_/ ||
|
$2 ~ /^IOCTL_VM_SOCKETS_/ ||
|
||||||
$2 ~ /^(TASKSTATS|TS)_/ ||
|
$2 ~ /^(TASKSTATS|TS)_/ ||
|
||||||
$2 ~ /^CGROUPSTATS_/ ||
|
$2 ~ /^CGROUPSTATS_/ ||
|
||||||
$2 ~ /^GENL_/ ||
|
$2 ~ /^GENL_/ ||
|
||||||
$2 ~ /^STATX_/ ||
|
$2 ~ /^STATX_/ ||
|
||||||
|
$2 ~ /^RENAME/ ||
|
||||||
|
$2 ~ /^UBI_IOC[A-Z]/ ||
|
||||||
$2 ~ /^UTIME_/ ||
|
$2 ~ /^UTIME_/ ||
|
||||||
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
||||||
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
||||||
$2 ~ /^FSOPT_/ ||
|
$2 ~ /^FSOPT_/ ||
|
||||||
$2 ~ /^WDIOC_/ ||
|
$2 ~ /^WDIOC_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
|
$2 ~ /^XDP_/ ||
|
||||||
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
||||||
$2 !~ "WMESGLEN" &&
|
$2 !~ "WMESGLEN" &&
|
||||||
$2 ~ /^W[A-Z0-9]+$/ ||
|
$2 ~ /^W[A-Z0-9]+$/ ||
|
||||||
@@ -469,7 +517,7 @@ errors=$(
|
|||||||
signals=$(
|
signals=$(
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
||||||
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||||
sort
|
sort
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -479,7 +527,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
|||||||
sort >_error.grep
|
sort >_error.grep
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
||||||
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||||
sort >_signal.grep
|
sort >_signal.grep
|
||||||
|
|
||||||
echo '// mkerrors.sh' "$@"
|
echo '// mkerrors.sh' "$@"
|
||||||
|
|||||||
+385
@@ -0,0 +1,385 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
# Copyright 2018 The Go 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_aix.go) and generates system call bodies.
|
||||||
|
# The prototypes are marked by lines beginning with "//sys"
|
||||||
|
# and read like func declarations if //sys is replaced by func, but:
|
||||||
|
# * The parameter lists must give a name for each argument.
|
||||||
|
# This includes return parameters.
|
||||||
|
# * The parameter lists must give a type for each argument:
|
||||||
|
# the (x, y, z int) shorthand is not allowed.
|
||||||
|
# * If the return parameter is an error number, it must be named err.
|
||||||
|
# * If go func name needs to be different than its libc name,
|
||||||
|
# * or the function is not in libc, name could be specified
|
||||||
|
# * at the end, after "=" sign, like
|
||||||
|
# //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $cmdline = "mksyscall_aix.pl " . join(' ', @ARGV);
|
||||||
|
my $errors = 0;
|
||||||
|
my $_32bit = "";
|
||||||
|
my $tags = ""; # build tags
|
||||||
|
my $aix = 0;
|
||||||
|
my $solaris = 0;
|
||||||
|
|
||||||
|
binmode STDOUT;
|
||||||
|
|
||||||
|
if($ARGV[0] eq "-b32") {
|
||||||
|
$_32bit = "big-endian";
|
||||||
|
shift;
|
||||||
|
} elsif($ARGV[0] eq "-l32") {
|
||||||
|
$_32bit = "little-endian";
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-aix") {
|
||||||
|
$aix = 1;
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
if($ARGV[0] eq "-tags") {
|
||||||
|
shift;
|
||||||
|
$tags = $ARGV[0];
|
||||||
|
shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ARGV[0] =~ /^-/) {
|
||||||
|
print STDERR "usage: mksyscall_aix.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parseparamlist($) {
|
||||||
|
my ($list) = @_;
|
||||||
|
$list =~ s/^\s*//;
|
||||||
|
$list =~ s/\s*$//;
|
||||||
|
if($list eq "") {
|
||||||
|
return ();
|
||||||
|
}
|
||||||
|
return split(/\s*,\s*/, $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parseparam($) {
|
||||||
|
my ($p) = @_;
|
||||||
|
if($p !~ /^(\S*) (\S*)$/) {
|
||||||
|
print STDERR "$ARGV:$.: malformed parameter: $p\n";
|
||||||
|
$errors = 1;
|
||||||
|
return ("xx", "int");
|
||||||
|
}
|
||||||
|
return ($1, $2);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $package = "";
|
||||||
|
my $text = "";
|
||||||
|
my $c_extern = "/*\n#include <stdint.h>\n";
|
||||||
|
my @vars = ();
|
||||||
|
while(<>) {
|
||||||
|
chomp;
|
||||||
|
s/\s+/ /g;
|
||||||
|
s/^\s+//;
|
||||||
|
s/\s+$//;
|
||||||
|
$package = $1 if !$package && /^package (\S+)$/;
|
||||||
|
my $nonblock = /^\/\/sysnb /;
|
||||||
|
next if !/^\/\/sys / && !$nonblock;
|
||||||
|
|
||||||
|
# Line must be of the form
|
||||||
|
# func Open(path string, mode int, perm int) (fd int, err error)
|
||||||
|
# Split into name, in params, out params.
|
||||||
|
if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
|
||||||
|
print STDERR "$ARGV:$.: malformed //sys declaration\n";
|
||||||
|
$errors = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
|
||||||
|
|
||||||
|
# Split argument lists on comma.
|
||||||
|
my @in = parseparamlist($in);
|
||||||
|
my @out = parseparamlist($out);
|
||||||
|
|
||||||
|
$in = join(', ', @in);
|
||||||
|
$out = join(', ', @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";
|
||||||
|
|
||||||
|
# Check if value return, err return available
|
||||||
|
my $errvar = "";
|
||||||
|
my $retvar = "";
|
||||||
|
my $rettype = "";
|
||||||
|
foreach my $p (@out) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type eq "error") {
|
||||||
|
$errvar = $name;
|
||||||
|
} else {
|
||||||
|
$retvar = $name;
|
||||||
|
$rettype = $type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# System call name.
|
||||||
|
#if($func ne "fcntl") {
|
||||||
|
|
||||||
|
if($sysname eq "") {
|
||||||
|
$sysname = "$func";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sysname =~ s/([a-z])([A-Z])/${1}_$2/g;
|
||||||
|
$sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
|
||||||
|
|
||||||
|
my $C_rettype = "";
|
||||||
|
if($rettype eq "unsafe.Pointer") {
|
||||||
|
$C_rettype = "uintptr_t";
|
||||||
|
} elsif($rettype eq "uintptr") {
|
||||||
|
$C_rettype = "uintptr_t";
|
||||||
|
} elsif($rettype =~ /^_/) {
|
||||||
|
$C_rettype = "uintptr_t";
|
||||||
|
} elsif($rettype eq "int") {
|
||||||
|
$C_rettype = "int";
|
||||||
|
} elsif($rettype eq "int32") {
|
||||||
|
$C_rettype = "int";
|
||||||
|
} elsif($rettype eq "int64") {
|
||||||
|
$C_rettype = "long long";
|
||||||
|
} elsif($rettype eq "uint32") {
|
||||||
|
$C_rettype = "unsigned int";
|
||||||
|
} elsif($rettype eq "uint64") {
|
||||||
|
$C_rettype = "unsigned long long";
|
||||||
|
} else {
|
||||||
|
$C_rettype = "int";
|
||||||
|
}
|
||||||
|
if($sysname eq "exit") {
|
||||||
|
$C_rettype = "void";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Change types to c
|
||||||
|
my @c_in = ();
|
||||||
|
foreach my $p (@in) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type =~ /^\*/) {
|
||||||
|
push @c_in, "uintptr_t";
|
||||||
|
} elsif($type eq "string") {
|
||||||
|
push @c_in, "uintptr_t";
|
||||||
|
} elsif($type =~ /^\[\](.*)/) {
|
||||||
|
push @c_in, "uintptr_t", "size_t";
|
||||||
|
} elsif($type eq "unsafe.Pointer") {
|
||||||
|
push @c_in, "uintptr_t";
|
||||||
|
} elsif($type eq "uintptr") {
|
||||||
|
push @c_in, "uintptr_t";
|
||||||
|
} elsif($type =~ /^_/) {
|
||||||
|
push @c_in, "uintptr_t";
|
||||||
|
} elsif($type eq "int") {
|
||||||
|
push @c_in, "int";
|
||||||
|
} elsif($type eq "int32") {
|
||||||
|
push @c_in, "int";
|
||||||
|
} elsif($type eq "int64") {
|
||||||
|
push @c_in, "long long";
|
||||||
|
} elsif($type eq "uint32") {
|
||||||
|
push @c_in, "unsigned int";
|
||||||
|
} elsif($type eq "uint64") {
|
||||||
|
push @c_in, "unsigned long long";
|
||||||
|
} else {
|
||||||
|
push @c_in, "int";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($func ne "fcntl" && $func ne "FcntlInt" && $func ne "readlen" && $func ne "writelen") {
|
||||||
|
# Imports of system calls from libc
|
||||||
|
$c_extern .= "$C_rettype $sysname";
|
||||||
|
my $c_in = join(', ', @c_in);
|
||||||
|
$c_extern .= "($c_in);\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# So file name.
|
||||||
|
if($aix) {
|
||||||
|
if($modname eq "") {
|
||||||
|
$modname = "libc.a/shr_64.o";
|
||||||
|
} else {
|
||||||
|
print STDERR "$func: only syscall using libc are available\n";
|
||||||
|
$errors = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $strconvfunc = "C.CString";
|
||||||
|
my $strconvtype = "*byte";
|
||||||
|
|
||||||
|
# Go function header.
|
||||||
|
if($out ne "") {
|
||||||
|
$out = " ($out)";
|
||||||
|
}
|
||||||
|
if($text ne "") {
|
||||||
|
$text .= "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out ;
|
||||||
|
|
||||||
|
# Prepare arguments to call.
|
||||||
|
my @args = ();
|
||||||
|
my $n = 0;
|
||||||
|
my $arg_n = 0;
|
||||||
|
foreach my $p (@in) {
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
if($type =~ /^\*/) {
|
||||||
|
push @args, "C.uintptr_t(uintptr(unsafe.Pointer($name)))";
|
||||||
|
} elsif($type eq "string" && $errvar ne "") {
|
||||||
|
$text .= "\t_p$n := uintptr(unsafe.Pointer($strconvfunc($name)))\n";
|
||||||
|
push @args, "C.uintptr_t(_p$n)";
|
||||||
|
$n++;
|
||||||
|
} elsif($type eq "string") {
|
||||||
|
print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
|
||||||
|
$text .= "\t_p$n := uintptr(unsafe.Pointer($strconvfunc($name)))\n";
|
||||||
|
push @args, "C.uintptr_t(_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, "C.uintptr_t(uintptr(unsafe.Pointer(_p$n)))";
|
||||||
|
$n++;
|
||||||
|
$text .= "\tvar _p$n int\n";
|
||||||
|
$text .= "\t_p$n = len($name)\n";
|
||||||
|
push @args, "C.size_t(_p$n)";
|
||||||
|
$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)";
|
||||||
|
}
|
||||||
|
$n++;
|
||||||
|
} 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, "_p$n";
|
||||||
|
$n++;
|
||||||
|
} elsif($type =~ /^_/) {
|
||||||
|
push @args, "C.uintptr_t(uintptr($name))";
|
||||||
|
} elsif($type eq "unsafe.Pointer") {
|
||||||
|
push @args, "C.uintptr_t(uintptr($name))";
|
||||||
|
} elsif($type eq "int") {
|
||||||
|
if (($arg_n == 2) && (($func eq "readlen") || ($func eq "writelen"))) {
|
||||||
|
push @args, "C.size_t($name)";
|
||||||
|
} elsif ($arg_n == 0 && $func eq "fcntl") {
|
||||||
|
push @args, "C.uintptr_t($name)";
|
||||||
|
} elsif (($arg_n == 2) && (($func eq "fcntl") || ($func eq "FcntlInt"))) {
|
||||||
|
push @args, "C.uintptr_t($name)";
|
||||||
|
} else {
|
||||||
|
push @args, "C.int($name)";
|
||||||
|
}
|
||||||
|
} elsif($type eq "int32") {
|
||||||
|
push @args, "C.int($name)";
|
||||||
|
} elsif($type eq "int64") {
|
||||||
|
push @args, "C.longlong($name)";
|
||||||
|
} elsif($type eq "uint32") {
|
||||||
|
push @args, "C.uint($name)";
|
||||||
|
} elsif($type eq "uint64") {
|
||||||
|
push @args, "C.ulonglong($name)";
|
||||||
|
} elsif($type eq "uintptr") {
|
||||||
|
push @args, "C.uintptr_t($name)";
|
||||||
|
} else {
|
||||||
|
push @args, "C.int($name)";
|
||||||
|
}
|
||||||
|
$arg_n++;
|
||||||
|
}
|
||||||
|
my $nargs = @args;
|
||||||
|
|
||||||
|
|
||||||
|
# Determine which form to use; pad args with zeros.
|
||||||
|
if ($nonblock) {
|
||||||
|
}
|
||||||
|
|
||||||
|
my $args = join(', ', @args);
|
||||||
|
my $call = "";
|
||||||
|
if ($sysname eq "exit") {
|
||||||
|
if ($errvar ne "") {
|
||||||
|
$call .= "er :=";
|
||||||
|
} else {
|
||||||
|
$call .= "";
|
||||||
|
}
|
||||||
|
} elsif ($errvar ne "") {
|
||||||
|
$call .= "r0,er :=";
|
||||||
|
} elsif ($retvar ne "") {
|
||||||
|
$call .= "r0,_ :=";
|
||||||
|
} else {
|
||||||
|
$call .= ""
|
||||||
|
}
|
||||||
|
$call .= "C.$sysname($args)";
|
||||||
|
|
||||||
|
# Assign return values.
|
||||||
|
my $body = "";
|
||||||
|
my $failexpr = "";
|
||||||
|
|
||||||
|
for(my $i=0; $i<@out; $i++) {
|
||||||
|
my $p = $out[$i];
|
||||||
|
my ($name, $type) = parseparam($p);
|
||||||
|
my $reg = "";
|
||||||
|
if($name eq "err") {
|
||||||
|
$reg = "e1";
|
||||||
|
} else {
|
||||||
|
$reg = "r0";
|
||||||
|
}
|
||||||
|
if($reg ne "e1" ) {
|
||||||
|
$body .= "\t$name = $type($reg)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# verify return
|
||||||
|
if ($sysname ne "exit" && $errvar ne "") {
|
||||||
|
if ($C_rettype =~ /^uintptr/) {
|
||||||
|
$body .= "\tif \(uintptr\(r0\) ==\^uintptr\(0\) && er != nil\) {\n";
|
||||||
|
$body .= "\t\t$errvar = er\n";
|
||||||
|
$body .= "\t}\n";
|
||||||
|
} else {
|
||||||
|
$body .= "\tif \(r0 ==-1 && er != nil\) {\n";
|
||||||
|
$body .= "\t\t$errvar = er\n";
|
||||||
|
$body .= "\t}\n";
|
||||||
|
}
|
||||||
|
} elsif ($errvar ne "") {
|
||||||
|
$body .= "\tif \(er != nil\) {\n";
|
||||||
|
$body .= "\t\t$errvar = er\n";
|
||||||
|
$body .= "\t}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "\t$call\n";
|
||||||
|
$text .= $body;
|
||||||
|
|
||||||
|
$text .= "\treturn\n";
|
||||||
|
$text .= "}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($errors) {
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// $cmdline
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build $tags
|
||||||
|
|
||||||
|
package $package
|
||||||
|
|
||||||
|
|
||||||
|
$c_extern
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix";
|
||||||
|
|
||||||
|
chomp($_=<<EOF);
|
||||||
|
|
||||||
|
$text
|
||||||
|
EOF
|
||||||
|
print $_;
|
||||||
|
exit 0;
|
||||||
+1
-1
@@ -27,7 +27,7 @@ const (
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
while(<>){
|
while(<>){
|
||||||
if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
|
if(/^([0-9]+)\s+\S+\s+(?:NO)?STD\s+({ \S+\s+(\w+).*)$/){
|
||||||
my $num = $1;
|
my $num = $1;
|
||||||
my $proto = $2;
|
my $proto = $2;
|
||||||
my $name = "SYS_$3";
|
my $name = "SYS_$3";
|
||||||
|
|||||||
+66
-9
@@ -8,6 +8,9 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
@@ -16,23 +19,77 @@ const (
|
|||||||
_SYS_PLEDGE = 108
|
_SYS_PLEDGE = 108
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pledge implements the pledge syscall. For more information see pledge(2).
|
// Pledge implements the pledge syscall.
|
||||||
func Pledge(promises string, paths []string) error {
|
//
|
||||||
promisesPtr, err := syscall.BytePtrFromString(promises)
|
// The pledge syscall does not accept execpromises on OpenBSD releases
|
||||||
|
// before 6.3.
|
||||||
|
//
|
||||||
|
// execpromises must be empty when Pledge is called on OpenBSD
|
||||||
|
// releases predating 6.3, otherwise an error will be returned.
|
||||||
|
//
|
||||||
|
// For more information see pledge(2).
|
||||||
|
func Pledge(promises, execpromises string) error {
|
||||||
|
maj, min, err := majmin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil)
|
|
||||||
if paths != nil {
|
// If OpenBSD <= 5.9, pledge is not available.
|
||||||
var pathsPtr []*byte
|
if (maj == 5 && min != 9) || maj < 5 {
|
||||||
if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil {
|
return fmt.Errorf("pledge syscall is not available on OpenBSD %d.%d", maj, min)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If OpenBSD <= 6.2 and execpromises is not empty
|
||||||
|
// return an error - execpromises is not available before 6.3
|
||||||
|
if (maj < 6 || (maj == 6 && min <= 2)) && execpromises != "" {
|
||||||
|
return fmt.Errorf("cannot use execpromises on OpenBSD %d.%d", maj, min)
|
||||||
|
}
|
||||||
|
|
||||||
|
pptr, err := syscall.BytePtrFromString(promises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// This variable will hold either a nil unsafe.Pointer or
|
||||||
|
// an unsafe.Pointer to a string (execpromises).
|
||||||
|
var expr unsafe.Pointer
|
||||||
|
|
||||||
|
// If we're running on OpenBSD > 6.2, pass execpromises to the syscall.
|
||||||
|
if maj > 6 || (maj == 6 && min > 2) {
|
||||||
|
exptr, err := syscall.BytePtrFromString(execpromises)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pathsUnsafe = unsafe.Pointer(&pathsPtr[0])
|
expr = unsafe.Pointer(exptr)
|
||||||
}
|
}
|
||||||
_, _, e := syscall.Syscall(_SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0)
|
|
||||||
|
_, _, e := syscall.Syscall(_SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0)
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// majmin returns major and minor version number for an OpenBSD system.
|
||||||
|
func majmin() (major int, minor int, err error) {
|
||||||
|
var v Utsname
|
||||||
|
err = Uname(&v)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
major, err = strconv.Atoi(string(v.Release[0]))
|
||||||
|
if err != nil {
|
||||||
|
err = errors.New("cannot parse major version number returned by uname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
minor, err = strconv.Atoi(string(v.Release[2]))
|
||||||
|
if err != nil {
|
||||||
|
err = errors.New("cannot parse minor version number returned by uname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// For Unix, get the pagesize from the runtime.
|
// For Unix, get the pagesize from the runtime.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
|
// +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// Socket control messages
|
// Socket control messages
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// Package unix contains an interface to the low-level operating system
|
// Package unix contains an interface to the low-level operating system
|
||||||
// primitives. OS details vary depending on the underlying system, and
|
// primitives. OS details vary depending on the underlying system, and
|
||||||
|
|||||||
+564
@@ -0,0 +1,564 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix
|
||||||
|
|
||||||
|
// Aix 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
|
func Utimes(path string, tv []Timeval) error {
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
|
||||||
|
func UtimesNano(path string, ts []Timespec) error {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if n == len(sa.raw.Path) && name[0] != '@' {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_UNIX
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
sa.raw.Path[i] = uint8(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
|
||||||
|
}
|
||||||
|
|
||||||
|
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(fd, &rsa)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getcwd(buf []byte) (err error)
|
||||||
|
|
||||||
|
const ImplementsGetwd = true
|
||||||
|
|
||||||
|
func Getwd() (ret string, err error) {
|
||||||
|
for len := uint64(4096); ; len *= 2 {
|
||||||
|
b := make([]byte, len)
|
||||||
|
err := getcwd(b)
|
||||||
|
if err == nil {
|
||||||
|
i := 0
|
||||||
|
for b[i] != 0 {
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return string(b[0:i]), nil
|
||||||
|
}
|
||||||
|
if err != ERANGE {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getcwd(buf []byte) (n int, err error) {
|
||||||
|
err = getcwd(buf)
|
||||||
|
if err == nil {
|
||||||
|
i := 0
|
||||||
|
for buf[i] != 0 {
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
n = i + 1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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])
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Socket
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
|
||||||
|
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(fd, &rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
|
||||||
|
// Recvmsg not implemented on AIX
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
return -1, -1, -1, sa, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
// SendmsgN not implemented on AIX
|
||||||
|
return -1, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
switch rsa.Addr.Family {
|
||||||
|
|
||||||
|
case AF_UNIX:
|
||||||
|
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
|
||||||
|
// Some versions of AIX have a bug in getsockname (see IV78655).
|
||||||
|
// We can't rely on sa.Len being set correctly.
|
||||||
|
n := SizeofSockaddrUnix - 3 // substract leading Family, Len, terminating NUL.
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if pp.Path[i] == 0 {
|
||||||
|
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 Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
err = gettimeofday(tv, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
return -1, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getdirent(fd int, buf []byte) (n int, err error)
|
||||||
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||||
|
return getdirent(fd, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
|
||||||
|
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||||
|
var status _C_int
|
||||||
|
var r Pid_t
|
||||||
|
err = ERESTART
|
||||||
|
// AIX wait4 may return with ERESTART errno, while the processus is still
|
||||||
|
// active.
|
||||||
|
for err == ERESTART {
|
||||||
|
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
||||||
|
}
|
||||||
|
wpid = int(r)
|
||||||
|
if wstatus != nil {
|
||||||
|
*wstatus = WaitStatus(status)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait
|
||||||
|
*/
|
||||||
|
|
||||||
|
type WaitStatus uint32
|
||||||
|
|
||||||
|
func (w WaitStatus) Stopped() bool { return w&0x40 != 0 }
|
||||||
|
func (w WaitStatus) StopSignal() syscall.Signal {
|
||||||
|
if !w.Stopped() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return syscall.Signal(w>>8) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Exited() bool { return w&0xFF == 0 }
|
||||||
|
func (w WaitStatus) ExitStatus() int {
|
||||||
|
if !w.Exited() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int((w >> 8) & 0xFF)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Signaled() bool { return w&0x40 == 0 && w&0xFF != 0 }
|
||||||
|
func (w WaitStatus) Signal() syscall.Signal {
|
||||||
|
if !w.Signaled() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return syscall.Signal(w>>16) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) CoreDump() bool { return w&0x200 != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) TrapCause() int { return -1 }
|
||||||
|
|
||||||
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
|
// functions for specific types are permissible.
|
||||||
|
|
||||||
|
// IoctlSetInt performs an ioctl operation which sets an integer value
|
||||||
|
// on fd, using the specified request number.
|
||||||
|
func IoctlSetInt(fd int, req uint, value int) error {
|
||||||
|
return ioctl(fd, req, uintptr(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetInt performs an ioctl operation which gets an integer value
|
||||||
|
// from fd, using the specified request number.
|
||||||
|
func IoctlGetInt(fd int, req uint) (int, error) {
|
||||||
|
var value int
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
||||||
|
var value Winsize
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
|
||||||
|
var value Termios
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
|
||||||
|
// There is no way to create a custom fcntl and to keep //sys fcntl easily,
|
||||||
|
// Therefore, the programmer must call dup2 instead of fcntl in this case.
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
//sys FcntlInt(fd uintptr, cmd int, arg int) (r int,err error) = fcntl
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
//sys FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) = fcntl
|
||||||
|
|
||||||
|
func Flock(fd int, how int) (err error) {
|
||||||
|
return syscall.Flock(fd, how)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Direct access
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys Acct(path string) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chroot(path string) (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)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//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 Fsync(fd int) (err error)
|
||||||
|
// readdir_r
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
|
||||||
|
//sys Getpgrp() (pid int)
|
||||||
|
|
||||||
|
//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 Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Kill(pid int, sig syscall.Signal) (err error)
|
||||||
|
//sys Klogctl(typ int, buf []byte) (n int, err error) = syslog
|
||||||
|
//sys Mkdir(dirfd int, 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 Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error) = open64
|
||||||
|
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Removexattr(path string, attr string) (err error)
|
||||||
|
//sys 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 Setuid(uid int) (err error)
|
||||||
|
//sys Setgid(uid int) (err error)
|
||||||
|
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error)
|
||||||
|
//sys Sync()
|
||||||
|
//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
|
||||||
|
//sysnb Times(tms *Tms) (ticks uintptr, err error)
|
||||||
|
//sysnb Umask(mask int) (oldmask int)
|
||||||
|
//sysnb Uname(buf *Utsname) (err error)
|
||||||
|
//TODO umount
|
||||||
|
// //sys Unmount(target string, flags int) (err error) = umount
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
||||||
|
//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 readlen(fd int, p *byte, np int) (n int, err error) = read
|
||||||
|
//sys writelen(fd int, p *byte, np int) (n int, err error) = write
|
||||||
|
|
||||||
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = fstatat
|
||||||
|
//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 Getuid() (uid int)
|
||||||
|
//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) = pread64
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64
|
||||||
|
//TODO Select
|
||||||
|
// //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
|
||||||
|
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (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 Truncate(path string, length int64) (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 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 Mlockall(flags int) (err error)
|
||||||
|
//sys Msync(b []byte, flags int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
|
||||||
|
//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)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys gettimeofday(tv *Timeval, tzp *Timezone) (err error)
|
||||||
|
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix
|
||||||
|
// +build ppc
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64
|
||||||
|
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2018 The Go 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 aix
|
||||||
|
// +build ppc64
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
|
||||||
|
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int64(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
+28
-8
@@ -199,7 +199,13 @@ func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
|
|||||||
return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
|
return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
|
//sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
|
||||||
|
|
||||||
|
func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
|
||||||
|
return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
|
||||||
|
|
||||||
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||||
// The parameters for the OS X implementation vary slightly compared to the
|
// The parameters for the OS X implementation vary slightly compared to the
|
||||||
@@ -235,7 +241,13 @@ func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
|
|||||||
return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
|
return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys removexattr(path string, attr string, options int) (err error)
|
//sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
|
||||||
|
|
||||||
|
func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
|
||||||
|
return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys removexattr(path string, attr string, options int) (err error)
|
||||||
|
|
||||||
func Removexattr(path string, attr string) (err error) {
|
func Removexattr(path string, attr string) (err error) {
|
||||||
// We wrap around and explicitly zero out the options provided to the OS X
|
// We wrap around and explicitly zero out the options provided to the OS X
|
||||||
@@ -248,6 +260,12 @@ func Lremovexattr(link string, attr string) (err error) {
|
|||||||
return removexattr(link, attr, XATTR_NOFOLLOW)
|
return removexattr(link, attr, XATTR_NOFOLLOW)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys fremovexattr(fd int, attr string, options int) (err error)
|
||||||
|
|
||||||
|
func Fremovexattr(fd int, attr string) (err error) {
|
||||||
|
return fremovexattr(fd, attr, 0)
|
||||||
|
}
|
||||||
|
|
||||||
//sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
|
//sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
|
||||||
|
|
||||||
func Listxattr(path string, dest []byte) (sz int, err error) {
|
func Listxattr(path string, dest []byte) (sz int, err error) {
|
||||||
@@ -258,6 +276,12 @@ func Llistxattr(link string, dest []byte) (sz int, err error) {
|
|||||||
return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
|
return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
|
||||||
|
|
||||||
|
func Flistxattr(fd int, dest []byte) (sz int, err error) {
|
||||||
|
return flistxattr(fd, xattrPointer(dest), len(dest), 0)
|
||||||
|
}
|
||||||
|
|
||||||
func setattrlistTimes(path string, times []Timespec, flags int) error {
|
func setattrlistTimes(path string, times []Timespec, flags int) error {
|
||||||
_p0, err := BytePtrFromString(path)
|
_p0, err := BytePtrFromString(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -313,11 +337,11 @@ func IoctlSetInt(fd int, req uint, value int) error {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,10 +553,6 @@ func Uname(uname *Utsname) error {
|
|||||||
// Watchevent
|
// Watchevent
|
||||||
// Waitevent
|
// Waitevent
|
||||||
// Modwatch
|
// Modwatch
|
||||||
// Fgetxattr
|
|
||||||
// Fsetxattr
|
|
||||||
// Fremovexattr
|
|
||||||
// Flistxattr
|
|
||||||
// Fsctl
|
// Fsctl
|
||||||
// Initgroups
|
// Initgroups
|
||||||
// Posix_spawn
|
// Posix_spawn
|
||||||
|
|||||||
+2
-2
@@ -143,11 +143,11 @@ func IoctlSetInt(fd int, req uint, value int) error {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-234
@@ -13,7 +13,6 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -58,14 +57,21 @@ func nametomib(name string) (mib []_C_int, err error) {
|
|||||||
return buf[0 : n/siz], nil
|
return buf[0 : n/siz], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//sysnb pipe() (r int, w int, err error)
|
|
||||||
|
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
|
return Pipe2(p, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) error {
|
||||||
if len(p) != 2 {
|
if len(p) != 2 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
}
|
}
|
||||||
p[0], p[1], err = pipe()
|
var pp [2]_C_int
|
||||||
return
|
err := pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
||||||
@@ -134,225 +140,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
|
|||||||
return ENOSYS
|
return ENOSYS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Derive extattr namespace and attribute name
|
|
||||||
|
|
||||||
func xattrnamespace(fullattr string) (ns int, attr string, err error) {
|
|
||||||
s := strings.IndexByte(fullattr, '.')
|
|
||||||
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
|
|
||||||
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 {
|
|
||||||
continue
|
|
||||||
} else if e != nil {
|
|
||||||
return s, e
|
|
||||||
}
|
|
||||||
|
|
||||||
s += stmp
|
|
||||||
destsiz -= s
|
|
||||||
if destsiz < 0 {
|
|
||||||
destsiz = 0
|
|
||||||
}
|
|
||||||
d = initxattrdest(dest, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return s, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Flistxattr(fd int, dest []byte) (sz int, err error) {
|
|
||||||
d := initxattrdest(dest, 0)
|
|
||||||
destsiz := len(dest)
|
|
||||||
|
|
||||||
s := 0
|
|
||||||
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 {
|
|
||||||
continue
|
|
||||||
} else if e != nil {
|
|
||||||
return s, e
|
|
||||||
}
|
|
||||||
|
|
||||||
s += stmp
|
|
||||||
destsiz -= s
|
|
||||||
if destsiz < 0 {
|
|
||||||
destsiz = 0
|
|
||||||
}
|
|
||||||
d = initxattrdest(dest, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return s, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Llistxattr(link string, dest []byte) (sz int, err error) {
|
|
||||||
d := initxattrdest(dest, 0)
|
|
||||||
destsiz := len(dest)
|
|
||||||
|
|
||||||
s := 0
|
|
||||||
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 {
|
|
||||||
continue
|
|
||||||
} else if e != nil {
|
|
||||||
return s, e
|
|
||||||
}
|
|
||||||
|
|
||||||
s += stmp
|
|
||||||
destsiz -= s
|
|
||||||
if destsiz < 0 {
|
|
||||||
destsiz = 0
|
|
||||||
}
|
|
||||||
d = initxattrdest(dest, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return s, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
// ioctl itself should not be exposed directly, but additional get/set
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
@@ -364,11 +151,11 @@ func IoctlSetInt(fd int, req uint, value int) error {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,14 +389,6 @@ func Uname(uname *Utsname) error {
|
|||||||
// Watchevent
|
// Watchevent
|
||||||
// Waitevent
|
// Waitevent
|
||||||
// Modwatch
|
// Modwatch
|
||||||
// Getxattr
|
|
||||||
// Fgetxattr
|
|
||||||
// Setxattr
|
|
||||||
// Fsetxattr
|
|
||||||
// Removexattr
|
|
||||||
// Fremovexattr
|
|
||||||
// Listxattr
|
|
||||||
// Flistxattr
|
|
||||||
// Fsctl
|
// Fsctl
|
||||||
// Initgroups
|
// Initgroups
|
||||||
// Posix_spawn
|
// Posix_spawn
|
||||||
|
|||||||
+98
-9
@@ -61,11 +61,11 @@ func IoctlSetInt(fd int, req uint, value int) error {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,6 +692,24 @@ func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SockaddrXDP struct {
|
||||||
|
Flags uint16
|
||||||
|
Ifindex uint32
|
||||||
|
QueueID uint32
|
||||||
|
SharedUmemFD uint32
|
||||||
|
raw RawSockaddrXDP
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrXDP) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
sa.raw.Family = AF_XDP
|
||||||
|
sa.raw.Flags = sa.Flags
|
||||||
|
sa.raw.Ifindex = sa.Ifindex
|
||||||
|
sa.raw.Queue_id = sa.QueueID
|
||||||
|
sa.raw.Shared_umem_fd = sa.SharedUmemFD
|
||||||
|
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrXDP, nil
|
||||||
|
}
|
||||||
|
|
||||||
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
switch rsa.Addr.Family {
|
switch rsa.Addr.Family {
|
||||||
case AF_NETLINK:
|
case AF_NETLINK:
|
||||||
@@ -793,6 +811,15 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||||||
}
|
}
|
||||||
return sa, nil
|
return sa, nil
|
||||||
}
|
}
|
||||||
|
case AF_XDP:
|
||||||
|
pp := (*RawSockaddrXDP)(unsafe.Pointer(rsa))
|
||||||
|
sa := &SockaddrXDP{
|
||||||
|
Flags: pp.Flags,
|
||||||
|
Ifindex: pp.Ifindex,
|
||||||
|
QueueID: pp.Queue_id,
|
||||||
|
SharedUmemFD: pp.Shared_umem_fd,
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
}
|
}
|
||||||
return nil, EAFNOSUPPORT
|
return nil, EAFNOSUPPORT
|
||||||
}
|
}
|
||||||
@@ -1288,7 +1315,11 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
|
|||||||
//sys Fchownat(dirfd int, path string, uid int, gid int, 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 fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
//sys Fdatasync(fd int) (err error)
|
//sys Fdatasync(fd int) (err error)
|
||||||
|
//sys Fgetxattr(fd int, attr string, dest []byte) (sz int, err error)
|
||||||
|
//sys Flistxattr(fd int, dest []byte) (sz int, err error)
|
||||||
//sys Flock(fd int, how int) (err error)
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fremovexattr(fd int, attr string) (err error)
|
||||||
|
//sys Fsetxattr(fd int, attr string, dest []byte, flags int) (err error)
|
||||||
//sys Fsync(fd int) (err error)
|
//sys Fsync(fd int) (err error)
|
||||||
//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
|
//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
|
||||||
//sysnb Getpgid(pid int) (pgid int, err error)
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
@@ -1316,6 +1347,7 @@ func Getpgrp() (pid int) {
|
|||||||
//sys Llistxattr(path string, dest []byte) (sz int, err error)
|
//sys Llistxattr(path string, dest []byte) (sz int, err error)
|
||||||
//sys Lremovexattr(path string, attr string) (err error)
|
//sys Lremovexattr(path string, attr string) (err error)
|
||||||
//sys Lsetxattr(path string, attr string, data []byte, flags int) (err error)
|
//sys Lsetxattr(path string, attr string, data []byte, flags int) (err error)
|
||||||
|
//sys MemfdCreate(name string, flags int) (fd int, err error)
|
||||||
//sys Mkdirat(dirfd int, path string, mode uint32) (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 Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||||
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
@@ -1327,6 +1359,7 @@ func Getpgrp() (pid int) {
|
|||||||
//sys read(fd int, p []byte) (n int, err error)
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
//sys Removexattr(path string, attr string) (err error)
|
//sys Removexattr(path string, attr string) (err error)
|
||||||
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
||||||
|
//sys Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error)
|
||||||
//sys RequestKey(keyType string, description string, callback string, destRingid int) (id int, err error)
|
//sys RequestKey(keyType string, description string, callback string, destRingid int) (id int, err error)
|
||||||
//sys Setdomainname(p []byte) (err error)
|
//sys Setdomainname(p []byte) (err error)
|
||||||
//sys Sethostname(p []byte) (err error)
|
//sys Sethostname(p []byte) (err error)
|
||||||
@@ -1415,10 +1448,70 @@ func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
|
|||||||
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
|
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
|
||||||
if flags & ^(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 {
|
if flags & ^(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
} else if flags&(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 {
|
|
||||||
return EOPNOTSUPP
|
|
||||||
}
|
}
|
||||||
return faccessat(dirfd, path, mode)
|
|
||||||
|
// The Linux kernel faccessat system call does not take any flags.
|
||||||
|
// The glibc faccessat implements the flags itself; see
|
||||||
|
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/faccessat.c;hb=HEAD
|
||||||
|
// Because people naturally expect syscall.Faccessat to act
|
||||||
|
// like C faccessat, we do the same.
|
||||||
|
|
||||||
|
if flags == 0 {
|
||||||
|
return faccessat(dirfd, path, mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
var st Stat_t
|
||||||
|
if err := Fstatat(dirfd, path, &st, flags&AT_SYMLINK_NOFOLLOW); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mode &= 7
|
||||||
|
if mode == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var uid int
|
||||||
|
if flags&AT_EACCESS != 0 {
|
||||||
|
uid = Geteuid()
|
||||||
|
} else {
|
||||||
|
uid = Getuid()
|
||||||
|
}
|
||||||
|
|
||||||
|
if uid == 0 {
|
||||||
|
if mode&1 == 0 {
|
||||||
|
// Root can read and write any file.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if st.Mode&0111 != 0 {
|
||||||
|
// Root can execute any file that anybody can execute.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return EACCES
|
||||||
|
}
|
||||||
|
|
||||||
|
var fmode uint32
|
||||||
|
if uint32(uid) == st.Uid {
|
||||||
|
fmode = (st.Mode >> 6) & 7
|
||||||
|
} else {
|
||||||
|
var gid int
|
||||||
|
if flags&AT_EACCESS != 0 {
|
||||||
|
gid = Getegid()
|
||||||
|
} else {
|
||||||
|
gid = Getgid()
|
||||||
|
}
|
||||||
|
|
||||||
|
if uint32(gid) == st.Gid {
|
||||||
|
fmode = (st.Mode >> 3) & 7
|
||||||
|
} else {
|
||||||
|
fmode = st.Mode & 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if fmode&mode == mode {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return EACCES
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1440,11 +1533,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
|
|||||||
// EpollPwait
|
// EpollPwait
|
||||||
// EpollWaitOld
|
// EpollWaitOld
|
||||||
// Execve
|
// Execve
|
||||||
// Fgetxattr
|
|
||||||
// Flistxattr
|
|
||||||
// Fork
|
// Fork
|
||||||
// Fremovexattr
|
|
||||||
// Fsetxattr
|
|
||||||
// Futex
|
// Futex
|
||||||
// GetKernelSyms
|
// GetKernelSyms
|
||||||
// GetMempolicy
|
// GetMempolicy
|
||||||
|
|||||||
+3
-4
@@ -124,14 +124,13 @@ func Pipe2(p []int, flags int) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sysnb pipe() (p1 int, p2 int, err error)
|
||||||
|
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
if len(p) != 2 {
|
if len(p) != 2 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
}
|
}
|
||||||
var pp [2]_C_int
|
p[0], p[1], err = pipe()
|
||||||
err = pipe2(&pp, 0)
|
|
||||||
p[0] = int(pp[0])
|
|
||||||
p[1] = int(pp[1])
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-1
@@ -44,7 +44,6 @@ package unix
|
|||||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, 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 Stat(path string, stat *Stat_t) (err error)
|
||||||
//sys Statfs(path string, buf *Statfs_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 Truncate(path string, length int64) (err error)
|
||||||
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||||
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
@@ -129,3 +128,11 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
|
|||||||
}
|
}
|
||||||
return poll(&fds[0], len(fds), timeout)
|
return poll(&fds[0], len(fds), timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2
|
||||||
|
|
||||||
|
func SyncFileRange(fd int, off int64, n int64, flags int) error {
|
||||||
|
// The sync_file_range and sync_file_range2 syscalls differ only in the
|
||||||
|
// order of their arguments.
|
||||||
|
return syncFileRange2(fd, flags, off, n)
|
||||||
|
}
|
||||||
+212
@@ -0,0 +1,212 @@
|
|||||||
|
// Copyright 2018 The Go 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 riscv64,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
func EpollCreate(size int) (fd int, err error) {
|
||||||
|
if size <= 0 {
|
||||||
|
return -1, EINVAL
|
||||||
|
}
|
||||||
|
return EpollCreate1(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
|
||||||
|
//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 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
|
||||||
|
|
||||||
|
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
|
||||||
|
var ts *Timespec
|
||||||
|
if timeout != nil {
|
||||||
|
ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
|
||||||
|
}
|
||||||
|
return Pselect(nfd, r, w, e, ts, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
//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)
|
||||||
|
|
||||||
|
func Ustat(dev int, ubuf *Ustat_t) (err error) {
|
||||||
|
return ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
//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)
|
||||||
|
|
||||||
|
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: sec, Usec: usec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
|
||||||
|
if tv == nil {
|
||||||
|
return utimensat(dirfd, path, nil, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := []Timespec{
|
||||||
|
NsecToTimespec(TimevalToNsec(tv[0])),
|
||||||
|
NsecToTimespec(TimevalToNsec(tv[1])),
|
||||||
|
}
|
||||||
|
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 utimes(path string, tv *[2]Timeval) (err error) {
|
||||||
|
if tv == nil {
|
||||||
|
return utimensat(AT_FDCWD, path, nil, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := []Timespec{
|
||||||
|
NsecToTimespec(TimevalToNsec(tv[0])),
|
||||||
|
NsecToTimespec(TimevalToNsec(tv[1])),
|
||||||
|
}
|
||||||
|
return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, 0)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PtraceRegs) PC() uint64 { return r.Pc }
|
||||||
|
|
||||||
|
func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InotifyInit() (fd int, err error) {
|
||||||
|
return InotifyInit1(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Dup2(oldfd int, newfd int) (err error) {
|
||||||
|
return Dup3(oldfd, newfd, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pause() (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
+14
-2
@@ -145,11 +145,11 @@ func IoctlSetInt(fd int, req uint, value int) error {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +233,18 @@ func Uname(uname *Utsname) error {
|
|||||||
//sys Dup(fd int) (nfd int, err error)
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
//sys Dup2(from int, to int) (err error)
|
//sys Dup2(from int, to int) (err error)
|
||||||
//sys Exit(code int)
|
//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 Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
|
||||||
//sys Fchdir(fd int) (err error)
|
//sys Fchdir(fd int) (err error)
|
||||||
|
|||||||
+2
-2
@@ -113,11 +113,11 @@ func IoctlSetInt(fd int, req uint, value int) error {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -540,11 +540,11 @@ func IoctlSetInt(fd int, req uint, value int) (err error) {
|
|||||||
return ioctl(fd, req, uintptr(value))
|
return ioctl(fd, req, uintptr(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) (err error) {
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) (err error) {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) (err error) {
|
func ioctlSetTermios(fd int, req uint, value *Termios) (err error) {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
|||||||
+236
@@ -0,0 +1,236 @@
|
|||||||
|
// Copyright 2018 The Go 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
|
||||||
|
// +build aix
|
||||||
|
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/limits.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <utime.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statfs.h>
|
||||||
|
#include <sys/termio.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/icmp6.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
type off64 C.off64_t
|
||||||
|
type off C.off_t
|
||||||
|
type Mode_t C.mode_t
|
||||||
|
|
||||||
|
// Time
|
||||||
|
|
||||||
|
type Timespec C.struct_timespec
|
||||||
|
|
||||||
|
type StTimespec C.struct_st_timespec
|
||||||
|
|
||||||
|
type Timeval C.struct_timeval
|
||||||
|
|
||||||
|
type Timeval32 C.struct_timeval32
|
||||||
|
|
||||||
|
type Timex C.struct_timex
|
||||||
|
|
||||||
|
type Time_t C.time_t
|
||||||
|
|
||||||
|
type Tms C.struct_tms
|
||||||
|
|
||||||
|
type Utimbuf C.struct_utimbuf
|
||||||
|
|
||||||
|
type Timezone C.struct_timezone
|
||||||
|
|
||||||
|
// Processes
|
||||||
|
|
||||||
|
type Rusage C.struct_rusage
|
||||||
|
|
||||||
|
type Rlimit C.struct_rlimit64
|
||||||
|
|
||||||
|
type Pid_t C.pid_t
|
||||||
|
|
||||||
|
type _Gid_t C.gid_t
|
||||||
|
|
||||||
|
type dev_t C.dev_t
|
||||||
|
|
||||||
|
// Files
|
||||||
|
|
||||||
|
type Stat_t C.struct_stat
|
||||||
|
|
||||||
|
type StatxTimestamp C.struct_statx_timestamp
|
||||||
|
|
||||||
|
type Statx_t C.struct_statx
|
||||||
|
|
||||||
|
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 RawSockaddr C.struct_sockaddr
|
||||||
|
|
||||||
|
type RawSockaddrAny C.struct_sockaddr_any
|
||||||
|
|
||||||
|
type _Socklen C.socklen_t
|
||||||
|
|
||||||
|
type Cmsghdr C.struct_cmsghdr
|
||||||
|
|
||||||
|
type ICMPv6Filter C.struct_icmp6_filter
|
||||||
|
|
||||||
|
type Iovec C.struct_iovec
|
||||||
|
|
||||||
|
type IPMreq C.struct_ip_mreq
|
||||||
|
|
||||||
|
type IPv6Mreq C.struct_ipv6_mreq
|
||||||
|
|
||||||
|
type IPv6MTUInfo C.struct_ip6_mtuinfo
|
||||||
|
|
||||||
|
type Linger C.struct_linger
|
||||||
|
|
||||||
|
type Msghdr C.struct_msghdr
|
||||||
|
|
||||||
|
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
|
||||||
|
SizeofLinger = C.sizeof_struct_linger
|
||||||
|
SizeofIPMreq = C.sizeof_struct_ip_mreq
|
||||||
|
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
|
||||||
|
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
||||||
|
SizeofMsghdr = C.sizeof_struct_msghdr
|
||||||
|
SizeofCmsghdr = C.sizeof_struct_cmsghdr
|
||||||
|
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
||||||
|
)
|
||||||
|
|
||||||
|
// Routing and interface messages
|
||||||
|
|
||||||
|
const (
|
||||||
|
SizeofIfMsghdr = C.sizeof_struct_if_msghdr
|
||||||
|
)
|
||||||
|
|
||||||
|
type IfMsgHdr C.struct_if_msghdr
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
|
||||||
|
type FdSet C.fd_set
|
||||||
|
|
||||||
|
type Utsname C.struct_utsname
|
||||||
|
|
||||||
|
type Ustat_t C.struct_ustat
|
||||||
|
|
||||||
|
type Sigset_t C.sigset_t
|
||||||
|
|
||||||
|
const (
|
||||||
|
AT_FDCWD = C.AT_FDCWD
|
||||||
|
AT_REMOVEDIR = C.AT_REMOVEDIR
|
||||||
|
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
|
||||||
|
)
|
||||||
|
|
||||||
|
// Terminal handling
|
||||||
|
|
||||||
|
type Termios C.struct_termios
|
||||||
|
|
||||||
|
type Termio C.struct_termio
|
||||||
|
|
||||||
|
type Winsize C.struct_winsize
|
||||||
|
|
||||||
|
//poll
|
||||||
|
|
||||||
|
type PollFd struct {
|
||||||
|
Fd int32
|
||||||
|
Events uint16
|
||||||
|
Revents uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
POLLERR = C.POLLERR
|
||||||
|
POLLHUP = C.POLLHUP
|
||||||
|
POLLIN = C.POLLIN
|
||||||
|
POLLNVAL = C.POLLNVAL
|
||||||
|
POLLOUT = C.POLLOUT
|
||||||
|
POLLPRI = C.POLLPRI
|
||||||
|
POLLRDBAND = C.POLLRDBAND
|
||||||
|
POLLRDNORM = C.POLLRDNORM
|
||||||
|
POLLWRBAND = C.POLLWRBAND
|
||||||
|
POLLWRNORM = C.POLLWRNORM
|
||||||
|
)
|
||||||
|
|
||||||
|
//flock_t
|
||||||
|
|
||||||
|
type Flock_t C.struct_flock64
|
||||||
|
|
||||||
|
// Statfs
|
||||||
|
|
||||||
|
type Fsid_t C.struct_fsid_t
|
||||||
|
type Fsid64_t C.struct_fsid64_t
|
||||||
|
|
||||||
|
type Statfs_t C.struct_statfs
|
||||||
|
|
||||||
|
const RNDGETENTCNT = 0x80045200
|
||||||
-17
@@ -100,23 +100,6 @@ type _Gid_t C.gid_t
|
|||||||
|
|
||||||
// Files
|
// 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 Stat_t C.struct_stat
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
type Statfs_t C.struct_statfs
|
||||||
|
|||||||
-17
@@ -189,23 +189,6 @@ type _Gid_t C.gid_t
|
|||||||
|
|
||||||
// Files
|
// 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 Stat_t C.struct_stat8
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
type Statfs_t C.struct_statfs
|
||||||
|
|||||||
-17
@@ -101,23 +101,6 @@ type _Gid_t C.gid_t
|
|||||||
|
|
||||||
// Files
|
// 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 Stat_t C.struct_stat
|
||||||
|
|
||||||
type Statfs_t C.struct_statfs
|
type Statfs_t C.struct_statfs
|
||||||
|
|||||||
-17
@@ -118,23 +118,6 @@ type _Gid_t C.gid_t
|
|||||||
|
|
||||||
// Files
|
// 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 Stat_t C.struct_stat
|
||||||
|
|
||||||
type Flock_t C.struct_flock
|
type Flock_t C.struct_flock
|
||||||
|
|||||||
+231
@@ -0,0 +1,231 @@
|
|||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build freebsd netbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Derive extattr namespace and attribute name
|
||||||
|
|
||||||
|
func xattrnamespace(fullattr string) (ns int, attr string, err error) {
|
||||||
|
s := strings.IndexByte(fullattr, '.')
|
||||||
|
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 and NetBSD implement their 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
|
||||||
|
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 {
|
||||||
|
continue
|
||||||
|
} else if e != nil {
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
s += stmp
|
||||||
|
destsiz -= s
|
||||||
|
if destsiz < 0 {
|
||||||
|
destsiz = 0
|
||||||
|
}
|
||||||
|
d = initxattrdest(dest, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Flistxattr(fd int, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsiz := len(dest)
|
||||||
|
|
||||||
|
s := 0
|
||||||
|
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 {
|
||||||
|
continue
|
||||||
|
} else if e != nil {
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
s += stmp
|
||||||
|
destsiz -= s
|
||||||
|
if destsiz < 0 {
|
||||||
|
destsiz = 0
|
||||||
|
}
|
||||||
|
d = initxattrdest(dest, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Llistxattr(link string, dest []byte) (sz int, err error) {
|
||||||
|
d := initxattrdest(dest, 0)
|
||||||
|
destsiz := len(dest)
|
||||||
|
|
||||||
|
s := 0
|
||||||
|
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 {
|
||||||
|
continue
|
||||||
|
} else if e != nil {
|
||||||
|
return s, e
|
||||||
|
}
|
||||||
|
|
||||||
|
s += stmp
|
||||||
|
destsiz -= s
|
||||||
|
if destsiz < 0 {
|
||||||
|
destsiz = 0
|
||||||
|
}
|
||||||
|
d = initxattrdest(dest, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
+1372
File diff suppressed because it is too large.
Load diff
+1373
File diff suppressed because it is too large.
Load diff
+65
-1
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
// +build amd64,dragonfly
|
// +build amd64,dragonfly
|
||||||
|
|
||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs -- -m64 _const.go
|
// cgo -godefs -- -m64 _const.go
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
@@ -880,6 +880,40 @@ const (
|
|||||||
MAP_VPAGETABLE = 0x2000
|
MAP_VPAGETABLE = 0x2000
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
|
MNT_ASYNC = 0x40
|
||||||
|
MNT_AUTOMOUNTED = 0x20
|
||||||
|
MNT_CMDFLAGS = 0xf0000
|
||||||
|
MNT_DEFEXPORTED = 0x200
|
||||||
|
MNT_DELEXPORT = 0x20000
|
||||||
|
MNT_EXKERB = 0x800
|
||||||
|
MNT_EXPORTANON = 0x400
|
||||||
|
MNT_EXPORTED = 0x100
|
||||||
|
MNT_EXPUBLIC = 0x20000000
|
||||||
|
MNT_EXRDONLY = 0x80
|
||||||
|
MNT_FORCE = 0x80000
|
||||||
|
MNT_IGNORE = 0x800000
|
||||||
|
MNT_LAZY = 0x4
|
||||||
|
MNT_LOCAL = 0x1000
|
||||||
|
MNT_NOATIME = 0x10000000
|
||||||
|
MNT_NOCLUSTERR = 0x40000000
|
||||||
|
MNT_NOCLUSTERW = 0x80000000
|
||||||
|
MNT_NODEV = 0x10
|
||||||
|
MNT_NOEXEC = 0x4
|
||||||
|
MNT_NOSUID = 0x8
|
||||||
|
MNT_NOSYMFOLLOW = 0x400000
|
||||||
|
MNT_NOWAIT = 0x2
|
||||||
|
MNT_QUOTA = 0x2000
|
||||||
|
MNT_RDONLY = 0x1
|
||||||
|
MNT_RELOAD = 0x40000
|
||||||
|
MNT_ROOTFS = 0x4000
|
||||||
|
MNT_SOFTDEP = 0x200000
|
||||||
|
MNT_SUIDDIR = 0x100000
|
||||||
|
MNT_SYNCHRONOUS = 0x2
|
||||||
|
MNT_TRIM = 0x1000000
|
||||||
|
MNT_UPDATE = 0x10000
|
||||||
|
MNT_USER = 0x8000
|
||||||
|
MNT_VISFLAGMASK = 0xf1f0ffff
|
||||||
|
MNT_WAIT = 0x1
|
||||||
MSG_CMSG_CLOEXEC = 0x1000
|
MSG_CMSG_CLOEXEC = 0x1000
|
||||||
MSG_CTRUNC = 0x20
|
MSG_CTRUNC = 0x20
|
||||||
MSG_DONTROUTE = 0x4
|
MSG_DONTROUTE = 0x4
|
||||||
@@ -1168,6 +1202,36 @@ const (
|
|||||||
SO_TIMESTAMP = 0x400
|
SO_TIMESTAMP = 0x400
|
||||||
SO_TYPE = 0x1008
|
SO_TYPE = 0x1008
|
||||||
SO_USELOOPBACK = 0x40
|
SO_USELOOPBACK = 0x40
|
||||||
|
S_BLKSIZE = 0x200
|
||||||
|
S_IEXEC = 0x40
|
||||||
|
S_IFBLK = 0x6000
|
||||||
|
S_IFCHR = 0x2000
|
||||||
|
S_IFDB = 0x9000
|
||||||
|
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
|
TCIFLUSH = 0x1
|
||||||
TCIOFF = 0x3
|
TCIOFF = 0x3
|
||||||
TCIOFLUSH = 0x3
|
TCIOFLUSH = 0x3
|
||||||
|
|||||||
+29
@@ -1345,6 +1345,35 @@ const (
|
|||||||
SO_USELOOPBACK = 0x40
|
SO_USELOOPBACK = 0x40
|
||||||
SO_USER_COOKIE = 0x1015
|
SO_USER_COOKIE = 0x1015
|
||||||
SO_VENDOR = 0x80000000
|
SO_VENDOR = 0x80000000
|
||||||
|
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
|
||||||
TAB0 = 0x0
|
TAB0 = 0x0
|
||||||
TAB3 = 0x4
|
TAB3 = 0x4
|
||||||
TABDLY = 0x4
|
TABDLY = 0x4
|
||||||
|
|||||||
+29
@@ -1346,6 +1346,35 @@ const (
|
|||||||
SO_USELOOPBACK = 0x40
|
SO_USELOOPBACK = 0x40
|
||||||
SO_USER_COOKIE = 0x1015
|
SO_USER_COOKIE = 0x1015
|
||||||
SO_VENDOR = 0x80000000
|
SO_VENDOR = 0x80000000
|
||||||
|
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
|
||||||
TAB0 = 0x0
|
TAB0 = 0x0
|
||||||
TAB3 = 0x4
|
TAB3 = 0x4
|
||||||
TABDLY = 0x4
|
TABDLY = 0x4
|
||||||
|
|||||||
+29
@@ -1354,6 +1354,35 @@ const (
|
|||||||
SO_USELOOPBACK = 0x40
|
SO_USELOOPBACK = 0x40
|
||||||
SO_USER_COOKIE = 0x1015
|
SO_USER_COOKIE = 0x1015
|
||||||
SO_VENDOR = 0x80000000
|
SO_VENDOR = 0x80000000
|
||||||
|
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
|
||||||
TAB0 = 0x0
|
TAB0 = 0x0
|
||||||
TAB3 = 0x4
|
TAB3 = 0x4
|
||||||
TABDLY = 0x4
|
TABDLY = 0x4
|
||||||
|
|||||||
+75
-2
@@ -64,6 +64,7 @@ const (
|
|||||||
AF_VSOCK = 0x28
|
AF_VSOCK = 0x28
|
||||||
AF_WANPIPE = 0x19
|
AF_WANPIPE = 0x19
|
||||||
AF_X25 = 0x9
|
AF_X25 = 0x9
|
||||||
|
AF_XDP = 0x2c
|
||||||
ALG_OP_DECRYPT = 0x0
|
ALG_OP_DECRYPT = 0x0
|
||||||
ALG_OP_ENCRYPT = 0x1
|
ALG_OP_ENCRYPT = 0x1
|
||||||
ALG_SET_AEAD_ASSOCLEN = 0x4
|
ALG_SET_AEAD_ASSOCLEN = 0x4
|
||||||
@@ -499,6 +500,8 @@ const (
|
|||||||
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
||||||
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
||||||
FS_ENCRYPTION_MODE_INVALID = 0x0
|
FS_ENCRYPTION_MODE_INVALID = 0x0
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
|
||||||
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
||||||
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
||||||
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
||||||
@@ -636,7 +639,7 @@ const (
|
|||||||
IFA_F_STABLE_PRIVACY = 0x800
|
IFA_F_STABLE_PRIVACY = 0x800
|
||||||
IFA_F_TEMPORARY = 0x1
|
IFA_F_TEMPORARY = 0x1
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_MAX = 0x8
|
IFA_MAX = 0x9
|
||||||
IFF_ALLMULTI = 0x200
|
IFF_ALLMULTI = 0x200
|
||||||
IFF_ATTACH_QUEUE = 0x200
|
IFF_ATTACH_QUEUE = 0x200
|
||||||
IFF_AUTOMEDIA = 0x4000
|
IFF_AUTOMEDIA = 0x4000
|
||||||
@@ -763,6 +766,7 @@ const (
|
|||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
IPV6_HOPOPTS = 0x36
|
IPV6_HOPOPTS = 0x36
|
||||||
@@ -956,6 +960,7 @@ const (
|
|||||||
MAP_EXECUTABLE = 0x1000
|
MAP_EXECUTABLE = 0x1000
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
MAP_GROWSDOWN = 0x100
|
MAP_GROWSDOWN = 0x100
|
||||||
MAP_HUGETLB = 0x40000
|
MAP_HUGETLB = 0x40000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
@@ -966,11 +971,28 @@ const (
|
|||||||
MAP_POPULATE = 0x8000
|
MAP_POPULATE = 0x8000
|
||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
|
MAP_SHARED_VALIDATE = 0x3
|
||||||
MAP_STACK = 0x20000
|
MAP_STACK = 0x20000
|
||||||
|
MAP_SYNC = 0x80000
|
||||||
MAP_TYPE = 0xf
|
MAP_TYPE = 0xf
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MCL_ONFAULT = 0x4
|
MCL_ONFAULT = 0x4
|
||||||
|
MFD_ALLOW_SEALING = 0x2
|
||||||
|
MFD_CLOEXEC = 0x1
|
||||||
|
MFD_HUGETLB = 0x4
|
||||||
|
MFD_HUGE_16GB = -0x78000000
|
||||||
|
MFD_HUGE_16MB = 0x60000000
|
||||||
|
MFD_HUGE_1GB = 0x78000000
|
||||||
|
MFD_HUGE_1MB = 0x50000000
|
||||||
|
MFD_HUGE_256MB = 0x70000000
|
||||||
|
MFD_HUGE_2GB = 0x7c000000
|
||||||
|
MFD_HUGE_2MB = 0x54000000
|
||||||
|
MFD_HUGE_512KB = 0x4c000000
|
||||||
|
MFD_HUGE_64KB = 0x40000000
|
||||||
|
MFD_HUGE_8MB = 0x5c000000
|
||||||
|
MFD_HUGE_MASK = 0x3f
|
||||||
|
MFD_HUGE_SHIFT = 0x1a
|
||||||
MINIX2_SUPER_MAGIC = 0x2468
|
MINIX2_SUPER_MAGIC = 0x2468
|
||||||
MINIX2_SUPER_MAGIC2 = 0x2478
|
MINIX2_SUPER_MAGIC2 = 0x2478
|
||||||
MINIX3_SUPER_MAGIC = 0x4d5a
|
MINIX3_SUPER_MAGIC = 0x4d5a
|
||||||
@@ -1076,6 +1098,8 @@ const (
|
|||||||
NETLINK_UNUSED = 0x1
|
NETLINK_UNUSED = 0x1
|
||||||
NETLINK_USERSOCK = 0x2
|
NETLINK_USERSOCK = 0x2
|
||||||
NETLINK_XFRM = 0x6
|
NETLINK_XFRM = 0x6
|
||||||
|
NETNSA_MAX = 0x3
|
||||||
|
NETNSA_NSID_NOT_ASSIGNED = -0x1
|
||||||
NFNETLINK_V0 = 0x0
|
NFNETLINK_V0 = 0x0
|
||||||
NFNLGRP_ACCT_QUOTA = 0x8
|
NFNLGRP_ACCT_QUOTA = 0x8
|
||||||
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
||||||
@@ -1427,6 +1451,9 @@ const (
|
|||||||
RAMFS_MAGIC = 0x858458f6
|
RAMFS_MAGIC = 0x858458f6
|
||||||
RDTGROUP_SUPER_MAGIC = 0x7655821
|
RDTGROUP_SUPER_MAGIC = 0x7655821
|
||||||
REISERFS_SUPER_MAGIC = 0x52654973
|
REISERFS_SUPER_MAGIC = 0x52654973
|
||||||
|
RENAME_EXCHANGE = 0x2
|
||||||
|
RENAME_NOREPLACE = 0x1
|
||||||
|
RENAME_WHITEOUT = 0x4
|
||||||
RLIMIT_AS = 0x9
|
RLIMIT_AS = 0x9
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
@@ -1469,7 +1496,7 @@ const (
|
|||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1a
|
RTA_MAX = 0x1d
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
@@ -1605,17 +1632,22 @@ const (
|
|||||||
RTNH_F_UNRESOLVED = 0x20
|
RTNH_F_UNRESOLVED = 0x20
|
||||||
RTN_MAX = 0xb
|
RTN_MAX = 0xb
|
||||||
RTPROT_BABEL = 0x2a
|
RTPROT_BABEL = 0x2a
|
||||||
|
RTPROT_BGP = 0xba
|
||||||
RTPROT_BIRD = 0xc
|
RTPROT_BIRD = 0xc
|
||||||
RTPROT_BOOT = 0x3
|
RTPROT_BOOT = 0x3
|
||||||
RTPROT_DHCP = 0x10
|
RTPROT_DHCP = 0x10
|
||||||
RTPROT_DNROUTED = 0xd
|
RTPROT_DNROUTED = 0xd
|
||||||
|
RTPROT_EIGRP = 0xc0
|
||||||
RTPROT_GATED = 0x8
|
RTPROT_GATED = 0x8
|
||||||
|
RTPROT_ISIS = 0xbb
|
||||||
RTPROT_KERNEL = 0x2
|
RTPROT_KERNEL = 0x2
|
||||||
RTPROT_MROUTED = 0x11
|
RTPROT_MROUTED = 0x11
|
||||||
RTPROT_MRT = 0xa
|
RTPROT_MRT = 0xa
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
|
RTPROT_OSPF = 0xbc
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
|
RTPROT_RIP = 0xbd
|
||||||
RTPROT_STATIC = 0x4
|
RTPROT_STATIC = 0x4
|
||||||
RTPROT_UNSPEC = 0x0
|
RTPROT_UNSPEC = 0x0
|
||||||
RTPROT_XORP = 0xe
|
RTPROT_XORP = 0xe
|
||||||
@@ -1780,6 +1812,7 @@ const (
|
|||||||
SOL_TIPC = 0x10f
|
SOL_TIPC = 0x10f
|
||||||
SOL_TLS = 0x11a
|
SOL_TLS = 0x11a
|
||||||
SOL_X25 = 0x106
|
SOL_X25 = 0x106
|
||||||
|
SOL_XDP = 0x11b
|
||||||
SOMAXCONN = 0x80
|
SOMAXCONN = 0x80
|
||||||
SO_ACCEPTCONN = 0x1e
|
SO_ACCEPTCONN = 0x1e
|
||||||
SO_ATTACH_BPF = 0x32
|
SO_ATTACH_BPF = 0x32
|
||||||
@@ -1875,6 +1908,9 @@ const (
|
|||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
SYNC_FILE_RANGE_WRITE = 0x2
|
||||||
SYSFS_MAGIC = 0x62656572
|
SYSFS_MAGIC = 0x62656572
|
||||||
S_BLKSIZE = 0x200
|
S_BLKSIZE = 0x200
|
||||||
S_IEXEC = 0x40
|
S_IEXEC = 0x40
|
||||||
@@ -1938,6 +1974,8 @@ const (
|
|||||||
TCP_DEFER_ACCEPT = 0x9
|
TCP_DEFER_ACCEPT = 0x9
|
||||||
TCP_FASTOPEN = 0x17
|
TCP_FASTOPEN = 0x17
|
||||||
TCP_FASTOPEN_CONNECT = 0x1e
|
TCP_FASTOPEN_CONNECT = 0x1e
|
||||||
|
TCP_FASTOPEN_KEY = 0x21
|
||||||
|
TCP_FASTOPEN_NO_COOKIE = 0x22
|
||||||
TCP_INFO = 0xb
|
TCP_INFO = 0xb
|
||||||
TCP_KEEPCNT = 0x6
|
TCP_KEEPCNT = 0x6
|
||||||
TCP_KEEPIDLE = 0x4
|
TCP_KEEPIDLE = 0x4
|
||||||
@@ -2105,6 +2143,21 @@ const (
|
|||||||
TUNSETVNETBE = 0x400454de
|
TUNSETVNETBE = 0x400454de
|
||||||
TUNSETVNETHDRSZ = 0x400454d8
|
TUNSETVNETHDRSZ = 0x400454d8
|
||||||
TUNSETVNETLE = 0x400454dc
|
TUNSETVNETLE = 0x400454dc
|
||||||
|
UBI_IOCATT = 0x40186f40
|
||||||
|
UBI_IOCDET = 0x40046f41
|
||||||
|
UBI_IOCEBCH = 0x40044f02
|
||||||
|
UBI_IOCEBER = 0x40044f01
|
||||||
|
UBI_IOCEBISMAP = 0x80044f05
|
||||||
|
UBI_IOCEBMAP = 0x40084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x40044f04
|
||||||
|
UBI_IOCMKVOL = 0x40986f00
|
||||||
|
UBI_IOCRMVOL = 0x40046f01
|
||||||
|
UBI_IOCRNVOL = 0x51106f03
|
||||||
|
UBI_IOCRSVOL = 0x400c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x40104f06
|
||||||
|
UBI_IOCVOLCRBLK = 0x40804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x4f08
|
||||||
|
UBI_IOCVOLUP = 0x40084f00
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
@@ -2242,6 +2295,26 @@ const (
|
|||||||
XATTR_CREATE = 0x1
|
XATTR_CREATE = 0x1
|
||||||
XATTR_REPLACE = 0x2
|
XATTR_REPLACE = 0x2
|
||||||
XCASE = 0x4
|
XCASE = 0x4
|
||||||
|
XDP_COPY = 0x2
|
||||||
|
XDP_FLAGS_DRV_MODE = 0x4
|
||||||
|
XDP_FLAGS_HW_MODE = 0x8
|
||||||
|
XDP_FLAGS_MASK = 0xf
|
||||||
|
XDP_FLAGS_MODES = 0xe
|
||||||
|
XDP_FLAGS_SKB_MODE = 0x2
|
||||||
|
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
|
||||||
|
XDP_MMAP_OFFSETS = 0x1
|
||||||
|
XDP_PGOFF_RX_RING = 0x0
|
||||||
|
XDP_PGOFF_TX_RING = 0x80000000
|
||||||
|
XDP_RX_RING = 0x2
|
||||||
|
XDP_SHARED_UMEM = 0x1
|
||||||
|
XDP_STATISTICS = 0x7
|
||||||
|
XDP_TX_RING = 0x3
|
||||||
|
XDP_UMEM_COMPLETION_RING = 0x6
|
||||||
|
XDP_UMEM_FILL_RING = 0x5
|
||||||
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_ZEROCOPY = 0x4
|
||||||
XENFS_SUPER_MAGIC = 0xabba1974
|
XENFS_SUPER_MAGIC = 0xabba1974
|
||||||
XTABS = 0x1800
|
XTABS = 0x1800
|
||||||
ZSMALLOC_MAGIC = 0x58295829
|
ZSMALLOC_MAGIC = 0x58295829
|
||||||
|
|||||||
+75
-2
@@ -64,6 +64,7 @@ const (
|
|||||||
AF_VSOCK = 0x28
|
AF_VSOCK = 0x28
|
||||||
AF_WANPIPE = 0x19
|
AF_WANPIPE = 0x19
|
||||||
AF_X25 = 0x9
|
AF_X25 = 0x9
|
||||||
|
AF_XDP = 0x2c
|
||||||
ALG_OP_DECRYPT = 0x0
|
ALG_OP_DECRYPT = 0x0
|
||||||
ALG_OP_ENCRYPT = 0x1
|
ALG_OP_ENCRYPT = 0x1
|
||||||
ALG_SET_AEAD_ASSOCLEN = 0x4
|
ALG_SET_AEAD_ASSOCLEN = 0x4
|
||||||
@@ -499,6 +500,8 @@ const (
|
|||||||
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
||||||
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
||||||
FS_ENCRYPTION_MODE_INVALID = 0x0
|
FS_ENCRYPTION_MODE_INVALID = 0x0
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
|
||||||
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
||||||
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
||||||
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
||||||
@@ -636,7 +639,7 @@ const (
|
|||||||
IFA_F_STABLE_PRIVACY = 0x800
|
IFA_F_STABLE_PRIVACY = 0x800
|
||||||
IFA_F_TEMPORARY = 0x1
|
IFA_F_TEMPORARY = 0x1
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_MAX = 0x8
|
IFA_MAX = 0x9
|
||||||
IFF_ALLMULTI = 0x200
|
IFF_ALLMULTI = 0x200
|
||||||
IFF_ATTACH_QUEUE = 0x200
|
IFF_ATTACH_QUEUE = 0x200
|
||||||
IFF_AUTOMEDIA = 0x4000
|
IFF_AUTOMEDIA = 0x4000
|
||||||
@@ -763,6 +766,7 @@ const (
|
|||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
IPV6_HOPOPTS = 0x36
|
IPV6_HOPOPTS = 0x36
|
||||||
@@ -956,6 +960,7 @@ const (
|
|||||||
MAP_EXECUTABLE = 0x1000
|
MAP_EXECUTABLE = 0x1000
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
MAP_GROWSDOWN = 0x100
|
MAP_GROWSDOWN = 0x100
|
||||||
MAP_HUGETLB = 0x40000
|
MAP_HUGETLB = 0x40000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
@@ -966,11 +971,28 @@ const (
|
|||||||
MAP_POPULATE = 0x8000
|
MAP_POPULATE = 0x8000
|
||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
|
MAP_SHARED_VALIDATE = 0x3
|
||||||
MAP_STACK = 0x20000
|
MAP_STACK = 0x20000
|
||||||
|
MAP_SYNC = 0x80000
|
||||||
MAP_TYPE = 0xf
|
MAP_TYPE = 0xf
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MCL_ONFAULT = 0x4
|
MCL_ONFAULT = 0x4
|
||||||
|
MFD_ALLOW_SEALING = 0x2
|
||||||
|
MFD_CLOEXEC = 0x1
|
||||||
|
MFD_HUGETLB = 0x4
|
||||||
|
MFD_HUGE_16GB = -0x78000000
|
||||||
|
MFD_HUGE_16MB = 0x60000000
|
||||||
|
MFD_HUGE_1GB = 0x78000000
|
||||||
|
MFD_HUGE_1MB = 0x50000000
|
||||||
|
MFD_HUGE_256MB = 0x70000000
|
||||||
|
MFD_HUGE_2GB = 0x7c000000
|
||||||
|
MFD_HUGE_2MB = 0x54000000
|
||||||
|
MFD_HUGE_512KB = 0x4c000000
|
||||||
|
MFD_HUGE_64KB = 0x40000000
|
||||||
|
MFD_HUGE_8MB = 0x5c000000
|
||||||
|
MFD_HUGE_MASK = 0x3f
|
||||||
|
MFD_HUGE_SHIFT = 0x1a
|
||||||
MINIX2_SUPER_MAGIC = 0x2468
|
MINIX2_SUPER_MAGIC = 0x2468
|
||||||
MINIX2_SUPER_MAGIC2 = 0x2478
|
MINIX2_SUPER_MAGIC2 = 0x2478
|
||||||
MINIX3_SUPER_MAGIC = 0x4d5a
|
MINIX3_SUPER_MAGIC = 0x4d5a
|
||||||
@@ -1076,6 +1098,8 @@ const (
|
|||||||
NETLINK_UNUSED = 0x1
|
NETLINK_UNUSED = 0x1
|
||||||
NETLINK_USERSOCK = 0x2
|
NETLINK_USERSOCK = 0x2
|
||||||
NETLINK_XFRM = 0x6
|
NETLINK_XFRM = 0x6
|
||||||
|
NETNSA_MAX = 0x3
|
||||||
|
NETNSA_NSID_NOT_ASSIGNED = -0x1
|
||||||
NFNETLINK_V0 = 0x0
|
NFNETLINK_V0 = 0x0
|
||||||
NFNLGRP_ACCT_QUOTA = 0x8
|
NFNLGRP_ACCT_QUOTA = 0x8
|
||||||
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
||||||
@@ -1428,6 +1452,9 @@ const (
|
|||||||
RAMFS_MAGIC = 0x858458f6
|
RAMFS_MAGIC = 0x858458f6
|
||||||
RDTGROUP_SUPER_MAGIC = 0x7655821
|
RDTGROUP_SUPER_MAGIC = 0x7655821
|
||||||
REISERFS_SUPER_MAGIC = 0x52654973
|
REISERFS_SUPER_MAGIC = 0x52654973
|
||||||
|
RENAME_EXCHANGE = 0x2
|
||||||
|
RENAME_NOREPLACE = 0x1
|
||||||
|
RENAME_WHITEOUT = 0x4
|
||||||
RLIMIT_AS = 0x9
|
RLIMIT_AS = 0x9
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
@@ -1470,7 +1497,7 @@ const (
|
|||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1a
|
RTA_MAX = 0x1d
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
@@ -1606,17 +1633,22 @@ const (
|
|||||||
RTNH_F_UNRESOLVED = 0x20
|
RTNH_F_UNRESOLVED = 0x20
|
||||||
RTN_MAX = 0xb
|
RTN_MAX = 0xb
|
||||||
RTPROT_BABEL = 0x2a
|
RTPROT_BABEL = 0x2a
|
||||||
|
RTPROT_BGP = 0xba
|
||||||
RTPROT_BIRD = 0xc
|
RTPROT_BIRD = 0xc
|
||||||
RTPROT_BOOT = 0x3
|
RTPROT_BOOT = 0x3
|
||||||
RTPROT_DHCP = 0x10
|
RTPROT_DHCP = 0x10
|
||||||
RTPROT_DNROUTED = 0xd
|
RTPROT_DNROUTED = 0xd
|
||||||
|
RTPROT_EIGRP = 0xc0
|
||||||
RTPROT_GATED = 0x8
|
RTPROT_GATED = 0x8
|
||||||
|
RTPROT_ISIS = 0xbb
|
||||||
RTPROT_KERNEL = 0x2
|
RTPROT_KERNEL = 0x2
|
||||||
RTPROT_MROUTED = 0x11
|
RTPROT_MROUTED = 0x11
|
||||||
RTPROT_MRT = 0xa
|
RTPROT_MRT = 0xa
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
|
RTPROT_OSPF = 0xbc
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
|
RTPROT_RIP = 0xbd
|
||||||
RTPROT_STATIC = 0x4
|
RTPROT_STATIC = 0x4
|
||||||
RTPROT_UNSPEC = 0x0
|
RTPROT_UNSPEC = 0x0
|
||||||
RTPROT_XORP = 0xe
|
RTPROT_XORP = 0xe
|
||||||
@@ -1781,6 +1813,7 @@ const (
|
|||||||
SOL_TIPC = 0x10f
|
SOL_TIPC = 0x10f
|
||||||
SOL_TLS = 0x11a
|
SOL_TLS = 0x11a
|
||||||
SOL_X25 = 0x106
|
SOL_X25 = 0x106
|
||||||
|
SOL_XDP = 0x11b
|
||||||
SOMAXCONN = 0x80
|
SOMAXCONN = 0x80
|
||||||
SO_ACCEPTCONN = 0x1e
|
SO_ACCEPTCONN = 0x1e
|
||||||
SO_ATTACH_BPF = 0x32
|
SO_ATTACH_BPF = 0x32
|
||||||
@@ -1876,6 +1909,9 @@ const (
|
|||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
SYNC_FILE_RANGE_WRITE = 0x2
|
||||||
SYSFS_MAGIC = 0x62656572
|
SYSFS_MAGIC = 0x62656572
|
||||||
S_BLKSIZE = 0x200
|
S_BLKSIZE = 0x200
|
||||||
S_IEXEC = 0x40
|
S_IEXEC = 0x40
|
||||||
@@ -1939,6 +1975,8 @@ const (
|
|||||||
TCP_DEFER_ACCEPT = 0x9
|
TCP_DEFER_ACCEPT = 0x9
|
||||||
TCP_FASTOPEN = 0x17
|
TCP_FASTOPEN = 0x17
|
||||||
TCP_FASTOPEN_CONNECT = 0x1e
|
TCP_FASTOPEN_CONNECT = 0x1e
|
||||||
|
TCP_FASTOPEN_KEY = 0x21
|
||||||
|
TCP_FASTOPEN_NO_COOKIE = 0x22
|
||||||
TCP_INFO = 0xb
|
TCP_INFO = 0xb
|
||||||
TCP_KEEPCNT = 0x6
|
TCP_KEEPCNT = 0x6
|
||||||
TCP_KEEPIDLE = 0x4
|
TCP_KEEPIDLE = 0x4
|
||||||
@@ -2106,6 +2144,21 @@ const (
|
|||||||
TUNSETVNETBE = 0x400454de
|
TUNSETVNETBE = 0x400454de
|
||||||
TUNSETVNETHDRSZ = 0x400454d8
|
TUNSETVNETHDRSZ = 0x400454d8
|
||||||
TUNSETVNETLE = 0x400454dc
|
TUNSETVNETLE = 0x400454dc
|
||||||
|
UBI_IOCATT = 0x40186f40
|
||||||
|
UBI_IOCDET = 0x40046f41
|
||||||
|
UBI_IOCEBCH = 0x40044f02
|
||||||
|
UBI_IOCEBER = 0x40044f01
|
||||||
|
UBI_IOCEBISMAP = 0x80044f05
|
||||||
|
UBI_IOCEBMAP = 0x40084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x40044f04
|
||||||
|
UBI_IOCMKVOL = 0x40986f00
|
||||||
|
UBI_IOCRMVOL = 0x40046f01
|
||||||
|
UBI_IOCRNVOL = 0x51106f03
|
||||||
|
UBI_IOCRSVOL = 0x400c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x40104f06
|
||||||
|
UBI_IOCVOLCRBLK = 0x40804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x4f08
|
||||||
|
UBI_IOCVOLUP = 0x40084f00
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
@@ -2242,6 +2295,26 @@ const (
|
|||||||
XATTR_CREATE = 0x1
|
XATTR_CREATE = 0x1
|
||||||
XATTR_REPLACE = 0x2
|
XATTR_REPLACE = 0x2
|
||||||
XCASE = 0x4
|
XCASE = 0x4
|
||||||
|
XDP_COPY = 0x2
|
||||||
|
XDP_FLAGS_DRV_MODE = 0x4
|
||||||
|
XDP_FLAGS_HW_MODE = 0x8
|
||||||
|
XDP_FLAGS_MASK = 0xf
|
||||||
|
XDP_FLAGS_MODES = 0xe
|
||||||
|
XDP_FLAGS_SKB_MODE = 0x2
|
||||||
|
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
|
||||||
|
XDP_MMAP_OFFSETS = 0x1
|
||||||
|
XDP_PGOFF_RX_RING = 0x0
|
||||||
|
XDP_PGOFF_TX_RING = 0x80000000
|
||||||
|
XDP_RX_RING = 0x2
|
||||||
|
XDP_SHARED_UMEM = 0x1
|
||||||
|
XDP_STATISTICS = 0x7
|
||||||
|
XDP_TX_RING = 0x3
|
||||||
|
XDP_UMEM_COMPLETION_RING = 0x6
|
||||||
|
XDP_UMEM_FILL_RING = 0x5
|
||||||
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_ZEROCOPY = 0x4
|
||||||
XENFS_SUPER_MAGIC = 0xabba1974
|
XENFS_SUPER_MAGIC = 0xabba1974
|
||||||
XTABS = 0x1800
|
XTABS = 0x1800
|
||||||
ZSMALLOC_MAGIC = 0x58295829
|
ZSMALLOC_MAGIC = 0x58295829
|
||||||
|
|||||||
+75
-2
@@ -64,6 +64,7 @@ const (
|
|||||||
AF_VSOCK = 0x28
|
AF_VSOCK = 0x28
|
||||||
AF_WANPIPE = 0x19
|
AF_WANPIPE = 0x19
|
||||||
AF_X25 = 0x9
|
AF_X25 = 0x9
|
||||||
|
AF_XDP = 0x2c
|
||||||
ALG_OP_DECRYPT = 0x0
|
ALG_OP_DECRYPT = 0x0
|
||||||
ALG_OP_ENCRYPT = 0x1
|
ALG_OP_ENCRYPT = 0x1
|
||||||
ALG_SET_AEAD_ASSOCLEN = 0x4
|
ALG_SET_AEAD_ASSOCLEN = 0x4
|
||||||
@@ -498,6 +499,8 @@ const (
|
|||||||
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
||||||
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
||||||
FS_ENCRYPTION_MODE_INVALID = 0x0
|
FS_ENCRYPTION_MODE_INVALID = 0x0
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
|
||||||
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
||||||
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
||||||
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
||||||
@@ -635,7 +638,7 @@ const (
|
|||||||
IFA_F_STABLE_PRIVACY = 0x800
|
IFA_F_STABLE_PRIVACY = 0x800
|
||||||
IFA_F_TEMPORARY = 0x1
|
IFA_F_TEMPORARY = 0x1
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_MAX = 0x8
|
IFA_MAX = 0x9
|
||||||
IFF_ALLMULTI = 0x200
|
IFF_ALLMULTI = 0x200
|
||||||
IFF_ATTACH_QUEUE = 0x200
|
IFF_ATTACH_QUEUE = 0x200
|
||||||
IFF_AUTOMEDIA = 0x4000
|
IFF_AUTOMEDIA = 0x4000
|
||||||
@@ -762,6 +765,7 @@ const (
|
|||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
IPV6_HOPOPTS = 0x36
|
IPV6_HOPOPTS = 0x36
|
||||||
@@ -954,6 +958,7 @@ const (
|
|||||||
MAP_EXECUTABLE = 0x1000
|
MAP_EXECUTABLE = 0x1000
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
MAP_GROWSDOWN = 0x100
|
MAP_GROWSDOWN = 0x100
|
||||||
MAP_HUGETLB = 0x40000
|
MAP_HUGETLB = 0x40000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
@@ -964,11 +969,28 @@ const (
|
|||||||
MAP_POPULATE = 0x8000
|
MAP_POPULATE = 0x8000
|
||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
|
MAP_SHARED_VALIDATE = 0x3
|
||||||
MAP_STACK = 0x20000
|
MAP_STACK = 0x20000
|
||||||
|
MAP_SYNC = 0x80000
|
||||||
MAP_TYPE = 0xf
|
MAP_TYPE = 0xf
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MCL_ONFAULT = 0x4
|
MCL_ONFAULT = 0x4
|
||||||
|
MFD_ALLOW_SEALING = 0x2
|
||||||
|
MFD_CLOEXEC = 0x1
|
||||||
|
MFD_HUGETLB = 0x4
|
||||||
|
MFD_HUGE_16GB = -0x78000000
|
||||||
|
MFD_HUGE_16MB = 0x60000000
|
||||||
|
MFD_HUGE_1GB = 0x78000000
|
||||||
|
MFD_HUGE_1MB = 0x50000000
|
||||||
|
MFD_HUGE_256MB = 0x70000000
|
||||||
|
MFD_HUGE_2GB = 0x7c000000
|
||||||
|
MFD_HUGE_2MB = 0x54000000
|
||||||
|
MFD_HUGE_512KB = 0x4c000000
|
||||||
|
MFD_HUGE_64KB = 0x40000000
|
||||||
|
MFD_HUGE_8MB = 0x5c000000
|
||||||
|
MFD_HUGE_MASK = 0x3f
|
||||||
|
MFD_HUGE_SHIFT = 0x1a
|
||||||
MINIX2_SUPER_MAGIC = 0x2468
|
MINIX2_SUPER_MAGIC = 0x2468
|
||||||
MINIX2_SUPER_MAGIC2 = 0x2478
|
MINIX2_SUPER_MAGIC2 = 0x2478
|
||||||
MINIX3_SUPER_MAGIC = 0x4d5a
|
MINIX3_SUPER_MAGIC = 0x4d5a
|
||||||
@@ -1074,6 +1096,8 @@ const (
|
|||||||
NETLINK_UNUSED = 0x1
|
NETLINK_UNUSED = 0x1
|
||||||
NETLINK_USERSOCK = 0x2
|
NETLINK_USERSOCK = 0x2
|
||||||
NETLINK_XFRM = 0x6
|
NETLINK_XFRM = 0x6
|
||||||
|
NETNSA_MAX = 0x3
|
||||||
|
NETNSA_NSID_NOT_ASSIGNED = -0x1
|
||||||
NFNETLINK_V0 = 0x0
|
NFNETLINK_V0 = 0x0
|
||||||
NFNLGRP_ACCT_QUOTA = 0x8
|
NFNLGRP_ACCT_QUOTA = 0x8
|
||||||
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
||||||
@@ -1434,6 +1458,9 @@ const (
|
|||||||
RAMFS_MAGIC = 0x858458f6
|
RAMFS_MAGIC = 0x858458f6
|
||||||
RDTGROUP_SUPER_MAGIC = 0x7655821
|
RDTGROUP_SUPER_MAGIC = 0x7655821
|
||||||
REISERFS_SUPER_MAGIC = 0x52654973
|
REISERFS_SUPER_MAGIC = 0x52654973
|
||||||
|
RENAME_EXCHANGE = 0x2
|
||||||
|
RENAME_NOREPLACE = 0x1
|
||||||
|
RENAME_WHITEOUT = 0x4
|
||||||
RLIMIT_AS = 0x9
|
RLIMIT_AS = 0x9
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
@@ -1476,7 +1503,7 @@ const (
|
|||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1a
|
RTA_MAX = 0x1d
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
@@ -1612,17 +1639,22 @@ const (
|
|||||||
RTNH_F_UNRESOLVED = 0x20
|
RTNH_F_UNRESOLVED = 0x20
|
||||||
RTN_MAX = 0xb
|
RTN_MAX = 0xb
|
||||||
RTPROT_BABEL = 0x2a
|
RTPROT_BABEL = 0x2a
|
||||||
|
RTPROT_BGP = 0xba
|
||||||
RTPROT_BIRD = 0xc
|
RTPROT_BIRD = 0xc
|
||||||
RTPROT_BOOT = 0x3
|
RTPROT_BOOT = 0x3
|
||||||
RTPROT_DHCP = 0x10
|
RTPROT_DHCP = 0x10
|
||||||
RTPROT_DNROUTED = 0xd
|
RTPROT_DNROUTED = 0xd
|
||||||
|
RTPROT_EIGRP = 0xc0
|
||||||
RTPROT_GATED = 0x8
|
RTPROT_GATED = 0x8
|
||||||
|
RTPROT_ISIS = 0xbb
|
||||||
RTPROT_KERNEL = 0x2
|
RTPROT_KERNEL = 0x2
|
||||||
RTPROT_MROUTED = 0x11
|
RTPROT_MROUTED = 0x11
|
||||||
RTPROT_MRT = 0xa
|
RTPROT_MRT = 0xa
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
|
RTPROT_OSPF = 0xbc
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
|
RTPROT_RIP = 0xbd
|
||||||
RTPROT_STATIC = 0x4
|
RTPROT_STATIC = 0x4
|
||||||
RTPROT_UNSPEC = 0x0
|
RTPROT_UNSPEC = 0x0
|
||||||
RTPROT_XORP = 0xe
|
RTPROT_XORP = 0xe
|
||||||
@@ -1787,6 +1819,7 @@ const (
|
|||||||
SOL_TIPC = 0x10f
|
SOL_TIPC = 0x10f
|
||||||
SOL_TLS = 0x11a
|
SOL_TLS = 0x11a
|
||||||
SOL_X25 = 0x106
|
SOL_X25 = 0x106
|
||||||
|
SOL_XDP = 0x11b
|
||||||
SOMAXCONN = 0x80
|
SOMAXCONN = 0x80
|
||||||
SO_ACCEPTCONN = 0x1e
|
SO_ACCEPTCONN = 0x1e
|
||||||
SO_ATTACH_BPF = 0x32
|
SO_ATTACH_BPF = 0x32
|
||||||
@@ -1882,6 +1915,9 @@ const (
|
|||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
SYNC_FILE_RANGE_WRITE = 0x2
|
||||||
SYSFS_MAGIC = 0x62656572
|
SYSFS_MAGIC = 0x62656572
|
||||||
S_BLKSIZE = 0x200
|
S_BLKSIZE = 0x200
|
||||||
S_IEXEC = 0x40
|
S_IEXEC = 0x40
|
||||||
@@ -1945,6 +1981,8 @@ const (
|
|||||||
TCP_DEFER_ACCEPT = 0x9
|
TCP_DEFER_ACCEPT = 0x9
|
||||||
TCP_FASTOPEN = 0x17
|
TCP_FASTOPEN = 0x17
|
||||||
TCP_FASTOPEN_CONNECT = 0x1e
|
TCP_FASTOPEN_CONNECT = 0x1e
|
||||||
|
TCP_FASTOPEN_KEY = 0x21
|
||||||
|
TCP_FASTOPEN_NO_COOKIE = 0x22
|
||||||
TCP_INFO = 0xb
|
TCP_INFO = 0xb
|
||||||
TCP_KEEPCNT = 0x6
|
TCP_KEEPCNT = 0x6
|
||||||
TCP_KEEPIDLE = 0x4
|
TCP_KEEPIDLE = 0x4
|
||||||
@@ -2112,6 +2150,21 @@ const (
|
|||||||
TUNSETVNETBE = 0x400454de
|
TUNSETVNETBE = 0x400454de
|
||||||
TUNSETVNETHDRSZ = 0x400454d8
|
TUNSETVNETHDRSZ = 0x400454d8
|
||||||
TUNSETVNETLE = 0x400454dc
|
TUNSETVNETLE = 0x400454dc
|
||||||
|
UBI_IOCATT = 0x40186f40
|
||||||
|
UBI_IOCDET = 0x40046f41
|
||||||
|
UBI_IOCEBCH = 0x40044f02
|
||||||
|
UBI_IOCEBER = 0x40044f01
|
||||||
|
UBI_IOCEBISMAP = 0x80044f05
|
||||||
|
UBI_IOCEBMAP = 0x40084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x40044f04
|
||||||
|
UBI_IOCMKVOL = 0x40986f00
|
||||||
|
UBI_IOCRMVOL = 0x40046f01
|
||||||
|
UBI_IOCRNVOL = 0x51106f03
|
||||||
|
UBI_IOCRSVOL = 0x400c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x40104f06
|
||||||
|
UBI_IOCVOLCRBLK = 0x40804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x4f08
|
||||||
|
UBI_IOCVOLUP = 0x40084f00
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
@@ -2248,6 +2301,26 @@ const (
|
|||||||
XATTR_CREATE = 0x1
|
XATTR_CREATE = 0x1
|
||||||
XATTR_REPLACE = 0x2
|
XATTR_REPLACE = 0x2
|
||||||
XCASE = 0x4
|
XCASE = 0x4
|
||||||
|
XDP_COPY = 0x2
|
||||||
|
XDP_FLAGS_DRV_MODE = 0x4
|
||||||
|
XDP_FLAGS_HW_MODE = 0x8
|
||||||
|
XDP_FLAGS_MASK = 0xf
|
||||||
|
XDP_FLAGS_MODES = 0xe
|
||||||
|
XDP_FLAGS_SKB_MODE = 0x2
|
||||||
|
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
|
||||||
|
XDP_MMAP_OFFSETS = 0x1
|
||||||
|
XDP_PGOFF_RX_RING = 0x0
|
||||||
|
XDP_PGOFF_TX_RING = 0x80000000
|
||||||
|
XDP_RX_RING = 0x2
|
||||||
|
XDP_SHARED_UMEM = 0x1
|
||||||
|
XDP_STATISTICS = 0x7
|
||||||
|
XDP_TX_RING = 0x3
|
||||||
|
XDP_UMEM_COMPLETION_RING = 0x6
|
||||||
|
XDP_UMEM_FILL_RING = 0x5
|
||||||
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_ZEROCOPY = 0x4
|
||||||
XENFS_SUPER_MAGIC = 0xabba1974
|
XENFS_SUPER_MAGIC = 0xabba1974
|
||||||
XTABS = 0x1800
|
XTABS = 0x1800
|
||||||
ZSMALLOC_MAGIC = 0x58295829
|
ZSMALLOC_MAGIC = 0x58295829
|
||||||
|
|||||||
+75
-2
@@ -64,6 +64,7 @@ const (
|
|||||||
AF_VSOCK = 0x28
|
AF_VSOCK = 0x28
|
||||||
AF_WANPIPE = 0x19
|
AF_WANPIPE = 0x19
|
||||||
AF_X25 = 0x9
|
AF_X25 = 0x9
|
||||||
|
AF_XDP = 0x2c
|
||||||
ALG_OP_DECRYPT = 0x0
|
ALG_OP_DECRYPT = 0x0
|
||||||
ALG_OP_ENCRYPT = 0x1
|
ALG_OP_ENCRYPT = 0x1
|
||||||
ALG_SET_AEAD_ASSOCLEN = 0x4
|
ALG_SET_AEAD_ASSOCLEN = 0x4
|
||||||
@@ -501,6 +502,8 @@ const (
|
|||||||
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
||||||
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
||||||
FS_ENCRYPTION_MODE_INVALID = 0x0
|
FS_ENCRYPTION_MODE_INVALID = 0x0
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
|
||||||
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
|
||||||
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
|
||||||
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
|
||||||
@@ -638,7 +641,7 @@ const (
|
|||||||
IFA_F_STABLE_PRIVACY = 0x800
|
IFA_F_STABLE_PRIVACY = 0x800
|
||||||
IFA_F_TEMPORARY = 0x1
|
IFA_F_TEMPORARY = 0x1
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_MAX = 0x8
|
IFA_MAX = 0x9
|
||||||
IFF_ALLMULTI = 0x200
|
IFF_ALLMULTI = 0x200
|
||||||
IFF_ATTACH_QUEUE = 0x200
|
IFF_ATTACH_QUEUE = 0x200
|
||||||
IFF_AUTOMEDIA = 0x4000
|
IFF_AUTOMEDIA = 0x4000
|
||||||
@@ -765,6 +768,7 @@ const (
|
|||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
IPV6_HOPOPTS = 0x36
|
IPV6_HOPOPTS = 0x36
|
||||||
@@ -957,6 +961,7 @@ const (
|
|||||||
MAP_EXECUTABLE = 0x1000
|
MAP_EXECUTABLE = 0x1000
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
MAP_GROWSDOWN = 0x100
|
MAP_GROWSDOWN = 0x100
|
||||||
MAP_HUGETLB = 0x40000
|
MAP_HUGETLB = 0x40000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
@@ -967,11 +972,28 @@ const (
|
|||||||
MAP_POPULATE = 0x8000
|
MAP_POPULATE = 0x8000
|
||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
|
MAP_SHARED_VALIDATE = 0x3
|
||||||
MAP_STACK = 0x20000
|
MAP_STACK = 0x20000
|
||||||
|
MAP_SYNC = 0x80000
|
||||||
MAP_TYPE = 0xf
|
MAP_TYPE = 0xf
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MCL_ONFAULT = 0x4
|
MCL_ONFAULT = 0x4
|
||||||
|
MFD_ALLOW_SEALING = 0x2
|
||||||
|
MFD_CLOEXEC = 0x1
|
||||||
|
MFD_HUGETLB = 0x4
|
||||||
|
MFD_HUGE_16GB = -0x78000000
|
||||||
|
MFD_HUGE_16MB = 0x60000000
|
||||||
|
MFD_HUGE_1GB = 0x78000000
|
||||||
|
MFD_HUGE_1MB = 0x50000000
|
||||||
|
MFD_HUGE_256MB = 0x70000000
|
||||||
|
MFD_HUGE_2GB = 0x7c000000
|
||||||
|
MFD_HUGE_2MB = 0x54000000
|
||||||
|
MFD_HUGE_512KB = 0x4c000000
|
||||||
|
MFD_HUGE_64KB = 0x40000000
|
||||||
|
MFD_HUGE_8MB = 0x5c000000
|
||||||
|
MFD_HUGE_MASK = 0x3f
|
||||||
|
MFD_HUGE_SHIFT = 0x1a
|
||||||
MINIX2_SUPER_MAGIC = 0x2468
|
MINIX2_SUPER_MAGIC = 0x2468
|
||||||
MINIX2_SUPER_MAGIC2 = 0x2478
|
MINIX2_SUPER_MAGIC2 = 0x2478
|
||||||
MINIX3_SUPER_MAGIC = 0x4d5a
|
MINIX3_SUPER_MAGIC = 0x4d5a
|
||||||
@@ -1077,6 +1099,8 @@ const (
|
|||||||
NETLINK_UNUSED = 0x1
|
NETLINK_UNUSED = 0x1
|
||||||
NETLINK_USERSOCK = 0x2
|
NETLINK_USERSOCK = 0x2
|
||||||
NETLINK_XFRM = 0x6
|
NETLINK_XFRM = 0x6
|
||||||
|
NETNSA_MAX = 0x3
|
||||||
|
NETNSA_NSID_NOT_ASSIGNED = -0x1
|
||||||
NFNETLINK_V0 = 0x0
|
NFNETLINK_V0 = 0x0
|
||||||
NFNLGRP_ACCT_QUOTA = 0x8
|
NFNLGRP_ACCT_QUOTA = 0x8
|
||||||
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
||||||
@@ -1418,6 +1442,9 @@ const (
|
|||||||
RAMFS_MAGIC = 0x858458f6
|
RAMFS_MAGIC = 0x858458f6
|
||||||
RDTGROUP_SUPER_MAGIC = 0x7655821
|
RDTGROUP_SUPER_MAGIC = 0x7655821
|
||||||
REISERFS_SUPER_MAGIC = 0x52654973
|
REISERFS_SUPER_MAGIC = 0x52654973
|
||||||
|
RENAME_EXCHANGE = 0x2
|
||||||
|
RENAME_NOREPLACE = 0x1
|
||||||
|
RENAME_WHITEOUT = 0x4
|
||||||
RLIMIT_AS = 0x9
|
RLIMIT_AS = 0x9
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
@@ -1460,7 +1487,7 @@ const (
|
|||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1a
|
RTA_MAX = 0x1d
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
@@ -1596,17 +1623,22 @@ const (
|
|||||||
RTNH_F_UNRESOLVED = 0x20
|
RTNH_F_UNRESOLVED = 0x20
|
||||||
RTN_MAX = 0xb
|
RTN_MAX = 0xb
|
||||||
RTPROT_BABEL = 0x2a
|
RTPROT_BABEL = 0x2a
|
||||||
|
RTPROT_BGP = 0xba
|
||||||
RTPROT_BIRD = 0xc
|
RTPROT_BIRD = 0xc
|
||||||
RTPROT_BOOT = 0x3
|
RTPROT_BOOT = 0x3
|
||||||
RTPROT_DHCP = 0x10
|
RTPROT_DHCP = 0x10
|
||||||
RTPROT_DNROUTED = 0xd
|
RTPROT_DNROUTED = 0xd
|
||||||
|
RTPROT_EIGRP = 0xc0
|
||||||
RTPROT_GATED = 0x8
|
RTPROT_GATED = 0x8
|
||||||
|
RTPROT_ISIS = 0xbb
|
||||||
RTPROT_KERNEL = 0x2
|
RTPROT_KERNEL = 0x2
|
||||||
RTPROT_MROUTED = 0x11
|
RTPROT_MROUTED = 0x11
|
||||||
RTPROT_MRT = 0xa
|
RTPROT_MRT = 0xa
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
|
RTPROT_OSPF = 0xbc
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
|
RTPROT_RIP = 0xbd
|
||||||
RTPROT_STATIC = 0x4
|
RTPROT_STATIC = 0x4
|
||||||
RTPROT_UNSPEC = 0x0
|
RTPROT_UNSPEC = 0x0
|
||||||
RTPROT_XORP = 0xe
|
RTPROT_XORP = 0xe
|
||||||
@@ -1771,6 +1803,7 @@ const (
|
|||||||
SOL_TIPC = 0x10f
|
SOL_TIPC = 0x10f
|
||||||
SOL_TLS = 0x11a
|
SOL_TLS = 0x11a
|
||||||
SOL_X25 = 0x106
|
SOL_X25 = 0x106
|
||||||
|
SOL_XDP = 0x11b
|
||||||
SOMAXCONN = 0x80
|
SOMAXCONN = 0x80
|
||||||
SO_ACCEPTCONN = 0x1e
|
SO_ACCEPTCONN = 0x1e
|
||||||
SO_ATTACH_BPF = 0x32
|
SO_ATTACH_BPF = 0x32
|
||||||
@@ -1867,6 +1900,9 @@ const (
|
|||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
SVE_MAGIC = 0x53564501
|
SVE_MAGIC = 0x53564501
|
||||||
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
SYNC_FILE_RANGE_WRITE = 0x2
|
||||||
SYSFS_MAGIC = 0x62656572
|
SYSFS_MAGIC = 0x62656572
|
||||||
S_BLKSIZE = 0x200
|
S_BLKSIZE = 0x200
|
||||||
S_IEXEC = 0x40
|
S_IEXEC = 0x40
|
||||||
@@ -1930,6 +1966,8 @@ const (
|
|||||||
TCP_DEFER_ACCEPT = 0x9
|
TCP_DEFER_ACCEPT = 0x9
|
||||||
TCP_FASTOPEN = 0x17
|
TCP_FASTOPEN = 0x17
|
||||||
TCP_FASTOPEN_CONNECT = 0x1e
|
TCP_FASTOPEN_CONNECT = 0x1e
|
||||||
|
TCP_FASTOPEN_KEY = 0x21
|
||||||
|
TCP_FASTOPEN_NO_COOKIE = 0x22
|
||||||
TCP_INFO = 0xb
|
TCP_INFO = 0xb
|
||||||
TCP_KEEPCNT = 0x6
|
TCP_KEEPCNT = 0x6
|
||||||
TCP_KEEPIDLE = 0x4
|
TCP_KEEPIDLE = 0x4
|
||||||
@@ -2097,6 +2135,21 @@ const (
|
|||||||
TUNSETVNETBE = 0x400454de
|
TUNSETVNETBE = 0x400454de
|
||||||
TUNSETVNETHDRSZ = 0x400454d8
|
TUNSETVNETHDRSZ = 0x400454d8
|
||||||
TUNSETVNETLE = 0x400454dc
|
TUNSETVNETLE = 0x400454dc
|
||||||
|
UBI_IOCATT = 0x40186f40
|
||||||
|
UBI_IOCDET = 0x40046f41
|
||||||
|
UBI_IOCEBCH = 0x40044f02
|
||||||
|
UBI_IOCEBER = 0x40044f01
|
||||||
|
UBI_IOCEBISMAP = 0x80044f05
|
||||||
|
UBI_IOCEBMAP = 0x40084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x40044f04
|
||||||
|
UBI_IOCMKVOL = 0x40986f00
|
||||||
|
UBI_IOCRMVOL = 0x40046f01
|
||||||
|
UBI_IOCRNVOL = 0x51106f03
|
||||||
|
UBI_IOCRSVOL = 0x400c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x40104f06
|
||||||
|
UBI_IOCVOLCRBLK = 0x40804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x4f08
|
||||||
|
UBI_IOCVOLUP = 0x40084f00
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
@@ -2233,6 +2286,26 @@ const (
|
|||||||
XATTR_CREATE = 0x1
|
XATTR_CREATE = 0x1
|
||||||
XATTR_REPLACE = 0x2
|
XATTR_REPLACE = 0x2
|
||||||
XCASE = 0x4
|
XCASE = 0x4
|
||||||
|
XDP_COPY = 0x2
|
||||||
|
XDP_FLAGS_DRV_MODE = 0x4
|
||||||
|
XDP_FLAGS_HW_MODE = 0x8
|
||||||
|
XDP_FLAGS_MASK = 0xf
|
||||||
|
XDP_FLAGS_MODES = 0xe
|
||||||
|
XDP_FLAGS_SKB_MODE = 0x2
|
||||||
|
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
|
||||||
|
XDP_MMAP_OFFSETS = 0x1
|
||||||
|
XDP_PGOFF_RX_RING = 0x0
|
||||||
|
XDP_PGOFF_TX_RING = 0x80000000
|
||||||
|
XDP_RX_RING = 0x2
|
||||||
|
XDP_SHARED_UMEM = 0x1
|
||||||
|
XDP_STATISTICS = 0x7
|
||||||
|
XDP_TX_RING = 0x3
|
||||||
|
XDP_UMEM_COMPLETION_RING = 0x6
|
||||||
|
XDP_UMEM_FILL_RING = 0x5
|
||||||
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_ZEROCOPY = 0x4
|
||||||
XENFS_SUPER_MAGIC = 0xabba1974
|
XENFS_SUPER_MAGIC = 0xabba1974
|
||||||
XTABS = 0x1800
|
XTABS = 0x1800
|
||||||
ZSMALLOC_MAGIC = 0x58295829
|
ZSMALLOC_MAGIC = 0x58295829
|
||||||
|
|||||||
+74
-2
@@ -64,6 +64,7 @@ const (
|
|||||||
AF_VSOCK = 0x28
|
AF_VSOCK = 0x28
|
||||||
AF_WANPIPE = 0x19
|
AF_WANPIPE = 0x19
|
||||||
AF_X25 = 0x9
|
AF_X25 = 0x9
|
||||||
|
AF_XDP = 0x2c
|
||||||
ALG_OP_DECRYPT = 0x0
|
ALG_OP_DECRYPT = 0x0
|
||||||
ALG_OP_ENCRYPT = 0x1
|
ALG_OP_ENCRYPT = 0x1
|
||||||
ALG_SET_AEAD_ASSOCLEN = 0x4
|
ALG_SET_AEAD_ASSOCLEN = 0x4
|
||||||
@@ -498,6 +499,8 @@ const (
|
|||||||
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
||||||
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
||||||
FS_ENCRYPTION_MODE_INVALID = 0x0
|
FS_ENCRYPTION_MODE_INVALID = 0x0
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
|
||||||
FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
|
||||||
FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
|
||||||
FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
|
||||||
@@ -635,7 +638,7 @@ const (
|
|||||||
IFA_F_STABLE_PRIVACY = 0x800
|
IFA_F_STABLE_PRIVACY = 0x800
|
||||||
IFA_F_TEMPORARY = 0x1
|
IFA_F_TEMPORARY = 0x1
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_MAX = 0x8
|
IFA_MAX = 0x9
|
||||||
IFF_ALLMULTI = 0x200
|
IFF_ALLMULTI = 0x200
|
||||||
IFF_ATTACH_QUEUE = 0x200
|
IFF_ATTACH_QUEUE = 0x200
|
||||||
IFF_AUTOMEDIA = 0x4000
|
IFF_AUTOMEDIA = 0x4000
|
||||||
@@ -762,6 +765,7 @@ const (
|
|||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
IPV6_HOPOPTS = 0x36
|
IPV6_HOPOPTS = 0x36
|
||||||
@@ -954,6 +958,7 @@ const (
|
|||||||
MAP_EXECUTABLE = 0x4000
|
MAP_EXECUTABLE = 0x4000
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
MAP_GROWSDOWN = 0x1000
|
MAP_GROWSDOWN = 0x1000
|
||||||
MAP_HUGETLB = 0x80000
|
MAP_HUGETLB = 0x80000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
@@ -965,11 +970,27 @@ const (
|
|||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
MAP_RENAME = 0x800
|
MAP_RENAME = 0x800
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
|
MAP_SHARED_VALIDATE = 0x3
|
||||||
MAP_STACK = 0x40000
|
MAP_STACK = 0x40000
|
||||||
MAP_TYPE = 0xf
|
MAP_TYPE = 0xf
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MCL_ONFAULT = 0x4
|
MCL_ONFAULT = 0x4
|
||||||
|
MFD_ALLOW_SEALING = 0x2
|
||||||
|
MFD_CLOEXEC = 0x1
|
||||||
|
MFD_HUGETLB = 0x4
|
||||||
|
MFD_HUGE_16GB = -0x78000000
|
||||||
|
MFD_HUGE_16MB = 0x60000000
|
||||||
|
MFD_HUGE_1GB = 0x78000000
|
||||||
|
MFD_HUGE_1MB = 0x50000000
|
||||||
|
MFD_HUGE_256MB = 0x70000000
|
||||||
|
MFD_HUGE_2GB = 0x7c000000
|
||||||
|
MFD_HUGE_2MB = 0x54000000
|
||||||
|
MFD_HUGE_512KB = 0x4c000000
|
||||||
|
MFD_HUGE_64KB = 0x40000000
|
||||||
|
MFD_HUGE_8MB = 0x5c000000
|
||||||
|
MFD_HUGE_MASK = 0x3f
|
||||||
|
MFD_HUGE_SHIFT = 0x1a
|
||||||
MINIX2_SUPER_MAGIC = 0x2468
|
MINIX2_SUPER_MAGIC = 0x2468
|
||||||
MINIX2_SUPER_MAGIC2 = 0x2478
|
MINIX2_SUPER_MAGIC2 = 0x2478
|
||||||
MINIX3_SUPER_MAGIC = 0x4d5a
|
MINIX3_SUPER_MAGIC = 0x4d5a
|
||||||
@@ -1075,6 +1096,8 @@ const (
|
|||||||
NETLINK_UNUSED = 0x1
|
NETLINK_UNUSED = 0x1
|
||||||
NETLINK_USERSOCK = 0x2
|
NETLINK_USERSOCK = 0x2
|
||||||
NETLINK_XFRM = 0x6
|
NETLINK_XFRM = 0x6
|
||||||
|
NETNSA_MAX = 0x3
|
||||||
|
NETNSA_NSID_NOT_ASSIGNED = -0x1
|
||||||
NFNETLINK_V0 = 0x0
|
NFNETLINK_V0 = 0x0
|
||||||
NFNLGRP_ACCT_QUOTA = 0x8
|
NFNLGRP_ACCT_QUOTA = 0x8
|
||||||
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
||||||
@@ -1428,6 +1451,9 @@ const (
|
|||||||
RAMFS_MAGIC = 0x858458f6
|
RAMFS_MAGIC = 0x858458f6
|
||||||
RDTGROUP_SUPER_MAGIC = 0x7655821
|
RDTGROUP_SUPER_MAGIC = 0x7655821
|
||||||
REISERFS_SUPER_MAGIC = 0x52654973
|
REISERFS_SUPER_MAGIC = 0x52654973
|
||||||
|
RENAME_EXCHANGE = 0x2
|
||||||
|
RENAME_NOREPLACE = 0x1
|
||||||
|
RENAME_WHITEOUT = 0x4
|
||||||
RLIMIT_AS = 0x6
|
RLIMIT_AS = 0x6
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
@@ -1470,7 +1496,7 @@ const (
|
|||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1a
|
RTA_MAX = 0x1d
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
@@ -1606,17 +1632,22 @@ const (
|
|||||||
RTNH_F_UNRESOLVED = 0x20
|
RTNH_F_UNRESOLVED = 0x20
|
||||||
RTN_MAX = 0xb
|
RTN_MAX = 0xb
|
||||||
RTPROT_BABEL = 0x2a
|
RTPROT_BABEL = 0x2a
|
||||||
|
RTPROT_BGP = 0xba
|
||||||
RTPROT_BIRD = 0xc
|
RTPROT_BIRD = 0xc
|
||||||
RTPROT_BOOT = 0x3
|
RTPROT_BOOT = 0x3
|
||||||
RTPROT_DHCP = 0x10
|
RTPROT_DHCP = 0x10
|
||||||
RTPROT_DNROUTED = 0xd
|
RTPROT_DNROUTED = 0xd
|
||||||
|
RTPROT_EIGRP = 0xc0
|
||||||
RTPROT_GATED = 0x8
|
RTPROT_GATED = 0x8
|
||||||
|
RTPROT_ISIS = 0xbb
|
||||||
RTPROT_KERNEL = 0x2
|
RTPROT_KERNEL = 0x2
|
||||||
RTPROT_MROUTED = 0x11
|
RTPROT_MROUTED = 0x11
|
||||||
RTPROT_MRT = 0xa
|
RTPROT_MRT = 0xa
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
|
RTPROT_OSPF = 0xbc
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
|
RTPROT_RIP = 0xbd
|
||||||
RTPROT_STATIC = 0x4
|
RTPROT_STATIC = 0x4
|
||||||
RTPROT_UNSPEC = 0x0
|
RTPROT_UNSPEC = 0x0
|
||||||
RTPROT_XORP = 0xe
|
RTPROT_XORP = 0xe
|
||||||
@@ -1781,6 +1812,7 @@ const (
|
|||||||
SOL_TIPC = 0x10f
|
SOL_TIPC = 0x10f
|
||||||
SOL_TLS = 0x11a
|
SOL_TLS = 0x11a
|
||||||
SOL_X25 = 0x106
|
SOL_X25 = 0x106
|
||||||
|
SOL_XDP = 0x11b
|
||||||
SOMAXCONN = 0x80
|
SOMAXCONN = 0x80
|
||||||
SO_ACCEPTCONN = 0x1009
|
SO_ACCEPTCONN = 0x1009
|
||||||
SO_ATTACH_BPF = 0x32
|
SO_ATTACH_BPF = 0x32
|
||||||
@@ -1877,6 +1909,9 @@ const (
|
|||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
SYNC_FILE_RANGE_WRITE = 0x2
|
||||||
SYSFS_MAGIC = 0x62656572
|
SYSFS_MAGIC = 0x62656572
|
||||||
S_BLKSIZE = 0x200
|
S_BLKSIZE = 0x200
|
||||||
S_IEXEC = 0x40
|
S_IEXEC = 0x40
|
||||||
@@ -1939,6 +1974,8 @@ const (
|
|||||||
TCP_DEFER_ACCEPT = 0x9
|
TCP_DEFER_ACCEPT = 0x9
|
||||||
TCP_FASTOPEN = 0x17
|
TCP_FASTOPEN = 0x17
|
||||||
TCP_FASTOPEN_CONNECT = 0x1e
|
TCP_FASTOPEN_CONNECT = 0x1e
|
||||||
|
TCP_FASTOPEN_KEY = 0x21
|
||||||
|
TCP_FASTOPEN_NO_COOKIE = 0x22
|
||||||
TCP_INFO = 0xb
|
TCP_INFO = 0xb
|
||||||
TCP_KEEPCNT = 0x6
|
TCP_KEEPCNT = 0x6
|
||||||
TCP_KEEPIDLE = 0x4
|
TCP_KEEPIDLE = 0x4
|
||||||
@@ -2108,6 +2145,21 @@ const (
|
|||||||
TUNSETVNETBE = 0x800454de
|
TUNSETVNETBE = 0x800454de
|
||||||
TUNSETVNETHDRSZ = 0x800454d8
|
TUNSETVNETHDRSZ = 0x800454d8
|
||||||
TUNSETVNETLE = 0x800454dc
|
TUNSETVNETLE = 0x800454dc
|
||||||
|
UBI_IOCATT = 0x80186f40
|
||||||
|
UBI_IOCDET = 0x80046f41
|
||||||
|
UBI_IOCEBCH = 0x80044f02
|
||||||
|
UBI_IOCEBER = 0x80044f01
|
||||||
|
UBI_IOCEBISMAP = 0x40044f05
|
||||||
|
UBI_IOCEBMAP = 0x80084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x80044f04
|
||||||
|
UBI_IOCMKVOL = 0x80986f00
|
||||||
|
UBI_IOCRMVOL = 0x80046f01
|
||||||
|
UBI_IOCRNVOL = 0x91106f03
|
||||||
|
UBI_IOCRSVOL = 0x800c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x80104f06
|
||||||
|
UBI_IOCVOLCRBLK = 0x80804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x20004f08
|
||||||
|
UBI_IOCVOLUP = 0x80084f00
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
@@ -2245,6 +2297,26 @@ const (
|
|||||||
XATTR_CREATE = 0x1
|
XATTR_CREATE = 0x1
|
||||||
XATTR_REPLACE = 0x2
|
XATTR_REPLACE = 0x2
|
||||||
XCASE = 0x4
|
XCASE = 0x4
|
||||||
|
XDP_COPY = 0x2
|
||||||
|
XDP_FLAGS_DRV_MODE = 0x4
|
||||||
|
XDP_FLAGS_HW_MODE = 0x8
|
||||||
|
XDP_FLAGS_MASK = 0xf
|
||||||
|
XDP_FLAGS_MODES = 0xe
|
||||||
|
XDP_FLAGS_SKB_MODE = 0x2
|
||||||
|
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
|
||||||
|
XDP_MMAP_OFFSETS = 0x1
|
||||||
|
XDP_PGOFF_RX_RING = 0x0
|
||||||
|
XDP_PGOFF_TX_RING = 0x80000000
|
||||||
|
XDP_RX_RING = 0x2
|
||||||
|
XDP_SHARED_UMEM = 0x1
|
||||||
|
XDP_STATISTICS = 0x7
|
||||||
|
XDP_TX_RING = 0x3
|
||||||
|
XDP_UMEM_COMPLETION_RING = 0x6
|
||||||
|
XDP_UMEM_FILL_RING = 0x5
|
||||||
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_ZEROCOPY = 0x4
|
||||||
XENFS_SUPER_MAGIC = 0xabba1974
|
XENFS_SUPER_MAGIC = 0xabba1974
|
||||||
XTABS = 0x1800
|
XTABS = 0x1800
|
||||||
ZSMALLOC_MAGIC = 0x58295829
|
ZSMALLOC_MAGIC = 0x58295829
|
||||||
|
|||||||
+74
-2
@@ -64,6 +64,7 @@ const (
|
|||||||
AF_VSOCK = 0x28
|
AF_VSOCK = 0x28
|
||||||
AF_WANPIPE = 0x19
|
AF_WANPIPE = 0x19
|
||||||
AF_X25 = 0x9
|
AF_X25 = 0x9
|
||||||
|
AF_XDP = 0x2c
|
||||||
ALG_OP_DECRYPT = 0x0
|
ALG_OP_DECRYPT = 0x0
|
||||||
ALG_OP_ENCRYPT = 0x1
|
ALG_OP_ENCRYPT = 0x1
|
||||||
ALG_SET_AEAD_ASSOCLEN = 0x4
|
ALG_SET_AEAD_ASSOCLEN = 0x4
|
||||||
@@ -498,6 +499,8 @@ const (
|
|||||||
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
|
||||||
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
|
||||||
FS_ENCRYPTION_MODE_INVALID = 0x0
|
FS_ENCRYPTION_MODE_INVALID = 0x0
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
|
||||||
|
FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
|
||||||
FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
|
FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
|
||||||
FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
|
FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
|
||||||
FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
|
FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
|
||||||
@@ -635,7 +638,7 @@ const (
|
|||||||
IFA_F_STABLE_PRIVACY = 0x800
|
IFA_F_STABLE_PRIVACY = 0x800
|
||||||
IFA_F_TEMPORARY = 0x1
|
IFA_F_TEMPORARY = 0x1
|
||||||
IFA_F_TENTATIVE = 0x40
|
IFA_F_TENTATIVE = 0x40
|
||||||
IFA_MAX = 0x8
|
IFA_MAX = 0x9
|
||||||
IFF_ALLMULTI = 0x200
|
IFF_ALLMULTI = 0x200
|
||||||
IFF_ATTACH_QUEUE = 0x200
|
IFF_ATTACH_QUEUE = 0x200
|
||||||
IFF_AUTOMEDIA = 0x4000
|
IFF_AUTOMEDIA = 0x4000
|
||||||
@@ -762,6 +765,7 @@ const (
|
|||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
IPV6_HOPOPTS = 0x36
|
IPV6_HOPOPTS = 0x36
|
||||||
@@ -954,6 +958,7 @@ const (
|
|||||||
MAP_EXECUTABLE = 0x4000
|
MAP_EXECUTABLE = 0x4000
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
MAP_GROWSDOWN = 0x1000
|
MAP_GROWSDOWN = 0x1000
|
||||||
MAP_HUGETLB = 0x80000
|
MAP_HUGETLB = 0x80000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
@@ -965,11 +970,27 @@ const (
|
|||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
MAP_RENAME = 0x800
|
MAP_RENAME = 0x800
|
||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
|
MAP_SHARED_VALIDATE = 0x3
|
||||||
MAP_STACK = 0x40000
|
MAP_STACK = 0x40000
|
||||||
MAP_TYPE = 0xf
|
MAP_TYPE = 0xf
|
||||||
MCL_CURRENT = 0x1
|
MCL_CURRENT = 0x1
|
||||||
MCL_FUTURE = 0x2
|
MCL_FUTURE = 0x2
|
||||||
MCL_ONFAULT = 0x4
|
MCL_ONFAULT = 0x4
|
||||||
|
MFD_ALLOW_SEALING = 0x2
|
||||||
|
MFD_CLOEXEC = 0x1
|
||||||
|
MFD_HUGETLB = 0x4
|
||||||
|
MFD_HUGE_16GB = -0x78000000
|
||||||
|
MFD_HUGE_16MB = 0x60000000
|
||||||
|
MFD_HUGE_1GB = 0x78000000
|
||||||
|
MFD_HUGE_1MB = 0x50000000
|
||||||
|
MFD_HUGE_256MB = 0x70000000
|
||||||
|
MFD_HUGE_2GB = 0x7c000000
|
||||||
|
MFD_HUGE_2MB = 0x54000000
|
||||||
|
MFD_HUGE_512KB = 0x4c000000
|
||||||
|
MFD_HUGE_64KB = 0x40000000
|
||||||
|
MFD_HUGE_8MB = 0x5c000000
|
||||||
|
MFD_HUGE_MASK = 0x3f
|
||||||
|
MFD_HUGE_SHIFT = 0x1a
|
||||||
MINIX2_SUPER_MAGIC = 0x2468
|
MINIX2_SUPER_MAGIC = 0x2468
|
||||||
MINIX2_SUPER_MAGIC2 = 0x2478
|
MINIX2_SUPER_MAGIC2 = 0x2478
|
||||||
MINIX3_SUPER_MAGIC = 0x4d5a
|
MINIX3_SUPER_MAGIC = 0x4d5a
|
||||||
@@ -1075,6 +1096,8 @@ const (
|
|||||||
NETLINK_UNUSED = 0x1
|
NETLINK_UNUSED = 0x1
|
||||||
NETLINK_USERSOCK = 0x2
|
NETLINK_USERSOCK = 0x2
|
||||||
NETLINK_XFRM = 0x6
|
NETLINK_XFRM = 0x6
|
||||||
|
NETNSA_MAX = 0x3
|
||||||
|
NETNSA_NSID_NOT_ASSIGNED = -0x1
|
||||||
NFNETLINK_V0 = 0x0
|
NFNETLINK_V0 = 0x0
|
||||||
NFNLGRP_ACCT_QUOTA = 0x8
|
NFNLGRP_ACCT_QUOTA = 0x8
|
||||||
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
NFNLGRP_CONNTRACK_DESTROY = 0x3
|
||||||
@@ -1428,6 +1451,9 @@ const (
|
|||||||
RAMFS_MAGIC = 0x858458f6
|
RAMFS_MAGIC = 0x858458f6
|
||||||
RDTGROUP_SUPER_MAGIC = 0x7655821
|
RDTGROUP_SUPER_MAGIC = 0x7655821
|
||||||
REISERFS_SUPER_MAGIC = 0x52654973
|
REISERFS_SUPER_MAGIC = 0x52654973
|
||||||
|
RENAME_EXCHANGE = 0x2
|
||||||
|
RENAME_NOREPLACE = 0x1
|
||||||
|
RENAME_WHITEOUT = 0x4
|
||||||
RLIMIT_AS = 0x6
|
RLIMIT_AS = 0x6
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
@@ -1470,7 +1496,7 @@ const (
|
|||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1a
|
RTA_MAX = 0x1d
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
@@ -1606,17 +1632,22 @@ const (
|
|||||||
RTNH_F_UNRESOLVED = 0x20
|
RTNH_F_UNRESOLVED = 0x20
|
||||||
RTN_MAX = 0xb
|
RTN_MAX = 0xb
|
||||||
RTPROT_BABEL = 0x2a
|
RTPROT_BABEL = 0x2a
|
||||||
|
RTPROT_BGP = 0xba
|
||||||
RTPROT_BIRD = 0xc
|
RTPROT_BIRD = 0xc
|
||||||
RTPROT_BOOT = 0x3
|
RTPROT_BOOT = 0x3
|
||||||
RTPROT_DHCP = 0x10
|
RTPROT_DHCP = 0x10
|
||||||
RTPROT_DNROUTED = 0xd
|
RTPROT_DNROUTED = 0xd
|
||||||
|
RTPROT_EIGRP = 0xc0
|
||||||
RTPROT_GATED = 0x8
|
RTPROT_GATED = 0x8
|
||||||
|
RTPROT_ISIS = 0xbb
|
||||||
RTPROT_KERNEL = 0x2
|
RTPROT_KERNEL = 0x2
|
||||||
RTPROT_MROUTED = 0x11
|
RTPROT_MROUTED = 0x11
|
||||||
RTPROT_MRT = 0xa
|
RTPROT_MRT = 0xa
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
|
RTPROT_OSPF = 0xbc
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
|
RTPROT_RIP = 0xbd
|
||||||
RTPROT_STATIC = 0x4
|
RTPROT_STATIC = 0x4
|
||||||
RTPROT_UNSPEC = 0x0
|
RTPROT_UNSPEC = 0x0
|
||||||
RTPROT_XORP = 0xe
|
RTPROT_XORP = 0xe
|
||||||
@@ -1781,6 +1812,7 @@ const (
|
|||||||
SOL_TIPC = 0x10f
|
SOL_TIPC = 0x10f
|
||||||
SOL_TLS = 0x11a
|
SOL_TLS = 0x11a
|
||||||
SOL_X25 = 0x106
|
SOL_X25 = 0x106
|
||||||
|
SOL_XDP = 0x11b
|
||||||
SOMAXCONN = 0x80
|
SOMAXCONN = 0x80
|
||||||
SO_ACCEPTCONN = 0x1009
|
SO_ACCEPTCONN = 0x1009
|
||||||
SO_ATTACH_BPF = 0x32
|
SO_ATTACH_BPF = 0x32
|
||||||
@@ -1877,6 +1909,9 @@ const (
|
|||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
SYNC_FILE_RANGE_WRITE = 0x2
|
||||||
SYSFS_MAGIC = 0x62656572
|
SYSFS_MAGIC = 0x62656572
|
||||||
S_BLKSIZE = 0x200
|
S_BLKSIZE = 0x200
|
||||||
S_IEXEC = 0x40
|
S_IEXEC = 0x40
|
||||||
@@ -1939,6 +1974,8 @@ const (
|
|||||||
TCP_DEFER_ACCEPT = 0x9
|
TCP_DEFER_ACCEPT = 0x9
|
||||||
TCP_FASTOPEN = 0x17
|
TCP_FASTOPEN = 0x17
|
||||||
TCP_FASTOPEN_CONNECT = 0x1e
|
TCP_FASTOPEN_CONNECT = 0x1e
|
||||||
|
TCP_FASTOPEN_KEY = 0x21
|
||||||
|
TCP_FASTOPEN_NO_COOKIE = 0x22
|
||||||
TCP_INFO = 0xb
|
TCP_INFO = 0xb
|
||||||
TCP_KEEPCNT = 0x6
|
TCP_KEEPCNT = 0x6
|
||||||
TCP_KEEPIDLE = 0x4
|
TCP_KEEPIDLE = 0x4
|
||||||
@@ -2108,6 +2145,21 @@ const (
|
|||||||
TUNSETVNETBE = 0x800454de
|
TUNSETVNETBE = 0x800454de
|
||||||
TUNSETVNETHDRSZ = 0x800454d8
|
TUNSETVNETHDRSZ = 0x800454d8
|
||||||
TUNSETVNETLE = 0x800454dc
|
TUNSETVNETLE = 0x800454dc
|
||||||
|
UBI_IOCATT = 0x80186f40
|
||||||
|
UBI_IOCDET = 0x80046f41
|
||||||
|
UBI_IOCEBCH = 0x80044f02
|
||||||
|
UBI_IOCEBER = 0x80044f01
|
||||||
|
UBI_IOCEBISMAP = 0x40044f05
|
||||||
|
UBI_IOCEBMAP = 0x80084f03
|
||||||
|
UBI_IOCEBUNMAP = 0x80044f04
|
||||||
|
UBI_IOCMKVOL = 0x80986f00
|
||||||
|
UBI_IOCRMVOL = 0x80046f01
|
||||||
|
UBI_IOCRNVOL = 0x91106f03
|
||||||
|
UBI_IOCRSVOL = 0x800c6f02
|
||||||
|
UBI_IOCSETVOLPROP = 0x80104f06
|
||||||
|
UBI_IOCVOLCRBLK = 0x80804f07
|
||||||
|
UBI_IOCVOLRMBLK = 0x20004f08
|
||||||
|
UBI_IOCVOLUP = 0x80084f00
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
@@ -2245,6 +2297,26 @@ const (
|
|||||||
XATTR_CREATE = 0x1
|
XATTR_CREATE = 0x1
|
||||||
XATTR_REPLACE = 0x2
|
XATTR_REPLACE = 0x2
|
||||||
XCASE = 0x4
|
XCASE = 0x4
|
||||||
|
XDP_COPY = 0x2
|
||||||
|
XDP_FLAGS_DRV_MODE = 0x4
|
||||||
|
XDP_FLAGS_HW_MODE = 0x8
|
||||||
|
XDP_FLAGS_MASK = 0xf
|
||||||
|
XDP_FLAGS_MODES = 0xe
|
||||||
|
XDP_FLAGS_SKB_MODE = 0x2
|
||||||
|
XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
|
||||||
|
XDP_MMAP_OFFSETS = 0x1
|
||||||
|
XDP_PGOFF_RX_RING = 0x0
|
||||||
|
XDP_PGOFF_TX_RING = 0x80000000
|
||||||
|
XDP_RX_RING = 0x2
|
||||||
|
XDP_SHARED_UMEM = 0x1
|
||||||
|
XDP_STATISTICS = 0x7
|
||||||
|
XDP_TX_RING = 0x3
|
||||||
|
XDP_UMEM_COMPLETION_RING = 0x6
|
||||||
|
XDP_UMEM_FILL_RING = 0x5
|
||||||
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_ZEROCOPY = 0x4
|
||||||
XENFS_SUPER_MAGIC = 0xabba1974
|
XENFS_SUPER_MAGIC = 0xabba1974
|
||||||
XTABS = 0x1800
|
XTABS = 0x1800
|
||||||
ZSMALLOC_MAGIC = 0x58295829
|
ZSMALLOC_MAGIC = 0x58295829
|
||||||
|
|||||||
Loaded 100 of 221 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user