├── .gitignore
├── .idea
└── workspace.xml
├── .travis.yml
├── LICENSE
├── README.md
├── _config.yml
├── advisors
├── advisors.go
├── all
│ └── all.go
├── disk
│ ├── disk.go
│ ├── disk_test.go
│ └── inode.go
└── tcp
│ ├── tcp.go
│ ├── tcp_ports.go
│ ├── tcp_status.go
│ └── tcp_test.go
├── collectors
├── all
│ └── all.go
├── collectors.go
├── cpu
│ ├── cpu_usage.go
│ └── system_call.go
├── disk
│ ├── disk.go
│ └── disk_test.go
├── memory
│ └── memory.go
├── netstat
│ ├── netstat.go
│ └── netstat_test.go
└── system
│ └── system.go
├── core
├── snout.go
└── version.go
├── coverage.txt
├── resolvers
└── resolvers.go
├── snout
├── snout.go
├── storage
└── memstorage.go
├── test.sh
├── types
├── manager.go
├── metrics.go
└── symptom.go
└── vendor
├── github.com
├── Sirupsen
│ └── logrus
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── alt_exit.go
│ │ ├── doc.go
│ │ ├── entry.go
│ │ ├── exported.go
│ │ ├── formatter.go
│ │ ├── hooks.go
│ │ ├── json_formatter.go
│ │ ├── logger.go
│ │ ├── logrus.go
│ │ ├── terminal_appengine.go
│ │ ├── terminal_bsd.go
│ │ ├── terminal_linux.go
│ │ ├── terminal_notwindows.go
│ │ ├── terminal_solaris.go
│ │ ├── terminal_windows.go
│ │ ├── text_formatter.go
│ │ └── writer.go
├── drael
│ └── GOnetstat
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ └── gonetstat.go
├── fatih
│ └── structs
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── field.go
│ │ ├── structs.go
│ │ └── tags.go
├── lunixbochs
│ ├── ghostrace
│ │ ├── LICENSE
│ │ ├── cli.go
│ │ └── ghost
│ │ │ ├── cli.go
│ │ │ ├── event.go
│ │ │ ├── memio
│ │ │ └── memio.go
│ │ │ ├── process
│ │ │ ├── list.go
│ │ │ ├── process.go
│ │ │ ├── process_darwin.go
│ │ │ └── process_linux.go
│ │ │ ├── sys
│ │ │ ├── call
│ │ │ │ └── call.go
│ │ │ ├── codec.go
│ │ │ ├── enum.go
│ │ │ ├── iovec.go
│ │ │ ├── num
│ │ │ │ ├── darwin_x86_64_mach_sys.go
│ │ │ │ ├── darwin_x86_mach_sys.go
│ │ │ │ ├── darwin_x86_sys.go
│ │ │ │ ├── linux_arm64_sys.go
│ │ │ │ ├── linux_arm_sys.go
│ │ │ │ ├── linux_mips_sys.go
│ │ │ │ ├── linux_x86_64_sys.go
│ │ │ │ └── linux_x86_sys.go
│ │ │ └── syscall.go
│ │ │ └── trace_linux.go
│ └── struc
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── binary.go
│ │ ├── custom.go
│ │ ├── custom_float16.go
│ │ ├── field.go
│ │ ├── fields.go
│ │ ├── legacy.go
│ │ ├── packer.go
│ │ ├── parse.go
│ │ ├── struc.go
│ │ └── types.go
├── mattn
│ └── go-runewidth
│ │ ├── LICENSE
│ │ ├── README.mkd
│ │ ├── runewidth.go
│ │ ├── runewidth_js.go
│ │ ├── runewidth_posix.go
│ │ └── runewidth_windows.go
├── olekukonko
│ └── tablewriter
│ │ ├── LICENCE.md
│ │ ├── README.md
│ │ ├── csv.go
│ │ ├── table.go
│ │ ├── table_with_color.go
│ │ ├── test.csv
│ │ ├── test_info.csv
│ │ ├── util.go
│ │ └── wrap.go
└── ringtail
│ ├── GOnetstat
│ ├── LICENSE.md
│ ├── README.md
│ └── gonetstat.go
│ ├── go-statfs
│ ├── LICENSE
│ ├── README.md
│ └── statfs.go
│ └── sysctl
│ ├── LICENSE
│ ├── README.md
│ └── sysctl.go
├── golang.org
└── x
│ └── sys
│ ├── LICENSE
│ ├── PATENTS
│ └── unix
│ ├── README.md
│ ├── asm_darwin_386.s
│ ├── asm_darwin_amd64.s
│ ├── asm_darwin_arm.s
│ ├── asm_darwin_arm64.s
│ ├── asm_dragonfly_amd64.s
│ ├── asm_freebsd_386.s
│ ├── asm_freebsd_amd64.s
│ ├── asm_freebsd_arm.s
│ ├── asm_linux_386.s
│ ├── asm_linux_amd64.s
│ ├── asm_linux_arm.s
│ ├── asm_linux_arm64.s
│ ├── asm_linux_mips64x.s
│ ├── asm_linux_mipsx.s
│ ├── asm_linux_ppc64x.s
│ ├── asm_linux_s390x.s
│ ├── asm_netbsd_386.s
│ ├── asm_netbsd_amd64.s
│ ├── asm_netbsd_arm.s
│ ├── asm_openbsd_386.s
│ ├── asm_openbsd_amd64.s
│ ├── asm_solaris_amd64.s
│ ├── bluetooth_linux.go
│ ├── constants.go
│ ├── dirent.go
│ ├── endian_big.go
│ ├── endian_little.go
│ ├── env_unix.go
│ ├── env_unset.go
│ ├── flock.go
│ ├── flock_linux_32bit.go
│ ├── gccgo.go
│ ├── gccgo_c.c
│ ├── gccgo_linux_amd64.go
│ ├── gccgo_linux_sparc64.go
│ ├── mkall.sh
│ ├── mkerrors.sh
│ ├── mkpost.go
│ ├── mksyscall.pl
│ ├── mksyscall_solaris.pl
│ ├── mksysctl_openbsd.pl
│ ├── mksysnum_darwin.pl
│ ├── mksysnum_dragonfly.pl
│ ├── mksysnum_freebsd.pl
│ ├── mksysnum_netbsd.pl
│ ├── mksysnum_openbsd.pl
│ ├── openbsd_pledge.go
│ ├── race.go
│ ├── race0.go
│ ├── sockcmsg_linux.go
│ ├── sockcmsg_unix.go
│ ├── str.go
│ ├── syscall.go
│ ├── syscall_bsd.go
│ ├── syscall_darwin.go
│ ├── syscall_darwin_386.go
│ ├── syscall_darwin_amd64.go
│ ├── syscall_darwin_arm.go
│ ├── syscall_darwin_arm64.go
│ ├── syscall_dragonfly.go
│ ├── syscall_dragonfly_amd64.go
│ ├── syscall_freebsd.go
│ ├── syscall_freebsd_386.go
│ ├── syscall_freebsd_amd64.go
│ ├── syscall_freebsd_arm.go
│ ├── syscall_linux.go
│ ├── syscall_linux_386.go
│ ├── syscall_linux_amd64.go
│ ├── syscall_linux_amd64_gc.go
│ ├── syscall_linux_arm.go
│ ├── syscall_linux_arm64.go
│ ├── syscall_linux_mips64x.go
│ ├── syscall_linux_mipsx.go
│ ├── syscall_linux_ppc64x.go
│ ├── syscall_linux_s390x.go
│ ├── syscall_linux_sparc64.go
│ ├── syscall_netbsd.go
│ ├── syscall_netbsd_386.go
│ ├── syscall_netbsd_amd64.go
│ ├── syscall_netbsd_arm.go
│ ├── syscall_no_getwd.go
│ ├── syscall_openbsd.go
│ ├── syscall_openbsd_386.go
│ ├── syscall_openbsd_amd64.go
│ ├── syscall_solaris.go
│ ├── syscall_solaris_amd64.go
│ ├── syscall_unix.go
│ ├── syscall_unix_gc.go
│ ├── types_darwin.go
│ ├── types_dragonfly.go
│ ├── types_freebsd.go
│ ├── types_netbsd.go
│ ├── types_openbsd.go
│ ├── types_solaris.go
│ ├── zerrors_darwin_386.go
│ ├── zerrors_darwin_amd64.go
│ ├── zerrors_darwin_arm.go
│ ├── zerrors_darwin_arm64.go
│ ├── zerrors_dragonfly_amd64.go
│ ├── zerrors_freebsd_386.go
│ ├── zerrors_freebsd_amd64.go
│ ├── zerrors_freebsd_arm.go
│ ├── zerrors_linux_386.go
│ ├── zerrors_linux_amd64.go
│ ├── zerrors_linux_arm.go
│ ├── zerrors_linux_arm64.go
│ ├── zerrors_linux_mips.go
│ ├── zerrors_linux_mips64.go
│ ├── zerrors_linux_mips64le.go
│ ├── zerrors_linux_mipsle.go
│ ├── zerrors_linux_ppc64.go
│ ├── zerrors_linux_ppc64le.go
│ ├── zerrors_linux_s390x.go
│ ├── zerrors_linux_sparc64.go
│ ├── zerrors_netbsd_386.go
│ ├── zerrors_netbsd_amd64.go
│ ├── zerrors_netbsd_arm.go
│ ├── zerrors_openbsd_386.go
│ ├── zerrors_openbsd_amd64.go
│ ├── zerrors_solaris_amd64.go
│ ├── zsyscall_darwin_386.go
│ ├── zsyscall_darwin_amd64.go
│ ├── zsyscall_darwin_arm.go
│ ├── zsyscall_darwin_arm64.go
│ ├── zsyscall_dragonfly_amd64.go
│ ├── zsyscall_freebsd_386.go
│ ├── zsyscall_freebsd_amd64.go
│ ├── zsyscall_freebsd_arm.go
│ ├── zsyscall_linux_386.go
│ ├── zsyscall_linux_amd64.go
│ ├── zsyscall_linux_arm.go
│ ├── zsyscall_linux_arm64.go
│ ├── zsyscall_linux_mips.go
│ ├── zsyscall_linux_mips64.go
│ ├── zsyscall_linux_mips64le.go
│ ├── zsyscall_linux_mipsle.go
│ ├── zsyscall_linux_ppc64.go
│ ├── zsyscall_linux_ppc64le.go
│ ├── zsyscall_linux_s390x.go
│ ├── zsyscall_linux_sparc64.go
│ ├── zsyscall_netbsd_386.go
│ ├── zsyscall_netbsd_amd64.go
│ ├── zsyscall_netbsd_arm.go
│ ├── zsyscall_openbsd_386.go
│ ├── zsyscall_openbsd_amd64.go
│ ├── zsyscall_solaris_amd64.go
│ ├── zsysctl_openbsd.go
│ ├── zsysnum_darwin_386.go
│ ├── zsysnum_darwin_amd64.go
│ ├── zsysnum_darwin_arm.go
│ ├── zsysnum_darwin_arm64.go
│ ├── zsysnum_dragonfly_amd64.go
│ ├── zsysnum_freebsd_386.go
│ ├── zsysnum_freebsd_amd64.go
│ ├── zsysnum_freebsd_arm.go
│ ├── zsysnum_linux_386.go
│ ├── zsysnum_linux_amd64.go
│ ├── zsysnum_linux_arm.go
│ ├── zsysnum_linux_arm64.go
│ ├── zsysnum_linux_mips.go
│ ├── zsysnum_linux_mips64.go
│ ├── zsysnum_linux_mips64le.go
│ ├── zsysnum_linux_mipsle.go
│ ├── zsysnum_linux_ppc64.go
│ ├── zsysnum_linux_ppc64le.go
│ ├── zsysnum_linux_s390x.go
│ ├── zsysnum_linux_sparc64.go
│ ├── zsysnum_netbsd_386.go
│ ├── zsysnum_netbsd_amd64.go
│ ├── zsysnum_netbsd_arm.go
│ ├── zsysnum_openbsd_386.go
│ ├── zsysnum_openbsd_amd64.go
│ ├── zsysnum_solaris_amd64.go
│ ├── ztypes_darwin_386.go
│ ├── ztypes_darwin_amd64.go
│ ├── ztypes_darwin_arm.go
│ ├── ztypes_darwin_arm64.go
│ ├── ztypes_dragonfly_amd64.go
│ ├── ztypes_freebsd_386.go
│ ├── ztypes_freebsd_amd64.go
│ ├── ztypes_freebsd_arm.go
│ ├── ztypes_linux_386.go
│ ├── ztypes_linux_amd64.go
│ ├── ztypes_linux_arm.go
│ ├── ztypes_linux_arm64.go
│ ├── ztypes_linux_mips.go
│ ├── ztypes_linux_mips64.go
│ ├── ztypes_linux_mips64le.go
│ ├── ztypes_linux_mipsle.go
│ ├── ztypes_linux_ppc64.go
│ ├── ztypes_linux_ppc64le.go
│ ├── ztypes_linux_s390x.go
│ ├── ztypes_linux_sparc64.go
│ ├── ztypes_netbsd_386.go
│ ├── ztypes_netbsd_amd64.go
│ ├── ztypes_netbsd_arm.go
│ ├── ztypes_openbsd_386.go
│ ├── ztypes_openbsd_amd64.go
│ └── ztypes_solaris_amd64.go
└── vendor.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 | .idea
6 | # C extensions
7 | *.so
8 | snout
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 |
49 | # Translations
50 | *.mo
51 | *.pot
52 |
53 | # Django stuff:
54 | *.log
55 | local_settings.py
56 |
57 | # Flask stuff:
58 | instance/
59 | .webassets-cache
60 |
61 | # Scrapy stuff:
62 | .scrapy
63 |
64 | # Sphinx documentation
65 | docs/_build/
66 |
67 | # PyBuilder
68 | target/
69 |
70 | # Jupyter Notebook
71 | .ipynb_checkpoints
72 |
73 | # pyenv
74 | .python-version
75 |
76 | # celery beat schedule file
77 | celerybeat-schedule
78 |
79 | # SageMath parsed files
80 | *.sage.py
81 |
82 | # dotenv
83 | .env
84 |
85 | # virtualenv
86 | .venv
87 | venv/
88 | ENV/
89 |
90 | # Spyder project settings
91 | .spyderproject
92 | .spyproject
93 |
94 | # Rope project settings
95 | .ropeproject
96 |
97 | # mkdocs documentation
98 | /site
99 |
100 | # mypy
101 | .mypy_cache/
102 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | install: true
3 | sudo: required
4 | go:
5 | - 1.7
6 | - 1.8
7 | - 1.9
8 | - master
9 | script:
10 | - ./test.sh
11 | after_success:
12 | - bash <(curl -s https://codecov.io/bash)
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # snout
2 |
3 |
4 |
sniff bad smell about performance
5 |
6 |
7 | [](https://travis-ci.org/ringtail/snout)
8 | [](https://codecov.io/gh/ringtail/snout)
9 | [](https://www.apache.org/licenses/LICENSE-2.0.html)
10 |
11 | # What is snout
12 |
13 | snout is command line tool to collect system metrics and give you some advice about performance
14 |
15 | # Usage
16 |
17 | Download snout with command `wget https://snout.oss-cn-beijing.aliyuncs.com/snout`,run `chmod +x snout` and then run snout with sudo
18 |
19 | ```
20 | =====================================================
21 |
22 | ███████╗███╗ ██╗ ██████╗ ██╗ ██╗████████╗
23 | ██╔════╝████╗ ██║██╔═══██╗██║ ██║╚══██╔══╝
24 | ███████╗██╔██╗ ██║██║ ██║██║ ██║ ██║
25 | ╚════██║██║╚██╗██║██║ ██║██║ ██║ ██║
26 | ███████║██║ ╚████║╚██████╔╝╚██████╔╝ ██║
27 | ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝
28 |
29 | snout is tool to improve your system performance
30 | =====================================================
31 |
32 |
33 | Usage:
34 | snout [commands|flags]
35 |
36 | The commands & flags are:
37 | help print snout help
38 | version print the version to stdout
39 | --debug switch on debug mode
40 |
41 | Examples:
42 | # start in normal mode
43 | snout
44 |
45 | # start in debug mode
46 | snout --debug
47 | ```
48 | # TIME_WAIT DEMO
49 | ```
50 | +--------------------+--------------------------------+----------------------------------------------------------------------------------+
51 | | SYMPTOM | DESCRIPTION | ADVISES |
52 | +--------------------+--------------------------------+----------------------------------------------------------------------------------+
53 | | TIME_WAIT_TOO_MUCH | tcp connection state | You can reuse tcp connection by set `keepalive` in http client,set |
54 | | | `TIME_WAIT` is too much, | `fastcgi_keep_conn` in php-fpm settings |
55 | | | current amount is 23 | |
56 | + + +----------------------------------------------------------------------------------+
57 | | | | You can accelerate the `TIME_WAIT` connection recycle by sysctl: sysclt -w |
58 | | | | net.ipv4.tcp_syncookies = 1;sysclt -w net.ipv4.tcp_tw_reuse = 1;sysclt -w |
59 | | | | net.ipv4.tcp_tw_recycle = 1;sysclt -w net.ipv4.tcp_fin_timeout = 30 |
60 | +--------------------+--------------------------------+----------------------------------------------------------------------------------+
61 | ```
62 |
63 | # Symptom Support
64 | * tcp stack analysis
65 | * disk usage analysis
66 | * inode usage analysis
67 | * network ports usage analysis
68 |
69 | # Related Project
70 | `statfs(df)` implement in golang (https://github.com/ringtail/go-statfs)
71 | `sysctl` implement in golang (https://github.com/ringtail/sysctl)
72 | `netstat` implement in golang (https://github.com/ringtail/GOnetstat)
73 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/advisors/advisors.go:
--------------------------------------------------------------------------------
1 | package advisors
2 |
3 | import (
4 | "github.com/ringtail/snout/types"
5 | )
6 |
7 | type AdvisorInterface interface {
8 | Name() string
9 | Description() string
10 | Advise() []types.Symptom
11 | }
12 |
13 | type AdvisorsManager struct {
14 | Advisors map[string]AdvisorInterface
15 | }
16 |
17 | func (am *AdvisorsManager) Find(name string) AdvisorInterface {
18 | return am.Advisors[name]
19 | }
20 |
21 | func (am *AdvisorsManager) Add(name string, adi AdvisorInterface) {
22 | am.Advisors[name] = adi
23 | }
24 |
25 | func (am *AdvisorsManager) Empty() bool {
26 | return false
27 | }
28 |
29 | func (am *AdvisorsManager) Start(names ...string) {
30 | dra := types.DefaultDiagnosticReport{}
31 | if len(names) == 0 {
32 | for _, advisor := range am.Advisors {
33 | symptoms := advisor.Advise()
34 | dra.Add(symptoms)
35 | }
36 | } else {
37 | for _, name := range names {
38 | advisor := am.Find(name)
39 | symptoms := advisor.Advise()
40 | dra.Add(symptoms)
41 | }
42 | }
43 | dra.Print()
44 | }
45 |
46 | var Am *AdvisorsManager
47 |
48 | func init() {
49 | Am = &AdvisorsManager{}
50 | Am.Advisors = make(map[string]AdvisorInterface)
51 | }
52 |
53 | func Add(ad AdvisorInterface) {
54 | name := ad.Name()
55 | if name == "" {
56 | return
57 | }
58 | Am.Add(name, ad)
59 | }
60 |
--------------------------------------------------------------------------------
/advisors/all/all.go:
--------------------------------------------------------------------------------
1 | package all
2 |
3 | import (
4 | _ "github.com/ringtail/snout/advisors/tcp"
5 | _ "github.com/ringtail/snout/advisors/disk"
6 | )
7 |
--------------------------------------------------------------------------------
/advisors/disk/disk.go:
--------------------------------------------------------------------------------
1 | package disk
2 |
3 | import (
4 | "github.com/ringtail/snout/storage"
5 | "github.com/ringtail/snout/types"
6 | "github.com/ringtail/snout/advisors"
7 | )
8 |
9 | const (
10 | DISK_ADVISOR = "DISK_ADVISOR"
11 | )
12 |
13 | //TODO
14 | type DiskAdvisor struct{}
15 |
16 | func (da *DiskAdvisor) Name() string {
17 | return DISK_ADVISOR
18 | }
19 |
20 | func (da *DiskAdvisor) Description() string {
21 | return ""
22 | }
23 |
24 | func (da *DiskAdvisor) Advise() []types.Symptom {
25 | tree := storage.InternalMetricsTree
26 | symptoms := make([]types.Symptom, 0)
27 |
28 | if inode_symptom := GetInodeSymptom(tree); inode_symptom != nil {
29 | symptoms = append(symptoms, inode_symptom)
30 | }
31 | return symptoms
32 | }
33 |
34 | func init() {
35 | da := &DiskAdvisor{}
36 | advisors.Add(da)
37 | }
38 |
--------------------------------------------------------------------------------
/advisors/disk/disk_test.go:
--------------------------------------------------------------------------------
1 | package disk
2 |
3 | import (
4 | "testing"
5 | "github.com/ringtail/snout/storage"
6 | "github.com/ringtail/snout/types"
7 | "github.com/ringtail/snout/collectors"
8 | "github.com/ringtail/snout/collectors/disk"
9 | )
10 |
11 | var (
12 | Metrics_tree *storage.MetricsTree
13 | )
14 |
15 | func init() {
16 | Metrics_tree = &storage.MetricsTree{}
17 | Metrics_tree.MetricsSection = make(map[string]types.MetricsSection)
18 | ds, _ := collectors.Cm.Find(disk.DISK_STATUS).Gather()
19 | Metrics_tree.AddSection(ds)
20 | }
21 |
22 | func Test_DiskAdvisor_Name(t *testing.T) {
23 | da := &DiskAdvisor{}
24 | if da.Name() == DISK_ADVISOR {
25 | t.Logf("pass Test_DiskAdvisor_Name")
26 | return
27 | }
28 | t.Error("Failed to pass Test_DiskAdvisor_Name")
29 | }
30 |
31 | func Test_DiskAdvisor_Advise(t *testing.T) {
32 | da := &DiskAdvisor{}
33 | symptoms := da.Advise()
34 | if len(symptoms) == 0 {
35 | t.Skipf("pass Test_DiskAdvisor_Advise because of not enough metrics")
36 | return
37 | }
38 | t.Log("pass Test_DiskAdvisor_Advise")
39 | }
40 |
41 | func Test_GetInodeSymptom(t *testing.T) {
42 | inode_symptom := GetInodeSymptom(Metrics_tree)
43 | if inode_symptom == nil {
44 | t.Skipf("pass Test_GetInodeSymptom because of not enough metrics")
45 | return
46 | }
47 | t.Log("pass Test_GetInodeSymptom")
48 | }
49 |
--------------------------------------------------------------------------------
/advisors/disk/inode.go:
--------------------------------------------------------------------------------
1 | package disk
2 |
3 | import (
4 | "github.com/ringtail/snout/types"
5 | "github.com/ringtail/snout/storage"
6 | "github.com/ringtail/snout/collectors/disk"
7 | log "github.com/Sirupsen/logrus"
8 | "strconv"
9 | "fmt"
10 | )
11 |
12 | const (
13 | INODE_THRESHOLD = 0.8
14 | INODE_USAGE_SYMPTOM = "INODE_USAGE_SYMPTOM"
15 | )
16 |
17 | func GetInodeSymptom(metrics_tree *storage.MetricsTree) types.Symptom {
18 | disk_status := metrics_tree.FindSection(disk.DISK_STATUS)
19 | if disk_status == nil {
20 | log.Warnf("Failed to get disk status from metrics storage.")
21 | return nil
22 | }
23 | inodeUsed, _ := strconv.Atoi(disk_status.Find("InodesUsed"))
24 | inodeAll, _ := strconv.Atoi(disk_status.Find("Inodes"))
25 | log.Debug(inodeUsed, inodeAll)
26 | if (float32(inodeUsed) / float32(inodeAll)) > INODE_THRESHOLD {
27 | desc := fmt.Sprintf("Current system can have %d inodes, but used %d inodes", inodeAll, inodeUsed)
28 | adviseDescs := []string{
29 | "The inode is a data structure in a Unix-style file system that describes a " +
30 | "filesystem object such as a file or a directory.Maybe you have too much fragment files",
31 |
32 | "You can use `sysctl -w vm.vfs_cache_pressure=200`.default value is 100, 100 means kernel's reclaim" +
33 | " thememory versus pagecache and swap. Increasing this value increases the rate at which VFS caches are reclaimed",
34 |
35 | "You can also enlarge the inode settings by remount disk,But we strongly suggest you not to do it.",
36 | }
37 | inode_usage_symptom := types.CreateTextDefaultSymptom(INODE_USAGE_SYMPTOM, desc, adviseDescs)
38 | return inode_usage_symptom
39 | }
40 | return nil
41 | }
42 |
--------------------------------------------------------------------------------
/advisors/tcp/tcp.go:
--------------------------------------------------------------------------------
1 | package tcp
2 |
3 | import (
4 | "github.com/ringtail/snout/advisors"
5 | "github.com/ringtail/snout/storage"
6 | "github.com/ringtail/snout/types"
7 | )
8 |
9 | func init() {
10 | ta := &TcpAdvisor{}
11 | advisors.Add(ta)
12 | }
13 |
14 | var (
15 | TCP_ADVISOR = "TCP_ADVISOR"
16 | TIME_WAIT_TOO_MUCH_SYMPTOM = "TIME_WAIT_TOO_MUCH"
17 | CLOSE_WAIT_TOO_MUCH_SYMPTOM = "CLOSE_WAIT_TOO_MUCH"
18 | SYN_SENT_TOO_MUCH_SYMPTOM = "SYN_SENT_TOO_MUCH"
19 | PORTS_USAGE_TOO_MUCH_SYMPTOM = "PORTS_USAGE_TOO_MUCH"
20 | )
21 |
22 | const (
23 | MAX_TIME_OUT_CONNECTION = 20
24 | MAX_CLOSE_WAIT_CONNECTION = 20
25 | MAX_SYN_SENT_CONNECTION = 10
26 | )
27 |
28 | type TcpAdvisor struct {
29 | }
30 |
31 | func (ta *TcpAdvisor) Name() string {
32 | return TCP_ADVISOR
33 | }
34 |
35 | func (ta *TcpAdvisor) Description() string {
36 | return ""
37 | }
38 |
39 | func (ta *TcpAdvisor) Advise() []types.Symptom {
40 | tree := storage.InternalMetricsTree
41 | symptoms := make([]types.Symptom, 0)
42 | if time_wait_sympton := GetTimeWaitSymptom(tree); time_wait_sympton != nil {
43 | symptoms = append(symptoms, time_wait_sympton)
44 | }
45 |
46 | if close_wait_sympton := GetCloseWaitSymptom(tree); close_wait_sympton != nil {
47 | symptoms = append(symptoms, close_wait_sympton)
48 | }
49 |
50 | if port_range_symptom := GetPortRangeSymptom(tree); port_range_symptom != nil {
51 | symptoms = append(symptoms, port_range_symptom)
52 | }
53 |
54 | if syn_sent_symptom := GetSynSentSymptom(tree); syn_sent_symptom != nil {
55 | symptoms = append(symptoms, syn_sent_symptom)
56 | }
57 | return symptoms
58 | }
59 |
--------------------------------------------------------------------------------
/advisors/tcp/tcp_ports.go:
--------------------------------------------------------------------------------
1 | package tcp
2 |
3 | import (
4 | "fmt"
5 | "github.com/ringtail/snout/collectors/netstat"
6 | "github.com/ringtail/snout/collectors/system"
7 | "github.com/ringtail/snout/storage"
8 | "github.com/ringtail/snout/types"
9 | "strconv"
10 | "strings"
11 | )
12 |
13 | func GetPortRangeSymptom(metrics_tree *storage.MetricsTree) types.Symptom {
14 | kernel_settings := metrics_tree.FindSection(system.KERNEL_SETTINGS)
15 | netstat_status := metrics_tree.FindSection(netstat.NETSTAT_STATUS)
16 | ports_total_range := kernel_settings.Find("net.ipv4.ip_local_port_range")
17 | if ports_total_range != "" {
18 | n := 1
19 | ports_total_range_slim := strings.TrimFunc(ports_total_range, func(r rune) bool {
20 | if r == ' ' {
21 | if n == 1 {
22 | n = n + 1
23 | return false
24 | }
25 | return true
26 | }
27 | return false
28 | })
29 |
30 | ports_total_arr := strings.Split(ports_total_range_slim, " ")
31 | max, _ := strconv.Atoi(ports_total_arr[1])
32 | min, _ := strconv.Atoi(ports_total_arr[0])
33 |
34 | ports_total := max - min
35 | ports_usage, _ := strconv.Atoi(netstat_status.Find("PORTS_USAGE"))
36 | if float32(ports_usage) > 0.8*float32(ports_total) {
37 | desc := fmt.Sprintf("Current system ports range is between %s, but ports total usage is %v", ports_total_range, ports_usage)
38 | adviseDescs := []string{
39 | "Ports Usage too much means connections is too much,Please check connection status is in normal status " +
40 | "by `netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' ` ",
41 |
42 | "Please check weather your application has too much 504 or 502 timeout in logs, " +
43 | "You can also increase port range by `sudo sysctl -w net.ipv4.ip_local_port_range=\"min_port_num max_port_num\"`",
44 | }
45 | ports_usage_symptom := types.CreateTextDefaultSymptom(PORTS_USAGE_TOO_MUCH_SYMPTOM, desc, adviseDescs)
46 | return ports_usage_symptom
47 | }
48 | }
49 | return nil
50 | }
--------------------------------------------------------------------------------
/advisors/tcp/tcp_status.go:
--------------------------------------------------------------------------------
1 | package tcp
2 |
3 | import (
4 | "fmt"
5 | "github.com/ringtail/snout/collectors/netstat"
6 | "github.com/ringtail/snout/storage"
7 | "github.com/ringtail/snout/types"
8 | "strconv"
9 | )
10 |
11 | func GetTimeWaitSymptom(metrics_tree *storage.MetricsTree) types.Symptom {
12 | netstat_status := metrics_tree.FindSection(netstat.NETSTAT_STATUS)
13 | time_wait_num, _ := strconv.Atoi(netstat_status.Find("TIME_WAIT"))
14 | if time_wait_num > MAX_TIME_OUT_CONNECTION {
15 | desc := fmt.Sprintf("tcp connection state `TIME_WAIT` is too much, current amount is %d", time_wait_num)
16 | adviseDescs := []string{
17 | "`TIME_WAIT` means the client initiative close the connection and wait the stack to recycle or reuse the " +
18 | "connection, Maybe you use short connection in http client",
19 |
20 | "You can reuse tcp connection by set `keepalive` in http client,set `fastcgi_keep_conn` in php-fpm settings",
21 |
22 | "You can accelerate the `TIME_WAIT` connection recycle by sysctl: sysclt -w net.ipv4.tcp_syncookies = 1;" +
23 | "sysclt -w net.ipv4.tcp_tw_reuse = 1; sysclt -w net.ipv4.tcp_tw_recycle = 1; sysclt -w net.ipv4.tcp_fin_timeout = 30",
24 | }
25 | time_wait_symptom := types.CreateTextDefaultSymptom(TIME_WAIT_TOO_MUCH_SYMPTOM, desc, adviseDescs)
26 | return time_wait_symptom
27 | }
28 | return nil
29 | }
30 |
31 | func GetCloseWaitSymptom(metrics_tree *storage.MetricsTree) types.Symptom {
32 | netstat_status := metrics_tree.FindSection(netstat.NETSTAT_STATUS)
33 | close_wait_num, _ := strconv.Atoi(netstat_status.Find("CLOSE_WAIT"))
34 | if close_wait_num > MAX_CLOSE_WAIT_CONNECTION {
35 | desc := fmt.Sprintf("tcp connection state `CLOSE_WAIT` is too much, current amount is %d", close_wait_num)
36 | adviseDescs := []string{
37 | "`CLOSE_WAIT` means some other application close the connection but you don't receive a fin pocket," +
38 | "You can check the api provider and close the connection timely",
39 |
40 | "`CLOSE_WAIT` could also occur when you client doesn't close response in http client.",
41 | }
42 | close_wait_symptom := types.CreateTextDefaultSymptom(CLOSE_WAIT_TOO_MUCH_SYMPTOM, desc, adviseDescs)
43 | return close_wait_symptom
44 | }
45 | return nil
46 | }
47 |
48 | func GetSynSentSymptom(metrics_tree *storage.MetricsTree) types.Symptom {
49 | netstat_status := metrics_tree.FindSection(netstat.NETSTAT_STATUS)
50 | syn_sent_num, _ := strconv.Atoi(netstat_status.Find("SYN_SENT"))
51 | if syn_sent_num > MAX_SYN_SENT_CONNECTION {
52 | desc := fmt.Sprintf("tcp connection state `SYN_SENT` is too much, current amount is %d", syn_sent_num)
53 | adviseDescs := []string{
54 | "`SYN_SENT` is a very short status for tcp connection. It will occur before a connection,too much `SYN_SENT` means " +
55 | "Your client send too much request to different domain or ip. Please check weather your pc is hijacked by hacker",
56 | "`SYN_SENT` also occur when you create too much requests to a invalid domain or the target network is too slow",
57 | }
58 | syn_sent_symptom := types.CreateTextDefaultSymptom(SYN_SENT_TOO_MUCH_SYMPTOM, desc, adviseDescs)
59 | return syn_sent_symptom
60 | }
61 | return nil
62 | }
63 |
--------------------------------------------------------------------------------
/advisors/tcp/tcp_test.go:
--------------------------------------------------------------------------------
1 | package tcp
2 |
3 | import (
4 | "testing"
5 | "github.com/ringtail/snout/storage"
6 | "github.com/ringtail/snout/types"
7 | "github.com/ringtail/snout/collectors"
8 | "github.com/ringtail/snout/collectors/system"
9 | "github.com/ringtail/snout/collectors/netstat"
10 | )
11 |
12 | var (
13 | Metrics_tree *storage.MetricsTree
14 | )
15 |
16 | func init() {
17 | Metrics_tree = &storage.MetricsTree{}
18 | Metrics_tree.MetricsSection = make(map[string]types.MetricsSection)
19 | ks, _ := collectors.Cm.Find(system.KERNEL_SETTINGS).Gather()
20 | Metrics_tree.AddSection(ks)
21 | nt, _ := collectors.Cm.Find(netstat.NETSTAT_STATUS).Gather()
22 | Metrics_tree.AddSection(nt)
23 | }
24 |
25 | func TestGetCloseWaitSymptom(t *testing.T) {
26 | symptom := GetCloseWaitSymptom(Metrics_tree)
27 | if symptom != nil {
28 | t.Logf("pass GetCloseWaitSymptom: %s %s", symptom.GetName(), symptom.GetDescription())
29 | }
30 | t.Skipf("pass GetCloseWaitSymptom, because not enough metrics")
31 | }
32 |
33 | func TestGetTimeWaitSymptom(t *testing.T) {
34 | symptom := GetTimeWaitSymptom(Metrics_tree)
35 | if symptom != nil {
36 | t.Logf("pass TestGetTimeWaitSymptom: %s %s", symptom.GetName(), symptom.GetDescription())
37 | }
38 | t.Skipf("pass TestGetTimeWaitSymptom, because not enough metrics")
39 | }
40 |
41 | func TestGetPortRangeSymptom(t *testing.T) {
42 | symptom := GetPortRangeSymptom(Metrics_tree)
43 | if symptom != nil {
44 | t.Logf("pass TestGetPortRangeSymptom: %s %s", symptom.GetName(), symptom.GetDescription())
45 | }
46 | t.Skipf("pass TestGetPortRangeSymptom, because not enough metrics")
47 | }
48 |
--------------------------------------------------------------------------------
/collectors/all/all.go:
--------------------------------------------------------------------------------
1 | package all
2 |
3 | import (
4 | _ "github.com/ringtail/snout/collectors/netstat"
5 | _ "github.com/ringtail/snout/collectors/system"
6 | _ "github.com/ringtail/snout/collectors/memory"
7 | _ "github.com/ringtail/snout/collectors/cpu"
8 | _ "github.com/ringtail/snout/collectors/disk"
9 | )
10 |
--------------------------------------------------------------------------------
/collectors/collectors.go:
--------------------------------------------------------------------------------
1 | package collectors
2 |
3 | import (
4 | log "github.com/Sirupsen/logrus"
5 | "github.com/ringtail/snout/storage"
6 | "github.com/ringtail/snout/types"
7 | "sync"
8 | )
9 |
10 | type CollectorInterface interface {
11 | Name() string
12 | Description() string
13 | Gather() (types.MetricsSection, error)
14 | }
15 |
16 | type CollectionManager struct {
17 | Collectors map[string]CollectorInterface
18 | }
19 |
20 | func (cm *CollectionManager) Empty() bool {
21 | return false
22 | }
23 |
24 | func (cm *CollectionManager) Add(ci CollectorInterface) {
25 | if ci.Name() == "" {
26 | return
27 | }
28 | cm.Collectors[ci.Name()] = ci
29 | }
30 |
31 | func (cm *CollectionManager) Find(name string) CollectorInterface {
32 | return cm.Collectors[name]
33 | }
34 |
35 | func (cm *CollectionManager) Start(names ...string) {
36 | var wg sync.WaitGroup
37 | if len(names) == 0 {
38 | for index, _ := range cm.Collectors {
39 | ci := cm.Collectors[index]
40 | wg.Add(1)
41 | go func(collectorInterface CollectorInterface) {
42 | defer wg.Done()
43 | ms, err := ci.Gather()
44 | if err != nil {
45 | log.Warnf("[%s] Failed to gather metrics,because of %v", ci.Name(), err.Error())
46 | return
47 | }
48 | storage.InternalMetricsTree.AddSection(ms)
49 | }(ci)
50 | }
51 | } else {
52 | for _, name := range names {
53 | wg.Add(1)
54 | go func() {
55 | defer wg.Done()
56 | ci := cm.Find(name)
57 | if ci != nil {
58 | ms, err := ci.Gather()
59 | if err != nil {
60 | log.Warnf("[%s] Failed to gather metrics,because of %v", ci.Name(), err.Error())
61 | return
62 | }
63 | storage.InternalMetricsTree.AddSection(ms)
64 | }
65 | }()
66 | }
67 | }
68 | wg.Wait()
69 | }
70 |
71 | var Cm *CollectionManager
72 |
73 | func init() {
74 | Cm = &CollectionManager{}
75 | Cm.Collectors = make(map[string]CollectorInterface, 0)
76 | }
77 |
78 | func Add(ci CollectorInterface) {
79 | Cm.Add(ci)
80 | }
81 |
--------------------------------------------------------------------------------
/collectors/cpu/cpu_usage.go:
--------------------------------------------------------------------------------
1 | package cpu
2 |
3 | import (
4 | "github.com/ringtail/snout/collectors"
5 | log "github.com/Sirupsen/logrus"
6 | "github.com/ringtail/snout/types"
7 | "strconv"
8 | "os/exec"
9 | "bytes"
10 | "strings"
11 | "fmt"
12 | )
13 |
14 | const (
15 | CPU_USAGE_SETTING = "CPU_USAGE"
16 |
17 | CPU_USAGE_THRESHOLD = 70
18 | )
19 |
20 | func init() {
21 | sc := &CPUCollector{}
22 | collectors.Add(sc)
23 | }
24 |
25 | type CPUCollector struct{}
26 |
27 | func (sc *CPUCollector) Name() string {
28 | return CPU_USAGE_SETTING
29 | }
30 |
31 | func (sc *CPUCollector) Description() string {
32 | return "Gather cpu usage from ps aux"
33 | }
34 |
35 | type CPUMetricsSection struct {
36 |
37 | Name string
38 | Metrics map[string]string
39 | }
40 |
41 | func (sc *CPUCollector) Gather() (types.MetricsSection, error) {
42 | cpuUsage := GatherAllProcessCpuUsage()
43 | return &types.DefaultMetricsSection{
44 | Name: CPU_USAGE_SETTING,
45 | Metrics: convertCPUToStringMap(cpuUsage),
46 | }, nil
47 | }
48 |
49 |
50 |
51 | func GatherAllProcessCpuUsage() map[string] float64{
52 | cmd := exec.Command("ps", "aux")
53 | var out bytes.Buffer
54 | cmd.Stdout = &out
55 | err := cmd.Run()
56 | if err != nil {
57 | log.Fatal(err)
58 | return nil
59 | }
60 | processCPUUsages := make(map[string]float64)
61 | // Skip first line
62 | out.ReadString('\n')
63 | for {
64 | line, err := out.ReadString('\n')
65 | if err!=nil {
66 | break;
67 | }
68 | tokens := strings.Split(line, " ")
69 | ft := make([]string, 0)
70 | for _, t := range(tokens) {
71 | if t!="" && t!="\t" {
72 | ft = append(ft, t)
73 | }
74 | }
75 | pidStr := ft[1]
76 | _, err = strconv.Atoi(pidStr)
77 | if err != nil {
78 | log.Errorf("Failed to parse pid from %s", ft[1])
79 | continue
80 | }
81 | cpu, err := strconv.ParseFloat(ft[2], 64)
82 | if err != nil {
83 | log.Errorf("Failed to parse pid cpu usage from %s", ft[2])
84 | }
85 | processCPUUsages[pidStr] = cpu
86 |
87 | }
88 | return processCPUUsages
89 | }
90 |
91 | func convertCPUToStringMap(processCPU map[string] float64) map[string] string {
92 | processCPUString := make(map[string]string)
93 | for pid, cpu := range processCPU {
94 | if cpu > CPU_USAGE_THRESHOLD {
95 | processCPUString[pid] = fmt.Sprintf("%f", cpu)
96 | }
97 | }
98 | return processCPUString
99 | }
100 |
101 |
--------------------------------------------------------------------------------
/collectors/cpu/system_call.go:
--------------------------------------------------------------------------------
1 | package cpu
2 |
3 | import (
4 | "github.com/lunixbochs/ghostrace/ghost"
5 | "fmt"
6 | "log"
7 | "github.com/ringtail/snout/types"
8 | "time"
9 | "strconv"
10 | "strings"
11 | "github.com/ringtail/snout/collectors"
12 | "sync"
13 | "encoding/json"
14 | )
15 |
16 | const (
17 |
18 | TRACE_TIME = 5 * time.Second
19 |
20 | MAX_CPU_PROCESS = "MAX_CPU_PROCESS"
21 | )
22 |
23 | func init() {
24 | sc := &CPUSystemCallCollector{}
25 | collectors.Add(sc)
26 | }
27 |
28 | type CPUSystemCallCollector struct{}
29 |
30 | func (sc *CPUSystemCallCollector) Name() string {
31 | return MAX_CPU_PROCESS
32 | }
33 |
34 | func (sc *CPUSystemCallCollector) Description() string {
35 | return "Gather max cpu usage process detail"
36 | }
37 |
38 | func (sc *CPUSystemCallCollector) Gather() (types.MetricsSection, error) {
39 | metric := GatherMaxCPUProcessMetric()
40 | return &types.DefaultMetricsSection{
41 | Name: CPU_USAGE_SETTING,
42 | Metrics: metric,
43 | }, nil
44 | }
45 |
46 | func getMaxCpuProcess() (int, float64){
47 | maxCpu := 0.0
48 | maxCpuPid := ""
49 | cpuProcess := GatherAllProcessCpuUsage()
50 | for pid, cpu := range cpuProcess {
51 | if cpu > maxCpu {
52 | maxCpu = cpu
53 | maxCpuPid = pid
54 | }
55 | }
56 | pid, err := strconv.Atoi(maxCpuPid)
57 | if err != nil {
58 | log.Fatal(err)
59 | return 0, 0
60 | }
61 | return pid, maxCpu
62 | }
63 |
64 | func GatherMaxCPUProcessMetric() map[string]string {
65 | systemCallMetric := make(map[string]string)
66 | pid, cpu := getMaxCpuProcess()
67 |
68 | systemCallMetric["PID"] = fmt.Sprintf("%d", pid)
69 | systemCallMetric["CURRENT_CPU_USAGE"] = fmt.Sprintf("%f", cpu)
70 |
71 | systemCallRecord, err := GatherProcessSystemCallWithinTime(pid, TRACE_TIME)
72 | if err != nil {
73 | return systemCallMetric
74 | }
75 |
76 | result, _ := json.Marshal(systemCallRecord)
77 |
78 | systemCallMetric["SYSTEM_CALL"] = string(result)
79 | systemCallMetric["SYSTEM_CALL_RECORD_TIME"] = "5s"
80 |
81 | return systemCallMetric
82 | }
83 |
84 | func getSystemCallName(systemCall string) string{
85 | splitTemp := strings.Split(systemCall, "(")
86 | return splitTemp[0]
87 | }
88 |
89 | func GatherProcessSystemCallWithinTime(pid int, maxTime time.Duration) (map[string]int, error) {
90 | systemCallRecord := make(map[string]int)
91 | var wg sync.WaitGroup
92 | traceExit := false
93 |
94 | wg.Add(1)
95 |
96 | // Trace system call of the process
97 | go func() {
98 | defer wg.Done()
99 | tracer := ghost.NewTracer()
100 | trace, err := tracer.Trace(pid)
101 | if err != nil {
102 | log.Fatal(err)
103 | return
104 | }
105 | for sc := range trace {
106 | if traceExit {
107 | break
108 | }
109 | if sc.Exit {
110 | break
111 | }
112 | result := fmt.Sprintf("%s", sc.Syscall)
113 | systemCallName := getSystemCallName(result)
114 | value, ok := systemCallRecord[systemCallName]; if ok {
115 | systemCallRecord[systemCallName] = value + 1
116 | }else {
117 | systemCallRecord[systemCallName] = 1
118 | }
119 | }
120 | }()
121 |
122 | // Limit trace time
123 | go func() {
124 | defer wg.Done()
125 | startTime := time.Now()
126 | for {
127 | time.Sleep(1000 * time.Millisecond)
128 | if time.Now().Sub(startTime) > maxTime {
129 | traceExit = true
130 | break
131 | }
132 | }
133 | }()
134 | wg.Wait()
135 |
136 | return systemCallRecord, nil
137 | }
138 |
--------------------------------------------------------------------------------
/collectors/disk/disk.go:
--------------------------------------------------------------------------------
1 | package disk
2 |
3 | import (
4 | "github.com/ringtail/snout/types"
5 | df "github.com/ringtail/go-statfs"
6 | log "github.com/Sirupsen/logrus"
7 | "github.com/fatih/structs"
8 | "github.com/ringtail/snout/collectors"
9 | "strconv"
10 | )
11 |
12 | const (
13 | DISK_STATUS = "DISK_STATUS"
14 | )
15 |
16 | type DiskCollector struct{}
17 |
18 | func (dc *DiskCollector) Name() string {
19 | return DISK_STATUS
20 | }
21 |
22 | func (dc *DiskCollector) Description() string {
23 | return ""
24 | }
25 |
26 | func (dc *DiskCollector) Gather() (types.MetricsSection, error) {
27 | diskInfo, err := df.GetDiskInfo("/")
28 | if err != nil {
29 | log.Warnf("Failed to get disk info,because of %s", err.Error())
30 | }
31 | metricsMap := make(map[string]string)
32 | di := structs.New(diskInfo)
33 | for _, f := range di.Fields() {
34 | metricsMap[f.Name()] = strconv.FormatInt(f.Value().(int64), 10)
35 | }
36 | return &types.DefaultMetricsSection{
37 | Name: DISK_STATUS,
38 | Metrics: metricsMap,
39 | }, nil
40 | }
41 |
42 | func init() {
43 | dc := &DiskCollector{}
44 | collectors.Add(dc)
45 | }
46 |
--------------------------------------------------------------------------------
/collectors/disk/disk_test.go:
--------------------------------------------------------------------------------
1 | package disk
2 |
3 | import (
4 | "testing"
5 | )
6 | /***
7 | map[Available:14879744000
8 | Capacity:248391270400
9 | Usage:233249382400
10 | Inodes:60642398
11 | InodesFree:3632750
12 | InodesUsed:57009648]
13 | */
14 |
15 | func Test_DiskCollector_Name(t *testing.T) {
16 | dc := &DiskCollector{}
17 | if dc.Name() == DISK_STATUS {
18 | t.Log("pass TestDiskCollector_Name")
19 | return
20 | }
21 | t.Errorf("Failed to pass TestDiskCollector_Name because of name is not equals")
22 | }
23 |
24 | func Test_DiskCollector_Gather(t *testing.T) {
25 | dc := &DiskCollector{}
26 | mc, err := dc.Gather()
27 | if err != nil {
28 | t.Errorf("Failed to gather disk info,because of %s", err.Error())
29 | return
30 | }
31 | t.Logf("pass Test_DiskCollector_Gather and metrics is %v", mc.List())
32 | }
33 |
--------------------------------------------------------------------------------
/collectors/memory/memory.go:
--------------------------------------------------------------------------------
1 | package memory
2 |
3 | import (
4 | "github.com/ringtail/snout/types"
5 | "github.com/ringtail/snout/collectors"
6 | "os"
7 | log "github.com/Sirupsen/logrus"
8 | "io/ioutil"
9 | "strings"
10 | )
11 |
12 | func init() {
13 | mc := &MemoryCollector{}
14 | collectors.Add(mc)
15 | }
16 |
17 | const (
18 | MEMORY_PROC_STATUS_PATH = "/proc/meminfo"
19 | )
20 |
21 | const (
22 | MEMORY_STATUS = "MEMORY_STATUS"
23 | )
24 |
25 | type MemoryCollector struct{}
26 |
27 | func (mc *MemoryCollector) Name() string {
28 | return MEMORY_STATUS
29 | }
30 |
31 | func (mc *MemoryCollector) Description() string {
32 | return ""
33 | }
34 | func (mc *MemoryCollector) Gather() (types.MetricsSection, error) {
35 | if _, err := os.Stat(MEMORY_PROC_STATUS_PATH); os.IsNotExist(err) {
36 | log.Errorf("Failed to get meminfo, Because of %v", err.Error())
37 | return nil, err
38 | }
39 | bytes, err := ioutil.ReadFile(MEMORY_PROC_STATUS_PATH)
40 | if err != nil {
41 | log.Errorf("Failed to get meminfo from file, Because of %s", err.Error())
42 | return nil, err
43 | }
44 | meminfo := ReadBytesToMap(bytes)
45 | return &types.DefaultMetricsSection{
46 | Name: MEMORY_STATUS,
47 | Metrics: meminfo,
48 | }, nil
49 |
50 | }
51 |
52 | func ReadBytesToMap(bytes []byte) map[string]string {
53 | meminfo := make(map[string]string)
54 | linesStr := string(bytes)
55 | lineArr := strings.Split(linesStr, "\n")
56 | for _, line := range lineArr {
57 | if !strings.Contains(line, ":") {
58 | continue
59 | }
60 | line_key_value := strings.Split(line, ":")
61 | meminfo[line_key_value[0]] = line_key_value[1]
62 | }
63 | return meminfo
64 | }
65 |
--------------------------------------------------------------------------------
/collectors/netstat/netstat.go:
--------------------------------------------------------------------------------
1 | package netstat
2 |
3 | import (
4 | "github.com/drael/GOnetstat"
5 | "github.com/ringtail/snout/collectors"
6 | "github.com/ringtail/snout/types"
7 | "strconv"
8 | )
9 |
10 | const (
11 | NETSTAT_STATUS = "NETSTAT_STATUS"
12 | PORTS_USAGE = "PORTS_USAGE"
13 | )
14 |
15 | func init() {
16 | ns := &NetstatCollector{}
17 | collectors.Add(ns)
18 | }
19 |
20 | type NetstatCollector struct{}
21 |
22 | func (nsc *NetstatCollector) Name() string {
23 | return NETSTAT_STATUS
24 | }
25 |
26 | func (nsc *NetstatCollector) Description() string {
27 | return ""
28 | }
29 |
30 | func (nsc *NetstatCollector) Gather() (types.MetricsSection, error) {
31 | tcp := GOnetstat.Tcp()
32 | udp := GOnetstat.Udp()
33 | connection_status := make(map[string]string)
34 | ports := make(map[int64]int)
35 | for _, p := range tcp {
36 | if connection_status[p.State] == "" {
37 | connection_status[p.State] = "1"
38 | } else {
39 | times, _ := strconv.Atoi(connection_status[p.State])
40 | connection_status[p.State] = strconv.Itoa(times + 1)
41 | }
42 | ports[p.Port] = ports[p.Port] + 1
43 | }
44 |
45 | for _, u := range udp {
46 | ports[u.Port] = ports[u.Port] + 1
47 | }
48 |
49 | connection_status [PORTS_USAGE] = strconv.Itoa(len(ports))
50 |
51 | return &types.DefaultMetricsSection{
52 | Name: NETSTAT_STATUS,
53 | Metrics: connection_status,
54 | }, nil
55 | }
56 |
--------------------------------------------------------------------------------
/collectors/netstat/netstat_test.go:
--------------------------------------------------------------------------------
1 | package netstat
2 |
3 | import (
4 | "github.com/ringtail/GOnetstat"
5 | "testing"
6 | )
7 |
8 | func TestNetstatLib(t *testing.T) {
9 | d := GOnetstat.Tcp()
10 | for index, p := range d {
11 | t.Logf("%d: %s %s\n", index, p.Name, p.State)
12 | }
13 |
14 | ud := GOnetstat.Udp()
15 | for index, p := range ud {
16 | t.Logf("%d: %s %s\n", index, p.Name, p.State)
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/collectors/system/system.go:
--------------------------------------------------------------------------------
1 | package system
2 |
3 | import (
4 | "errors"
5 | "github.com/ringtail/snout/collectors"
6 | "github.com/ringtail/snout/types"
7 | "github.com/ringtail/sysctl"
8 | )
9 |
10 | const (
11 | KERNEL_SETTINGS = "KERNEL_SETTINGS"
12 | )
13 |
14 | func init() {
15 | sc := &SystemCollector{}
16 | collectors.Add(sc)
17 | }
18 |
19 | type SystemCollector struct{}
20 |
21 | func (sc *SystemCollector) Name() string {
22 | return KERNEL_SETTINGS
23 | }
24 |
25 | func (sc *SystemCollector) Description() string {
26 | return "Gather kernel settings from /proc/sys"
27 | }
28 |
29 | func (sc *SystemCollector) Gather() (types.MetricsSection, error) {
30 | metrics := sysctl.All()
31 | if metrics == nil {
32 | return nil, errors.New("Failed to Gather " + KERNEL_SETTINGS + " metrics")
33 | }
34 | return &types.DefaultMetricsSection{
35 | Name: KERNEL_SETTINGS,
36 | Metrics: metrics,
37 | }, nil
38 | }
39 |
--------------------------------------------------------------------------------
/core/snout.go:
--------------------------------------------------------------------------------
1 | package core
2 |
3 | import (
4 | log "github.com/Sirupsen/logrus"
5 |
6 | "github.com/ringtail/snout/advisors"
7 | "github.com/ringtail/snout/collectors"
8 | "github.com/ringtail/snout/types"
9 |
10 | _ "github.com/ringtail/snout/advisors/all"
11 | _ "github.com/ringtail/snout/collectors/all"
12 | "github.com/ringtail/snout/storage"
13 | )
14 |
15 | type Plugins interface {
16 | Empty() bool
17 | Start()
18 | }
19 |
20 | type Snout struct {
21 | CollectorManager types.Manager
22 | AdvisorsManager types.Manager
23 | }
24 |
25 | func (st *Snout) Load() {
26 | st.CollectorManager = collectors.Cm
27 | st.AdvisorsManager = advisors.Am
28 | }
29 |
30 | func (st *Snout) Run() {
31 | st.Load()
32 | if st.CollectorManager.Empty() {
33 | log.Errorf("Failed to load any collectors, advisors or resolvers.")
34 | return
35 | }
36 | st.CollectorManager.Start()
37 | storage.InternalMetricsTree.DumpAll()
38 | st.AdvisorsManager.Start()
39 | }
40 |
--------------------------------------------------------------------------------
/core/version.go:
--------------------------------------------------------------------------------
1 | package core
2 |
3 | const VERSION = "0.0.1"
4 |
--------------------------------------------------------------------------------
/coverage.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/resolvers/resolvers.go:
--------------------------------------------------------------------------------
1 | package resolvers
2 |
3 | type Resolver interface {
4 | Resolve()
5 | }
6 |
--------------------------------------------------------------------------------
/snout:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ringtail/snout/8cead4581289bc91be506b0481e72465a766f726/snout
--------------------------------------------------------------------------------
/snout.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | log "github.com/Sirupsen/logrus"
7 | "github.com/ringtail/snout/core"
8 | )
9 |
10 | const USAGE_DESC = `
11 |
12 | =====================================================
13 |
14 | ███████╗███╗ ██╗ ██████╗ ██╗ ██╗████████╗
15 | ██╔════╝████╗ ██║██╔═══██╗██║ ██║╚══██╔══╝
16 | ███████╗██╔██╗ ██║██║ ██║██║ ██║ ██║
17 | ╚════██║██║╚██╗██║██║ ██║██║ ██║ ██║
18 | ███████║██║ ╚████║╚██████╔╝╚██████╔╝ ██║
19 | ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝
20 |
21 | snout is tool to improve your system performance
22 | =====================================================
23 |
24 |
25 | Usage:
26 | snout [commands|flags]
27 |
28 | The commands & flags are:
29 | help print snout help
30 | version print the version to stdout
31 | --debug switch on debug mode
32 |
33 | Examples:
34 | # start in normal mode
35 | snout
36 |
37 | # start in debug mode
38 | snout --debug
39 | `
40 |
41 | var (
42 | h bool
43 | v bool
44 | debug bool
45 | )
46 |
47 | func init() {
48 | flag.BoolVar(&h, "help", false, "--help")
49 | flag.BoolVar(&v, "version", false, "--version")
50 | flag.BoolVar(&debug, "debug", false, "--debug")
51 | }
52 |
53 | func main() {
54 | flag.Parse()
55 | if h == true {
56 | fmt.Println(USAGE_DESC)
57 | return
58 | }
59 | if v == true {
60 | fmt.Println(core.VERSION)
61 | return
62 | }
63 |
64 | customFormatter := new(log.TextFormatter)
65 | customFormatter.DisableTimestamp = true
66 | log.SetFormatter(customFormatter)
67 |
68 | if debug == true {
69 | log.SetLevel(log.DebugLevel)
70 | }
71 |
72 | st := &core.Snout{}
73 | st.Run()
74 | }
75 |
--------------------------------------------------------------------------------
/storage/memstorage.go:
--------------------------------------------------------------------------------
1 | package storage
2 |
3 | import (
4 | log "github.com/Sirupsen/logrus"
5 | "github.com/ringtail/snout/types"
6 | )
7 |
8 | type MetricsTree struct {
9 | MetricsSection map[string]types.MetricsSection
10 | }
11 |
12 | func (mt *MetricsTree) AddSection(section types.MetricsSection) {
13 | name := section.GetName()
14 | mt.MetricsSection[name] = section
15 | }
16 |
17 | func (mt *MetricsTree) FindSection(name string) types.MetricsSection {
18 | return mt.MetricsSection[name]
19 | }
20 |
21 | func (mt *MetricsTree) DumpAll() {
22 | for key, value := range mt.MetricsSection {
23 | log.Debugf("================== Metric Section %s Begin ==================", key)
24 | for map_key, map_value := range value.List() {
25 | log.Debugf("%s:%s", map_key, map_value)
26 | }
27 | log.Debugf("================== Metric Section %s End ==================", key)
28 | }
29 | }
30 |
31 | type SymptomStorage struct {
32 | }
33 |
34 | var (
35 | InternalMetricsTree *MetricsTree
36 | InternalSymptom *SymptomStorage
37 | )
38 |
39 | func init() {
40 | InternalMetricsTree = &MetricsTree{}
41 | InternalMetricsTree.MetricsSection = make(map[string]types.MetricsSection)
42 | }
43 |
--------------------------------------------------------------------------------
/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | echo "" > coverage.txt
5 |
6 | for d in $(go list ./... | grep -v vendor); do
7 | go test -race -coverprofile=profile.out -covermode=atomic $d
8 | if [ -f profile.out ]; then
9 | cat profile.out >> coverage.txt
10 | rm profile.out
11 | fi
12 | done
13 |
--------------------------------------------------------------------------------
/types/manager.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | type Manager interface {
4 | Empty() bool
5 | Start(name ...string)
6 | }
7 |
--------------------------------------------------------------------------------
/types/metrics.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | type MetricsSection interface {
4 | GetName() string
5 | List() map[string]string
6 | Find(name string) string
7 | }
8 |
9 | type DefaultMetricsSection struct {
10 | Name string
11 | Metrics map[string]string
12 | }
13 |
14 | func (dms *DefaultMetricsSection) GetName() string {
15 | return dms.Name
16 | }
17 | func (dms *DefaultMetricsSection) List() map[string]string {
18 | return dms.Metrics
19 | }
20 |
21 | func (dms *DefaultMetricsSection) Find(name string) string {
22 | return dms.Metrics[name]
23 | }
24 |
--------------------------------------------------------------------------------
/types/symptom.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "github.com/olekukonko/tablewriter"
5 | "github.com/ringtail/snout/resolvers"
6 | "os"
7 | "fmt"
8 | )
9 |
10 | /**
11 | A DiagnosticReport may contains several symptom
12 | A symptom
13 | */
14 |
15 | type DiagnosticReport interface {
16 | GetSymptom() []Symptom
17 | Print()
18 | }
19 |
20 | type Symptom interface {
21 | GetDescription() string
22 | GetName() string
23 | GetAdvises() []Advise
24 | GetAdviseDescriptions() []string
25 | }
26 |
27 | type Advise interface {
28 | GetDescription() string
29 | GetResolvers() []resolvers.Resolver
30 | }
31 |
32 | type DefaultAdvise struct {
33 | Description string
34 | Resolvers []resolvers.Resolver
35 | }
36 |
37 | func (da *DefaultAdvise) GetDescription() string {
38 | return da.Description
39 | }
40 |
41 | func (da *DefaultAdvise) GetResolvers() []resolvers.Resolver {
42 | return da.Resolvers
43 | }
44 |
45 | type DefaultDiagnosticReport struct {
46 | Symptom []Symptom
47 | }
48 |
49 | func (ddr *DefaultDiagnosticReport) Add(syms []Symptom) {
50 | for _, sym := range syms {
51 | ddr.Symptom = append(ddr.Symptom, sym)
52 | }
53 | }
54 |
55 | func (ddr *DefaultDiagnosticReport) GetSymptom() []Symptom {
56 | return ddr.Symptom
57 | }
58 |
59 | func (ddr *DefaultDiagnosticReport) Print() {
60 | if len(ddr.GetSymptom()) == 0 {
61 | fmt.Println("Snout doesn't sniff any bad smell about performance in your system")
62 | return
63 | }
64 | table := tablewriter.NewWriter(os.Stdout)
65 | //table.SetAutoMergeCells(true)
66 | table.SetHeader([]string{"Symptom", "Description", "Advises"})
67 |
68 | for _, symptom := range ddr.GetSymptom() {
69 | data := make([][]string, 0)
70 | for _, adviseDescription := range symptom.GetAdviseDescriptions() {
71 | data = append(data, []string{symptom.GetName(), symptom.GetDescription(), adviseDescription})
72 | }
73 |
74 | table.SetAutoMergeCells(true)
75 | table.SetRowLine(true)
76 | table.SetColMinWidth(2, 80)
77 | table.AppendBulk(data) // Add Bulk Data
78 |
79 | }
80 | table.Render()
81 | }
82 |
83 | type DefaultSymptom struct {
84 | Name string
85 | Description string
86 | Advises []Advise
87 | }
88 |
89 | func (ds *DefaultSymptom) GetName() string {
90 | return ds.Name
91 | }
92 | func (ds *DefaultSymptom) GetDescription() string {
93 | return ds.Description
94 | }
95 |
96 | func (ds *DefaultSymptom) GetAdvises() []Advise {
97 | return ds.Advises
98 | }
99 |
100 | func (ds *DefaultSymptom) GetAdviseDescriptions() []string {
101 | descriptions := make([]string, 0)
102 | for _, advise := range ds.Advises {
103 | descriptions = append(descriptions, advise.GetDescription())
104 | }
105 | return descriptions
106 | }
107 |
108 | func CreateTextDefaultSymptom(name, desc string, adviseDescriptions []string) Symptom {
109 | symptom := &DefaultSymptom{
110 | Name: name,
111 | Description: desc,
112 | Advises: make([]Advise, 0),
113 | }
114 | for _, adviseDesc := range adviseDescriptions {
115 | symptom.Advises = append(symptom.Advises, &DefaultAdvise{
116 | Description: adviseDesc,
117 | })
118 | }
119 | return symptom
120 | }
121 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 0.10.0
2 |
3 | * feature: Add a test hook (#180)
4 | * feature: `ParseLevel` is now case-insensitive (#326)
5 | * feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308)
6 | * performance: avoid re-allocations on `WithFields` (#335)
7 |
8 | # 0.9.0
9 |
10 | * logrus/text_formatter: don't emit empty msg
11 | * logrus/hooks/airbrake: move out of main repository
12 | * logrus/hooks/sentry: move out of main repository
13 | * logrus/hooks/papertrail: move out of main repository
14 | * logrus/hooks/bugsnag: move out of main repository
15 | * logrus/core: run tests with `-race`
16 | * logrus/core: detect TTY based on `stderr`
17 | * logrus/core: support `WithError` on logger
18 | * logrus/core: Solaris support
19 |
20 | # 0.8.7
21 |
22 | * logrus/core: fix possible race (#216)
23 | * logrus/doc: small typo fixes and doc improvements
24 |
25 |
26 | # 0.8.6
27 |
28 | * hooks/raven: allow passing an initialized client
29 |
30 | # 0.8.5
31 |
32 | * logrus/core: revert #208
33 |
34 | # 0.8.4
35 |
36 | * formatter/text: fix data race (#218)
37 |
38 | # 0.8.3
39 |
40 | * logrus/core: fix entry log level (#208)
41 | * logrus/core: improve performance of text formatter by 40%
42 | * logrus/core: expose `LevelHooks` type
43 | * logrus/core: add support for DragonflyBSD and NetBSD
44 | * formatter/text: print structs more verbosely
45 |
46 | # 0.8.2
47 |
48 | * logrus: fix more Fatal family functions
49 |
50 | # 0.8.1
51 |
52 | * logrus: fix not exiting on `Fatalf` and `Fatalln`
53 |
54 | # 0.8.0
55 |
56 | * logrus: defaults to stderr instead of stdout
57 | * hooks/sentry: add special field for `*http.Request`
58 | * formatter/text: ignore Windows for colors
59 |
60 | # 0.7.3
61 |
62 | * formatter/\*: allow configuration of timestamp layout
63 |
64 | # 0.7.2
65 |
66 | * formatter/text: Add configuration option for time format (#158)
67 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Simon Eskildsen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/alt_exit.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | // The following code was sourced and modified from the
4 | // https://bitbucket.org/tebeka/atexit package governed by the following license:
5 | //
6 | // Copyright (c) 2012 Miki Tebeka .
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
9 | // this software and associated documentation files (the "Software"), to deal in
10 | // the Software without restriction, including without limitation the rights to
11 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 | // the Software, and to permit persons to whom the Software is furnished to do so,
13 | // subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in all
16 | // copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 |
25 | import (
26 | "fmt"
27 | "os"
28 | )
29 |
30 | var handlers = []func(){}
31 |
32 | func runHandler(handler func()) {
33 | defer func() {
34 | if err := recover(); err != nil {
35 | fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err)
36 | }
37 | }()
38 |
39 | handler()
40 | }
41 |
42 | func runHandlers() {
43 | for _, handler := range handlers {
44 | runHandler(handler)
45 | }
46 | }
47 |
48 | // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
49 | func Exit(code int) {
50 | runHandlers()
51 | os.Exit(code)
52 | }
53 |
54 | // RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke
55 | // all handlers. The handlers will also be invoked when any Fatal log entry is
56 | // made.
57 | //
58 | // This method is useful when a caller wishes to use logrus to log a fatal
59 | // message but also needs to gracefully shutdown. An example usecase could be
60 | // closing database connections, or sending a alert that the application is
61 | // closing.
62 | func RegisterExitHandler(handler func()) {
63 | handlers = append(handlers, handler)
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
3 |
4 |
5 | The simplest way to use Logrus is simply the package-level exported logger:
6 |
7 | package main
8 |
9 | import (
10 | log "github.com/Sirupsen/logrus"
11 | )
12 |
13 | func main() {
14 | log.WithFields(log.Fields{
15 | "animal": "walrus",
16 | "number": 1,
17 | "size": 10,
18 | }).Info("A walrus appears")
19 | }
20 |
21 | Output:
22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
23 |
24 | For a full guide visit https://github.com/Sirupsen/logrus
25 | */
26 | package logrus
27 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/formatter.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import "time"
4 |
5 | const DefaultTimestampFormat = time.RFC3339
6 |
7 | // The Formatter interface is used to implement a custom Formatter. It takes an
8 | // `Entry`. It exposes all the fields, including the default ones:
9 | //
10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
11 | // * `entry.Data["time"]`. The timestamp.
12 | // * `entry.Data["level"]. The level the entry was logged at.
13 | //
14 | // Any additional fields added with `WithField` or `WithFields` are also in
15 | // `entry.Data`. Format is expected to return an array of bytes which are then
16 | // logged to `logger.Out`.
17 | type Formatter interface {
18 | Format(*Entry) ([]byte, error)
19 | }
20 |
21 | // This is to not silently overwrite `time`, `msg` and `level` fields when
22 | // dumping it. If this code wasn't there doing:
23 | //
24 | // logrus.WithField("level", 1).Info("hello")
25 | //
26 | // Would just silently drop the user provided level. Instead with this code
27 | // it'll logged as:
28 | //
29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
30 | //
31 | // It's not exported because it's still using Data in an opinionated way. It's to
32 | // avoid code duplication between the two default formatters.
33 | func prefixFieldClashes(data Fields) {
34 | if t, ok := data["time"]; ok {
35 | data["fields.time"] = t
36 | }
37 |
38 | if m, ok := data["msg"]; ok {
39 | data["fields.msg"] = m
40 | }
41 |
42 | if l, ok := data["level"]; ok {
43 | data["fields.level"] = l
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/hooks.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | // A hook to be fired when logging on the logging levels returned from
4 | // `Levels()` on your implementation of the interface. Note that this is not
5 | // fired in a goroutine or a channel with workers, you should handle such
6 | // functionality yourself if your call is non-blocking and you don't wish for
7 | // the logging calls for levels returned from `Levels()` to block.
8 | type Hook interface {
9 | Levels() []Level
10 | Fire(*Entry) error
11 | }
12 |
13 | // Internal type for storing the hooks on a logger instance.
14 | type LevelHooks map[Level][]Hook
15 |
16 | // Add a hook to an instance of logger. This is called with
17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
18 | func (hooks LevelHooks) Add(hook Hook) {
19 | for _, level := range hook.Levels() {
20 | hooks[level] = append(hooks[level], hook)
21 | }
22 | }
23 |
24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire
25 | // appropriate hooks for a log entry.
26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
27 | for _, hook := range hooks[level] {
28 | if err := hook.Fire(entry); err != nil {
29 | return err
30 | }
31 | }
32 |
33 | return nil
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/json_formatter.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | )
7 |
8 | type fieldKey string
9 | type FieldMap map[fieldKey]string
10 |
11 | const (
12 | FieldKeyMsg = "msg"
13 | FieldKeyLevel = "level"
14 | FieldKeyTime = "time"
15 | )
16 |
17 | func (f FieldMap) resolve(key fieldKey) string {
18 | if k, ok := f[key]; ok {
19 | return k
20 | }
21 |
22 | return string(key)
23 | }
24 |
25 | type JSONFormatter struct {
26 | // TimestampFormat sets the format used for marshaling timestamps.
27 | TimestampFormat string
28 |
29 | // DisableTimestamp allows disabling automatic timestamps in output
30 | DisableTimestamp bool
31 |
32 | // FieldMap allows users to customize the names of keys for various fields.
33 | // As an example:
34 | // formatter := &JSONFormatter{
35 | // FieldMap: FieldMap{
36 | // FieldKeyTime: "@timestamp",
37 | // FieldKeyLevel: "@level",
38 | // FieldKeyLevel: "@message",
39 | // },
40 | // }
41 | FieldMap FieldMap
42 | }
43 |
44 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
45 | data := make(Fields, len(entry.Data)+3)
46 | for k, v := range entry.Data {
47 | switch v := v.(type) {
48 | case error:
49 | // Otherwise errors are ignored by `encoding/json`
50 | // https://github.com/Sirupsen/logrus/issues/137
51 | data[k] = v.Error()
52 | default:
53 | data[k] = v
54 | }
55 | }
56 | prefixFieldClashes(data)
57 |
58 | timestampFormat := f.TimestampFormat
59 | if timestampFormat == "" {
60 | timestampFormat = DefaultTimestampFormat
61 | }
62 |
63 | if !f.DisableTimestamp {
64 | data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
65 | }
66 | data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
67 | data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
68 |
69 | serialized, err := json.Marshal(data)
70 | if err != nil {
71 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
72 | }
73 | return append(serialized, '\n'), nil
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/logrus.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import (
4 | "fmt"
5 | "log"
6 | "strings"
7 | )
8 |
9 | // Fields type, used to pass to `WithFields`.
10 | type Fields map[string]interface{}
11 |
12 | // Level type
13 | type Level uint8
14 |
15 | // Convert the Level to a string. E.g. PanicLevel becomes "panic".
16 | func (level Level) String() string {
17 | switch level {
18 | case DebugLevel:
19 | return "debug"
20 | case InfoLevel:
21 | return "info"
22 | case WarnLevel:
23 | return "warning"
24 | case ErrorLevel:
25 | return "error"
26 | case FatalLevel:
27 | return "fatal"
28 | case PanicLevel:
29 | return "panic"
30 | }
31 |
32 | return "unknown"
33 | }
34 |
35 | // ParseLevel takes a string level and returns the Logrus log level constant.
36 | func ParseLevel(lvl string) (Level, error) {
37 | switch strings.ToLower(lvl) {
38 | case "panic":
39 | return PanicLevel, nil
40 | case "fatal":
41 | return FatalLevel, nil
42 | case "error":
43 | return ErrorLevel, nil
44 | case "warn", "warning":
45 | return WarnLevel, nil
46 | case "info":
47 | return InfoLevel, nil
48 | case "debug":
49 | return DebugLevel, nil
50 | }
51 |
52 | var l Level
53 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
54 | }
55 |
56 | // A constant exposing all logging levels
57 | var AllLevels = []Level{
58 | PanicLevel,
59 | FatalLevel,
60 | ErrorLevel,
61 | WarnLevel,
62 | InfoLevel,
63 | DebugLevel,
64 | }
65 |
66 | // These are the different logging levels. You can set the logging level to log
67 | // on your instance of logger, obtained with `logrus.New()`.
68 | const (
69 | // PanicLevel level, highest level of severity. Logs and then calls panic with the
70 | // message passed to Debug, Info, ...
71 | PanicLevel Level = iota
72 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
73 | // logging level is set to Panic.
74 | FatalLevel
75 | // ErrorLevel level. Logs. Used for errors that should definitely be noted.
76 | // Commonly used for hooks to send errors to an error tracking service.
77 | ErrorLevel
78 | // WarnLevel level. Non-critical entries that deserve eyes.
79 | WarnLevel
80 | // InfoLevel level. General operational entries about what's going on inside the
81 | // application.
82 | InfoLevel
83 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging.
84 | DebugLevel
85 | )
86 |
87 | // Won't compile if StdLogger can't be realized by a log.Logger
88 | var (
89 | _ StdLogger = &log.Logger{}
90 | _ StdLogger = &Entry{}
91 | _ StdLogger = &Logger{}
92 | )
93 |
94 | // StdLogger is what your logrus-enabled library should take, that way
95 | // it'll accept a stdlib logger and a logrus logger. There's no standard
96 | // interface, this is the closest we get, unfortunately.
97 | type StdLogger interface {
98 | Print(...interface{})
99 | Printf(string, ...interface{})
100 | Println(...interface{})
101 |
102 | Fatal(...interface{})
103 | Fatalf(string, ...interface{})
104 | Fatalln(...interface{})
105 |
106 | Panic(...interface{})
107 | Panicf(string, ...interface{})
108 | Panicln(...interface{})
109 | }
110 |
111 | // The FieldLogger interface generalizes the Entry and Logger types
112 | type FieldLogger interface {
113 | WithField(key string, value interface{}) *Entry
114 | WithFields(fields Fields) *Entry
115 | WithError(err error) *Entry
116 |
117 | Debugf(format string, args ...interface{})
118 | Infof(format string, args ...interface{})
119 | Printf(format string, args ...interface{})
120 | Warnf(format string, args ...interface{})
121 | Warningf(format string, args ...interface{})
122 | Errorf(format string, args ...interface{})
123 | Fatalf(format string, args ...interface{})
124 | Panicf(format string, args ...interface{})
125 |
126 | Debug(args ...interface{})
127 | Info(args ...interface{})
128 | Print(args ...interface{})
129 | Warn(args ...interface{})
130 | Warning(args ...interface{})
131 | Error(args ...interface{})
132 | Fatal(args ...interface{})
133 | Panic(args ...interface{})
134 |
135 | Debugln(args ...interface{})
136 | Infoln(args ...interface{})
137 | Println(args ...interface{})
138 | Warnln(args ...interface{})
139 | Warningln(args ...interface{})
140 | Errorln(args ...interface{})
141 | Fatalln(args ...interface{})
142 | Panicln(args ...interface{})
143 | }
144 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/terminal_appengine.go:
--------------------------------------------------------------------------------
1 | // +build appengine
2 |
3 | package logrus
4 |
5 | // IsTerminal returns true if stderr's file descriptor is a terminal.
6 | func IsTerminal() bool {
7 | return true
8 | }
9 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/terminal_bsd.go:
--------------------------------------------------------------------------------
1 | // +build darwin freebsd openbsd netbsd dragonfly
2 | // +build !appengine
3 |
4 | package logrus
5 |
6 | import "syscall"
7 |
8 | const ioctlReadTermios = syscall.TIOCGETA
9 |
10 | type Termios syscall.Termios
11 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/terminal_linux.go:
--------------------------------------------------------------------------------
1 | // Based on ssh/terminal:
2 | // Copyright 2013 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // +build !appengine
7 |
8 | package logrus
9 |
10 | import "syscall"
11 |
12 | const ioctlReadTermios = syscall.TCGETS
13 |
14 | type Termios syscall.Termios
15 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go:
--------------------------------------------------------------------------------
1 | // Based on ssh/terminal:
2 | // Copyright 2011 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // +build linux darwin freebsd openbsd netbsd dragonfly
7 | // +build !appengine
8 |
9 | package logrus
10 |
11 | import (
12 | "syscall"
13 | "unsafe"
14 | )
15 |
16 | // IsTerminal returns true if stderr's file descriptor is a terminal.
17 | func IsTerminal() bool {
18 | fd := syscall.Stderr
19 | var termios Termios
20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
21 | return err == 0
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/terminal_solaris.go:
--------------------------------------------------------------------------------
1 | // +build solaris,!appengine
2 |
3 | package logrus
4 |
5 | import (
6 | "os"
7 |
8 | "golang.org/x/sys/unix"
9 | )
10 |
11 | // IsTerminal returns true if the given file descriptor is a terminal.
12 | func IsTerminal() bool {
13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
14 | return err == nil
15 | }
16 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/terminal_windows.go:
--------------------------------------------------------------------------------
1 | // Based on ssh/terminal:
2 | // Copyright 2011 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // +build windows,!appengine
7 |
8 | package logrus
9 |
10 | import (
11 | "syscall"
12 | "unsafe"
13 | )
14 |
15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll")
16 |
17 | var (
18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
19 | )
20 |
21 | // IsTerminal returns true if stderr's file descriptor is a terminal.
22 | func IsTerminal() bool {
23 | fd := syscall.Stderr
24 | var st uint32
25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
26 | return r != 0 && e == 0
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/github.com/Sirupsen/logrus/writer.go:
--------------------------------------------------------------------------------
1 | package logrus
2 |
3 | import (
4 | "bufio"
5 | "io"
6 | "runtime"
7 | )
8 |
9 | func (logger *Logger) Writer() *io.PipeWriter {
10 | return logger.WriterLevel(InfoLevel)
11 | }
12 |
13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
14 | reader, writer := io.Pipe()
15 |
16 | var printFunc func(args ...interface{})
17 | switch level {
18 | case DebugLevel:
19 | printFunc = logger.Debug
20 | case InfoLevel:
21 | printFunc = logger.Info
22 | case WarnLevel:
23 | printFunc = logger.Warn
24 | case ErrorLevel:
25 | printFunc = logger.Error
26 | case FatalLevel:
27 | printFunc = logger.Fatal
28 | case PanicLevel:
29 | printFunc = logger.Panic
30 | default:
31 | printFunc = logger.Print
32 | }
33 |
34 | go logger.writerScanner(reader, printFunc)
35 | runtime.SetFinalizer(writer, writerFinalizer)
36 |
37 | return writer
38 | }
39 |
40 | func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
41 | scanner := bufio.NewScanner(reader)
42 | for scanner.Scan() {
43 | printFunc(scanner.Text())
44 | }
45 | if err := scanner.Err(); err != nil {
46 | logger.Errorf("Error while reading from Writer: %s", err)
47 | }
48 | reader.Close()
49 | }
50 |
51 | func writerFinalizer(writer *io.PipeWriter) {
52 | writer.Close()
53 | }
54 |
--------------------------------------------------------------------------------
/vendor/github.com/drael/GOnetstat/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Rafael Santos
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/drael/GOnetstat/README.md:
--------------------------------------------------------------------------------
1 | # GOnetstat
2 |
3 | Netstat implementation in Golang.
4 |
5 | This Package get data from /proc/net/tcp|6 and /proc/net/udp|6 and parse
6 | /proc/[0-9]*/fd/[0-9]* to match the correct inode.
7 |
8 | ## Usage
9 |
10 | TCP/UDP
11 | ```go
12 | tcp_data := GOnetstat.Tcp()
13 | udp_data := GOnetstat.Udp()
14 | ```
15 |
16 | This will return a array of a Process struct like this
17 |
18 | ```go
19 | type Process struct {
20 | User string
21 | Name string
22 | Pid string
23 | Exe string
24 | State string
25 | Ip string
26 | Port int64
27 | ForeignIp string
28 | ForeignPort int64
29 | }
30 | ```
31 | So you can loop through data output and format the output of your program
32 | in whatever way you want it.
33 | See the Examples folder!
34 |
35 | TCP6/UDP6
36 | ```go
37 | tcp6_data := GOnetstat.Tcp6()
38 | udp6_data := GOnetstat.Udp6()
39 | ```
40 | The return will be a array of a Process struct like mentioned above.
41 | Still need to create a way to compress the ipv6 because is too long.
42 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/structs/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Fatih Arslan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/vendor/github.com/fatih/structs/tags.go:
--------------------------------------------------------------------------------
1 | package structs
2 |
3 | import "strings"
4 |
5 | // tagOptions contains a slice of tag options
6 | type tagOptions []string
7 |
8 | // Has returns true if the given option is available in tagOptions
9 | func (t tagOptions) Has(opt string) bool {
10 | for _, tagOpt := range t {
11 | if tagOpt == opt {
12 | return true
13 | }
14 | }
15 |
16 | return false
17 | }
18 |
19 | // parseTag splits a struct field's tag into its name and a list of options
20 | // which comes after a name. A tag is in the form of: "name,option1,option2".
21 | // The name can be neglectected.
22 | func parseTag(tag string) (string, tagOptions) {
23 | // tag is one of followings:
24 | // ""
25 | // "name"
26 | // "name,opt"
27 | // "name,opt,opt2"
28 | // ",opt"
29 |
30 | res := strings.Split(tag, ",")
31 | return res[0], res[1:]
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Ryan Hileman
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/cli.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "github.com/lunixbochs/ghostrace/ghost"
8 | )
9 |
10 | func main() {
11 | trace, err := ghost.DefaultCli(os.Args, nil)
12 | if err != nil {
13 | fmt.Printf("%s\n", err)
14 | os.Exit(1)
15 | }
16 | // TODO: no way to kill target, so this should be more than a channel
17 | for sc := range trace {
18 | fmt.Fprintf(os.Stderr, "%+v\n", sc)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/cli.go:
--------------------------------------------------------------------------------
1 | package ghost
2 |
3 | import (
4 | "errors"
5 | "flag"
6 | "fmt"
7 | "os"
8 | )
9 |
10 | var BadArgsErr = errors.New("insufficient arguments")
11 |
12 | func DefaultCli(args []string, fs *flag.FlagSet) (chan *Event, error) {
13 | if fs == nil {
14 | fs = flag.NewFlagSet("ghostrace", flag.ExitOnError)
15 | fs.Usage = func() {
16 | fmt.Fprintf(os.Stderr, "Usage: %s [options] -p | [args...]\n", args[0])
17 | fs.PrintDefaults()
18 | }
19 | }
20 | follow := fs.Bool("f", false, "follow subprocesses")
21 | pid := fs.Int("p", -1, "attach to pid")
22 | fs.Parse(args[1:])
23 | args = fs.Args()
24 |
25 | var trace chan *Event
26 | var err error
27 | tracer := NewTracer()
28 | if pid != nil && *pid >= 0 {
29 | trace, err = tracer.Trace(*pid)
30 | } else {
31 | if len(args) > 0 {
32 | trace, err = tracer.Spawn(args[0], args...)
33 | } else {
34 | fs.Usage()
35 | return nil, BadArgsErr
36 | }
37 | }
38 | if err != nil {
39 | return nil, fmt.Errorf("Error starting trace: %s", err)
40 | }
41 | tracer.ExecFilter(func(c *Event) (bool, bool) {
42 | // fmt.Println("exec filter", c)
43 | // keepParent, followChild
44 | return true, *follow
45 | })
46 | return trace, nil
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/event.go:
--------------------------------------------------------------------------------
1 | package ghost
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/lunixbochs/ghostrace/ghost/process"
7 | "github.com/lunixbochs/ghostrace/ghost/sys"
8 | )
9 |
10 | type Event struct {
11 | Process process.Process
12 | Syscall sys.Syscall
13 | Exit bool
14 | }
15 |
16 | func (e *Event) String() string {
17 | if e.Exit {
18 | return fmt.Sprintf("[pid %d] exit", e.Process.Pid())
19 | }
20 | return fmt.Sprintf("[pid %d] %s", e.Process.Pid(), e.Syscall)
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/memio/memio.go:
--------------------------------------------------------------------------------
1 | package memio
2 |
3 | import (
4 | "bytes"
5 | "io"
6 | )
7 |
8 | type MemIO interface {
9 | ReadAt(p []byte, addr uint64) (int, error)
10 | ReadStrAt(addr uint64) (string, error)
11 | WriteAt(p []byte, addr uint64) (int, error)
12 | StreamAt(addr uint64) io.ReadWriter
13 | }
14 |
15 | type callback func(p []byte, addr uint64) (int, error)
16 |
17 | type memIO struct {
18 | read, write callback
19 | }
20 |
21 | func NewMemIO(read, write callback) MemIO {
22 | return &memIO{read, write}
23 | }
24 |
25 | func (m *memIO) ReadAt(p []byte, addr uint64) (int, error) {
26 | return m.read(p, addr)
27 | }
28 |
29 | // TODO: this probably makes way too many syscalls.
30 | // could do a large page-aligned read but that's not as portable
31 | func (m *memIO) ReadStrAt(addr uint64) (string, error) {
32 | var tmp = [4]byte{1, 1, 1, 1}
33 | var ret []byte
34 | nul := []byte{0}
35 | for !bytes.Contains(tmp[:], nul) {
36 | n, err := m.ReadAt(tmp[:], addr)
37 | if err != nil {
38 | return "", err
39 | }
40 | addr += uint64(n)
41 | ret = append(ret, tmp[:]...)
42 | }
43 | split := bytes.Index(ret, nul)
44 | return string(ret[:split]), nil
45 | }
46 |
47 | func (m *memIO) WriteAt(p []byte, addr uint64) (int, error) {
48 | return m.write(p, addr)
49 | }
50 |
51 | func (m *memIO) StreamAt(addr uint64) io.ReadWriter {
52 | return &memIOStream{*m, addr}
53 | }
54 |
55 | type memIOStream struct {
56 | memIO
57 | addr uint64
58 | }
59 |
60 | func (m *memIOStream) Read(p []byte) (int, error) {
61 | n, err := m.read(p, m.addr)
62 | m.addr += uint64(n)
63 | return n, err
64 | }
65 |
66 | func (m *memIOStream) Write(p []byte) (int, error) {
67 | n, err := m.write(p, m.addr)
68 | m.addr += uint64(n)
69 | return n, err
70 | }
71 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/process/list.go:
--------------------------------------------------------------------------------
1 | package process
2 |
3 | import (
4 | "fmt"
5 | "sort"
6 | )
7 |
8 | type ProcessList []Process
9 | type byPid ProcessList
10 | type byUid ProcessList
11 |
12 | func (a byPid) Len() int { return len(a) }
13 | func (a byPid) Less(i, j int) bool { return a[i].Pid() < a[j].Pid() }
14 | func (a byPid) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
15 | func (a byUid) Len() int { return len(a) }
16 | func (a byUid) Less(i, j int) bool { return a[i].Uid() < a[j].Uid() }
17 | func (a byUid) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
18 |
19 | func (pl ProcessList) Print(tree bool) {
20 | sort.Sort(byPid(pl))
21 | for _, p := range pl {
22 | fmt.Printf("%+v\n", p)
23 | }
24 | }
25 |
26 | func (pl ProcessList) Filter(cb func(Process) bool) ProcessList {
27 | out := make(ProcessList, 0, len(pl))
28 | for _, v := range pl {
29 | if v != nil && cb(v) {
30 | out = append(out, v)
31 | }
32 | }
33 | return out
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/process/process.go:
--------------------------------------------------------------------------------
1 | package process
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 | )
7 |
8 | type process struct {
9 | pid, uid, gid int
10 | }
11 |
12 | func (p *process) Pid() int {
13 | return p.pid
14 | }
15 |
16 | func (p *process) Uid() int {
17 | return p.uid
18 | }
19 |
20 | func (p *process) Gid() int {
21 | return p.gid
22 | }
23 |
24 | type Process interface {
25 | Pid() int
26 | Exe() string
27 | Cmdline() []string
28 | Uid() int
29 | Gid() int
30 | Parent() Process
31 | Children() ProcessList
32 | String() string
33 | }
34 |
35 | type Match struct {
36 | Name string
37 | }
38 |
39 | func Filter(cb func(Process) bool) (ProcessList, error) {
40 | list, err := List()
41 | if err != nil {
42 | return nil, err
43 | }
44 | return list.Filter(cb), nil
45 | }
46 |
47 | func FindName(name string) (ProcessList, error) {
48 | return Filter(func(p Process) bool {
49 | return strings.Contains(p.Cmdline()[0], name)
50 | })
51 | }
52 |
53 | func FindPid(pid int) (Process, error) {
54 | return get(pid)
55 | }
56 |
57 | func getFallback(pid int) (Process, error) {
58 | list, err := Filter(func(p Process) bool {
59 | return p.Pid() == pid
60 | })
61 | if err != nil {
62 | return nil, err
63 | }
64 | if len(list) == 0 {
65 | return nil, fmt.Errorf("pid %d not found", pid)
66 | }
67 | return list[0], nil
68 | }
69 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/process/process_darwin.go:
--------------------------------------------------------------------------------
1 | package process
2 |
3 | import (
4 | "bytes"
5 | "errors"
6 | "fmt"
7 | "strings"
8 | "unsafe"
9 | )
10 |
11 | /*
12 | #include
13 | #include
14 | #include
15 |
16 | struct kinfo_proc *process_list(int *count) {
17 | size_t size;
18 | int params[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
19 | if (sysctl(params, 3, NULL, &size, NULL, 0) < 0) {
20 | return NULL;
21 | }
22 | struct kinfo_proc *ret = NULL;
23 | if (! (ret = malloc(size))) {
24 | return NULL;
25 | }
26 | if (sysctl(params, 3, ret, &size, NULL, 0) < 0) {
27 | free(ret);
28 | return NULL;
29 | }
30 | *count = size / sizeof(struct kinfo_proc);
31 | return ret;
32 | }
33 |
34 | char *process_args(int pid, int *argc, size_t *size_out) {
35 | size_t size;
36 | int params[] = {CTL_KERN, KERN_PROCARGS2, pid};
37 | // get argc
38 | if (sysctl(params, 3, NULL, &size, NULL, 0) < 0) {
39 | return NULL;
40 | }
41 | char *buf = malloc(size);
42 | if (sysctl(params, 3, buf, &size, NULL, 0) < 0) {
43 | free(buf);
44 | return NULL;
45 | }
46 | *argc = *(int *)buf;
47 | free(buf);
48 |
49 | params[1] = KERN_PROCARGS;
50 | // get argv
51 | if (sysctl(params, 3, NULL, &size, NULL, 0) < 0) {
52 | return NULL;
53 | }
54 | buf = malloc(size);
55 | if (sysctl(params, 3, buf, &size, NULL, 0) < 0) {
56 | free(buf);
57 | return NULL;
58 | }
59 | *size_out = size;
60 | return buf;
61 | }
62 | */
63 | import "C"
64 |
65 | func charToByte(cc []C.char) []byte {
66 | tmp := make([]byte, len(cc))
67 | for i, v := range cc {
68 | tmp[i] = byte(v)
69 | }
70 | return bytes.Trim(tmp, "\x00")
71 | }
72 |
73 | func cstr(cc []C.char) string {
74 | return string(bytes.SplitN(charToByte(cc), []byte{0}, 2)[0])
75 | }
76 |
77 | type DarwinProcess struct {
78 | process
79 | ppid int
80 | comm string
81 | }
82 |
83 | func (p *DarwinProcess) argv() []string {
84 | var argc C.int
85 | var size C.size_t
86 | buf := C.process_args(C.int(p.pid), &argc, &size)
87 | if buf == nil {
88 | return nil
89 | }
90 | defer C.free(unsafe.Pointer(buf))
91 |
92 | count := int(argc)
93 | tmp := string(charToByte((*[1 << 30]C.char)(unsafe.Pointer(buf))[:size:size]))
94 | tmpSplit := strings.SplitN(tmp, "\x00", 2)
95 | exe, tmp := tmpSplit[0], strings.TrimLeft(tmpSplit[1], "\x00")
96 | argv := strings.SplitN(tmp, "\x00", count+1)[:count]
97 | return append([]string{exe}, argv...)
98 | }
99 |
100 | func (p *DarwinProcess) String() string {
101 | return fmt.Sprintf("= 1 {
107 | return argv[0]
108 | }
109 | return p.comm
110 | }
111 |
112 | func (p *DarwinProcess) Cmdline() []string {
113 | argv := p.argv()
114 | if len(argv) > 1 {
115 | return argv[1:]
116 | }
117 | return nil
118 | }
119 |
120 | func get(pid int) (Process, error) {
121 | return getFallback(pid)
122 | }
123 |
124 | func List() (ProcessList, error) {
125 | var count C.int
126 | tmp := C.process_list(&count)
127 | defer C.free(unsafe.Pointer(tmp))
128 | if tmp == nil {
129 | return nil, errors.New("Could not retrieve process list.")
130 | }
131 | kinfo := (*[1 << 30]C.struct_kinfo_proc)(unsafe.Pointer(tmp))[:count:count]
132 | pl := make([]Process, 0, count)
133 | for i := 0; i < int(count); i++ {
134 | proc := kinfo[i]
135 | ps := &DarwinProcess{
136 | process: process{
137 | pid: int(proc.kp_proc.p_pid),
138 | uid: int(proc.kp_eproc.e_pcred.p_ruid),
139 | gid: int(proc.kp_eproc.e_pcred.p_rgid),
140 | },
141 | ppid: int(proc.kp_eproc.e_ppid),
142 | comm: cstr(proc.kp_proc.p_comm[:]),
143 | }
144 | pl = append(pl, ps)
145 | }
146 | return pl, nil
147 | }
148 |
149 | func (p *DarwinProcess) Parent() Process {
150 | ps, _ := FindPid(p.ppid)
151 | return ps
152 | }
153 |
154 | func (dp *DarwinProcess) Children() ProcessList {
155 | list, _ := Filter(func(p Process) bool {
156 | parent := p.Parent()
157 | return parent != nil && parent.Pid() == dp.pid
158 | })
159 | return list
160 | }
161 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/process/process_linux.go:
--------------------------------------------------------------------------------
1 | package process
2 |
3 | import (
4 | "fmt"
5 | "io/ioutil"
6 | "os"
7 | "regexp"
8 | "strconv"
9 | "strings"
10 | "syscall"
11 | )
12 |
13 | var numRe = regexp.MustCompile(`^\d+$`)
14 |
15 | type LinuxProcess struct {
16 | process
17 | exe string
18 | cmdline []string
19 | }
20 |
21 | func (p *LinuxProcess) String() string {
22 | return fmt.Sprintf("", p.Pid(), strings.Join(p.Cmdline(), ", "))
23 | }
24 |
25 | func (p *LinuxProcess) Exe() string {
26 | return p.exe
27 | }
28 |
29 | func (p *LinuxProcess) Cmdline() []string {
30 | return p.cmdline
31 | }
32 |
33 | func get(pid int) (Process, error) {
34 | dir, err := os.Stat(fmt.Sprintf("/proc/%d", pid))
35 | if err != nil {
36 | return nil, err
37 | }
38 | stat := dir.Sys().(*syscall.Stat_t)
39 | exe, _ := os.Readlink(fmt.Sprintf("/proc/%d/exe", pid))
40 | rawcmdline, _ := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cmdline", pid))
41 | cmdline := strings.Split(strings.TrimRight(string(rawcmdline), "\x00"), "\x00")
42 | return &LinuxProcess{
43 | process: process{
44 | pid: pid,
45 | uid: int(stat.Uid),
46 | gid: int(stat.Gid),
47 | },
48 | exe: exe,
49 | cmdline: cmdline,
50 | }, nil
51 | }
52 |
53 | func List() (ProcessList, error) {
54 | proc, err := ioutil.ReadDir("/proc")
55 | if err != nil {
56 | return nil, err
57 | }
58 | pl := make([]Process, 0, len(proc))
59 | for _, p := range proc {
60 | if p.IsDir() && numRe.Match([]byte(p.Name())) {
61 | i, _ := strconv.Atoi(p.Name())
62 | ps, _ := get(i)
63 | pl = append(pl, ps)
64 | }
65 | }
66 | return pl, nil
67 | }
68 |
69 | var statusRe = regexp.MustCompile(`(?im)^ppid:\s*(\d+)$`)
70 |
71 | func (p *LinuxProcess) Parent() Process {
72 | status, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/status", p.pid))
73 | if err != nil {
74 | return nil
75 | }
76 | sub := statusRe.FindSubmatch(status)
77 | if len(sub) >= 2 {
78 | ppid, _ := strconv.Atoi(string(sub[1]))
79 | p, _ := get(ppid)
80 | return p
81 | }
82 | return nil
83 | }
84 |
85 | func (lp *LinuxProcess) Children() ProcessList {
86 | list, _ := Filter(func(p Process) bool {
87 | parent := p.Parent()
88 | return parent != nil && parent.Pid() == lp.pid
89 | })
90 | return list
91 | }
92 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/sys/call/call.go:
--------------------------------------------------------------------------------
1 | package call
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 | )
7 |
8 | // TODO: where to put errno?
9 |
10 | type Generic struct {
11 | Num int
12 | Name string
13 | Args []uint64
14 | Ret uint64
15 | }
16 |
17 | func (c *Generic) Base() *Generic {
18 | return c
19 | }
20 |
21 | func (c *Generic) String() string {
22 | strArgs := make([]string, len(c.Args))
23 | for i, v := range c.Args {
24 | strArgs[i] = fmt.Sprintf("0x%x", v)
25 | }
26 | args := strings.Join(strArgs, ", ")
27 | return fmt.Sprintf("%s(%s) = 0x%x", c.Name, args, c.Ret)
28 | }
29 |
30 | type Open struct {
31 | Generic
32 | Path string
33 | Mode, Flags int
34 | Fd int
35 | }
36 |
37 | func (c *Open) String() string {
38 | return fmt.Sprintf("open(%#v, %d, %d) = %d", c.Path, c.Mode, c.Flags, c.Fd)
39 | }
40 |
41 | type Close struct {
42 | Generic
43 | Fd int
44 | }
45 |
46 | func (c *Close) String() string {
47 | return fmt.Sprintf("close(%d)", c.Fd)
48 | }
49 |
50 | type Read struct {
51 | Generic
52 | Fd int
53 | Data []byte
54 | Buf, Size uint64
55 | Ret int
56 | }
57 |
58 | func (c *Read) String() string {
59 | return fmt.Sprintf("read(%d, 0x%x) = (%d) %#v", c.Fd, c.Size, c.Ret, string(c.Data))
60 | }
61 |
62 | type Write struct {
63 | Generic
64 | Fd int
65 | Data []byte
66 | Buf, Size uint64
67 | Ret int
68 | }
69 |
70 | func (c *Write) String() string {
71 | return fmt.Sprintf("write(%d, %#v) = %d", c.Fd, string(c.Data), c.Ret)
72 | }
73 |
74 | type Readv struct {
75 | Generic
76 | Fd int
77 | Iovec, Count uint64
78 | }
79 |
80 | type Writev struct {
81 | Generic
82 | Fd int
83 | Data []byte
84 | Iovec, Count uint64
85 | }
86 |
87 | type Execve struct {
88 | Generic
89 | Path string
90 | Argv []string
91 | Envp []string
92 | }
93 |
94 | func (c *Execve) String() string {
95 | return fmt.Sprintf("execve(%s, %+v, %+v)", c.Path, c.Argv, c.Envp)
96 | }
97 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/sys/codec.go:
--------------------------------------------------------------------------------
1 | package sys
2 |
3 | import (
4 | "encoding/binary"
5 | "errors"
6 | "fmt"
7 |
8 | "github.com/lunixbochs/ghostrace/ghost/memio"
9 | "github.com/lunixbochs/ghostrace/ghost/sys/call"
10 | "github.com/lunixbochs/ghostrace/ghost/sys/num"
11 | )
12 |
13 | type Codec struct {
14 | Arch ArchType
15 | OS OSType
16 | Mem memio.MemIO
17 | }
18 |
19 | func NewCodec(arch ArchType, os OSType, mem memio.MemIO) (*Codec, error) {
20 | if arch != ARCH_X86_64 && os != OS_LINUX {
21 | return nil, errors.New("unsupported arch/os")
22 | }
23 | return &Codec{arch, os, mem}, nil
24 | }
25 |
26 | func (c *Codec) DecodeCall(n int, args []uint64) (Syscall, error) {
27 | return c.decode(n, args, 0, false)
28 | }
29 |
30 | func (c *Codec) DecodeRet(n int, args []uint64, ret uint64) (Syscall, error) {
31 | return c.decode(n, args, ret, true)
32 | }
33 |
34 | func (c *Codec) GetName(n int) string {
35 | name, _ := num.Linux_x86_64[n]
36 | return name
37 | }
38 |
39 | func (c *Codec) decode(n int, args []uint64, ret uint64, done bool) (Syscall, error) {
40 | name, ok := num.Linux_x86_64[n]
41 | if !ok {
42 | return nil, fmt.Errorf("unknown syscall: %d\n", n)
43 | }
44 | if !done {
45 | return nil, errors.New("decoding unfinished syscalls is unimplemented")
46 | }
47 | base := call.Generic{n, name, args, ret}
48 | var out Syscall = &base
49 | var err error
50 | switch name {
51 | case "open":
52 | path, err := c.Mem.ReadStrAt(args[0])
53 | if err != nil {
54 | return nil, err
55 | }
56 | out = &call.Open{base, path, int(args[1]), int(args[2]), int(ret)}
57 | case "close":
58 | out = &call.Close{base, int(args[0])}
59 | case "read":
60 | length := int(int64(ret))
61 | var data []byte
62 | if length > 0 {
63 | data = make([]byte, ret)
64 | _, err = c.Mem.ReadAt(data, args[1])
65 | }
66 | out = &call.Read{base, int(args[0]), data, args[1], args[2], length}
67 | case "readv":
68 | length := int(int64(ret))
69 | var data []byte
70 | if length > 0 {
71 | data = make([]byte, length)
72 | mem := c.Mem.StreamAt(args[1])
73 | // TODO: platform specific
74 | var pos uint64
75 | for _, vec := range iovecRead(mem, args[2], 64, binary.LittleEndian) {
76 | end := vec.Len
77 | if int(pos+end) > length {
78 | end = uint64(length)
79 | }
80 | c.Mem.ReadAt(data[pos:end], vec.Base)
81 | if end == uint64(length) {
82 | break
83 | }
84 | }
85 | }
86 | out = &call.Read{base, int(args[0]), data, args[1], args[2], length}
87 | case "write":
88 | data := make([]byte, args[2])
89 | _, err = c.Mem.ReadAt(data, args[1])
90 | out = &call.Write{base, int(args[0]), data, args[1], args[2], int(int64(ret))}
91 | case "writev":
92 | mem := c.Mem.StreamAt(args[1])
93 | vecs := iovecRead(mem, args[2], 64, binary.LittleEndian)
94 | var size uint64
95 | for _, v := range vecs {
96 | size += v.Len
97 | }
98 | data := make([]byte, 0, size)
99 | for _, vec := range vecs {
100 | pos := uint64(len(data))
101 | data = data[:pos+vec.Len]
102 | c.Mem.ReadAt(data[pos:pos+vec.Len], vec.Base)
103 | }
104 | out = &call.Write{base, int(args[0]), data, args[1], args[2], int(int64(ret))}
105 | case "execve":
106 | path, _ := c.Mem.ReadStrAt(args[0])
107 | var readPointers = func(addr uint64) []uint64 {
108 | var pointers []uint64
109 | var tmp [8]byte
110 | stream := c.Mem.StreamAt(addr)
111 | for {
112 | _, err := stream.Read(tmp[:])
113 | if err != nil {
114 | break
115 | }
116 | ptr := binary.LittleEndian.Uint64(tmp[:])
117 | if ptr == 0 {
118 | break
119 | }
120 | pointers = append(pointers, ptr)
121 | }
122 | return pointers
123 | }
124 | argvAddrs := readPointers(args[1])
125 | argv := make([]string, len(argvAddrs))
126 | for i, addr := range argvAddrs {
127 | argv[i], _ = c.Mem.ReadStrAt(addr)
128 | }
129 | envpAddrs := readPointers(args[2])
130 | envp := make([]string, len(envpAddrs))
131 | for i, addr := range envpAddrs {
132 | envp[i], _ = c.Mem.ReadStrAt(addr)
133 | }
134 | out = &call.Execve{base, path, argv, envp}
135 | }
136 | return out, err
137 | }
138 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/sys/enum.go:
--------------------------------------------------------------------------------
1 | package sys
2 |
3 | type ArchType int
4 | type OSType int
5 |
6 | const (
7 | ARCH_NONE ArchType = iota
8 | ARCH_ARM
9 | ARCH_ARM64
10 | ARCH_MIPS
11 | ARCH_PPC
12 | ARCH_SPARC
13 | ARCH_SPARC64
14 | ARCH_M68K
15 | ARCH_X86
16 | ARCH_X86_64
17 | )
18 |
19 | const (
20 | OS_NONE OSType = iota
21 | OS_LINUX
22 | OS_DARWIN
23 | OS_WIN
24 | OS_FREEBSD
25 | OS_NETBSD
26 | OS_OPENBSD
27 | OS_SOLARIS
28 | )
29 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/sys/iovec.go:
--------------------------------------------------------------------------------
1 | package sys
2 |
3 | import (
4 | "encoding/binary"
5 | "github.com/lunixbochs/struc"
6 | "io"
7 | )
8 |
9 | type Iovec32 struct {
10 | Base uint32
11 | Len uint32
12 | }
13 |
14 | type Iovec64 struct {
15 | Base uint64
16 | Len uint64
17 | }
18 |
19 | func iovecRead(r io.Reader, count uint64, bits int, endian binary.ByteOrder) []Iovec64 {
20 | ret := make([]Iovec64, 0, count)
21 | for i := uint64(0); i < count; i++ {
22 | if bits == 64 {
23 | var iovec Iovec64
24 | struc.UnpackWithOrder(r, &iovec, endian)
25 | ret = append(ret, iovec)
26 | } else {
27 | var iv32 Iovec32
28 | struc.UnpackWithOrder(r, &iv32, endian)
29 | ret = append(ret, Iovec64{uint64(iv32.Base), uint64(iv32.Len)})
30 | }
31 | }
32 | return ret
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/ghostrace/ghost/sys/syscall.go:
--------------------------------------------------------------------------------
1 | package sys
2 |
3 | import "github.com/lunixbochs/ghostrace/ghost/sys/call"
4 |
5 | type Syscall interface {
6 | Base() *call.Generic
7 | String() string
8 | }
9 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Ryan Hileman
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/lunixbochs/struc)
2 |
3 | struc
4 | ====
5 |
6 | Struc exists to pack and unpack C-style structures from bytes, which is useful for binary files and network protocols. It could be considered an alternative to `encoding/binary`, which requires massive boilerplate for some similar operations.
7 |
8 | Take a look at an [example comparing `struc` and `encoding/binary`](https://bochs.info/p/cxvm9)
9 |
10 | Struc considers usability first. That said, it does cache reflection data and aims to be competitive with `encoding/binary` struct packing in every way, including performance.
11 |
12 | Example struct
13 | ----
14 |
15 | ```Go
16 | type Example struct {
17 | Var int `struc:"int32,sizeof=Str"`
18 | Str string
19 | Weird []byte `struc:"[8]int64"`
20 | Var []int `struc:"[]int32,little"`
21 | }
22 | ```
23 |
24 | Struct tag format
25 | ----
26 |
27 | - ```Var []int `struc:"[]int32,little,sizeof=StringField"` ``` will pack Var as a slice of little-endian int32, and link it as the size of `StringField`.
28 | - `sizeof=`: Indicates this field is a number used to track the length of a another field. `sizeof` fields are automatically updated on `Pack()` based on the current length of the tracked field, and are used to size the target field during `Unpack()`.
29 | - Bare values will be parsed as type and endianness.
30 |
31 | Endian formats
32 | ----
33 |
34 | - `big` (default)
35 | - `little`
36 |
37 | Recognized types
38 | ----
39 |
40 | - `pad` - this type ignores field contents and is backed by a `[length]byte` containing nulls
41 | - `bool`
42 | - `byte`
43 | - `int8`, `uint8`
44 | - `int16`, `uint16`
45 | - `int32`, `uint32`
46 | - `int64`, `uint64`
47 | - `float32`
48 | - `float64`
49 |
50 | Types can be indicated as arrays/slices using `[]` syntax. Example: `[]int64`, `[8]int32`.
51 |
52 | Bare slice types (those with no `[size]`) must have a linked `Sizeof` field.
53 |
54 | Private fields are ignored when packing and unpacking.
55 |
56 | Example code
57 | ----
58 |
59 | ```Go
60 | package main
61 |
62 | import (
63 | "bytes"
64 | "github.com/lunixbochs/struc"
65 | )
66 |
67 | type Example struct {
68 | A int `struc:"big"`
69 |
70 | // B will be encoded/decoded as a 16-bit int (a "short")
71 | // but is stored as a native int in the struct
72 | B int `struc:"int16"`
73 |
74 | // the sizeof key links a buffer's size to any int field
75 | Size int `struc:"int8,little,sizeof=Str"`
76 | Str string
77 |
78 | // you can get freaky if you want
79 | Str2 string `struc:"[5]int64"`
80 | }
81 |
82 | func main() {
83 | var buf bytes.Buffer
84 | t := &Example{1, 2, 0, "test", "test2"}
85 | err := struc.Pack(&buf, t)
86 | o := &Example{}
87 | err = struc.Unpack(&buf, o)
88 | }
89 | ```
90 |
91 | Benchmark
92 | ----
93 |
94 | `BenchmarkEncode` uses struc. `Stdlib` benchmarks use equivalent `encoding/binary` code. `Manual` encodes without any reflection, and should be considered an upper bound on performance (which generated code based on struc definitions should be able to achieve).
95 |
96 | ```
97 | BenchmarkEncode 1000000 1265 ns/op
98 | BenchmarkStdlibEncode 1000000 1855 ns/op
99 | BenchmarkManualEncode 5000000 284 ns/op
100 | BenchmarkDecode 1000000 1259 ns/op
101 | BenchmarkStdlibDecode 1000000 1656 ns/op
102 | BenchmarkManualDecode 20000000 89.0 ns/op
103 | ```
104 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/binary.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "encoding/binary"
5 | "io"
6 | "reflect"
7 | )
8 |
9 | type byteWriter struct {
10 | buf []byte
11 | pos int
12 | }
13 |
14 | func (b byteWriter) Write(p []byte) (int, error) {
15 | capacity := len(b.buf) - b.pos
16 | if capacity < len(p) {
17 | p = p[:capacity]
18 | }
19 | if len(p) > 0 {
20 | copy(b.buf[b.pos:], p)
21 | b.pos += len(p)
22 | }
23 | return len(p), nil
24 | }
25 |
26 | type binaryFallback reflect.Value
27 |
28 | func (b binaryFallback) String() string {
29 | return b.String()
30 | }
31 |
32 | func (b binaryFallback) Sizeof(val reflect.Value, options *Options) int {
33 | return binary.Size(val.Interface())
34 | }
35 |
36 | func (b binaryFallback) Pack(buf []byte, val reflect.Value, options *Options) (int, error) {
37 | tmp := byteWriter{buf: buf}
38 | var order binary.ByteOrder = binary.BigEndian
39 | if options.Order != nil {
40 | order = options.Order
41 | }
42 | err := binary.Write(tmp, order, val.Interface())
43 | return tmp.pos, err
44 | }
45 |
46 | func (b binaryFallback) Unpack(r io.Reader, val reflect.Value, options *Options) error {
47 | var order binary.ByteOrder = binary.BigEndian
48 | if options.Order != nil {
49 | order = options.Order
50 | }
51 | return binary.Read(r, order, val.Interface())
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/custom.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "io"
5 | "reflect"
6 | )
7 |
8 | type Custom interface {
9 | Pack(p []byte, opt *Options) (int, error)
10 | Unpack(r io.Reader, length int, opt *Options) error
11 | Size(opt *Options) int
12 | String() string
13 | }
14 |
15 | type customFallback struct {
16 | custom Custom
17 | }
18 |
19 | func (c customFallback) Pack(p []byte, val reflect.Value, opt *Options) (int, error) {
20 | return c.custom.Pack(p, opt)
21 | }
22 |
23 | func (c customFallback) Unpack(r io.Reader, val reflect.Value, opt *Options) error {
24 | return c.custom.Unpack(r, 1, opt)
25 | }
26 |
27 | func (c customFallback) Sizeof(val reflect.Value, opt *Options) int {
28 | return c.custom.Size(opt)
29 | }
30 |
31 | func (c customFallback) String() string {
32 | return c.custom.String()
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/custom_float16.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "encoding/binary"
5 | "io"
6 | "math"
7 | "strconv"
8 | )
9 |
10 | type Float16 float64
11 |
12 | func (f *Float16) Pack(p []byte, opt *Options) (int, error) {
13 | order := opt.Order
14 | if order == nil {
15 | order = binary.BigEndian
16 | }
17 | sign := uint16(0)
18 | if *f < 0 {
19 | sign = 1
20 | }
21 | var frac, exp uint16
22 | if math.IsInf(float64(*f), 0) {
23 | exp = 0x1f
24 | frac = 0
25 | } else if math.IsNaN(float64(*f)) {
26 | exp = 0x1f
27 | frac = 1
28 | } else {
29 | bits := math.Float64bits(float64(*f))
30 | exp64 := (bits >> 52) & 0x7ff
31 | if exp64 != 0 {
32 | exp = uint16((exp64 - 1023 + 15) & 0x1f)
33 | }
34 | frac = uint16((bits >> 42) & 0x3ff)
35 | }
36 | var out uint16
37 | out |= sign << 15
38 | out |= exp << 10
39 | out |= frac & 0x3ff
40 | order.PutUint16(p, out)
41 | return 2, nil
42 | }
43 | func (f *Float16) Unpack(r io.Reader, length int, opt *Options) error {
44 | order := opt.Order
45 | if order == nil {
46 | order = binary.BigEndian
47 | }
48 | var tmp [2]byte
49 | if _, err := r.Read(tmp[:]); err != nil {
50 | return err
51 | }
52 | val := order.Uint16(tmp[:2])
53 | sign := (val >> 15) & 1
54 | exp := int16((val >> 10) & 0x1f)
55 | frac := val & 0x3ff
56 | if exp == 0x1f {
57 | if frac != 0 {
58 | *f = Float16(math.NaN())
59 | } else {
60 | *f = Float16(math.Inf(int(sign)*-2 + 1))
61 | }
62 | } else {
63 | var bits uint64
64 | bits |= uint64(sign) << 63
65 | bits |= uint64(frac) << 42
66 | if exp > 0 {
67 | bits |= uint64(exp-15+1023) << 52
68 | }
69 | *f = Float16(math.Float64frombits(bits))
70 | }
71 | return nil
72 | }
73 | func (f *Float16) Size(opt *Options) int {
74 | return 2
75 | }
76 | func (f *Float16) String() string {
77 | return strconv.FormatFloat(float64(*f), 'g', -1, 32)
78 | }
79 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/legacy.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "encoding/binary"
5 | "io"
6 | )
7 |
8 | // Deprecated. Use PackWithOptions.
9 | func PackWithOrder(w io.Writer, data interface{}, order binary.ByteOrder) error {
10 | return PackWithOptions(w, data, &Options{Order: order})
11 | }
12 |
13 | // Deprecated. Use UnpackWithOptions.
14 | func UnpackWithOrder(r io.Reader, data interface{}, order binary.ByteOrder) error {
15 | return UnpackWithOptions(r, data, &Options{Order: order})
16 | }
17 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/packer.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "io"
5 | "reflect"
6 | )
7 |
8 | type Packer interface {
9 | Pack(buf []byte, val reflect.Value, options *Options) (int, error)
10 | Unpack(r io.Reader, val reflect.Value, options *Options) error
11 | Sizeof(val reflect.Value, options *Options) int
12 | String() string
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/struc.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "encoding/binary"
5 | "fmt"
6 | "io"
7 | "reflect"
8 | )
9 |
10 | type Options struct {
11 | ByteAlign int
12 | PtrSize int
13 | Order binary.ByteOrder
14 | }
15 |
16 | func (o *Options) Validate() error {
17 | if o.PtrSize == 0 {
18 | o.PtrSize = 32
19 | } else {
20 | switch o.PtrSize {
21 | case 8, 16, 32, 64:
22 | default:
23 | return fmt.Errorf("Invalid Options.PtrSize: %d. Must be in (8, 16, 32, 64)", o.PtrSize)
24 | }
25 | }
26 | return nil
27 | }
28 |
29 | var emptyOptions = &Options{}
30 |
31 | func prep(data interface{}) (reflect.Value, Packer, error) {
32 | value := reflect.ValueOf(data)
33 | for value.Kind() == reflect.Ptr {
34 | next := value.Elem().Kind()
35 | if next == reflect.Struct || next == reflect.Ptr {
36 | value = value.Elem()
37 | } else {
38 | break
39 | }
40 | }
41 | switch value.Kind() {
42 | case reflect.Struct:
43 | fields, err := parseFields(value)
44 | return value, fields, err
45 | default:
46 | if !value.IsValid() {
47 | return reflect.Value{}, nil, fmt.Errorf("Invalid reflect.Value for %+v", data)
48 | }
49 | if c, ok := data.(Custom); ok {
50 | return value, customFallback{c}, nil
51 | }
52 | return value, binaryFallback(value), nil
53 | }
54 | }
55 |
56 | func Pack(w io.Writer, data interface{}) error {
57 | return PackWithOptions(w, data, nil)
58 | }
59 |
60 | func PackWithOptions(w io.Writer, data interface{}, options *Options) error {
61 | if options == nil {
62 | options = emptyOptions
63 | }
64 | if err := options.Validate(); err != nil {
65 | return err
66 | }
67 | val, packer, err := prep(data)
68 | if err != nil {
69 | return err
70 | }
71 | if val.Type().Kind() == reflect.String {
72 | val = val.Convert(reflect.TypeOf([]byte{}))
73 | }
74 | size := packer.Sizeof(val, options)
75 | buf := make([]byte, size)
76 | if _, err := packer.Pack(buf, val, options); err != nil {
77 | return err
78 | }
79 | _, err = w.Write(buf)
80 | return err
81 | }
82 |
83 | func Unpack(r io.Reader, data interface{}) error {
84 | return UnpackWithOptions(r, data, nil)
85 | }
86 |
87 | func UnpackWithOptions(r io.Reader, data interface{}, options *Options) error {
88 | if options == nil {
89 | options = emptyOptions
90 | }
91 | if err := options.Validate(); err != nil {
92 | return err
93 | }
94 | val, packer, err := prep(data)
95 | if err != nil {
96 | return err
97 | }
98 | return packer.Unpack(r, val, options)
99 | }
100 |
101 | func Sizeof(data interface{}) (int, error) {
102 | return SizeofWithOptions(data, nil)
103 | }
104 |
105 | func SizeofWithOptions(data interface{}, options *Options) (int, error) {
106 | if options == nil {
107 | options = emptyOptions
108 | }
109 | if err := options.Validate(); err != nil {
110 | return 0, err
111 | }
112 | val, packer, err := prep(data)
113 | if err != nil {
114 | return 0, err
115 | }
116 | return packer.Sizeof(val, options), nil
117 | }
118 |
--------------------------------------------------------------------------------
/vendor/github.com/lunixbochs/struc/types.go:
--------------------------------------------------------------------------------
1 | package struc
2 |
3 | import (
4 | "fmt"
5 | "reflect"
6 | )
7 |
8 | type Type int
9 |
10 | const (
11 | Invalid Type = iota
12 | Pad
13 | Bool
14 | Int
15 | Int8
16 | Uint8
17 | Int16
18 | Uint16
19 | Int32
20 | Uint32
21 | Int64
22 | Uint64
23 | Float32
24 | Float64
25 | String
26 | Struct
27 | Ptr
28 |
29 | SizeType
30 | OffType
31 | CustomType
32 | )
33 |
34 | func (t Type) Resolve(options *Options) Type {
35 | switch t {
36 | case OffType:
37 | switch options.PtrSize {
38 | case 8:
39 | return Int8
40 | case 16:
41 | return Int16
42 | case 32:
43 | return Int32
44 | case 64:
45 | return Int64
46 | default:
47 | panic(fmt.Sprintf("unsupported ptr bits: %d", options.PtrSize))
48 | }
49 | case SizeType:
50 | switch options.PtrSize {
51 | case 8:
52 | return Uint8
53 | case 16:
54 | return Uint16
55 | case 32:
56 | return Uint32
57 | case 64:
58 | return Uint64
59 | default:
60 | panic(fmt.Sprintf("unsupported ptr bits: %d", options.PtrSize))
61 | }
62 | }
63 | return t
64 | }
65 |
66 | func (t Type) String() string {
67 | return typeNames[t]
68 | }
69 |
70 | func (t Type) Size() int {
71 | switch t {
72 | case SizeType, OffType:
73 | panic("Size_t/Off_t types must be converted to another type using options.PtrSize")
74 | case Pad, String, Int8, Uint8, Bool:
75 | return 1
76 | case Int16, Uint16:
77 | return 2
78 | case Int32, Uint32, Float32:
79 | return 4
80 | case Int64, Uint64, Float64:
81 | return 8
82 | default:
83 | panic("Cannot resolve size of type:" + t.String())
84 | }
85 | }
86 |
87 | var typeLookup = map[string]Type{
88 | "pad": Pad,
89 | "bool": Bool,
90 | "byte": Uint8,
91 | "int8": Int8,
92 | "uint8": Uint8,
93 | "int16": Int16,
94 | "uint16": Uint16,
95 | "int32": Int32,
96 | "uint32": Uint32,
97 | "int64": Int64,
98 | "uint64": Uint64,
99 | "float32": Float32,
100 | "float64": Float64,
101 |
102 | "size_t": SizeType,
103 | "off_t": OffType,
104 | }
105 |
106 | var typeNames = map[Type]string{
107 | CustomType: "Custom",
108 | }
109 |
110 | func init() {
111 | for name, enum := range typeLookup {
112 | typeNames[enum] = name
113 | }
114 | }
115 |
116 | type Size_t uint64
117 | type Off_t int64
118 |
119 | var reflectTypeMap = map[reflect.Kind]Type{
120 | reflect.Bool: Bool,
121 | reflect.Int8: Int8,
122 | reflect.Int16: Int16,
123 | reflect.Int: Int32,
124 | reflect.Int32: Int32,
125 | reflect.Int64: Int64,
126 | reflect.Uint8: Uint8,
127 | reflect.Uint16: Uint16,
128 | reflect.Uint: Uint32,
129 | reflect.Uint32: Uint32,
130 | reflect.Uint64: Uint64,
131 | reflect.Float32: Float32,
132 | reflect.Float64: Float64,
133 | reflect.String: String,
134 | reflect.Struct: Struct,
135 | reflect.Ptr: Ptr,
136 | }
137 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-runewidth/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Yasuhiro Matsumoto
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-runewidth/README.mkd:
--------------------------------------------------------------------------------
1 | go-runewidth
2 | ============
3 |
4 | [](https://travis-ci.org/mattn/go-runewidth)
5 | [](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD)
6 | [](http://godoc.org/github.com/mattn/go-runewidth)
7 | [](https://goreportcard.com/report/github.com/mattn/go-runewidth)
8 |
9 | Provides functions to get fixed width of the character or string.
10 |
11 | Usage
12 | -----
13 |
14 | ```go
15 | runewidth.StringWidth("つのだ☆HIRO") == 12
16 | ```
17 |
18 |
19 | Author
20 | ------
21 |
22 | Yasuhiro Matsumoto
23 |
24 | License
25 | -------
26 |
27 | under the MIT License: http://mattn.mit-license.org/2013
28 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-runewidth/runewidth_js.go:
--------------------------------------------------------------------------------
1 | // +build js
2 |
3 | package runewidth
4 |
5 | func IsEastAsian() bool {
6 | // TODO: Implement this for the web. Detect east asian in a compatible way, and return true.
7 | return false
8 | }
9 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-runewidth/runewidth_posix.go:
--------------------------------------------------------------------------------
1 | // +build !windows,!js
2 |
3 | package runewidth
4 |
5 | import (
6 | "os"
7 | "regexp"
8 | "strings"
9 | )
10 |
11 | var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`)
12 |
13 | var mblenTable = map[string]int{
14 | "utf-8": 6,
15 | "utf8": 6,
16 | "jis": 8,
17 | "eucjp": 3,
18 | "euckr": 2,
19 | "euccn": 2,
20 | "sjis": 2,
21 | "cp932": 2,
22 | "cp51932": 2,
23 | "cp936": 2,
24 | "cp949": 2,
25 | "cp950": 2,
26 | "big5": 2,
27 | "gbk": 2,
28 | "gb2312": 2,
29 | }
30 |
31 | func isEastAsian(locale string) bool {
32 | charset := strings.ToLower(locale)
33 | r := reLoc.FindStringSubmatch(locale)
34 | if len(r) == 2 {
35 | charset = strings.ToLower(r[1])
36 | }
37 |
38 | if strings.HasSuffix(charset, "@cjk_narrow") {
39 | return false
40 | }
41 |
42 | for pos, b := range []byte(charset) {
43 | if b == '@' {
44 | charset = charset[:pos]
45 | break
46 | }
47 | }
48 | max := 1
49 | if m, ok := mblenTable[charset]; ok {
50 | max = m
51 | }
52 | if max > 1 && (charset[0] != 'u' ||
53 | strings.HasPrefix(locale, "ja") ||
54 | strings.HasPrefix(locale, "ko") ||
55 | strings.HasPrefix(locale, "zh")) {
56 | return true
57 | }
58 | return false
59 | }
60 |
61 | // IsEastAsian return true if the current locale is CJK
62 | func IsEastAsian() bool {
63 | locale := os.Getenv("LC_CTYPE")
64 | if locale == "" {
65 | locale = os.Getenv("LANG")
66 | }
67 |
68 | // ignore C locale
69 | if locale == "POSIX" || locale == "C" {
70 | return false
71 | }
72 | if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') {
73 | return false
74 | }
75 |
76 | return isEastAsian(locale)
77 | }
78 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-runewidth/runewidth_windows.go:
--------------------------------------------------------------------------------
1 | package runewidth
2 |
3 | import (
4 | "syscall"
5 | )
6 |
7 | var (
8 | kernel32 = syscall.NewLazyDLL("kernel32")
9 | procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP")
10 | )
11 |
12 | // IsEastAsian return true if the current locale is CJK
13 | func IsEastAsian() bool {
14 | r1, _, _ := procGetConsoleOutputCP.Call()
15 | if r1 == 0 {
16 | return false
17 | }
18 |
19 | switch int(r1) {
20 | case 932, 51932, 936, 949, 950:
21 | return true
22 | }
23 |
24 | return false
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/LICENCE.md:
--------------------------------------------------------------------------------
1 | Copyright (C) 2014 by Oleku Konko
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/csv.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Oleku Konko All rights reserved.
2 | // Use of this source code is governed by a MIT
3 | // license that can be found in the LICENSE file.
4 |
5 | // This module is a Table Writer API for the Go Programming Language.
6 | // The protocols were written in pure Go and works on windows and unix systems
7 |
8 | package tablewriter
9 |
10 | import (
11 | "encoding/csv"
12 | "io"
13 | "os"
14 | )
15 |
16 | // Start A new table by importing from a CSV file
17 | // Takes io.Writer and csv File name
18 | func NewCSV(writer io.Writer, fileName string, hasHeader bool) (*Table, error) {
19 | file, err := os.Open(fileName)
20 | if err != nil {
21 | return &Table{}, err
22 | }
23 | defer file.Close()
24 | csvReader := csv.NewReader(file)
25 | t, err := NewCSVReader(writer, csvReader, hasHeader)
26 | return t, err
27 | }
28 |
29 | // Start a New Table Writer with csv.Reader
30 | // This enables customisation such as reader.Comma = ';'
31 | // See http://golang.org/src/pkg/encoding/csv/reader.go?s=3213:3671#L94
32 | func NewCSVReader(writer io.Writer, csvReader *csv.Reader, hasHeader bool) (*Table, error) {
33 | t := NewWriter(writer)
34 | if hasHeader {
35 | // Read the first row
36 | headers, err := csvReader.Read()
37 | if err != nil {
38 | return &Table{}, err
39 | }
40 | t.SetHeader(headers)
41 | }
42 | for {
43 | record, err := csvReader.Read()
44 | if err == io.EOF {
45 | break
46 | } else if err != nil {
47 | return &Table{}, err
48 | }
49 | t.Append(record)
50 | }
51 | return t, nil
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/table_with_color.go:
--------------------------------------------------------------------------------
1 | package tablewriter
2 |
3 | import (
4 | "fmt"
5 | "strconv"
6 | "strings"
7 | )
8 |
9 | const ESC = "\033"
10 | const SEP = ";"
11 |
12 | const (
13 | BgBlackColor int = iota + 40
14 | BgRedColor
15 | BgGreenColor
16 | BgYellowColor
17 | BgBlueColor
18 | BgMagentaColor
19 | BgCyanColor
20 | BgWhiteColor
21 | )
22 |
23 | const (
24 | FgBlackColor int = iota + 30
25 | FgRedColor
26 | FgGreenColor
27 | FgYellowColor
28 | FgBlueColor
29 | FgMagentaColor
30 | FgCyanColor
31 | FgWhiteColor
32 | )
33 |
34 | const (
35 | BgHiBlackColor int = iota + 100
36 | BgHiRedColor
37 | BgHiGreenColor
38 | BgHiYellowColor
39 | BgHiBlueColor
40 | BgHiMagentaColor
41 | BgHiCyanColor
42 | BgHiWhiteColor
43 | )
44 |
45 | const (
46 | FgHiBlackColor int = iota + 90
47 | FgHiRedColor
48 | FgHiGreenColor
49 | FgHiYellowColor
50 | FgHiBlueColor
51 | FgHiMagentaColor
52 | FgHiCyanColor
53 | FgHiWhiteColor
54 | )
55 |
56 | const (
57 | Normal = 0
58 | Bold = 1
59 | UnderlineSingle = 4
60 | Italic
61 | )
62 |
63 | type Colors []int
64 |
65 | func startFormat(seq string) string {
66 | return fmt.Sprintf("%s[%sm", ESC, seq)
67 | }
68 |
69 | func stopFormat() string {
70 | return fmt.Sprintf("%s[%dm", ESC, Normal)
71 | }
72 |
73 | // Making the SGR (Select Graphic Rendition) sequence.
74 | func makeSequence(codes []int) string {
75 | codesInString := []string{}
76 | for _, code := range codes {
77 | codesInString = append(codesInString, strconv.Itoa(code))
78 | }
79 | return strings.Join(codesInString, SEP)
80 | }
81 |
82 | // Adding ANSI escape sequences before and after string
83 | func format(s string, codes interface{}) string {
84 | var seq string
85 |
86 | switch v := codes.(type) {
87 |
88 | case string:
89 | seq = v
90 | case []int:
91 | seq = makeSequence(v)
92 | default:
93 | return s
94 | }
95 |
96 | if len(seq) == 0 {
97 | return s
98 | }
99 | return startFormat(seq) + s + stopFormat()
100 | }
101 |
102 | // Adding header colors (ANSI codes)
103 | func (t *Table) SetHeaderColor(colors ...Colors) {
104 | if t.colSize != len(colors) {
105 | panic("Number of header colors must be equal to number of headers.")
106 | }
107 | for i := 0; i < len(colors); i++ {
108 | t.headerParams = append(t.headerParams, makeSequence(colors[i]))
109 | }
110 | }
111 |
112 | // Adding column colors (ANSI codes)
113 | func (t *Table) SetColumnColor(colors ...Colors) {
114 | if t.colSize != len(colors) {
115 | panic("Number of column colors must be equal to number of headers.")
116 | }
117 | for i := 0; i < len(colors); i++ {
118 | t.columnsParams = append(t.columnsParams, makeSequence(colors[i]))
119 | }
120 | }
121 |
122 | // Adding column colors (ANSI codes)
123 | func (t *Table) SetFooterColor(colors ...Colors) {
124 | if len(t.footers) != len(colors) {
125 | panic("Number of footer colors must be equal to number of footer.")
126 | }
127 | for i := 0; i < len(colors); i++ {
128 | t.footerParams = append(t.footerParams, makeSequence(colors[i]))
129 | }
130 | }
131 |
132 | func Color(colors ...int) []int {
133 | return colors
134 | }
135 |
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/test.csv:
--------------------------------------------------------------------------------
1 | first_name,last_name,ssn
2 | John,Barry,123456
3 | Kathy,Smith,687987
4 | Bob,McCornick,3979870
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/test_info.csv:
--------------------------------------------------------------------------------
1 | Field,Type,Null,Key,Default,Extra
2 | user_id,smallint(5),NO,PRI,NULL,auto_increment
3 | username,varchar(10),NO,,NULL,
4 | password,varchar(100),NO,,NULL,
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/util.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Oleku Konko All rights reserved.
2 | // Use of this source code is governed by a MIT
3 | // license that can be found in the LICENSE file.
4 |
5 | // This module is a Table Writer API for the Go Programming Language.
6 | // The protocols were written in pure Go and works on windows and unix systems
7 |
8 | package tablewriter
9 |
10 | import (
11 | "math"
12 | "regexp"
13 | "strings"
14 |
15 | "github.com/mattn/go-runewidth"
16 | )
17 |
18 | var ansi = regexp.MustCompile("\033\\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]")
19 |
20 | func DisplayWidth(str string) int {
21 | return runewidth.StringWidth(ansi.ReplaceAllLiteralString(str, ""))
22 | }
23 |
24 | // Simple Condition for string
25 | // Returns value based on condition
26 | func ConditionString(cond bool, valid, inValid string) string {
27 | if cond {
28 | return valid
29 | }
30 | return inValid
31 | }
32 |
33 | // Format Table Header
34 | // Replace _ , . and spaces
35 | func Title(name string) string {
36 | name = strings.Replace(name, "_", " ", -1)
37 | name = strings.Replace(name, ".", " ", -1)
38 | name = strings.TrimSpace(name)
39 | return strings.ToUpper(name)
40 | }
41 |
42 | // Pad String
43 | // Attempts to play string in the center
44 | func Pad(s, pad string, width int) string {
45 | gap := width - DisplayWidth(s)
46 | if gap > 0 {
47 | gapLeft := int(math.Ceil(float64(gap / 2)))
48 | gapRight := gap - gapLeft
49 | return strings.Repeat(string(pad), gapLeft) + s + strings.Repeat(string(pad), gapRight)
50 | }
51 | return s
52 | }
53 |
54 | // Pad String Right position
55 | // This would pace string at the left side fo the screen
56 | func PadRight(s, pad string, width int) string {
57 | gap := width - DisplayWidth(s)
58 | if gap > 0 {
59 | return s + strings.Repeat(string(pad), gap)
60 | }
61 | return s
62 | }
63 |
64 | // Pad String Left position
65 | // This would pace string at the right side fo the screen
66 | func PadLeft(s, pad string, width int) string {
67 | gap := width - DisplayWidth(s)
68 | if gap > 0 {
69 | return strings.Repeat(string(pad), gap) + s
70 | }
71 | return s
72 | }
73 |
--------------------------------------------------------------------------------
/vendor/github.com/olekukonko/tablewriter/wrap.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Oleku Konko All rights reserved.
2 | // Use of this source code is governed by a MIT
3 | // license that can be found in the LICENSE file.
4 |
5 | // This module is a Table Writer API for the Go Programming Language.
6 | // The protocols were written in pure Go and works on windows and unix systems
7 |
8 | package tablewriter
9 |
10 | import (
11 | "math"
12 | "strings"
13 |
14 | "github.com/mattn/go-runewidth"
15 | )
16 |
17 | var (
18 | nl = "\n"
19 | sp = " "
20 | )
21 |
22 | const defaultPenalty = 1e5
23 |
24 | // Wrap wraps s into a paragraph of lines of length lim, with minimal
25 | // raggedness.
26 | func WrapString(s string, lim int) ([]string, int) {
27 | words := strings.Split(strings.Replace(s, nl, sp, -1), sp)
28 | var lines []string
29 | max := 0
30 | for _, v := range words {
31 | max = runewidth.StringWidth(v)
32 | if max > lim {
33 | lim = max
34 | }
35 | }
36 | for _, line := range WrapWords(words, 1, lim, defaultPenalty) {
37 | lines = append(lines, strings.Join(line, sp))
38 | }
39 | return lines, lim
40 | }
41 |
42 | // WrapWords is the low-level line-breaking algorithm, useful if you need more
43 | // control over the details of the text wrapping process. For most uses,
44 | // WrapString will be sufficient and more convenient.
45 | //
46 | // WrapWords splits a list of words into lines with minimal "raggedness",
47 | // treating each rune as one unit, accounting for spc units between adjacent
48 | // words on each line, and attempting to limit lines to lim units. Raggedness
49 | // is the total error over all lines, where error is the square of the
50 | // difference of the length of the line and lim. Too-long lines (which only
51 | // happen when a single word is longer than lim units) have pen penalty units
52 | // added to the error.
53 | func WrapWords(words []string, spc, lim, pen int) [][]string {
54 | n := len(words)
55 |
56 | length := make([][]int, n)
57 | for i := 0; i < n; i++ {
58 | length[i] = make([]int, n)
59 | length[i][i] = runewidth.StringWidth(words[i])
60 | for j := i + 1; j < n; j++ {
61 | length[i][j] = length[i][j-1] + spc + runewidth.StringWidth(words[j])
62 | }
63 | }
64 | nbrk := make([]int, n)
65 | cost := make([]int, n)
66 | for i := range cost {
67 | cost[i] = math.MaxInt32
68 | }
69 | for i := n - 1; i >= 0; i-- {
70 | if length[i][n-1] <= lim {
71 | cost[i] = 0
72 | nbrk[i] = n
73 | } else {
74 | for j := i + 1; j < n; j++ {
75 | d := lim - length[i][j-1]
76 | c := d*d + cost[j]
77 | if length[i][j-1] > lim {
78 | c += pen // too-long lines get a worse penalty
79 | }
80 | if c < cost[i] {
81 | cost[i] = c
82 | nbrk[i] = j
83 | }
84 | }
85 | }
86 | }
87 | var lines [][]string
88 | i := 0
89 | for i < n {
90 | lines = append(lines, words[i:nbrk[i]])
91 | i = nbrk[i]
92 | }
93 | return lines
94 | }
95 |
96 | // getLines decomposes a multiline string into a slice of strings.
97 | func getLines(s string) []string {
98 | var lines []string
99 |
100 | for _, line := range strings.Split(s, nl) {
101 | lines = append(lines, line)
102 | }
103 | return lines
104 | }
105 |
--------------------------------------------------------------------------------
/vendor/github.com/ringtail/GOnetstat/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Rafael Santos
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/ringtail/GOnetstat/README.md:
--------------------------------------------------------------------------------
1 | # GOnetstat
2 |
3 | Netstat implementation in Golang.
4 |
5 | This Package get data from /proc/net/tcp|6 and /proc/net/udp|6 and parse
6 | /proc/[0-9]*/fd/[0-9]* to match the correct inode.
7 |
8 | ## Usage
9 |
10 | TCP/UDP
11 | ```go
12 | tcp_data := GOnetstat.Tcp()
13 | udp_data := GOnetstat.Udp()
14 | ```
15 |
16 | This will return a array of a Process struct like this
17 |
18 | ```go
19 | type Process struct {
20 | User string
21 | Name string
22 | Pid string
23 | Exe string
24 | State string
25 | Ip string
26 | Port int64
27 | ForeignIp string
28 | ForeignPort int64
29 | }
30 | ```
31 | So you can loop through data output and format the output of your program
32 | in whatever way you want it.
33 | See the Examples folder!
34 |
35 | TCP6/UDP6
36 | ```go
37 | tcp6_data := GOnetstat.Tcp6()
38 | udp6_data := GOnetstat.Udp6()
39 | ```
40 | The return will be a array of a Process struct like mentioned above.
41 | Still need to create a way to compress the ipv6 because is too long.
42 |
--------------------------------------------------------------------------------
/vendor/github.com/ringtail/go-statfs/README.md:
--------------------------------------------------------------------------------
1 | # go-statfs
2 | [](https://travis-ci.org/ringtail/go-statfs)
3 | [](https://codecov.io/gh/ringtail/go-statfs)
4 | [](https://www.apache.org/licenses/LICENSE-2.0.html)
5 | Statfs implement in golang
6 |
7 | ## Description
8 | go-statfs is similar as command `df` and `df -i`,you can get such a struct from it.
9 |
10 | ```
11 | type DiskInfo struct {
12 | Available int64
13 | Capacity int64
14 | Usage int64
15 | Inodes int64
16 | InodesFree int64
17 | InodesUsed int64
18 | }
19 | ```
20 |
21 | ## Usage
22 |
23 | ```
24 | func TestGetDiskInfo(t *testing.T) {
25 | disUsage, err := GetDiskInfo("/")
26 | if err != nil {
27 | t.Errorf("Failed to get disk info,because of %s", err.Error())
28 | }
29 | t.Logf("available %d, capacity %d, usage %d, inodes %d, inodesFree %d, inodesUsed %d",
30 | disUsage.Available, disUsage.Capacity, disUsage.Usage, disUsage.Inodes, disUsage.InodesFree, disUsage.InodesUsed)
31 | }
32 | ```
33 |
34 | ## License
35 | This software is released under the Apache 2.0 license.
--------------------------------------------------------------------------------
/vendor/github.com/ringtail/go-statfs/statfs.go:
--------------------------------------------------------------------------------
1 | package statfs
2 |
3 | import "golang.org/x/sys/unix"
4 |
5 | type DiskInfo struct {
6 | Available int64
7 | Capacity int64
8 | Usage int64
9 | Inodes int64
10 | InodesFree int64
11 | InodesUsed int64
12 | }
13 |
14 | func GetDiskInfo(path string) (*DiskInfo, error) {
15 | statfs := &unix.Statfs_t{}
16 | err := unix.Statfs(path, statfs)
17 | if err != nil {
18 | return nil, err
19 | }
20 |
21 | // Available is blocks available * fragment size
22 | available := int64(statfs.Bavail) * int64(statfs.Bsize)
23 |
24 | // Capacity is total block count * fragment size
25 | capacity := int64(statfs.Blocks) * int64(statfs.Bsize)
26 |
27 | // Usage is block being used * fragment size (aka block size).
28 | usage := (int64(statfs.Blocks) - int64(statfs.Bfree)) * int64(statfs.Bsize)
29 |
30 | inodes := int64(statfs.Files)
31 | inodesFree := int64(statfs.Ffree)
32 | inodesUsed := inodes - inodesFree
33 |
34 | df := &DiskInfo{
35 | Available: available,
36 | Capacity: capacity,
37 | Usage: usage,
38 | Inodes: inodes,
39 | InodesFree: inodesFree,
40 | InodesUsed: inodesUsed,
41 | }
42 |
43 | return df, nil
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/vendor/github.com/ringtail/sysctl/README.md:
--------------------------------------------------------------------------------
1 | # sysctl
2 | [](https://travis-ci.org/ringtail/sysctl)
3 | [](https://codecov.io/gh/ringtail/sysctl)
4 | [](https://www.apache.org/licenses/LICENSE-2.0.html)
5 |
6 | sysctl implementation in Go
7 |
8 | # Usage Test Cases
9 | case1: List all system kernel settings
10 |
11 | ```
12 | func TestAll(t *testing.T) {
13 | kernel_settings := All()
14 | if kernel_settings != nil {
15 | t.Log("fetch kernel_settings successfully \n")
16 | t.Log(kernel_settings)
17 | return
18 | }
19 | t.Error("Failed to fetch any kernel_setttings")
20 | }
21 | ```
22 | result:
23 |
24 | ```
25 | map[net.ipv4.tcp_moderate_rcvbuf:1
26 | net.ipv4.conf.all.igmpv3_unsolicited_report_interval:1000
27 | net.ipv4.conf.default.rp_filter:0
28 | net.ipv6.route.max_size:4096
29 | net.ipv4.conf.eth1.arp_notify:0
30 | net.dccp.default.retries1:3
31 | net.ipv4.conf.default.forwarding:1
32 | net.ipv6.conf.all.proxy_ndp:0
33 | ...
34 | net.ipv4.conf.default.proxy_arp:0
35 | net.ipv6.neigh.eth1.base_reachable_time_ms:30000
36 | net.ipv6.neigh.eth0.app_solicit:0]
37 | ```
38 |
39 | ---
40 |
41 | case2: Find one specific kernel settings
42 |
43 | ```
44 | func TestFind(t *testing.T) {
45 | kernel_settings := Find("dev.cdrom.debug")
46 | if kernel_settings != nil {
47 | t.Log("fetch kernel_settings successfully \n")
48 | t.Log(kernel_settings)
49 | return
50 | }
51 | t.Error("Failed to fetch any kernel_setttings")
52 | }
53 | ```
54 | result:
55 |
56 | ```
57 | map[dev.cdrom.debug:0]
58 | ```
59 |
60 | ---
61 |
62 | case3: Find one more specific kernel settings
63 |
64 | ```
65 | func TestFindOneMore(t *testing.T) {
66 | kernel_settings := Find("dev.cdrom.debug", "vm.laptop_mode")
67 | if kernel_settings != nil {
68 | t.Log("fetch kernel_settings successfully \n")
69 | t.Log(kernel_settings)
70 | return
71 | }
72 | t.Error("Failed to fetch any kernel_setttings")
73 | }
74 | ```
75 | result:
76 |
77 | ```
78 | map[vm.laptop_mode:1 dev.cdrom.debug:0]
79 | ```
80 |
81 | ---
82 |
83 | case4: Apply one kernel settings
84 |
85 | ```
86 | func TestApply(t *testing.T) {
87 | err := Apply("vm.laptop_mode", "1")
88 | if err != nil {
89 | log.Errorf("Failed to apply kernel settings %v", err.Error())
90 | return
91 | }
92 | t.Log("Apply kernel settings successfully")
93 | }
94 | ```
95 | result:
96 |
97 | ```
98 | Apply kernel settings successfully
99 | ```
100 |
--------------------------------------------------------------------------------
/vendor/github.com/ringtail/sysctl/sysctl.go:
--------------------------------------------------------------------------------
1 | package sysctl
2 |
3 | import (
4 | log "github.com/Sirupsen/logrus"
5 | "io/ioutil"
6 | "os"
7 | "path/filepath"
8 | "strings"
9 | )
10 |
11 | const (
12 | SYSTEM_PROC_DIR = "/proc/sys/"
13 | )
14 |
15 | // export api
16 |
17 | func All() map[string]string {
18 | return walkAndCatFiles(SYSTEM_PROC_DIR)
19 | }
20 |
21 | func Find(names ...string) map[string]string {
22 | settings := make(map[string]string)
23 | for _, name := range names {
24 | settings_file_path := convert_settings_to_path(name)
25 | if _, err := os.Stat(settings_file_path); os.IsNotExist(err) {
26 | log.Warnf("Failed to query settings %v, Because of %v\n", name, err.Error())
27 | continue
28 | }
29 | bytes, err := ioutil.ReadFile(settings_file_path)
30 | if err != nil {
31 | log.Warnf("Failed to read settings %v from proc, Because of %v", name, err.Error())
32 | continue
33 | }
34 | settings[name] = string(bytes)
35 | }
36 | return settings
37 | }
38 |
39 | func Apply(name string, value string) error {
40 | settings_file_path := convert_settings_to_path(name)
41 | if _, err := os.Stat(settings_file_path); os.IsNotExist(err) {
42 | log.Warnf("Failed to apply settings change, Because of %v", err.Error())
43 | return err
44 | }
45 | err := ioutil.WriteFile(settings_file_path, []byte(value), 0644)
46 | if err != nil {
47 | log.Warnf("Failed to apply settings change, Because of %v", err.Error())
48 | }
49 | return err
50 | }
51 |
52 | // internal api
53 |
54 | func walkAndCatFiles(rootPath string) map[string]string {
55 | settings := make(map[string]string)
56 | if !strings.Contains(rootPath, SYSTEM_PROC_DIR) {
57 | log.Warnf("The specific path is invalid %v", rootPath)
58 | return nil
59 | }
60 | fi, err := os.Stat(rootPath)
61 | if err != nil {
62 | log.Warnf("Failed to open files, Because of %v \n", rootPath)
63 | return nil
64 | }
65 | if fi.IsDir() == false {
66 | bytes, err := ioutil.ReadFile(rootPath)
67 | if err != nil {
68 | log.Warnf("Failed to read files, Because of %v", err.Error())
69 | return nil
70 | }
71 | settings_name := convert_path_to_settings(rootPath)
72 | settings[settings_name] = strings.Replace(strings.Trim(string(bytes), "\n"), "\t", " ", -1)
73 | return settings
74 | } else {
75 | files, err := ioutil.ReadDir(rootPath)
76 | if err != nil {
77 | log.Warnf("Failed to list dir, Because of %v", err.Error())
78 | return nil
79 | }
80 | for _, file := range files {
81 | base_path := filepath.Join(rootPath, file.Name())
82 | subfolder_settings := walkAndCatFiles(base_path)
83 | for key, value := range subfolder_settings {
84 | settings[key] = value
85 | }
86 | }
87 | }
88 | return settings
89 | }
90 |
91 | func convert_path_to_settings(path string) string {
92 | name := path[len(SYSTEM_PROC_DIR):]
93 | settings_arr := strings.Split(name, "/")
94 | return strings.Join(settings_arr, ".")
95 | }
96 |
97 | func convert_settings_to_path(name string) string {
98 | settings_arr := strings.Split(name, ".")
99 | return filepath.Join(SYSTEM_PROC_DIR, strings.Join(settings_arr, "/"))
100 | }
101 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009 The Go Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, Darwin
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, Darwin
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 | // +build arm,darwin
7 |
8 | #include "textflag.h"
9 |
10 | //
11 | // System call support for ARM, Darwin
12 | //
13 |
14 | // Just jump to package syscall's implementation for all these functions.
15 | // The runtime may know about them.
16 |
17 | TEXT ·Syscall(SB),NOSPLIT,$0-28
18 | B syscall·Syscall(SB)
19 |
20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
21 | B syscall·Syscall6(SB)
22 |
23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
24 | B syscall·Syscall9(SB)
25 |
26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
27 | B syscall·RawSyscall(SB)
28 |
29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
30 | B syscall·RawSyscall6(SB)
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 | // +build arm64,darwin
7 |
8 | #include "textflag.h"
9 |
10 | //
11 | // System call support for AMD64, Darwin
12 | //
13 |
14 | // Just jump to package syscall's implementation for all these functions.
15 | // The runtime may know about them.
16 |
17 | TEXT ·Syscall(SB),NOSPLIT,$0-56
18 | B syscall·Syscall(SB)
19 |
20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
21 | B syscall·Syscall6(SB)
22 |
23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
24 | B syscall·Syscall9(SB)
25 |
26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
27 | B syscall·RawSyscall(SB)
28 |
29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
30 | B syscall·RawSyscall6(SB)
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, DragonFly
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-64
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_freebsd_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, FreeBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, FreeBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for ARM, FreeBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | B syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | B syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | B syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | B syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | B syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for 386, Linux
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
23 | JMP syscall·RawSyscall(SB)
24 |
25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
26 | JMP syscall·RawSyscall6(SB)
27 |
28 | TEXT ·socketcall(SB),NOSPLIT,$0-36
29 | JMP syscall·socketcall(SB)
30 |
31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
32 | JMP syscall·rawsocketcall(SB)
33 |
34 | TEXT ·seek(SB),NOSPLIT,$0-28
35 | JMP syscall·seek(SB)
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for AMD64, Linux
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
23 | JMP syscall·RawSyscall(SB)
24 |
25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
26 | JMP syscall·RawSyscall6(SB)
27 |
28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16
29 | JMP syscall·gettimeofday(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for arm, Linux
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | B syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | B syscall·Syscall6(SB)
21 |
22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
23 | B syscall·RawSyscall(SB)
24 |
25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
26 | B syscall·RawSyscall6(SB)
27 |
28 | TEXT ·seek(SB),NOSPLIT,$0-32
29 | B syscall·seek(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_arm64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build arm64
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | // Just jump to package syscall's implementation for all these functions.
12 | // The runtime may know about them.
13 |
14 | TEXT ·Syscall(SB),NOSPLIT,$0-56
15 | B syscall·Syscall(SB)
16 |
17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
18 | B syscall·Syscall6(SB)
19 |
20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
21 | B syscall·RawSyscall(SB)
22 |
23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
24 | B syscall·RawSyscall6(SB)
25 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build mips64 mips64le
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for mips64, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-56
19 | JMP syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
22 | JMP syscall·Syscall6(SB)
23 |
24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25 | JMP syscall·RawSyscall(SB)
26 |
27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28 | JMP syscall·RawSyscall6(SB)
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build mips mipsle
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for mips, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-28
19 | JMP syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
22 | JMP syscall·Syscall6(SB)
23 |
24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
25 | JMP syscall·Syscall9(SB)
26 |
27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
28 | JMP syscall·RawSyscall(SB)
29 |
30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
31 | JMP syscall·RawSyscall6(SB)
32 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build ppc64 ppc64le
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for ppc64, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-56
19 | BR syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
22 | BR syscall·Syscall6(SB)
23 |
24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25 | BR syscall·RawSyscall(SB)
26 |
27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28 | BR syscall·RawSyscall6(SB)
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_s390x.s:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build s390x
6 | // +build linux
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for s390x, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-56
19 | BR syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
22 | BR syscall·Syscall6(SB)
23 |
24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25 | BR syscall·RawSyscall(SB)
26 |
27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28 | BR syscall·RawSyscall6(SB)
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_netbsd_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, NetBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, NetBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for ARM, NetBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | B syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | B syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | B syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | B syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | B syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_openbsd_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, OpenBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, OpenBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
11 | //
12 |
13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88
14 | JMP syscall·sysvicall6(SB)
15 |
16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
17 | JMP syscall·rawSysvicall6(SB)
18 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/bluetooth_linux.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Bluetooth sockets and messages
6 |
7 | package unix
8 |
9 | // Bluetooth Protocols
10 | const (
11 | BTPROTO_L2CAP = 0
12 | BTPROTO_HCI = 1
13 | BTPROTO_SCO = 2
14 | BTPROTO_RFCOMM = 3
15 | BTPROTO_BNEP = 4
16 | BTPROTO_CMTP = 5
17 | BTPROTO_HIDP = 6
18 | BTPROTO_AVDTP = 7
19 | )
20 |
21 | const (
22 | HCI_CHANNEL_RAW = 0
23 | HCI_CHANNEL_USER = 1
24 | HCI_CHANNEL_MONITOR = 2
25 | HCI_CHANNEL_CONTROL = 3
26 | )
27 |
28 | // Socketoption Level
29 | const (
30 | SOL_BLUETOOTH = 0x112
31 | SOL_HCI = 0x0
32 | SOL_L2CAP = 0x6
33 | SOL_RFCOMM = 0x12
34 | SOL_SCO = 0x11
35 | )
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/constants.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | const (
10 | R_OK = 0x4
11 | W_OK = 0x2
12 | X_OK = 0x1
13 | )
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/dirent.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | import "unsafe"
10 |
11 | // readInt returns the size-bytes unsigned integer in native byte order at offset off.
12 | func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
13 | if len(b) < int(off+size) {
14 | return 0, false
15 | }
16 | if isBigEndian {
17 | return readIntBE(b[off:], size), true
18 | }
19 | return readIntLE(b[off:], size), true
20 | }
21 |
22 | func readIntBE(b []byte, size uintptr) uint64 {
23 | switch size {
24 | case 1:
25 | return uint64(b[0])
26 | case 2:
27 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
28 | return uint64(b[1]) | uint64(b[0])<<8
29 | case 4:
30 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
31 | return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
32 | case 8:
33 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
34 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
35 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
36 | default:
37 | panic("syscall: readInt with unsupported size")
38 | }
39 | }
40 |
41 | func readIntLE(b []byte, size uintptr) uint64 {
42 | switch size {
43 | case 1:
44 | return uint64(b[0])
45 | case 2:
46 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
47 | return uint64(b[0]) | uint64(b[1])<<8
48 | case 4:
49 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
50 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
51 | case 8:
52 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
53 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
54 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
55 | default:
56 | panic("syscall: readInt with unsupported size")
57 | }
58 | }
59 |
60 | // ParseDirent parses up to max directory entries in buf,
61 | // appending the names to names. It returns the number of
62 | // bytes consumed from buf, the number of entries added
63 | // to names, and the new names slice.
64 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
65 | origlen := len(buf)
66 | count = 0
67 | for max != 0 && len(buf) > 0 {
68 | reclen, ok := direntReclen(buf)
69 | if !ok || reclen > uint64(len(buf)) {
70 | return origlen, count, names
71 | }
72 | rec := buf[:reclen]
73 | buf = buf[reclen:]
74 | ino, ok := direntIno(rec)
75 | if !ok {
76 | break
77 | }
78 | if ino == 0 { // File absent in directory.
79 | continue
80 | }
81 | const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
82 | namlen, ok := direntNamlen(rec)
83 | if !ok || namoff+namlen > uint64(len(rec)) {
84 | break
85 | }
86 | name := rec[namoff : namoff+namlen]
87 | for i, c := range name {
88 | if c == 0 {
89 | name = name[:i]
90 | break
91 | }
92 | }
93 | // Check for useless names before allocating a string.
94 | if string(name) == "." || string(name) == ".." {
95 | continue
96 | }
97 | max--
98 | count++
99 | names = append(names, string(name))
100 | }
101 | return origlen - len(buf), count, names
102 | }
103 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/endian_big.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 | //
5 | // +build ppc64 s390x mips mips64
6 |
7 | package unix
8 |
9 | const isBigEndian = true
10 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/endian_little.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 | //
5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
6 |
7 | package unix
8 |
9 | const isBigEndian = false
10 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/env_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | // Unix environment variables.
8 |
9 | package unix
10 |
11 | import "syscall"
12 |
13 | func Getenv(key string) (value string, found bool) {
14 | return syscall.Getenv(key)
15 | }
16 |
17 | func Setenv(key, value string) error {
18 | return syscall.Setenv(key, value)
19 | }
20 |
21 | func Clearenv() {
22 | syscall.Clearenv()
23 | }
24 |
25 | func Environ() []string {
26 | return syscall.Environ()
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/env_unset.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.4
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | func Unsetenv(key string) error {
12 | // This was added in Go 1.4.
13 | return syscall.Unsetenv(key)
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/flock.go:
--------------------------------------------------------------------------------
1 | // +build linux darwin freebsd openbsd netbsd dragonfly
2 |
3 | // Copyright 2014 The Go Authors. All rights reserved.
4 | // Use of this source code is governed by a BSD-style
5 | // license that can be found in the LICENSE file.
6 |
7 | // +build darwin dragonfly freebsd linux netbsd openbsd
8 |
9 | package unix
10 |
11 | import "unsafe"
12 |
13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64.
15 | var fcntl64Syscall uintptr = SYS_FCNTL
16 |
17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
20 | if errno == 0 {
21 | return nil
22 | }
23 | return errno
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/flock_linux_32bit.go:
--------------------------------------------------------------------------------
1 | // +build linux,386 linux,arm linux,mips linux,mipsle
2 |
3 | // Copyright 2014 The Go Authors. All rights reserved.
4 | // Use of this source code is governed by a BSD-style
5 | // license that can be found in the LICENSE file.
6 |
7 | package unix
8 |
9 | func init() {
10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's
11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
12 | fcntl64Syscall = SYS_FCNTL64
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | // We can't use the gc-syntax .s files for gccgo. On the plus side
12 | // much of the functionality can be written directly in Go.
13 |
14 | //extern gccgoRealSyscall
15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
16 |
17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
18 | syscall.Entersyscall()
19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
20 | syscall.Exitsyscall()
21 | return r, 0, syscall.Errno(errno)
22 | }
23 |
24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
25 | syscall.Entersyscall()
26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
27 | syscall.Exitsyscall()
28 | return r, 0, syscall.Errno(errno)
29 | }
30 |
31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
32 | syscall.Entersyscall()
33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
34 | syscall.Exitsyscall()
35 | return r, 0, syscall.Errno(errno)
36 | }
37 |
38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
40 | return r, 0, syscall.Errno(errno)
41 | }
42 |
43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
45 | return r, 0, syscall.Errno(errno)
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo_c.c:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #define _STRINGIFY2_(x) #x
12 | #define _STRINGIFY_(x) _STRINGIFY2_(x)
13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
14 |
15 | // Call syscall from C code because the gccgo support for calling from
16 | // Go to C does not support varargs functions.
17 |
18 | struct ret {
19 | uintptr_t r;
20 | uintptr_t err;
21 | };
22 |
23 | struct ret
24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
25 | {
26 | struct ret r;
27 |
28 | errno = 0;
29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
30 | r.err = errno;
31 | return r;
32 | }
33 |
34 | // Define the use function in C so that it is not inlined.
35 |
36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
37 |
38 | void
39 | use(void *p __attribute__ ((unused)))
40 | {
41 | }
42 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo,linux,amd64
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | //extern gettimeofday
12 | func realGettimeofday(*Timeval, *byte) int32
13 |
14 | func gettimeofday(tv *Timeval) (err syscall.Errno) {
15 | r := realGettimeofday(tv, nil)
16 | if r < 0 {
17 | return syscall.GetErrno()
18 | }
19 | return 0
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo,linux,sparc64
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | //extern sysconf
12 | func realSysconf(name int) int64
13 |
14 | func sysconf(name int) (n int64, err syscall.Errno) {
15 | r := realSysconf(name)
16 | if r < 0 {
17 | return 0, syscall.GetErrno()
18 | }
19 | return r, 0
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mkpost.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | // mkpost processes the output of cgo -godefs to
8 | // modify the generated types. It is used to clean up
9 | // the sys API in an architecture specific manner.
10 | //
11 | // mkpost is run after cgo -godefs; see README.md.
12 | package main
13 |
14 | import (
15 | "bytes"
16 | "fmt"
17 | "go/format"
18 | "io/ioutil"
19 | "log"
20 | "os"
21 | "regexp"
22 | )
23 |
24 | func main() {
25 | // Get the OS and architecture (using GOARCH_TARGET if it exists)
26 | goos := os.Getenv("GOOS")
27 | goarch := os.Getenv("GOARCH_TARGET")
28 | if goarch == "" {
29 | goarch = os.Getenv("GOARCH")
30 | }
31 | // Check that we are using the new build system if we should be.
32 | if goos == "linux" && goarch != "sparc64" {
33 | if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
34 | os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n")
35 | os.Stderr.WriteString("See README.md\n")
36 | os.Exit(1)
37 | }
38 | }
39 |
40 | b, err := ioutil.ReadAll(os.Stdin)
41 | if err != nil {
42 | log.Fatal(err)
43 | }
44 |
45 | // If we have empty Ptrace structs, we should delete them. Only s390x emits
46 | // nonempty Ptrace structs.
47 | ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
48 | b = ptraceRexexp.ReplaceAll(b, nil)
49 |
50 | // Replace the control_regs union with a blank identifier for now.
51 | controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`)
52 | b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64"))
53 |
54 | // Remove fields that are added by glibc
55 | // Note that this is unstable as the identifers are private.
56 | removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`)
57 | b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
58 |
59 | // We refuse to export private fields on s390x
60 | if goarch == "s390x" && goos == "linux" {
61 | // Remove cgo padding fields
62 | removeFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`)
63 | b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
64 |
65 | // Remove padding, hidden, or unused fields
66 | removeFieldsRegex = regexp.MustCompile(`X_\S+`)
67 | b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
68 | }
69 |
70 | // Remove the first line of warning from cgo
71 | b = b[bytes.IndexByte(b, '\n')+1:]
72 | // Modify the command in the header to include:
73 | // mkpost, our own warning, and a build tag.
74 | replacement := fmt.Sprintf(`$1 | go run mkpost.go
75 | // Code generated by the command above; see README.md. DO NOT EDIT.
76 |
77 | // +build %s,%s`, goarch, goos)
78 | cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
79 | b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
80 |
81 | // gofmt
82 | b, err = format.Source(b)
83 | if err != nil {
84 | log.Fatal(err)
85 | }
86 |
87 | os.Stdout.Write(b)
88 | }
89 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 | #
6 | # Generate system call table for Darwin from sys/syscall.h
7 |
8 | use strict;
9 |
10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
11 | print STDERR "GOARCH or GOOS not defined in environment\n";
12 | exit 1;
13 | }
14 |
15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
16 |
17 | print <){
29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
30 | my $name = $1;
31 | my $num = $2;
32 | $name =~ y/a-z/A-Z/;
33 | print " SYS_$name = $num;"
34 | }
35 | }
36 |
37 | print <){
30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
31 | my $num = $1;
32 | my $proto = $2;
33 | my $name = "SYS_$3";
34 | $name =~ y/a-z/A-Z/;
35 |
36 | # There are multiple entries for enosys and nosys, so comment them out.
37 | if($name =~ /^SYS_E?NOSYS$/){
38 | $name = "// $name";
39 | }
40 | if($name eq 'SYS_SYS_EXIT'){
41 | $name = 'SYS_EXIT';
42 | }
43 |
44 | print " $name = $num; // $proto\n";
45 | }
46 | }
47 |
48 | print <){
30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
31 | my $num = $1;
32 | my $proto = $2;
33 | my $name = "SYS_$3";
34 | $name =~ y/a-z/A-Z/;
35 |
36 | # There are multiple entries for enosys and nosys, so comment them out.
37 | if($name =~ /^SYS_E?NOSYS$/){
38 | $name = "// $name";
39 | }
40 | if($name eq 'SYS_SYS_EXIT'){
41 | $name = 'SYS_EXIT';
42 | }
43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
44 | next
45 | }
46 |
47 | print " $name = $num; // $proto\n";
48 |
49 | # We keep Capsicum syscall numbers for FreeBSD
50 | # 9-STABLE here because we are not sure whether they
51 | # are mature and stable.
52 | if($num == 513){
53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
57 | }
58 | }
59 | }
60 |
61 | print <){
31 | if($line =~ /^(.*)\\$/) {
32 | # Handle continuation
33 | $line = $1;
34 | $_ =~ s/^\s+//;
35 | $line .= $_;
36 | } else {
37 | # New line
38 | $line = $_;
39 | }
40 | next if $line =~ /\\$/;
41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
42 | my $num = $1;
43 | my $proto = $6;
44 | my $compat = $8;
45 | my $name = "$7_$9";
46 |
47 | $name = "$7_$11" if $11 ne '';
48 | $name =~ y/a-z/A-Z/;
49 |
50 | if($compat eq '' || $compat eq '30' || $compat eq '50') {
51 | print " $name = $num; // $proto\n";
52 | }
53 | }
54 | }
55 |
56 | print <){
30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
31 | my $num = $1;
32 | my $proto = $3;
33 | my $name = $4;
34 | $name =~ y/a-z/A-Z/;
35 |
36 | # There are multiple entries for enosys and nosys, so comment them out.
37 | if($name =~ /^SYS_E?NOSYS$/){
38 | $name = "// $name";
39 | }
40 | if($name eq 'SYS_SYS_EXIT'){
41 | $name = 'SYS_EXIT';
42 | }
43 |
44 | print " $name = $num; // $proto\n";
45 | }
46 | }
47 |
48 | print < uint64(len(b)) {
67 | return nil, nil, EINVAL
68 | }
69 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
70 | }
71 |
72 | // UnixRights encodes a set of open file descriptors into a socket
73 | // control message for sending to another process.
74 | func UnixRights(fds ...int) []byte {
75 | datalen := len(fds) * 4
76 | b := make([]byte, CmsgSpace(datalen))
77 | h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
78 | h.Level = SOL_SOCKET
79 | h.Type = SCM_RIGHTS
80 | h.SetLen(CmsgLen(datalen))
81 | data := cmsgData(h)
82 | for _, fd := range fds {
83 | *(*int32)(data) = int32(fd)
84 | data = unsafe.Pointer(uintptr(data) + 4)
85 | }
86 | return b
87 | }
88 |
89 | // ParseUnixRights decodes a socket control message that contains an
90 | // integer array of open file descriptors from another process.
91 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
92 | if m.Header.Level != SOL_SOCKET {
93 | return nil, EINVAL
94 | }
95 | if m.Header.Type != SCM_RIGHTS {
96 | return nil, EINVAL
97 | }
98 | fds := make([]int, len(m.Data)>>2)
99 | for i, j := 0, 0; i < len(m.Data); i += 4 {
100 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
101 | j++
102 | }
103 | return fds, nil
104 | }
105 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/str.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency
10 | if val < 0 {
11 | return "-" + uitoa(uint(-val))
12 | }
13 | return uitoa(uint(val))
14 | }
15 |
16 | func uitoa(val uint) string {
17 | var buf [32]byte // big enough for int64
18 | i := len(buf) - 1
19 | for val >= 10 {
20 | buf[i] = byte(val%10 + '0')
21 | i--
22 | val /= 10
23 | }
24 | buf[i] = byte(val + '0')
25 | return string(buf[i:])
26 | }
27 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | // Package unix contains an interface to the low-level operating system
8 | // primitives. OS details vary depending on the underlying system, and
9 | // by default, godoc will display OS-specific documentation for the current
10 | // system. If you want godoc to display OS documentation for another
11 | // system, set $GOOS and $GOARCH to the desired system. For example, if
12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
13 | // to freebsd and $GOARCH to arm.
14 | // The primary use of this package is inside other packages that provide a more
15 | // portable interface to the system, such as "os", "time" and "net". Use
16 | // those packages rather than this one if you can.
17 | // For details of the functions and data types in this package consult
18 | // the manuals for the appropriate operating system.
19 | // These calls return err == nil to indicate success; otherwise
20 | // err represents an operating system error describing the failure and
21 | // holds a value of type syscall.Errno.
22 | package unix // import "golang.org/x/sys/unix"
23 |
24 | // ByteSliceFromString returns a NUL-terminated slice of bytes
25 | // containing the text of s. If s contains a NUL byte at any
26 | // location, it returns (nil, EINVAL).
27 | func ByteSliceFromString(s string) ([]byte, error) {
28 | for i := 0; i < len(s); i++ {
29 | if s[i] == 0 {
30 | return nil, EINVAL
31 | }
32 | }
33 | a := make([]byte, len(s)+1)
34 | copy(a, s)
35 | return a, nil
36 | }
37 |
38 | // BytePtrFromString returns a pointer to a NUL-terminated array of
39 | // bytes containing the text of s. If s contains a NUL byte at any
40 | // location, it returns (nil, EINVAL).
41 | func BytePtrFromString(s string) (*byte, error) {
42 | a, err := ByteSliceFromString(s)
43 | if err != nil {
44 | return nil, err
45 | }
46 | return &a[0], nil
47 | }
48 |
49 | // Single-word zero for use when we need a valid pointer to 0 bytes.
50 | // See mkunix.pl.
51 | var _zero uintptr
52 |
53 | func (ts *Timespec) Unix() (sec int64, nsec int64) {
54 | return int64(ts.Sec), int64(ts.Nsec)
55 | }
56 |
57 | func (tv *Timeval) Unix() (sec int64, nsec int64) {
58 | return int64(tv.Sec), int64(tv.Usec) * 1000
59 | }
60 |
61 | func (ts *Timespec) Nano() int64 {
62 | return int64(ts.Sec)*1e9 + int64(ts.Nsec)
63 | }
64 |
65 | func (tv *Timeval) Nano() int64 {
66 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
67 | }
68 |
69 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
70 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,darwin
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = int32(nsec / 1e9)
20 | ts.Nsec = int32(nsec % 1e9)
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = int32(nsec / 1e9)
28 | return
29 | }
30 |
31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
32 | func Gettimeofday(tv *Timeval) (err error) {
33 | // The tv passed to gettimeofday must be non-nil
34 | // but is otherwise unused. The answers come back
35 | // in the two registers.
36 | sec, usec, err := gettimeofday(tv)
37 | tv.Sec = int32(sec)
38 | tv.Usec = int32(usec)
39 | return err
40 | }
41 |
42 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
43 | k.Ident = uint32(fd)
44 | k.Filter = int16(mode)
45 | k.Flags = uint16(flags)
46 | }
47 |
48 | func (iov *Iovec) SetLen(length int) {
49 | iov.Len = uint32(length)
50 | }
51 |
52 | func (msghdr *Msghdr) SetControllen(length int) {
53 | msghdr.Controllen = uint32(length)
54 | }
55 |
56 | func (cmsg *Cmsghdr) SetLen(length int) {
57 | cmsg.Len = uint32(length)
58 | }
59 |
60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
61 | var length = uint64(count)
62 |
63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
64 |
65 | written = int(length)
66 |
67 | if e1 != 0 {
68 | err = e1
69 | }
70 | return
71 | }
72 |
73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
74 |
75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
76 | // of darwin/386 the syscall is called sysctl instead of __sysctl.
77 | const SYS___SYSCTL = SYS_SYSCTL
78 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,darwin
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
15 |
16 | func Getpagesize() int { return 4096 }
17 |
18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
19 |
20 | func NsecToTimespec(nsec int64) (ts Timespec) {
21 | ts.Sec = nsec / 1e9
22 | ts.Nsec = nsec % 1e9
23 | return
24 | }
25 |
26 | func NsecToTimeval(nsec int64) (tv Timeval) {
27 | nsec += 999 // round up to microsecond
28 | tv.Usec = int32(nsec % 1e9 / 1e3)
29 | tv.Sec = int64(nsec / 1e9)
30 | return
31 | }
32 |
33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
34 | func Gettimeofday(tv *Timeval) (err error) {
35 | // The tv passed to gettimeofday must be non-nil
36 | // but is otherwise unused. The answers come back
37 | // in the two registers.
38 | sec, usec, err := gettimeofday(tv)
39 | tv.Sec = sec
40 | tv.Usec = usec
41 | return err
42 | }
43 |
44 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
45 | k.Ident = uint64(fd)
46 | k.Filter = int16(mode)
47 | k.Flags = uint16(flags)
48 | }
49 |
50 | func (iov *Iovec) SetLen(length int) {
51 | iov.Len = uint64(length)
52 | }
53 |
54 | func (msghdr *Msghdr) SetControllen(length int) {
55 | msghdr.Controllen = uint32(length)
56 | }
57 |
58 | func (cmsg *Cmsghdr) SetLen(length int) {
59 | cmsg.Len = uint32(length)
60 | }
61 |
62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
63 | var length = uint64(count)
64 |
65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
66 |
67 | written = int(length)
68 |
69 | if e1 != 0 {
70 | err = e1
71 | }
72 | return
73 | }
74 |
75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
76 |
77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl.
79 | const SYS___SYSCTL = SYS_SYSCTL
80 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package unix
6 |
7 | import (
8 | "syscall"
9 | "unsafe"
10 | )
11 |
12 | func Getpagesize() int { return 4096 }
13 |
14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
15 |
16 | func NsecToTimespec(nsec int64) (ts Timespec) {
17 | ts.Sec = int32(nsec / 1e9)
18 | ts.Nsec = int32(nsec % 1e9)
19 | return
20 | }
21 |
22 | func NsecToTimeval(nsec int64) (tv Timeval) {
23 | nsec += 999 // round up to microsecond
24 | tv.Usec = int32(nsec % 1e9 / 1e3)
25 | tv.Sec = int32(nsec / 1e9)
26 | return
27 | }
28 |
29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
30 | func Gettimeofday(tv *Timeval) (err error) {
31 | // The tv passed to gettimeofday must be non-nil
32 | // but is otherwise unused. The answers come back
33 | // in the two registers.
34 | sec, usec, err := gettimeofday(tv)
35 | tv.Sec = int32(sec)
36 | tv.Usec = int32(usec)
37 | return err
38 | }
39 |
40 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
41 | k.Ident = uint32(fd)
42 | k.Filter = int16(mode)
43 | k.Flags = uint16(flags)
44 | }
45 |
46 | func (iov *Iovec) SetLen(length int) {
47 | iov.Len = uint32(length)
48 | }
49 |
50 | func (msghdr *Msghdr) SetControllen(length int) {
51 | msghdr.Controllen = uint32(length)
52 | }
53 |
54 | func (cmsg *Cmsghdr) SetLen(length int) {
55 | cmsg.Len = uint32(length)
56 | }
57 |
58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
59 | var length = uint64(count)
60 |
61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
62 |
63 | written = int(length)
64 |
65 | if e1 != 0 {
66 | err = e1
67 | }
68 | return
69 | }
70 |
71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
72 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build arm64,darwin
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 16384 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = nsec / 1e9
20 | ts.Nsec = nsec % 1e9
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = int64(nsec / 1e9)
28 | return
29 | }
30 |
31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
32 | func Gettimeofday(tv *Timeval) (err error) {
33 | // The tv passed to gettimeofday must be non-nil
34 | // but is otherwise unused. The answers come back
35 | // in the two registers.
36 | sec, usec, err := gettimeofday(tv)
37 | tv.Sec = sec
38 | tv.Usec = usec
39 | return err
40 | }
41 |
42 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
43 | k.Ident = uint64(fd)
44 | k.Filter = int16(mode)
45 | k.Flags = uint16(flags)
46 | }
47 |
48 | func (iov *Iovec) SetLen(length int) {
49 | iov.Len = uint64(length)
50 | }
51 |
52 | func (msghdr *Msghdr) SetControllen(length int) {
53 | msghdr.Controllen = uint32(length)
54 | }
55 |
56 | func (cmsg *Cmsghdr) SetLen(length int) {
57 | cmsg.Len = uint32(length)
58 | }
59 |
60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
61 | var length = uint64(count)
62 |
63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
64 |
65 | written = int(length)
66 |
67 | if e1 != 0 {
68 | err = e1
69 | }
70 | return
71 | }
72 |
73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
74 |
75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl.
77 | const SYS___SYSCTL = SYS_SYSCTL
78 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,dragonfly
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = nsec / 1e9
20 | ts.Nsec = nsec % 1e9
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = nsec % 1e9 / 1e3
27 | tv.Sec = int64(nsec / 1e9)
28 | return
29 | }
30 |
31 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
32 | k.Ident = uint64(fd)
33 | k.Filter = int16(mode)
34 | k.Flags = uint16(flags)
35 | }
36 |
37 | func (iov *Iovec) SetLen(length int) {
38 | iov.Len = uint64(length)
39 | }
40 |
41 | func (msghdr *Msghdr) SetControllen(length int) {
42 | msghdr.Controllen = uint32(length)
43 | }
44 |
45 | func (cmsg *Cmsghdr) SetLen(length int) {
46 | cmsg.Len = uint32(length)
47 | }
48 |
49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50 | var writtenOut uint64 = 0
51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
52 |
53 | written = int(writtenOut)
54 |
55 | if e1 != 0 {
56 | err = e1
57 | }
58 | return
59 | }
60 |
61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,freebsd
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = int32(nsec / 1e9)
20 | ts.Nsec = int32(nsec % 1e9)
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = int32(nsec / 1e9)
28 | return
29 | }
30 |
31 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
32 | k.Ident = uint32(fd)
33 | k.Filter = int16(mode)
34 | k.Flags = uint16(flags)
35 | }
36 |
37 | func (iov *Iovec) SetLen(length int) {
38 | iov.Len = uint32(length)
39 | }
40 |
41 | func (msghdr *Msghdr) SetControllen(length int) {
42 | msghdr.Controllen = uint32(length)
43 | }
44 |
45 | func (cmsg *Cmsghdr) SetLen(length int) {
46 | cmsg.Len = uint32(length)
47 | }
48 |
49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50 | var writtenOut uint64 = 0
51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
52 |
53 | written = int(writtenOut)
54 |
55 | if e1 != 0 {
56 | err = e1
57 | }
58 | return
59 | }
60 |
61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,freebsd
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = nsec / 1e9
20 | ts.Nsec = nsec % 1e9
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = nsec % 1e9 / 1e3
27 | tv.Sec = int64(nsec / 1e9)
28 | return
29 | }
30 |
31 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
32 | k.Ident = uint64(fd)
33 | k.Filter = int16(mode)
34 | k.Flags = uint16(flags)
35 | }
36 |
37 | func (iov *Iovec) SetLen(length int) {
38 | iov.Len = uint64(length)
39 | }
40 |
41 | func (msghdr *Msghdr) SetControllen(length int) {
42 | msghdr.Controllen = uint32(length)
43 | }
44 |
45 | func (cmsg *Cmsghdr) SetLen(length int) {
46 | cmsg.Len = uint32(length)
47 | }
48 |
49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50 | var writtenOut uint64 = 0
51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
52 |
53 | written = int(writtenOut)
54 |
55 | if e1 != 0 {
56 | err = e1
57 | }
58 | return
59 | }
60 |
61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build arm,freebsd
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = nsec / 1e9
20 | ts.Nsec = int32(nsec % 1e9)
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = nsec / 1e9
28 | return
29 | }
30 |
31 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
32 | k.Ident = uint32(fd)
33 | k.Filter = int16(mode)
34 | k.Flags = uint16(flags)
35 | }
36 |
37 | func (iov *Iovec) SetLen(length int) {
38 | iov.Len = uint32(length)
39 | }
40 |
41 | func (msghdr *Msghdr) SetControllen(length int) {
42 | msghdr.Controllen = uint32(length)
43 | }
44 |
45 | func (cmsg *Cmsghdr) SetLen(length int) {
46 | cmsg.Len = uint32(length)
47 | }
48 |
49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50 | var writtenOut uint64 = 0
51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
52 |
53 | written = int(writtenOut)
54 |
55 | if e1 != 0 {
56 | err = e1
57 | }
58 | return
59 | }
60 |
61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,linux
6 | // +build !gccgo
7 |
8 | package unix
9 |
10 | import "syscall"
11 |
12 | //go:noescape
13 | func gettimeofday(tv *Timeval) (err syscall.Errno)
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,netbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int32(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint32(fd)
28 | k.Filter = uint32(mode)
29 | k.Flags = uint32(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint32(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,netbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int64(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint64(fd)
28 | k.Filter = uint32(mode)
29 | k.Flags = uint32(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint64(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build arm,netbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int32(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint32(fd)
28 | k.Filter = uint32(mode)
29 | k.Flags = uint32(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint32(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_no_getwd.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build dragonfly freebsd netbsd openbsd
6 |
7 | package unix
8 |
9 | const ImplementsGetwd = false
10 |
11 | func Getwd() (string, error) { return "", ENOTSUP }
12 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,openbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int32(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint32(fd)
28 | k.Filter = int16(mode)
29 | k.Flags = uint16(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint32(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,openbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = nsec / 1e9
15 | ts.Nsec = nsec % 1e9
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = nsec % 1e9 / 1e3
22 | tv.Sec = nsec / 1e9
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint64(fd)
28 | k.Filter = int16(mode)
29 | k.Flags = uint16(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint64(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,solaris
6 |
7 | package unix
8 |
9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
10 |
11 | func NsecToTimespec(nsec int64) (ts Timespec) {
12 | ts.Sec = nsec / 1e9
13 | ts.Nsec = nsec % 1e9
14 | return
15 | }
16 |
17 | func NsecToTimeval(nsec int64) (tv Timeval) {
18 | nsec += 999 // round up to microsecond
19 | tv.Usec = nsec % 1e9 / 1e3
20 | tv.Sec = int64(nsec / 1e9)
21 | return
22 | }
23 |
24 | func (iov *Iovec) SetLen(length int) {
25 | iov.Len = uint64(length)
26 | }
27 |
28 | func (cmsg *Cmsghdr) SetLen(length int) {
29 | cmsg.Len = uint32(length)
30 | }
31 |
32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
33 | // TODO(aram): implement this, see issue 5847.
34 | panic("unimplemented")
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_unix_gc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 | // +build !gccgo
7 |
8 | package unix
9 |
10 | import "syscall"
11 |
12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
16 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,solaris
6 |
7 | package unix
8 |
9 | // TODO(aram): remove these before Go 1.3.
10 | const (
11 | SYS_EXECVE = 59
12 | SYS_FCNTL = 62
13 | )
14 |
--------------------------------------------------------------------------------
/vendor/vendor.json:
--------------------------------------------------------------------------------
1 | {
2 | "comment": "",
3 | "ignore": "test",
4 | "package": [
5 | {
6 | "checksumSHA1": "dGXnnR7ZhsrZNnEqFimk6q7YCqs=",
7 | "path": "github.com/Sirupsen/logrus",
8 | "revision": "61e43dc76f7ee59a82bdf3d71033dc12bea4c77d",
9 | "revisionTime": "2017-01-13T01:19:11Z"
10 | },
11 | {
12 | "checksumSHA1": "d9Rs1y1rOWhOOE6tal5O9OpkBEQ=",
13 | "path": "github.com/drael/GOnetstat",
14 | "revision": "a08125f5157d481dd0d0355c021467bd8c84eb6d",
15 | "revisionTime": "2015-11-20T22:08:30Z"
16 | },
17 | {
18 | "checksumSHA1": "Z2LEpah3ZMTYNpRy7Rd+tI+T+W0=",
19 | "path": "github.com/fatih/structs",
20 | "revision": "f5faa72e73092639913f5833b75e1ac1d6bc7a63",
21 | "revisionTime": "2017-10-20T06:48:19Z"
22 | },
23 | {
24 | "checksumSHA1": "YlH8m7ins7mlVyjsm5vo11hjUNc=",
25 | "path": "github.com/lunixbochs/ghostrace",
26 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
27 | "revisionTime": "2017-12-05T19:00:53Z"
28 | },
29 | {
30 | "checksumSHA1": "SxC7f1n6HYiyYEilAYuvkRpm1I0=",
31 | "path": "github.com/lunixbochs/ghostrace/ghost",
32 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
33 | "revisionTime": "2017-12-05T19:00:53Z"
34 | },
35 | {
36 | "checksumSHA1": "50Kn3lWHPz1kjnK8faEN5gpzHRU=",
37 | "path": "github.com/lunixbochs/ghostrace/ghost/memio",
38 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
39 | "revisionTime": "2017-12-05T19:00:53Z"
40 | },
41 | {
42 | "checksumSHA1": "JBhvhs5nXUSmZzxPfY1vsS5DGTc=",
43 | "path": "github.com/lunixbochs/ghostrace/ghost/process",
44 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
45 | "revisionTime": "2017-12-05T19:00:53Z"
46 | },
47 | {
48 | "checksumSHA1": "frd9a7CLsPndk5KzjT5d4iENs6o=",
49 | "path": "github.com/lunixbochs/ghostrace/ghost/sys",
50 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
51 | "revisionTime": "2017-12-05T19:00:53Z"
52 | },
53 | {
54 | "checksumSHA1": "tbYiT83e/vFuskcGYg9fHh7pYsQ=",
55 | "path": "github.com/lunixbochs/ghostrace/ghost/sys/call",
56 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
57 | "revisionTime": "2017-12-05T19:00:53Z"
58 | },
59 | {
60 | "checksumSHA1": "k9unnxDyCVIQhuzIXkuvLpdFo0A=",
61 | "path": "github.com/lunixbochs/ghostrace/ghost/sys/num",
62 | "revision": "4410d44f27b61f86a8b6901ce307928bcd5635df",
63 | "revisionTime": "2017-12-05T19:00:53Z"
64 | },
65 | {
66 | "checksumSHA1": "VFKWmbPCdSOahktIMpHBeNVrOVM=",
67 | "path": "github.com/lunixbochs/struc",
68 | "revision": "ef56447db6a068ad9e52bc54a1aff5fb9e1ed2dd",
69 | "revisionTime": "2017-08-31T18:37:20Z"
70 | },
71 | {
72 | "checksumSHA1": "cJE7dphDlam/i7PhnsyosNWtbd4=",
73 | "path": "github.com/mattn/go-runewidth",
74 | "revision": "97311d9f7767e3d6f422ea06661bc2c7a19e8a5d",
75 | "revisionTime": "2017-05-10T07:48:58Z"
76 | },
77 | {
78 | "checksumSHA1": "xOuDLNlycARp+sA0Ob/1oWT0mYs=",
79 | "path": "github.com/olekukonko/tablewriter",
80 | "revision": "a7a4c189eb47ed33ce7b35f2880070a0c82a67d4",
81 | "revisionTime": "2017-09-25T23:40:30Z"
82 | },
83 | {
84 | "checksumSHA1": "SnVSA0xgYWfpwzrs+1TiiekTXg0=",
85 | "path": "github.com/ringtail/GOnetstat",
86 | "revision": "9f661425cded943a2290f913067c16989693ea45",
87 | "revisionTime": "2017-12-02T15:43:56Z"
88 | },
89 | {
90 | "checksumSHA1": "ANQkdJhOGi0XQ5j4UNgoddGzBt8=",
91 | "path": "github.com/ringtail/go-statfs",
92 | "revision": "38116532c370e865858dd8c3c13dd4978eb7018a",
93 | "revisionTime": "2017-12-12T07:46:26Z"
94 | },
95 | {
96 | "checksumSHA1": "3DUI21C1Mi2Q2eO8Qau/W8r+5gs=",
97 | "path": "github.com/ringtail/sysctl",
98 | "revision": "859a433d06ffddb62f88f013dbf6c5fac05c1f35",
99 | "revisionTime": "2017-12-02T15:50:47Z"
100 | },
101 | {
102 | "checksumSHA1": "To5eWGIjHQcw3pQ0N1uFepqaxmE=",
103 | "path": "golang.org/x/sys/unix",
104 | "revision": "739734461d1c916b6c72a63d7efda2b27edb369f",
105 | "revisionTime": "2017-07-07T11:51:12Z"
106 | }
107 | ],
108 | "rootPath": "github.com/ringtail/snout"
109 | }
110 |
--------------------------------------------------------------------------------