Update golang.org/x/sys

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-07-12 15:14:35 -07:00
parent cb4bf2003f
commit 0c0c271b54
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB
202 changed files with 30205 additions and 8240 deletions

View File

@ -27,7 +27,7 @@ golang.org/x/net b3756b4b77d7b13260a0a2ec658753cf48922eac
google.golang.org/grpc v1.12.0 google.golang.org/grpc v1.12.0
github.com/pkg/errors v0.8.0 github.com/pkg/errors v0.8.0
github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7 github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7
golang.org/x/sys 314a259e304ff91bd6985da2a7149bbf91237993 https://github.com/golang/sys golang.org/x/sys 1b2967e3c290b7c545b3db0deeda16e9be4f98a2 https://github.com/golang/sys
github.com/opencontainers/image-spec v1.0.1 github.com/opencontainers/image-spec v1.0.1
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895

38
vendor/golang.org/x/sys/cpu/cpu.go generated vendored Normal file
View File

@ -0,0 +1,38 @@
// 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.
// Package cpu implements processor feature detection for
// various CPU architectures.
package cpu
// CacheLinePad is used to pad structs to avoid false sharing.
type CacheLinePad struct{ _ [cacheLineSize]byte }
// X86 contains the supported CPU features of the
// current X86/AMD64 platform. If the current platform
// is not X86/AMD64 then all feature flags are false.
//
// X86 is padded to avoid false sharing. Further the HasAVX
// and HasAVX2 are only set if the OS supports XMM and YMM
// registers in addition to the CPUID feature bit being set.
var X86 struct {
_ CacheLinePad
HasAES bool // AES hardware implementation (AES NI)
HasADX bool // Multi-precision add-carry instruction extensions
HasAVX bool // Advanced vector extension
HasAVX2 bool // Advanced vector extension 2
HasBMI1 bool // Bit manipulation instruction set 1
HasBMI2 bool // Bit manipulation instruction set 2
HasERMS bool // Enhanced REP for MOVSB and STOSB
HasFMA bool // Fused-multiply-add instructions
HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
HasPOPCNT bool // Hamming weight instruction POPCNT.
HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64)
HasSSE3 bool // Streaming SIMD extension 3
HasSSSE3 bool // Supplemental streaming SIMD extension 3
HasSSE41 bool // Streaming SIMD extension 4 and 4.1
HasSSE42 bool // Streaming SIMD extension 4 and 4.2
_ CacheLinePad
}

7
vendor/golang.org/x/sys/cpu/cpu_arm.go generated vendored Normal file
View File

@ -0,0 +1,7 @@
// 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.
package cpu
const cacheLineSize = 32

7
vendor/golang.org/x/sys/cpu/cpu_arm64.go generated vendored Normal file
View File

@ -0,0 +1,7 @@
// 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.
package cpu
const cacheLineSize = 64

16
vendor/golang.org/x/sys/cpu/cpu_gc_x86.go generated vendored Normal file
View File

@ -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 386 amd64 amd64p32
// +build !gccgo
package cpu
// cpuid is implemented in cpu_x86.s for gc compiler
// and in cpu_gccgo.c for gccgo.
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
// xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler
// and in cpu_gccgo.c for gccgo.
func xgetbv() (eax, edx uint32)

43
vendor/golang.org/x/sys/cpu/cpu_gccgo.c generated vendored Normal file
View File

@ -0,0 +1,43 @@
// 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 386 amd64 amd64p32
// +build gccgo
#include <cpuid.h>
#include <stdint.h>
// Need to wrap __get_cpuid_count because it's declared as static.
int
gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx)
{
return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx);
}
// xgetbv reads the contents of an XCR (Extended Control Register)
// specified in the ECX register into registers EDX:EAX.
// Currently, the only supported value for XCR is 0.
//
// TODO: Replace with a better alternative:
//
// #include <xsaveintrin.h>
//
// #pragma GCC target("xsave")
//
// void gccgoXgetbv(uint32_t *eax, uint32_t *edx) {
// unsigned long long x = _xgetbv(0);
// *eax = x & 0xffffffff;
// *edx = (x >> 32) & 0xffffffff;
// }
//
// Note that _xgetbv is defined starting with GCC 8.
void
gccgoXgetbv(uint32_t *eax, uint32_t *edx)
{
__asm(" xorl %%ecx, %%ecx\n"
" xgetbv"
: "=a"(*eax), "=d"(*edx));
}

26
vendor/golang.org/x/sys/cpu/cpu_gccgo.go generated vendored Normal file
View File

@ -0,0 +1,26 @@
// 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 386 amd64 amd64p32
// +build gccgo
package cpu
//extern gccgoGetCpuidCount
func gccgoGetCpuidCount(eaxArg, ecxArg uint32, eax, ebx, ecx, edx *uint32)
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) {
var a, b, c, d uint32
gccgoGetCpuidCount(eaxArg, ecxArg, &a, &b, &c, &d)
return a, b, c, d
}
//extern gccgoXgetbv
func gccgoXgetbv(eax, edx *uint32)
func xgetbv() (eax, edx uint32) {
var a, d uint32
gccgoXgetbv(&a, &d)
return a, d
}

9
vendor/golang.org/x/sys/cpu/cpu_mips64x.go generated vendored Normal file
View File

@ -0,0 +1,9 @@
// 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 mips64 mips64le
package cpu
const cacheLineSize = 32

9
vendor/golang.org/x/sys/cpu/cpu_mipsx.go generated vendored Normal file
View File

@ -0,0 +1,9 @@
// 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 mips mipsle
package cpu
const cacheLineSize = 32

9
vendor/golang.org/x/sys/cpu/cpu_ppc64x.go generated vendored Normal file
View File

@ -0,0 +1,9 @@
// 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 ppc64 ppc64le
package cpu
const cacheLineSize = 128

7
vendor/golang.org/x/sys/cpu/cpu_s390x.go generated vendored Normal file
View File

@ -0,0 +1,7 @@
// 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.
package cpu
const cacheLineSize = 256

55
vendor/golang.org/x/sys/cpu/cpu_x86.go generated vendored Normal file
View File

@ -0,0 +1,55 @@
// 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 386 amd64 amd64p32
package cpu
const cacheLineSize = 64
func init() {
maxID, _, _, _ := cpuid(0, 0)
if maxID < 1 {
return
}
_, _, ecx1, edx1 := cpuid(1, 0)
X86.HasSSE2 = isSet(26, edx1)
X86.HasSSE3 = isSet(0, ecx1)
X86.HasPCLMULQDQ = isSet(1, ecx1)
X86.HasSSSE3 = isSet(9, ecx1)
X86.HasFMA = isSet(12, ecx1)
X86.HasSSE41 = isSet(19, ecx1)
X86.HasSSE42 = isSet(20, ecx1)
X86.HasPOPCNT = isSet(23, ecx1)
X86.HasAES = isSet(25, ecx1)
X86.HasOSXSAVE = isSet(27, ecx1)
osSupportsAVX := false
// For XGETBV, OSXSAVE bit is required and sufficient.
if X86.HasOSXSAVE {
eax, _ := xgetbv()
// Check if XMM and YMM registers have OS support.
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
}
X86.HasAVX = isSet(28, ecx1) && osSupportsAVX
if maxID < 7 {
return
}
_, ebx7, _, _ := cpuid(7, 0)
X86.HasBMI1 = isSet(3, ebx7)
X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX
X86.HasBMI2 = isSet(8, ebx7)
X86.HasERMS = isSet(9, ebx7)
X86.HasADX = isSet(19, ebx7)
}
func isSet(bitpos uint, value uint32) bool {
return value&(1<<bitpos) != 0
}

27
vendor/golang.org/x/sys/cpu/cpu_x86.s generated vendored Normal file
View File

@ -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 386 amd64 amd64p32
// +build !gccgo
#include "textflag.h"
// func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
TEXT ·cpuid(SB), NOSPLIT, $0-24
MOVL eaxArg+0(FP), AX
MOVL ecxArg+4(FP), CX
CPUID
MOVL AX, eax+8(FP)
MOVL BX, ebx+12(FP)
MOVL CX, ecx+16(FP)
MOVL DX, edx+20(FP)
RET
// func xgetbv() (eax, edx uint32)
TEXT ·xgetbv(SB),NOSPLIT,$0-8
MOVL $0, CX
XGETBV
MOVL AX, eax+0(FP)
MOVL DX, edx+4(FP)
RET

124
vendor/golang.org/x/sys/unix/affinity_linux.go generated vendored Normal file
View File

@ -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)
}

View File

@ -13,17 +13,17 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-64 TEXT ·Syscall(SB),NOSPLIT,$0-56
JMP syscall·Syscall(SB) JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-88 TEXT ·Syscall6(SB),NOSPLIT,$0-80
JMP syscall·Syscall6(SB) JMP syscall·Syscall6(SB)
TEXT ·Syscall9(SB),NOSPLIT,$0-112 TEXT ·Syscall9(SB),NOSPLIT,$0-104
JMP syscall·Syscall9(SB) JMP syscall·Syscall9(SB)
TEXT ·RawSyscall(SB),NOSPLIT,$0-64 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
JMP syscall·RawSyscall(SB) JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
JMP syscall·RawSyscall6(SB) JMP syscall·RawSyscall6(SB)

View File

@ -10,21 +10,51 @@
// System calls for 386, Linux // System calls for 386, Linux
// //
// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
// instead of the glibc-specific "CALL 0x10(GS)".
#define INVOKE_SYSCALL INT $0x80
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-28 TEXT ·Syscall(SB),NOSPLIT,$0-28
JMP syscall·Syscall(SB) JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-40 TEXT ·Syscall6(SB),NOSPLIT,$0-40
JMP syscall·Syscall6(SB) JMP syscall·Syscall6(SB)
TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
CALL runtime·entersyscall(SB)
MOVL trap+0(FP), AX // syscall entry
MOVL a1+4(FP), BX
MOVL a2+8(FP), CX
MOVL a3+12(FP), DX
MOVL $0, SI
MOVL $0, DI
INVOKE_SYSCALL
MOVL AX, r1+16(FP)
MOVL DX, r2+20(FP)
CALL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 TEXT ·RawSyscall(SB),NOSPLIT,$0-28
JMP syscall·RawSyscall(SB) JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
JMP syscall·RawSyscall6(SB) JMP syscall·RawSyscall6(SB)
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
MOVL trap+0(FP), AX // syscall entry
MOVL a1+4(FP), BX
MOVL a2+8(FP), CX
MOVL a3+12(FP), DX
MOVL $0, SI
MOVL $0, DI
INVOKE_SYSCALL
MOVL AX, r1+16(FP)
MOVL DX, r2+20(FP)
RET
TEXT ·socketcall(SB),NOSPLIT,$0-36 TEXT ·socketcall(SB),NOSPLIT,$0-36
JMP syscall·socketcall(SB) JMP syscall·socketcall(SB)

View File

@ -13,17 +13,45 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-56 TEXT ·Syscall(SB),NOSPLIT,$0-56
JMP syscall·Syscall(SB) JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·Syscall6(SB),NOSPLIT,$0-80
JMP syscall·Syscall6(SB) JMP syscall·Syscall6(SB)
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
CALL runtime·entersyscall(SB)
MOVQ a1+8(FP), DI
MOVQ a2+16(FP), SI
MOVQ a3+24(FP), DX
MOVQ $0, R10
MOVQ $0, R8
MOVQ $0, R9
MOVQ trap+0(FP), AX // syscall entry
SYSCALL
MOVQ AX, r1+32(FP)
MOVQ DX, r2+40(FP)
CALL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
JMP syscall·RawSyscall(SB) JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
JMP syscall·RawSyscall6(SB) JMP syscall·RawSyscall6(SB)
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
MOVQ a1+8(FP), DI
MOVQ a2+16(FP), SI
MOVQ a3+24(FP), DX
MOVQ $0, R10
MOVQ $0, R8
MOVQ $0, R9
MOVQ trap+0(FP), AX // syscall entry
SYSCALL
MOVQ AX, r1+32(FP)
MOVQ DX, r2+40(FP)
RET
TEXT ·gettimeofday(SB),NOSPLIT,$0-16 TEXT ·gettimeofday(SB),NOSPLIT,$0-16
JMP syscall·gettimeofday(SB) JMP syscall·gettimeofday(SB)

View File

@ -13,17 +13,44 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-28 TEXT ·Syscall(SB),NOSPLIT,$0-28
B syscall·Syscall(SB) B syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-40 TEXT ·Syscall6(SB),NOSPLIT,$0-40
B syscall·Syscall6(SB) B syscall·Syscall6(SB)
TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
BL runtime·entersyscall(SB)
MOVW trap+0(FP), R7
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
MOVW $0, R3
MOVW $0, R4
MOVW $0, R5
SWI $0
MOVW R0, r1+16(FP)
MOVW $0, R0
MOVW R0, r2+20(FP)
BL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 TEXT ·RawSyscall(SB),NOSPLIT,$0-28
B syscall·RawSyscall(SB) B syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
B syscall·RawSyscall6(SB) B syscall·RawSyscall6(SB)
TEXT ·seek(SB),NOSPLIT,$0-32 TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
MOVW trap+0(FP), R7 // syscall entry
MOVW a1+4(FP), R0
MOVW a2+8(FP), R1
MOVW a3+12(FP), R2
SWI $0
MOVW R0, r1+16(FP)
MOVW $0, R0
MOVW R0, r2+20(FP)
RET
TEXT ·seek(SB),NOSPLIT,$0-28
B syscall·seek(SB) B syscall·seek(SB)

View File

@ -11,14 +11,42 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-56 TEXT ·Syscall(SB),NOSPLIT,$0-56
B syscall·Syscall(SB) B syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·Syscall6(SB),NOSPLIT,$0-80
B syscall·Syscall6(SB) B syscall·Syscall6(SB)
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
BL runtime·entersyscall(SB)
MOVD a1+8(FP), R0
MOVD a2+16(FP), R1
MOVD a3+24(FP), R2
MOVD $0, R3
MOVD $0, R4
MOVD $0, R5
MOVD trap+0(FP), R8 // syscall entry
SVC
MOVD R0, r1+32(FP) // r1
MOVD R1, r2+40(FP) // r2
BL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
B syscall·RawSyscall(SB) B syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
B syscall·RawSyscall6(SB) B syscall·RawSyscall6(SB)
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
MOVD a1+8(FP), R0
MOVD a2+16(FP), R1
MOVD a3+24(FP), R2
MOVD $0, R3
MOVD $0, R4
MOVD $0, R5
MOVD trap+0(FP), R8 // syscall entry
SVC
MOVD R0, r1+32(FP)
MOVD R1, r2+40(FP)
RET

View File

@ -15,14 +15,42 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-56 TEXT ·Syscall(SB),NOSPLIT,$0-56
JMP syscall·Syscall(SB) JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·Syscall6(SB),NOSPLIT,$0-80
JMP syscall·Syscall6(SB) JMP syscall·Syscall6(SB)
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
JAL runtime·entersyscall(SB)
MOVV a1+8(FP), R4
MOVV a2+16(FP), R5
MOVV a3+24(FP), R6
MOVV R0, R7
MOVV R0, R8
MOVV R0, R9
MOVV trap+0(FP), R2 // syscall entry
SYSCALL
MOVV R2, r1+32(FP)
MOVV R3, r2+40(FP)
JAL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
JMP syscall·RawSyscall(SB) JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
JMP syscall·RawSyscall6(SB) JMP syscall·RawSyscall6(SB)
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
MOVV a1+8(FP), R4
MOVV a2+16(FP), R5
MOVV a3+24(FP), R6
MOVV R0, R7
MOVV R0, R8
MOVV R0, R9
MOVV trap+0(FP), R2 // syscall entry
SYSCALL
MOVV R2, r1+32(FP)
MOVV R3, r2+40(FP)
RET

View File

@ -15,17 +15,40 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-28 TEXT ·Syscall(SB),NOSPLIT,$0-28
JMP syscall·Syscall(SB) JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-40 TEXT ·Syscall6(SB),NOSPLIT,$0-40
JMP syscall·Syscall6(SB) JMP syscall·Syscall6(SB)
TEXT ·Syscall9(SB),NOSPLIT,$0-52 TEXT ·Syscall9(SB),NOSPLIT,$0-52
JMP syscall·Syscall9(SB) JMP syscall·Syscall9(SB)
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 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) JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
JMP syscall·RawSyscall6(SB) 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

View File

@ -15,14 +15,42 @@
// Just jump to package syscall's implementation for all these functions. // Just jump to package syscall's implementation for all these functions.
// The runtime may know about them. // The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-56 TEXT ·Syscall(SB),NOSPLIT,$0-56
BR syscall·Syscall(SB) BR syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·Syscall6(SB),NOSPLIT,$0-80
BR syscall·Syscall6(SB) BR syscall·Syscall6(SB)
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
BL runtime·entersyscall(SB)
MOVD a1+8(FP), R3
MOVD a2+16(FP), R4
MOVD a3+24(FP), R5
MOVD R0, R6
MOVD R0, R7
MOVD R0, R8
MOVD trap+0(FP), R9 // syscall entry
SYSCALL R9
MOVD R3, r1+32(FP)
MOVD R4, r2+40(FP)
BL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
BR syscall·RawSyscall(SB) BR syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
BR syscall·RawSyscall6(SB) BR syscall·RawSyscall6(SB)
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
MOVD a1+8(FP), R3
MOVD a2+16(FP), R4
MOVD a3+24(FP), R5
MOVD R0, R6
MOVD R0, R7
MOVD R0, R8
MOVD trap+0(FP), R9 // syscall entry
SYSCALL R9
MOVD R3, r1+32(FP)
MOVD R4, r2+40(FP)
RET

View File

@ -21,8 +21,36 @@ TEXT ·Syscall(SB),NOSPLIT,$0-56
TEXT ·Syscall6(SB),NOSPLIT,$0-80 TEXT ·Syscall6(SB),NOSPLIT,$0-80
BR syscall·Syscall6(SB) BR syscall·Syscall6(SB)
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
BL runtime·entersyscall(SB)
MOVD a1+8(FP), R2
MOVD a2+16(FP), R3
MOVD a3+24(FP), R4
MOVD $0, R5
MOVD $0, R6
MOVD $0, R7
MOVD trap+0(FP), R1 // syscall entry
SYSCALL
MOVD R2, r1+32(FP)
MOVD R3, r2+40(FP)
BL runtime·exitsyscall(SB)
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
BR syscall·RawSyscall(SB) BR syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
BR syscall·RawSyscall6(SB) BR syscall·RawSyscall6(SB)
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
MOVD a1+8(FP), R2
MOVD a2+16(FP), R3
MOVD a3+24(FP), R4
MOVD $0, R5
MOVD $0, R6
MOVD $0, R7
MOVD trap+0(FP), R1 // syscall entry
SYSCALL
MOVD R2, r1+32(FP)
MOVD R3, r2+40(FP)
RET

View File

@ -7,7 +7,7 @@
package unix package unix
import ( import (
errorspkg "errors" "errors"
"fmt" "fmt"
) )
@ -60,26 +60,26 @@ func CapRightsSet(rights *CapRights, setrights []uint64) error {
n := caparsize(rights) n := caparsize(rights)
if n < capArSizeMin || n > capArSizeMax { if n < capArSizeMin || n > capArSizeMax {
return errorspkg.New("bad rights size") return errors.New("bad rights size")
} }
for _, right := range setrights { for _, right := range setrights {
if caprver(right) != CAP_RIGHTS_VERSION_00 { if caprver(right) != CAP_RIGHTS_VERSION_00 {
return errorspkg.New("bad right version") return errors.New("bad right version")
} }
i, err := rightToIndex(right) i, err := rightToIndex(right)
if err != nil { if err != nil {
return err return err
} }
if i >= n { if i >= n {
return errorspkg.New("index overflow") return errors.New("index overflow")
} }
if capidxbit(rights.Rights[i]) != capidxbit(right) { if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errorspkg.New("index mismatch") return errors.New("index mismatch")
} }
rights.Rights[i] |= right rights.Rights[i] |= right
if capidxbit(rights.Rights[i]) != capidxbit(right) { if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errorspkg.New("index mismatch (after assign)") return errors.New("index mismatch (after assign)")
} }
} }
@ -95,26 +95,26 @@ func CapRightsClear(rights *CapRights, clearrights []uint64) error {
n := caparsize(rights) n := caparsize(rights)
if n < capArSizeMin || n > capArSizeMax { if n < capArSizeMin || n > capArSizeMax {
return errorspkg.New("bad rights size") return errors.New("bad rights size")
} }
for _, right := range clearrights { for _, right := range clearrights {
if caprver(right) != CAP_RIGHTS_VERSION_00 { if caprver(right) != CAP_RIGHTS_VERSION_00 {
return errorspkg.New("bad right version") return errors.New("bad right version")
} }
i, err := rightToIndex(right) i, err := rightToIndex(right)
if err != nil { if err != nil {
return err return err
} }
if i >= n { if i >= n {
return errorspkg.New("index overflow") return errors.New("index overflow")
} }
if capidxbit(rights.Rights[i]) != capidxbit(right) { if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errorspkg.New("index mismatch") return errors.New("index mismatch")
} }
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
if capidxbit(rights.Rights[i]) != capidxbit(right) { if capidxbit(rights.Rights[i]) != capidxbit(right) {
return errorspkg.New("index mismatch (after assign)") return errors.New("index mismatch (after assign)")
} }
} }
@ -130,22 +130,22 @@ func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
n := caparsize(rights) n := caparsize(rights)
if n < capArSizeMin || n > capArSizeMax { if n < capArSizeMin || n > capArSizeMax {
return false, errorspkg.New("bad rights size") return false, errors.New("bad rights size")
} }
for _, right := range setrights { for _, right := range setrights {
if caprver(right) != CAP_RIGHTS_VERSION_00 { if caprver(right) != CAP_RIGHTS_VERSION_00 {
return false, errorspkg.New("bad right version") return false, errors.New("bad right version")
} }
i, err := rightToIndex(right) i, err := rightToIndex(right)
if err != nil { if err != nil {
return false, err return false, err
} }
if i >= n { if i >= n {
return false, errorspkg.New("index overflow") return false, errors.New("index overflow")
} }
if capidxbit(rights.Rights[i]) != capidxbit(right) { if capidxbit(rights.Rights[i]) != capidxbit(right) {
return false, errorspkg.New("index mismatch") return false, errors.New("index mismatch")
} }
if (rights.Rights[i] & right) != right { if (rights.Rights[i] & right) != right {
return false, nil return false, nil

View File

@ -6,97 +6,12 @@
package unix package unix
import "unsafe" import "syscall"
// readInt returns the size-bytes unsigned integer in native byte order at offset off.
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
if len(b) < int(off+size) {
return 0, false
}
if isBigEndian {
return readIntBE(b[off:], size), true
}
return readIntLE(b[off:], size), true
}
func readIntBE(b []byte, size uintptr) uint64 {
switch size {
case 1:
return uint64(b[0])
case 2:
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
return uint64(b[1]) | uint64(b[0])<<8
case 4:
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
case 8:
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
default:
panic("syscall: readInt with unsupported size")
}
}
func readIntLE(b []byte, size uintptr) uint64 {
switch size {
case 1:
return uint64(b[0])
case 2:
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
return uint64(b[0]) | uint64(b[1])<<8
case 4:
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
case 8:
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
default:
panic("syscall: readInt with unsupported size")
}
}
// ParseDirent parses up to max directory entries in buf, // ParseDirent parses up to max directory entries in buf,
// appending the names to names. It returns the number of // appending the names to names. It returns the number of
// bytes consumed from buf, the number of entries added // bytes consumed from buf, the number of entries added
// to names, and the new names slice. // to names, and the new names slice.
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
origlen := len(buf) return syscall.ParseDirent(buf, max, names)
count = 0
for max != 0 && len(buf) > 0 {
reclen, ok := direntReclen(buf)
if !ok || reclen > uint64(len(buf)) {
return origlen, count, names
}
rec := buf[:reclen]
buf = buf[reclen:]
ino, ok := direntIno(rec)
if !ok {
break
}
if ino == 0 { // File absent in directory.
continue
}
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
namlen, ok := direntNamlen(rec)
if !ok || namoff+namlen > uint64(len(rec)) {
break
}
name := rec[namoff : namoff+namlen]
for i, c := range name {
if c == 0 {
name = name[:i]
break
}
}
// Check for useless names before allocating a string.
if string(name) == "." || string(name) == ".." {
continue
}
max--
count++
names = append(names, string(name))
}
return origlen - len(buf), count, names
} }

View File

@ -1,4 +1,4 @@
// Copyright 2010 The Go Authors. All rights reserved. // Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -25,3 +25,7 @@ func Clearenv() {
func Environ() []string { func Environ() []string {
return syscall.Environ() return syscall.Environ()
} }
func Unsetenv(key string) error {
return syscall.Unsetenv(key)
}

View File

@ -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)
}

View File

@ -12,6 +12,16 @@ import "unsafe"
// systems by flock_linux_32bit.go to be SYS_FCNTL64. // systems by flock_linux_32bit.go to be SYS_FCNTL64.
var fcntl64Syscall uintptr = SYS_FCNTL var fcntl64Syscall uintptr = SYS_FCNTL
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
var err error
if errno != 0 {
err = errno
}
return int(valptr), err
}
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))

View File

@ -1,27 +0,0 @@
// 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
import (
"os"
"syscall"
)
// FIXME: unexported function from os
// syscallMode returns the syscall-specific mode bits from Go's portable mode bits.
func syscallMode(i os.FileMode) (o uint32) {
o |= uint32(i.Perm())
if i&os.ModeSetuid != 0 {
o |= syscall.S_ISUID
}
if i&os.ModeSetgid != 0 {
o |= syscall.S_ISGID
}
if i&os.ModeSticky != 0 {
o |= syscall.S_ISVTX
}
// No mapping for Go's ModeTemporary (plan9 only).
return
}

View File

@ -1,4 +1,4 @@
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -8,12 +8,22 @@ package unix
import "syscall" import "syscall"
// We can't use the gc-syntax .s files for gccgo. On the plus side // We can't use the gc-syntax .s files for gccgo. On the plus side
// much of the functionality can be written directly in Go. // much of the functionality can be written directly in Go.
//extern gccgoRealSyscallNoError
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
//extern gccgoRealSyscall //extern gccgoRealSyscall
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
syscall.Entersyscall()
r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
syscall.Exitsyscall()
return r, 0
}
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
syscall.Entersyscall() syscall.Entersyscall()
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
@ -35,6 +45,11 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr,
return r, 0, syscall.Errno(errno) return r, 0, syscall.Errno(errno)
} }
func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
return r, 0
}
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
return r, 0, syscall.Errno(errno) return r, 0, syscall.Errno(errno)

View File

@ -1,4 +1,4 @@
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -31,11 +31,8 @@ gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintp
return r; return r;
} }
// Define the use function in C so that it is not inlined. uintptr_t
gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
void
use(void *p __attribute__ ((unused)))
{ {
return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -13,7 +13,7 @@ import (
) )
const ( const (
SYS_PLEDGE = 108 _SYS_PLEDGE = 108
) )
// Pledge implements the pledge syscall. For more information see pledge(2). // Pledge implements the pledge syscall. For more information see pledge(2).
@ -30,7 +30,7 @@ func Pledge(promises string, paths []string) error {
} }
pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) pathsUnsafe = unsafe.Pointer(&pathsPtr[0])
} }
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) _, _, e := syscall.Syscall(_SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0)
if e != 0 { if e != 0 {
return e return e
} }

View File

@ -1,4 +1,4 @@
// Copyright 2017 The Go Authors. All rights reserved. // Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2011 The Go Authors. All rights reserved. // Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -5,30 +5,33 @@
// +build darwin dragonfly freebsd linux netbsd openbsd solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris
// Package unix contains an interface to the low-level operating system // Package unix contains an interface to the low-level operating system
// primitives. OS details vary depending on the underlying system, and // primitives. OS details vary depending on the underlying system, and
// by default, godoc will display OS-specific documentation for the current // by default, godoc will display OS-specific documentation for the current
// system. If you want godoc to display OS documentation for another // system. If you want godoc to display OS documentation for another
// system, set $GOOS and $GOARCH to the desired system. For example, if // system, set $GOOS and $GOARCH to the desired system. For example, if
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
// to freebsd and $GOARCH to arm. // to freebsd and $GOARCH to arm.
//
// The primary use of this package is inside other packages that provide a more // The primary use of this package is inside other packages that provide a more
// portable interface to the system, such as "os", "time" and "net". Use // portable interface to the system, such as "os", "time" and "net". Use
// those packages rather than this one if you can. // those packages rather than this one if you can.
//
// For details of the functions and data types in this package consult // For details of the functions and data types in this package consult
// the manuals for the appropriate operating system. // the manuals for the appropriate operating system.
//
// These calls return err == nil to indicate success; otherwise // These calls return err == nil to indicate success; otherwise
// err represents an operating system error describing the failure and // err represents an operating system error describing the failure and
// holds a value of type syscall.Errno. // holds a value of type syscall.Errno.
package unix // import "golang.org/x/sys/unix" package unix // import "golang.org/x/sys/unix"
import "strings"
// ByteSliceFromString returns a NUL-terminated slice of bytes // ByteSliceFromString returns a NUL-terminated slice of bytes
// containing the text of s. If s contains a NUL byte at any // containing the text of s. If s contains a NUL byte at any
// location, it returns (nil, EINVAL). // location, it returns (nil, EINVAL).
func ByteSliceFromString(s string) ([]byte, error) { func ByteSliceFromString(s string) ([]byte, error) {
for i := 0; i < len(s); i++ { if strings.IndexByte(s, 0) != -1 {
if s[i] == 0 { return nil, EINVAL
return nil, EINVAL
}
} }
a := make([]byte, len(s)+1) a := make([]byte, len(s)+1)
copy(a, s) copy(a, s)
@ -49,21 +52,3 @@ func BytePtrFromString(s string) (*byte, error) {
// Single-word zero for use when we need a valid pointer to 0 bytes. // Single-word zero for use when we need a valid pointer to 0 bytes.
// See mkunix.pl. // See mkunix.pl.
var _zero uintptr var _zero uintptr
func (ts *Timespec) Unix() (sec int64, nsec int64) {
return int64(ts.Sec), int64(ts.Nsec)
}
func (tv *Timeval) Unix() (sec int64, nsec int64) {
return int64(tv.Sec), int64(tv.Usec) * 1000
}
func (ts *Timespec) Nano() int64 {
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
}
func (tv *Timeval) Nano() int64 {
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
}
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }

View File

@ -34,7 +34,7 @@ func Getgroups() (gids []int, err error) {
return nil, nil return nil, nil
} }
// Sanity check group count. Max is 16 on BSD. // Sanity check group count. Max is 16 on BSD.
if n < 0 || n > 1000 { if n < 0 || n > 1000 {
return nil, EINVAL return nil, EINVAL
} }
@ -206,7 +206,7 @@ func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
} }
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
switch rsa.Addr.Family { switch rsa.Addr.Family {
case AF_LINK: case AF_LINK:
pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa)) pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
@ -286,7 +286,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) {
Close(nfd) Close(nfd)
return 0, nil, ECONNABORTED return 0, nil, ECONNABORTED
} }
sa, err = anyToSockaddr(&rsa) sa, err = anyToSockaddr(fd, &rsa)
if err != nil { if err != nil {
Close(nfd) Close(nfd)
nfd = 0 nfd = 0
@ -306,50 +306,21 @@ func Getsockname(fd int) (sa Sockaddr, err error) {
rsa.Addr.Family = AF_UNIX rsa.Addr.Family = AF_UNIX
rsa.Addr.Len = SizeofSockaddrUnix rsa.Addr.Len = SizeofSockaddrUnix
} }
return anyToSockaddr(&rsa) return anyToSockaddr(fd, &rsa)
} }
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
func GetsockoptByte(fd, level, opt int) (value byte, err error) { // GetsockoptString returns the string value of the socket option opt for the
var n byte // socket associated with fd at the given socket level.
vallen := _Socklen(1) func GetsockoptString(fd, level, opt int) (string, error) {
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) buf := make([]byte, 256)
return n, err vallen := _Socklen(len(buf))
} err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen)
if err != nil {
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) { return "", err
vallen := _Socklen(4) }
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) return string(buf[:vallen-1]), nil
return value, err
}
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
var value IPMreq
vallen := _Socklen(SizeofIPMreq)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
var value IPv6Mreq
vallen := _Socklen(SizeofIPv6Mreq)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
var value IPv6MTUInfo
vallen := _Socklen(SizeofIPv6MTUInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
var value ICMPv6Filter
vallen := _Socklen(SizeofICMPv6Filter)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
} }
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
@ -385,7 +356,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from
recvflags = int(msg.Flags) recvflags = int(msg.Flags)
// source address is only specified if the socket is unconnected // source address is only specified if the socket is unconnected
if rsa.Addr.Family != AF_UNSPEC { if rsa.Addr.Family != AF_UNSPEC {
from, err = anyToSockaddr(&rsa) from, err = anyToSockaddr(fd, &rsa)
} }
return return
} }
@ -570,7 +541,12 @@ func UtimesNano(path string, ts []Timespec) error {
if len(ts) != 2 { if len(ts) != 2 {
return EINVAL return EINVAL
} }
err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) // Darwin setattrlist can set nanosecond timestamps
err := setattrlistTimes(path, ts, 0)
if err != ENOSYS {
return err
}
err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
if err != ENOSYS { if err != ENOSYS {
return err return err
} }
@ -590,6 +566,10 @@ func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
if len(ts) != 2 { if len(ts) != 2 {
return EINVAL return EINVAL
} }
err := setattrlistTimes(path, ts, flags)
if err != ENOSYS {
return err
}
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
} }
@ -607,6 +587,15 @@ func Futimes(fd int, tv []Timeval) error {
//sys fcntl(fd int, cmd int, arg int) (val int, err error) //sys fcntl(fd int, cmd int, arg int) (val int, err error)
//sys 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)
}
// TODO: wrap // TODO: wrap
// Acct(name nil-string) (err error) // Acct(name nil-string) (err error)
// Gethostuuid(uuid *byte, timeout *Timespec) (err error) // Gethostuuid(uuid *byte, timeout *Timespec) (err error)

View File

@ -13,7 +13,7 @@
package unix package unix
import ( import (
errorspkg "errors" "errors"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@ -36,6 +36,7 @@ func Getwd() (string, error) {
return "", ENOTSUP return "", ENOTSUP
} }
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct { type SockaddrDatalink struct {
Len uint8 Len uint8
Family uint8 Family uint8
@ -54,7 +55,7 @@ func nametomib(name string) (mib []_C_int, err error) {
// NOTE(rsc): It seems strange to set the buffer to have // NOTE(rsc): It seems strange to set the buffer to have
// size CTL_MAXNAME+2 but use only CTL_MAXNAME // size CTL_MAXNAME+2 but use only CTL_MAXNAME
// as the size. I don't know why the +2 is here, but the // as the size. I don't know why the +2 is here, but the
// kernel uses +2 for its own implementation of this function. // kernel uses +2 for its own implementation of this function.
// I am scared that if we don't include the +2 here, the kernel // I am scared that if we don't include the +2 here, the kernel
// will silently write 2 words farther than we specify // will silently write 2 words farther than we specify
@ -76,18 +77,6 @@ func nametomib(name string) (mib []_C_int, err error) {
return buf[0 : n/siz], nil return buf[0 : n/siz], nil
} }
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
}
func direntReclen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
}
func direntNamlen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
}
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) //sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
@ -109,7 +98,7 @@ type attrList struct {
func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) { func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
if len(attrBuf) < 4 { if len(attrBuf) < 4 {
return nil, errorspkg.New("attrBuf too small") return nil, errors.New("attrBuf too small")
} }
attrList.bitmapCount = attrBitMapCount attrList.bitmapCount = attrBitMapCount
@ -145,12 +134,12 @@ func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (
for i := uint32(0); int(i) < len(dat); { for i := uint32(0); int(i) < len(dat); {
header := dat[i:] header := dat[i:]
if len(header) < 8 { if len(header) < 8 {
return attrs, errorspkg.New("truncated attribute header") return attrs, errors.New("truncated attribute header")
} }
datOff := *(*int32)(unsafe.Pointer(&header[0])) datOff := *(*int32)(unsafe.Pointer(&header[0]))
attrLen := *(*uint32)(unsafe.Pointer(&header[4])) attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) { if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
return attrs, errorspkg.New("truncated results; attrBuf too small") return attrs, errors.New("truncated results; attrBuf too small")
} }
end := uint32(datOff) + attrLen end := uint32(datOff) + attrLen
attrs = append(attrs, dat[datOff:end]) attrs = append(attrs, dat[datOff:end])
@ -187,6 +176,119 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
return return
} }
func xattrPointer(dest []byte) *byte {
// It's only when dest is set to NULL that the OS X implementations of
// getxattr() and listxattr() return the current sizes of the named attributes.
// An empty byte array is not sufficient. To maintain the same behaviour as the
// linux implementation, we wrap around the system calls and pass in NULL when
// dest is empty.
var destp *byte
if len(dest) > 0 {
destp = &dest[0]
}
return destp
}
//sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
}
func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
}
//sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
// The parameters for the OS X implementation vary slightly compared to the
// linux system call, specifically the position parameter:
//
// linux:
// int setxattr(
// const char *path,
// const char *name,
// const void *value,
// size_t size,
// int flags
// );
//
// darwin:
// int setxattr(
// const char *path,
// const char *name,
// void *value,
// size_t size,
// u_int32_t position,
// int options
// );
//
// position specifies the offset within the extended attribute. In the
// current implementation, only the resource fork extended attribute makes
// use of this argument. For all others, position is reserved. We simply
// default to setting it to zero.
return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
}
func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
}
//sys removexattr(path string, attr string, options int) (err error)
func Removexattr(path string, attr string) (err error) {
// We wrap around and explicitly zero out the options provided to the OS X
// implementation of removexattr, we do so for interoperability with the
// linux variant.
return removexattr(path, attr, 0)
}
func Lremovexattr(link string, attr string) (err error) {
return removexattr(link, attr, XATTR_NOFOLLOW)
}
//sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
func Listxattr(path string, dest []byte) (sz int, err error) {
return listxattr(path, xattrPointer(dest), len(dest), 0)
}
func Llistxattr(link string, dest []byte) (sz int, err error) {
return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
}
func setattrlistTimes(path string, times []Timespec, flags int) error {
_p0, err := BytePtrFromString(path)
if err != nil {
return err
}
var attrList attrList
attrList.bitmapCount = ATTR_BIT_MAP_COUNT
attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME
// order is mtime, atime: the opposite of Chtimes
attributes := [2]Timespec{times[1], times[0]}
options := 0
if flags&AT_SYMLINK_NOFOLLOW != 0 {
options |= FSOPT_NOFOLLOW
}
_, _, e1 := Syscall6(
SYS_SETATTRLIST,
uintptr(unsafe.Pointer(_p0)),
uintptr(unsafe.Pointer(&attrList)),
uintptr(unsafe.Pointer(&attributes)),
uintptr(unsafe.Sizeof(attributes)),
uintptr(options),
0,
)
if e1 != 0 {
return e1
}
return nil
}
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error { func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
// Darwin doesn't support SYS_UTIMENSAT // Darwin doesn't support SYS_UTIMENSAT
return ENOSYS return ENOSYS
@ -239,6 +341,52 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
return &value, err return &value, err
} }
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
n = unsafe.Sizeof(uname.Nodename)
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
n = unsafe.Sizeof(uname.Release)
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
return err
}
// The version might have newlines or tabs in it, convert them to
// spaces.
for i, b := range uname.Version {
if b == '\n' || b == '\t' {
if i == len(uname.Version)-1 {
uname.Version[i] = 0
} else {
uname.Version[i] = ' '
}
}
}
mib = []_C_int{CTL_HW, HW_MACHINE}
n = unsafe.Sizeof(uname.Machine)
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
return err
}
return nil
}
/* /*
* Exposed directly * Exposed directly
*/ */
@ -264,6 +412,7 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
//sys Flock(fd int, how int) (err error) //sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error) //sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
//sys Fsync(fd int) (err error) //sys Fsync(fd int) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
@ -377,17 +526,12 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
// Searchfs // Searchfs
// Delete // Delete
// Copyfile // Copyfile
// Poll
// Watchevent // Watchevent
// Waitevent // Waitevent
// Modwatch // Modwatch
// Getxattr
// Fgetxattr // Fgetxattr
// Setxattr
// Fsetxattr // Fsetxattr
// Removexattr
// Fremovexattr // Fremovexattr
// Listxattr
// Flistxattr // Flistxattr
// Fsctl // Fsctl
// Initgroups // Initgroups

View File

@ -11,25 +11,18 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: int32(sec), Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int32(nsec / 1e9)
return
} }
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) { func Gettimeofday(tv *Timeval) (err error) {
// The tv passed to gettimeofday must be non-nil // The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back // but is otherwise unused. The answers come back
// in the two registers. // in the two registers.
sec, usec, err := gettimeofday(tv) sec, usec, err := gettimeofday(tv)
tv.Sec = int32(sec) tv.Sec = int32(sec)

View File

@ -11,25 +11,18 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) { func Gettimeofday(tv *Timeval) (err error) {
// The tv passed to gettimeofday must be non-nil // The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back // but is otherwise unused. The answers come back
// in the two registers. // in the two registers.
sec, usec, err := gettimeofday(tv) sec, usec, err := gettimeofday(tv)
tv.Sec = sec tv.Sec = sec

View File

@ -9,25 +9,18 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: int32(sec), Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int32(nsec / 1e9)
return
} }
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) { func Gettimeofday(tv *Timeval) (err error) {
// The tv passed to gettimeofday must be non-nil // The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back // but is otherwise unused. The answers come back
// in the two registers. // in the two registers.
sec, usec, err := gettimeofday(tv) sec, usec, err := gettimeofday(tv)
tv.Sec = int32(sec) tv.Sec = int32(sec)
@ -67,3 +60,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
} }
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/arm the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL

View File

@ -11,25 +11,18 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) { func Gettimeofday(tv *Timeval) (err error) {
// The tv passed to gettimeofday must be non-nil // The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back // but is otherwise unused. The answers come back
// in the two registers. // in the two registers.
sec, usec, err := gettimeofday(tv) sec, usec, err := gettimeofday(tv)
tv.Sec = sec tv.Sec = sec

View File

@ -14,6 +14,7 @@ package unix
import "unsafe" import "unsafe"
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct { type SockaddrDatalink struct {
Len uint8 Len uint8
Family uint8 Family uint8
@ -56,22 +57,6 @@ func nametomib(name string) (mib []_C_int, err error) {
return buf[0 : n/siz], nil return buf[0 : n/siz], nil
} }
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
}
func direntReclen(buf []byte) (uint64, bool) {
namlen, ok := direntNamlen(buf)
if !ok {
return 0, false
}
return (16 + namlen + 1 + 7) &^ 7, true
}
func direntNamlen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
}
//sysnb pipe() (r int, w int, err error) //sysnb pipe() (r int, w int, err error)
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
@ -102,7 +87,7 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
if len > SizeofSockaddrAny { if len > SizeofSockaddrAny {
panic("RawSockaddrAny too small") panic("RawSockaddrAny too small")
} }
sa, err = anyToSockaddr(&rsa) sa, err = anyToSockaddr(fd, &rsa)
if err != nil { if err != nil {
Close(nfd) Close(nfd)
nfd = 0 nfd = 0
@ -110,6 +95,23 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
return return
} }
const ImplementsGetwd = true
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
func Getwd() (string, error) {
var buf [PathMax]byte
_, err := Getcwd(buf[0:])
if err != nil {
return "", err
}
n := clen(buf[:])
if n < 1 {
return "", EINVAL
}
return string(buf[:n]), nil
}
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
var bufsize uintptr var bufsize uintptr
@ -125,6 +127,113 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
return return
} }
func setattrlistTimes(path string, times []Timespec, flags int) error {
// used on Darwin for UtimesNano
return ENOSYS
}
//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
}
func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error {
err := sysctl(mib, old, oldlen, nil, 0)
if err != nil {
// Utsname members on Dragonfly are only 32 bytes and
// the syscall returns ENOMEM in case the actual value
// is longer.
if err == ENOMEM {
err = nil
}
}
return err
}
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
if err := sysctlUname(mib, &uname.Sysname[0], &n); err != nil {
return err
}
uname.Sysname[unsafe.Sizeof(uname.Sysname)-1] = 0
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
n = unsafe.Sizeof(uname.Nodename)
if err := sysctlUname(mib, &uname.Nodename[0], &n); err != nil {
return err
}
uname.Nodename[unsafe.Sizeof(uname.Nodename)-1] = 0
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
n = unsafe.Sizeof(uname.Release)
if err := sysctlUname(mib, &uname.Release[0], &n); err != nil {
return err
}
uname.Release[unsafe.Sizeof(uname.Release)-1] = 0
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
if err := sysctlUname(mib, &uname.Version[0], &n); err != nil {
return err
}
// The version might have newlines or tabs in it, convert them to
// spaces.
for i, b := range uname.Version {
if b == '\n' || b == '\t' {
if i == len(uname.Version)-1 {
uname.Version[i] = 0
} else {
uname.Version[i] = ' '
}
}
}
mib = []_C_int{CTL_HW, HW_MACHINE}
n = unsafe.Sizeof(uname.Machine)
if err := sysctlUname(mib, &uname.Machine[0], &n); err != nil {
return err
}
uname.Machine[unsafe.Sizeof(uname.Machine)-1] = 0
return nil
}
/* /*
* Exposed directly * Exposed directly
*/ */
@ -142,10 +251,12 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
//sys Fchdir(fd int) (err error) //sys Fchdir(fd int) (err error)
//sys Fchflags(fd int, flags int) (err error) //sys Fchflags(fd int, flags int) (err error)
//sys Fchmod(fd int, mode uint32) (err error) //sys Fchmod(fd int, mode uint32) (err error)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Flock(fd int, how int) (err error) //sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error) //sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (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, stat *Statfs_t) (err error) //sys Fstatfs(fd int, stat *Statfs_t) (err error)
//sys Fsync(fd int) (err error) //sys Fsync(fd int) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
@ -225,7 +336,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
// Getlogin // Getlogin
// Sigpending // Sigpending
// Sigaltstack // Sigaltstack
// Ioctl
// Reboot // Reboot
// Execve // Execve
// Vfork // Vfork
@ -257,7 +367,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
// Searchfs // Searchfs
// Delete // Delete
// Copyfile // Copyfile
// Poll
// Watchevent // Watchevent
// Waitevent // Waitevent
// Modwatch // Modwatch
@ -403,7 +512,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
// Pread_nocancel // Pread_nocancel
// Pwrite_nocancel // Pwrite_nocancel
// Waitid_nocancel // Waitid_nocancel
// Poll_nocancel
// Msgsnd_nocancel // Msgsnd_nocancel
// Msgrcv_nocancel // Msgrcv_nocancel
// Sem_wait_nocancel // Sem_wait_nocancel

View File

@ -11,19 +11,12 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Usec = nsec % 1e9 / 1e3
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -12,8 +12,12 @@
package unix package unix
import "unsafe" import (
"strings"
"unsafe"
)
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct { type SockaddrDatalink struct {
Len uint8 Len uint8
Family uint8 Family uint8
@ -32,7 +36,7 @@ func nametomib(name string) (mib []_C_int, err error) {
// NOTE(rsc): It seems strange to set the buffer to have // NOTE(rsc): It seems strange to set the buffer to have
// size CTL_MAXNAME+2 but use only CTL_MAXNAME // size CTL_MAXNAME+2 but use only CTL_MAXNAME
// as the size. I don't know why the +2 is here, but the // as the size. I don't know why the +2 is here, but the
// kernel uses +2 for its own implementation of this function. // kernel uses +2 for its own implementation of this function.
// I am scared that if we don't include the +2 here, the kernel // I am scared that if we don't include the +2 here, the kernel
// will silently write 2 words farther than we specify // will silently write 2 words farther than we specify
@ -54,18 +58,6 @@ func nametomib(name string) (mib []_C_int, err error) {
return buf[0 : n/siz], nil return buf[0 : n/siz], nil
} }
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
}
func direntReclen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
}
func direntNamlen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
}
//sysnb pipe() (r int, w int, err error) //sysnb pipe() (r int, w int, err error)
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
@ -97,7 +89,7 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
if len > SizeofSockaddrAny { if len > SizeofSockaddrAny {
panic("RawSockaddrAny too small") panic("RawSockaddrAny too small")
} }
sa, err = anyToSockaddr(&rsa) sa, err = anyToSockaddr(fd, &rsa)
if err != nil { if err != nil {
Close(nfd) Close(nfd)
nfd = 0 nfd = 0
@ -105,6 +97,23 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
return return
} }
const ImplementsGetwd = true
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
func Getwd() (string, error) {
var buf [PathMax]byte
_, err := Getcwd(buf[0:])
if err != nil {
return "", err
}
n := clen(buf[:])
if n < 1 {
return "", EINVAL
}
return string(buf[:n]), nil
}
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var _p0 unsafe.Pointer var _p0 unsafe.Pointer
var bufsize uintptr var bufsize uintptr
@ -120,17 +129,15 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
return return
} }
func setattrlistTimes(path string, times []Timespec, flags int) error {
// used on Darwin for UtimesNano
return ENOSYS
}
// Derive extattr namespace and attribute name // Derive extattr namespace and attribute name
func xattrnamespace(fullattr string) (ns int, attr string, err error) { func xattrnamespace(fullattr string) (ns int, attr string, err error) {
s := -1 s := strings.IndexByte(fullattr, '.')
for idx, val := range fullattr {
if val == '.' {
s = idx
break
}
}
if s == -1 { if s == -1 {
return -1, "", ENOATTR return -1, "", ENOATTR
} }
@ -271,7 +278,6 @@ func Listxattr(file string, dest []byte) (sz int, err error) {
// FreeBSD won't allow you to list xattrs from multiple namespaces // FreeBSD won't allow you to list xattrs from multiple namespaces
s := 0 s := 0
var e error
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz) stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz)
@ -283,7 +289,6 @@ func Listxattr(file string, dest []byte) (sz int, err error) {
* we don't have read permissions on, so don't ignore those errors * we don't have read permissions on, so don't ignore those errors
*/ */
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
e = nil
continue continue
} else if e != nil { } else if e != nil {
return s, e return s, e
@ -297,7 +302,7 @@ func Listxattr(file string, dest []byte) (sz int, err error) {
d = initxattrdest(dest, s) d = initxattrdest(dest, s)
} }
return s, e return s, nil
} }
func Flistxattr(fd int, dest []byte) (sz int, err error) { func Flistxattr(fd int, dest []byte) (sz int, err error) {
@ -305,11 +310,9 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) {
destsiz := len(dest) destsiz := len(dest)
s := 0 s := 0
var e error
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz) stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz)
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
e = nil
continue continue
} else if e != nil { } else if e != nil {
return s, e return s, e
@ -323,7 +326,7 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) {
d = initxattrdest(dest, s) d = initxattrdest(dest, s)
} }
return s, e return s, nil
} }
func Llistxattr(link string, dest []byte) (sz int, err error) { func Llistxattr(link string, dest []byte) (sz int, err error) {
@ -331,11 +334,9 @@ func Llistxattr(link string, dest []byte) (sz int, err error) {
destsiz := len(dest) destsiz := len(dest)
s := 0 s := 0
var e error
for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz) stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz)
if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
e = nil
continue continue
} else if e != nil { } else if e != nil {
return s, e return s, e
@ -349,7 +350,7 @@ func Llistxattr(link string, dest []byte) (sz int, err error) {
d = initxattrdest(dest, s) d = initxattrdest(dest, s)
} }
return s, e return s, nil
} }
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
@ -391,6 +392,52 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
return &value, err return &value, err
} }
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
n = unsafe.Sizeof(uname.Nodename)
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
n = unsafe.Sizeof(uname.Release)
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
return err
}
// The version might have newlines or tabs in it, convert them to
// spaces.
for i, b := range uname.Version {
if b == '\n' || b == '\t' {
if i == len(uname.Version)-1 {
uname.Version[i] = 0
} else {
uname.Version[i] = ' '
}
}
}
mib = []_C_int{CTL_HW, HW_MACHINE}
n = unsafe.Sizeof(uname.Machine)
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
return err
}
return nil
}
/* /*
* Exposed directly * Exposed directly
*/ */
@ -431,9 +478,11 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
//sys Flock(fd int, how int) (err error) //sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error) //sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (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, stat *Statfs_t) (err error) //sys Fstatfs(fd int, stat *Statfs_t) (err error)
//sys Fsync(fd int) (err error) //sys Fsync(fd int) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sys Getdents(fd int, buf []byte) (n int, err error)
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
//sys Getdtablesize() (size int) //sys Getdtablesize() (size int)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -550,7 +599,6 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
// Searchfs // Searchfs
// Delete // Delete
// Copyfile // Copyfile
// Poll
// Watchevent // Watchevent
// Waitevent // Waitevent
// Modwatch // Modwatch

View File

@ -11,19 +11,12 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: int32(sec), Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int32(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -11,19 +11,12 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Usec = nsec % 1e9 / 1e3
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -11,19 +11,12 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = nsec / 1e9
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -148,8 +148,6 @@ func Unlink(path string) error {
//sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unlinkat(dirfd int, path string, flags int) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func Utimes(path string, tv []Timeval) error { func Utimes(path string, tv []Timeval) error {
if tv == nil { if tv == nil {
err := utimensat(AT_FDCWD, path, nil, 0) err := utimensat(AT_FDCWD, path, nil, 0)
@ -207,20 +205,14 @@ func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
} }
//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
func Futimesat(dirfd int, path string, tv []Timeval) error { func Futimesat(dirfd int, path string, tv []Timeval) error {
pathp, err := BytePtrFromString(path)
if err != nil {
return err
}
if tv == nil { if tv == nil {
return futimesat(dirfd, pathp, nil) return futimesat(dirfd, path, nil)
} }
if len(tv) != 2 { if len(tv) != 2 {
return EINVAL return EINVAL
} }
return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) return futimesat(dirfd, path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
} }
func Futimes(fd int, tv []Timeval) (err error) { func Futimes(fd int, tv []Timeval) (err error) {
@ -255,7 +247,7 @@ func Getgroups() (gids []int, err error) {
return nil, nil return nil, nil
} }
// Sanity check group count. Max is 1<<16 on Linux. // Sanity check group count. Max is 1<<16 on Linux.
if n < 0 || n > 1<<20 { if n < 0 || n > 1<<20 {
return nil, EINVAL return nil, EINVAL
} }
@ -290,8 +282,8 @@ type WaitStatus uint32
// 0x7F (stopped), or a signal number that caused an exit. // 0x7F (stopped), or a signal number that caused an exit.
// The 0x80 bit is whether there was a core dump. // The 0x80 bit is whether there was a core dump.
// An extra number (exit code, signal causing a stop) // An extra number (exit code, signal causing a stop)
// is in the high bits. At least that's the idea. // is in the high bits. At least that's the idea.
// There are various irregularities. For example, the // There are various irregularities. For example, the
// "continued" status is 0xFFFF, distinguishing itself // "continued" status is 0xFFFF, distinguishing itself
// from stopped via the core dump bit. // from stopped via the core dump bit.
@ -413,6 +405,7 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), sl, nil return unsafe.Pointer(&sa.raw), sl, nil
} }
// SockaddrLinklayer implements the Sockaddr interface for AF_PACKET type sockets.
type SockaddrLinklayer struct { type SockaddrLinklayer struct {
Protocol uint16 Protocol uint16
Ifindex int Ifindex int
@ -439,6 +432,7 @@ func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil
} }
// SockaddrNetlink implements the Sockaddr interface for AF_NETLINK type sockets.
type SockaddrNetlink struct { type SockaddrNetlink struct {
Family uint16 Family uint16
Pad uint16 Pad uint16
@ -455,6 +449,8 @@ func (sa *SockaddrNetlink) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), SizeofSockaddrNetlink, nil return unsafe.Pointer(&sa.raw), SizeofSockaddrNetlink, nil
} }
// SockaddrHCI implements the Sockaddr interface for AF_BLUETOOTH type sockets
// using the HCI protocol.
type SockaddrHCI struct { type SockaddrHCI struct {
Dev uint16 Dev uint16
Channel uint16 Channel uint16
@ -468,6 +464,72 @@ func (sa *SockaddrHCI) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), SizeofSockaddrHCI, nil return unsafe.Pointer(&sa.raw), SizeofSockaddrHCI, nil
} }
// SockaddrL2 implements the Sockaddr interface for AF_BLUETOOTH type sockets
// using the L2CAP protocol.
type SockaddrL2 struct {
PSM uint16
CID uint16
Addr [6]uint8
AddrType uint8
raw RawSockaddrL2
}
func (sa *SockaddrL2) sockaddr() (unsafe.Pointer, _Socklen, error) {
sa.raw.Family = AF_BLUETOOTH
psm := (*[2]byte)(unsafe.Pointer(&sa.raw.Psm))
psm[0] = byte(sa.PSM)
psm[1] = byte(sa.PSM >> 8)
for i := 0; i < len(sa.Addr); i++ {
sa.raw.Bdaddr[i] = sa.Addr[len(sa.Addr)-1-i]
}
cid := (*[2]byte)(unsafe.Pointer(&sa.raw.Cid))
cid[0] = byte(sa.CID)
cid[1] = byte(sa.CID >> 8)
sa.raw.Bdaddr_type = sa.AddrType
return unsafe.Pointer(&sa.raw), SizeofSockaddrL2, nil
}
// SockaddrRFCOMM implements the Sockaddr interface for AF_BLUETOOTH type sockets
// using the RFCOMM protocol.
//
// Server example:
//
// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
// _ = unix.Bind(fd, &unix.SockaddrRFCOMM{
// Channel: 1,
// Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00
// })
// _ = Listen(fd, 1)
// nfd, sa, _ := Accept(fd)
// fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd)
// Read(nfd, buf)
//
// Client example:
//
// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
// _ = Connect(fd, &SockaddrRFCOMM{
// Channel: 1,
// Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11
// })
// Write(fd, []byte(`hello`))
type SockaddrRFCOMM struct {
// Addr represents a bluetooth address, byte ordering is little-endian.
Addr [6]uint8
// Channel is a designated bluetooth channel, only 1-30 are available for use.
// Since Linux 2.6.7 and further zero value is the first available channel.
Channel uint8
raw RawSockaddrRFCOMM
}
func (sa *SockaddrRFCOMM) sockaddr() (unsafe.Pointer, _Socklen, error) {
sa.raw.Family = AF_BLUETOOTH
sa.raw.Channel = sa.Channel
sa.raw.Bdaddr = sa.Addr
return unsafe.Pointer(&sa.raw), SizeofSockaddrRFCOMM, nil
}
// SockaddrCAN implements the Sockaddr interface for AF_CAN type sockets. // SockaddrCAN implements the Sockaddr interface for AF_CAN type sockets.
// The RxID and TxID fields are used for transport protocol addressing in // The RxID and TxID fields are used for transport protocol addressing in
// (CAN_TP16, CAN_TP20, CAN_MCNET, and CAN_ISOTP), they can be left with // (CAN_TP16, CAN_TP20, CAN_MCNET, and CAN_ISOTP), they can be left with
@ -630,7 +692,7 @@ func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
} }
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
switch rsa.Addr.Family { switch rsa.Addr.Family {
case AF_NETLINK: case AF_NETLINK:
pp := (*RawSockaddrNetlink)(unsafe.Pointer(rsa)) pp := (*RawSockaddrNetlink)(unsafe.Pointer(rsa))
@ -707,6 +769,30 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
Port: pp.Port, Port: pp.Port,
} }
return sa, nil return sa, nil
case AF_BLUETOOTH:
proto, err := GetsockoptInt(fd, SOL_SOCKET, SO_PROTOCOL)
if err != nil {
return nil, err
}
// only BTPROTO_L2CAP and BTPROTO_RFCOMM can accept connections
switch proto {
case BTPROTO_L2CAP:
pp := (*RawSockaddrL2)(unsafe.Pointer(rsa))
sa := &SockaddrL2{
PSM: pp.Psm,
CID: pp.Cid,
Addr: pp.Bdaddr,
AddrType: pp.Bdaddr_type,
}
return sa, nil
case BTPROTO_RFCOMM:
pp := (*RawSockaddrRFCOMM)(unsafe.Pointer(rsa))
sa := &SockaddrRFCOMM{
Channel: pp.Channel,
Addr: pp.Bdaddr,
}
return sa, nil
}
} }
return nil, EAFNOSUPPORT return nil, EAFNOSUPPORT
} }
@ -718,7 +804,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) {
if err != nil { if err != nil {
return return
} }
sa, err = anyToSockaddr(&rsa) sa, err = anyToSockaddr(fd, &rsa)
if err != nil { if err != nil {
Close(nfd) Close(nfd)
nfd = 0 nfd = 0
@ -736,7 +822,7 @@ func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
if len > SizeofSockaddrAny { if len > SizeofSockaddrAny {
panic("RawSockaddrAny too small") panic("RawSockaddrAny too small")
} }
sa, err = anyToSockaddr(&rsa) sa, err = anyToSockaddr(fd, &rsa)
if err != nil { if err != nil {
Close(nfd) Close(nfd)
nfd = 0 nfd = 0
@ -750,20 +836,7 @@ func Getsockname(fd int) (sa Sockaddr, err error) {
if err = getsockname(fd, &rsa, &len); err != nil { if err = getsockname(fd, &rsa, &len); err != nil {
return return
} }
return anyToSockaddr(&rsa) return anyToSockaddr(fd, &rsa)
}
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
vallen := _Socklen(4)
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
return value, err
}
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
var value IPMreq
vallen := _Socklen(SizeofIPMreq)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
} }
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
@ -773,27 +846,6 @@ func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
return &value, err return &value, err
} }
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
var value IPv6Mreq
vallen := _Socklen(SizeofIPv6Mreq)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
var value IPv6MTUInfo
vallen := _Socklen(SizeofIPv6MTUInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
var value ICMPv6Filter
vallen := _Socklen(SizeofICMPv6Filter)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptUcred(fd, level, opt int) (*Ucred, error) { func GetsockoptUcred(fd, level, opt int) (*Ucred, error) {
var value Ucred var value Ucred
vallen := _Socklen(SizeofUcred) vallen := _Socklen(SizeofUcred)
@ -808,6 +860,24 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) {
return &value, err return &value, err
} }
// GetsockoptString returns the string value of the socket option opt for the
// socket associated with fd at the given socket level.
func GetsockoptString(fd, level, opt int) (string, error) {
buf := make([]byte, 256)
vallen := _Socklen(len(buf))
err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen)
if err != nil {
if err == ERANGE {
buf = make([]byte, vallen)
err = getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen)
}
if err != nil {
return "", err
}
}
return string(buf[:vallen-1]), nil
}
func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
} }
@ -926,22 +996,24 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from
msg.Namelen = uint32(SizeofSockaddrAny) msg.Namelen = uint32(SizeofSockaddrAny)
var iov Iovec var iov Iovec
if len(p) > 0 { if len(p) > 0 {
iov.Base = (*byte)(unsafe.Pointer(&p[0])) iov.Base = &p[0]
iov.SetLen(len(p)) iov.SetLen(len(p))
} }
var dummy byte var dummy byte
if len(oob) > 0 { if len(oob) > 0 {
var sockType int if len(p) == 0 {
sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE) var sockType int
if err != nil { sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE)
return if err != nil {
return
}
// receive at least one normal byte
if sockType != SOCK_DGRAM {
iov.Base = &dummy
iov.SetLen(1)
}
} }
// receive at least one normal byte msg.Control = &oob[0]
if sockType != SOCK_DGRAM && len(p) == 0 {
iov.Base = &dummy
iov.SetLen(1)
}
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
msg.SetControllen(len(oob)) msg.SetControllen(len(oob))
} }
msg.Iov = &iov msg.Iov = &iov
@ -953,7 +1025,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from
recvflags = int(msg.Flags) recvflags = int(msg.Flags)
// source address is only specified if the socket is unconnected // source address is only specified if the socket is unconnected
if rsa.Addr.Family != AF_UNSPEC { if rsa.Addr.Family != AF_UNSPEC {
from, err = anyToSockaddr(&rsa) from, err = anyToSockaddr(fd, &rsa)
} }
return return
} }
@ -974,26 +1046,28 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error)
} }
} }
var msg Msghdr var msg Msghdr
msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Name = (*byte)(ptr)
msg.Namelen = uint32(salen) msg.Namelen = uint32(salen)
var iov Iovec var iov Iovec
if len(p) > 0 { if len(p) > 0 {
iov.Base = (*byte)(unsafe.Pointer(&p[0])) iov.Base = &p[0]
iov.SetLen(len(p)) iov.SetLen(len(p))
} }
var dummy byte var dummy byte
if len(oob) > 0 { if len(oob) > 0 {
var sockType int if len(p) == 0 {
sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE) var sockType int
if err != nil { sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE)
return 0, err if err != nil {
return 0, err
}
// send at least one normal byte
if sockType != SOCK_DGRAM {
iov.Base = &dummy
iov.SetLen(1)
}
} }
// send at least one normal byte msg.Control = &oob[0]
if sockType != SOCK_DGRAM && len(p) == 0 {
iov.Base = &dummy
iov.SetLen(1)
}
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
msg.SetControllen(len(oob)) msg.SetControllen(len(oob))
} }
msg.Iov = &iov msg.Iov = &iov
@ -1023,7 +1097,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro
var buf [sizeofPtr]byte var buf [sizeofPtr]byte
// Leading edge. PEEKTEXT/PEEKDATA don't require aligned // Leading edge. PEEKTEXT/PEEKDATA don't require aligned
// access (PEEKUSER warns that it might), but if we don't // access (PEEKUSER warns that it might), but if we don't
// align our reads, we might straddle an unmapped page // align our reads, we might straddle an unmapped page
// boundary and not get the bytes leading up to the page // boundary and not get the bytes leading up to the page
@ -1125,6 +1199,10 @@ func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) {
return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data) return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data)
} }
func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) {
return ptracePoke(PTRACE_POKEUSR, PTRACE_PEEKUSR, pid, addr, data)
}
func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
} }
@ -1168,22 +1246,6 @@ func ReadDirent(fd int, buf []byte) (n int, err error) {
return Getdents(fd, buf) return Getdents(fd, buf)
} }
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
}
func direntReclen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
}
func direntNamlen(buf []byte) (uint64, bool) {
reclen, ok := direntReclen(buf)
if !ok {
return 0, false
}
return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true
}
//sys mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) //sys mount(source string, target string, fstype string, flags uintptr, data *byte) (err error)
func Mount(source string, target string, fstype string, flags uintptr, data string) (err error) { func Mount(source string, target string, fstype string, flags uintptr, data string) (err error) {
@ -1216,12 +1278,10 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
//sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
//sys Dup(oldfd int) (fd int, err error) //sys Dup(oldfd int) (fd int, err error)
//sys Dup3(oldfd int, newfd int, flags int) (err error) //sys Dup3(oldfd int, newfd int, flags int) (err error)
//sysnb EpollCreate(size int) (fd int, err error)
//sysnb EpollCreate1(flag int) (fd int, err error) //sysnb EpollCreate1(flag int) (fd int, err error)
//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
//sys Eventfd(initval uint, flags int) (fd int, err error) = SYS_EVENTFD2 //sys Eventfd(initval uint, flags int) (fd int, err error) = SYS_EVENTFD2
//sys Exit(code int) = SYS_EXIT_GROUP //sys Exit(code int) = SYS_EXIT_GROUP
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) //sys Fallocate(fd int, mode uint32, off int64, len int64) (err error)
//sys Fchdir(fd int) (err error) //sys Fchdir(fd int) (err error)
//sys Fchmod(fd int, mode uint32) (err error) //sys Fchmod(fd int, mode uint32) (err error)
@ -1259,9 +1319,11 @@ func Getpgrp() (pid int) {
//sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
//sys PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error)
//sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT
//sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 //sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64
//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) //sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error)
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) = SYS_PSELECT6
//sys read(fd int, p []byte) (n int, err error) //sys read(fd int, p []byte) (n int, err error)
//sys Removexattr(path string, attr string) (err error) //sys Removexattr(path string, attr string) (err error)
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
@ -1288,6 +1350,7 @@ func Setgid(uid int) (err error) {
//sys Setpriority(which int, who int, prio int) (err error) //sys Setpriority(which int, who int, prio int) (err error)
//sys Setxattr(path string, attr string, data []byte, flags int) (err error) //sys Setxattr(path string, attr string, data []byte, flags int) (err error)
//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error)
//sys Sync() //sys Sync()
//sys Syncfs(fd int) (err error) //sys Syncfs(fd int) (err error)
//sysnb Sysinfo(info *Sysinfo_t) (err error) //sysnb Sysinfo(info *Sysinfo_t) (err error)
@ -1298,7 +1361,6 @@ func Setgid(uid int) (err error) {
//sysnb Uname(buf *Utsname) (err error) //sysnb Uname(buf *Utsname) (err error)
//sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2 //sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2
//sys Unshare(flags int) (err error) //sys Unshare(flags int) (err error)
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sys write(fd int, p []byte) (n int, err error) //sys write(fd int, p []byte) (n int, err error)
//sys exitThread(code int) (err error) = SYS_EXIT //sys exitThread(code int) (err error) = SYS_EXIT
//sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ //sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ
@ -1348,6 +1410,17 @@ func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
return int(n), nil return int(n), nil
} }
//sys faccessat(dirfd int, path string, mode uint32) (err error)
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
if flags & ^(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 {
return EINVAL
} else if flags&(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 {
return EOPNOTSUPP
}
return faccessat(dirfd, path, mode)
}
/* /*
* Unimplemented * Unimplemented
*/ */
@ -1405,7 +1478,6 @@ func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
// Msgget // Msgget
// Msgrcv // Msgrcv
// Msgsnd // Msgsnd
// Newfstatat
// Nfsservctl // Nfsservctl
// Personality // Personality
// Pselect6 // Pselect6
@ -1426,11 +1498,9 @@ func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
// RtSigtimedwait // RtSigtimedwait
// SchedGetPriorityMax // SchedGetPriorityMax
// SchedGetPriorityMin // SchedGetPriorityMin
// SchedGetaffinity
// SchedGetparam // SchedGetparam
// SchedGetscheduler // SchedGetscheduler
// SchedRrGetInterval // SchedRrGetInterval
// SchedSetaffinity
// SchedSetparam // SchedSetparam
// SchedYield // SchedYield
// Security // Security

View File

@ -10,23 +10,15 @@
package unix package unix
import ( import (
"syscall"
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: int32(sec), Usec: int32(usec)}
tv.Sec = int32(nsec / 1e9)
tv.Usec = int32(nsec % 1e9 / 1e3)
return
} }
//sysnb pipe(p *[2]_C_int) (err error) //sysnb pipe(p *[2]_C_int) (err error)
@ -58,9 +50,12 @@ func Pipe2(p []int, flags int) (err error) {
// 64-bit file system and 32-bit uid calls // 64-bit file system and 32-bit uid calls
// (386 default is 32-bit file system and 16-bit uid). // (386 default is 32-bit file system and 16-bit uid).
//sys Dup2(oldfd int, newfd int) (err error) //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_64 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64
//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //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 Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
//sysnb Getegid() (egid int) = SYS_GETEGID32 //sysnb Getegid() (egid int) = SYS_GETEGID32
//sysnb Geteuid() (euid int) = SYS_GETEUID32 //sysnb Geteuid() (euid int) = SYS_GETEUID32
@ -84,12 +79,12 @@ func Pipe2(p []int, flags int) (err error) {
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
//sys SyncFileRange(fd int, off int64, n int64, flags 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 Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32 //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32 //sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) //sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Pause() (err error) //sys Pause() (err error)
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
@ -163,10 +158,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) {
return setrlimit(resource, &rl) return setrlimit(resource, &rl)
} }
// 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 Seek(fd int, offset int64, whence int) (newoffset int64, err error) { func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
newoffset, errno := seek(fd, offset, whence) newoffset, errno := seek(fd, offset, whence)
if errno != 0 { if errno != 0 {
@ -175,17 +166,17 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
return newoffset, nil return newoffset, nil
} }
// Vsyscalls on amd64. //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
//sysnb Time(t *Time_t) (tt Time_t, err error) //sysnb Time(t *Time_t) (tt Time_t, err error)
//sys Utime(path string, buf *Utimbuf) (err error) //sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
// On x86 Linux, all the socket calls go through an extra indirection, // On x86 Linux, all the socket calls go through an extra indirection,
// I think because the 5-register system call interface can't handle // I think because the 5-register system call interface can't handle
// the 6-argument calls like sendto and recvfrom. Instead the // the 6-argument calls like sendto and recvfrom. Instead the
// arguments to the underlying system call are the number below // arguments to the underlying system call are the number below
// and a pointer to an array of uintptr. We hide the pointer in the // and a pointer to an array of uintptr. We hide the pointer in the
// socketcall assembly to avoid allocation on every system call. // socketcall assembly to avoid allocation on every system call.
const ( const (
@ -212,9 +203,6 @@ const (
_SENDMMSG = 20 _SENDMMSG = 20
) )
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)
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
if e != 0 { if e != 0 {

View File

@ -7,10 +7,12 @@
package unix package unix
//sys Dup2(oldfd int, newfd int) (err error) //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 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 Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (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_NEWFSTATAT
//sys Fstatfs(fd int, buf *Statfs_t) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -28,7 +30,15 @@ package unix
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //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 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 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)
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 sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
//sys Setfsgid(gid int) (err error) //sys Setfsgid(gid int) (err error)
//sys Setfsuid(uid int) (err error) //sys Setfsuid(uid int) (err error)
@ -39,10 +49,16 @@ package unix
//sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error)
//sys Shutdown(fd int, how 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 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)
func Stat(path string, stat *Stat_t) (err error) {
// Use fstatat, because Android's seccomp policy blocks stat.
return Fstatat(AT_FDCWD, path, stat, 0)
}
//sys Statfs(path string, buf *Statfs_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error)
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
//sys Truncate(path string, length int64) (err error) //sys Truncate(path string, length int64) (err error)
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, 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 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 bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
@ -61,6 +77,8 @@ package unix
//sys sendmsg(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) //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
func Gettimeofday(tv *Timeval) (err error) { func Gettimeofday(tv *Timeval) (err error) {
errno := gettimeofday(tv) errno := gettimeofday(tv)
if errno != 0 { if errno != 0 {
@ -82,20 +100,14 @@ func Time(t *Time_t) (tt Time_t, err error) {
} }
//sys Utime(path string, buf *Utimbuf) (err error) //sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Sec = nsec / 1e9
tv.Usec = nsec % 1e9 / 1e3
return
} }
//sysnb pipe(p *[2]_C_int) (err error) //sysnb pipe(p *[2]_C_int) (err error)

View File

@ -11,19 +11,12 @@ import (
"unsafe" "unsafe"
) )
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: int32(sec), Usec: int32(usec)}
tv.Sec = int32(nsec / 1e9)
tv.Usec = int32(nsec % 1e9 / 1e3)
return
} }
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
@ -82,8 +75,11 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
// 64-bit file system and 32-bit uid calls // 64-bit file system and 32-bit uid calls
// (16-bit uid calls are not always supported in newer kernels) // (16-bit uid calls are not always supported in newer kernels)
//sys Dup2(oldfd int, newfd int) (err error) //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 Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //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
//sysnb Getegid() (egid int) = SYS_GETEGID32 //sysnb Getegid() (egid int) = SYS_GETEGID32
//sysnb Geteuid() (euid int) = SYS_GETEUID32 //sysnb Geteuid() (euid int) = SYS_GETEUID32
//sysnb Getgid() (gid int) = SYS_GETGID32 //sysnb Getgid() (gid int) = SYS_GETGID32
@ -92,6 +88,7 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
//sys Listen(s int, n int) (err error) //sys Listen(s int, n int) (err error)
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
//sys Pause() (err error)
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32 //sys Setfsgid(gid int) (err error) = SYS_SETFSGID32
@ -103,11 +100,10 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
//sys Shutdown(fd int, how 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 Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
// Vsyscalls on amd64. //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Pause() (err error)
func Time(t *Time_t) (Time_t, error) { func Time(t *Time_t) (Time_t, error) {
var tv Timeval var tv Timeval
@ -129,6 +125,8 @@ func Utime(path string, buf *Utimbuf) error {
return Utimes(path, tv) return Utimes(path, tv)
} }
//sys utimes(path string, times *[2]Timeval) (err error)
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //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 Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64

View File

@ -6,7 +6,17 @@
package unix 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 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 Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (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 Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
@ -21,7 +31,15 @@ package unix
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //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 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 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_PSELECT6
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 sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
//sys Setfsgid(gid int) (err error) //sys Setfsgid(gid int) (err error)
//sys Setfsuid(uid int) (err error) //sys Setfsuid(uid int) (err error)
@ -48,6 +66,11 @@ func Lstat(path string, stat *Stat_t) (err error) {
//sys Statfs(path string, buf *Statfs_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error)
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
//sys Truncate(path string, length int64) (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 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 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 bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
@ -68,19 +91,24 @@ func Lstat(path string, stat *Stat_t) (err error) {
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Sec = nsec / 1e9 }
tv.Usec = nsec % 1e9 / 1e3
return 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) { func Time(t *Time_t) (Time_t, error) {
@ -103,6 +131,18 @@ func Utime(path string, buf *Utimbuf) error {
return Utimes(path, tv) 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) { func Pipe(p []int) (err error) {
if len(p) != 2 { if len(p) != 2 {
return EINVAL return EINVAL
@ -159,22 +199,6 @@ func Pause() (err error) {
return return
} }
// TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove
// these when the deprecated syscalls that the syscall package relies on
// are removed.
const (
SYS_GETPGRP = 1060
SYS_UTIMES = 1037
SYS_FUTIMESAT = 1066
SYS_PAUSE = 1061
SYS_USTAT = 1070
SYS_UTIME = 1063
SYS_LCHOWN = 1032
SYS_TIME = 1062
SYS_EPOLL_CREATE = 1042
SYS_EPOLL_WAIT = 1069
)
func Poll(fds []PollFd, timeout int) (n int, err error) { func Poll(fds []PollFd, timeout int) (n int, err error) {
var ts *Timespec var ts *Timespec
if timeout >= 0 { if timeout >= 0 {

14
vendor/golang.org/x/sys/unix/syscall_linux_gc.go generated vendored Normal file
View File

@ -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)

16
vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go generated vendored Normal file
View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -8,8 +8,11 @@
package unix package unix
//sys Dup2(oldfd int, newfd int) (err error) //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 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 Fchown(fd int, uid int, gid int) (err error)
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
//sys Fstatfs(fd int, buf *Statfs_t) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -23,7 +26,15 @@ package unix
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //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 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 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_PSELECT6
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 sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
//sys Setfsgid(gid int) (err error) //sys Setfsgid(gid int) (err error)
//sys Setfsuid(uid int) (err error) //sys Setfsuid(uid int) (err error)
@ -37,6 +48,7 @@ package unix
//sys Statfs(path string, buf *Statfs_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error)
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
//sys Truncate(path string, length int64) (err error) //sys Truncate(path string, length int64) (err error)
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, 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 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 bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
@ -55,6 +67,7 @@ package unix
//sys sendmsg(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) //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
func Time(t *Time_t) (tt Time_t, err error) { func Time(t *Time_t) (tt Time_t, err error) {
@ -70,20 +83,14 @@ func Time(t *Time_t) (tt Time_t, err error) {
} }
//sys Utime(path string, buf *Utimbuf) (err error) //sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Sec = nsec / 1e9
tv.Usec = nsec % 1e9 / 1e3
return
} }
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {

View File

@ -15,6 +15,9 @@ import (
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 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) //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 Fchown(fd int, uid int, gid int) (err error)
//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -32,13 +35,12 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr,
//sysnb Setregid(rgid int, egid int) (err error) //sysnb Setregid(rgid int, egid int) (err error)
//sysnb Setresgid(rgid int, egid int, sgid int) (err error) //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setresuid(ruid int, euid int, suid int) (err error)
//sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error)
//sys Shutdown(fd int, how 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 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 SyncFileRange(fd int, off int64, n int64, flags int) (err error)
//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 //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 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 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 bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
@ -60,15 +62,17 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr,
//sys Ioperm(from int, num int, on int) (err error) //sys Ioperm(from int, num int, on int) (err error)
//sys Iopl(level 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 Gettimeofday(tv *Timeval) (err error)
//sysnb Time(t *Time_t) (tt Time_t, 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 Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //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 Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
//sys Utime(path string, buf *Utimbuf) (err error)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Pause() (err error) //sys Pause() (err error)
func Fstatfs(fd int, buf *Statfs_t) (err error) { func Fstatfs(fd int, buf *Statfs_t) (err error) {
@ -99,19 +103,12 @@ func Seek(fd int, offset int64, whence int) (off int64, err error) {
return return
} }
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: int32(sec), Usec: int32(usec)}
tv.Sec = int32(nsec / 1e9)
tv.Usec = int32(nsec % 1e9 / 1e3)
return
} }
//sysnb pipe2(p *[2]_C_int, flags int) (err error) //sysnb pipe2(p *[2]_C_int, flags int) (err error)

View File

@ -7,10 +7,13 @@
package unix package unix
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys Dup2(oldfd int, newfd int) (err error) //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 Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (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_NEWFSTATAT
//sys Fstatfs(fd int, buf *Statfs_t) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -43,6 +46,7 @@ package unix
//sys Statfs(path string, buf *Statfs_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error)
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
//sys Truncate(path string, length int64) (err error) //sys Truncate(path string, length int64) (err error)
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, 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 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 bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
@ -61,24 +65,18 @@ package unix
//sys sendmsg(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) //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
//sysnb Time(t *Time_t) (tt Time_t, err error) //sysnb Time(t *Time_t) (tt Time_t, err error)
//sys Utime(path string, buf *Utimbuf) (err error) //sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Sec = nsec / 1e9
tv.Usec = nsec % 1e9 / 1e3
return
} }
func (r *PtraceRegs) PC() uint64 { return r.Nip } func (r *PtraceRegs) PC() uint64 { return r.Nip }

View File

@ -11,10 +11,12 @@ import (
) )
//sys Dup2(oldfd int, newfd int) (err error) //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 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 Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (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_NEWFSTATAT
//sys Fstatfs(fd int, buf *Statfs_t) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -43,9 +45,11 @@ import (
//sys Statfs(path string, buf *Statfs_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error)
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
//sys Truncate(path string, length int64) (err error) //sys Truncate(path string, length int64) (err error)
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
//sysnb setgroups(n int, list *_Gid_t) (err error) //sysnb setgroups(n int, list *_Gid_t) (err error)
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
func Time(t *Time_t) (tt Time_t, err error) { func Time(t *Time_t) (tt Time_t, err error) {
@ -61,20 +65,14 @@ func Time(t *Time_t) (tt Time_t, err error) {
} }
//sys Utime(path string, buf *Utimbuf) (err error) //sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Sec = nsec / 1e9
tv.Usec = nsec % 1e9 / 1e3
return
} }
//sysnb pipe2(p *[2]_C_int, flags int) (err error) //sysnb pipe2(p *[2]_C_int, flags int) (err error)

View File

@ -7,9 +7,11 @@
package unix package unix
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n 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 Dup2(oldfd int, newfd int) (err error) //sys Dup2(oldfd int, newfd int) (err error)
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Fstat(fd int, stat *Stat_t) (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 Fstatfs(fd int, buf *Statfs_t) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -66,6 +68,7 @@ func Iopl(level int) (err error) {
return ENOSYS return ENOSYS
} }
//sys futimesat(dirfd int, path string, times *[2]Timeval) (err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
func Time(t *Time_t) (tt Time_t, err error) { func Time(t *Time_t) (tt Time_t, err error) {
@ -81,20 +84,14 @@ func Time(t *Time_t) (tt Time_t, err error) {
} }
//sys Utime(path string, buf *Utimbuf) (err error) //sys Utime(path string, buf *Utimbuf) (err error)
//sys utimes(path string, times *[2]Timeval) (err error)
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Sec = nsec / 1e9
tv.Usec = int32(nsec % 1e9 / 1e3)
return
} }
func (r *PtraceRegs) PC() uint64 { return r.Tpc } func (r *PtraceRegs) PC() uint64 { return r.Tpc }

View File

@ -17,6 +17,7 @@ import (
"unsafe" "unsafe"
) )
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct { type SockaddrDatalink struct {
Len uint8 Len uint8
Family uint8 Family uint8
@ -55,7 +56,6 @@ func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
} }
func nametomib(name string) (mib []_C_int, err error) { func nametomib(name string) (mib []_C_int, err error) {
// Split name into components. // Split name into components.
var parts []string var parts []string
last := 0 last := 0
@ -93,18 +93,6 @@ func nametomib(name string) (mib []_C_int, err error) {
return mib, nil return mib, nil
} }
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
}
func direntReclen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
}
func direntNamlen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
}
//sysnb pipe() (fd1 int, fd2 int, err error) //sysnb pipe() (fd1 int, fd2 int, err error)
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
if len(p) != 2 { if len(p) != 2 {
@ -119,11 +107,118 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
return getdents(fd, buf) return getdents(fd, buf)
} }
const ImplementsGetwd = true
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
func Getwd() (string, error) {
var buf [PathMax]byte
_, err := Getcwd(buf[0:])
if err != nil {
return "", err
}
n := clen(buf[:])
if n < 1 {
return "", EINVAL
}
return string(buf[:n]), nil
}
// TODO // TODO
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
return -1, ENOSYS return -1, ENOSYS
} }
func setattrlistTimes(path string, times []Timespec, flags int) error {
// used on Darwin for UtimesNano
return ENOSYS
}
//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
}
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
n = unsafe.Sizeof(uname.Nodename)
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
n = unsafe.Sizeof(uname.Release)
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
return err
}
// The version might have newlines or tabs in it, convert them to
// spaces.
for i, b := range uname.Version {
if b == '\n' || b == '\t' {
if i == len(uname.Version)-1 {
uname.Version[i] = 0
} else {
uname.Version[i] = ' '
}
}
}
mib = []_C_int{CTL_HW, HW_MACHINE}
n = unsafe.Sizeof(uname.Machine)
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
return err
}
return nil
}
/* /*
* Exposed directly * Exposed directly
*/ */
@ -138,13 +233,17 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys Dup(fd int) (nfd int, err error) //sys Dup(fd int) (nfd int, err error)
//sys Dup2(from int, to int) (err error) //sys Dup2(from int, to int) (err error)
//sys Exit(code int) //sys Exit(code int)
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
//sys Fchdir(fd int) (err error) //sys Fchdir(fd int) (err error)
//sys Fchflags(fd int, flags int) (err error) //sys Fchflags(fd int, flags int) (err error)
//sys Fchmod(fd int, mode uint32) (err error) //sys Fchmod(fd int, mode uint32) (err error)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Flock(fd int, how int) (err error) //sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error) //sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (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 Fsync(fd int) (err error) //sys Fsync(fd int) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
//sysnb Getegid() (egid int) //sysnb Getegid() (egid int)
@ -225,7 +324,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
// __msync13 // __msync13
// __ntp_gettime30 // __ntp_gettime30
// __posix_chown // __posix_chown
// __posix_fadvise50
// __posix_fchown // __posix_fchown
// __posix_lchown // __posix_lchown
// __posix_rename // __posix_rename
@ -384,7 +482,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
// getitimer // getitimer
// getvfsstat // getvfsstat
// getxattr // getxattr
// ioctl
// ktrace // ktrace
// lchflags // lchflags
// lchmod // lchmod
@ -422,7 +519,6 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
// ntp_adjtime // ntp_adjtime
// pmc_control // pmc_control
// pmc_get_info // pmc_get_info
// poll
// pollts // pollts
// preadv // preadv
// profil // profil

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int64(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int64(nsec / 1e9)
ts.Nsec = int64(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int64(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -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 }

View File

@ -13,10 +13,12 @@
package unix package unix
import ( import (
"sort"
"syscall" "syscall"
"unsafe" "unsafe"
) )
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct { type SockaddrDatalink struct {
Len uint8 Len uint8
Family uint8 Family uint8
@ -32,39 +34,15 @@ type SockaddrDatalink struct {
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
func nametomib(name string) (mib []_C_int, err error) { func nametomib(name string) (mib []_C_int, err error) {
i := sort.Search(len(sysctlMib), func(i int) bool {
// Perform lookup via a binary search return sysctlMib[i].ctlname >= name
left := 0 })
right := len(sysctlMib) - 1 if i < len(sysctlMib) && sysctlMib[i].ctlname == name {
for { return sysctlMib[i].ctloid, nil
idx := left + (right-left)/2
switch {
case name == sysctlMib[idx].ctlname:
return sysctlMib[idx].ctloid, nil
case name > sysctlMib[idx].ctlname:
left = idx + 1
default:
right = idx - 1
}
if left > right {
break
}
} }
return nil, EINVAL return nil, EINVAL
} }
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
}
func direntReclen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
}
func direntNamlen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
}
//sysnb pipe(p *[2]_C_int) (err error) //sysnb pipe(p *[2]_C_int) (err error)
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
if len(p) != 2 { if len(p) != 2 {
@ -82,6 +60,23 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
return getdents(fd, buf) return getdents(fd, buf)
} }
const ImplementsGetwd = true
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
func Getwd() (string, error) {
var buf [PathMax]byte
_, err := Getcwd(buf[0:])
if err != nil {
return "", err
}
n := clen(buf[:])
if n < 1 {
return "", EINVAL
}
return string(buf[:n]), nil
}
// TODO // TODO
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
return -1, ENOSYS return -1, ENOSYS
@ -102,6 +97,96 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
return return
} }
func setattrlistTimes(path string, times []Timespec, flags int) error {
// used on Darwin for UtimesNano
return ENOSYS
}
//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
}
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
n = unsafe.Sizeof(uname.Nodename)
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
n = unsafe.Sizeof(uname.Release)
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
return err
}
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
return err
}
// The version might have newlines or tabs in it, convert them to
// spaces.
for i, b := range uname.Version {
if b == '\n' || b == '\t' {
if i == len(uname.Version)-1 {
uname.Version[i] = 0
} else {
uname.Version[i] = ' '
}
}
}
mib = []_C_int{CTL_HW, HW_MACHINE}
n = unsafe.Sizeof(uname.Machine)
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
return err
}
return nil
}
/* /*
* Exposed directly * Exposed directly
*/ */
@ -116,13 +201,16 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
//sys Dup(fd int) (nfd int, err error) //sys Dup(fd int) (nfd int, err error)
//sys Dup2(from int, to int) (err error) //sys Dup2(from int, to int) (err error)
//sys Exit(code int) //sys Exit(code int)
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchdir(fd int) (err error) //sys Fchdir(fd int) (err error)
//sys Fchflags(fd int, flags int) (err error) //sys Fchflags(fd int, flags int) (err error)
//sys Fchmod(fd int, mode uint32) (err error) //sys Fchmod(fd int, mode uint32) (err error)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Flock(fd int, how int) (err error) //sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error) //sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (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, stat *Statfs_t) (err error) //sys Fstatfs(fd int, stat *Statfs_t) (err error)
//sys Fsync(fd int) (err error) //sys Fsync(fd int) (err error)
//sys Ftruncate(fd int, length int64) (err error) //sys Ftruncate(fd int, length int64) (err error)
@ -135,6 +223,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
//sysnb Getppid() (ppid int) //sysnb Getppid() (ppid int)
//sys Getpriority(which int, who int) (prio int, err error) //sys Getpriority(which int, who int) (prio int, err error)
//sysnb Getrlimit(which int, lim *Rlimit) (err error) //sysnb Getrlimit(which int, lim *Rlimit) (err error)
//sysnb Getrtable() (rtable int, err error)
//sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Getrusage(who int, rusage *Rusage) (err error)
//sysnb Getsid(pid int) (sid int, err error) //sysnb Getsid(pid int) (sid int, err error)
//sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Gettimeofday(tv *Timeval) (err error)
@ -172,6 +261,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
//sysnb Setresgid(rgid int, egid int, sgid int) (err error) //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setresuid(ruid int, euid int, suid int) (err error)
//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setrlimit(which int, lim *Rlimit) (err error)
//sysnb Setrtable(rtable int) (err error)
//sysnb Setsid() (pid int, err error) //sysnb Setsid() (pid int, err error)
//sysnb Settimeofday(tp *Timeval) (err error) //sysnb Settimeofday(tp *Timeval) (err error)
//sysnb Setuid(uid int) (err error) //sysnb Setuid(uid int) (err error)
@ -220,9 +310,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
// getlogin // getlogin
// getresgid // getresgid
// getresuid // getresuid
// getrtable
// getthrid // getthrid
// ioctl
// ktrace // ktrace
// lfs_bmapv // lfs_bmapv
// lfs_markv // lfs_markv
@ -243,7 +331,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
// nfssvc // nfssvc
// nnpfspioctl // nnpfspioctl
// openat // openat
// poll
// preadv // preadv
// profil // profil
// pwritev // pwritev
@ -258,7 +345,6 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
// semop // semop
// setgroups // setgroups
// setitimer // setitimer
// setrtable
// setsockopt // setsockopt
// shmat // shmat
// shmctl // shmctl

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int64(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Usec = nsec % 1e9 / 1e3
tv.Sec = nsec / 1e9
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {
@ -38,3 +31,7 @@ func (msghdr *Msghdr) SetControllen(length int) {
func (cmsg *Cmsghdr) SetLen(length int) { func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length) cmsg.Len = uint32(length)
} }
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of openbsd/amd64 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: int32(nsec)}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int64(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9)
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: int32(usec)}
tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9)
return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {

View File

@ -23,6 +23,7 @@ type syscallFunc uintptr
func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct { type SockaddrDatalink struct {
Family uint16 Family uint16
Index uint16 Index uint16
@ -34,31 +35,6 @@ type SockaddrDatalink struct {
raw RawSockaddrDatalink raw RawSockaddrDatalink
} }
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
if n[i] == 0 {
return i
}
}
return len(n)
}
func direntIno(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
}
func direntReclen(buf []byte) (uint64, bool) {
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
}
func direntNamlen(buf []byte) (uint64, bool) {
reclen, ok := direntReclen(buf)
if !ok {
return 0, false
}
return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true
}
//sysnb pipe(p *[2]_C_int) (n int, err error) //sysnb pipe(p *[2]_C_int) (n int, err error)
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
@ -136,7 +112,19 @@ func Getsockname(fd int) (sa Sockaddr, err error) {
if err = getsockname(fd, &rsa, &len); err != nil { if err = getsockname(fd, &rsa, &len); err != nil {
return return
} }
return anyToSockaddr(&rsa) return anyToSockaddr(fd, &rsa)
}
// GetsockoptString returns the string value of the socket option opt for the
// socket associated with fd at the given socket level.
func GetsockoptString(fd, level, opt int) (string, error) {
buf := make([]byte, 256)
vallen := _Socklen(len(buf))
err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen)
if err != nil {
return "", err
}
return string(buf[:vallen-1]), nil
} }
const ImplementsGetwd = true const ImplementsGetwd = true
@ -166,7 +154,7 @@ func Getwd() (wd string, err error) {
func Getgroups() (gids []int, err error) { func Getgroups() (gids []int, err error) {
n, err := getgroups(0, nil) n, err := getgroups(0, nil)
// Check for error and sanity check group count. Newer versions of // Check for error and sanity check group count. Newer versions of
// Solaris allow up to 1024 (NGROUPS_MAX). // Solaris allow up to 1024 (NGROUPS_MAX).
if n < 0 || n > 1024 { if n < 0 || n > 1024 {
if err != nil { if err != nil {
@ -324,6 +312,16 @@ func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
//sys fcntl(fd int, cmd int, arg int) (val int, err error) //sys fcntl(fd int, cmd int, arg int) (val int, err error)
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
valptr, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
var err error
if errno != 0 {
err = errno
}
return int(valptr), err
}
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0)
@ -350,7 +348,7 @@ func Futimesat(dirfd int, path string, tv []Timeval) error {
} }
// Solaris doesn't have an futimes function because it allows NULL to be // Solaris doesn't have an futimes function because it allows NULL to be
// specified as the path for futimesat. However, Go doesn't like // specified as the path for futimesat. However, Go doesn't like
// NULL-style string interfaces, so this simple wrapper is provided. // NULL-style string interfaces, so this simple wrapper is provided.
func Futimes(fd int, tv []Timeval) error { func Futimes(fd int, tv []Timeval) error {
if tv == nil { if tv == nil {
@ -362,7 +360,7 @@ func Futimes(fd int, tv []Timeval) error {
return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
} }
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
switch rsa.Addr.Family { switch rsa.Addr.Family {
case AF_UNIX: case AF_UNIX:
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
@ -413,7 +411,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) {
if nfd == -1 { if nfd == -1 {
return return
} }
sa, err = anyToSockaddr(&rsa) sa, err = anyToSockaddr(fd, &rsa)
if err != nil { if err != nil {
Close(nfd) Close(nfd)
nfd = 0 nfd = 0
@ -450,7 +448,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from
oobn = int(msg.Accrightslen) oobn = int(msg.Accrightslen)
// source address is only specified if the socket is unconnected // source address is only specified if the socket is unconnected
if rsa.Addr.Family != AF_UNSPEC { if rsa.Addr.Family != AF_UNSPEC {
from, err = anyToSockaddr(&rsa) from, err = anyToSockaddr(fd, &rsa)
} }
return return
} }
@ -578,6 +576,15 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) {
return &value, err return &value, err
} }
//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)
}
/* /*
* Exposed directly * Exposed directly
*/ */
@ -592,15 +599,17 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) {
//sys Dup(fd int) (nfd int, err error) //sys Dup(fd int) (nfd int, err error)
//sys Dup2(oldfd int, newfd int) (err error) //sys Dup2(oldfd int, newfd int) (err error)
//sys Exit(code int) //sys Exit(code int)
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchdir(fd int) (err error) //sys Fchdir(fd int) (err error)
//sys Fchmod(fd int, mode uint32) (err error) //sys Fchmod(fd int, mode uint32) (err error)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchown(fd int, uid int, gid int) (err error) //sys Fchown(fd int, uid int, gid int) (err error)
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
//sys Fdatasync(fd int) (err error) //sys Fdatasync(fd int) (err error)
//sys Flock(fd int, how int) (err error) //sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error) //sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (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 Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) //sys Fstatvfs(fd int, vfsstat *Statvfs_t) (err error)
//sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) //sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error)
//sysnb Getgid() (gid int) //sysnb Getgid() (gid int)
@ -646,6 +655,7 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) {
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
//sys Rmdir(path string) (err error) //sys Rmdir(path string) (err error)
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
//sysnb Setegid(egid int) (err error) //sysnb Setegid(egid int) (err error)
//sysnb Seteuid(euid int) (err error) //sysnb Seteuid(euid int) (err error)
//sysnb Setgid(gid int) (err error) //sysnb Setgid(gid int) (err error)
@ -677,6 +687,7 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) {
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_connect //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_connect
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
//sys munmap(addr uintptr, length uintptr) (err error) //sys munmap(addr uintptr, length uintptr) (err error)
//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = libsendfile.sendfile
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_sendto //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_sendto
//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.__xnet_socket //sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.__xnet_socket
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.__xnet_socketpair //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.__xnet_socketpair

View File

@ -6,19 +6,12 @@
package unix package unix
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = nsec / 1e9
ts.Nsec = nsec % 1e9
return
} }
func NsecToTimeval(nsec int64) (tv Timeval) { func setTimeval(sec, usec int64) Timeval {
nsec += 999 // round up to microsecond return Timeval{Sec: sec, Usec: usec}
tv.Usec = nsec % 1e9 / 1e3
tv.Sec = int64(nsec / 1e9)
return
} }
func (iov *Iovec) SetLen(length int) { func (iov *Iovec) SetLen(length int) {
@ -28,8 +21,3 @@ func (iov *Iovec) SetLen(length int) {
func (cmsg *Cmsghdr) SetLen(length int) { func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length) cmsg.Len = uint32(length)
} }
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
// TODO(aram): implement this, see issue 5847.
panic("unimplemented")
}

View File

@ -7,7 +7,9 @@
package unix package unix
import ( import (
"bytes"
"runtime" "runtime"
"sort"
"sync" "sync"
"syscall" "syscall"
"unsafe" "unsafe"
@ -50,6 +52,37 @@ func errnoErr(e syscall.Errno) error {
return e return e
} }
// ErrnoName returns the error name for error number e.
func ErrnoName(e syscall.Errno) string {
i := sort.Search(len(errorList), func(i int) bool {
return errorList[i].num >= e
})
if i < len(errorList) && errorList[i].num == e {
return errorList[i].name
}
return ""
}
// SignalName returns the signal name for signal number s.
func SignalName(s syscall.Signal) string {
i := sort.Search(len(signalList), func(i int) bool {
return signalList[i].num >= s
})
if i < len(signalList) && signalList[i].num == s {
return signalList[i].name
}
return ""
}
// clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte.
func clen(n []byte) int {
i := bytes.IndexByte(n, 0)
if i == -1 {
i = len(n)
}
return i
}
// Mmap manager, for use by operating system-specific implementations. // Mmap manager, for use by operating system-specific implementations.
type mmapper struct { type mmapper struct {
@ -138,16 +171,19 @@ func Write(fd int, p []byte) (n int, err error) {
// creation of IPv6 sockets to return EAFNOSUPPORT. // creation of IPv6 sockets to return EAFNOSUPPORT.
var SocketDisableIPv6 bool var SocketDisableIPv6 bool
// Sockaddr represents a socket address.
type Sockaddr interface { type Sockaddr interface {
sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
} }
// SockaddrInet4 implements the Sockaddr interface for AF_INET type sockets.
type SockaddrInet4 struct { type SockaddrInet4 struct {
Port int Port int
Addr [4]byte Addr [4]byte
raw RawSockaddrInet4 raw RawSockaddrInet4
} }
// SockaddrInet6 implements the Sockaddr interface for AF_INET6 type sockets.
type SockaddrInet6 struct { type SockaddrInet6 struct {
Port int Port int
ZoneId uint32 ZoneId uint32
@ -155,6 +191,7 @@ type SockaddrInet6 struct {
raw RawSockaddrInet6 raw RawSockaddrInet6
} }
// SockaddrUnix implements the Sockaddr interface for AF_UNIX type sockets.
type SockaddrUnix struct { type SockaddrUnix struct {
Name string Name string
raw RawSockaddrUnix raw RawSockaddrUnix
@ -182,7 +219,14 @@ func Getpeername(fd int) (sa Sockaddr, err error) {
if err = getpeername(fd, &rsa, &len); err != nil { if err = getpeername(fd, &rsa, &len); err != nil {
return return
} }
return anyToSockaddr(&rsa) return anyToSockaddr(fd, &rsa)
}
func GetsockoptByte(fd, level, opt int) (value byte, err error) {
var n byte
vallen := _Socklen(1)
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
return n, err
} }
func GetsockoptInt(fd, level, opt int) (value int, err error) { func GetsockoptInt(fd, level, opt int) (value int, err error) {
@ -192,6 +236,54 @@ func GetsockoptInt(fd, level, opt int) (value int, err error) {
return int(n), err return int(n), err
} }
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
vallen := _Socklen(4)
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
return value, err
}
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
var value IPMreq
vallen := _Socklen(SizeofIPMreq)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
var value IPv6Mreq
vallen := _Socklen(SizeofIPv6Mreq)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
var value IPv6MTUInfo
vallen := _Socklen(SizeofIPv6MTUInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
var value ICMPv6Filter
vallen := _Socklen(SizeofICMPv6Filter)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptLinger(fd, level, opt int) (*Linger, error) {
var linger Linger
vallen := _Socklen(SizeofLinger)
err := getsockopt(fd, level, opt, unsafe.Pointer(&linger), &vallen)
return &linger, err
}
func GetsockoptTimeval(fd, level, opt int) (*Timeval, error) {
var tv Timeval
vallen := _Socklen(unsafe.Sizeof(tv))
err := getsockopt(fd, level, opt, unsafe.Pointer(&tv), &vallen)
return &tv, err
}
func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
var rsa RawSockaddrAny var rsa RawSockaddrAny
var len _Socklen = SizeofSockaddrAny var len _Socklen = SizeofSockaddrAny
@ -199,7 +291,7 @@ func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
return return
} }
if rsa.Addr.Family != AF_UNSPEC { if rsa.Addr.Family != AF_UNSPEC {
from, err = anyToSockaddr(&rsa) from, err = anyToSockaddr(fd, &rsa)
} }
return return
} }
@ -291,3 +383,12 @@ func SetNonblock(fd int, nonblocking bool) (err error) {
_, err = fcntl(fd, F_SETFL, flag) _, err = fcntl(fd, F_SETFL, flag)
return err return err
} }
// Exec calls execve(2), which replaces the calling executable in the process
// tree. argv0 should be the full path to an executable ("/bin/ls") and the
// executable name should also be the first argument in argv (["ls", "-l"]).
// envv are the environment variables that should be passed to the new
// process (["USER=go", "PWD=/tmp"]).
func Exec(argv0 string, argv []string, envv []string) error {
return syscall.Exec(argv0, argv, envv)
}

82
vendor/golang.org/x/sys/unix/timestruct.go generated vendored Normal file
View File

@ -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 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
}

View File

@ -49,6 +49,86 @@ const (
AF_UNSPEC = 0x0 AF_UNSPEC = 0x0
AF_UTUN = 0x26 AF_UTUN = 0x26
ALTWERASE = 0x200 ALTWERASE = 0x200
ATTR_BIT_MAP_COUNT = 0x5
ATTR_CMN_ACCESSMASK = 0x20000
ATTR_CMN_ACCTIME = 0x1000
ATTR_CMN_ADDEDTIME = 0x10000000
ATTR_CMN_BKUPTIME = 0x2000
ATTR_CMN_CHGTIME = 0x800
ATTR_CMN_CRTIME = 0x200
ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000
ATTR_CMN_DEVID = 0x2
ATTR_CMN_DOCUMENT_ID = 0x100000
ATTR_CMN_ERROR = 0x20000000
ATTR_CMN_EXTENDED_SECURITY = 0x400000
ATTR_CMN_FILEID = 0x2000000
ATTR_CMN_FLAGS = 0x40000
ATTR_CMN_FNDRINFO = 0x4000
ATTR_CMN_FSID = 0x4
ATTR_CMN_FULLPATH = 0x8000000
ATTR_CMN_GEN_COUNT = 0x80000
ATTR_CMN_GRPID = 0x10000
ATTR_CMN_GRPUUID = 0x1000000
ATTR_CMN_MODTIME = 0x400
ATTR_CMN_NAME = 0x1
ATTR_CMN_NAMEDATTRCOUNT = 0x80000
ATTR_CMN_NAMEDATTRLIST = 0x100000
ATTR_CMN_OBJID = 0x20
ATTR_CMN_OBJPERMANENTID = 0x40
ATTR_CMN_OBJTAG = 0x10
ATTR_CMN_OBJTYPE = 0x8
ATTR_CMN_OWNERID = 0x8000
ATTR_CMN_PARENTID = 0x4000000
ATTR_CMN_PAROBJID = 0x80
ATTR_CMN_RETURNED_ATTRS = 0x80000000
ATTR_CMN_SCRIPT = 0x100
ATTR_CMN_SETMASK = 0x41c7ff00
ATTR_CMN_USERACCESS = 0x200000
ATTR_CMN_UUID = 0x800000
ATTR_CMN_VALIDMASK = 0xffffffff
ATTR_CMN_VOLSETMASK = 0x6700
ATTR_FILE_ALLOCSIZE = 0x4
ATTR_FILE_CLUMPSIZE = 0x10
ATTR_FILE_DATAALLOCSIZE = 0x400
ATTR_FILE_DATAEXTENTS = 0x800
ATTR_FILE_DATALENGTH = 0x200
ATTR_FILE_DEVTYPE = 0x20
ATTR_FILE_FILETYPE = 0x40
ATTR_FILE_FORKCOUNT = 0x80
ATTR_FILE_FORKLIST = 0x100
ATTR_FILE_IOBLOCKSIZE = 0x8
ATTR_FILE_LINKCOUNT = 0x1
ATTR_FILE_RSRCALLOCSIZE = 0x2000
ATTR_FILE_RSRCEXTENTS = 0x4000
ATTR_FILE_RSRCLENGTH = 0x1000
ATTR_FILE_SETMASK = 0x20
ATTR_FILE_TOTALSIZE = 0x2
ATTR_FILE_VALIDMASK = 0x37ff
ATTR_VOL_ALLOCATIONCLUMP = 0x40
ATTR_VOL_ATTRIBUTES = 0x40000000
ATTR_VOL_CAPABILITIES = 0x20000
ATTR_VOL_DIRCOUNT = 0x400
ATTR_VOL_ENCODINGSUSED = 0x10000
ATTR_VOL_FILECOUNT = 0x200
ATTR_VOL_FSTYPE = 0x1
ATTR_VOL_INFO = 0x80000000
ATTR_VOL_IOBLOCKSIZE = 0x80
ATTR_VOL_MAXOBJCOUNT = 0x800
ATTR_VOL_MINALLOCATION = 0x20
ATTR_VOL_MOUNTEDDEVICE = 0x8000
ATTR_VOL_MOUNTFLAGS = 0x4000
ATTR_VOL_MOUNTPOINT = 0x1000
ATTR_VOL_NAME = 0x2000
ATTR_VOL_OBJCOUNT = 0x100
ATTR_VOL_QUOTA_SIZE = 0x10000000
ATTR_VOL_RESERVED_SIZE = 0x20000000
ATTR_VOL_SETMASK = 0x80002000
ATTR_VOL_SIGNATURE = 0x2
ATTR_VOL_SIZE = 0x4
ATTR_VOL_SPACEAVAIL = 0x10
ATTR_VOL_SPACEFREE = 0x8
ATTR_VOL_UUID = 0x40000
ATTR_VOL_VALIDMASK = 0xf007ffff
B0 = 0x0 B0 = 0x0
B110 = 0x6e B110 = 0x6e
B115200 = 0x1c200 B115200 = 0x1c200
@ -169,6 +249,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -390,6 +472,11 @@ const (
FF1 = 0x4000 FF1 = 0x4000
FFDLY = 0x4000 FFDLY = 0x4000
FLUSHO = 0x800000 FLUSHO = 0x800000
FSOPT_ATTR_CMN_EXTENDED = 0x20
FSOPT_NOFOLLOW = 0x1
FSOPT_NOINMEMUPDATE = 0x2
FSOPT_PACK_INVAL_ATTRS = 0x8
FSOPT_REPORT_FULLSIZE = 0x4
F_ADDFILESIGS = 0x3d F_ADDFILESIGS = 0x3d
F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 F_ADDFILESIGS_FOR_DYLD_SIM = 0x53
F_ADDFILESIGS_RETURN = 0x61 F_ADDFILESIGS_RETURN = 0x61
@ -425,6 +512,7 @@ const (
F_PATHPKG_CHECK = 0x34 F_PATHPKG_CHECK = 0x34
F_PEOFPOSMODE = 0x3 F_PEOFPOSMODE = 0x3
F_PREALLOCATE = 0x2a F_PREALLOCATE = 0x2a
F_PUNCHHOLE = 0x63
F_RDADVISE = 0x2c F_RDADVISE = 0x2c
F_RDAHEAD = 0x2d F_RDAHEAD = 0x2d
F_RDLCK = 0x1 F_RDLCK = 0x1
@ -441,10 +529,12 @@ const (
F_SINGLE_WRITER = 0x4c F_SINGLE_WRITER = 0x4c
F_THAW_FS = 0x36 F_THAW_FS = 0x36
F_TRANSCODEKEY = 0x4b F_TRANSCODEKEY = 0x4b
F_TRIM_ACTIVE_FILE = 0x64
F_UNLCK = 0x2 F_UNLCK = 0x2
F_VOLPOSMODE = 0x4 F_VOLPOSMODE = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -681,6 +771,7 @@ const (
IPV6_FAITH = 0x1d IPV6_FAITH = 0x1d
IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWINFO_MASK = 0xffffff0f
IPV6_FLOWLABEL_MASK = 0xffff0f00 IPV6_FLOWLABEL_MASK = 0xffff0f00
IPV6_FLOW_ECN_MASK = 0x300
IPV6_FRAGTTL = 0x3c IPV6_FRAGTTL = 0x3c
IPV6_FW_ADD = 0x1e IPV6_FW_ADD = 0x1e
IPV6_FW_DEL = 0x1f IPV6_FW_DEL = 0x1f
@ -771,6 +862,7 @@ const (
IP_RECVOPTS = 0x5 IP_RECVOPTS = 0x5
IP_RECVPKTINFO = 0x1a IP_RECVPKTINFO = 0x1a
IP_RECVRETOPTS = 0x6 IP_RECVRETOPTS = 0x6
IP_RECVTOS = 0x1b
IP_RECVTTL = 0x18 IP_RECVTTL = 0x18
IP_RETOPTS = 0x8 IP_RETOPTS = 0x8
IP_RF = 0x8000 IP_RF = 0x8000
@ -789,6 +881,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -1377,6 +1473,12 @@ const (
WORDSIZE = 0x20 WORDSIZE = 0x20
WSTOPPED = 0x8 WSTOPPED = 0x8
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x2
XATTR_NODEFAULT = 0x10
XATTR_NOFOLLOW = 0x1
XATTR_NOSECURITY = 0x8
XATTR_REPLACE = 0x4
XATTR_SHOWCOMPRESSION = 0x20
) )
// Errors // Errors
@ -1528,146 +1630,154 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "resource busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "resource busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "ENOTSUP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "device power is off", {78, "ENOSYS", "function not implemented"},
83: "device error", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "bad executable (or shared library)", {81, "ENEEDAUTH", "need authenticator"},
86: "bad CPU type in executable", {82, "EPWROFF", "device power is off"},
87: "shared library version mismatch", {83, "EDEVERR", "device error"},
88: "malformed Mach-o file", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "operation canceled", {85, "EBADEXEC", "bad executable (or shared library)"},
90: "identifier removed", {86, "EBADARCH", "bad CPU type in executable"},
91: "no message of desired type", {87, "ESHLIBVERS", "shared library version mismatch"},
92: "illegal byte sequence", {88, "EBADMACHO", "malformed Mach-o file"},
93: "attribute not found", {89, "ECANCELED", "operation canceled"},
94: "bad message", {90, "EIDRM", "identifier removed"},
95: "EMULTIHOP (Reserved)", {91, "ENOMSG", "no message of desired type"},
96: "no message available on STREAM", {92, "EILSEQ", "illegal byte sequence"},
97: "ENOLINK (Reserved)", {93, "ENOATTR", "attribute not found"},
98: "no STREAM resources", {94, "EBADMSG", "bad message"},
99: "not a STREAM", {95, "EMULTIHOP", "EMULTIHOP (Reserved)"},
100: "protocol error", {96, "ENODATA", "no message available on STREAM"},
101: "STREAM ioctl timeout", {97, "ENOLINK", "ENOLINK (Reserved)"},
102: "operation not supported on socket", {98, "ENOSR", "no STREAM resources"},
103: "policy not found", {99, "ENOSTR", "not a STREAM"},
104: "state not recoverable", {100, "EPROTO", "protocol error"},
105: "previous owner died", {101, "ETIME", "STREAM ioctl timeout"},
106: "interface output queue is full", {102, "EOPNOTSUPP", "operation not supported on socket"},
{103, "ENOPOLICY", "policy not found"},
{104, "ENOTRECOVERABLE", "state not recoverable"},
{105, "EOWNERDEAD", "previous owner died"},
{106, "EQFULL", "interface output queue is full"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGABRT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
{28, "SIGWINCH", "window size changes"},
{29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
} }

View File

@ -49,6 +49,86 @@ const (
AF_UNSPEC = 0x0 AF_UNSPEC = 0x0
AF_UTUN = 0x26 AF_UTUN = 0x26
ALTWERASE = 0x200 ALTWERASE = 0x200
ATTR_BIT_MAP_COUNT = 0x5
ATTR_CMN_ACCESSMASK = 0x20000
ATTR_CMN_ACCTIME = 0x1000
ATTR_CMN_ADDEDTIME = 0x10000000
ATTR_CMN_BKUPTIME = 0x2000
ATTR_CMN_CHGTIME = 0x800
ATTR_CMN_CRTIME = 0x200
ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000
ATTR_CMN_DEVID = 0x2
ATTR_CMN_DOCUMENT_ID = 0x100000
ATTR_CMN_ERROR = 0x20000000
ATTR_CMN_EXTENDED_SECURITY = 0x400000
ATTR_CMN_FILEID = 0x2000000
ATTR_CMN_FLAGS = 0x40000
ATTR_CMN_FNDRINFO = 0x4000
ATTR_CMN_FSID = 0x4
ATTR_CMN_FULLPATH = 0x8000000
ATTR_CMN_GEN_COUNT = 0x80000
ATTR_CMN_GRPID = 0x10000
ATTR_CMN_GRPUUID = 0x1000000
ATTR_CMN_MODTIME = 0x400
ATTR_CMN_NAME = 0x1
ATTR_CMN_NAMEDATTRCOUNT = 0x80000
ATTR_CMN_NAMEDATTRLIST = 0x100000
ATTR_CMN_OBJID = 0x20
ATTR_CMN_OBJPERMANENTID = 0x40
ATTR_CMN_OBJTAG = 0x10
ATTR_CMN_OBJTYPE = 0x8
ATTR_CMN_OWNERID = 0x8000
ATTR_CMN_PARENTID = 0x4000000
ATTR_CMN_PAROBJID = 0x80
ATTR_CMN_RETURNED_ATTRS = 0x80000000
ATTR_CMN_SCRIPT = 0x100
ATTR_CMN_SETMASK = 0x41c7ff00
ATTR_CMN_USERACCESS = 0x200000
ATTR_CMN_UUID = 0x800000
ATTR_CMN_VALIDMASK = 0xffffffff
ATTR_CMN_VOLSETMASK = 0x6700
ATTR_FILE_ALLOCSIZE = 0x4
ATTR_FILE_CLUMPSIZE = 0x10
ATTR_FILE_DATAALLOCSIZE = 0x400
ATTR_FILE_DATAEXTENTS = 0x800
ATTR_FILE_DATALENGTH = 0x200
ATTR_FILE_DEVTYPE = 0x20
ATTR_FILE_FILETYPE = 0x40
ATTR_FILE_FORKCOUNT = 0x80
ATTR_FILE_FORKLIST = 0x100
ATTR_FILE_IOBLOCKSIZE = 0x8
ATTR_FILE_LINKCOUNT = 0x1
ATTR_FILE_RSRCALLOCSIZE = 0x2000
ATTR_FILE_RSRCEXTENTS = 0x4000
ATTR_FILE_RSRCLENGTH = 0x1000
ATTR_FILE_SETMASK = 0x20
ATTR_FILE_TOTALSIZE = 0x2
ATTR_FILE_VALIDMASK = 0x37ff
ATTR_VOL_ALLOCATIONCLUMP = 0x40
ATTR_VOL_ATTRIBUTES = 0x40000000
ATTR_VOL_CAPABILITIES = 0x20000
ATTR_VOL_DIRCOUNT = 0x400
ATTR_VOL_ENCODINGSUSED = 0x10000
ATTR_VOL_FILECOUNT = 0x200
ATTR_VOL_FSTYPE = 0x1
ATTR_VOL_INFO = 0x80000000
ATTR_VOL_IOBLOCKSIZE = 0x80
ATTR_VOL_MAXOBJCOUNT = 0x800
ATTR_VOL_MINALLOCATION = 0x20
ATTR_VOL_MOUNTEDDEVICE = 0x8000
ATTR_VOL_MOUNTFLAGS = 0x4000
ATTR_VOL_MOUNTPOINT = 0x1000
ATTR_VOL_NAME = 0x2000
ATTR_VOL_OBJCOUNT = 0x100
ATTR_VOL_QUOTA_SIZE = 0x10000000
ATTR_VOL_RESERVED_SIZE = 0x20000000
ATTR_VOL_SETMASK = 0x80002000
ATTR_VOL_SIGNATURE = 0x2
ATTR_VOL_SIZE = 0x4
ATTR_VOL_SPACEAVAIL = 0x10
ATTR_VOL_SPACEFREE = 0x8
ATTR_VOL_UUID = 0x40000
ATTR_VOL_VALIDMASK = 0xf007ffff
B0 = 0x0 B0 = 0x0
B110 = 0x6e B110 = 0x6e
B115200 = 0x1c200 B115200 = 0x1c200
@ -169,6 +249,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -390,6 +472,11 @@ const (
FF1 = 0x4000 FF1 = 0x4000
FFDLY = 0x4000 FFDLY = 0x4000
FLUSHO = 0x800000 FLUSHO = 0x800000
FSOPT_ATTR_CMN_EXTENDED = 0x20
FSOPT_NOFOLLOW = 0x1
FSOPT_NOINMEMUPDATE = 0x2
FSOPT_PACK_INVAL_ATTRS = 0x8
FSOPT_REPORT_FULLSIZE = 0x4
F_ADDFILESIGS = 0x3d F_ADDFILESIGS = 0x3d
F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 F_ADDFILESIGS_FOR_DYLD_SIM = 0x53
F_ADDFILESIGS_RETURN = 0x61 F_ADDFILESIGS_RETURN = 0x61
@ -425,6 +512,7 @@ const (
F_PATHPKG_CHECK = 0x34 F_PATHPKG_CHECK = 0x34
F_PEOFPOSMODE = 0x3 F_PEOFPOSMODE = 0x3
F_PREALLOCATE = 0x2a F_PREALLOCATE = 0x2a
F_PUNCHHOLE = 0x63
F_RDADVISE = 0x2c F_RDADVISE = 0x2c
F_RDAHEAD = 0x2d F_RDAHEAD = 0x2d
F_RDLCK = 0x1 F_RDLCK = 0x1
@ -441,10 +529,12 @@ const (
F_SINGLE_WRITER = 0x4c F_SINGLE_WRITER = 0x4c
F_THAW_FS = 0x36 F_THAW_FS = 0x36
F_TRANSCODEKEY = 0x4b F_TRANSCODEKEY = 0x4b
F_TRIM_ACTIVE_FILE = 0x64
F_UNLCK = 0x2 F_UNLCK = 0x2
F_VOLPOSMODE = 0x4 F_VOLPOSMODE = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -681,6 +771,7 @@ const (
IPV6_FAITH = 0x1d IPV6_FAITH = 0x1d
IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWINFO_MASK = 0xffffff0f
IPV6_FLOWLABEL_MASK = 0xffff0f00 IPV6_FLOWLABEL_MASK = 0xffff0f00
IPV6_FLOW_ECN_MASK = 0x300
IPV6_FRAGTTL = 0x3c IPV6_FRAGTTL = 0x3c
IPV6_FW_ADD = 0x1e IPV6_FW_ADD = 0x1e
IPV6_FW_DEL = 0x1f IPV6_FW_DEL = 0x1f
@ -771,6 +862,7 @@ const (
IP_RECVOPTS = 0x5 IP_RECVOPTS = 0x5
IP_RECVPKTINFO = 0x1a IP_RECVPKTINFO = 0x1a
IP_RECVRETOPTS = 0x6 IP_RECVRETOPTS = 0x6
IP_RECVTOS = 0x1b
IP_RECVTTL = 0x18 IP_RECVTTL = 0x18
IP_RETOPTS = 0x8 IP_RETOPTS = 0x8
IP_RF = 0x8000 IP_RF = 0x8000
@ -789,6 +881,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -1377,6 +1473,12 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x8 WSTOPPED = 0x8
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x2
XATTR_NODEFAULT = 0x10
XATTR_NOFOLLOW = 0x1
XATTR_NOSECURITY = 0x8
XATTR_REPLACE = 0x4
XATTR_SHOWCOMPRESSION = 0x20
) )
// Errors // Errors
@ -1528,146 +1630,154 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "resource busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "resource busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "ENOTSUP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "device power is off", {78, "ENOSYS", "function not implemented"},
83: "device error", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "bad executable (or shared library)", {81, "ENEEDAUTH", "need authenticator"},
86: "bad CPU type in executable", {82, "EPWROFF", "device power is off"},
87: "shared library version mismatch", {83, "EDEVERR", "device error"},
88: "malformed Mach-o file", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "operation canceled", {85, "EBADEXEC", "bad executable (or shared library)"},
90: "identifier removed", {86, "EBADARCH", "bad CPU type in executable"},
91: "no message of desired type", {87, "ESHLIBVERS", "shared library version mismatch"},
92: "illegal byte sequence", {88, "EBADMACHO", "malformed Mach-o file"},
93: "attribute not found", {89, "ECANCELED", "operation canceled"},
94: "bad message", {90, "EIDRM", "identifier removed"},
95: "EMULTIHOP (Reserved)", {91, "ENOMSG", "no message of desired type"},
96: "no message available on STREAM", {92, "EILSEQ", "illegal byte sequence"},
97: "ENOLINK (Reserved)", {93, "ENOATTR", "attribute not found"},
98: "no STREAM resources", {94, "EBADMSG", "bad message"},
99: "not a STREAM", {95, "EMULTIHOP", "EMULTIHOP (Reserved)"},
100: "protocol error", {96, "ENODATA", "no message available on STREAM"},
101: "STREAM ioctl timeout", {97, "ENOLINK", "ENOLINK (Reserved)"},
102: "operation not supported on socket", {98, "ENOSR", "no STREAM resources"},
103: "policy not found", {99, "ENOSTR", "not a STREAM"},
104: "state not recoverable", {100, "EPROTO", "protocol error"},
105: "previous owner died", {101, "ETIME", "STREAM ioctl timeout"},
106: "interface output queue is full", {102, "EOPNOTSUPP", "operation not supported on socket"},
{103, "ENOPOLICY", "policy not found"},
{104, "ENOTRECOVERABLE", "state not recoverable"},
{105, "EOWNERDEAD", "previous owner died"},
{106, "EQFULL", "interface output queue is full"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGABRT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
{28, "SIGWINCH", "window size changes"},
{29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
} }

View File

@ -49,6 +49,86 @@ const (
AF_UNSPEC = 0x0 AF_UNSPEC = 0x0
AF_UTUN = 0x26 AF_UTUN = 0x26
ALTWERASE = 0x200 ALTWERASE = 0x200
ATTR_BIT_MAP_COUNT = 0x5
ATTR_CMN_ACCESSMASK = 0x20000
ATTR_CMN_ACCTIME = 0x1000
ATTR_CMN_ADDEDTIME = 0x10000000
ATTR_CMN_BKUPTIME = 0x2000
ATTR_CMN_CHGTIME = 0x800
ATTR_CMN_CRTIME = 0x200
ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000
ATTR_CMN_DEVID = 0x2
ATTR_CMN_DOCUMENT_ID = 0x100000
ATTR_CMN_ERROR = 0x20000000
ATTR_CMN_EXTENDED_SECURITY = 0x400000
ATTR_CMN_FILEID = 0x2000000
ATTR_CMN_FLAGS = 0x40000
ATTR_CMN_FNDRINFO = 0x4000
ATTR_CMN_FSID = 0x4
ATTR_CMN_FULLPATH = 0x8000000
ATTR_CMN_GEN_COUNT = 0x80000
ATTR_CMN_GRPID = 0x10000
ATTR_CMN_GRPUUID = 0x1000000
ATTR_CMN_MODTIME = 0x400
ATTR_CMN_NAME = 0x1
ATTR_CMN_NAMEDATTRCOUNT = 0x80000
ATTR_CMN_NAMEDATTRLIST = 0x100000
ATTR_CMN_OBJID = 0x20
ATTR_CMN_OBJPERMANENTID = 0x40
ATTR_CMN_OBJTAG = 0x10
ATTR_CMN_OBJTYPE = 0x8
ATTR_CMN_OWNERID = 0x8000
ATTR_CMN_PARENTID = 0x4000000
ATTR_CMN_PAROBJID = 0x80
ATTR_CMN_RETURNED_ATTRS = 0x80000000
ATTR_CMN_SCRIPT = 0x100
ATTR_CMN_SETMASK = 0x41c7ff00
ATTR_CMN_USERACCESS = 0x200000
ATTR_CMN_UUID = 0x800000
ATTR_CMN_VALIDMASK = 0xffffffff
ATTR_CMN_VOLSETMASK = 0x6700
ATTR_FILE_ALLOCSIZE = 0x4
ATTR_FILE_CLUMPSIZE = 0x10
ATTR_FILE_DATAALLOCSIZE = 0x400
ATTR_FILE_DATAEXTENTS = 0x800
ATTR_FILE_DATALENGTH = 0x200
ATTR_FILE_DEVTYPE = 0x20
ATTR_FILE_FILETYPE = 0x40
ATTR_FILE_FORKCOUNT = 0x80
ATTR_FILE_FORKLIST = 0x100
ATTR_FILE_IOBLOCKSIZE = 0x8
ATTR_FILE_LINKCOUNT = 0x1
ATTR_FILE_RSRCALLOCSIZE = 0x2000
ATTR_FILE_RSRCEXTENTS = 0x4000
ATTR_FILE_RSRCLENGTH = 0x1000
ATTR_FILE_SETMASK = 0x20
ATTR_FILE_TOTALSIZE = 0x2
ATTR_FILE_VALIDMASK = 0x37ff
ATTR_VOL_ALLOCATIONCLUMP = 0x40
ATTR_VOL_ATTRIBUTES = 0x40000000
ATTR_VOL_CAPABILITIES = 0x20000
ATTR_VOL_DIRCOUNT = 0x400
ATTR_VOL_ENCODINGSUSED = 0x10000
ATTR_VOL_FILECOUNT = 0x200
ATTR_VOL_FSTYPE = 0x1
ATTR_VOL_INFO = 0x80000000
ATTR_VOL_IOBLOCKSIZE = 0x80
ATTR_VOL_MAXOBJCOUNT = 0x800
ATTR_VOL_MINALLOCATION = 0x20
ATTR_VOL_MOUNTEDDEVICE = 0x8000
ATTR_VOL_MOUNTFLAGS = 0x4000
ATTR_VOL_MOUNTPOINT = 0x1000
ATTR_VOL_NAME = 0x2000
ATTR_VOL_OBJCOUNT = 0x100
ATTR_VOL_QUOTA_SIZE = 0x10000000
ATTR_VOL_RESERVED_SIZE = 0x20000000
ATTR_VOL_SETMASK = 0x80002000
ATTR_VOL_SIGNATURE = 0x2
ATTR_VOL_SIZE = 0x4
ATTR_VOL_SPACEAVAIL = 0x10
ATTR_VOL_SPACEFREE = 0x8
ATTR_VOL_UUID = 0x40000
ATTR_VOL_VALIDMASK = 0xf007ffff
B0 = 0x0 B0 = 0x0
B110 = 0x6e B110 = 0x6e
B115200 = 0x1c200 B115200 = 0x1c200
@ -169,6 +249,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -390,6 +472,11 @@ const (
FF1 = 0x4000 FF1 = 0x4000
FFDLY = 0x4000 FFDLY = 0x4000
FLUSHO = 0x800000 FLUSHO = 0x800000
FSOPT_ATTR_CMN_EXTENDED = 0x20
FSOPT_NOFOLLOW = 0x1
FSOPT_NOINMEMUPDATE = 0x2
FSOPT_PACK_INVAL_ATTRS = 0x8
FSOPT_REPORT_FULLSIZE = 0x4
F_ADDFILESIGS = 0x3d F_ADDFILESIGS = 0x3d
F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 F_ADDFILESIGS_FOR_DYLD_SIM = 0x53
F_ADDFILESIGS_RETURN = 0x61 F_ADDFILESIGS_RETURN = 0x61
@ -425,6 +512,7 @@ const (
F_PATHPKG_CHECK = 0x34 F_PATHPKG_CHECK = 0x34
F_PEOFPOSMODE = 0x3 F_PEOFPOSMODE = 0x3
F_PREALLOCATE = 0x2a F_PREALLOCATE = 0x2a
F_PUNCHHOLE = 0x63
F_RDADVISE = 0x2c F_RDADVISE = 0x2c
F_RDAHEAD = 0x2d F_RDAHEAD = 0x2d
F_RDLCK = 0x1 F_RDLCK = 0x1
@ -441,10 +529,12 @@ const (
F_SINGLE_WRITER = 0x4c F_SINGLE_WRITER = 0x4c
F_THAW_FS = 0x36 F_THAW_FS = 0x36
F_TRANSCODEKEY = 0x4b F_TRANSCODEKEY = 0x4b
F_TRIM_ACTIVE_FILE = 0x64
F_UNLCK = 0x2 F_UNLCK = 0x2
F_VOLPOSMODE = 0x4 F_VOLPOSMODE = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -681,6 +771,7 @@ const (
IPV6_FAITH = 0x1d IPV6_FAITH = 0x1d
IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWINFO_MASK = 0xffffff0f
IPV6_FLOWLABEL_MASK = 0xffff0f00 IPV6_FLOWLABEL_MASK = 0xffff0f00
IPV6_FLOW_ECN_MASK = 0x300
IPV6_FRAGTTL = 0x3c IPV6_FRAGTTL = 0x3c
IPV6_FW_ADD = 0x1e IPV6_FW_ADD = 0x1e
IPV6_FW_DEL = 0x1f IPV6_FW_DEL = 0x1f
@ -771,6 +862,7 @@ const (
IP_RECVOPTS = 0x5 IP_RECVOPTS = 0x5
IP_RECVPKTINFO = 0x1a IP_RECVPKTINFO = 0x1a
IP_RECVRETOPTS = 0x6 IP_RECVRETOPTS = 0x6
IP_RECVTOS = 0x1b
IP_RECVTTL = 0x18 IP_RECVTTL = 0x18
IP_RETOPTS = 0x8 IP_RETOPTS = 0x8
IP_RF = 0x8000 IP_RF = 0x8000
@ -789,6 +881,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -1377,6 +1473,12 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x8 WSTOPPED = 0x8
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x2
XATTR_NODEFAULT = 0x10
XATTR_NOFOLLOW = 0x1
XATTR_NOSECURITY = 0x8
XATTR_REPLACE = 0x4
XATTR_SHOWCOMPRESSION = 0x20
) )
// Errors // Errors
@ -1528,146 +1630,154 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "resource busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "resource busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "ENOTSUP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "device power is off", {78, "ENOSYS", "function not implemented"},
83: "device error", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "bad executable (or shared library)", {81, "ENEEDAUTH", "need authenticator"},
86: "bad CPU type in executable", {82, "EPWROFF", "device power is off"},
87: "shared library version mismatch", {83, "EDEVERR", "device error"},
88: "malformed Mach-o file", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "operation canceled", {85, "EBADEXEC", "bad executable (or shared library)"},
90: "identifier removed", {86, "EBADARCH", "bad CPU type in executable"},
91: "no message of desired type", {87, "ESHLIBVERS", "shared library version mismatch"},
92: "illegal byte sequence", {88, "EBADMACHO", "malformed Mach-o file"},
93: "attribute not found", {89, "ECANCELED", "operation canceled"},
94: "bad message", {90, "EIDRM", "identifier removed"},
95: "EMULTIHOP (Reserved)", {91, "ENOMSG", "no message of desired type"},
96: "no message available on STREAM", {92, "EILSEQ", "illegal byte sequence"},
97: "ENOLINK (Reserved)", {93, "ENOATTR", "attribute not found"},
98: "no STREAM resources", {94, "EBADMSG", "bad message"},
99: "not a STREAM", {95, "EMULTIHOP", "EMULTIHOP (Reserved)"},
100: "protocol error", {96, "ENODATA", "no message available on STREAM"},
101: "STREAM ioctl timeout", {97, "ENOLINK", "ENOLINK (Reserved)"},
102: "operation not supported on socket", {98, "ENOSR", "no STREAM resources"},
103: "policy not found", {99, "ENOSTR", "not a STREAM"},
104: "state not recoverable", {100, "EPROTO", "protocol error"},
105: "previous owner died", {101, "ETIME", "STREAM ioctl timeout"},
106: "interface output queue is full", {102, "EOPNOTSUPP", "operation not supported on socket"},
{103, "ENOPOLICY", "policy not found"},
{104, "ENOTRECOVERABLE", "state not recoverable"},
{105, "EOWNERDEAD", "previous owner died"},
{106, "EQFULL", "interface output queue is full"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGABRT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
{28, "SIGWINCH", "window size changes"},
{29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
} }

View File

@ -49,6 +49,86 @@ const (
AF_UNSPEC = 0x0 AF_UNSPEC = 0x0
AF_UTUN = 0x26 AF_UTUN = 0x26
ALTWERASE = 0x200 ALTWERASE = 0x200
ATTR_BIT_MAP_COUNT = 0x5
ATTR_CMN_ACCESSMASK = 0x20000
ATTR_CMN_ACCTIME = 0x1000
ATTR_CMN_ADDEDTIME = 0x10000000
ATTR_CMN_BKUPTIME = 0x2000
ATTR_CMN_CHGTIME = 0x800
ATTR_CMN_CRTIME = 0x200
ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000
ATTR_CMN_DEVID = 0x2
ATTR_CMN_DOCUMENT_ID = 0x100000
ATTR_CMN_ERROR = 0x20000000
ATTR_CMN_EXTENDED_SECURITY = 0x400000
ATTR_CMN_FILEID = 0x2000000
ATTR_CMN_FLAGS = 0x40000
ATTR_CMN_FNDRINFO = 0x4000
ATTR_CMN_FSID = 0x4
ATTR_CMN_FULLPATH = 0x8000000
ATTR_CMN_GEN_COUNT = 0x80000
ATTR_CMN_GRPID = 0x10000
ATTR_CMN_GRPUUID = 0x1000000
ATTR_CMN_MODTIME = 0x400
ATTR_CMN_NAME = 0x1
ATTR_CMN_NAMEDATTRCOUNT = 0x80000
ATTR_CMN_NAMEDATTRLIST = 0x100000
ATTR_CMN_OBJID = 0x20
ATTR_CMN_OBJPERMANENTID = 0x40
ATTR_CMN_OBJTAG = 0x10
ATTR_CMN_OBJTYPE = 0x8
ATTR_CMN_OWNERID = 0x8000
ATTR_CMN_PARENTID = 0x4000000
ATTR_CMN_PAROBJID = 0x80
ATTR_CMN_RETURNED_ATTRS = 0x80000000
ATTR_CMN_SCRIPT = 0x100
ATTR_CMN_SETMASK = 0x41c7ff00
ATTR_CMN_USERACCESS = 0x200000
ATTR_CMN_UUID = 0x800000
ATTR_CMN_VALIDMASK = 0xffffffff
ATTR_CMN_VOLSETMASK = 0x6700
ATTR_FILE_ALLOCSIZE = 0x4
ATTR_FILE_CLUMPSIZE = 0x10
ATTR_FILE_DATAALLOCSIZE = 0x400
ATTR_FILE_DATAEXTENTS = 0x800
ATTR_FILE_DATALENGTH = 0x200
ATTR_FILE_DEVTYPE = 0x20
ATTR_FILE_FILETYPE = 0x40
ATTR_FILE_FORKCOUNT = 0x80
ATTR_FILE_FORKLIST = 0x100
ATTR_FILE_IOBLOCKSIZE = 0x8
ATTR_FILE_LINKCOUNT = 0x1
ATTR_FILE_RSRCALLOCSIZE = 0x2000
ATTR_FILE_RSRCEXTENTS = 0x4000
ATTR_FILE_RSRCLENGTH = 0x1000
ATTR_FILE_SETMASK = 0x20
ATTR_FILE_TOTALSIZE = 0x2
ATTR_FILE_VALIDMASK = 0x37ff
ATTR_VOL_ALLOCATIONCLUMP = 0x40
ATTR_VOL_ATTRIBUTES = 0x40000000
ATTR_VOL_CAPABILITIES = 0x20000
ATTR_VOL_DIRCOUNT = 0x400
ATTR_VOL_ENCODINGSUSED = 0x10000
ATTR_VOL_FILECOUNT = 0x200
ATTR_VOL_FSTYPE = 0x1
ATTR_VOL_INFO = 0x80000000
ATTR_VOL_IOBLOCKSIZE = 0x80
ATTR_VOL_MAXOBJCOUNT = 0x800
ATTR_VOL_MINALLOCATION = 0x20
ATTR_VOL_MOUNTEDDEVICE = 0x8000
ATTR_VOL_MOUNTFLAGS = 0x4000
ATTR_VOL_MOUNTPOINT = 0x1000
ATTR_VOL_NAME = 0x2000
ATTR_VOL_OBJCOUNT = 0x100
ATTR_VOL_QUOTA_SIZE = 0x10000000
ATTR_VOL_RESERVED_SIZE = 0x20000000
ATTR_VOL_SETMASK = 0x80002000
ATTR_VOL_SIGNATURE = 0x2
ATTR_VOL_SIZE = 0x4
ATTR_VOL_SPACEAVAIL = 0x10
ATTR_VOL_SPACEFREE = 0x8
ATTR_VOL_UUID = 0x40000
ATTR_VOL_VALIDMASK = 0xf007ffff
B0 = 0x0 B0 = 0x0
B110 = 0x6e B110 = 0x6e
B115200 = 0x1c200 B115200 = 0x1c200
@ -169,6 +249,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -390,6 +472,11 @@ const (
FF1 = 0x4000 FF1 = 0x4000
FFDLY = 0x4000 FFDLY = 0x4000
FLUSHO = 0x800000 FLUSHO = 0x800000
FSOPT_ATTR_CMN_EXTENDED = 0x20
FSOPT_NOFOLLOW = 0x1
FSOPT_NOINMEMUPDATE = 0x2
FSOPT_PACK_INVAL_ATTRS = 0x8
FSOPT_REPORT_FULLSIZE = 0x4
F_ADDFILESIGS = 0x3d F_ADDFILESIGS = 0x3d
F_ADDFILESIGS_FOR_DYLD_SIM = 0x53 F_ADDFILESIGS_FOR_DYLD_SIM = 0x53
F_ADDFILESIGS_RETURN = 0x61 F_ADDFILESIGS_RETURN = 0x61
@ -425,6 +512,7 @@ const (
F_PATHPKG_CHECK = 0x34 F_PATHPKG_CHECK = 0x34
F_PEOFPOSMODE = 0x3 F_PEOFPOSMODE = 0x3
F_PREALLOCATE = 0x2a F_PREALLOCATE = 0x2a
F_PUNCHHOLE = 0x63
F_RDADVISE = 0x2c F_RDADVISE = 0x2c
F_RDAHEAD = 0x2d F_RDAHEAD = 0x2d
F_RDLCK = 0x1 F_RDLCK = 0x1
@ -441,10 +529,12 @@ const (
F_SINGLE_WRITER = 0x4c F_SINGLE_WRITER = 0x4c
F_THAW_FS = 0x36 F_THAW_FS = 0x36
F_TRANSCODEKEY = 0x4b F_TRANSCODEKEY = 0x4b
F_TRIM_ACTIVE_FILE = 0x64
F_UNLCK = 0x2 F_UNLCK = 0x2
F_VOLPOSMODE = 0x4 F_VOLPOSMODE = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -681,6 +771,7 @@ const (
IPV6_FAITH = 0x1d IPV6_FAITH = 0x1d
IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWINFO_MASK = 0xffffff0f
IPV6_FLOWLABEL_MASK = 0xffff0f00 IPV6_FLOWLABEL_MASK = 0xffff0f00
IPV6_FLOW_ECN_MASK = 0x300
IPV6_FRAGTTL = 0x3c IPV6_FRAGTTL = 0x3c
IPV6_FW_ADD = 0x1e IPV6_FW_ADD = 0x1e
IPV6_FW_DEL = 0x1f IPV6_FW_DEL = 0x1f
@ -771,6 +862,7 @@ const (
IP_RECVOPTS = 0x5 IP_RECVOPTS = 0x5
IP_RECVPKTINFO = 0x1a IP_RECVPKTINFO = 0x1a
IP_RECVRETOPTS = 0x6 IP_RECVRETOPTS = 0x6
IP_RECVTOS = 0x1b
IP_RECVTTL = 0x18 IP_RECVTTL = 0x18
IP_RETOPTS = 0x8 IP_RETOPTS = 0x8
IP_RF = 0x8000 IP_RF = 0x8000
@ -789,6 +881,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -1377,6 +1473,12 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x8 WSTOPPED = 0x8
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x2
XATTR_NODEFAULT = 0x10
XATTR_NOFOLLOW = 0x1
XATTR_NOSECURITY = 0x8
XATTR_REPLACE = 0x4
XATTR_SHOWCOMPRESSION = 0x20
) )
// Errors // Errors
@ -1528,146 +1630,154 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "resource busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "resource busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "ENOTSUP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "device power is off", {78, "ENOSYS", "function not implemented"},
83: "device error", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "bad executable (or shared library)", {81, "ENEEDAUTH", "need authenticator"},
86: "bad CPU type in executable", {82, "EPWROFF", "device power is off"},
87: "shared library version mismatch", {83, "EDEVERR", "device error"},
88: "malformed Mach-o file", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "operation canceled", {85, "EBADEXEC", "bad executable (or shared library)"},
90: "identifier removed", {86, "EBADARCH", "bad CPU type in executable"},
91: "no message of desired type", {87, "ESHLIBVERS", "shared library version mismatch"},
92: "illegal byte sequence", {88, "EBADMACHO", "malformed Mach-o file"},
93: "attribute not found", {89, "ECANCELED", "operation canceled"},
94: "bad message", {90, "EIDRM", "identifier removed"},
95: "EMULTIHOP (Reserved)", {91, "ENOMSG", "no message of desired type"},
96: "no message available on STREAM", {92, "EILSEQ", "illegal byte sequence"},
97: "ENOLINK (Reserved)", {93, "ENOATTR", "attribute not found"},
98: "no STREAM resources", {94, "EBADMSG", "bad message"},
99: "not a STREAM", {95, "EMULTIHOP", "EMULTIHOP (Reserved)"},
100: "protocol error", {96, "ENODATA", "no message available on STREAM"},
101: "STREAM ioctl timeout", {97, "ENOLINK", "ENOLINK (Reserved)"},
102: "operation not supported on socket", {98, "ENOSR", "no STREAM resources"},
103: "policy not found", {99, "ENOSTR", "not a STREAM"},
104: "state not recoverable", {100, "EPROTO", "protocol error"},
105: "previous owner died", {101, "ETIME", "STREAM ioctl timeout"},
106: "interface output queue is full", {102, "EOPNOTSUPP", "operation not supported on socket"},
{103, "ENOPOLICY", "policy not found"},
{104, "ENOTRECOVERABLE", "state not recoverable"},
{105, "EOWNERDEAD", "previous owner died"},
{106, "EQFULL", "interface output queue is full"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGABRT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
{28, "SIGWINCH", "window size changes"},
{29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
} }

View File

@ -168,6 +168,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -353,6 +355,7 @@ const (
F_UNLCK = 0x2 F_UNLCK = 0x2
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -835,6 +838,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -973,7 +980,10 @@ const (
RLIMIT_CPU = 0x0 RLIMIT_CPU = 0x0
RLIMIT_DATA = 0x2 RLIMIT_DATA = 0x2
RLIMIT_FSIZE = 0x1 RLIMIT_FSIZE = 0x1
RLIMIT_MEMLOCK = 0x6
RLIMIT_NOFILE = 0x8 RLIMIT_NOFILE = 0x8
RLIMIT_NPROC = 0x7
RLIMIT_RSS = 0x5
RLIMIT_STACK = 0x3 RLIMIT_STACK = 0x3
RLIM_INFINITY = 0x7fffffffffffffff RLIM_INFINITY = 0x7fffffffffffffff
RTAX_AUTHOR = 0x6 RTAX_AUTHOR = 0x6
@ -1427,142 +1437,150 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "device busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "device busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EWOULDBLOCK", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "EOPNOTSUPP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "identifier removed", {78, "ENOSYS", "function not implemented"},
83: "no message of desired type", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "operation canceled", {81, "ENEEDAUTH", "need authenticator"},
86: "illegal byte sequence", {82, "EIDRM", "identifier removed"},
87: "attribute not found", {83, "ENOMSG", "no message of desired type"},
88: "programming error", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "bad message", {85, "ECANCELED", "operation canceled"},
90: "multihop attempted", {86, "EILSEQ", "illegal byte sequence"},
91: "link has been severed", {87, "ENOATTR", "attribute not found"},
92: "protocol error", {88, "EDOOFUS", "programming error"},
93: "no medium found", {89, "EBADMSG", "bad message"},
94: "unknown error: 94", {90, "EMULTIHOP", "multihop attempted"},
95: "unknown error: 95", {91, "ENOLINK", "link has been severed"},
96: "unknown error: 96", {92, "EPROTO", "protocol error"},
97: "unknown error: 97", {93, "ENOMEDIUM", "no medium found"},
98: "unknown error: 98", {94, "EUNUSED94", "unknown error: 94"},
99: "unknown error: 99", {95, "EUNUSED95", "unknown error: 95"},
{96, "EUNUSED96", "unknown error: 96"},
{97, "EUNUSED97", "unknown error: 97"},
{98, "EUNUSED98", "unknown error: 98"},
{99, "ELAST", "unknown error: 99"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGIOT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
32: "thread Scheduler", {28, "SIGWINCH", "window size changes"},
33: "checkPoint", {29, "SIGINFO", "information request"},
34: "checkPointExit", {30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
{32, "SIGTHR", "thread Scheduler"},
{33, "SIGCKPT", "checkPoint"},
{34, "SIGCKPTEXIT", "checkPointExit"},
} }

View File

@ -351,6 +351,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0x18 CTL_MAXNAME = 0x18
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -608,6 +610,7 @@ const (
F_UNLCKSYS = 0x4 F_UNLCKSYS = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -944,6 +947,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -981,6 +988,49 @@ const (
MAP_STACK = 0x400 MAP_STACK = 0x400
MCL_CURRENT = 0x1 MCL_CURRENT = 0x1
MCL_FUTURE = 0x2 MCL_FUTURE = 0x2
MNT_ACLS = 0x8000000
MNT_ASYNC = 0x40
MNT_AUTOMOUNTED = 0x200000000
MNT_BYFSID = 0x8000000
MNT_CMDFLAGS = 0xd0f0000
MNT_DEFEXPORTED = 0x200
MNT_DELEXPORT = 0x20000
MNT_EXKERB = 0x800
MNT_EXPORTANON = 0x400
MNT_EXPORTED = 0x100
MNT_EXPUBLIC = 0x20000000
MNT_EXRDONLY = 0x80
MNT_FORCE = 0x80000
MNT_GJOURNAL = 0x2000000
MNT_IGNORE = 0x800000
MNT_LAZY = 0x3
MNT_LOCAL = 0x1000
MNT_MULTILABEL = 0x4000000
MNT_NFS4ACLS = 0x10
MNT_NOATIME = 0x10000000
MNT_NOCLUSTERR = 0x40000000
MNT_NOCLUSTERW = 0x80000000
MNT_NOEXEC = 0x4
MNT_NONBUSY = 0x4000000
MNT_NOSUID = 0x8
MNT_NOSYMFOLLOW = 0x400000
MNT_NOWAIT = 0x2
MNT_QUOTA = 0x2000
MNT_RDONLY = 0x1
MNT_RELOAD = 0x40000
MNT_ROOTFS = 0x4000
MNT_SNAPSHOT = 0x1000000
MNT_SOFTDEP = 0x200000
MNT_SUIDDIR = 0x100000
MNT_SUJ = 0x100000000
MNT_SUSPEND = 0x4
MNT_SYNCHRONOUS = 0x2
MNT_UNION = 0x20
MNT_UPDATE = 0x10000
MNT_UPDATEMASK = 0x2d8d0807e
MNT_USER = 0x8000
MNT_VISFLAGMASK = 0x3fef0ffff
MNT_WAIT = 0x1
MSG_CMSG_CLOEXEC = 0x40000 MSG_CMSG_CLOEXEC = 0x40000
MSG_COMPAT = 0x8000 MSG_COMPAT = 0x8000
MSG_CTRUNC = 0x20 MSG_CTRUNC = 0x20
@ -1569,138 +1619,146 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "device busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "device busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "EOPNOTSUPP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "identifier removed", {78, "ENOSYS", "function not implemented"},
83: "no message of desired type", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "operation canceled", {81, "ENEEDAUTH", "need authenticator"},
86: "illegal byte sequence", {82, "EIDRM", "identifier removed"},
87: "attribute not found", {83, "ENOMSG", "no message of desired type"},
88: "programming error", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "bad message", {85, "ECANCELED", "operation canceled"},
90: "multihop attempted", {86, "EILSEQ", "illegal byte sequence"},
91: "link has been severed", {87, "ENOATTR", "attribute not found"},
92: "protocol error", {88, "EDOOFUS", "programming error"},
93: "capabilities insufficient", {89, "EBADMSG", "bad message"},
94: "not permitted in capability mode", {90, "EMULTIHOP", "multihop attempted"},
95: "state not recoverable", {91, "ENOLINK", "link has been severed"},
96: "previous owner died", {92, "EPROTO", "protocol error"},
{93, "ENOTCAPABLE", "capabilities insufficient"},
{94, "ECAPMODE", "not permitted in capability mode"},
{95, "ENOTRECOVERABLE", "state not recoverable"},
{96, "EOWNERDEAD", "previous owner died"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGIOT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
32: "unknown signal", {28, "SIGWINCH", "window size changes"},
33: "unknown signal", {29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
{32, "SIGTHR", "unknown signal"},
{33, "SIGLIBRT", "unknown signal"},
} }

View File

@ -351,6 +351,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0x18 CTL_MAXNAME = 0x18
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -608,6 +610,7 @@ const (
F_UNLCKSYS = 0x4 F_UNLCKSYS = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -944,6 +947,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -982,6 +989,49 @@ const (
MAP_STACK = 0x400 MAP_STACK = 0x400
MCL_CURRENT = 0x1 MCL_CURRENT = 0x1
MCL_FUTURE = 0x2 MCL_FUTURE = 0x2
MNT_ACLS = 0x8000000
MNT_ASYNC = 0x40
MNT_AUTOMOUNTED = 0x200000000
MNT_BYFSID = 0x8000000
MNT_CMDFLAGS = 0xd0f0000
MNT_DEFEXPORTED = 0x200
MNT_DELEXPORT = 0x20000
MNT_EXKERB = 0x800
MNT_EXPORTANON = 0x400
MNT_EXPORTED = 0x100
MNT_EXPUBLIC = 0x20000000
MNT_EXRDONLY = 0x80
MNT_FORCE = 0x80000
MNT_GJOURNAL = 0x2000000
MNT_IGNORE = 0x800000
MNT_LAZY = 0x3
MNT_LOCAL = 0x1000
MNT_MULTILABEL = 0x4000000
MNT_NFS4ACLS = 0x10
MNT_NOATIME = 0x10000000
MNT_NOCLUSTERR = 0x40000000
MNT_NOCLUSTERW = 0x80000000
MNT_NOEXEC = 0x4
MNT_NONBUSY = 0x4000000
MNT_NOSUID = 0x8
MNT_NOSYMFOLLOW = 0x400000
MNT_NOWAIT = 0x2
MNT_QUOTA = 0x2000
MNT_RDONLY = 0x1
MNT_RELOAD = 0x40000
MNT_ROOTFS = 0x4000
MNT_SNAPSHOT = 0x1000000
MNT_SOFTDEP = 0x200000
MNT_SUIDDIR = 0x100000
MNT_SUJ = 0x100000000
MNT_SUSPEND = 0x4
MNT_SYNCHRONOUS = 0x2
MNT_UNION = 0x20
MNT_UPDATE = 0x10000
MNT_UPDATEMASK = 0x2d8d0807e
MNT_USER = 0x8000
MNT_VISFLAGMASK = 0x3fef0ffff
MNT_WAIT = 0x1
MSG_CMSG_CLOEXEC = 0x40000 MSG_CMSG_CLOEXEC = 0x40000
MSG_COMPAT = 0x8000 MSG_COMPAT = 0x8000
MSG_CTRUNC = 0x20 MSG_CTRUNC = 0x20
@ -1570,138 +1620,146 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "device busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "device busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "EOPNOTSUPP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "identifier removed", {78, "ENOSYS", "function not implemented"},
83: "no message of desired type", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "operation canceled", {81, "ENEEDAUTH", "need authenticator"},
86: "illegal byte sequence", {82, "EIDRM", "identifier removed"},
87: "attribute not found", {83, "ENOMSG", "no message of desired type"},
88: "programming error", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "bad message", {85, "ECANCELED", "operation canceled"},
90: "multihop attempted", {86, "EILSEQ", "illegal byte sequence"},
91: "link has been severed", {87, "ENOATTR", "attribute not found"},
92: "protocol error", {88, "EDOOFUS", "programming error"},
93: "capabilities insufficient", {89, "EBADMSG", "bad message"},
94: "not permitted in capability mode", {90, "EMULTIHOP", "multihop attempted"},
95: "state not recoverable", {91, "ENOLINK", "link has been severed"},
96: "previous owner died", {92, "EPROTO", "protocol error"},
{93, "ENOTCAPABLE", "capabilities insufficient"},
{94, "ECAPMODE", "not permitted in capability mode"},
{95, "ENOTRECOVERABLE", "state not recoverable"},
{96, "EOWNERDEAD", "previous owner died"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGIOT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
32: "unknown signal", {28, "SIGWINCH", "window size changes"},
33: "unknown signal", {29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
{32, "SIGTHR", "unknown signal"},
{33, "SIGLIBRT", "unknown signal"},
} }

View File

@ -351,6 +351,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0x18 CTL_MAXNAME = 0x18
CTL_NET = 0x4 CTL_NET = 0x4
DLT_A429 = 0xb8 DLT_A429 = 0xb8
@ -615,6 +617,7 @@ const (
F_UNLCKSYS = 0x4 F_UNLCKSYS = 0x4
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -951,6 +954,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -989,6 +996,49 @@ const (
MAP_STACK = 0x400 MAP_STACK = 0x400
MCL_CURRENT = 0x1 MCL_CURRENT = 0x1
MCL_FUTURE = 0x2 MCL_FUTURE = 0x2
MNT_ACLS = 0x8000000
MNT_ASYNC = 0x40
MNT_AUTOMOUNTED = 0x200000000
MNT_BYFSID = 0x8000000
MNT_CMDFLAGS = 0xd0f0000
MNT_DEFEXPORTED = 0x200
MNT_DELEXPORT = 0x20000
MNT_EXKERB = 0x800
MNT_EXPORTANON = 0x400
MNT_EXPORTED = 0x100
MNT_EXPUBLIC = 0x20000000
MNT_EXRDONLY = 0x80
MNT_FORCE = 0x80000
MNT_GJOURNAL = 0x2000000
MNT_IGNORE = 0x800000
MNT_LAZY = 0x3
MNT_LOCAL = 0x1000
MNT_MULTILABEL = 0x4000000
MNT_NFS4ACLS = 0x10
MNT_NOATIME = 0x10000000
MNT_NOCLUSTERR = 0x40000000
MNT_NOCLUSTERW = 0x80000000
MNT_NOEXEC = 0x4
MNT_NONBUSY = 0x4000000
MNT_NOSUID = 0x8
MNT_NOSYMFOLLOW = 0x400000
MNT_NOWAIT = 0x2
MNT_QUOTA = 0x2000
MNT_RDONLY = 0x1
MNT_RELOAD = 0x40000
MNT_ROOTFS = 0x4000
MNT_SNAPSHOT = 0x1000000
MNT_SOFTDEP = 0x200000
MNT_SUIDDIR = 0x100000
MNT_SUJ = 0x100000000
MNT_SUSPEND = 0x4
MNT_SYNCHRONOUS = 0x2
MNT_UNION = 0x20
MNT_UPDATE = 0x10000
MNT_UPDATEMASK = 0x2d8d0807e
MNT_USER = 0x8000
MNT_VISFLAGMASK = 0x3fef0ffff
MNT_WAIT = 0x1
MSG_CMSG_CLOEXEC = 0x40000 MSG_CMSG_CLOEXEC = 0x40000
MSG_COMPAT = 0x8000 MSG_COMPAT = 0x8000
MSG_CTRUNC = 0x20 MSG_CTRUNC = 0x20
@ -1578,138 +1628,146 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "device busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "device busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "EOPNOTSUPP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "operation timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "operation timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "identifier removed", {78, "ENOSYS", "function not implemented"},
83: "no message of desired type", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "operation canceled", {81, "ENEEDAUTH", "need authenticator"},
86: "illegal byte sequence", {82, "EIDRM", "identifier removed"},
87: "attribute not found", {83, "ENOMSG", "no message of desired type"},
88: "programming error", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "bad message", {85, "ECANCELED", "operation canceled"},
90: "multihop attempted", {86, "EILSEQ", "illegal byte sequence"},
91: "link has been severed", {87, "ENOATTR", "attribute not found"},
92: "protocol error", {88, "EDOOFUS", "programming error"},
93: "capabilities insufficient", {89, "EBADMSG", "bad message"},
94: "not permitted in capability mode", {90, "EMULTIHOP", "multihop attempted"},
95: "state not recoverable", {91, "ENOLINK", "link has been severed"},
96: "previous owner died", {92, "EPROTO", "protocol error"},
{93, "ENOTCAPABLE", "capabilities insufficient"},
{94, "ECAPMODE", "not permitted in capability mode"},
{95, "ENOTRECOVERABLE", "state not recoverable"},
{96, "EOWNERDEAD", "previous owner died"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGIOT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "suspended (signal)", {13, "SIGPIPE", "broken pipe"},
18: "suspended", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "suspended (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "suspended"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
32: "unknown signal", {28, "SIGWINCH", "window size changes"},
33: "unknown signal", {29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
{32, "SIGTHR", "unknown signal"},
{33, "SIGLIBRT", "unknown signal"},
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
// mkerrors.sh -m64 // mkerrors.sh -m64
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // Code generated by the command above; DO NOT EDIT.
// +build sparc64,linux // +build sparc64,linux

View File

@ -1,5 +1,5 @@
// mkerrors.sh -m32 // mkerrors.sh -m32
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // Code generated by the command above; see README.md. DO NOT EDIT.
// +build 386,netbsd // +build 386,netbsd
@ -159,6 +159,7 @@ const (
CLONE_VFORK = 0x4000 CLONE_VFORK = 0x4000
CLONE_VM = 0x100 CLONE_VM = 0x100
CREAD = 0x800 CREAD = 0x800
CRTSCTS = 0x10000
CS5 = 0x0 CS5 = 0x0
CS6 = 0x100 CS6 = 0x100
CS7 = 0x200 CS7 = 0x200
@ -169,6 +170,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
CTL_QUERY = -0x2 CTL_QUERY = -0x2
@ -581,6 +584,7 @@ const (
F_UNLCK = 0x2 F_UNLCK = 0x2
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -970,6 +974,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -1576,137 +1584,145 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "device busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "device busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large or too small", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large or too small"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol option not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol option not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "EOPNOTSUPP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "connection timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "connection timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "identifier removed", {78, "ENOSYS", "function not implemented"},
83: "no message of desired type", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "illegal byte sequence", {81, "ENEEDAUTH", "need authenticator"},
86: "not supported", {82, "EIDRM", "identifier removed"},
87: "operation Canceled", {83, "ENOMSG", "no message of desired type"},
88: "bad or Corrupt message", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "no message available", {85, "EILSEQ", "illegal byte sequence"},
90: "no STREAM resources", {86, "ENOTSUP", "not supported"},
91: "not a STREAM", {87, "ECANCELED", "operation Canceled"},
92: "STREAM ioctl timeout", {88, "EBADMSG", "bad or Corrupt message"},
93: "attribute not found", {89, "ENODATA", "no message available"},
94: "multihop attempted", {90, "ENOSR", "no STREAM resources"},
95: "link has been severed", {91, "ENOSTR", "not a STREAM"},
96: "protocol error", {92, "ETIME", "STREAM ioctl timeout"},
{93, "ENOATTR", "attribute not found"},
{94, "EMULTIHOP", "multihop attempted"},
{95, "ENOLINK", "link has been severed"},
{96, "ELAST", "protocol error"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGIOT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "stopped (signal)", {13, "SIGPIPE", "broken pipe"},
18: "stopped", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "stopped (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "stopped"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
32: "power fail/restart", {28, "SIGWINCH", "window size changes"},
{29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
{32, "SIGPWR", "power fail/restart"},
} }

View File

@ -1,5 +1,5 @@
// mkerrors.sh -m64 // mkerrors.sh -m64
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // Code generated by the command above; see README.md. DO NOT EDIT.
// +build amd64,netbsd // +build amd64,netbsd
@ -159,6 +159,7 @@ const (
CLONE_VFORK = 0x4000 CLONE_VFORK = 0x4000
CLONE_VM = 0x100 CLONE_VM = 0x100
CREAD = 0x800 CREAD = 0x800
CRTSCTS = 0x10000
CS5 = 0x0 CS5 = 0x0
CS6 = 0x100 CS6 = 0x100
CS7 = 0x200 CS7 = 0x200
@ -169,6 +170,8 @@ const (
CSTOP = 0x13 CSTOP = 0x13
CSTOPB = 0x400 CSTOPB = 0x400
CSUSP = 0x1a CSUSP = 0x1a
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc CTL_MAXNAME = 0xc
CTL_NET = 0x4 CTL_NET = 0x4
CTL_QUERY = -0x2 CTL_QUERY = -0x2
@ -571,6 +574,7 @@ const (
F_UNLCK = 0x2 F_UNLCK = 0x2
F_WRLCK = 0x3 F_WRLCK = 0x3
HUPCL = 0x4000 HUPCL = 0x4000
HW_MACHINE = 0x1
ICANON = 0x100 ICANON = 0x100
ICMP6_FILTER = 0x12 ICMP6_FILTER = 0x12
ICRNL = 0x100 ICRNL = 0x100
@ -960,6 +964,10 @@ const (
IXANY = 0x800 IXANY = 0x800
IXOFF = 0x400 IXOFF = 0x400
IXON = 0x200 IXON = 0x200
KERN_HOSTNAME = 0xa
KERN_OSRELEASE = 0x2
KERN_OSTYPE = 0x1
KERN_VERSION = 0x4
LOCK_EX = 0x2 LOCK_EX = 0x2
LOCK_NB = 0x4 LOCK_NB = 0x4
LOCK_SH = 0x1 LOCK_SH = 0x1
@ -1566,137 +1574,145 @@ const (
) )
// Error table // Error table
var errors = [...]string{ var errorList = [...]struct {
1: "operation not permitted", num syscall.Errno
2: "no such file or directory", name string
3: "no such process", desc string
4: "interrupted system call", }{
5: "input/output error", {1, "EPERM", "operation not permitted"},
6: "device not configured", {2, "ENOENT", "no such file or directory"},
7: "argument list too long", {3, "ESRCH", "no such process"},
8: "exec format error", {4, "EINTR", "interrupted system call"},
9: "bad file descriptor", {5, "EIO", "input/output error"},
10: "no child processes", {6, "ENXIO", "device not configured"},
11: "resource deadlock avoided", {7, "E2BIG", "argument list too long"},
12: "cannot allocate memory", {8, "ENOEXEC", "exec format error"},
13: "permission denied", {9, "EBADF", "bad file descriptor"},
14: "bad address", {10, "ECHILD", "no child processes"},
15: "block device required", {11, "EDEADLK", "resource deadlock avoided"},
16: "device busy", {12, "ENOMEM", "cannot allocate memory"},
17: "file exists", {13, "EACCES", "permission denied"},
18: "cross-device link", {14, "EFAULT", "bad address"},
19: "operation not supported by device", {15, "ENOTBLK", "block device required"},
20: "not a directory", {16, "EBUSY", "device busy"},
21: "is a directory", {17, "EEXIST", "file exists"},
22: "invalid argument", {18, "EXDEV", "cross-device link"},
23: "too many open files in system", {19, "ENODEV", "operation not supported by device"},
24: "too many open files", {20, "ENOTDIR", "not a directory"},
25: "inappropriate ioctl for device", {21, "EISDIR", "is a directory"},
26: "text file busy", {22, "EINVAL", "invalid argument"},
27: "file too large", {23, "ENFILE", "too many open files in system"},
28: "no space left on device", {24, "EMFILE", "too many open files"},
29: "illegal seek", {25, "ENOTTY", "inappropriate ioctl for device"},
30: "read-only file system", {26, "ETXTBSY", "text file busy"},
31: "too many links", {27, "EFBIG", "file too large"},
32: "broken pipe", {28, "ENOSPC", "no space left on device"},
33: "numerical argument out of domain", {29, "ESPIPE", "illegal seek"},
34: "result too large or too small", {30, "EROFS", "read-only file system"},
35: "resource temporarily unavailable", {31, "EMLINK", "too many links"},
36: "operation now in progress", {32, "EPIPE", "broken pipe"},
37: "operation already in progress", {33, "EDOM", "numerical argument out of domain"},
38: "socket operation on non-socket", {34, "ERANGE", "result too large or too small"},
39: "destination address required", {35, "EAGAIN", "resource temporarily unavailable"},
40: "message too long", {36, "EINPROGRESS", "operation now in progress"},
41: "protocol wrong type for socket", {37, "EALREADY", "operation already in progress"},
42: "protocol option not available", {38, "ENOTSOCK", "socket operation on non-socket"},
43: "protocol not supported", {39, "EDESTADDRREQ", "destination address required"},
44: "socket type not supported", {40, "EMSGSIZE", "message too long"},
45: "operation not supported", {41, "EPROTOTYPE", "protocol wrong type for socket"},
46: "protocol family not supported", {42, "ENOPROTOOPT", "protocol option not available"},
47: "address family not supported by protocol family", {43, "EPROTONOSUPPORT", "protocol not supported"},
48: "address already in use", {44, "ESOCKTNOSUPPORT", "socket type not supported"},
49: "can't assign requested address", {45, "EOPNOTSUPP", "operation not supported"},
50: "network is down", {46, "EPFNOSUPPORT", "protocol family not supported"},
51: "network is unreachable", {47, "EAFNOSUPPORT", "address family not supported by protocol family"},
52: "network dropped connection on reset", {48, "EADDRINUSE", "address already in use"},
53: "software caused connection abort", {49, "EADDRNOTAVAIL", "can't assign requested address"},
54: "connection reset by peer", {50, "ENETDOWN", "network is down"},
55: "no buffer space available", {51, "ENETUNREACH", "network is unreachable"},
56: "socket is already connected", {52, "ENETRESET", "network dropped connection on reset"},
57: "socket is not connected", {53, "ECONNABORTED", "software caused connection abort"},
58: "can't send after socket shutdown", {54, "ECONNRESET", "connection reset by peer"},
59: "too many references: can't splice", {55, "ENOBUFS", "no buffer space available"},
60: "connection timed out", {56, "EISCONN", "socket is already connected"},
61: "connection refused", {57, "ENOTCONN", "socket is not connected"},
62: "too many levels of symbolic links", {58, "ESHUTDOWN", "can't send after socket shutdown"},
63: "file name too long", {59, "ETOOMANYREFS", "too many references: can't splice"},
64: "host is down", {60, "ETIMEDOUT", "connection timed out"},
65: "no route to host", {61, "ECONNREFUSED", "connection refused"},
66: "directory not empty", {62, "ELOOP", "too many levels of symbolic links"},
67: "too many processes", {63, "ENAMETOOLONG", "file name too long"},
68: "too many users", {64, "EHOSTDOWN", "host is down"},
69: "disc quota exceeded", {65, "EHOSTUNREACH", "no route to host"},
70: "stale NFS file handle", {66, "ENOTEMPTY", "directory not empty"},
71: "too many levels of remote in path", {67, "EPROCLIM", "too many processes"},
72: "RPC struct is bad", {68, "EUSERS", "too many users"},
73: "RPC version wrong", {69, "EDQUOT", "disc quota exceeded"},
74: "RPC prog. not avail", {70, "ESTALE", "stale NFS file handle"},
75: "program version wrong", {71, "EREMOTE", "too many levels of remote in path"},
76: "bad procedure for program", {72, "EBADRPC", "RPC struct is bad"},
77: "no locks available", {73, "ERPCMISMATCH", "RPC version wrong"},
78: "function not implemented", {74, "EPROGUNAVAIL", "RPC prog. not avail"},
79: "inappropriate file type or format", {75, "EPROGMISMATCH", "program version wrong"},
80: "authentication error", {76, "EPROCUNAVAIL", "bad procedure for program"},
81: "need authenticator", {77, "ENOLCK", "no locks available"},
82: "identifier removed", {78, "ENOSYS", "function not implemented"},
83: "no message of desired type", {79, "EFTYPE", "inappropriate file type or format"},
84: "value too large to be stored in data type", {80, "EAUTH", "authentication error"},
85: "illegal byte sequence", {81, "ENEEDAUTH", "need authenticator"},
86: "not supported", {82, "EIDRM", "identifier removed"},
87: "operation Canceled", {83, "ENOMSG", "no message of desired type"},
88: "bad or Corrupt message", {84, "EOVERFLOW", "value too large to be stored in data type"},
89: "no message available", {85, "EILSEQ", "illegal byte sequence"},
90: "no STREAM resources", {86, "ENOTSUP", "not supported"},
91: "not a STREAM", {87, "ECANCELED", "operation Canceled"},
92: "STREAM ioctl timeout", {88, "EBADMSG", "bad or Corrupt message"},
93: "attribute not found", {89, "ENODATA", "no message available"},
94: "multihop attempted", {90, "ENOSR", "no STREAM resources"},
95: "link has been severed", {91, "ENOSTR", "not a STREAM"},
96: "protocol error", {92, "ETIME", "STREAM ioctl timeout"},
{93, "ENOATTR", "attribute not found"},
{94, "EMULTIHOP", "multihop attempted"},
{95, "ENOLINK", "link has been severed"},
{96, "ELAST", "protocol error"},
} }
// Signal table // Signal table
var signals = [...]string{ var signalList = [...]struct {
1: "hangup", num syscall.Signal
2: "interrupt", name string
3: "quit", desc string
4: "illegal instruction", }{
5: "trace/BPT trap", {1, "SIGHUP", "hangup"},
6: "abort trap", {2, "SIGINT", "interrupt"},
7: "EMT trap", {3, "SIGQUIT", "quit"},
8: "floating point exception", {4, "SIGILL", "illegal instruction"},
9: "killed", {5, "SIGTRAP", "trace/BPT trap"},
10: "bus error", {6, "SIGIOT", "abort trap"},
11: "segmentation fault", {7, "SIGEMT", "EMT trap"},
12: "bad system call", {8, "SIGFPE", "floating point exception"},
13: "broken pipe", {9, "SIGKILL", "killed"},
14: "alarm clock", {10, "SIGBUS", "bus error"},
15: "terminated", {11, "SIGSEGV", "segmentation fault"},
16: "urgent I/O condition", {12, "SIGSYS", "bad system call"},
17: "stopped (signal)", {13, "SIGPIPE", "broken pipe"},
18: "stopped", {14, "SIGALRM", "alarm clock"},
19: "continued", {15, "SIGTERM", "terminated"},
20: "child exited", {16, "SIGURG", "urgent I/O condition"},
21: "stopped (tty input)", {17, "SIGSTOP", "stopped (signal)"},
22: "stopped (tty output)", {18, "SIGTSTP", "stopped"},
23: "I/O possible", {19, "SIGCONT", "continued"},
24: "cputime limit exceeded", {20, "SIGCHLD", "child exited"},
25: "filesize limit exceeded", {21, "SIGTTIN", "stopped (tty input)"},
26: "virtual timer expired", {22, "SIGTTOU", "stopped (tty output)"},
27: "profiling timer expired", {23, "SIGIO", "I/O possible"},
28: "window size changes", {24, "SIGXCPU", "cputime limit exceeded"},
29: "information request", {25, "SIGXFSZ", "filesize limit exceeded"},
30: "user defined signal 1", {26, "SIGVTALRM", "virtual timer expired"},
31: "user defined signal 2", {27, "SIGPROF", "profiling timer expired"},
32: "power fail/restart", {28, "SIGWINCH", "window size changes"},
{29, "SIGINFO", "information request"},
{30, "SIGUSR1", "user defined signal 1"},
{31, "SIGUSR2", "user defined signal 2"},
{32, "SIGPWR", "power fail/restart"},
} }

Some files were not shown because too many files have changed in this diff Show More