美文网首页
Golang标准库——syscall

Golang标准库——syscall

作者: DevilRoshan | 来源:发表于2020-10-23 00:38 被阅读0次

    syscall

    syscall包包含一个指向底层操作系统原语的接口。详细信息取决于基础系统,默认情况下,godoc将显示当前系统的syscall文档。如果要godoc显示其他系统的syscall文档,请将GOOS和 GOARCH设置为所需的系统。例如,如果要在linux / amd64上查看freebsd / arm的文档,请将GOOS设置为freebsd,将 GOARCH设置为arm。 syscall的主要用途是在其他可以为系统提供更轻便接口的软件包中,例如“ os”,“ time”和“ net”。如果可以,请使用这些软件包,而不要使用此软件包。有关此软件包中功能和数据类型的详细信息,请参阅相应操作系统的手册。这些调用返回err == nil表示成功;否则err是描述故障的操作系统错误。在大多数系统上,该错误的类型为syscall.Errno。

    注意:此包装已锁定。应该迁移标准Go存储库之外的代码,以使用golang.org/x/sys存储库中的相应软件包。这也是应该应用新系统或版本所需的更新的地方。有关更多信息,请参见https://github.com/golang/go/blob/master/s/go1.4-syscall

    Constants

    const (
        AF_ALG                           = 0x26
        AF_APPLETALK                     = 0x5
        AF_ASH                           = 0x12
        // ......
        WSTOPPED                         = 0x2
        WUNTRACED                        = 0x2
    )
    
    const (
        E2BIG           = Errno(0x7)
        EACCES          = Errno(0xd)
        EADDRINUSE      = Errno(0x62)
        
        // ......
        EXFULL          = Errno(0x36)
    )
    

    Errors

    const (
        SIGABRT   = Signal(0x6)
        SIGALRM   = Signal(0xe)
        SIGBUS    = Signal(0x7)
        // ......
        SIGXCPU   = Signal(0x18)
        SIGXFSZ   = Signal(0x19)
    )
    

    Signals

    const (
        SYS_READ                   = 0
        SYS_WRITE                  = 1
        SYS_OPEN                   = 2
        // ......
        SYS_PRLIMIT64              = 302
    )
    
    const (
        SizeofSockaddrInet4     = 0x10
        SizeofSockaddrInet6     = 0x1c
        SizeofSockaddrAny       = 0x70
        // ......
        SizeofTCPInfo           = 0x68
    )
    
    const (
        IFA_UNSPEC          = 0x0
        IFA_ADDRESS         = 0x1
        IFA_LOCAL           = 0x2
        // ......
        SizeofRtNexthop     = 0x8
    )
    
    const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
    )
    
    const (
        VINTR    = 0x0
        VQUIT    = 0x1
        VERASE   = 0x2
        // ......
        TCSETS   = 0x5402
    )
    
    const ImplementsGetwd = true
    
    const (
        PathMax = 0x1000
    )
    
    const SizeofInotifyEvent = 0x10
    

    Variables

    var (
        Stdin  = 0
        Stdout = 1
        Stderr = 2
    )
    
    var ForkLock sync.RWMutex
    
    var SocketDisableIPv6 bool
    

    为了测试:客户端可以设置该标志以强制创建IPv6套接字以返回EAFNOSUPPORT。

    func Accept

    func Accept(fd int) (nfd int, sa Sockaddr, err error)
    

    func Accept4

    func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error)
    

    func Access

    func Access(path string, mode uint32) (err error)
    

    func Acct

    func Acct(path string) (err error)
    

    func Adjtimex

    func Adjtimex(buf *Timex) (state int, err error)
    

    func AttachLsf

    func AttachLsf(fd int, i []SockFilter) error
    

    弃用:改用golang.org/x/net/bpf。

    func Bind

    func Bind(fd int, sa Sockaddr) (err error)
    

    func BindToDevice

    func BindToDevice(fd int, device string) (err error)
    

    BindToDevice将与fd关联的套接字绑定到设备。

    func BytePtrFromString

    func BytePtrFromString(s string) (*byte, error)
    

    BytePtrFromString返回一个指向NUL终止的字节数组的指针,该数组包含s的文本。 如果s在任意位置包含NUL字节,则返回(nil,EINVAL)。

    func ByteSliceFromString

    func ByteSliceFromString(s string) ([]byte, error)
    

    ByteSliceFromString返回以NULL结尾的字节切片,其中包含s的文本。 如果s在任意位置包含NUL字节,则返回(nil,EINVAL)。

    func Chdir

    func Chdir(path string) (err error)
    

    func Chmod

    func Chmod(path string, mode uint32) (err error)
    

    func Chown

    func Chown(path string, uid int, gid int) (err error)
    

    func Chroot

    func Chroot(path string) (err error)
    

    func Clearenv

    func Clearenv()
    

    func Close

    func Close(fd int) (err error)
    

    func CloseOnExec

    func CloseOnExec(fd int)
    

    func CmsgLen

    func CmsgLen(datalen int) int
    

    CmsgLen会考虑到任何必要的对齐方式,返回要存储在Cmsghdr结构的Len字段中的值。

    func CmsgSpace

    func CmsgSpace(datalen int) int
    

    CmsgSpace返回辅助元素的字节数,该辅助元素的有效载荷为所传递的数据长度。

    func Connect

    func Connect(fd int, sa Sockaddr) (err error)
    

    func Creat

    func Creat(path string, mode uint32) (fd int, err error)
    

    func DetachLsf

    func DetachLsf(fd int) error
    

    弃用:改用golang.org/x/net/bpf。

    func Dup

    func Dup(oldfd int) (fd int, err error)
    

    func Dup2

    func Dup2(oldfd int, newfd int) (err error)
    

    func Dup3

    func Dup3(oldfd int, newfd int, flags int) (err error)
    

    func Environ

    func Environ() []string
    

    func EpollCreate

    func EpollCreate(size int) (fd int, err error)
    

    func EpollCreate1

    func EpollCreate1(flag int) (fd int, err error)
    

    func EpollCtl

    func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
    

    func EpollWait

    func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
    

    func Exec

    func Exec(argv0 string, argv []string, envv []string) (err error)
    

    Exec调用execve(2)系统调用。

    func Exit

    func Exit(code int)
    

    func Faccessat

    func Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
    

    func Fallocate

    func Fallocate(fd int, mode uint32, off int64, len int64) (err error)
    

    func Fchdir

    func Fchdir(fd int) (err error)
    

    func Fchmod

    func Fchmod(fd int, mode uint32) (err error)
    

    func Fchmodat

    func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
    

    func Fchown

    func Fchown(fd int, uid int, gid int) (err error)
    

    func Fchownat

    func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
    

    func FcntlFlock

    func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error
    

    FcntlFlock对F_GETLK,F_SETLK或F_SETLKW命令执行fcntl系统调用。

    func Fdatasync

    func Fdatasync(fd int) (err error)
    

    func Flock

    func Flock(fd int, how int) (err error)
    

    func ForkExec

    func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
    

    将fork和exec结合使用,请小心以确保线程安全。

    func Fstat

    func Fstat(fd int, stat *Stat_t) (err error)
    

    func Fstatfs

    func Fstatfs(fd int, buf *Statfs_t) (err error)
    

    func Fsync

    func Fsync(fd int) (err error)
    

    func Ftruncate

    func Ftruncate(fd int, length int64) (err error)
    

    func Futimes

    func Futimes(fd int, tv []Timeval) (err error)
    

    func Futimesat

    func Futimesat(dirfd int, path string, tv []Timeval) (err error)
    

    func Getcwd

    func Getcwd(buf []byte) (n int, err error)
    

    func Getdents

    func Getdents(fd int, buf []byte) (n int, err error)
    

    func Getegid

    func Getegid() (egid int)
    

    func Getenv

    func Getenv(key string) (value string, found bool)
    

    func Geteuid

    func Geteuid() (euid int)
    

    func Getgid

    func Getgid() (gid int)
    

    func Getgroups

    func Getgroups() (gids []int, err error)
    

    func Getpagesize

    func Getpagesize() int
    

    func Getpgid

    func Getpgid(pid int) (pgid int, err error)
    

    func Getpgrp

    func Getpgrp() (pid int)
    

    func Getpid

    func Getpid() (pid int)
    

    func Getppid

    func Getppid() (ppid int)
    

    func Getpriority

    func Getpriority(which int, who int) (prio int, err error)
    

    func Getrlimit

    func Getrlimit(resource int, rlim *Rlimit) (err error)
    

    func Getrusage

    func Getrusage(who int, rusage *Rusage) (err error)
    

    func GetsockoptInet4Addr

    func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error)
    

    func GetsockoptInt

    func GetsockoptInt(fd, level, opt int) (value int, err error)
    

    func Gettid

    func Gettid() (tid int)
    

    func Gettimeofday

    func Gettimeofday(tv *Timeval) (err error)
    

    func Getuid

    func Getuid() (uid int)
    

    func Getwd

    func Getwd() (wd string, err error)
    

    func Getxattr

    func Getxattr(path string, attr string, dest []byte) (sz int, err error)
    

    func InotifyAddWatch

    func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error)
    

    func InotifyInit

    func InotifyInit() (fd int, err error)
    

    func InotifyInit1

    func InotifyInit1(flags int) (fd int, err error)
    

    func InotifyRmWatch

    func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error)
    

    func Ioperm

    func Ioperm(from int, num int, on int) (err error)
    

    func Iopl

    func Iopl(level int) (err error)
    

    func Kill

    func Kill(pid int, sig Signal) (err error)
    

    func Klogctl

    func Klogctl(typ int, buf []byte) (n int, err error)
    

    func Lchown

    func Lchown(path string, uid int, gid int) (err error)
    

    func Link

    func Link(oldpath string, newpath string) (err error)
    

    func Listen

    func Listen(s int, n int) (err error)
    

    func Listxattr

    func Listxattr(path string, dest []byte) (sz int, err error)
    

    func LsfSocket

    func LsfSocket(ifindex, proto int) (int, error)
    

    不推荐使用: 使用golang.org/x/net/bpf 代替.

    func Lstat

    func Lstat(path string, stat *Stat_t) (err error)
    

    func Madvise

    func Madvise(b []byte, advice int) (err error)
    

    func Mkdir

    func Mkdir(path string, mode uint32) (err error)
    

    func Mkdirat

    func Mkdirat(dirfd int, path string, mode uint32) (err error)
    

    func Mkfifo

    func Mkfifo(path string, mode uint32) (err error)
    

    func Mknod

    func Mknod(path string, mode uint32, dev int) (err error)
    

    func Mknodat

    func Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
    

    func Mlock

    func Mlock(b []byte) (err error)
    

    func Mlockall

    func Mlockall(flags int) (err error)
    

    func Mmap

    func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)
    

    func Mount

    func Mount(source string, target string, fstype string, flags uintptr, data string) (err error)
    

    func Mprotect

    func Mprotect(b []byte, prot int) (err error)
    

    func Munlock

    func Munlock(b []byte) (err error)
    

    func Munlockall

    func Munlockall() (err error)
    

    func Munmap

    func Munmap(b []byte) (err error)
    

    func Nanosleep

    func Nanosleep(time *Timespec, leftover *Timespec) (err error)
    

    func NetlinkRIB

    func NetlinkRIB(proto, family int) ([]byte, error)
    

    NetlinkRIB返回路由信息库,称为RIB,它由网络设施信息,状态和参数组成。

    func Open

    func Open(path string, mode int, perm uint32) (fd int, err error)
    

    func Openat

    func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
    

    func ParseDirent

    func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string)
    

    ParseDirent最多解析buf中的最大目录条目,并将名称附加到名称中。 它返回从buf消耗的字节数,添加到名称中的条目数以及新名称切片。

    func ParseNetlinkMessage

    func ParseNetlinkMessage(b []byte) ([]NetlinkMessage, error)
    

    ParseNetlinkMessage将b解析为一组netlink消息,并返回包含NetlinkMessage结构的切片。

    func ParseNetlinkRouteAttr

    func ParseNetlinkRouteAttr(m *NetlinkMessage) ([]NetlinkRouteAttr, error)
    

    ParseNetlinkRouteAttr将m的有效载荷解析为一组netlink路由属性,并返回包含NetlinkRouteAttr结构的切片。

    func ParseSocketControlMessage

    func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error)
    

    ParseSocketControlMessage将b解析为套接字控制消息的数组。

    func ParseUnixRights

    func ParseUnixRights(m *SocketControlMessage) ([]int, error)
    

    ParseUnixRights解码套接字控制消息,该消息包含来自另一个进程的打开文件描述符的整数数组。

    func Pause

    func Pause() (err error)
    

    func Pipe

    func Pipe(p []int) (err error)
    

    func Pipe2

    func Pipe2(p []int, flags int) (err error)
    

    func PivotRoot

    func PivotRoot(newroot string, putold string) (err error)
    

    func Pread

    func Pread(fd int, p []byte, offset int64) (n int, err error)
    

    func PtraceAttach

    func PtraceAttach(pid int) (err error)
    

    func PtraceCont

    func PtraceCont(pid int, signal int) (err error)
    

    func PtraceDetach

    func PtraceDetach(pid int) (err error)
    

    func PtraceGetEventMsg

    func PtraceGetEventMsg(pid int) (msg uint, err error)
    

    func PtraceGetRegs

    func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error)
    

    func PtracePeekData

    func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error)
    

    func PtracePeekText

    func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error)
    

    func PtracePokeData

    func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error)
    

    func PtracePokeText

    func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error)
    

    func PtraceSetOptions

    func PtraceSetOptions(pid int, options int) (err error)
    

    func PtraceSetRegs

    func PtraceSetRegs(pid int, regs *PtraceRegs) (err error)
    

    func PtraceSingleStep

    func PtraceSingleStep(pid int) (err error)
    

    func PtraceSyscall

    func PtraceSyscall(pid int, signal int) (err error)
    

    func Pwrite

    func Pwrite(fd int, p []byte, offset int64) (n int, err error)
    

    func RawSyscall

    func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
    

    func RawSyscall6

    func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
    

    func Read

    func Read(fd int, p []byte) (n int, err error)
    

    func ReadDirent

    func ReadDirent(fd int, buf []byte) (n int, err error)
    

    func Readlink

    func Readlink(path string, buf []byte) (n int, err error)
    

    func Reboot

    func Reboot(cmd int) (err error)
    

    func Recvfrom

    func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error)
    

    func Recvmsg

    func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error)
    

    func Removexattr

    func Removexattr(path string, attr string) (err error)
    

    func Rename

    func Rename(oldpath string, newpath string) (err error)
    

    func Renameat

    func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
    

    func Rmdir

    func Rmdir(path string) error
    

    func Seek

    func Seek(fd int, offset int64, whence int) (off int64, err error)
    

    func Select

    func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
    

    func Sendfile

    func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    

    func Sendmsg

    func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error)
    

    func SendmsgN

    func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error)
    

    func Sendto

    func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error)
    

    func SetLsfPromisc

    func SetLsfPromisc(name string, m bool) error
    

    不推荐使用: 使用golang.org/x/net/bpf 代替.

    func SetNonblock

    func SetNonblock(fd int, nonblocking bool) (err error)
    

    func Setdomainname

    func Setdomainname(p []byte) (err error)
    

    func Setenv

    func Setenv(key, value string) error
    

    func Setfsgid

    func Setfsgid(gid int) (err error)
    

    func Setfsuid

    func Setfsuid(uid int) (err error)
    

    func Setgid

    func Setgid(gid int) (err error)
    

    func Setgroups

    func Setgroups(gids []int) (err error)
    

    func Sethostname

    func Sethostname(p []byte) (err error)
    

    func Setpgid

    func Setpgid(pid int, pgid int) (err error)
    

    func Setpriority

    func Setpriority(which int, who int, prio int) (err error)
    

    func Setregid

    func Setregid(rgid int, egid int) (err error)
    

    func Setresgid

    func Setresgid(rgid int, egid int, sgid int) (err error)
    

    func Setresuid

    func Setresuid(ruid int, euid int, suid int) (err error)
    

    func Setreuid

    func Setreuid(ruid int, euid int) (err error)
    

    func Setrlimit

    func Setrlimit(resource int, rlim *Rlimit) (err error)
    

    func Setsid

    func Setsid() (pid int, err error)
    

    func SetsockoptByte

    func SetsockoptByte(fd, level, opt int, value byte) (err error)
    

    func SetsockoptICMPv6Filter

    func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error
    

    func SetsockoptIPMreq

    func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error)
    

    func SetsockoptIPMreqn

    func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error)
    

    func SetsockoptIPv6Mreq

    func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error)
    

    func SetsockoptInet4Addr

    func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error)
    

    func SetsockoptInt

    func SetsockoptInt(fd, level, opt int, value int) (err error)
    

    func SetsockoptLinger

    func SetsockoptLinger(fd, level, opt int, l *Linger) (err error)
    

    func SetsockoptString

    func SetsockoptString(fd, level, opt int, s string) (err error)
    

    func SetsockoptTimeval

    func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error)
    

    func Settimeofday

    func Settimeofday(tv *Timeval) (err error)
    

    func Setuid

    func Setuid(uid int) (err error)
    

    func Setxattr

    func Setxattr(path string, attr string, data []byte, flags int) (err error)
    

    func Shutdown

    func Shutdown(fd int, how int) (err error)
    

    func SlicePtrFromStrings

    func SlicePtrFromStrings(ss []string) ([]*byte, error)
    

    SlicePtrFromStrings将字符串切片转换为指向NUL终止的字节数组的指针切片。 如果任何字符串包含NUL字节,则返回(nil,EINVAL)。

    func Socket

    func Socket(domain, typ, proto int) (fd int, err error)
    

    func Socketpair

    func Socketpair(domain, typ, proto int) (fd [2]int, err error)
    

    func Splice

    func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    

    func StartProcess

    func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error)
    

    StartProcess将ForkExec包装为包 os.

    func Stat

    func Stat(path string, stat *Stat_t) (err error)
    

    func [tatfs

    func Statfs(path string, buf *Statfs_t) (err error)
    

    func StringBytePtr

    func StringBytePtr(s string) *byte
    

    StringBytePtr返回一个指向NUL终止的字节数组的指针。 如果s包含NUL字节,则此函数将紧急而不是返回错误。

    不推荐使用:改用BytePtrFromString。

    func StringByteSlice

    func StringByteSlice(s string) []byte
    

    StringByteSlice将字符串转换为以NUL终止的[] byte,如果s包含NUL字节,则此函数会发生恐慌而不是返回错误。

    不推荐使用:改用ByteSliceFromString。

    func StringSlicePtr

    func StringSlicePtr(ss []string) []*byte
    

    StringSlicePtr将字符串切片转换为指向NUL终止的字节数组的指针切片。 如果任何字符串包含NUL字节,则此函数会紧急而不是返回错误。

    弃用:改用SlicePtrFromStrings。

    func Symlink

    func Symlink(oldpath string, newpath string) (err error)
    

    func Sync

    func Sync()
    

    func SyncFileRange

    func SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    

    func Syscall

    func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
    

    func Syscall6

    func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
    

    func Sysinfo

    func Sysinfo(info *Sysinfo_t) (err error)
    

    func Tee

    func Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
    

    func Tgkill

    func Tgkill(tgid int, tid int, sig Signal) (err error)
    

    func Times

    func Times(tms *Tms) (ticks uintptr, err error)
    

    func TimespecToNsec

    func TimespecToNsec(ts Timespec) int64
    

    自Unix时代以来,TimespecToNsec将Timespec值转换为十亿分之一秒。

    func TimevalToNsec

    func TimevalToNsec(tv Timeval) int64
    

    自Unix时代以来,TimevalToNsec将Timeval值转换为十亿分之一秒。

    func Truncate

    func Truncate(path string, length int64) (err error)
    

    func Umask

    func Umask(mask int) (oldmask int)
    

    func Uname

    func Uname(buf *Utsname) (err error)
    

    func UnixCredentials

    func UnixCredentials(ucred *Ucred) []byte
    

    UnixCredentials将凭据编码为套接字控制消息,以发送给另一个进程。 这可以用于身份验证。

    func UnixRights

    func UnixRights(fds ...int) []byte
    

    UnixRights将一组打开的文件描述符编码为套接字控制消息,以发送给另一个进程。

    func Unlink

    func Unlink(path string) error
    

    func Unlinkat

    func Unlinkat(dirfd int, path string) error
    

    func Unmount

    func Unmount(target string, flags int) (err error)
    

    func Unsetenv

    func Unsetenv(key string) error
    

    func Unshare

    func Unshare(flags int) (err error)
    

    func Ustat

    func Ustat(dev int, ubuf *Ustat_t) (err error)
    

    func Utime

    func Utime(path string, buf *Utimbuf) (err error)
    

    func Utimes

    func Utimes(path string, tv []Timeval) (err error)
    

    func UtimesNano

    func UtimesNano(path string, ts []Timespec) (err error)
    

    func Wait4

    func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error)
    

    func Write

    func Write(fd int, p []byte) (n int, err error)
    

    type Cmsghdr

    type Cmsghdr struct {
        Len   uint64
        Level int32
        Type  int32
    }
    

    func (*Cmsghdr) SetLen

    func (cmsg *Cmsghdr) SetLen(length int)
    

    type Credential

    type Credential struct {
        Uid    uint32   // User ID.
        Gid    uint32   // Group ID.
        Groups []uint32 // Supplementary group IDs.
    }
    

    Credential保存由StartProcess启动的子进程假定的用户和组标识。

    type Dirent

    type Dirent struct {
        Ino       uint64
        Off       int64
        Reclen    uint16
        Type      uint8
        Name      [256]int8
        Pad_cgo_0 [5]byte
    }
    

    type EpollEvent

    type EpollEvent struct {
        Events uint32
        Fd     int32
        Pad    int32
    }
    

    type Errno

    type Errno uintptr
    

    Errno是描述错误情况的无符号数字。 它实现了错误接口。 按照惯例,零Errno是非错误的,因此从Errno转换为error的代码应使用:

    err = nil
    if errno != 0 {
        err = errno
    }
    

    func (Errno) Error

    func (e Errno) Error() string
    

    func (Errno) Temporary

    func (e Errno) Temporary() bool
    

    func (Errno) Timeout

    func (e Errno) Timeout() bool
    

    type FdSet

    type FdSet struct {
        Bits [16]int64
    }
    

    type Flock_t

    type Flock_t struct {
        Type      int16
        Whence    int16
        Pad_cgo_0 [4]byte
        Start     int64
        Len       int64
        Pid       int32
        Pad_cgo_1 [4]byte
    }
    

    type Fsid

    type Fsid struct {
        X__val [2]int32
    }
    

    type ICMPv6Filter

    type ICMPv6Filter struct {
        Data [8]uint32
    }
    

    func GetsockoptICMPv6Filter

    func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error)
    

    type IPMreq

    type IPMreq struct {
        Multiaddr [4]byte /* in_addr */
        Interface [4]byte /* in_addr */
    }
    

    func GetsockoptIPMreq

    func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error)
    

    type IPMreqn

    type IPMreqn struct {
        Multiaddr [4]byte /* in_addr */
        Address   [4]byte /* in_addr */
        Ifindex   int32
    }
    

    func GetsockoptIPMreqn

    func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error)
    

    type IPv6MTUInfo

    type IPv6MTUInfo struct {
        Addr RawSockaddrInet6
        Mtu  uint32
    }
    

    func GetsockoptIPv6MTUInfo

    func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error)
    

    type IPv6Mreq

    type IPv6Mreq struct {
        Multiaddr [16]byte /* in6_addr */
        Interface uint32
    }
    

    func GetsockoptIPv6Mreq

    func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error)
    

    type IfAddrmsg

    type IfAddrmsg struct {
        Family    uint8
        Prefixlen uint8
        Flags     uint8
        Scope     uint8
        Index     uint32
    }
    

    type IfInfomsg

    type IfInfomsg struct {
        Family     uint8
        X__ifi_pad uint8
        Type       uint16
        Index      int32
        Flags      uint32
        Change     uint32
    }
    

    type Inet4Pktinfo

    type Inet4Pktinfo struct {
        Ifindex  int32
        Spec_dst [4]byte /* in_addr */
        Addr     [4]byte /* in_addr */
    }
    

    type Inet6Pktinfo

    type Inet6Pktinfo struct {
        Addr    [16]byte /* in6_addr */
        Ifindex uint32
    }
    

    type InotifyEvent

    type InotifyEvent struct {
        Wd     int32
        Mask   uint32
        Cookie uint32
        Len    uint32
        Name   [0]uint8
    }
    

    type Iovec

    type Iovec struct {
        Base *byte
        Len  uint64
    }
    

    func (*Iovec) SetLen

    func (iov *Iovec) SetLen(length int)
    

    type Linger

    type Linger struct {
        Onoff  int32
        Linger int32
    }
    

    type Msghdr

    type Msghdr struct {
        Name       *byte
        Namelen    uint32
        Pad_cgo_0  [4]byte
        Iov        *Iovec
        Iovlen     uint64
        Control    *byte
        Controllen uint64
        Flags      int32
        Pad_cgo_1  [4]byte
    }
    

    func (*Msghdr) SetControllen

    func (msghdr *Msghdr) SetControllen(length int)
    

    type NetlinkMessage

    type NetlinkMessage struct {
        Header NlMsghdr
        Data   []byte
    }
    

    NetlinkMessage表示网络链接消息。

    type NetlinkRouteAttr

    type NetlinkRouteAttr struct {
        Attr  RtAttr
        Value []byte
    }
    

    NetlinkRouteAttr表示网络链接路由属性。

    type NetlinkRouteRequest

    type NetlinkRouteRequest struct {
        Header NlMsghdr
        Data   RtGenmsg
    }
    

    NetlinkRouteRequest表示从内核接收路由和链接状态的请求消息。

    type NlAttr

    type NlAttr struct {
        Len  uint16
        Type uint16
    }
    

    type NlMsgerr

    type NlMsgerr struct {
        Error int32
        Msg   NlMsghdr
    }
    

    type NlMsghdr

    type NlMsghdr struct {
        Len   uint32
        Type  uint16
        Flags uint16
        Seq   uint32
        Pid   uint32
    }
    

    type ProcAttr

    type ProcAttr struct {
        Dir   string    // Current working directory.
        Env   []string  // Environment.
        Files []uintptr // File descriptors.
        Sys   *SysProcAttr
    }
    

    ProcAttr保留将应用于StartProcess启动的新流程的属性。

    type PtraceRegs

    type PtraceRegs struct {
        R15      uint64
        R14      uint64
        R13      uint64
        R12      uint64
        Rbp      uint64
        Rbx      uint64
        R11      uint64
        R10      uint64
        R9       uint64
        R8       uint64
        Rax      uint64
        Rcx      uint64
        Rdx      uint64
        Rsi      uint64
        Rdi      uint64
        Orig_rax uint64
        Rip      uint64
        Cs       uint64
        Eflags   uint64
        Rsp      uint64
        Ss       uint64
        Fs_base  uint64
        Gs_base  uint64
        Ds       uint64
        Es       uint64
        Fs       uint64
        Gs       uint64
    }
    

    func (*PtraceRegs) PC

    func (r *PtraceRegs) PC() uint64
    

    func (*PtraceRegs) SetPC

    func (r *PtraceRegs) SetPC(pc uint64)
    

    type RawSockaddr

    type RawSockaddr struct {
        Family uint16
        Data   [14]int8
    }
    

    type RawSockaddrAny

    type RawSockaddrAny struct {
        Addr RawSockaddr
        Pad  [96]int8
    }
    

    type RawSockaddrInet4

    type RawSockaddrInet4 struct {
        Family uint16
        Port   uint16
        Addr   [4]byte /* in_addr */
        Zero   [8]uint8
    }
    

    type RawSockaddrInet6

    type RawSockaddrInet6 struct {
        Family   uint16
        Port     uint16
        Flowinfo uint32
        Addr     [16]byte /* in6_addr */
        Scope_id uint32
    }
    

    type RawSockaddrLinklayer

    type RawSockaddrLinklayer struct {
        Family   uint16
        Protocol uint16
        Ifindex  int32
        Hatype   uint16
        Pkttype  uint8
        Halen    uint8
        Addr     [8]uint8
    }
    

    type RawSockaddrNetlink

    type RawSockaddrNetlink struct {
        Family uint16
        Pad    uint16
        Pid    uint32
        Groups uint32
    }
    

    type RawSockaddrUnix

    type RawSockaddrUnix struct {
        Family uint16
        Path   [108]int8
    }
    

    type Rlimit

    type Rlimit struct {
        Cur uint64
        Max uint64
    }
    

    type RtAttr

    type RtAttr struct {
        Len  uint16
        Type uint16
    }
    

    type RtGenmsg

    type RtGenmsg struct {
        Family uint8
    }
    

    type RtMsg

    type RtMsg struct {
        Family   uint8
        Dst_len  uint8
        Src_len  uint8
        Tos      uint8
        Table    uint8
        Protocol uint8
        Scope    uint8
        Type     uint8
        Flags    uint32
    }
    

    type RtNexthop

    type RtNexthop struct {
        Len     uint16
        Flags   uint8
        Hops    uint8
        Ifindex int32
    }
    

    type Rusage

    type Rusage struct {
        Utime    Timeval
        Stime    Timeval
        Maxrss   int64
        Ixrss    int64
        Idrss    int64
        Isrss    int64
        Minflt   int64
        Majflt   int64
        Nswap    int64
        Inblock  int64
        Oublock  int64
        Msgsnd   int64
        Msgrcv   int64
        Nsignals int64
        Nvcsw    int64
        Nivcsw   int64
    }
    

    type Signal

    type Signal int
    

    信号是描述过程信号的数字。 它实现了os.Signal接口。

    func (Signal) Signal

    func (s Signal) Signal()
    

    func (Signal) String

    func (s Signal) String() string
    

    type SockFilter

    type SockFilter struct {
        Code uint16
        Jt   uint8
        Jf   uint8
        K    uint32
    }
    

    func LsfJump

    func LsfJump(code, k, jt, jf int) *SockFilter
    

    弃用:改用golang.org/x/net/bpf。

    func LsfStmt

    func LsfStmt(code, k int) *SockFilter
    

    弃用:改用golang.org/x/net/bpf。

    type SockFprog

    type SockFprog struct {
        Len       uint16
        Pad_cgo_0 [6]byte
        Filter    *SockFilter
    }
    

    type Sockaddr

    type Sockaddr interface {
        sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
    }
    

    func Getpeername

    func Getpeername(fd int) (sa Sockaddr, err error)
    

    func Getsockname

    func Getsockname(fd int) (sa Sockaddr, err error)
    

    type SockaddrInet4

    type SockaddrInet4 struct {
        Port int
        Addr [4]byte
        // contains filtered or unexported fields
    }
    

    type SockaddrInet6

    type SockaddrInet6 struct {
        Port   int
        ZoneId uint32
        Addr   [16]byte
        // contains filtered or unexported fields
    }
    

    type SockaddrLinklayer

    type SockaddrLinklayer struct {
        Protocol uint16
        Ifindex  int
        Hatype   uint16
        Pkttype  uint8
        Halen    uint8
        Addr     [8]byte
        // contains filtered or unexported fields
    }
    

    type SockaddrNetlink

    type SockaddrNetlink struct {
        Family uint16
        Pad    uint16
        Pid    uint32
        Groups uint32
        // contains filtered or unexported fields
    }
    

    type SockaddrUnix

    type SockaddrUnix struct {
        Name string
        // contains filtered or unexported fields
    }
    

    type SocketControlMessage

    type SocketControlMessage struct {
        Header Cmsghdr
        Data   []byte
    }
    

    SocketControlMessage表示套接字控制消息。

    type Stat_t

    type Stat_t struct {
        Dev       uint64
        Ino       uint64
        Nlink     uint64
        Mode      uint32
        Uid       uint32
        Gid       uint32
        X__pad0   int32
        Rdev      uint64
        Size      int64
        Blksize   int64
        Blocks    int64
        Atim      Timespec
        Mtim      Timespec
        Ctim      Timespec
        X__unused [3]int64
    }
    

    type Statfs_t

    type Statfs_t struct {
        Type    int64
        Bsize   int64
        Blocks  uint64
        Bfree   uint64
        Bavail  uint64
        Files   uint64
        Ffree   uint64
        Fsid    Fsid
        Namelen int64
        Frsize  int64
        Flags   int64
        Spare   [4]int64
    }
    

    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 Pgid, or, if Pgid == 0, to new pid.
        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
        Foreground   bool           // Place child's process group in foreground. (Implies Setpgid. Uses Ctty as fd of controlling TTY)
        Pgid         int            // Child's process group ID if Setpgid.
        Pdeathsig    Signal         // Signal that the process will get when its parent dies (Linux only)
        Cloneflags   uintptr        // Flags for clone calls (Linux only)
        Unshareflags uintptr        // Flags for unshare calls (Linux only)
        UidMappings  []SysProcIDMap // User ID mappings for user namespaces.
        GidMappings  []SysProcIDMap // Group ID mappings for user namespaces.
        // GidMappingsEnableSetgroups enabling setgroups syscall.
        // If false, then setgroups syscall will be disabled for the child process.
        // This parameter is no-op if GidMappings == nil. Otherwise for unprivileged
        // users this should be set to false for mappings work.
        GidMappingsEnableSetgroups bool
    }
    

    type SysProcIDMap

    type SysProcIDMap struct {
        ContainerID int // Container ID.
        HostID      int // Host ID.
        Size        int // Size.
    }
    

    SysProcIDMap保留用于Linux中用户命名空间的容器ID到主机ID的映射。 参见user_namespaces(7)。

    type Sysinfo_t

    type Sysinfo_t struct {
        Uptime    int64
        Loads     [3]uint64
        Totalram  uint64
        Freeram   uint64
        Sharedram uint64
        Bufferram uint64
        Totalswap uint64
        Freeswap  uint64
        Procs     uint16
        Pad       uint16
        Pad_cgo_0 [4]byte
        Totalhigh uint64
        Freehigh  uint64
        Unit      uint32
        X_f       [0]byte
        Pad_cgo_1 [4]byte
    }
    

    type TCPInfo

    type TCPInfo struct {
        State          uint8
        Ca_state       uint8
        Retransmits    uint8
        Probes         uint8
        Backoff        uint8
        Options        uint8
        Pad_cgo_0      [2]byte
        Rto            uint32
        Ato            uint32
        Snd_mss        uint32
        Rcv_mss        uint32
        Unacked        uint32
        Sacked         uint32
        Lost           uint32
        Retrans        uint32
        Fackets        uint32
        Last_data_sent uint32
        Last_ack_sent  uint32
        Last_data_recv uint32
        Last_ack_recv  uint32
        Pmtu           uint32
        Rcv_ssthresh   uint32
        Rtt            uint32
        Rttvar         uint32
        Snd_ssthresh   uint32
        Snd_cwnd       uint32
        Advmss         uint32
        Reordering     uint32
        Rcv_rtt        uint32
        Rcv_space      uint32
        Total_retrans  uint32
    }
    

    type Termios

    type Termios struct {
        Iflag     uint32
        Oflag     uint32
        Cflag     uint32
        Lflag     uint32
        Line      uint8
        Cc        [32]uint8
        Pad_cgo_0 [3]byte
        Ispeed    uint32
        Ospeed    uint32
    }
    

    type Time_t

    type Time_t int64
    

    func Timeh

    func Time(t *Time_t) (tt Time_t, err error)
    

    type Timespec

    type Timespec struct {
        Sec  int64
        Nsec int64
    }
    

    func NsecToTimespec

    func NsecToTimespec(nsec int64) Timespec
    

    自Unix时代以来,NsecToTimespec花费了数纳秒的时间,并返回相应的Timespec值。

    func (*Timespec) Nano

    func (ts *Timespec) Nano() int64
    

    func (*Timespec) Unix

    func (ts *Timespec) Unix() (sec int64, nsec int64)
    

    type Timeval

    type Timeval struct {
        Sec  int64
        Usec int64
    }
    

    func NsecToTimeval

    func NsecToTimeval(nsec int64) Timeval
    

    自Unix时代以来,NsecToTimeval花费了数纳秒的时间,并返回相应的Timeval值。

    func (*Timeval) Nano

    func (tv *Timeval) Nano() int64
    

    func (*Timeval) Unix

    func (tv *Timeval) Unix() (sec int64, nsec int64)
    

    type Timex

    type Timex struct {
        Modes     uint32
        Pad_cgo_0 [4]byte
        Offset    int64
        Freq      int64
        Maxerror  int64
        Esterror  int64
        Status    int32
        Pad_cgo_1 [4]byte
        Constant  int64
        Precision int64
        Tolerance int64
        Time      Timeval
        Tick      int64
        Ppsfreq   int64
        Jitter    int64
        Shift     int32
        Pad_cgo_2 [4]byte
        Stabil    int64
        Jitcnt    int64
        Calcnt    int64
        Errcnt    int64
        Stbcnt    int64
        Tai       int32
        Pad_cgo_3 [44]byte
    }
    

    type Tms

    type Tms struct {
        Utime  int64
        Stime  int64
        Cutime int64
        Cstime int64
    }
    

    type Ucred

    type Ucred struct {
        Pid int32
        Uid uint32
        Gid uint32
    }
    

    func GetsockoptUcred

    func GetsockoptUcred(fd, level, opt int) (*Ucred, error)
    

    func ParseUnixCredentials

    func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error)
    

    ParseUnixCredentials解码包含Ucred结构中的凭据的套接字控制消息。 要接收这样的消息,必须在套接字上启用SO_PASSCRED选项。

    type Ustat_t

    type Ustat_t struct {
        Tfree     int32
        Pad_cgo_0 [4]byte
        Tinode    uint64
        Fname     [6]int8
        Fpack     [6]int8
        Pad_cgo_1 [4]byte
    }
    

    type Utimbuf

    type Utimbuf struct {
        Actime  int64
        Modtime int64
    }
    

    type Utsname

    type Utsname struct {
        Sysname    [65]int8
        Nodename   [65]int8
        Release    [65]int8
        Version    [65]int8
        Machine    [65]int8
        Domainname [65]int8
    }
    

    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() Signal
    

    func (WaitStatus) Signaled

    func (w WaitStatus) Signaled() bool
    

    func (WaitStatus) StopSignal

    func (w WaitStatus) StopSignal() Signal
    

    func (WaitStatus) Stopped

    func (w WaitStatus) Stopped() bool
    

    func (WaitStatus) TrapCause

    func (w WaitStatus) TrapCause() int
    

    相关文章

      网友评论

          本文标题:Golang标准库——syscall

          本文链接:https://www.haomeiwen.com/subject/mpqrmktx.html