mirror of https://github.com/go-gitea/gitea
Update vendor/golang.org/x/sys (#5059)
parent
2af57c7820
commit
99c09dfbfa
@ -0,0 +1,124 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// CPU affinity functions
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"unsafe" |
||||
) |
||||
|
||||
const cpuSetSize = _CPU_SETSIZE / _NCPUBITS |
||||
|
||||
// CPUSet represents a CPU affinity mask.
|
||||
type CPUSet [cpuSetSize]cpuMask |
||||
|
||||
func schedAffinity(trap uintptr, pid int, set *CPUSet) error { |
||||
_, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) |
||||
if e != 0 { |
||||
return errnoErr(e) |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
|
||||
// If pid is 0 the calling thread is used.
|
||||
func SchedGetaffinity(pid int, set *CPUSet) error { |
||||
return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) |
||||
} |
||||
|
||||
// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
|
||||
// If pid is 0 the calling thread is used.
|
||||
func SchedSetaffinity(pid int, set *CPUSet) error { |
||||
return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) |
||||
} |
||||
|
||||
// Zero clears the set s, so that it contains no CPUs.
|
||||
func (s *CPUSet) Zero() { |
||||
for i := range s { |
||||
s[i] = 0 |
||||
} |
||||
} |
||||
|
||||
func cpuBitsIndex(cpu int) int { |
||||
return cpu / _NCPUBITS |
||||
} |
||||
|
||||
func cpuBitsMask(cpu int) cpuMask { |
||||
return cpuMask(1 << (uint(cpu) % _NCPUBITS)) |
||||
} |
||||
|
||||
// Set adds cpu to the set s.
|
||||
func (s *CPUSet) Set(cpu int) { |
||||
i := cpuBitsIndex(cpu) |
||||
if i < len(s) { |
||||
s[i] |= cpuBitsMask(cpu) |
||||
} |
||||
} |
||||
|
||||
// Clear removes cpu from the set s.
|
||||
func (s *CPUSet) Clear(cpu int) { |
||||
i := cpuBitsIndex(cpu) |
||||
if i < len(s) { |
||||
s[i] &^= cpuBitsMask(cpu) |
||||
} |
||||
} |
||||
|
||||
// IsSet reports whether cpu is in the set s.
|
||||
func (s *CPUSet) IsSet(cpu int) bool { |
||||
i := cpuBitsIndex(cpu) |
||||
if i < len(s) { |
||||
return s[i]&cpuBitsMask(cpu) != 0 |
||||
} |
||||
return false |
||||
} |
||||
|
||||
// Count returns the number of CPUs in the set s.
|
||||
func (s *CPUSet) Count() int { |
||||
c := 0 |
||||
for _, b := range s { |
||||
c += onesCount64(uint64(b)) |
||||
} |
||||
return c |
||||
} |
||||
|
||||
// onesCount64 is a copy of Go 1.9's math/bits.OnesCount64.
|
||||
// Once this package can require Go 1.9, we can delete this
|
||||
// and update the caller to use bits.OnesCount64.
|
||||
func onesCount64(x uint64) int { |
||||
const m0 = 0x5555555555555555 // 01010101 ...
|
||||
const m1 = 0x3333333333333333 // 00110011 ...
|
||||
const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ...
|
||||
const m3 = 0x00ff00ff00ff00ff // etc.
|
||||
const m4 = 0x0000ffff0000ffff |
||||
|
||||
// Implementation: Parallel summing of adjacent bits.
|
||||
// See "Hacker's Delight", Chap. 5: Counting Bits.
|
||||
// The following pattern shows the general approach:
|
||||
//
|
||||
// x = x>>1&(m0&m) + x&(m0&m)
|
||||
// x = x>>2&(m1&m) + x&(m1&m)
|
||||
// x = x>>4&(m2&m) + x&(m2&m)
|
||||
// x = x>>8&(m3&m) + x&(m3&m)
|
||||
// x = x>>16&(m4&m) + x&(m4&m)
|
||||
// x = x>>32&(m5&m) + x&(m5&m)
|
||||
// return int(x)
|
||||
//
|
||||
// Masking (& operations) can be left away when there's no
|
||||
// danger that a field's sum will carry over into the next
|
||||
// field: Since the result cannot be > 64, 8 bits is enough
|
||||
// and we can ignore the masks for the shifts by 8 and up.
|
||||
// Per "Hacker's Delight", the first line can be simplified
|
||||
// more, but it saves at best one instruction, so we leave
|
||||
// it alone for clarity.
|
||||
const m = 1<<64 - 1 |
||||
x = x>>1&(m0&m) + x&(m0&m) |
||||
x = x>>2&(m1&m) + x&(m1&m) |
||||
x = (x>>4 + x) & (m2 & m) |
||||
x += x >> 8 |
||||
x += x >> 16 |
||||
x += x >> 32 |
||||
return int(x) & (1<<7 - 1) |
||||
} |
@ -0,0 +1,14 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build go1.9
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
type Signal = syscall.Signal |
||||
type Errno = syscall.Errno |
||||
type SysProcAttr = syscall.SysProcAttr |
@ -1,10 +0,0 @@ |
||||
// Copyright 2014 The Go Authors. All rights reserved. |
||||
// Use of this source code is governed by a BSD-style |
||||
// license that can be found in the LICENSE file. |
||||
|
||||
// +build !gccgo |
||||
|
||||
#include "textflag.h" |
||||
|
||||
TEXT ·use(SB),NOSPLIT,$0 |
||||
RET |
@ -0,0 +1,17 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved. |
||||
// Use of this source code is governed by a BSD-style |
||||
// license that can be found in the LICENSE file. |
||||
|
||||
// +build !gccgo |
||||
|
||||
#include "textflag.h" |
||||
|
||||
// |
||||
// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go |
||||
// |
||||
|
||||
TEXT ·syscall6(SB),NOSPLIT,$0-88 |
||||
JMP syscall·syscall6(SB) |
||||
|
||||
TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 |
||||
JMP syscall·rawSyscall6(SB) |
@ -0,0 +1,54 @@ |
||||
// 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 linux |
||||
// +build mips mipsle |
||||
// +build !gccgo |
||||
|
||||
#include "textflag.h" |
||||
|
||||
// |
||||
// System calls for mips, Linux |
||||
// |
||||
|
||||
// Just jump to package syscall's implementation for all these functions. |
||||
// The runtime may know about them. |
||||
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
||||
JMP syscall·Syscall(SB) |
||||
|
||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
||||
JMP syscall·Syscall6(SB) |
||||
|
||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
||||
JMP syscall·Syscall9(SB) |
||||
|
||||
TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 |
||||
JAL runtime·entersyscall(SB) |
||||
MOVW a1+4(FP), R4 |
||||
MOVW a2+8(FP), R5 |
||||
MOVW a3+12(FP), R6 |
||||
MOVW R0, R7 |
||||
MOVW trap+0(FP), R2 // syscall entry |
||||
SYSCALL |
||||
MOVW R2, r1+16(FP) // r1 |
||||
MOVW R3, r2+20(FP) // r2 |
||||
JAL runtime·exitsyscall(SB) |
||||
RET |
||||
|
||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
||||
JMP syscall·RawSyscall(SB) |
||||
|
||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
||||
JMP syscall·RawSyscall6(SB) |
||||
|
||||
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 |
||||
MOVW a1+4(FP), R4 |
||||
MOVW a2+8(FP), R5 |
||||
MOVW a3+12(FP), R6 |
||||
MOVW trap+0(FP), R2 // syscall entry |
||||
SYSCALL |
||||
MOVW R2, r1+16(FP) |
||||
MOVW R3, r2+20(FP) |
||||
RET |
@ -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 ( |
||||
"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 errors.New("bad rights size") |
||||
} |
||||
|
||||
for _, right := range setrights { |
||||
if caprver(right) != CAP_RIGHTS_VERSION_00 { |
||||
return errors.New("bad right version") |
||||
} |
||||
i, err := rightToIndex(right) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if i >= n { |
||||
return errors.New("index overflow") |
||||
} |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errors.New("index mismatch") |
||||
} |
||||
rights.Rights[i] |= right |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errors.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 errors.New("bad rights size") |
||||
} |
||||
|
||||
for _, right := range clearrights { |
||||
if caprver(right) != CAP_RIGHTS_VERSION_00 { |
||||
return errors.New("bad right version") |
||||
} |
||||
i, err := rightToIndex(right) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if i >= n { |
||||
return errors.New("index overflow") |
||||
} |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errors.New("index mismatch") |
||||
} |
||||
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return errors.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, errors.New("bad rights size") |
||||
} |
||||
|
||||
for _, right := range setrights { |
||||
if caprver(right) != CAP_RIGHTS_VERSION_00 { |
||||
return false, errors.New("bad right version") |
||||
} |
||||
i, err := rightToIndex(right) |
||||
if err != nil { |
||||
return false, err |
||||
} |
||||
if i >= n { |
||||
return false, errors.New("index overflow") |
||||
} |
||||
if capidxbit(rights.Rights[i]) != capidxbit(right) { |
||||
return false, errors.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,27 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix
|
||||
// +build ppc
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used by AIX.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a Linux device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev >> 16) & 0xffff) |
||||
} |
||||
|
||||
// Minor returns the minor component of a Linux device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
return uint32(dev & 0xffff) |
||||
} |
||||
|
||||
// Mkdev returns a Linux device number generated from the given major and minor
|
||||
// components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
return uint64(((major) << 16) | (minor)) |
||||
} |
@ -0,0 +1,29 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix
|
||||
// +build ppc64
|
||||
|
||||
// Functions to access/create device major and minor numbers matching the
|
||||
// encoding used AIX.
|
||||
|
||||
package unix |
||||
|
||||
// Major returns the major component of a Linux device number.
|
||||
func Major(dev uint64) uint32 { |
||||
return uint32((dev & 0x3fffffff00000000) >> 32) |
||||
} |
||||
|
||||
// Minor returns the minor component of a Linux device number.
|
||||
func Minor(dev uint64) uint32 { |
||||
return uint32((dev & 0x00000000ffffffff) >> 0) |
||||
} |
||||
|
||||
// Mkdev returns a Linux device number generated from the given major and minor
|
||||
// components.
|
||||
func Mkdev(major, minor uint32) uint64 { |
||||
var DEVNO64 uint64 |
||||
DEVNO64 = 0x8000000000000000 |
||||
return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) |
||||
} |
@ -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,17 @@ |
||||
// 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 aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
// 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) { |
||||
return syscall.ParseDirent(buf, max, 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 |
@ -1,14 +0,0 @@ |
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.4
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
func Unsetenv(key string) error { |
||||
// This was added in Go 1.4.
|
||||
return syscall.Unsetenv(key) |
||||
} |
@ -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,4 +1,4 @@ |
||||
// +build linux,386 linux,arm
|
||||
// +build linux,386 linux,arm linux,mips linux,mipsle
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
@ -0,0 +1,30 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package unix |
||||
|
||||
import "runtime" |
||||
|
||||
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
||||
//
|
||||
// To change fd's window size, the req argument should be TIOCSWINSZ.
|
||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error { |
||||
// TODO: if we get the chance, remove the req parameter and
|
||||
// hardcode TIOCSWINSZ.
|
||||
err := ioctlSetWinsize(fd, req, value) |
||||
runtime.KeepAlive(value) |
||||
return err |
||||
} |
||||
|
||||
// IoctlSetTermios performs an ioctl on fd with a *Termios.
|
||||
//
|
||||
// The req value will usually be TCSETA or TIOCSETA.
|
||||
func IoctlSetTermios(fd int, req uint, value *Termios) error { |
||||
// TODO: if we get the chance, remove the req parameter.
|
||||
err := ioctlSetTermios(fd, req, value) |
||||
runtime.KeepAlive(value) |
||||
return err |
||||
} |
@ -0,0 +1,166 @@ |
||||
// 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 ( |
||||
"errors" |
||||
"fmt" |
||||
"strconv" |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
// Pledge implements the pledge syscall.
|
||||
//
|
||||
// The pledge syscall does not accept execpromises on OpenBSD releases
|
||||
// before 6.3.
|
||||
//
|
||||
// execpromises must be empty when Pledge is called on OpenBSD
|
||||
// releases predating 6.3, otherwise an error will be returned.
|
||||
//
|
||||
// For more information see pledge(2).
|
||||
func Pledge(promises, execpromises string) error { |
||||
maj, min, err := majmin() |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
err = pledgeAvailable(maj, min, execpromises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
pptr, err := syscall.BytePtrFromString(promises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
// This variable will hold either a nil unsafe.Pointer or
|
||||
// an unsafe.Pointer to a string (execpromises).
|
||||
var expr unsafe.Pointer |
||||
|
||||
// If we're running on OpenBSD > 6.2, pass execpromises to the syscall.
|
||||
if maj > 6 || (maj == 6 && min > 2) { |
||||
exptr, err := syscall.BytePtrFromString(execpromises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
expr = unsafe.Pointer(exptr) |
||||
} |
||||
|
||||
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) |
||||
if e != 0 { |
||||
return e |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// PledgePromises implements the pledge syscall.
|
||||
//
|
||||
// This changes the promises and leaves the execpromises untouched.
|
||||
//
|
||||
// For more information see pledge(2).
|
||||
func PledgePromises(promises string) error { |
||||
maj, min, err := majmin() |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
err = pledgeAvailable(maj, min, "") |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
// This variable holds the execpromises and is always nil.
|
||||
var expr unsafe.Pointer |
||||
|
||||
pptr, err := syscall.BytePtrFromString(promises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) |
||||
if e != 0 { |
||||
return e |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// PledgeExecpromises implements the pledge syscall.
|
||||
//
|
||||
// This changes the execpromises and leaves the promises untouched.
|
||||
//
|
||||
// For more information see pledge(2).
|
||||
func PledgeExecpromises(execpromises string) error { |
||||
maj, min, err := majmin() |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
err = pledgeAvailable(maj, min, execpromises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
// This variable holds the promises and is always nil.
|
||||
var pptr unsafe.Pointer |
||||
|
||||
exptr, err := syscall.BytePtrFromString(execpromises) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(pptr), uintptr(unsafe.Pointer(exptr)), 0) |
||||
if e != 0 { |
||||
return e |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// majmin returns major and minor version number for an OpenBSD system.
|
||||
func majmin() (major int, minor int, err error) { |
||||
var v Utsname |
||||
err = Uname(&v) |
||||
if err != nil { |
||||
return |
||||
} |
||||
|
||||
major, err = strconv.Atoi(string(v.Release[0])) |
||||
if err != nil { |
||||
err = errors.New("cannot parse major version number returned by uname") |
||||
return |
||||
} |
||||
|
||||
minor, err = strconv.Atoi(string(v.Release[2])) |
||||
if err != nil { |
||||
err = errors.New("cannot parse minor version number returned by uname") |
||||
return |
||||
} |
||||
|
||||
return |
||||
} |
||||
|
||||
// pledgeAvailable checks for availability of the pledge(2) syscall
|
||||
// based on the running OpenBSD version.
|
||||
func pledgeAvailable(maj, min int, execpromises string) error { |
||||
// If OpenBSD <= 5.9, pledge is not available.
|
||||
if (maj == 5 && min != 9) || maj < 5 { |
||||
return fmt.Errorf("pledge syscall is not available on OpenBSD %d.%d", maj, min) |
||||
} |
||||
|
||||
// If OpenBSD <= 6.2 and execpromises is not empty,
|
||||
// return an error - execpromises is not available before 6.3
|
||||
if (maj < 6 || (maj == 6 && min <= 2)) && execpromises != "" { |
||||
return fmt.Errorf("cannot use execpromises on OpenBSD %d.%d", maj, min) |
||||
} |
||||
|
||||
return nil |
||||
} |
@ -0,0 +1,44 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build openbsd
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
// Unveil implements the unveil syscall.
|
||||
// For more information see unveil(2).
|
||||
// Note that the special case of blocking further
|
||||
// unveil calls is handled by UnveilBlock.
|
||||
func Unveil(path string, flags string) error { |
||||
pathPtr, err := syscall.BytePtrFromString(path) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
flagsPtr, err := syscall.BytePtrFromString(flags) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
_, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) |
||||
if e != 0 { |
||||
return e |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
// UnveilBlock blocks future unveil calls.
|
||||
// For more information see unveil(2).
|
||||
func UnveilBlock() error { |
||||
// Both pointers must be nil.
|
||||
var pathUnsafe, flagsUnsafe unsafe.Pointer |
||||
_, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 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 aix 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,547 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix
|
||||
|
||||
// Aix system calls.
|
||||
// This file is compiled as ordinary Go code,
|
||||
// but it is also input to mksyscall,
|
||||
// which parses the //sys lines and generates system call stubs.
|
||||
// Note that sometimes we use a lowercase //sys name and
|
||||
// wrap it in our own nicer implementation.
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
/* |
||||
* Wrapped |
||||
*/ |
||||
|
||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||
func Utimes(path string, tv []Timeval) error { |
||||
if len(tv) != 2 { |
||||
return EINVAL |
||||
} |
||||
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) |
||||
} |
||||
|
||||
//sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
|
||||
func UtimesNano(path string, ts []Timespec) error { |
||||
if len(ts) != 2 { |
||||
return EINVAL |
||||
} |
||||
return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) |
||||
} |
||||
|
||||
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { |
||||
if ts == nil { |
||||
return utimensat(dirfd, path, nil, flags) |
||||
} |
||||
if len(ts) != 2 { |
||||
return EINVAL |
||||
} |
||||
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) |
||||
} |
||||
|
||||
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { |
||||
if sa.Port < 0 || sa.Port > 0xFFFF { |
||||
return nil, 0, EINVAL |
||||
} |
||||
sa.raw.Family = AF_INET |
||||
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) |
||||
p[0] = byte(sa.Port >> 8) |
||||
p[1] = byte(sa.Port) |
||||
for i := 0; i < len(sa.Addr); i++ { |
||||
sa.raw.Addr[i] = sa.Addr[i] |
||||
} |
||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil |
||||
} |
||||
|
||||
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { |
||||
if sa.Port < 0 || sa.Port > 0xFFFF { |
||||
return nil, 0, EINVAL |
||||
} |
||||
sa.raw.Family = AF_INET6 |
||||
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) |
||||
p[0] = byte(sa.Port >> 8) |
||||
p[1] = byte(sa.Port) |
||||
sa.raw.Scope_id = sa.ZoneId |
||||
for i := 0; i < len(sa.Addr); i++ { |
||||
sa.raw.Addr[i] = sa.Addr[i] |
||||
} |
||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil |
||||
} |
||||
|
||||
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { |
||||
name := sa.Name |
||||
n := len(name) |
||||
if n > len(sa.raw.Path) { |
||||
return nil, 0, EINVAL |
||||
} |
||||
if n == len(sa.raw.Path) && name[0] != '@' { |
||||
return nil, 0, EINVAL |
||||
} |
||||
sa.raw.Family = AF_UNIX |
||||
for i := 0; i < n; i++ { |
||||
sa.raw.Path[i] = uint8(name[i]) |
||||
} |
||||
// length is family (uint16), name, NUL.
|
||||
sl := _Socklen(2) |
||||
if n > 0 { |
||||
sl += _Socklen(n) + 1 |
||||
} |
||||
if sa.raw.Path[0] == '@' { |
||||
sa.raw.Path[0] = 0 |
||||
// Don't count trailing NUL for abstract address.
|
||||
sl-- |
||||
} |
||||
|
||||
return unsafe.Pointer(&sa.raw), sl, nil |
||||
} |
||||
|
||||
func Getsockname(fd int) (sa Sockaddr, err error) { |
||||
var rsa RawSockaddrAny |
||||
var len _Socklen = SizeofSockaddrAny |
||||
if err = getsockname(fd, &rsa, &len); err != nil { |
||||
return |
||||
} |
||||
return anyToSockaddr(fd, &rsa) |
||||
} |
||||
|
||||
//sys getcwd(buf []byte) (err error)
|
||||
|
||||
const ImplementsGetwd = true |
||||
|
||||
func Getwd() (ret string, err error) { |
||||
for len := uint64(4096); ; len *= 2 { |
||||
b := make([]byte, len) |
||||
err := getcwd(b) |
||||
if err == nil { |
||||
i := 0 |
||||
for b[i] != 0 { |
||||
i++ |
||||
} |
||||
return string(b[0:i]), nil |
||||
} |
||||
if err != ERANGE { |
||||
return "", err |
||||
} |
||||
} |
||||
} |
||||
|
||||
func Getcwd(buf []byte) (n int, err error) { |
||||
err = getcwd(buf) |
||||
if err == nil { |
||||
i := 0 |
||||
for buf[i] != 0 { |
||||
i++ |
||||
} |
||||
n = i + 1 |
||||
} |
||||
return |
||||
} |
||||
|
||||
func Getgroups() (gids []int, err error) { |
||||
n, err := getgroups(0, nil) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
if n == 0 { |
||||
return nil, nil |
||||
} |
||||
|
||||
// Sanity check group count. Max is 16 on BSD.
|
||||
if n < 0 || n > 1000 { |
||||
return nil, EINVAL |
||||
} |
||||
|
||||
a := make([]_Gid_t, n) |
||||
n, err = getgroups(n, &a[0]) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
gids = make([]int, n) |
||||
for i, v := range a[0:n] { |
||||
gids[i] = int(v) |
||||
} |
||||
return |
||||
} |
||||
|
||||
func Setgroups(gids []int) (err error) { |
||||
if len(gids) == 0 { |
||||
return setgroups(0, nil) |
||||
} |
||||
|
||||
a := make([]_Gid_t, len(gids)) |
||||
for i, v := range gids { |
||||
a[i] = _Gid_t(v) |
||||
} |
||||
return setgroups(len(a), &a[0]) |
||||
} |
||||
|
||||
/* |
||||
* Socket |
||||
*/ |
||||
|
||||
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||
|
||||
func Accept(fd int) (nfd int, sa Sockaddr, err error) { |
||||
var rsa RawSockaddrAny |
||||
var len _Socklen = SizeofSockaddrAny |
||||
nfd, err = accept(fd, &rsa, &len) |
||||
if nfd == -1 { |
||||
return |
||||
} |
||||
sa, err = anyToSockaddr(fd, &rsa) |
||||
if err != nil { |
||||
Close(nfd) |
||||
nfd = 0 |
||||
} |
||||
return |
||||
} |
||||
|
||||
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { |
||||
// Recvmsg not implemented on AIX
|
||||
sa := new(SockaddrUnix) |
||||
return -1, -1, -1, sa, ENOSYS |
||||
} |
||||
|
||||
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { |
||||
_, err = SendmsgN(fd, p, oob, to, flags) |
||||
return |
||||
} |
||||
|
||||
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { |
||||
// SendmsgN not implemented on AIX
|
||||
return -1, ENOSYS |
||||
} |
||||
|
||||
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { |
||||
switch rsa.Addr.Family { |
||||
|
||||
case AF_UNIX: |
||||
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) |
||||
sa := new(SockaddrUnix) |
||||
|
||||
// Some versions of AIX have a bug in getsockname (see IV78655).
|
||||
// We can't rely on sa.Len being set correctly.
|
||||
n := SizeofSockaddrUnix - 3 // substract leading Family, Len, terminating NUL.
|
||||
for i := 0; i < n; i++ { |
||||
if pp.Path[i] == 0 { |
||||
n = i |
||||
break |
||||
} |
||||
} |
||||
|
||||
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] |
||||
sa.Name = string(bytes) |
||||
return sa, nil |
||||
|
||||
case AF_INET: |
||||
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) |
||||
sa := new(SockaddrInet4) |
||||
p := (*[2]byte)(unsafe.Pointer(&pp.Port)) |
||||
sa.Port = int(p[0])<<8 + int(p[1]) |
||||
for i := 0; i < len(sa.Addr); i++ { |
||||
sa.Addr[i] = pp.Addr[i] |
||||
} |
||||
return sa, nil |
||||
|
||||
case AF_INET6: |
||||
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) |
||||
sa := new(SockaddrInet6) |
||||
p := (*[2]byte)(unsafe.Pointer(&pp.Port)) |
||||
sa.Port = int(p[0])<<8 + int(p[1]) |
||||
sa.ZoneId = pp.Scope_id |
||||
for i := 0; i < len(sa.Addr); i++ { |
||||
sa.Addr[i] = pp.Addr[i] |
||||
} |
||||
return sa, nil |
||||
} |
||||
return nil, EAFNOSUPPORT |
||||
} |
||||
|
||||
func Gettimeofday(tv *Timeval) (err error) { |
||||
err = gettimeofday(tv, nil) |
||||
return |
||||
} |
||||
|
||||
// TODO
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { |
||||
return -1, ENOSYS |
||||
} |
||||
|
||||
//sys getdirent(fd int, buf []byte) (n int, err error)
|
||||
func ReadDirent(fd int, buf []byte) (n int, err error) { |
||||
return getdirent(fd, buf) |
||||
} |
||||
|
||||
//sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
|
||||
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { |
||||
var status _C_int |
||||
var r Pid_t |
||||
err = ERESTART |
||||
// AIX wait4 may return with ERESTART errno, while the processus is still
|
||||
// active.
|
||||
for err == ERESTART { |
||||
r, err = wait4(Pid_t(pid), &status, options, rusage) |
||||
} |
||||
wpid = int(r) |
||||
if wstatus != nil { |
||||
*wstatus = WaitStatus(status) |
||||
} |
||||
return |
||||
} |
||||
|
||||
/* |
||||
* Wait |
||||
*/ |
||||
|
||||
type WaitStatus uint32 |
||||
|
||||
func (w WaitStatus) Stopped() bool { return w&0x40 != 0 } |
||||
func (w WaitStatus) StopSignal() Signal { |
||||
if !w.Stopped() { |
||||
return -1 |
||||
} |
||||
return Signal(w>>8) & 0xFF |
||||
} |
||||
|
||||
func (w WaitStatus) Exited() bool { return w&0xFF == 0 } |
||||
func (w WaitStatus) ExitStatus() int { |
||||
if !w.Exited() { |
||||
return -1 |
||||
} |
||||
return int((w >> 8) & 0xFF) |
||||
} |
||||
|
||||
func (w WaitStatus) Signaled() bool { return w&0x40 == 0 && w&0xFF != 0 } |
||||
func (w WaitStatus) Signal() Signal { |
||||
if !w.Signaled() { |
||||
return -1 |
||||
} |
||||
return Signal(w>>16) & 0xFF |
||||
} |
||||
|
||||
func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 } |
||||
|
||||
func (w WaitStatus) CoreDump() bool { return w&0x200 != 0 } |
||||
|
||||
func (w WaitStatus) TrapCause() int { return -1 } |
||||
|
||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||
|
||||
// ioctl itself should not be exposed directly, but additional get/set
|
||||
// functions for specific types are permissible.
|
||||
|
||||
// IoctlSetInt performs an ioctl operation which sets an integer value
|
||||
// on fd, using the specified request number.
|
||||
func IoctlSetInt(fd int, req uint, value int) error { |
||||
return ioctl(fd, req, uintptr(value)) |
||||
} |
||||
|
||||
func ioctlSetWinsize(fd int, req uint, value *Winsize) error { |
||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value))) |
||||
} |
||||
|
||||
func ioctlSetTermios(fd int, req uint, value *Termios) error { |
||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value))) |
||||
} |
||||
|
||||
// IoctlGetInt performs an ioctl operation which gets an integer value
|
||||
// from fd, using the specified request number.
|
||||
func IoctlGetInt(fd int, req uint) (int, error) { |
||||
var value int |
||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
||||
return value, err |
||||
} |
||||
|
||||
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { |
||||
var value Winsize |
||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
||||
return &value, err |
||||
} |
||||
|
||||
func IoctlGetTermios(fd int, req uint) (*Termios, error) { |
||||
var value Termios |
||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
||||
return &value, err |
||||
} |
||||
|
||||
// fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
|
||||
// There is no way to create a custom fcntl and to keep //sys fcntl easily,
|
||||
// Therefore, the programmer must call dup2 instead of fcntl in this case.
|
||||
|
||||
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||
//sys FcntlInt(fd uintptr, cmd int, arg int) (r int,err error) = fcntl
|
||||
|
||||
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||
//sys FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) = fcntl
|
||||
|
||||
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||
|
||||
func Flock(fd int, how int) (err error) { |
||||
return syscall.Flock(fd, how) |
||||
} |
||||
|
||||
/* |
||||
* Direct access |
||||
*/ |
||||
|
||||
//sys Acct(path string) (err error)
|
||||
//sys Chdir(path string) (err error)
|
||||
//sys Chroot(path string) (err error)
|
||||
//sys Close(fd int) (err error)
|
||||
//sys Dup(oldfd int) (fd int, err error)
|
||||
//sys Exit(code int)
|
||||
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||
//sys Fchdir(fd int) (err error)
|
||||
//sys Fchmod(fd int, mode uint32) (err error)
|
||||
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
||||
//sys Fdatasync(fd int) (err error)
|
||||
//sys Fsync(fd int) (err error)
|
||||
// readdir_r
|
||||
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||
|
||||
//sys Getpgrp() (pid int)
|
||||
|
||||
//sysnb Getpid() (pid int)
|
||||
//sysnb Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (prio int, err error)
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Getsid(pid int) (sid int, err error)
|
||||
//sysnb Kill(pid int, sig Signal) (err error)
|
||||
//sys Klogctl(typ int, buf []byte) (n int, err error) = syslog
|
||||
//sys Mkdir(dirfd int, path string, mode uint32) (err error)
|
||||
//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
|
||||
//sys Mkfifo(path string, mode uint32) (err error)
|
||||
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||
//sys Open(path string, mode int, perm uint32) (fd int, err error) = open64
|
||||
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
||||
//sys read(fd int, p []byte) (n int, err error)
|
||||
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
||||
//sys Setdomainname(p []byte) (err error)
|
||||
//sys Sethostname(p []byte) (err error)
|
||||
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||
//sysnb Setsid() (pid int, err error)
|
||||
//sysnb Settimeofday(tv *Timeval) (err error)
|
||||
|
||||
//sys Setuid(uid int) (err error)
|
||||
//sys Setgid(uid int) (err error)
|
||||
|
||||
//sys Setpriority(which int, who int, prio int) (err error)
|
||||
//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error)
|
||||
//sys Sync()
|
||||
//sysnb Times(tms *Tms) (ticks uintptr, err error)
|
||||
//sysnb Umask(mask int) (oldmask int)
|
||||
//sysnb Uname(buf *Utsname) (err error)
|
||||
//TODO umount
|
||||
// //sys Unmount(target string, flags int) (err error) = umount
|
||||
//sys Unlink(path string) (err error)
|
||||
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
||||
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||
//sys write(fd int, p []byte) (n int, err error)
|
||||
//sys readlen(fd int, p *byte, np int) (n int, err error) = read
|
||||
//sys writelen(fd int, p *byte, np int) (n int, err error) = write
|
||||
|
||||
//sys Dup2(oldfd int, newfd int) (err error)
|
||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = fstatat
|
||||
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error)
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (euid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Listen(s int, n int) (err error)
|
||||
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||
//sys Pause() (err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = pread64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64
|
||||
//TODO Select
|
||||
// //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
|
||||
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sys Shutdown(fd int, how int) (err error)
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
|
||||
//sys Stat(path string, stat *Stat_t) (err error)
|
||||
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||
//sys Truncate(path string, length int64) (err error)
|
||||
|
||||
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
|
||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||
|
||||
var mapper = &mmapper{ |
||||
active: make(map[*byte][]byte), |
||||
mmap: mmap, |
||||
munmap: munmap, |
||||
} |
||||
|
||||
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { |
||||
return mapper.Mmap(fd, offset, length, prot, flags) |
||||
} |
||||
|
||||
func Munmap(b []byte) (err error) { |
||||
return mapper.Munmap(b) |
||||
} |
||||
|
||||
//sys Madvise(b []byte, advice int) (err error)
|
||||
//sys Mprotect(b []byte, prot int) (err error)
|
||||
//sys Mlock(b []byte) (err error)
|
||||
//sys Mlockall(flags int) (err error)
|
||||
//sys Msync(b []byte, flags int) (err error)
|
||||
//sys Munlock(b []byte) (err error)
|
||||
//sys Munlockall() (err error)
|
||||
|
||||
//sysnb pipe(p *[2]_C_int) (err error)
|
||||
|
||||
func Pipe(p []int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
var pp [2]_C_int |
||||
err = pipe(&pp) |
||||
p[0] = int(pp[0]) |
||||
p[1] = int(pp[1]) |
||||
return |
||||
} |
||||
|
||||
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||
|
||||
func Poll(fds []PollFd, timeout int) (n int, err error) { |
||||
if len(fds) == 0 { |
||||
return poll(nil, 0, timeout) |
||||
} |
||||
return poll(&fds[0], len(fds), timeout) |
||||
} |
||||
|
||||
//sys gettimeofday(tv *Timeval, tzp *Timezone) (err error)
|
||||
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||
//sys Utime(path string, buf *Utimbuf) (err error)
|
@ -0,0 +1,34 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix
|
||||
// +build ppc
|
||||
|
||||
package unix |
||||
|
||||
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64
|
||||
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64
|
||||
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64
|
||||
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||
|
||||
func setTimespec(sec, nsec int64) Timespec { |
||||
return Timespec{Sec: int32(sec), Nsec: int32(nsec)} |
||||
} |
||||
|
||||
func setTimeval(sec, usec int64) Timeval { |
||||
return Timeval{Sec: int32(sec), Usec: int32(usec)} |
||||
} |
||||
|
||||
func (iov *Iovec) SetLen(length int) { |
||||
iov.Len = uint32(length) |
||||
} |
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) { |
||||
msghdr.Controllen = uint32(length) |
||||
} |
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) { |
||||
cmsg.Len = uint32(length) |
||||
} |
@ -0,0 +1,34 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build aix
|
||||
// +build ppc64
|
||||
|
||||
package unix |
||||
|
||||
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
|
||||
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
|
||||
|
||||
func setTimespec(sec, nsec int64) Timespec { |
||||
return Timespec{Sec: sec, Nsec: nsec} |
||||
} |
||||
|
||||
func setTimeval(sec, usec int64) Timeval { |
||||
return Timeval{Sec: int64(sec), Usec: int32(usec)} |
||||
} |
||||
|
||||
func (iov *Iovec) SetLen(length int) { |
||||
iov.Len = uint64(length) |
||||
} |
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) { |
||||
msghdr.Controllen = uint32(length) |
||||
} |
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) { |
||||
cmsg.Len = uint32(length) |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@ |
||||
// 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 amd64,linux
|
||||
// +build !gccgo
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
//go:noescape
|
||||
func gettimeofday(tv *Timeval) (err syscall.Errno) |
@ -0,0 +1,14 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux,!gccgo
|
||||
|
||||
package unix |
||||
|
||||
// SyscallNoError may be used instead of Syscall for syscalls that don't fail.
|
||||
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) |
||||
|
||||
// RawSyscallNoError may be used instead of RawSyscall for syscalls that don't
|
||||
// fail.
|
||||
func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) |
@ -0,0 +1,16 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux,!gccgo,386
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
// Underlying system call writes to newoffset via pointer.
|
||||
// Implemented in assembly to avoid allocation.
|
||||
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) |
||||
|
||||
func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) |
||||
func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) |
@ -0,0 +1,30 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux,gccgo,386
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { |
||||
var newoffset int64 |
||||
offsetLow := uint32(offset & 0xffffffff) |
||||
offsetHigh := uint32((offset >> 32) & 0xffffffff) |
||||
_, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) |
||||
return newoffset, err |
||||
} |
||||
|
||||
func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { |
||||
fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) |
||||
return int(fd), err |
||||
} |
||||
|
||||
func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { |
||||
fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) |
||||
return int(fd), err |
||||
} |
@ -0,0 +1,20 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux,gccgo,arm
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { |
||||
var newoffset int64 |
||||
offsetLow := uint32(offset & 0xffffffff) |
||||
offsetHigh := uint32((offset >> 32) & 0xffffffff) |
||||
_, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) |
||||
return newoffset, err |
||||
} |
@ -0,0 +1,233 @@ |
||||
// 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 linux
|
||||
// +build mips mipsle
|
||||
|
||||
package unix |
||||
|
||||
import ( |
||||
"syscall" |
||||
"unsafe" |
||||
) |
||||
|
||||
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) |
||||
|
||||
//sys Dup2(oldfd int, newfd int) (err error)
|
||||
//sysnb EpollCreate(size int) (fd int, err error)
|
||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (euid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Listen(s int, n int) (err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
|
||||
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
|
||||
//sys Setfsgid(gid int) (err error)
|
||||
//sys Setfsuid(uid int) (err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sys Shutdown(fd int, how int) (err error)
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
|
||||
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
|
||||
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
|
||||
//sysnb InotifyInit() (fd int, err error)
|
||||
//sys Ioperm(from int, num int, on int) (err error)
|
||||
//sys Iopl(level int) (err error)
|
||||
|
||||
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||
|
||||
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
|
||||
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||
|
||||
//sys Pause() (err error)
|
||||
|
||||
func Fstatfs(fd int, buf *Statfs_t) (err error) { |
||||
_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) |
||||
if e != 0 { |
||||
err = errnoErr(e) |
||||
} |
||||
return |
||||
} |
||||
|
||||
func Statfs(path string, buf *Statfs_t) (err error) { |
||||
p, err := BytePtrFromString(path) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(p)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) |
||||
if e != 0 { |
||||
err = errnoErr(e) |
||||
} |
||||
return |
||||
} |
||||
|
||||
func Seek(fd int, offset int64, whence int) (off int64, err error) { |
||||
_, _, e := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offset>>32), uintptr(offset), uintptr(unsafe.Pointer(&off)), uintptr(whence), 0) |
||||
if e != 0 { |
||||
err = errnoErr(e) |
||||
} |
||||
return |
||||
} |
||||
|
||||
func setTimespec(sec, nsec int64) Timespec { |
||||
return Timespec{Sec: int32(sec), Nsec: int32(nsec)} |
||||
} |
||||
|
||||
func setTimeval(sec, usec int64) Timeval { |
||||
return Timeval{Sec: int32(sec), Usec: int32(usec)} |
||||
} |
||||
|
||||
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
var pp [2]_C_int |
||||
err = pipe2(&pp, flags) |
||||
p[0] = int(pp[0]) |
||||
p[1] = int(pp[1]) |
||||
return |
||||
} |
||||
|
||||
//sysnb pipe() (p1 int, p2 int, err error)
|
||||
|
||||
func Pipe(p []int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
p[0], p[1], err = pipe() |
||||
return |
||||
} |
||||
|
||||
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
|
||||
|
||||
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { |
||||
page := uintptr(offset / 4096) |
||||
if offset != int64(page)*4096 { |
||||
return 0, EINVAL |
||||
} |
||||
return mmap2(addr, length, prot, flags, fd, page) |
||||
} |
||||
|
||||
const rlimInf32 = ^uint32(0) |
||||
const rlimInf64 = ^uint64(0) |
||||
|
||||
type rlimit32 struct { |
||||
Cur uint32 |
||||
Max uint32 |
||||
} |
||||
|
||||
//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
|
||||
|
||||
func Getrlimit(resource int, rlim *Rlimit) (err error) { |
||||
err = prlimit(0, resource, nil, rlim) |
||||
if err != ENOSYS { |
||||
return err |
||||
} |
||||
|
||||
rl := rlimit32{} |
||||
err = getrlimit(resource, &rl) |
||||
if err != nil { |
||||
return |
||||
} |
||||
|
||||
if rl.Cur == rlimInf32 { |
||||
rlim.Cur = rlimInf64 |
||||
} else { |
||||
rlim.Cur = uint64(rl.Cur) |
||||
} |
||||
|
||||
if rl.Max == rlimInf32 { |
||||
rlim.Max = rlimInf64 |
||||
} else { |
||||
rlim.Max = uint64(rl.Max) |
||||
} |
||||
return |
||||
} |
||||
|
||||
//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
|
||||
|
||||
func Setrlimit(resource int, rlim *Rlimit) (err error) { |
||||
err = prlimit(0, resource, rlim, nil) |
||||
if err != ENOSYS { |
||||
return err |
||||
} |
||||
|
||||
rl := rlimit32{} |
||||
if rlim.Cur == rlimInf64 { |
||||
rl.Cur = rlimInf32 |
||||
} else if rlim.Cur < uint64(rlimInf32) { |
||||
rl.Cur = uint32(rlim.Cur) |
||||
} else { |
||||
return EINVAL |
||||
} |
||||
if rlim.Max == rlimInf64 { |
||||
rl.Max = rlimInf32 |
||||
} else if rlim.Max < uint64(rlimInf32) { |
||||
rl.Max = uint32(rlim.Max) |
||||
} else { |
||||
return EINVAL |
||||
} |
||||
|
||||
return setrlimit(resource, &rl) |
||||
} |
||||
|
||||
func (r *PtraceRegs) PC() uint64 { return r.Epc } |
||||
|
||||
func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc } |
||||
|
||||
func (iov *Iovec) SetLen(length int) { |
||||
iov.Len = uint32(length) |
||||
} |
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) { |
||||
msghdr.Controllen = uint32(length) |
||||
} |
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) { |
||||
cmsg.Len = uint32(length) |
||||
} |
||||
|
||||
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||
|
||||
func Poll(fds []PollFd, timeout int) (n int, err error) { |
||||
if len(fds) == 0 { |
||||
return poll(nil, 0, timeout) |
||||
} |
||||
return poll(&fds[0], len(fds), timeout) |
||||
} |
@ -0,0 +1,209 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build riscv64,linux
|
||||
|
||||
package unix |
||||
|
||||
import "unsafe" |
||||
|
||||
func EpollCreate(size int) (fd int, err error) { |
||||
if size <= 0 { |
||||
return -1, EINVAL |
||||
} |
||||
return EpollCreate1(0) |
||||
} |
||||
|
||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
|
||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
||||
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error)
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (euid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Listen(s int, n int) (err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
|
||||
|
||||
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { |
||||
var ts *Timespec |
||||
if timeout != nil { |
||||
ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} |
||||
} |
||||
return Pselect(nfd, r, w, e, ts, nil) |
||||
} |
||||
|
||||
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
|
||||
//sys Setfsgid(gid int) (err error)
|
||||
//sys Setfsuid(uid int) (err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sys Shutdown(fd int, how int) (err error)
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
|
||||
|
||||
func Stat(path string, stat *Stat_t) (err error) { |
||||
return Fstatat(AT_FDCWD, path, stat, 0) |
||||
} |
||||
|
||||
func Lchown(path string, uid int, gid int) (err error) { |
||||
return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) |
||||
} |
||||
|
||||
func Lstat(path string, stat *Stat_t) (err error) { |
||||
return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) |
||||
} |
||||
|
||||
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||
//sys Truncate(path string, length int64) (err error)
|
||||
|
||||
func Ustat(dev int, ubuf *Ustat_t) (err error) { |
||||
return ENOSYS |
||||
} |
||||
|
||||
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
|
||||
func setTimespec(sec, nsec int64) Timespec { |
||||
return Timespec{Sec: sec, Nsec: nsec} |
||||
} |
||||
|
||||
func setTimeval(sec, usec int64) Timeval { |
||||
return Timeval{Sec: sec, Usec: usec} |
||||
} |
||||
|
||||
func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) { |
||||
if tv == nil { |
||||
return utimensat(dirfd, path, nil, 0) |
||||
} |
||||
|
||||
ts := []Timespec{ |
||||
NsecToTimespec(TimevalToNsec(tv[0])), |
||||
NsecToTimespec(TimevalToNsec(tv[1])), |
||||
} |
||||
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) |
||||
} |
||||
|
||||
func Time(t *Time_t) (Time_t, error) { |
||||
var tv Timeval |
||||
err := Gettimeofday(&tv) |
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
if t != nil { |
||||
*t = Time_t(tv.Sec) |
||||
} |
||||
return Time_t(tv.Sec), nil |
||||
} |
||||
|
||||
func Utime(path string, buf *Utimbuf) error { |
||||
tv := []Timeval{ |
||||
{Sec: buf.Actime}, |
||||
{Sec: buf.Modtime}, |
||||
} |
||||
return Utimes(path, tv) |
||||
} |
||||
|
||||
func utimes(path string, tv *[2]Timeval) (err error) { |
||||
if tv == nil { |
||||
return utimensat(AT_FDCWD, path, nil, 0) |
||||
} |
||||
|
||||
ts := []Timespec{ |
||||
NsecToTimespec(TimevalToNsec(tv[0])), |
||||
NsecToTimespec(TimevalToNsec(tv[1])), |
||||
} |
||||
return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) |
||||
} |
||||
|
||||
func Pipe(p []int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
var pp [2]_C_int |
||||
err = pipe2(&pp, 0) |
||||
p[0] = int(pp[0]) |
||||
p[1] = int(pp[1]) |
||||
return |
||||
} |
||||
|
||||
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
var pp [2]_C_int |
||||
err = pipe2(&pp, flags) |
||||
p[0] = int(pp[0]) |
||||
p[1] = int(pp[1]) |
||||
return |
||||
} |
||||
|
||||
func (r *PtraceRegs) PC() uint64 { return r.Pc } |
||||
|
||||
func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } |
||||
|
||||
func (iov *Iovec) SetLen(length int) { |
||||
iov.Len = uint64(length) |
||||
} |
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) { |
||||
msghdr.Controllen = uint64(length) |
||||
} |
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) { |
||||
cmsg.Len = uint64(length) |
||||
} |
||||
|
||||
func InotifyInit() (fd int, err error) { |
||||
return InotifyInit1(0) |
||||
} |
||||
|
||||
func Dup2(oldfd int, newfd int) (err error) { |
||||
return Dup3(oldfd, newfd, 0) |
||||
} |
||||
|
||||
func Pause() error { |
||||
_, err := ppoll(nil, 0, nil, nil) |
||||
return err |
||||
} |
||||
|
||||
func Poll(fds []PollFd, timeout int) (n int, err error) { |
||||
var ts *Timespec |
||||
if timeout >= 0 { |
||||
ts = new(Timespec) |
||||
*ts = NsecToTimespec(int64(timeout) * 1e6) |
||||
} |
||||
if len(fds) == 0 { |
||||
return ppoll(nil, 0, ts, nil) |
||||
} |
||||
return ppoll(&fds[0], len(fds), ts, nil) |
||||
} |
@ -0,0 +1,146 @@ |
||||
// 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 sparc64,linux
|
||||
|
||||
package unix |
||||
|
||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
|
||||
//sys Dup2(oldfd int, newfd int) (err error)
|
||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
|
||||
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||
//sys Ftruncate(fd int, length int64) (err error)
|
||||
//sysnb Getegid() (egid int)
|
||||
//sysnb Geteuid() (euid int)
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sysnb InotifyInit() (fd int, err error)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
//sys Listen(s int, n int) (err error)
|
||||
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||
//sys Pause() (err error)
|
||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
|
||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
|
||||
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
|
||||
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
|
||||
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
|
||||
//sys Setfsgid(gid int) (err error)
|
||||
//sys Setfsuid(uid int) (err error)
|
||||
//sysnb Setregid(rgid int, egid int) (err error)
|
||||
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
||||
//sysnb Setresuid(ruid int, euid int, suid int) (err error)
|
||||
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||
//sys Shutdown(fd int, how int) (err error)
|
||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
|
||||
//sys Stat(path string, stat *Stat_t) (err error)
|
||||
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
||||
//sys Truncate(path string, length int64) (err error)
|
||||
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
|
||||
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||
|
||||
func Ioperm(from int, num int, on int) (err error) { |
||||
return ENOSYS |
||||
} |
||||
|
||||
func Iopl(level int) (err error) { |
||||
return ENOSYS |
||||
} |
||||
|
||||
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
|
||||
func Time(t *Time_t) (tt Time_t, err error) { |
||||
var tv Timeval |
||||
err = Gettimeofday(&tv) |
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
if t != nil { |
||||
*t = Time_t(tv.Sec) |
||||
} |
||||
return Time_t(tv.Sec), nil |
||||
} |
||||
|
||||
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||
|
||||
func setTimespec(sec, nsec int64) Timespec { |
||||
return Timespec{Sec: sec, Nsec: nsec} |
||||
} |
||||
|
||||
func setTimeval(sec, usec int64) Timeval { |
||||
return Timeval{Sec: sec, Usec: int32(usec)} |
||||
} |
||||
|
||||
func (r *PtraceRegs) PC() uint64 { return r.Tpc } |
||||
|
||||
func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } |
||||
|
||||
func (iov *Iovec) SetLen(length int) { |
||||
iov.Len = uint64(length) |
||||
} |
||||
|
||||
func (msghdr *Msghdr) SetControllen(length int) { |
||||
msghdr.Controllen = uint64(length) |
||||
} |
||||
|
||||
func (cmsg *Cmsghdr) SetLen(length int) { |
||||
cmsg.Len = uint64(length) |
||||
} |
||||
|
||||
//sysnb pipe(p *[2]_C_int) (err error)
|
||||
|
||||
func Pipe(p []int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
var pp [2]_C_int |
||||
err = pipe(&pp) |
||||
p[0] = int(pp[0]) |
||||
p[1] = int(pp[1]) |
||||
return |
||||
} |
||||
|
||||
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) { |
||||
if len(p) != 2 { |
||||
return EINVAL |
||||
} |
||||
var pp [2]_C_int |
||||
err = pipe2(&pp, flags) |
||||
p[0] = int(pp[0]) |
||||
p[1] = int(pp[1]) |
||||
return |
||||
} |
||||
|
||||
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||
|
||||
func Poll(fds []PollFd, timeout int) (n int, err error) { |
||||
if len(fds) == 0 { |
||||
return poll(nil, 0, timeout) |
||||
} |
||||
return poll(&fds[0], len(fds), timeout) |
||||
} |
@ -1,11 +0,0 @@ |
||||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build dragonfly freebsd netbsd openbsd
|
||||
|
||||
package unix |
||||
|
||||
const ImplementsGetwd = false |
||||
|
||||
func Getwd() (string, error) { return "", ENOTSUP } |
@ -0,0 +1,37 @@ |
||||
// 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) |
||||
} |
||||
|
||||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||
// of openbsd/arm the syscall is called sysctl instead of __sysctl.
|
||||
const SYS___SYSCTL = SYS_SYSCTL |
@ -0,0 +1,15 @@ |
||||
// 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 darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build !gccgo
|
||||
|
||||
package unix |
||||
|
||||
import "syscall" |
||||
|
||||
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) |
||||
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) |
||||
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) |
||||
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) |
@ -0,0 +1,82 @@ |
||||
// 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package unix |
||||
|
||||
import "time" |
||||
|
||||
// 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) |
||||
} |
||||
|
||||
// TimeToTimespec converts t into a Timespec.
|
||||
// On some 32-bit systems the range of valid Timespec values are smaller
|
||||
// than that of time.Time values. So if t is out of the valid range of
|
||||
// Timespec, it returns a zero Timespec and ERANGE.
|
||||
func TimeToTimespec(t time.Time) (Timespec, error) { |
||||
sec := t.Unix() |
||||
nsec := int64(t.Nanosecond()) |
||||
ts := setTimespec(sec, nsec) |
||||
|
||||
// Currently all targets have either int32 or int64 for Timespec.Sec.
|
||||
// If there were a new target with floating point type for it, we have
|
||||
// to consider the rounding error.
|
||||
if int64(ts.Sec) != sec { |
||||
return Timespec{}, ERANGE |
||||
} |
||||
return ts, nil |
||||
} |
||||
|
||||
// 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 |
||||
} |
@ -0,0 +1,236 @@ |
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
// +build aix
|
||||
|
||||
/* |
||||
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
||||
*/ |
||||
|
||||
// +godefs map struct_in_addr [4]byte /* in_addr */
|
||||
// +godefs map struct_in6_addr [16]byte /* in6_addr */
|
||||
|
||||
package unix |
||||
|
||||
/* |
||||
#include <sys/types.h> |
||||
#include <sys/time.h> |
||||
#include <sys/limits.h> |
||||
#include <sys/un.h> |
||||
#include <utime.h> |
||||
#include <sys/utsname.h> |
||||
#include <sys/poll.h> |
||||
#include <sys/resource.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/statfs.h> |
||||
#include <sys/termio.h> |
||||
#include <sys/ioctl.h> |
||||
|
||||
#include <termios.h> |
||||
|
||||
#include <net/if.h> |
||||
#include <net/if_dl.h> |
||||
#include <netinet/in.h> |
||||
#include <netinet/icmp6.h> |
||||
|
||||
|
||||
#include <dirent.h> |
||||
#include <fcntl.h> |
||||
|
||||
enum { |
||||
sizeofPtr = sizeof(void*), |
||||
}; |
||||
|
||||
union sockaddr_all { |
||||
struct sockaddr s1; // this one gets used for fields
|
||||
struct sockaddr_in s2; // these pad it out
|
||||
struct sockaddr_in6 s3; |
||||
struct sockaddr_un s4; |
||||
struct sockaddr_dl s5; |
||||
}; |
||||
|
||||
struct sockaddr_any { |
||||
struct sockaddr addr; |
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
||||
}; |
||||
|
||||
*/ |
||||
import "C" |
||||
|
||||
// Machine characteristics
|
||||
|
||||
const ( |
||||
SizeofPtr = C.sizeofPtr |
||||
SizeofShort = C.sizeof_short |
||||
SizeofInt = C.sizeof_int |
||||
SizeofLong = C.sizeof_long |
||||
SizeofLongLong = C.sizeof_longlong |
||||
PathMax = C.PATH_MAX |
||||
) |
||||
|
||||
// Basic types
|
||||
|
||||
type ( |
||||
_C_short C.short |
||||
_C_int C.int |
||||
_C_long C.long |
||||
_C_long_long C.longlong |
||||
) |
||||
|
||||
type off64 C.off64_t |
||||
type off C.off_t |
||||
type Mode_t C.mode_t |
||||
|
||||
// Time
|
||||
|
||||
type Timespec C.struct_timespec |
||||
|
||||
type StTimespec C.struct_st_timespec |
||||
|
||||
type Timeval C.struct_timeval |
||||
|
||||
type Timeval32 C.struct_timeval32 |
||||
|
||||
type Timex C.struct_timex |
||||
|
||||
type Time_t C.time_t |
||||
|
||||
type Tms C.struct_tms |
||||
|
||||
type Utimbuf C.struct_utimbuf |
||||
|
||||
type Timezone C.struct_timezone |
||||
|
||||
// Processes
|
||||
|
||||
type Rusage C.struct_rusage |
||||
|
||||
type Rlimit C.struct_rlimit64 |
||||
|
||||
type Pid_t C.pid_t |
||||
|
||||
type _Gid_t C.gid_t |
||||
|
||||
type dev_t C.dev_t |
||||
|
||||
// Files
|
||||
|
||||
type Stat_t C.struct_stat |
||||
|
||||
type StatxTimestamp C.struct_statx_timestamp |
||||
|
||||
type Statx_t C.struct_statx |
||||
|
||||
type Dirent C.struct_dirent |
||||
|
||||
// Sockets
|
||||
|
||||
type RawSockaddrInet4 C.struct_sockaddr_in |
||||
|
||||
type RawSockaddrInet6 C.struct_sockaddr_in6 |
||||
|
||||
type RawSockaddrUnix C.struct_sockaddr_un |
||||
|
||||
type RawSockaddr C.struct_sockaddr |
||||
|
||||
type RawSockaddrAny C.struct_sockaddr_any |
||||
|
||||
type _Socklen C.socklen_t |
||||
|
||||
type Cmsghdr C.struct_cmsghdr |
||||
|
||||
type ICMPv6Filter C.struct_icmp6_filter |
||||
|
||||
type Iovec C.struct_iovec |
||||
|
||||
type IPMreq C.struct_ip_mreq |
||||
|
||||
type IPv6Mreq C.struct_ipv6_mreq |
||||
|
||||
type IPv6MTUInfo C.struct_ip6_mtuinfo |
||||
|
||||
type Linger C.struct_linger |
||||
|
||||
type Msghdr C.struct_msghdr |
||||
|
||||
const ( |
||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
||||
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
||||
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
||||
SizeofLinger = C.sizeof_struct_linger |
||||
SizeofIPMreq = C.sizeof_struct_ip_mreq |
||||
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
||||
SizeofMsghdr = C.sizeof_struct_msghdr |
||||
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
||||
) |
||||
|
||||
// Routing and interface messages
|
||||
|
||||
const ( |
||||
SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
||||
) |
||||
|
||||
type IfMsgHdr C.struct_if_msghdr |
||||
|
||||
// Misc
|
||||
|
||||
type FdSet C.fd_set |
||||
|
||||
type Utsname C.struct_utsname |
||||
|
||||
type Ustat_t C.struct_ustat |
||||
|
||||
type Sigset_t C.sigset_t |
||||
|
||||
const ( |
||||
AT_FDCWD = C.AT_FDCWD |
||||
AT_REMOVEDIR = C.AT_REMOVEDIR |
||||
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW |
||||
) |
||||
|
||||
// Terminal handling
|
||||
|
||||
type Termios C.struct_termios |
||||
|
||||
type Termio C.struct_termio |
||||
|
||||
type Winsize C.struct_winsize |
||||
|
||||
//poll
|
||||
|
||||
type PollFd struct { |
||||
Fd int32 |
||||
Events uint16 |
||||
Revents uint16 |
||||
} |
||||
|
||||
const ( |
||||
POLLERR = C.POLLERR |
||||
POLLHUP = C.POLLHUP |
||||
POLLIN = C.POLLIN |
||||
POLLNVAL = C.POLLNVAL |
||||
POLLOUT = C.POLLOUT |
||||
POLLPRI = C.POLLPRI |
||||
POLLRDBAND = C.POLLRDBAND |
||||
POLLRDNORM = C.POLLRDNORM |
||||
POLLWRBAND = C.POLLWRBAND |
||||
POLLWRNORM = C.POLLWRNORM |
||||
) |
||||
|
||||
//flock_t
|
||||
|
||||
type Flock_t C.struct_flock64 |
||||
|
||||
// Statfs
|
||||
|
||||
type Fsid_t C.struct_fsid_t |
||||
type Fsid64_t C.struct_fsid64_t |
||||
|
||||
type Statfs_t C.struct_statfs |
||||
|
||||
const RNDGETENTCNT = 0x80045200 |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue