Documentation ¶
Overview ¶
Package syscall contains an interface to the low-level operating system primitives. The details vary depending on the underlying system, and by default, godoc will display the syscall documentation for the current system. If you want godoc to display syscall documentation for another 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 to freebsd and $GOARCH to arm. The primary use of syscall is inside other packages that provide a more portable interface to the system, such as "os", "time" and "net". Use those packages rather than this one if you can. For details of the functions and data types in this package consult the manuals for the appropriate operating system. These calls return err == nil to indicate success; otherwise err is an operating system error describing the failure. On most systems, that error has type syscall.Errno.
Index ¶
- Constants
- Variables
- func AttachLsf(fd int, i []SockFilter) error
- func Bind(fd int, sa Sockaddr) (err error)
- func BindToDevice(fd int, device string) (err error)
- func BytePtrFromString(s string) (*byte, error)
- func ByteSliceFromString(s string) ([]byte, error)
- func Cgocall()
- func CgocallBack()
- func CgocallBackDone()
- func CgocallDone()
- func Clearenv()
- func CloseOnExec(fd int)
- func CmsgLen(datalen int) int
- func CmsgSpace(datalen int) int
- func Connect(fd int, sa Sockaddr) (err error)
- func DetachLsf(fd int) error
- func Entersyscall()
- func Environ() []string
- func Errstr(errno int) string
- func Exec(argv0 string, argv []string, envv []string) (err error)
- func Exitsyscall()
- func FDClr(fd int, set *FdSet)
- func FDIsSet(fd int, set *FdSet) bool
- func FDSet(fd int, set *FdSet)
- func FDZero(set *FdSet)
- func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
- func Futimes(fd int, tv []Timeval) (err error)
- func Futimesat(dirfd int, path string, tv []Timeval) (err error)
- func Getcwd(buf []byte) (n int, err error)
- func Getdents(fd int, buf []byte) (n int, err error)
- func Getenv(key string) (value string, found bool)
- func Getgroups() (gids []int, err error)
- func GetsockoptByte(fd, level, opt int) (value byte, err error)
- func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error)
- func GetsockoptInt(fd, level, opt int) (value int, err error)
- func Gettid() (tid int)
- func Gettimeofday(tv *Timeval) (err error)
- func Getwd() (ret string, err error)
- func LsfSocket(ifindex, proto int) (int, error)
- func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)
- func Munmap(b []byte) (err error)
- func NetlinkRIB(proto, family int) ([]byte, error)
- func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string)
- func ParseUnixRights(m *SocketControlMessage) ([]int, error)
- func Pipe(p []int) (err error)
- func Pipe2(p []int, flags int) (err error)
- func PtraceAttach(pid int) (err error)
- func PtraceCont(pid int, signal int) (err error)
- func PtraceDetach(pid int) (err error)
- func PtraceGetEventMsg(pid int) (msg uint, err error)
- func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error)
- func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error)
- func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error)
- func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error)
- func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error)
- func PtraceSetOptions(pid int, options int) (err error)
- func PtraceSetRegs(pid int, regs *PtraceRegs) (err error)
- func PtraceSingleStep(pid int) (err error)
- func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
- func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
- func Read(fd int, p []byte) (n int, err error)
- func ReadDirent(fd int, buf []byte) (n int, err error)
- func Reboot(cmd int) (err error)
- func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
- func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error)
- func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error)
- func SetErrno(Errno)
- func SetLsfPromisc(name string, m bool) error
- func SetNonblock(fd int, nonblocking bool) (err error)
- func Setenv(key, value string) error
- func Setgroups(gids []int) (err error)
- func SetsockoptByte(fd, level, opt int, value byte) (err error)
- func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error
- func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error)
- func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error)
- func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error)
- func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error)
- func SetsockoptInt(fd, level, opt int, value int) (err error)
- func SetsockoptLinger(fd, level, opt int, l *Linger) (err error)
- func SetsockoptString(fd, level, opt int, s string) (err error)
- func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error)
- func Settimeofday(tv *Timeval) (err error)
- func Signame(s Signal) string
- func Sleep(nsec int64) (err error)
- func SlicePtrFromStrings(ss []string) ([]*byte, error)
- func Socket(domain, typ, proto int) (fd int, err error)
- func Socketpair(domain, typ, proto int) (fd [2]int, err error)
- func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
- func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error)
- func StringBytePtr(s string) *byte
- func StringByteSlice(s string) []byte
- func StringSlicePtr(ss []string) []*byte
- func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
- func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
- func Tgkill(tgid int, tid int, sig Signal) error
- func TimespecToNsec(ts Timespec) int64
- func TimevalToNsec(tv Timeval) int64
- func UnixCredentials(ucred *Ucred) []byte
- func UnixRights(fds ...int) []byte
- func Unlinkat(dirfd int, path string) (err error)
- func Utimes(path string, tv []Timeval) (err error)
- func UtimesNano(path string, ts []Timespec) (err error)
- func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error)
- func Write(fd int, p []byte) (n int, err error)
- type Addrinfo
- type Credential
- type Errno
- func GetErrno() Errno
- func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
- func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
- func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
- func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
- type FdSet
- type Linger
- type NetlinkMessage
- type NetlinkRouteAttr
- type NetlinkRouteRequest
- type ProcAttr
- type PtraceRegs
- type RawSockaddr
- type RawSockaddrAny
- type RawSockaddrInet4
- type RawSockaddrInet6
- type RawSockaddrLinklayer
- type RawSockaddrNetlink
- type RawSockaddrUnix
- type Signal
- type Sockaddr
- func Accept(fd int) (nfd int, sa Sockaddr, err error)
- func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error)
- func Getpeername(fd int) (sa Sockaddr, err error)
- func Getsockname(fd int) (sa Sockaddr, err error)
- func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error)
- func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error)
- type SockaddrInet4
- type SockaddrInet6
- type SockaddrLinklayer
- type SockaddrNetlink
- type SockaddrUnix
- type SocketControlMessage
- type SysProcAttr
- type WaitStatus
- func (w WaitStatus) Continued() bool
- func (w WaitStatus) CoreDump() bool
- func (w WaitStatus) ExitStatus() int
- func (w WaitStatus) Exited() bool
- func (w WaitStatus) Signal() int
- func (w WaitStatus) Signaled() bool
- func (w WaitStatus) StopSignal() int
- func (w WaitStatus) Stopped() bool
- func (w WaitStatus) TrapCause() int
Constants ¶
const ( AI_PASSIVE = 0x00000001 AI_CANONNAME = 0x00000002 AI_NUMERICHOST = 0x00000004 AI_NUMERICSERV = 0x00000008 AI_ALL = 0x00000100 AI_ADDRCONFIG = 0x00000400 AI_V4MAPPED = 0x00000800 AI_DEFAULT = (AI_V4MAPPED | AI_ADDRCONFIG) )
const ( EAI_ADDRFAMILY = 1 EAI_AGAIN = 2 EAI_BADFLAGS = 3 EAI_FAIL = 4 EAI_FAMILY = 5 EAI_MEMORY = 6 EAI_NODATA = 7 EAI_NONAME = 8 EAI_SERVICE = 9 EAI_SOCKTYPE = 10 EAI_SYSTEM = 11 EAI_BADHINTS = 12 EAI_OVERFLOW = 13 EAI_MAX = 14 )
const ( IPV6_UNICAST_HOPS = 48 IPV6_MULTICAST_IF = IP_MULTICAST_IF IPV6_MULTICAST_HOPS = IP_MULTICAST_TTL IPV6_MULTICAST_LOOP = IP_MULTICAST_LOOP )
<netinet/in.h.h> only provides IPV6_* etc. if _NO_XOPEN4 && _NO_XOPEN5, so as above simply provide them here.
const ImplementsGetwd = true
const SizeofSockaddrAny = 0x6c
const SizeofSockaddrInet4 = 16
const SizeofSockaddrInet4 = 16
const SizeofSockaddrInet4 = 16
const SizeofSockaddrInet6 = 28
const SizeofSockaddrInet6 = 28
const SizeofSockaddrInet6 = 28
const SizeofSockaddrLinklayer = 20
const SizeofSockaddrNetlink = 12
const SizeofSockaddrUnix = 110
const SizeofSockaddrUnix = 110
const SizeofSockaddrUnix = 110
Variables ¶
var ( Stdin = 0 Stdout = 1 Stderr = 2 )
var ( // envs is provided by the runtime. elements are expected to be // of the form "key=value". Envs []string )
var ForkLock sync.RWMutex
var SocketDisableIPv6 bool
For testing: clients can set this flag to force creation of IPv6 sockets to return EAFNOSUPPORT.
Functions ¶
func BindToDevice ¶
BindToDevice binds the socket associated with fd to device.
func BytePtrFromString ¶
BytePtrFromString returns a pointer to a NUL-terminated array of bytes containing the text of s. If s contains a NUL byte at any location, it returns (nil, EINVAL).
func ByteSliceFromString ¶
ByteSliceFromString returns a NUL-terminated slice of bytes containing the text of s. If s contains a NUL byte at any location, it returns (nil, EINVAL).
func CgocallBack ¶
func CgocallBack()
func CgocallBackDone ¶
func CgocallBackDone()
func CgocallDone ¶
func CgocallDone()
func CloseOnExec ¶
func CloseOnExec(fd int)
func CmsgLen ¶
CmsgLen returns the value to store in the Len field of the Cmsghdr structure, taking into account any necessary alignment.
func CmsgSpace ¶
CmsgSpace returns the number of bytes an ancillary element with payload of the passed data length occupies.
func Entersyscall ¶
func Entersyscall()
func Exitsyscall ¶
func Exitsyscall()
func Futimesat ¶
sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) futimesat(dirfd _C_int, path *byte, times *[2]Timeval) _C_int
func GetsockoptByte ¶
func GetsockoptInet4Addr ¶
func GetsockoptInt ¶
func Gettimeofday ¶
func Gettimeofday(tv *Timeval) (err error)
sysnb gettimeofday(tv *Timeval, tz *byte) (err error) gettimeofday(tv *Timeval, tz *byte) _C_int
func NetlinkRIB ¶
NetlinkRIB returns routing information base, as known as RIB, which consists of network facility information, states and parameters.
func ParseDirent ¶
func ParseUnixRights ¶
func ParseUnixRights(m *SocketControlMessage) ([]int, error)
ParseUnixRights decodes a socket control message that contains an integer array of open file descriptors from another process.
func Pipe2 ¶
sysnb pipe2(p *[2]_C_int, flags int) (err error) pipe2(p *[2]_C_int, flags _C_int) _C_int
func PtraceAttach ¶
func PtraceCont ¶
func PtraceDetach ¶
func PtraceGetEventMsg ¶
func PtraceGetRegs ¶
func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error)
func PtracePokeData ¶
func PtracePokeText ¶
func PtraceSetOptions ¶
func PtraceSetRegs ¶
func PtraceSetRegs(pid int, regs *PtraceRegs) (err error)
func PtraceSingleStep ¶
func RawSyscall ¶
func RawSyscall6 ¶
func Reboot ¶
sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) reboot(magic1 _C_uint, magic2 _C_uint, cmd _C_int, arg *byte) _C_int
func Sendfile ¶
sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) sendfile64(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t
func SetLsfPromisc ¶
func SetNonblock ¶
func SetsockoptByte ¶
func SetsockoptICMPv6Filter ¶
func SetsockoptIPMreq ¶
func SetsockoptIPMreqn ¶
func SetsockoptIPv6Mreq ¶
func SetsockoptInet4Addr ¶
func SetsockoptInt ¶
func SetsockoptLinger ¶
func SetsockoptString ¶
func SetsockoptTimeval ¶
func Settimeofday ¶
func Settimeofday(tv *Timeval) (err error)
func SlicePtrFromStrings ¶
SlicePtrFromStrings converts a slice of strings to a slice of pointers to NUL-terminated byte slices. If any string contains a NUL byte, it returns (nil, EINVAL).
func Socketpair ¶
func Splice ¶
sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error) splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
func StartProcess ¶
StartProcess wraps ForkExec for package os.
func StringBytePtr ¶
StringBytePtr is deprecated. Use BytePtrFromString instead. If s contains a NUL byte this function panics instead of returning an error.
func StringByteSlice ¶
StringByteSlice is deprecated. Use ByteSliceFromString instead. If s contains a NUL byte this function panics instead of returning an error.
func StringSlicePtr ¶
StringSlicePtr is deprecated. Use SlicePtrFromStrings instead. If any string contains a NUL byte this function panics instead of returning an error.
func TimespecToNsec ¶
func TimespecToNsec(ts Timespec) int64
func TimevalToNsec ¶
func TimevalToNsec(tv Timeval) int64
func UnixCredentials ¶
func UnixCredentials(ucred *Ucred) []byte
UnixCredentials encodes credentials into a socket control message for sending to another process. This can be used for authentication.
func UnixRights ¶
UnixRights encodes a set of open file descriptors into a socket control message for sending to another process.
func Utimes ¶
sys utimes(path string, times *[2]Timeval) (err error) utimes(path *byte, times *[2]Timeval) _C_int
func UtimesNano ¶
sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) utimensat(dirfd _C_int, path *byte, times *[2]Timespec, flags _C_int) _C_int
Types ¶
type Addrinfo ¶
type Addrinfo struct { Ai_flags int32 Ai_family int32 Ai_socktype int32 Ai_protocol int32 Ai_addrlen int32 Ai_canonname *uint8 Ai_addr *_sockaddr Ai_next *Addrinfo }
<netdb.h> only provides struct addrinfo, AI_* and EAI_* if _NO_XOPEN4 && _NO_XOPEN5, but -D_XOPEN_SOURCE=500 is required for msg_control etc. in struct msghgr, so simply provide them here.
type Credential ¶
type Credential struct { Uid uint32 // User ID. Gid uint32 // Group ID. Groups []uint32 // Supplementary group IDs. }
Credential holds user and group identities to be assumed by a child process started by StartProcess.
type Errno ¶
type Errno uintptr
An Errno is an unsigned number describing an error condition. It implements the error interface. The zero Errno is by convention a non-error, so code to convert from Errno to error should use:
err = nil if errno != 0 { err = errno }
func RawSyscall ¶
func RawSyscall6 ¶
type NetlinkMessage ¶
type NetlinkMessage struct { Header NlMsghdr Data []byte }
NetlinkMessage represents a netlink message.
func ParseNetlinkMessage ¶
func ParseNetlinkMessage(b []byte) ([]NetlinkMessage, error)
ParseNetlinkMessage parses b as an array of netlink messages and returns the slice containing the NetlinkMessage structures.
type NetlinkRouteAttr ¶
type NetlinkRouteAttr struct { Attr RtAttr Value []byte }
NetlinkRouteAttr represents a netlink route attribute.
func ParseNetlinkRouteAttr ¶
func ParseNetlinkRouteAttr(m *NetlinkMessage) ([]NetlinkRouteAttr, error)
ParseNetlinkRouteAttr parses m's payload as an array of netlink route attributes and returns the slice containing the NetlinkRouteAttr structures.
type NetlinkRouteRequest ¶
type NetlinkRouteRequest struct { Header NlMsghdr Data RtGenmsg }
NetlinkRouteRequest represents a request message to receive routing and link states from the kernel.
type ProcAttr ¶
type ProcAttr struct { Dir string // Current working directory. Env []string // Environment. Files []uintptr // File descriptors. Sys *SysProcAttr }
ProcAttr holds attributes that will be applied to a new process started by StartProcess.
type PtraceRegs ¶
type PtraceRegs struct { R0 uint64 R1 uint64 R2 uint64 R3 uint64 R4 uint64 R5 uint64 R6 uint64 R7 uint64 R8 uint64 R19 uint64 R20 uint64 R21 uint64 R22 uint64 R23 uint64 R24 uint64 R25 uint64 R26 uint64 R27 uint64 R28 uint64 Hae uint64 Trap_a0 uint64 Trap_a1 uint64 Trap_a2 uint64 Ps uint64 Pc uint64 Gp uint64 R16 uint64 R17 uint64 R18 uint64 }
func (*PtraceRegs) PC ¶
func (r *PtraceRegs) PC() uint64
func (*PtraceRegs) SetPC ¶
func (r *PtraceRegs) SetPC(pc uint64)
type RawSockaddr ¶
type RawSockaddrAny ¶
type RawSockaddrAny struct { Addr RawSockaddr Pad [96]int8 }
type RawSockaddrInet4 ¶
type RawSockaddrInet6 ¶
type RawSockaddrLinklayer ¶
type RawSockaddrNetlink ¶
type RawSockaddrUnix ¶
type Signal ¶
type Signal int
A Signal is a number describing a process signal. It implements the os.Signal interface.
type Sockaddr ¶
type Sockaddr interface {
// contains filtered or unexported methods
}
func Getpeername ¶
func Getsockname ¶
type SockaddrInet4 ¶
type SockaddrInet6 ¶
type SockaddrLinklayer ¶
type SockaddrNetlink ¶
type SockaddrUnix ¶
type SockaddrUnix struct { Name string // contains filtered or unexported fields }
type SocketControlMessage ¶
type SocketControlMessage struct { Header Cmsghdr Data []byte }
SocketControlMessage represents a socket control message.
func ParseSocketControlMessage ¶
func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error)
ParseSocketControlMessage parses b as an array of socket control messages.
type SysProcAttr ¶
type SysProcAttr struct { Chroot string // Chroot. Credential *Credential // Credential. Ptrace bool // Enable tracing. Setsid bool // Create session. Setpgid bool // Set process group ID to new pid (SYSV setpgrp) Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set) Noctty bool // Detach fd 0 from controlling terminal Ctty int // Controlling TTY fd (Linux only) Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only) Cloneflags uintptr // Flags for clone calls (Linux only) }
type WaitStatus ¶
type WaitStatus uint32
func (WaitStatus) Continued ¶
func (w WaitStatus) Continued() bool
func (WaitStatus) CoreDump ¶
func (w WaitStatus) CoreDump() bool
func (WaitStatus) ExitStatus ¶
func (w WaitStatus) ExitStatus() int
func (WaitStatus) Exited ¶
func (w WaitStatus) Exited() bool
func (WaitStatus) Signal ¶
func (w WaitStatus) Signal() int
func (WaitStatus) Signaled ¶
func (w WaitStatus) Signaled() bool
func (WaitStatus) StopSignal ¶
func (w WaitStatus) StopSignal() int
func (WaitStatus) Stopped ¶
func (w WaitStatus) Stopped() bool
func (WaitStatus) TrapCause ¶
func (w WaitStatus) TrapCause() int
Source Files ¶
- env_unix.go
- errstr.go
- errstr_linux.go
- errstr_nor.go
- exec_linux.go
- exec_stubs.go
- exec_unix.go
- libcall_irix.go
- libcall_linux.go
- libcall_linux_alpha.go
- libcall_linux_amd64.go
- libcall_linux_utimesnano.go
- libcall_posix.go
- libcall_posix_largefile.go
- libcall_posix_regfile.go
- libcall_posix_utimesnano.go
- libcall_support.go
- libcall_uname.go
- libcall_wait4.go
- libcall_waitpid.go
- lsf_linux.go
- netlink_linux.go
- race0.go
- sleep_rtems.go
- sleep_select.go
- sockcmsg_linux.go
- sockcmsg_unix.go
- socket.go
- socket_bsd.go
- socket_irix.go
- socket_linux.go
- socket_posix.go
- socket_xnet.go
- str.go
- syscall.go
- syscall_errno.go
- syscall_linux_alpha.go
- syscall_linux_amd64.go
- syscall_stubs.go
- syscall_unix.go