forked from mirror/go-ethereum
* cmd/puppeth: handle encrypted ssh keys * cmd/puppeth: fix unconvert linter errorrelease/1.7
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) |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue