Source file src/syscall/syscall_linux_amd64.go

Documentation: syscall

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package syscall
     6  
     7  const (
     8  	_SYS_dup       = SYS_DUP2
     9  	_SYS_setgroups = SYS_SETGROUPS
    10  )
    11  
    12  //sys	Dup2(oldfd int, newfd int) (err error)
    13  //sys	Fchown(fd int, uid int, gid int) (err error)
    14  //sys	Fstat(fd int, stat *Stat_t) (err error)
    15  //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
    16  //sys	Ftruncate(fd int, length int64) (err error)
    17  //sysnb	Getegid() (egid int)
    18  //sysnb	Geteuid() (euid int)
    19  //sysnb	Getgid() (gid int)
    20  //sysnb	Getrlimit(resource int, rlim *Rlimit) (err error)
    21  //sysnb	Getuid() (uid int)
    22  //sysnb	InotifyInit() (fd int, err error)
    23  //sys	Ioperm(from int, num int, on int) (err error)
    24  //sys	Iopl(level int) (err error)
    25  //sys	Listen(s int, n int) (err error)
    26  //sys	Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    27  //sys	Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    28  //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    29  //sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
    30  //sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    31  //sys	Setfsgid(gid int) (err error)
    32  //sys	Setfsuid(uid int) (err error)
    33  //sysnb	Setregid(rgid int, egid int) (err error)
    34  //sysnb	Setresgid(rgid int, egid int, sgid int) (err error)
    35  //sysnb	Setresuid(ruid int, euid int, suid int) (err error)
    36  //sysnb	Setrlimit(resource int, rlim *Rlimit) (err error)
    37  //sysnb	Setreuid(ruid int, euid int) (err error)
    38  //sys	Shutdown(fd int, how int) (err error)
    39  //sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    40  //sys	Statfs(path string, buf *Statfs_t) (err error)
    41  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    42  //sys	Truncate(path string, length int64) (err error)
    43  //sys	accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
    44  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    45  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    46  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    47  //sys	fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
    48  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    49  //sysnb	setgroups(n int, list *_Gid_t) (err error)
    50  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    51  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    52  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    53  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    54  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    55  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    56  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    57  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    58  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    59  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    60  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    61  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
    62  
    63  func Stat(path string, stat *Stat_t) (err error) {
    64  	return fstatat(_AT_FDCWD, path, stat, 0)
    65  }
    66  
    67  func Lchown(path string, uid int, gid int) (err error) {
    68  	return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
    69  }
    70  
    71  func Lstat(path string, stat *Stat_t) (err error) {
    72  	return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
    73  }
    74  
    75  //go:noescape
    76  func gettimeofday(tv *Timeval) (err Errno)
    77  
    78  func Gettimeofday(tv *Timeval) (err error) {
    79  	errno := gettimeofday(tv)
    80  	if errno != 0 {
    81  		return errno
    82  	}
    83  	return nil
    84  }
    85  
    86  func Time(t *Time_t) (tt Time_t, err error) {
    87  	var tv Timeval
    88  	errno := gettimeofday(&tv)
    89  	if errno != 0 {
    90  		return 0, errno
    91  	}
    92  	if t != nil {
    93  		*t = Time_t(tv.Sec)
    94  	}
    95  	return Time_t(tv.Sec), nil
    96  }
    97  
    98  func setTimespec(sec, nsec int64) Timespec {
    99  	return Timespec{Sec: sec, Nsec: nsec}
   100  }
   101  
   102  func setTimeval(sec, usec int64) Timeval {
   103  	return Timeval{Sec: sec, Usec: usec}
   104  }
   105  
   106  //sysnb	pipe(p *[2]_C_int) (err error)
   107  
   108  func Pipe(p []int) (err error) {
   109  	if len(p) != 2 {
   110  		return EINVAL
   111  	}
   112  	var pp [2]_C_int
   113  	err = pipe(&pp)
   114  	p[0] = int(pp[0])
   115  	p[1] = int(pp[1])
   116  	return
   117  }
   118  
   119  //sysnb pipe2(p *[2]_C_int, flags int) (err error)
   120  
   121  func Pipe2(p []int, flags int) (err error) {
   122  	if len(p) != 2 {
   123  		return EINVAL
   124  	}
   125  	var pp [2]_C_int
   126  	err = pipe2(&pp, flags)
   127  	p[0] = int(pp[0])
   128  	p[1] = int(pp[1])
   129  	return
   130  }
   131  
   132  func (r *PtraceRegs) PC() uint64 { return r.Rip }
   133  
   134  func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
   135  
   136  func (iov *Iovec) SetLen(length int) {
   137  	iov.Len = uint64(length)
   138  }
   139  
   140  func (msghdr *Msghdr) SetControllen(length int) {
   141  	msghdr.Controllen = uint64(length)
   142  }
   143  
   144  func (cmsg *Cmsghdr) SetLen(length int) {
   145  	cmsg.Len = uint64(length)
   146  }
   147  
   148  func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno)
   149  

View as plain text