mirror of https://github.com/ethereum/go-ethereum
* cmd/puppeth: handle encrypted ssh keys * cmd/puppeth: fix unconvert linter errorpull/15464/head
parent
f47adc9ea8
commit
cb8bbe7081
@ -0,0 +1,173 @@ |
||||
# Building `sys/unix` |
||||
|
||||
The sys/unix package provides access to the raw system call interface of the |
||||
underlying operating system. See: https://godoc.org/golang.org/x/sys/unix |
||||
|
||||
Porting Go to a new architecture/OS combination or adding syscalls, types, or |
||||
constants to an existing architecture/OS pair requires some manual effort; |
||||
however, there are tools that automate much of the process. |
||||
|
||||
## Build Systems |
||||
|
||||
There are currently two ways we generate the necessary files. We are currently |
||||
migrating the build system to use containers so the builds are reproducible. |
||||
This is being done on an OS-by-OS basis. Please update this documentation as |
||||
components of the build system change. |
||||
|
||||
### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`) |
||||
|
||||
The old build system generates the Go files based on the C header files |
||||
present on your system. This means that files |
||||
for a given GOOS/GOARCH pair must be generated on a system with that OS and |
||||
architecture. This also means that the generated code can differ from system |
||||
to system, based on differences in the header files. |
||||
|
||||
To avoid this, if you are using the old build system, only generate the Go |
||||
files on an installation with unmodified header files. It is also important to |
||||
keep track of which version of the OS the files were generated from (ex. |
||||
Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes |
||||
and have each OS upgrade correspond to a single change. |
||||
|
||||
To build the files for your current OS and architecture, make sure GOOS and |
||||
GOARCH are set correctly and run `mkall.sh`. This will generate the files for |
||||
your specific system. Running `mkall.sh -n` shows the commands that will be run. |
||||
|
||||
Requirements: bash, perl, go |
||||
|
||||
### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`) |
||||
|
||||
The new build system uses a Docker container to generate the go files directly |
||||
from source checkouts of the kernel and various system libraries. This means |
||||
that on any platform that supports Docker, all the files using the new build |
||||
system can be generated at once, and generated files will not change based on |
||||
what the person running the scripts has installed on their computer. |
||||
|
||||
The OS specific files for the new build system are located in the `${GOOS}` |
||||
directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When |
||||
the kernel or system library updates, modify the Dockerfile at |
||||
`${GOOS}/Dockerfile` to checkout the new release of the source. |
||||
|
||||
To build all the files under the new build system, you must be on an amd64/Linux |
||||
system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will |
||||
then generate all of the files for all of the GOOS/GOARCH pairs in the new build |
||||
system. Running `mkall.sh -n` shows the commands that will be run. |
||||
|
||||
Requirements: bash, perl, go, docker |
||||
|
||||
## Component files |
||||
|
||||
This section describes the various files used in the code generation process. |
||||
It also contains instructions on how to modify these files to add a new |
||||
architecture/OS or to add additional syscalls, types, or constants. Note that |
||||
if you are using the new build system, the scripts cannot be called normally. |
||||
They must be called from within the docker container. |
||||
|
||||
### asm files |
||||
|
||||
The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system |
||||
call dispatch. There are three entry points: |
||||
``` |
||||
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) |
||||
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) |
||||
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) |
||||
``` |
||||
The first and second are the standard ones; they differ only in how many |
||||
arguments can be passed to the kernel. The third is for low-level use by the |
||||
ForkExec wrapper. Unlike the first two, it does not call into the scheduler to |
||||
let it know that a system call is running. |
||||
|
||||
When porting Go to an new architecture/OS, this file must be implemented for |
||||
each GOOS/GOARCH pair. |
||||
|
||||
### mksysnum |
||||
|
||||
Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl` |
||||
for the old system). This script takes in a list of header files containing the |
||||
syscall number declarations and parses them to produce the corresponding list of |
||||
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated |
||||
constants. |
||||
|
||||
Adding new syscall numbers is mostly done by running the build on a sufficiently |
||||
new installation of the target OS (or updating the source checkouts for the |
||||
new build system). However, depending on the OS, you make need to update the |
||||
parsing in mksysnum. |
||||
|
||||
### mksyscall.pl |
||||
|
||||
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are |
||||
hand-written Go files which implement system calls (for unix, the specific OS, |
||||
or the specific OS/Architecture pair respectively) that need special handling |
||||
and list `//sys` comments giving prototypes for ones that can be generated. |
||||
|
||||
The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts |
||||
them into syscalls. This requires the name of the prototype in the comment to |
||||
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function |
||||
prototype can be exported (capitalized) or not. |
||||
|
||||
Adding a new syscall often just requires adding a new `//sys` function prototype |
||||
with the desired arguments and a capitalized name so it is exported. However, if |
||||
you want the interface to the syscall to be different, often one will make an |
||||
unexported `//sys` prototype, an then write a custom wrapper in |
||||
`syscall_${GOOS}.go`. |
||||
|
||||
### types files |
||||
|
||||
For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or |
||||
`types_${GOOS}.go` on the old system). This file includes standard C headers and |
||||
creates Go type aliases to the corresponding C types. The file is then fed |
||||
through godef to get the Go compatible definitions. Finally, the generated code |
||||
is fed though mkpost.go to format the code correctly and remove any hidden or |
||||
private identifiers. This cleaned-up code is written to |
||||
`ztypes_${GOOS}_${GOARCH}.go`. |
||||
|
||||
The hardest part about preparing this file is figuring out which headers to |
||||
include and which symbols need to be `#define`d to get the actual data |
||||
structures that pass through to the kernel system calls. Some C libraries |
||||
preset alternate versions for binary compatibility and translate them on the |
||||
way in and out of system calls, but there is almost always a `#define` that can |
||||
get the real ones. |
||||
See `types_darwin.go` and `linux/types.go` for examples. |
||||
|
||||
To add a new type, add in the necessary include statement at the top of the |
||||
file (if it is not already there) and add in a type alias line. Note that if |
||||
your type is significantly different on different architectures, you may need |
||||
some `#if/#elif` macros in your include statements. |
||||
|
||||
### mkerrors.sh |
||||
|
||||
This script is used to generate the system's various constants. This doesn't |
||||
just include the error numbers and error strings, but also the signal numbers |
||||
an a wide variety of miscellaneous constants. The constants come from the list |
||||
of include files in the `includes_${uname}` variable. A regex then picks out |
||||
the desired `#define` statements, and generates the corresponding Go constants. |
||||
The error numbers and strings are generated from `#include <errno.h>`, and the |
||||
signal numbers and strings are generated from `#include <signal.h>`. All of |
||||
these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program, |
||||
`_errors.c`, which prints out all the constants. |
||||
|
||||
To add a constant, add the header that includes it to the appropriate variable. |
||||
Then, edit the regex (if necessary) to match the desired constant. Avoid making |
||||
the regex too broad to avoid matching unintended constants. |
||||
|
||||
|
||||
## Generated files |
||||
|
||||
### `zerror_${GOOS}_${GOARCH}.go` |
||||
|
||||
A file containing all of the system's generated error numbers, error strings, |
||||
signal numbers, and constants. Generated by `mkerrors.sh` (see above). |
||||
|
||||
### `zsyscall_${GOOS}_${GOARCH}.go` |
||||
|
||||
A file containing all the generated syscalls for a specific GOOS and GOARCH. |
||||
Generated by `mksyscall.pl` (see above). |
||||
|
||||
### `zsysnum_${GOOS}_${GOARCH}.go` |
||||
|
||||
A list of numeric constants for all the syscall number of the specific GOOS |
||||
and GOARCH. Generated by mksysnum (see above). |
||||
|
||||
### `ztypes_${GOOS}_${GOARCH}.go` |
||||
|
||||
A file containing Go types for passing into (or returning from) syscalls. |
||||
Generated by godefs and the types file (see above). |
@ -0,0 +1,29 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved. |
||||
// Use of this source code is governed by a BSD-style |
||||
// license that can be found in the LICENSE file. |
||||
|
||||
// +build !gccgo |
||||
|
||||
#include "textflag.h" |
||||
|
||||
// |
||||
// System call support for ARM, OpenBSD |
||||
// |
||||
|
||||
// Just jump to package syscall's implementation for all these functions. |
||||
// The runtime may know about them. |
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
||||
B syscall·Syscall(SB) |
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
||||
B syscall·Syscall6(SB) |
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
||||
B syscall·Syscall9(SB) |
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
||||
B syscall·RawSyscall(SB) |
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
||||
B syscall·RawSyscall6(SB) |
@ -0,0 +1,195 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build freebsd
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
errorspkg "errors" |
||||
"fmt" |
||||
) |
||||
|
||||
// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
|
||||
|
||||
const ( |
||||
// This is the version of CapRights this package understands. See C implementation for parallels.
|
||||
capRightsGoVersion = CAP_RIGHTS_VERSION_00 |
||||
capArSizeMin = CAP_RIGHTS_VERSION_00 + 2 |
||||
capArSizeMax = capRightsGoVersion + 2 |
||||
) |
||||
|
||||
var ( |
||||
bit2idx = []int{ |
||||
-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, |
||||
4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
||||
} |
||||
) |
||||
|
||||
func capidxbit(right uint64) int { |
||||
return int((right >> 57) & 0x1f) |
||||
} |
||||
|
||||
func rightToIndex(right uint64) (int, error) { |
||||
idx := capidxbit(right) |
||||
if idx < 0 || idx >= len(bit2idx) { |
||||
return -2, fmt.Errorf("index for right 0x%x out of range", right) |
||||
} |
||||
return bit2idx[idx], nil |
||||
} |
||||
|
||||
func caprver(right uint64) int { |
||||
return int(right >> 62) |
||||
} |
||||
|
||||
func capver(rights *CapRights) int { |
||||
return caprver(rights.Rights[0]) |
||||
} |
||||
|
||||
func caparsize(rights *CapRights) int { |
||||
return capver(rights) + 2 |
||||
} |
||||
|
||||
// CapRightsSet sets the permissions in setrights in rights.
|
||||
func CapRightsSet(rights *CapRights, setrights []uint64) error { |
||||
// This is essentially a copy of cap_rights_vset()
|
||||
if capver(rights) != CAP_RIGHTS_VERSION_00 { |
||||
return fmt.Errorf("bad rights version %d", capver(rights)) |
||||
} |
||||
|
||||
n := caparsize(rights) |
||||
if n < capArSizeMin || n > capArSizeMax { |
||||
return errorspkg.New("bad rights size") |
||||
} |
||||
|
||||
for _, right := range setrights { |
||||
if caprver(right) != CAP_RIGHTS_VERSION_00 { |
||||
return errorspkg.New("bad right version") |
||||
} |
||||
i, err := rightToIndex(right) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if i >= n { |
||||
return errorspkg.New("index overflow") |
||||
} |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errorspkg.New("index mismatch") |
||||
} |
||||
rights.Rights[i] |= right |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errorspkg.New("index mismatch (after assign)") |
||||
} |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// CapRightsClear clears the permissions in clearrights from rights.
|
||||
func CapRightsClear(rights *CapRights, clearrights []uint64) error { |
||||
// This is essentially a copy of cap_rights_vclear()
|
||||
if capver(rights) != CAP_RIGHTS_VERSION_00 { |
||||
return fmt.Errorf("bad rights version %d", capver(rights)) |
||||
} |
||||
|
||||
n := caparsize(rights) |
||||
if n < capArSizeMin || n > capArSizeMax { |
||||
return errorspkg.New("bad rights size") |
||||
} |
||||
|
||||
for _, right := range clearrights { |
||||
if caprver(right) != CAP_RIGHTS_VERSION_00 { |
||||
return errorspkg.New("bad right version") |
||||
} |
||||
i, err := rightToIndex(right) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if i >= n { |
||||
return errorspkg.New("index overflow") |
||||
} |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errorspkg.New("index mismatch") |
||||
} |
||||
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errorspkg.New("index mismatch (after assign)") |
||||
} |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
|
||||
func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) { |
||||
// This is essentially a copy of cap_rights_is_vset()
|
||||
if capver(rights) != CAP_RIGHTS_VERSION_00 { |
||||
return false, fmt.Errorf("bad rights version %d", capver(rights)) |
||||
} |
||||
|
||||
n := caparsize(rights) |
||||
if n < capArSizeMin || n > capArSizeMax { |
||||
return false, errorspkg.New("bad rights size") |
||||
} |
||||
|
||||
for _, right := range setrights { |
||||
if caprver(right) != CAP_RIGHTS_VERSION_00 { |
||||
return false, errorspkg.New("bad right version") |
||||
} |
||||
i, err := rightToIndex(right) |
||||
if err != nil { |
||||
return false, err |
||||
} |
||||
if i >= n { |
||||
return false, errorspkg.New("index overflow") |
||||
} |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return false, errorspkg.New("index mismatch") |
||||
} |
||||
if (rights.Rights[i] & right) != right { |
||||
return false, nil |
||||
} |
||||
} |
||||
|
||||
return true, nil |
||||
} |
||||
|
||||
func capright(idx uint64, bit uint64) uint64 { |
||||
return ((1 << (57 + idx)) | bit) |
||||
} |
||||
|
||||
// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
|
||||
// See man cap_rights_init(3) and rights(4).
|
||||
func CapRightsInit(rights []uint64) (*CapRights, error) { |
||||
var r CapRights |
||||
r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0) |
||||
r.Rights[1] = capright(1, 0) |
||||
|
||||
err := CapRightsSet(&r, rights) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &r, nil |
||||
} |
||||
|
||||
// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
|
||||
// The capability rights on fd can never be increased by CapRightsLimit.
|
||||
// See man cap_rights_limit(2) and rights(4).
|
||||
func CapRightsLimit(fd uintptr, rights *CapRights) error { |
||||
return capRightsLimit(int(fd), rights) |
||||
} |
||||
|
||||
// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
|
||||
// See man cap_rights_get(3) and rights(4).
|
||||
func CapRightsGet(fd uintptr) (*CapRights, error) { |
||||
r, err := CapRightsInit(nil) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
err = capRightsGet(capRightsGoVersion, int(fd), r) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return r, nil |
||||
} |
@ -0,0 +1,24 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used in Darwin's sys/types.h header.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a Darwin device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev >> 24) & 0xff) |
||||
} |
||||
|
||||
// Minor returns the minor component of a Darwin device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
return uint32(dev & 0xffffff) |
||||
} |
||||
|
||||
// Mkdev returns a Darwin device number generated from the given major and minor
|
||||
// components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
return (uint64(major) << 24) | uint64(minor) |
||||
} |
@ -0,0 +1,30 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used in Dragonfly's sys/types.h header.
|
||||
//
|
||||
// The information below is extracted and adapted from sys/types.h:
|
||||
//
|
||||
// Minor gives a cookie instead of an index since in order to avoid changing the
|
||||
// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
|
||||
// devices that don't use them.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a DragonFlyBSD device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev >> 8) & 0xff) |
||||
} |
||||
|
||||
// Minor returns the minor component of a DragonFlyBSD device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
return uint32(dev & 0xffff00ff) |
||||
} |
||||
|
||||
// Mkdev returns a DragonFlyBSD device number generated from the given major and
|
||||
// minor components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
return (uint64(major) << 8) | uint64(minor) |
||||
} |
@ -0,0 +1,30 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used in FreeBSD's sys/types.h header.
|
||||
//
|
||||
// The information below is extracted and adapted from sys/types.h:
|
||||
//
|
||||
// Minor gives a cookie instead of an index since in order to avoid changing the
|
||||
// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
|
||||
// devices that don't use them.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a FreeBSD device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev >> 8) & 0xff) |
||||
} |
||||
|
||||
// Minor returns the minor component of a FreeBSD device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
return uint32(dev & 0xffff00ff) |
||||
} |
||||
|
||||
// Mkdev returns a FreeBSD device number generated from the given major and
|
||||
// minor components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
return (uint64(major) << 8) | uint64(minor) |
||||
} |
@ -0,0 +1,42 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used by the Linux kernel and glibc.
|
||||
//
|
||||
// The information below is extracted and adapted from bits/sysmacros.h in the
|
||||
// glibc sources:
|
||||
//
|
||||
// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
|
||||
// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
|
||||
// number and m is a hex digit of the minor number. This is backward compatible
|
||||
// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
|
||||
// backward compatible with the Linux kernel, which for some architectures uses
|
||||
// 32-bit dev_t, encoded as mmmM MMmm.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a Linux device number.
|
||||
func Major(dev uint64) uint32 { |
||||
major := uint32((dev & 0x00000000000fff00) >> 8) |
||||
major |= uint32((dev & 0xfffff00000000000) >> 32) |
||||
return major |
||||
} |
||||
|
||||
// Minor returns the minor component of a Linux device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
minor := uint32((dev & 0x00000000000000ff) >> 0) |
||||
minor |= uint32((dev & 0x00000ffffff00000) >> 12) |
||||
return minor |
||||
} |
||||
|
||||
// Mkdev returns a Linux device number generated from the given major and minor
|
||||
// components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
dev := (uint64(major) & 0x00000fff) << 8 |
||||
dev |= (uint64(major) & 0xfffff000) << 32 |
||||
dev |= (uint64(minor) & 0x000000ff) << 0 |
||||
dev |= (uint64(minor) & 0xffffff00) << 12 |
||||
return dev |
||||
} |
@ -0,0 +1,29 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used in NetBSD's sys/types.h header.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a NetBSD device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev & 0x000fff00) >> 8) |
||||
} |
||||
|
||||
// Minor returns the minor component of a NetBSD device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
minor := uint32((dev & 0x000000ff) >> 0) |
||||
minor |= uint32((dev & 0xfff00000) >> 12) |
||||
return minor |
||||
} |
||||
|
||||
// Mkdev returns a NetBSD device number generated from the given major and minor
|
||||
// components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
dev := (uint64(major) << 8) & 0x000fff00 |
||||
dev |= (uint64(minor) << 12) & 0xfff00000 |
||||
dev |= (uint64(minor) << 0) & 0x000000ff |
||||
return dev |
||||
} |
@ -0,0 +1,29 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used in OpenBSD's sys/types.h header.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of an OpenBSD device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev & 0x0000ff00) >> 8) |
||||
} |
||||
|
||||
// Minor returns the minor component of an OpenBSD device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
minor := uint32((dev & 0x000000ff) >> 0) |
||||
minor |= uint32((dev & 0xffff0000) >> 8) |
||||
return minor |
||||
} |
||||
|
||||
// Mkdev returns an OpenBSD device number generated from the given major and minor
|
||||
// components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
dev := (uint64(major) << 8) & 0x0000ff00 |
||||
dev |= (uint64(minor) << 8) & 0xffff0000 |
||||
dev |= (uint64(minor) << 0) & 0x000000ff |
||||
return dev |
||||
} |
@ -0,0 +1,102 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package unix |
||||
|
||||
import "unsafe" |
||||
|
||||
// readInt returns the size-bytes unsigned integer in native byte order at offset off.
|
||||
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) { |
||||
if len(b) < int(off+size) { |
||||
return 0, false |
||||
} |
||||
if isBigEndian { |
||||
return readIntBE(b[off:], size), true |
||||
} |
||||
return readIntLE(b[off:], size), true |
||||
} |
||||
|
||||
func readIntBE(b []byte, size uintptr) uint64 { |
||||
switch size { |
||||
case 1: |
||||
return uint64(b[0]) |
||||
case 2: |
||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[1]) | uint64(b[0])<<8 |
||||
case 4: |
||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24 |
||||
case 8: |
||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | |
||||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 |
||||
default: |
||||
panic("syscall: readInt with unsupported size") |
||||
} |
||||
} |
||||
|
||||
func readIntLE(b []byte, size uintptr) uint64 { |
||||
switch size { |
||||
case 1: |
||||
return uint64(b[0]) |
||||
case 2: |
||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[0]) | uint64(b[1])<<8 |
||||
case 4: |
||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
||||
case 8: |
||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | |
||||
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 |
||||
default: |
||||
panic("syscall: readInt with unsupported size") |
||||
} |
||||
} |
||||
|
||||
// ParseDirent parses up to max directory entries in buf,
|
||||
// appending the names to names. It returns the number of
|
||||
// bytes consumed from buf, the number of entries added
|
||||
// to names, and the new names slice.
|
||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { |
||||
origlen := len(buf) |
||||
count = 0 |
||||
for max != 0 && len(buf) > 0 { |
||||
reclen, ok := direntReclen(buf) |
||||
if !ok || reclen > uint64(len(buf)) { |
||||
return origlen, count, names |
||||
} |
||||
rec := buf[:reclen] |
||||
buf = buf[reclen:] |
||||
ino, ok := direntIno(rec) |
||||
if !ok { |
||||
break |
||||
} |
||||
if ino == 0 { // File absent in directory.
|
||||
continue |
||||
} |
||||
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name)) |
||||
namlen, ok := direntNamlen(rec) |
||||
if !ok || namoff+namlen > uint64(len(rec)) { |
||||
break |
||||
} |
||||
name := rec[namoff : namoff+namlen] |
||||
for i, c := range name { |
||||
if c == 0 { |
||||
name = name[:i] |
||||
break |
||||
} |
||||
} |
||||
// Check for useless names before allocating a string.
|
||||
if string(name) == "." || string(name) == ".." { |
||||
continue |
||||
} |
||||
max-- |
||||
count++ |
||||
names = append(names, string(name)) |
||||
} |
||||
return origlen - len(buf), count, names |
||||
} |
@ -0,0 +1,9 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
// +build ppc64 s390x mips mips64
|
||||
|
||||
package unix |
||||
|
||||
const isBigEndian = true |
@ -0,0 +1,9 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
|
||||
|
||||
package unix |
||||
|
||||
const isBigEndian = false |
@ -0,0 +1,227 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||
// them here for backwards compatibility.
|
||||
|
||||
package unix |
||||
|
||||
const ( |
||||
IFF_SMART = 0x20 |
||||
IFT_1822 = 0x2 |
||||
IFT_A12MPPSWITCH = 0x82 |
||||
IFT_AAL2 = 0xbb |
||||
IFT_AAL5 = 0x31 |
||||
IFT_ADSL = 0x5e |
||||
IFT_AFLANE8023 = 0x3b |
||||
IFT_AFLANE8025 = 0x3c |
||||
IFT_ARAP = 0x58 |
||||
IFT_ARCNET = 0x23 |
||||
IFT_ARCNETPLUS = 0x24 |
||||
IFT_ASYNC = 0x54 |
||||
IFT_ATM = 0x25 |
||||
IFT_ATMDXI = 0x69 |
||||
IFT_ATMFUNI = 0x6a |
||||
IFT_ATMIMA = 0x6b |
||||
IFT_ATMLOGICAL = 0x50 |
||||
IFT_ATMRADIO = 0xbd |
||||
IFT_ATMSUBINTERFACE = 0x86 |
||||
IFT_ATMVCIENDPT = 0xc2 |
||||
IFT_ATMVIRTUAL = 0x95 |
||||
IFT_BGPPOLICYACCOUNTING = 0xa2 |
||||
IFT_BSC = 0x53 |
||||
IFT_CCTEMUL = 0x3d |
||||
IFT_CEPT = 0x13 |
||||
IFT_CES = 0x85 |
||||
IFT_CHANNEL = 0x46 |
||||
IFT_CNR = 0x55 |
||||
IFT_COFFEE = 0x84 |
||||
IFT_COMPOSITELINK = 0x9b |
||||
IFT_DCN = 0x8d |
||||
IFT_DIGITALPOWERLINE = 0x8a |
||||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba |
||||
IFT_DLSW = 0x4a |
||||
IFT_DOCSCABLEDOWNSTREAM = 0x80 |
||||
IFT_DOCSCABLEMACLAYER = 0x7f |
||||
IFT_DOCSCABLEUPSTREAM = 0x81 |
||||
IFT_DS0 = 0x51 |
||||
IFT_DS0BUNDLE = 0x52 |
||||
IFT_DS1FDL = 0xaa |
||||
IFT_DS3 = 0x1e |
||||
IFT_DTM = 0x8c |
||||
IFT_DVBASILN = 0xac |
||||
IFT_DVBASIOUT = 0xad |
||||
IFT_DVBRCCDOWNSTREAM = 0x93 |
||||
IFT_DVBRCCMACLAYER = 0x92 |
||||
IFT_DVBRCCUPSTREAM = 0x94 |
||||
IFT_ENC = 0xf4 |
||||
IFT_EON = 0x19 |
||||
IFT_EPLRS = 0x57 |
||||
IFT_ESCON = 0x49 |
||||
IFT_ETHER = 0x6 |
||||
IFT_FAITH = 0xf2 |
||||
IFT_FAST = 0x7d |
||||
IFT_FASTETHER = 0x3e |
||||
IFT_FASTETHERFX = 0x45 |
||||
IFT_FDDI = 0xf |
||||
IFT_FIBRECHANNEL = 0x38 |
||||
IFT_FRAMERELAYINTERCONNECT = 0x3a |
||||
IFT_FRAMERELAYMPI = 0x5c |
||||
IFT_FRDLCIENDPT = 0xc1 |
||||
IFT_FRELAY = 0x20 |
||||
IFT_FRELAYDCE = 0x2c |
||||
IFT_FRF16MFRBUNDLE = 0xa3 |
||||
IFT_FRFORWARD = 0x9e |
||||
IFT_G703AT2MB = 0x43 |
||||
IFT_G703AT64K = 0x42 |
||||
IFT_GIF = 0xf0 |
||||
IFT_GIGABITETHERNET = 0x75 |
||||
IFT_GR303IDT = 0xb2 |
||||
IFT_GR303RDT = 0xb1 |
||||
IFT_H323GATEKEEPER = 0xa4 |
||||
IFT_H323PROXY = 0xa5 |
||||
IFT_HDH1822 = 0x3 |
||||
IFT_HDLC = 0x76 |
||||
IFT_HDSL2 = 0xa8 |
||||
IFT_HIPERLAN2 = 0xb7 |
||||
IFT_HIPPI = 0x2f |
||||
IFT_HIPPIINTERFACE = 0x39 |
||||
IFT_HOSTPAD = 0x5a |
||||
IFT_HSSI = 0x2e |
||||
IFT_HY = 0xe |
||||
IFT_IBM370PARCHAN = 0x48 |
||||
IFT_IDSL = 0x9a |
||||
IFT_IEEE80211 = 0x47 |
||||
IFT_IEEE80212 = 0x37 |
||||
IFT_IEEE8023ADLAG = 0xa1 |
||||
IFT_IFGSN = 0x91 |
||||
IFT_IMT = 0xbe |
||||
IFT_INTERLEAVE = 0x7c |
||||
IFT_IP = 0x7e |
||||
IFT_IPFORWARD = 0x8e |
||||
IFT_IPOVERATM = 0x72 |
||||
IFT_IPOVERCDLC = 0x6d |
||||
IFT_IPOVERCLAW = 0x6e |
||||
IFT_IPSWITCH = 0x4e |
||||
IFT_IPXIP = 0xf9 |
||||
IFT_ISDN = 0x3f |
||||
IFT_ISDNBASIC = 0x14 |
||||
IFT_ISDNPRIMARY = 0x15 |
||||
IFT_ISDNS = 0x4b |
||||
IFT_ISDNU = 0x4c |
||||
IFT_ISO88022LLC = 0x29 |
||||
IFT_ISO88023 = 0x7 |
||||
IFT_ISO88024 = 0x8 |
||||
IFT_ISO88025 = 0x9 |
||||
IFT_ISO88025CRFPINT = 0x62 |
||||
IFT_ISO88025DTR = 0x56 |
||||
IFT_ISO88025FIBER = 0x73 |
||||
IFT_ISO88026 = 0xa |
||||
IFT_ISUP = 0xb3 |
||||
IFT_L3IPXVLAN = 0x89 |
||||
IFT_LAPB = 0x10 |
||||
IFT_LAPD = 0x4d |
||||
IFT_LAPF = 0x77 |
||||
IFT_LOCALTALK = 0x2a |
||||
IFT_LOOP = 0x18 |
||||
IFT_MEDIAMAILOVERIP = 0x8b |
||||
IFT_MFSIGLINK = 0xa7 |
||||
IFT_MIOX25 = 0x26 |
||||
IFT_MODEM = 0x30 |
||||
IFT_MPC = 0x71 |
||||
IFT_MPLS = 0xa6 |
||||
IFT_MPLSTUNNEL = 0x96 |
||||
IFT_MSDSL = 0x8f |
||||
IFT_MVL = 0xbf |
||||
IFT_MYRINET = 0x63 |
||||
IFT_NFAS = 0xaf |
||||
IFT_NSIP = 0x1b |
||||
IFT_OPTICALCHANNEL = 0xc3 |
||||
IFT_OPTICALTRANSPORT = 0xc4 |
||||
IFT_OTHER = 0x1 |
||||
IFT_P10 = 0xc |
||||
IFT_P80 = 0xd |
||||
IFT_PARA = 0x22 |
||||
IFT_PFLOG = 0xf6 |
||||
IFT_PFSYNC = 0xf7 |
||||
IFT_PLC = 0xae |
||||
IFT_POS = 0xab |
||||
IFT_PPPMULTILINKBUNDLE = 0x6c |
||||
IFT_PROPBWAP2MP = 0xb8 |
||||
IFT_PROPCNLS = 0x59 |
||||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 |
||||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 |
||||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 |
||||
IFT_PROPMUX = 0x36 |
||||
IFT_PROPWIRELESSP2P = 0x9d |
||||
IFT_PTPSERIAL = 0x16 |
||||
IFT_PVC = 0xf1 |
||||
IFT_QLLC = 0x44 |
||||
IFT_RADIOMAC = 0xbc |
||||
IFT_RADSL = 0x5f |
||||
IFT_REACHDSL = 0xc0 |
||||
IFT_RFC1483 = 0x9f |
||||
IFT_RS232 = 0x21 |
||||
IFT_RSRB = 0x4f |
||||
IFT_SDLC = 0x11 |
||||
IFT_SDSL = 0x60 |
||||
IFT_SHDSL = 0xa9 |
||||
IFT_SIP = 0x1f |
||||
IFT_SLIP = 0x1c |
||||
IFT_SMDSDXI = 0x2b |
||||
IFT_SMDSICIP = 0x34 |
||||
IFT_SONET = 0x27 |
||||
IFT_SONETOVERHEADCHANNEL = 0xb9 |
||||
IFT_SONETPATH = 0x32 |
||||
IFT_SONETVT = 0x33 |
||||
IFT_SRP = 0x97 |
||||
IFT_SS7SIGLINK = 0x9c |
||||
IFT_STACKTOSTACK = 0x6f |
||||
IFT_STARLAN = 0xb |
||||
IFT_STF = 0xd7 |
||||
IFT_T1 = 0x12 |
||||
IFT_TDLC = 0x74 |
||||
IFT_TERMPAD = 0x5b |
||||
IFT_TR008 = 0xb0 |
||||
IFT_TRANSPHDLC = 0x7b |
||||
IFT_TUNNEL = 0x83 |
||||
IFT_ULTRA = 0x1d |
||||
IFT_USB = 0xa0 |
||||
IFT_V11 = 0x40 |
||||
IFT_V35 = 0x2d |
||||
IFT_V36 = 0x41 |
||||
IFT_V37 = 0x78 |
||||
IFT_VDSL = 0x61 |
||||
IFT_VIRTUALIPADDRESS = 0x70 |
||||
IFT_VOICEEM = 0x64 |
||||
IFT_VOICEENCAP = 0x67 |
||||
IFT_VOICEFXO = 0x65 |
||||
IFT_VOICEFXS = 0x66 |
||||
IFT_VOICEOVERATM = 0x98 |
||||
IFT_VOICEOVERFRAMERELAY = 0x99 |
||||
IFT_VOICEOVERIP = 0x68 |
||||
IFT_X213 = 0x5d |
||||
IFT_X25 = 0x5 |
||||
IFT_X25DDN = 0x4 |
||||
IFT_X25HUNTGROUP = 0x7a |
||||
IFT_X25MLP = 0x79 |
||||
IFT_X25PLE = 0x28 |
||||
IFT_XETHER = 0x1a |
||||
IPPROTO_MAXID = 0x34 |
||||
IPV6_FAITH = 0x1d |
||||
IP_FAITH = 0x16 |
||||
MAP_NORESERVE = 0x40 |
||||
MAP_RENAME = 0x20 |
||||
NET_RT_MAXID = 0x6 |
||||
RTF_PRCLONING = 0x10000 |
||||
RTM_OLDADD = 0x9 |
||||
RTM_OLDDEL = 0xa |
||||
SIOCADDRT = 0x8030720a |
||||
SIOCALIFADDR = 0x8118691b |
||||
SIOCDELRT = 0x8030720b |
||||
SIOCDLIFADDR = 0x8118691d |
||||
SIOCGLIFADDR = 0xc118691c |
||||
SIOCGLIFPHYADDR = 0xc118694b |
||||
SIOCSLIFPHYADDR = 0x8118694a |
||||
) |
@ -0,0 +1,227 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||
// them here for backwards compatibility.
|
||||
|
||||
package unix |
||||
|
||||
const ( |
||||
IFF_SMART = 0x20 |
||||
IFT_1822 = 0x2 |
||||
IFT_A12MPPSWITCH = 0x82 |
||||
IFT_AAL2 = 0xbb |
||||
IFT_AAL5 = 0x31 |
||||
IFT_ADSL = 0x5e |
||||
IFT_AFLANE8023 = 0x3b |
||||
IFT_AFLANE8025 = 0x3c |
||||
IFT_ARAP = 0x58 |
||||
IFT_ARCNET = 0x23 |
||||
IFT_ARCNETPLUS = 0x24 |
||||
IFT_ASYNC = 0x54 |
||||
IFT_ATM = 0x25 |
||||
IFT_ATMDXI = 0x69 |
||||
IFT_ATMFUNI = 0x6a |
||||
IFT_ATMIMA = 0x6b |
||||
IFT_ATMLOGICAL = 0x50 |
||||
IFT_ATMRADIO = 0xbd |
||||
IFT_ATMSUBINTERFACE = 0x86 |
||||
IFT_ATMVCIENDPT = 0xc2 |
||||
IFT_ATMVIRTUAL = 0x95 |
||||
IFT_BGPPOLICYACCOUNTING = 0xa2 |
||||
IFT_BSC = 0x53 |
||||
IFT_CCTEMUL = 0x3d |
||||
IFT_CEPT = 0x13 |
||||
IFT_CES = 0x85 |
||||
IFT_CHANNEL = 0x46 |
||||
IFT_CNR = 0x55 |
||||
IFT_COFFEE = 0x84 |
||||
IFT_COMPOSITELINK = 0x9b |
||||
IFT_DCN = 0x8d |
||||
IFT_DIGITALPOWERLINE = 0x8a |
||||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba |
||||
IFT_DLSW = 0x4a |
||||
IFT_DOCSCABLEDOWNSTREAM = 0x80 |
||||
IFT_DOCSCABLEMACLAYER = 0x7f |
||||
IFT_DOCSCABLEUPSTREAM = 0x81 |
||||
IFT_DS0 = 0x51 |
||||
IFT_DS0BUNDLE = 0x52 |
||||
IFT_DS1FDL = 0xaa |
||||
IFT_DS3 = 0x1e |
||||
IFT_DTM = 0x8c |
||||
IFT_DVBASILN = 0xac |
||||
IFT_DVBASIOUT = 0xad |
||||
IFT_DVBRCCDOWNSTREAM = 0x93 |
||||
IFT_DVBRCCMACLAYER = 0x92 |
||||
IFT_DVBRCCUPSTREAM = 0x94 |
||||
IFT_ENC = 0xf4 |
||||
IFT_EON = 0x19 |
||||
IFT_EPLRS = 0x57 |
||||
IFT_ESCON = 0x49 |
||||
IFT_ETHER = 0x6 |
||||
IFT_FAITH = 0xf2 |
||||
IFT_FAST = 0x7d |
||||
IFT_FASTETHER = 0x3e |
||||
IFT_FASTETHERFX = 0x45 |
||||
IFT_FDDI = 0xf |
||||
IFT_FIBRECHANNEL = 0x38 |
||||
IFT_FRAMERELAYINTERCONNECT = 0x3a |
||||
IFT_FRAMERELAYMPI = 0x5c |
||||
IFT_FRDLCIENDPT = 0xc1 |
||||
IFT_FRELAY = 0x20 |
||||
IFT_FRELAYDCE = 0x2c |
||||
IFT_FRF16MFRBUNDLE = 0xa3 |
||||
IFT_FRFORWARD = 0x9e |
||||
IFT_G703AT2MB = 0x43 |
||||
IFT_G703AT64K = 0x42 |
||||
IFT_GIF = 0xf0 |
||||
IFT_GIGABITETHERNET = 0x75 |
||||
IFT_GR303IDT = 0xb2 |
||||
IFT_GR303RDT = 0xb1 |
||||
IFT_H323GATEKEEPER = 0xa4 |
||||
IFT_H323PROXY = 0xa5 |
||||
IFT_HDH1822 = 0x3 |
||||
IFT_HDLC = 0x76 |
||||
IFT_HDSL2 = 0xa8 |
||||
IFT_HIPERLAN2 = 0xb7 |
||||
IFT_HIPPI = 0x2f |
||||
IFT_HIPPIINTERFACE = 0x39 |
||||
IFT_HOSTPAD = 0x5a |
||||
IFT_HSSI = 0x2e |
||||
IFT_HY = 0xe |
||||
IFT_IBM370PARCHAN = 0x48 |
||||
IFT_IDSL = 0x9a |
||||
IFT_IEEE80211 = 0x47 |
||||
IFT_IEEE80212 = 0x37 |
||||
IFT_IEEE8023ADLAG = 0xa1 |
||||
IFT_IFGSN = 0x91 |
||||
IFT_IMT = 0xbe |
||||
IFT_INTERLEAVE = 0x7c |
||||
IFT_IP = 0x7e |
||||
IFT_IPFORWARD = 0x8e |
||||
IFT_IPOVERATM = 0x72 |
||||
IFT_IPOVERCDLC = 0x6d |
||||
IFT_IPOVERCLAW = 0x6e |
||||
IFT_IPSWITCH = 0x4e |
||||
IFT_IPXIP = 0xf9 |
||||
IFT_ISDN = 0x3f |
||||
IFT_ISDNBASIC = 0x14 |
||||
IFT_ISDNPRIMARY = 0x15 |
||||
IFT_ISDNS = 0x4b |
||||
IFT_ISDNU = 0x4c |
||||
IFT_ISO88022LLC = 0x29 |
||||
IFT_ISO88023 = 0x7 |
||||
IFT_ISO88024 = 0x8 |
||||
IFT_ISO88025 = 0x9 |
||||
IFT_ISO88025CRFPINT = 0x62 |
||||
IFT_ISO88025DTR = 0x56 |
||||
IFT_ISO88025FIBER = 0x73 |
||||
IFT_ISO88026 = 0xa |
||||
IFT_ISUP = 0xb3 |
||||
IFT_L3IPXVLAN = 0x89 |
||||
IFT_LAPB = 0x10 |
||||
IFT_LAPD = 0x4d |
||||
IFT_LAPF = 0x77 |
||||
IFT_LOCALTALK = 0x2a |
||||
IFT_LOOP = 0x18 |
||||
IFT_MEDIAMAILOVERIP = 0x8b |
||||
IFT_MFSIGLINK = 0xa7 |
||||
IFT_MIOX25 = 0x26 |
||||
IFT_MODEM = 0x30 |
||||
IFT_MPC = 0x71 |
||||
IFT_MPLS = 0xa6 |
||||
IFT_MPLSTUNNEL = 0x96 |
||||
IFT_MSDSL = 0x8f |
||||
IFT_MVL = 0xbf |
||||
IFT_MYRINET = 0x63 |
||||
IFT_NFAS = 0xaf |
||||
IFT_NSIP = 0x1b |
||||
IFT_OPTICALCHANNEL = 0xc3 |
||||
IFT_OPTICALTRANSPORT = 0xc4 |
||||
IFT_OTHER = 0x1 |
||||
IFT_P10 = 0xc |
||||
IFT_P80 = 0xd |
||||
IFT_PARA = 0x22 |
||||
IFT_PFLOG = 0xf6 |
||||
IFT_PFSYNC = 0xf7 |
||||
IFT_PLC = 0xae |
||||
IFT_POS = 0xab |
||||
IFT_PPPMULTILINKBUNDLE = 0x6c |
||||
IFT_PROPBWAP2MP = 0xb8 |
||||
IFT_PROPCNLS = 0x59 |
||||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 |
||||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 |
||||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 |
||||
IFT_PROPMUX = 0x36 |
||||
IFT_PROPWIRELESSP2P = 0x9d |
||||
IFT_PTPSERIAL = 0x16 |
||||
IFT_PVC = 0xf1 |
||||
IFT_QLLC = 0x44 |
||||
IFT_RADIOMAC = 0xbc |
||||
IFT_RADSL = 0x5f |
||||
IFT_REACHDSL = 0xc0 |
||||
IFT_RFC1483 = 0x9f |
||||
IFT_RS232 = 0x21 |
||||
IFT_RSRB = 0x4f |
||||
IFT_SDLC = 0x11 |
||||
IFT_SDSL = 0x60 |
||||
IFT_SHDSL = 0xa9 |
||||
IFT_SIP = 0x1f |
||||
IFT_SLIP = 0x1c |
||||
IFT_SMDSDXI = 0x2b |
||||
IFT_SMDSICIP = 0x34 |
||||
IFT_SONET = 0x27 |
||||
IFT_SONETOVERHEADCHANNEL = 0xb9 |
||||
IFT_SONETPATH = 0x32 |
||||
IFT_SONETVT = 0x33 |
||||
IFT_SRP = 0x97 |
||||
IFT_SS7SIGLINK = 0x9c |
||||
IFT_STACKTOSTACK = 0x6f |
||||
IFT_STARLAN = 0xb |
||||
IFT_STF = 0xd7 |
||||
IFT_T1 = 0x12 |
||||
IFT_TDLC = 0x74 |
||||
IFT_TERMPAD = 0x5b |
||||
IFT_TR008 = 0xb0 |
||||
IFT_TRANSPHDLC = 0x7b |
||||
IFT_TUNNEL = 0x83 |
||||
IFT_ULTRA = 0x1d |
||||
IFT_USB = 0xa0 |
||||
IFT_V11 = 0x40 |
||||
IFT_V35 = 0x2d |
||||
IFT_V36 = 0x41 |
||||
IFT_V37 = 0x78 |
||||
IFT_VDSL = 0x61 |
||||
IFT_VIRTUALIPADDRESS = 0x70 |
||||
IFT_VOICEEM = 0x64 |
||||
IFT_VOICEENCAP = 0x67 |
||||
IFT_VOICEFXO = 0x65 |
||||
IFT_VOICEFXS = 0x66 |
||||
IFT_VOICEOVERATM = 0x98 |
||||
IFT_VOICEOVERFRAMERELAY = 0x99 |
||||
IFT_VOICEOVERIP = 0x68 |
||||
IFT_X213 = 0x5d |
||||
IFT_X25 = 0x5 |
||||
IFT_X25DDN = 0x4 |
||||
IFT_X25HUNTGROUP = 0x7a |
||||
IFT_X25MLP = 0x79 |
||||
IFT_X25PLE = 0x28 |
||||
IFT_XETHER = 0x1a |
||||
IPPROTO_MAXID = 0x34 |
||||
IPV6_FAITH = 0x1d |
||||
IP_FAITH = 0x16 |
||||
MAP_NORESERVE = 0x40 |
||||
MAP_RENAME = 0x20 |
||||
NET_RT_MAXID = 0x6 |
||||
RTF_PRCLONING = 0x10000 |
||||
RTM_OLDADD = 0x9 |
||||
RTM_OLDDEL = 0xa |
||||
SIOCADDRT = 0x8040720a |
||||
SIOCALIFADDR = 0x8118691b |
||||
SIOCDELRT = 0x8040720b |
||||
SIOCDLIFADDR = 0x8118691d |
||||
SIOCGLIFADDR = 0xc118691c |
||||
SIOCGLIFPHYADDR = 0xc118694b |
||||
SIOCSLIFPHYADDR = 0x8118694a |
||||
) |
@ -0,0 +1,226 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package unix |
||||
|
||||
const ( |
||||
IFT_1822 = 0x2 |
||||
IFT_A12MPPSWITCH = 0x82 |
||||
IFT_AAL2 = 0xbb |
||||
IFT_AAL5 = 0x31 |
||||
IFT_ADSL = 0x5e |
||||
IFT_AFLANE8023 = 0x3b |
||||
IFT_AFLANE8025 = 0x3c |
||||
IFT_ARAP = 0x58 |
||||
IFT_ARCNET = 0x23 |
||||
IFT_ARCNETPLUS = 0x24 |
||||
IFT_ASYNC = 0x54 |
||||
IFT_ATM = 0x25 |
||||
IFT_ATMDXI = 0x69 |
||||
IFT_ATMFUNI = 0x6a |
||||
IFT_ATMIMA = 0x6b |
||||
IFT_ATMLOGICAL = 0x50 |
||||
IFT_ATMRADIO = 0xbd |
||||
IFT_ATMSUBINTERFACE = 0x86 |
||||
IFT_ATMVCIENDPT = 0xc2 |
||||
IFT_ATMVIRTUAL = 0x95 |
||||
IFT_BGPPOLICYACCOUNTING = 0xa2 |
||||
IFT_BSC = 0x53 |
||||
IFT_CCTEMUL = 0x3d |
||||
IFT_CEPT = 0x13 |
||||
IFT_CES = 0x85 |
||||
IFT_CHANNEL = 0x46 |
||||
IFT_CNR = 0x55 |
||||
IFT_COFFEE = 0x84 |
||||
IFT_COMPOSITELINK = 0x9b |
||||
IFT_DCN = 0x8d |
||||
IFT_DIGITALPOWERLINE = 0x8a |
||||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba |
||||
IFT_DLSW = 0x4a |
||||
IFT_DOCSCABLEDOWNSTREAM = 0x80 |
||||
IFT_DOCSCABLEMACLAYER = 0x7f |
||||
IFT_DOCSCABLEUPSTREAM = 0x81 |
||||
IFT_DS0 = 0x51 |
||||
IFT_DS0BUNDLE = 0x52 |
||||
IFT_DS1FDL = 0xaa |
||||
IFT_DS3 = 0x1e |
||||
IFT_DTM = 0x8c |
||||
IFT_DVBASILN = 0xac |
||||
IFT_DVBASIOUT = 0xad |
||||
IFT_DVBRCCDOWNSTREAM = 0x93 |
||||
IFT_DVBRCCMACLAYER = 0x92 |
||||
IFT_DVBRCCUPSTREAM = 0x94 |
||||
IFT_ENC = 0xf4 |
||||
IFT_EON = 0x19 |
||||
IFT_EPLRS = 0x57 |
||||
IFT_ESCON = 0x49 |
||||
IFT_ETHER = 0x6 |
||||
IFT_FAST = 0x7d |
||||
IFT_FASTETHER = 0x3e |
||||
IFT_FASTETHERFX = 0x45 |
||||
IFT_FDDI = 0xf |
||||
IFT_FIBRECHANNEL = 0x38 |
||||
IFT_FRAMERELAYINTERCONNECT = 0x3a |
||||
IFT_FRAMERELAYMPI = 0x5c |
||||
IFT_FRDLCIENDPT = 0xc1 |
||||
IFT_FRELAY = 0x20 |
||||
IFT_FRELAYDCE = 0x2c |
||||
IFT_FRF16MFRBUNDLE = 0xa3 |
||||
IFT_FRFORWARD = 0x9e |
||||
IFT_G703AT2MB = 0x43 |
||||
IFT_G703AT64K = 0x42 |
||||
IFT_GIF = 0xf0 |
||||
IFT_GIGABITETHERNET = 0x75 |
||||
IFT_GR303IDT = 0xb2 |
||||
IFT_GR303RDT = 0xb1 |
||||
IFT_H323GATEKEEPER = 0xa4 |
||||
IFT_H323PROXY = 0xa5 |
||||
IFT_HDH1822 = 0x3 |
||||
IFT_HDLC = 0x76 |
||||
IFT_HDSL2 = 0xa8 |
||||
IFT_HIPERLAN2 = 0xb7 |
||||
IFT_HIPPI = 0x2f |
||||
IFT_HIPPIINTERFACE = 0x39 |
||||
IFT_HOSTPAD = 0x5a |
||||
IFT_HSSI = 0x2e |
||||
IFT_HY = 0xe |
||||
IFT_IBM370PARCHAN = 0x48 |
||||
IFT_IDSL = 0x9a |
||||
IFT_IEEE80211 = 0x47 |
||||
IFT_IEEE80212 = 0x37 |
||||
IFT_IEEE8023ADLAG = 0xa1 |
||||
IFT_IFGSN = 0x91 |
||||
IFT_IMT = 0xbe |
||||
IFT_INTERLEAVE = 0x7c |
||||
IFT_IP = 0x7e |
||||
IFT_IPFORWARD = 0x8e |
||||
IFT_IPOVERATM = 0x72 |
||||
IFT_IPOVERCDLC = 0x6d |
||||
IFT_IPOVERCLAW = 0x6e |
||||
IFT_IPSWITCH = 0x4e |
||||
IFT_ISDN = 0x3f |
||||
IFT_ISDNBASIC = 0x14 |
||||
IFT_ISDNPRIMARY = 0x15 |
||||
IFT_ISDNS = 0x4b |
||||
IFT_ISDNU = 0x4c |
||||
IFT_ISO88022LLC = 0x29 |
||||
IFT_ISO88023 = 0x7 |
||||
IFT_ISO88024 = 0x8 |
||||
IFT_ISO88025 = 0x9 |
||||
IFT_ISO88025CRFPINT = 0x62 |
||||
IFT_ISO88025DTR = 0x56 |
||||
IFT_ISO88025FIBER = 0x73 |
||||
IFT_ISO88026 = 0xa |
||||
IFT_ISUP = 0xb3 |
||||
IFT_L3IPXVLAN = 0x89 |
||||
IFT_LAPB = 0x10 |
||||
IFT_LAPD = 0x4d |
||||
IFT_LAPF = 0x77 |
||||
IFT_LOCALTALK = 0x2a |
||||
IFT_LOOP = 0x18 |
||||
IFT_MEDIAMAILOVERIP = 0x8b |
||||
IFT_MFSIGLINK = 0xa7 |
||||
IFT_MIOX25 = 0x26 |
||||
IFT_MODEM = 0x30 |
||||
IFT_MPC = 0x71 |
||||
IFT_MPLS = 0xa6 |
||||
IFT_MPLSTUNNEL = 0x96 |
||||
IFT_MSDSL = 0x8f |
||||
IFT_MVL = 0xbf |
||||
IFT_MYRINET = 0x63 |
||||
IFT_NFAS = 0xaf |
||||
IFT_NSIP = 0x1b |
||||
IFT_OPTICALCHANNEL = 0xc3 |
||||
IFT_OPTICALTRANSPORT = 0xc4 |
||||
IFT_OTHER = 0x1 |
||||
IFT_P10 = 0xc |
||||
IFT_P80 = 0xd |
||||
IFT_PARA = 0x22 |
||||
IFT_PFLOG = 0xf6 |
||||
IFT_PFSYNC = 0xf7 |
||||
IFT_PLC = 0xae |
||||
IFT_POS = 0xab |
||||
IFT_PPPMULTILINKBUNDLE = 0x6c |
||||
IFT_PROPBWAP2MP = 0xb8 |
||||
IFT_PROPCNLS = 0x59 |
||||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 |
||||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 |
||||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 |
||||
IFT_PROPMUX = 0x36 |
||||
IFT_PROPWIRELESSP2P = 0x9d |
||||
IFT_PTPSERIAL = 0x16 |
||||
IFT_PVC = 0xf1 |
||||
IFT_QLLC = 0x44 |
||||
IFT_RADIOMAC = 0xbc |
||||
IFT_RADSL = 0x5f |
||||
IFT_REACHDSL = 0xc0 |
||||
IFT_RFC1483 = 0x9f |
||||
IFT_RS232 = 0x21 |
||||
IFT_RSRB = 0x4f |
||||
IFT_SDLC = 0x11 |
||||
IFT_SDSL = 0x60 |
||||
IFT_SHDSL = 0xa9 |
||||
IFT_SIP = 0x1f |
||||
IFT_SLIP = 0x1c |
||||
IFT_SMDSDXI = 0x2b |
||||
IFT_SMDSICIP = 0x34 |
||||
IFT_SONET = 0x27 |
||||
IFT_SONETOVERHEADCHANNEL = 0xb9 |
||||
IFT_SONETPATH = 0x32 |
||||
IFT_SONETVT = 0x33 |
||||
IFT_SRP = 0x97 |
||||
IFT_SS7SIGLINK = 0x9c |
||||
IFT_STACKTOSTACK = 0x6f |
||||
IFT_STARLAN = 0xb |
||||
IFT_STF = 0xd7 |
||||
IFT_T1 = 0x12 |
||||
IFT_TDLC = 0x74 |
||||
IFT_TERMPAD = 0x5b |
||||
IFT_TR008 = 0xb0 |
||||
IFT_TRANSPHDLC = 0x7b |
||||
IFT_TUNNEL = 0x83 |
||||
IFT_ULTRA = 0x1d |
||||
IFT_USB = 0xa0 |
||||
IFT_V11 = 0x40 |
||||
IFT_V35 = 0x2d |
||||
IFT_V36 = 0x41 |
||||
IFT_V37 = 0x78 |
||||
IFT_VDSL = 0x61 |
||||
IFT_VIRTUALIPADDRESS = 0x70 |
||||
IFT_VOICEEM = 0x64 |
||||
IFT_VOICEENCAP = 0x67 |
||||
IFT_VOICEFXO = 0x65 |
||||
IFT_VOICEFXS = 0x66 |
||||
IFT_VOICEOVERATM = 0x98 |
||||
IFT_VOICEOVERFRAMERELAY = 0x99 |
||||
IFT_VOICEOVERIP = 0x68 |
||||
IFT_X213 = 0x5d |
||||
IFT_X25 = 0x5 |
||||
IFT_X25DDN = 0x4 |
||||
IFT_X25HUNTGROUP = 0x7a |
||||
IFT_X25MLP = 0x79 |
||||
IFT_X25PLE = 0x28 |
||||
IFT_XETHER = 0x1a |
||||
|
||||
// missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
|
||||
IFF_SMART = 0x20 |
||||
IFT_FAITH = 0xf2 |
||||
IFT_IPXIP = 0xf9 |
||||
IPPROTO_MAXID = 0x34 |
||||
IPV6_FAITH = 0x1d |
||||
IP_FAITH = 0x16 |
||||
MAP_NORESERVE = 0x40 |
||||
MAP_RENAME = 0x20 |
||||
NET_RT_MAXID = 0x6 |
||||
RTF_PRCLONING = 0x10000 |
||||
RTM_OLDADD = 0x9 |
||||
RTM_OLDDEL = 0xa |
||||
SIOCADDRT = 0x8030720a |
||||
SIOCALIFADDR = 0x8118691b |
||||
SIOCDELRT = 0x8030720b |
||||
SIOCDLIFADDR = 0x8118691d |
||||
SIOCGLIFADDR = 0xc118691c |
||||
SIOCGLIFPHYADDR = 0xc118694b |
||||
SIOCSLIFPHYADDR = 0x8118694a |
||||
) |
@ -1,20 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build gccgo,linux,sparc64
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
//extern sysconf
|
||||
func realSysconf(name int) int64 |
||||
|
||||
func sysconf(name int) (n int64, err syscall.Errno) { |
||||
r := realSysconf(name) |
||||
if r < 0 { |
||||
return 0, syscall.GetErrno() |
||||
} |
||||
return r, 0 |
||||
} |
@ -1,62 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
// mkpost processes the output of cgo -godefs to
|
||||
// modify the generated types. It is used to clean up
|
||||
// the sys API in an architecture specific manner.
|
||||
//
|
||||
// mkpost is run after cgo -godefs by mkall.sh.
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"go/format" |
||||
"io/ioutil" |
||||
"log" |
||||
"os" |
||||
"regexp" |
||||
) |
||||
|
||||
func main() { |
||||
b, err := ioutil.ReadAll(os.Stdin) |
||||
if err != nil { |
||||
log.Fatal(err) |
||||
} |
||||
s := string(b) |
||||
|
||||
goarch := os.Getenv("GOARCH") |
||||
goos := os.Getenv("GOOS") |
||||
if goarch == "s390x" && goos == "linux" { |
||||
// Export the types of PtraceRegs fields.
|
||||
re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") |
||||
s = re.ReplaceAllString(s, "Ptrace$1") |
||||
|
||||
// Replace padding fields inserted by cgo with blank identifiers.
|
||||
re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") |
||||
s = re.ReplaceAllString(s, "_") |
||||
|
||||
// Replace other unwanted fields with blank identifiers.
|
||||
re = regexp.MustCompile("X_[A-Za-z0-9_]*") |
||||
s = re.ReplaceAllString(s, "_") |
||||
|
||||
// Replace the control_regs union with a blank identifier for now.
|
||||
re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") |
||||
s = re.ReplaceAllString(s, "_ [0]uint64") |
||||
} |
||||
|
||||
// gofmt
|
||||
b, err = format.Source([]byte(s)) |
||||
if err != nil { |
||||
log.Fatal(err) |
||||
} |
||||
|
||||
// Append this command to the header to show where the new file
|
||||
// came from.
|
||||
re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") |
||||
b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) |
||||
|
||||
fmt.Printf("%s", b) |
||||
} |
@ -1,68 +0,0 @@ |
||||
#!/usr/bin/env perl |
||||
# Copyright 2009 The Go Authors. All rights reserved. |
||||
# Use of this source code is governed by a BSD-style |
||||
# license that can be found in the LICENSE file. |
||||
|
||||
use strict; |
||||
|
||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { |
||||
print STDERR "GOARCH or GOOS not defined in environment\n"; |
||||
exit 1; |
||||
} |
||||
|
||||
my $command = "mksysnum_linux.pl ". join(' ', @ARGV); |
||||
|
||||
print <<EOF; |
||||
// $command |
||||
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT |
||||
|
||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'} |
||||
|
||||
package unix |
||||
|
||||
const( |
||||
EOF |
||||
|
||||
my $offset = 0; |
||||
|
||||
sub fmt { |
||||
my ($name, $num) = @_; |
||||
if($num > 999){ |
||||
# ignore deprecated syscalls that are no longer implemented |
||||
# https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 |
||||
return; |
||||
} |
||||
$name =~ y/a-z/A-Z/; |
||||
$num = $num + $offset; |
||||
print " SYS_$name = $num;\n"; |
||||
} |
||||
|
||||
my $prev; |
||||
open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; |
||||
while(<GCC>){ |
||||
if(/^#define __NR_Linux\s+([0-9]+)/){ |
||||
# mips/mips64: extract offset |
||||
$offset = $1; |
||||
} |
||||
elsif(/^#define __NR_syscalls\s+/) { |
||||
# ignore redefinitions of __NR_syscalls |
||||
} |
||||
elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ |
||||
$prev = $2; |
||||
fmt($1, $2); |
||||
} |
||||
elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ |
||||
$prev = $2; |
||||
fmt($1, $2); |
||||
} |
||||
elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ |
||||
fmt($1, $prev+$2) |
||||
} |
||||
elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){ |
||||
fmt($1, $2); |
||||
} |
||||
} |
||||
|
||||
print <<EOF; |
||||
) |
||||
EOF |
@ -0,0 +1,38 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build openbsd
|
||||
// +build 386 amd64 arm
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
const ( |
||||
SYS_PLEDGE = 108 |
||||
) |
||||
|
||||
// Pledge implements the pledge syscall. For more information see pledge(2).
|
||||
func Pledge(promises string, paths []string) error { |
||||
promisesPtr, err := syscall.BytePtrFromString(promises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) |
||||
if paths != nil { |
||||
var pathsPtr []*byte |
||||
if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { |
||||
return err |
||||
} |
||||
pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) |
||||
} |
||||
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) |
||||
if e != 0 { |
||||
return e |
||||
} |
||||
return nil |
||||
} |
@ -0,0 +1,15 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
// For Unix, get the pagesize from the runtime.
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
func Getpagesize() int { |
||||
return syscall.Getpagesize() |
||||
} |
@ -0,0 +1,33 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build arm,openbsd
|
||||
|
||||
package unix |
||||
|
||||
func setTimespec(sec, nsec int64) Timespec { |
||||
return Timespec{Sec: sec, Nsec: int32(nsec)} |
||||
} |
||||
|
||||
func setTimeval(sec, usec int64) Timeval { |
||||
return Timeval{Sec: sec, Usec: int32(usec)} |
||||
} |
||||
|
||||
func SetKevent(k *Kevent_t, fd, mode, flags int) { |
||||
k.Ident = uint32(fd) |
||||
k.Filter = int16(mode) |
||||
k.Flags = uint16(flags) |
||||
} |
||||
|
||||
func (iov *Iovec) SetLen(length int) { |
||||
iov.Len = uint32(length) |
||||
} |
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) { |
||||
msghdr.Controllen = uint32(length) |
||||
} |
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) { |
||||
cmsg.Len = uint32(length) |
||||
} |
@ -0,0 +1,62 @@ |
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package unix |
||||
|
||||
// TimespecToNsec converts a Timespec value into a number of
|
||||
// nanoseconds since the Unix epoch.
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } |
||||
|
||||
// NsecToTimespec takes a number of nanoseconds since the Unix epoch
|
||||
// and returns the corresponding Timespec value.
|
||||
func NsecToTimespec(nsec int64) Timespec { |
||||
sec := nsec / 1e9 |
||||
nsec = nsec % 1e9 |
||||
if nsec < 0 { |
||||
nsec += 1e9 |
||||
sec-- |
||||
} |
||||
return setTimespec(sec, nsec) |
||||
} |
||||
|
||||
// TimevalToNsec converts a Timeval value into a number of nanoseconds
|
||||
// since the Unix epoch.
|
||||
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } |
||||
|
||||
// NsecToTimeval takes a number of nanoseconds since the Unix epoch
|
||||
// and returns the corresponding Timeval value.
|
||||
func NsecToTimeval(nsec int64) Timeval { |
||||
nsec += 999 // round up to microsecond
|
||||
usec := nsec % 1e9 / 1e3 |
||||
sec := nsec / 1e9 |
||||
if usec < 0 { |
||||
usec += 1e6 |
||||
sec-- |
||||
} |
||||
return setTimeval(sec, usec) |
||||
} |
||||
|
||||
// Unix returns ts as the number of seconds and nanoseconds elapsed since the
|
||||
// Unix epoch.
|
||||
func (ts *Timespec) Unix() (sec int64, nsec int64) { |
||||
return int64(ts.Sec), int64(ts.Nsec) |
||||
} |
||||
|
||||
// Unix returns tv as the number of seconds and nanoseconds elapsed since the
|
||||
// Unix epoch.
|
||||
func (tv *Timeval) Unix() (sec int64, nsec int64) { |
||||
return int64(tv.Sec), int64(tv.Usec) * 1000 |
||||
} |
||||
|
||||
// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.
|
||||
func (ts *Timespec) Nano() int64 { |
||||
return int64(ts.Sec)*1e9 + int64(ts.Nsec) |
||||
} |
||||
|
||||
// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.
|
||||
func (tv *Timeval) Nano() int64 { |
||||
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 |
||||
} |
@ -1,250 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define __DARWIN_UNIX03 0 |
||||
#define KERNEL |
||||
#define _DARWIN_USE_64_BIT_INODE |
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <signal.h> |
||||
#include <termios.h> |
||||
#include <unistd.h> |
||||
#include <mach/mach.h> |
||||
#include <mach/message.h> |
||||
#include <sys/event.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/param.h> |
||||
#include <sys/ptrace.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/time.h> |
||||
#include <sys/types.h> |
||||
#include <sys/uio.h> |
||||
#include <sys/un.h> |
||||
#include <sys/wait.h> |
||||
#include <net/bpf.h> |
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <net/if_var.h> |
||||
#include <net/route.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
#include <netinet/tcp.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
type Timeval32 C.struct_timeval32 |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
type Stat_t C.struct_stat64 |
||||
|
||||
type Statfs_t C.struct_statfs64 |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
type Fstore_t C.struct_fstore |
||||
|
||||
type Radvisory_t C.struct_radvisory |
||||
|
||||
type Fbootstraptransfer_t C.struct_fbootstraptransfer |
||||
|
||||
type Log2phys_t C.struct_log2phys |
||||
|
||||
type Fsid C.struct_fsid |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddrDatalink C.struct_sockaddr_dl |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet4Pktinfo C.struct_in_pktinfo |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Ptrace requests
|
||||
|
||||
const ( |
||||
PTRACE_TRACEME = C.PT_TRACE_ME |
||||
PTRACE_CONT = C.PT_CONTINUE |
||||
PTRACE_KILL = C.PT_KILL |
||||
) |
||||
|
||||
// Events (kqueue, kevent)
|
||||
|
||||
type Kevent_t C.struct_kevent |
||||
|
||||
// Select
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
SizeofIfData = C.sizeof_struct_if_data |
||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
||||
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr |
||||
SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 |
||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics |
||||
) |
||||
|
||||
type IfMsghdr C.struct_if_msghdr |
||||
|
||||
type IfData C.struct_if_data |
||||
|
||||
type IfaMsghdr C.struct_ifa_msghdr |
||||
|
||||
type IfmaMsghdr C.struct_ifma_msghdr |
||||
|
||||
type IfmaMsghdr2 C.struct_ifma_msghdr2 |
||||
|
||||
type RtMsghdr C.struct_rt_msghdr |
||||
|
||||
type RtMetrics C.struct_rt_metrics |
||||
|
||||
// Berkeley packet filter
|
||||
|
||||
const ( |
||||
SizeofBpfVersion = C.sizeof_struct_bpf_version |
||||
SizeofBpfStat = C.sizeof_struct_bpf_stat |
||||
SizeofBpfProgram = C.sizeof_struct_bpf_program |
||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn |
||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
||||
) |
||||
|
||||
type BpfVersion C.struct_bpf_version |
||||
|
||||
type BpfStat C.struct_bpf_stat |
||||
|
||||
type BpfProgram C.struct_bpf_program |
||||
|
||||
type BpfInsn C.struct_bpf_insn |
||||
|
||||
type BpfHdr C.struct_bpf_hdr |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
||||
|
||||
// fchmodat-like syscalls.
|
||||
|
||||
const ( |
||||
AT_FDCWD = C.AT_FDCWD |
||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW |
||||
) |
@ -1,242 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define KERNEL |
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <signal.h> |
||||
#include <termios.h> |
||||
#include <stdio.h> |
||||
#include <unistd.h> |
||||
#include <sys/event.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/param.h> |
||||
#include <sys/ptrace.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/time.h> |
||||
#include <sys/types.h> |
||||
#include <sys/un.h> |
||||
#include <sys/wait.h> |
||||
#include <net/bpf.h> |
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <net/route.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
#include <netinet/tcp.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
const ( // Directory mode bits
|
||||
S_IFMT = C.S_IFMT |
||||
S_IFIFO = C.S_IFIFO |
||||
S_IFCHR = C.S_IFCHR |
||||
S_IFDIR = C.S_IFDIR |
||||
S_IFBLK = C.S_IFBLK |
||||
S_IFREG = C.S_IFREG |
||||
S_IFLNK = C.S_IFLNK |
||||
S_IFSOCK = C.S_IFSOCK |
||||
S_ISUID = C.S_ISUID |
||||
S_ISGID = C.S_ISGID |
||||
S_ISVTX = C.S_ISVTX |
||||
S_IRUSR = C.S_IRUSR |
||||
S_IWUSR = C.S_IWUSR |
||||
S_IXUSR = C.S_IXUSR |
||||
) |
||||
|
||||
type Stat_t C.struct_stat |
||||
|
||||
type Statfs_t C.struct_statfs |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
type Fsid C.struct_fsid |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddrDatalink C.struct_sockaddr_dl |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Ptrace requests
|
||||
|
||||
const ( |
||||
PTRACE_TRACEME = C.PT_TRACE_ME |
||||
PTRACE_CONT = C.PT_CONTINUE |
||||
PTRACE_KILL = C.PT_KILL |
||||
) |
||||
|
||||
// Events (kqueue, kevent)
|
||||
|
||||
type Kevent_t C.struct_kevent |
||||
|
||||
// Select
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
SizeofIfData = C.sizeof_struct_if_data |
||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
||||
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr |
||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr |
||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics |
||||
) |
||||
|
||||
type IfMsghdr C.struct_if_msghdr |
||||
|
||||
type IfData C.struct_if_data |
||||
|
||||
type IfaMsghdr C.struct_ifa_msghdr |
||||
|
||||
type IfmaMsghdr C.struct_ifma_msghdr |
||||
|
||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr |
||||
|
||||
type RtMsghdr C.struct_rt_msghdr |
||||
|
||||
type RtMetrics C.struct_rt_metrics |
||||
|
||||
// Berkeley packet filter
|
||||
|
||||
const ( |
||||
SizeofBpfVersion = C.sizeof_struct_bpf_version |
||||
SizeofBpfStat = C.sizeof_struct_bpf_stat |
||||
SizeofBpfProgram = C.sizeof_struct_bpf_program |
||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn |
||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
||||
) |
||||
|
||||
type BpfVersion C.struct_bpf_version |
||||
|
||||
type BpfStat C.struct_bpf_stat |
||||
|
||||
type BpfProgram C.struct_bpf_program |
||||
|
||||
type BpfInsn C.struct_bpf_insn |
||||
|
||||
type BpfHdr C.struct_bpf_hdr |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
@ -1,353 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define KERNEL |
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <signal.h> |
||||
#include <termios.h> |
||||
#include <stdio.h> |
||||
#include <unistd.h> |
||||
#include <sys/event.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/param.h> |
||||
#include <sys/ptrace.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/time.h> |
||||
#include <sys/types.h> |
||||
#include <sys/un.h> |
||||
#include <sys/wait.h> |
||||
#include <net/bpf.h> |
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <net/route.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
#include <netinet/tcp.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
// This structure is a duplicate of stat on FreeBSD 8-STABLE.
|
||||
// See /usr/include/sys/stat.h.
|
||||
struct stat8 { |
||||
#undef st_atimespec st_atim |
||||
#undef st_mtimespec st_mtim |
||||
#undef st_ctimespec st_ctim |
||||
#undef st_birthtimespec st_birthtim |
||||
__dev_t st_dev; |
||||
ino_t st_ino; |
||||
mode_t st_mode; |
||||
nlink_t st_nlink; |
||||
uid_t st_uid; |
||||
gid_t st_gid; |
||||
__dev_t st_rdev; |
||||
#if __BSD_VISIBLE |
||||
struct timespec st_atimespec; |
||||
struct timespec st_mtimespec; |
||||
struct timespec st_ctimespec; |
||||
#else |
||||
time_t st_atime; |
||||
long __st_atimensec; |
||||
time_t st_mtime; |
||||
long __st_mtimensec; |
||||
time_t st_ctime; |
||||
long __st_ctimensec; |
||||
#endif |
||||
off_t st_size; |
||||
blkcnt_t st_blocks; |
||||
blksize_t st_blksize; |
||||
fflags_t st_flags; |
||||
__uint32_t st_gen; |
||||
__int32_t st_lspare; |
||||
#if __BSD_VISIBLE |
||||
struct timespec st_birthtimespec; |
||||
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); |
||||
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); |
||||
#else |
||||
time_t st_birthtime; |
||||
long st_birthtimensec; |
||||
unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); |
||||
unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); |
||||
#endif |
||||
}; |
||||
|
||||
// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
|
||||
// See /usr/include/net/if.h.
|
||||
struct if_data8 { |
||||
u_char ifi_type; |
||||
u_char ifi_physical; |
||||
u_char ifi_addrlen; |
||||
u_char ifi_hdrlen; |
||||
u_char ifi_link_state; |
||||
u_char ifi_spare_char1; |
||||
u_char ifi_spare_char2; |
||||
u_char ifi_datalen; |
||||
u_long ifi_mtu; |
||||
u_long ifi_metric; |
||||
u_long ifi_baudrate; |
||||
u_long ifi_ipackets; |
||||
u_long ifi_ierrors; |
||||
u_long ifi_opackets; |
||||
u_long ifi_oerrors; |
||||
u_long ifi_collisions; |
||||
u_long ifi_ibytes; |
||||
u_long ifi_obytes; |
||||
u_long ifi_imcasts; |
||||
u_long ifi_omcasts; |
||||
u_long ifi_iqdrops; |
||||
u_long ifi_noproto; |
||||
u_long ifi_hwassist; |
||||
time_t ifi_epoch; |
||||
struct timeval ifi_lastchange; |
||||
}; |
||||
|
||||
// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
|
||||
// See /usr/include/net/if.h.
|
||||
struct if_msghdr8 { |
||||
u_short ifm_msglen; |
||||
u_char ifm_version; |
||||
u_char ifm_type; |
||||
int ifm_addrs; |
||||
int ifm_flags; |
||||
u_short ifm_index; |
||||
struct if_data8 ifm_data; |
||||
}; |
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
const ( // Directory mode bits
|
||||
S_IFMT = C.S_IFMT |
||||
S_IFIFO = C.S_IFIFO |
||||
S_IFCHR = C.S_IFCHR |
||||
S_IFDIR = C.S_IFDIR |
||||
S_IFBLK = C.S_IFBLK |
||||
S_IFREG = C.S_IFREG |
||||
S_IFLNK = C.S_IFLNK |
||||
S_IFSOCK = C.S_IFSOCK |
||||
S_ISUID = C.S_ISUID |
||||
S_ISGID = C.S_ISGID |
||||
S_ISVTX = C.S_ISVTX |
||||
S_IRUSR = C.S_IRUSR |
||||
S_IWUSR = C.S_IWUSR |
||||
S_IXUSR = C.S_IXUSR |
||||
) |
||||
|
||||
type Stat_t C.struct_stat8 |
||||
|
||||
type Statfs_t C.struct_statfs |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
type Fsid C.struct_fsid |
||||
|
||||
// Advice to Fadvise
|
||||
|
||||
const ( |
||||
FADV_NORMAL = C.POSIX_FADV_NORMAL |
||||
FADV_RANDOM = C.POSIX_FADV_RANDOM |
||||
FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL |
||||
FADV_WILLNEED = C.POSIX_FADV_WILLNEED |
||||
FADV_DONTNEED = C.POSIX_FADV_DONTNEED |
||||
FADV_NOREUSE = C.POSIX_FADV_NOREUSE |
||||
) |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddrDatalink C.struct_sockaddr_dl |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPMreqn C.struct_ip_mreqn |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPMreqn = C.sizeof_struct_ip_mreqn |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Ptrace requests
|
||||
|
||||
const ( |
||||
PTRACE_TRACEME = C.PT_TRACE_ME |
||||
PTRACE_CONT = C.PT_CONTINUE |
||||
PTRACE_KILL = C.PT_KILL |
||||
) |
||||
|
||||
// Events (kqueue, kevent)
|
||||
|
||||
type Kevent_t C.struct_kevent |
||||
|
||||
// Select
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
sizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 |
||||
sizeofIfData = C.sizeof_struct_if_data |
||||
SizeofIfData = C.sizeof_struct_if_data8 |
||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
||||
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr |
||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr |
||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics |
||||
) |
||||
|
||||
type ifMsghdr C.struct_if_msghdr |
||||
|
||||
type IfMsghdr C.struct_if_msghdr8 |
||||
|
||||
type ifData C.struct_if_data |
||||
|
||||
type IfData C.struct_if_data8 |
||||
|
||||
type IfaMsghdr C.struct_ifa_msghdr |
||||
|
||||
type IfmaMsghdr C.struct_ifma_msghdr |
||||
|
||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr |
||||
|
||||
type RtMsghdr C.struct_rt_msghdr |
||||
|
||||
type RtMetrics C.struct_rt_metrics |
||||
|
||||
// Berkeley packet filter
|
||||
|
||||
const ( |
||||
SizeofBpfVersion = C.sizeof_struct_bpf_version |
||||
SizeofBpfStat = C.sizeof_struct_bpf_stat |
||||
SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf |
||||
SizeofBpfProgram = C.sizeof_struct_bpf_program |
||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn |
||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
||||
SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header |
||||
) |
||||
|
||||
type BpfVersion C.struct_bpf_version |
||||
|
||||
type BpfStat C.struct_bpf_stat |
||||
|
||||
type BpfZbuf C.struct_bpf_zbuf |
||||
|
||||
type BpfProgram C.struct_bpf_program |
||||
|
||||
type BpfInsn C.struct_bpf_insn |
||||
|
||||
type BpfHdr C.struct_bpf_hdr |
||||
|
||||
type BpfZbufHeader C.struct_bpf_zbuf_header |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
@ -1,465 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define _LARGEFILE_SOURCE |
||||
#define _LARGEFILE64_SOURCE |
||||
#define _FILE_OFFSET_BITS 64 |
||||
#define _GNU_SOURCE |
||||
|
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/tcp.h> |
||||
#include <netpacket/packet.h> |
||||
#include <poll.h> |
||||
#include <signal.h> |
||||
#include <stdio.h> |
||||
#include <sys/epoll.h> |
||||
#include <sys/inotify.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/param.h> |
||||
#include <sys/ptrace.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/statfs.h> |
||||
#include <sys/sysinfo.h> |
||||
#include <sys/time.h> |
||||
#include <sys/times.h> |
||||
#include <sys/timex.h> |
||||
#include <sys/types.h> |
||||
#include <sys/un.h> |
||||
#include <sys/user.h> |
||||
#include <sys/utsname.h> |
||||
#include <sys/wait.h> |
||||
#include <linux/filter.h> |
||||
#include <linux/netlink.h> |
||||
#include <linux/rtnetlink.h> |
||||
#include <linux/icmpv6.h> |
||||
#include <asm/termbits.h> |
||||
#include <time.h> |
||||
#include <unistd.h> |
||||
#include <ustat.h> |
||||
#include <utime.h> |
||||
#include <bluetooth/bluetooth.h> |
||||
#include <bluetooth/hci.h> |
||||
#include <linux/can.h> |
||||
#include <linux/if_alg.h> |
||||
|
||||
#ifdef TCSETS2 |
||||
// On systems that have "struct termios2" use this as type Termios.
|
||||
typedef struct termios2 termios_t; |
||||
#else |
||||
typedef struct termios termios_t; |
||||
#endif |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_ll s5; |
||||
struct sockaddr_nl s6; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
// copied from /usr/include/linux/un.h
|
||||
struct my_sockaddr_un { |
||||
sa_family_t sun_family; |
||||
#if defined(__ARM_EABI__) || defined(__powerpc64__) |
||||
// on ARM char is by default unsigned
|
||||
signed char sun_path[108]; |
||||
#else |
||||
char sun_path[108]; |
||||
#endif |
||||
}; |
||||
|
||||
#ifdef __ARM_EABI__ |
||||
typedef struct user_regs PtraceRegs; |
||||
#elif defined(__aarch64__) |
||||
typedef struct user_pt_regs PtraceRegs; |
||||
#elif defined(__powerpc64__) |
||||
typedef struct pt_regs PtraceRegs; |
||||
#elif defined(__mips__) |
||||
typedef struct user PtraceRegs; |
||||
#elif defined(__s390x__) |
||||
typedef struct _user_regs_struct PtraceRegs; |
||||
#elif defined(__sparc__) |
||||
#include <asm/ptrace.h> |
||||
typedef struct pt_regs PtraceRegs; |
||||
#else |
||||
typedef struct user_regs_struct PtraceRegs; |
||||
#endif |
||||
|
||||
#if defined(__s390x__) |
||||
typedef struct _user_psw_struct ptracePsw; |
||||
typedef struct _user_fpregs_struct ptraceFpregs; |
||||
typedef struct _user_per_struct ptracePer; |
||||
#else |
||||
typedef struct {} ptracePsw; |
||||
typedef struct {} ptraceFpregs; |
||||
typedef struct {} ptracePer; |
||||
#endif |
||||
|
||||
// The real epoll_event is a union, and godefs doesn't handle it well.
|
||||
struct my_epoll_event { |
||||
uint32_t events; |
||||
#if defined(__ARM_EABI__) || defined(__aarch64__) || (defined(__mips__) && _MIPS_SIM == _ABIO32) |
||||
// padding is not specified in linux/eventpoll.h but added to conform to the
|
||||
// alignment requirements of EABI
|
||||
int32_t padFd; |
||||
#elif defined(__powerpc64__) || defined(__s390x__) || defined(__sparc__) |
||||
int32_t _padFd; |
||||
#endif |
||||
int32_t fd; |
||||
int32_t pad; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
PathMax = C.PATH_MAX |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
type Timex C.struct_timex |
||||
|
||||
type Time_t C.time_t |
||||
|
||||
type Tms C.struct_tms |
||||
|
||||
type Utimbuf C.struct_utimbuf |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
type Stat_t C.struct_stat |
||||
|
||||
type Statfs_t C.struct_statfs |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
type Fsid C.fsid_t |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
// Advice to Fadvise
|
||||
|
||||
const ( |
||||
FADV_NORMAL = C.POSIX_FADV_NORMAL |
||||
FADV_RANDOM = C.POSIX_FADV_RANDOM |
||||
FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL |
||||
FADV_WILLNEED = C.POSIX_FADV_WILLNEED |
||||
FADV_DONTNEED = C.POSIX_FADV_DONTNEED |
||||
FADV_NOREUSE = C.POSIX_FADV_NOREUSE |
||||
) |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_my_sockaddr_un |
||||
|
||||
type RawSockaddrLinklayer C.struct_sockaddr_ll |
||||
|
||||
type RawSockaddrNetlink C.struct_sockaddr_nl |
||||
|
||||
type RawSockaddrHCI C.struct_sockaddr_hci |
||||
|
||||
type RawSockaddrCAN C.struct_sockaddr_can |
||||
|
||||
type RawSockaddrALG C.struct_sockaddr_alg |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPMreqn C.struct_ip_mreqn |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet4Pktinfo C.struct_in_pktinfo |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
type Ucred C.struct_ucred |
||||
|
||||
type TCPInfo C.struct_tcp_info |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll |
||||
SizeofSockaddrNetlink = C.sizeof_struct_sockaddr_nl |
||||
SizeofSockaddrHCI = C.sizeof_struct_sockaddr_hci |
||||
SizeofSockaddrCAN = C.sizeof_struct_sockaddr_can |
||||
SizeofSockaddrALG = C.sizeof_struct_sockaddr_alg |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPMreqn = C.sizeof_struct_ip_mreqn |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
SizeofUcred = C.sizeof_struct_ucred |
||||
SizeofTCPInfo = C.sizeof_struct_tcp_info |
||||
) |
||||
|
||||
// Netlink routing and interface messages
|
||||
|
||||
const ( |
||||
IFA_UNSPEC = C.IFA_UNSPEC |
||||
IFA_ADDRESS = C.IFA_ADDRESS |
||||
IFA_LOCAL = C.IFA_LOCAL |
||||
IFA_LABEL = C.IFA_LABEL |
||||
IFA_BROADCAST = C.IFA_BROADCAST |
||||
IFA_ANYCAST = C.IFA_ANYCAST |
||||
IFA_CACHEINFO = C.IFA_CACHEINFO |
||||
IFA_MULTICAST = C.IFA_MULTICAST |
||||
IFLA_UNSPEC = C.IFLA_UNSPEC |
||||
IFLA_ADDRESS = C.IFLA_ADDRESS |
||||
IFLA_BROADCAST = C.IFLA_BROADCAST |
||||
IFLA_IFNAME = C.IFLA_IFNAME |
||||
IFLA_MTU = C.IFLA_MTU |
||||
IFLA_LINK = C.IFLA_LINK |
||||
IFLA_QDISC = C.IFLA_QDISC |
||||
IFLA_STATS = C.IFLA_STATS |
||||
IFLA_COST = C.IFLA_COST |
||||
IFLA_PRIORITY = C.IFLA_PRIORITY |
||||
IFLA_MASTER = C.IFLA_MASTER |
||||
IFLA_WIRELESS = C.IFLA_WIRELESS |
||||
IFLA_PROTINFO = C.IFLA_PROTINFO |
||||
IFLA_TXQLEN = C.IFLA_TXQLEN |
||||
IFLA_MAP = C.IFLA_MAP |
||||
IFLA_WEIGHT = C.IFLA_WEIGHT |
||||
IFLA_OPERSTATE = C.IFLA_OPERSTATE |
||||
IFLA_LINKMODE = C.IFLA_LINKMODE |
||||
IFLA_LINKINFO = C.IFLA_LINKINFO |
||||
IFLA_NET_NS_PID = C.IFLA_NET_NS_PID |
||||
IFLA_IFALIAS = C.IFLA_IFALIAS |
||||
IFLA_MAX = C.IFLA_MAX |
||||
RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE |
||||
RT_SCOPE_SITE = C.RT_SCOPE_SITE |
||||
RT_SCOPE_LINK = C.RT_SCOPE_LINK |
||||
RT_SCOPE_HOST = C.RT_SCOPE_HOST |
||||
RT_SCOPE_NOWHERE = C.RT_SCOPE_NOWHERE |
||||
RT_TABLE_UNSPEC = C.RT_TABLE_UNSPEC |
||||
RT_TABLE_COMPAT = C.RT_TABLE_COMPAT |
||||
RT_TABLE_DEFAULT = C.RT_TABLE_DEFAULT |
||||
RT_TABLE_MAIN = C.RT_TABLE_MAIN |
||||
RT_TABLE_LOCAL = C.RT_TABLE_LOCAL |
||||
RT_TABLE_MAX = C.RT_TABLE_MAX |
||||
RTA_UNSPEC = C.RTA_UNSPEC |
||||
RTA_DST = C.RTA_DST |
||||
RTA_SRC = C.RTA_SRC |
||||
RTA_IIF = C.RTA_IIF |
||||
RTA_OIF = C.RTA_OIF |
||||
RTA_GATEWAY = C.RTA_GATEWAY |
||||
RTA_PRIORITY = C.RTA_PRIORITY |
||||
RTA_PREFSRC = C.RTA_PREFSRC |
||||
RTA_METRICS = C.RTA_METRICS |
||||
RTA_MULTIPATH = C.RTA_MULTIPATH |
||||
RTA_FLOW = C.RTA_FLOW |
||||
RTA_CACHEINFO = C.RTA_CACHEINFO |
||||
RTA_TABLE = C.RTA_TABLE |
||||
RTN_UNSPEC = C.RTN_UNSPEC |
||||
RTN_UNICAST = C.RTN_UNICAST |
||||
RTN_LOCAL = C.RTN_LOCAL |
||||
RTN_BROADCAST = C.RTN_BROADCAST |
||||
RTN_ANYCAST = C.RTN_ANYCAST |
||||
RTN_MULTICAST = C.RTN_MULTICAST |
||||
RTN_BLACKHOLE = C.RTN_BLACKHOLE |
||||
RTN_UNREACHABLE = C.RTN_UNREACHABLE |
||||
RTN_PROHIBIT = C.RTN_PROHIBIT |
||||
RTN_THROW = C.RTN_THROW |
||||
RTN_NAT = C.RTN_NAT |
||||
RTN_XRESOLVE = C.RTN_XRESOLVE |
||||
RTNLGRP_NONE = C.RTNLGRP_NONE |
||||
RTNLGRP_LINK = C.RTNLGRP_LINK |
||||
RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY |
||||
RTNLGRP_NEIGH = C.RTNLGRP_NEIGH |
||||
RTNLGRP_TC = C.RTNLGRP_TC |
||||
RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR |
||||
RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE |
||||
RTNLGRP_IPV4_ROUTE = C.RTNLGRP_IPV4_ROUTE |
||||
RTNLGRP_IPV4_RULE = C.RTNLGRP_IPV4_RULE |
||||
RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR |
||||
RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE |
||||
RTNLGRP_IPV6_ROUTE = C.RTNLGRP_IPV6_ROUTE |
||||
RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO |
||||
RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX |
||||
RTNLGRP_IPV6_RULE = C.RTNLGRP_IPV6_RULE |
||||
RTNLGRP_ND_USEROPT = C.RTNLGRP_ND_USEROPT |
||||
SizeofNlMsghdr = C.sizeof_struct_nlmsghdr |
||||
SizeofNlMsgerr = C.sizeof_struct_nlmsgerr |
||||
SizeofRtGenmsg = C.sizeof_struct_rtgenmsg |
||||
SizeofNlAttr = C.sizeof_struct_nlattr |
||||
SizeofRtAttr = C.sizeof_struct_rtattr |
||||
SizeofIfInfomsg = C.sizeof_struct_ifinfomsg |
||||
SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg |
||||
SizeofRtMsg = C.sizeof_struct_rtmsg |
||||
SizeofRtNexthop = C.sizeof_struct_rtnexthop |
||||
) |
||||
|
||||
type NlMsghdr C.struct_nlmsghdr |
||||
|
||||
type NlMsgerr C.struct_nlmsgerr |
||||
|
||||
type RtGenmsg C.struct_rtgenmsg |
||||
|
||||
type NlAttr C.struct_nlattr |
||||
|
||||
type RtAttr C.struct_rtattr |
||||
|
||||
type IfInfomsg C.struct_ifinfomsg |
||||
|
||||
type IfAddrmsg C.struct_ifaddrmsg |
||||
|
||||
type RtMsg C.struct_rtmsg |
||||
|
||||
type RtNexthop C.struct_rtnexthop |
||||
|
||||
// Linux socket filter
|
||||
|
||||
const ( |
||||
SizeofSockFilter = C.sizeof_struct_sock_filter |
||||
SizeofSockFprog = C.sizeof_struct_sock_fprog |
||||
) |
||||
|
||||
type SockFilter C.struct_sock_filter |
||||
|
||||
type SockFprog C.struct_sock_fprog |
||||
|
||||
// Inotify
|
||||
|
||||
type InotifyEvent C.struct_inotify_event |
||||
|
||||
const SizeofInotifyEvent = C.sizeof_struct_inotify_event |
||||
|
||||
// Ptrace
|
||||
|
||||
// Register structures
|
||||
type PtraceRegs C.PtraceRegs |
||||
|
||||
// Structures contained in PtraceRegs on s390x (exported by mkpost.go)
|
||||
type ptracePsw C.ptracePsw |
||||
|
||||
type ptraceFpregs C.ptraceFpregs |
||||
|
||||
type ptracePer C.ptracePer |
||||
|
||||
// Misc
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
type Sysinfo_t C.struct_sysinfo |
||||
|
||||
type Utsname C.struct_utsname |
||||
|
||||
type Ustat_t C.struct_ustat |
||||
|
||||
type EpollEvent C.struct_my_epoll_event |
||||
|
||||
const ( |
||||
AT_FDCWD = C.AT_FDCWD |
||||
AT_REMOVEDIR = C.AT_REMOVEDIR |
||||
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW |
||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW |
||||
) |
||||
|
||||
type PollFd C.struct_pollfd |
||||
|
||||
const ( |
||||
POLLIN = C.POLLIN |
||||
POLLPRI = C.POLLPRI |
||||
POLLOUT = C.POLLOUT |
||||
POLLRDHUP = C.POLLRDHUP |
||||
POLLERR = C.POLLERR |
||||
POLLHUP = C.POLLHUP |
||||
POLLNVAL = C.POLLNVAL |
||||
) |
||||
|
||||
type Sigset_t C.sigset_t |
||||
|
||||
// sysconf information
|
||||
|
||||
const _SC_PAGESIZE = C._SC_PAGESIZE |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.termios_t |
@ -1,232 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define KERNEL |
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <signal.h> |
||||
#include <termios.h> |
||||
#include <stdio.h> |
||||
#include <unistd.h> |
||||
#include <sys/param.h> |
||||
#include <sys/types.h> |
||||
#include <sys/event.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/ptrace.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/sysctl.h> |
||||
#include <sys/time.h> |
||||
#include <sys/uio.h> |
||||
#include <sys/un.h> |
||||
#include <sys/wait.h> |
||||
#include <net/bpf.h> |
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <net/route.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
#include <netinet/tcp.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
type Stat_t C.struct_stat |
||||
|
||||
type Statfs_t C.struct_statfs |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
type Fsid C.fsid_t |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddrDatalink C.struct_sockaddr_dl |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Ptrace requests
|
||||
|
||||
const ( |
||||
PTRACE_TRACEME = C.PT_TRACE_ME |
||||
PTRACE_CONT = C.PT_CONTINUE |
||||
PTRACE_KILL = C.PT_KILL |
||||
) |
||||
|
||||
// Events (kqueue, kevent)
|
||||
|
||||
type Kevent_t C.struct_kevent |
||||
|
||||
// Select
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
SizeofIfData = C.sizeof_struct_if_data |
||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr |
||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics |
||||
) |
||||
|
||||
type IfMsghdr C.struct_if_msghdr |
||||
|
||||
type IfData C.struct_if_data |
||||
|
||||
type IfaMsghdr C.struct_ifa_msghdr |
||||
|
||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr |
||||
|
||||
type RtMsghdr C.struct_rt_msghdr |
||||
|
||||
type RtMetrics C.struct_rt_metrics |
||||
|
||||
type Mclpool C.struct_mclpool |
||||
|
||||
// Berkeley packet filter
|
||||
|
||||
const ( |
||||
SizeofBpfVersion = C.sizeof_struct_bpf_version |
||||
SizeofBpfStat = C.sizeof_struct_bpf_stat |
||||
SizeofBpfProgram = C.sizeof_struct_bpf_program |
||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn |
||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
||||
) |
||||
|
||||
type BpfVersion C.struct_bpf_version |
||||
|
||||
type BpfStat C.struct_bpf_stat |
||||
|
||||
type BpfProgram C.struct_bpf_program |
||||
|
||||
type BpfInsn C.struct_bpf_insn |
||||
|
||||
type BpfHdr C.struct_bpf_hdr |
||||
|
||||
type BpfTimeval C.struct_bpf_timeval |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
||||
|
||||
// Sysctl
|
||||
|
||||
type Sysctlnode C.struct_sysctlnode |
@ -1,244 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define KERNEL |
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <signal.h> |
||||
#include <termios.h> |
||||
#include <stdio.h> |
||||
#include <unistd.h> |
||||
#include <sys/param.h> |
||||
#include <sys/types.h> |
||||
#include <sys/event.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/ptrace.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/time.h> |
||||
#include <sys/uio.h> |
||||
#include <sys/un.h> |
||||
#include <sys/wait.h> |
||||
#include <net/bpf.h> |
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <net/route.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
#include <netinet/tcp.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
const ( // Directory mode bits
|
||||
S_IFMT = C.S_IFMT |
||||
S_IFIFO = C.S_IFIFO |
||||
S_IFCHR = C.S_IFCHR |
||||
S_IFDIR = C.S_IFDIR |
||||
S_IFBLK = C.S_IFBLK |
||||
S_IFREG = C.S_IFREG |
||||
S_IFLNK = C.S_IFLNK |
||||
S_IFSOCK = C.S_IFSOCK |
||||
S_ISUID = C.S_ISUID |
||||
S_ISGID = C.S_ISGID |
||||
S_ISVTX = C.S_ISVTX |
||||
S_IRUSR = C.S_IRUSR |
||||
S_IWUSR = C.S_IWUSR |
||||
S_IXUSR = C.S_IXUSR |
||||
) |
||||
|
||||
type Stat_t C.struct_stat |
||||
|
||||
type Statfs_t C.struct_statfs |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
type Fsid C.fsid_t |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddrDatalink C.struct_sockaddr_dl |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Ptrace requests
|
||||
|
||||
const ( |
||||
PTRACE_TRACEME = C.PT_TRACE_ME |
||||
PTRACE_CONT = C.PT_CONTINUE |
||||
PTRACE_KILL = C.PT_KILL |
||||
) |
||||
|
||||
// Events (kqueue, kevent)
|
||||
|
||||
type Kevent_t C.struct_kevent |
||||
|
||||
// Select
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
SizeofIfData = C.sizeof_struct_if_data |
||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
||||
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr |
||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics |
||||
) |
||||
|
||||
type IfMsghdr C.struct_if_msghdr |
||||
|
||||
type IfData C.struct_if_data |
||||
|
||||
type IfaMsghdr C.struct_ifa_msghdr |
||||
|
||||
type IfAnnounceMsghdr C.struct_if_announcemsghdr |
||||
|
||||
type RtMsghdr C.struct_rt_msghdr |
||||
|
||||
type RtMetrics C.struct_rt_metrics |
||||
|
||||
type Mclpool C.struct_mclpool |
||||
|
||||
// Berkeley packet filter
|
||||
|
||||
const ( |
||||
SizeofBpfVersion = C.sizeof_struct_bpf_version |
||||
SizeofBpfStat = C.sizeof_struct_bpf_stat |
||||
SizeofBpfProgram = C.sizeof_struct_bpf_program |
||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn |
||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
||||
) |
||||
|
||||
type BpfVersion C.struct_bpf_version |
||||
|
||||
type BpfStat C.struct_bpf_stat |
||||
|
||||
type BpfProgram C.struct_bpf_program |
||||
|
||||
type BpfInsn C.struct_bpf_insn |
||||
|
||||
type BpfHdr C.struct_bpf_hdr |
||||
|
||||
type BpfTimeval C.struct_bpf_timeval |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
@ -1,262 +0,0 @@ |
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#define KERNEL |
||||
// These defines ensure that builds done on newer versions of Solaris are
|
||||
// backwards-compatible with older versions of Solaris and
|
||||
// OpenSolaris-based derivatives.
|
||||
#define __USE_SUNOS_SOCKETS__ // msghdr
|
||||
#define __USE_LEGACY_PROTOTYPES__ // iovec
|
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
#include <netdb.h> |
||||
#include <limits.h> |
||||
#include <signal.h> |
||||
#include <termios.h> |
||||
#include <termio.h> |
||||
#include <stdio.h> |
||||
#include <unistd.h> |
||||
#include <sys/mman.h> |
||||
#include <sys/mount.h> |
||||
#include <sys/param.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/select.h> |
||||
#include <sys/signal.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/time.h> |
||||
#include <sys/times.h> |
||||
#include <sys/types.h> |
||||
#include <sys/utsname.h> |
||||
#include <sys/un.h> |
||||
#include <sys/wait.h> |
||||
#include <net/bpf.h> |
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <net/route.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
#include <netinet/tcp.h> |
||||
#include <ustat.h> |
||||
#include <utime.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics; for internal use.
|
||||
|
||||
const ( |
||||
sizeofPtr = C.sizeofPtr |
||||
sizeofShort = C.sizeof_short |
||||
sizeofInt = C.sizeof_int |
||||
sizeofLong = C.sizeof_long |
||||
sizeofLongLong = C.sizeof_longlong |
||||
PathMax = C.PATH_MAX |
||||
MaxHostNameLen = C.MAXHOSTNAMELEN |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
type Timeval32 C.struct_timeval32 |
||||
|
||||
type Tms C.struct_tms |
||||
|
||||
type Utimbuf C.struct_utimbuf |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
// Files
|
||||
|
||||
const ( // Directory mode bits
|
||||
S_IFMT = C.S_IFMT |
||||
S_IFIFO = C.S_IFIFO |
||||
S_IFCHR = C.S_IFCHR |
||||
S_IFDIR = C.S_IFDIR |
||||
S_IFBLK = C.S_IFBLK |
||||
S_IFREG = C.S_IFREG |
||||
S_IFLNK = C.S_IFLNK |
||||
S_IFSOCK = C.S_IFSOCK |
||||
S_ISUID = C.S_ISUID |
||||
S_ISGID = C.S_ISGID |
||||
S_ISVTX = C.S_ISVTX |
||||
S_IRUSR = C.S_IRUSR |
||||
S_IWUSR = C.S_IWUSR |
||||
S_IXUSR = C.S_IXUSR |
||||
) |
||||
|
||||
type Stat_t C.struct_stat |
||||
|
||||
type Flock_t C.struct_flock |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddrDatalink C.struct_sockaddr_dl |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type Inet6Pktinfo C.struct_in6_pktinfo |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Select
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
// Misc
|
||||
|
||||
type Utsname C.struct_utsname |
||||
|
||||
type Ustat_t C.struct_ustat |
||||
|
||||
const ( |
||||
AT_FDCWD = C.AT_FDCWD |
||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW |
||||
AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW |
||||
AT_REMOVEDIR = C.AT_REMOVEDIR |
||||
AT_EACCESS = C.AT_EACCESS |
||||
) |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
SizeofIfData = C.sizeof_struct_if_data |
||||
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
||||
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
||||
SizeofRtMetrics = C.sizeof_struct_rt_metrics |
||||
) |
||||
|
||||
type IfMsghdr C.struct_if_msghdr |
||||
|
||||
type IfData C.struct_if_data |
||||
|
||||
type IfaMsghdr C.struct_ifa_msghdr |
||||
|
||||
type RtMsghdr C.struct_rt_msghdr |
||||
|
||||
type RtMetrics C.struct_rt_metrics |
||||
|
||||
// Berkeley packet filter
|
||||
|
||||
const ( |
||||
SizeofBpfVersion = C.sizeof_struct_bpf_version |
||||
SizeofBpfStat = C.sizeof_struct_bpf_stat |
||||
SizeofBpfProgram = C.sizeof_struct_bpf_program |
||||
SizeofBpfInsn = C.sizeof_struct_bpf_insn |
||||
SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
||||
) |
||||
|
||||
type BpfVersion C.struct_bpf_version |
||||
|
||||
type BpfStat C.struct_bpf_stat |
||||
|
||||
type BpfProgram C.struct_bpf_program |
||||
|
||||
type BpfInsn C.struct_bpf_insn |
||||
|
||||
type BpfTimeval C.struct_bpf_timeval |
||||
|
||||
type BpfHdr C.struct_bpf_hdr |
||||
|
||||
// sysconf information
|
||||
|
||||
const _SC_PAGESIZE = C._SC_PAGESIZE |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
||||
|
||||
type Termio C.struct_termio |
||||
|
||||
type Winsize C.struct_winsize |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue