Source file src/syscall/syscall_linux_amd64.go

     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_setgroups  = SYS_SETGROUPS
     9  	_SYS_clone3     = 435
    10  	_SYS_faccessat2 = 439
    11  	_SYS_fchmodat2  = 452
    12  )
    13  
    14  //sys	Dup2(oldfd int, newfd int) (err error)
    15  //sys	Fchown(fd int, uid int, gid int) (err error)
    16  //sys	Fstat(fd int, stat *Stat_t) (err error)
    17  //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
    18  //sys	Ftruncate(fd int, length int64) (err error)
    19  //sysnb	Getegid() (egid int)
    20  //sysnb	Geteuid() (euid int)
    21  //sysnb	Getgid() (gid int)
    22  //sysnb	Getuid() (uid int)
    23  //sysnb	InotifyInit() (fd int, err error)
    24  //sys	Ioperm(from int, num int, on int) (err error)
    25  //sys	Iopl(level int) (err error)
    26  //sys	Listen(s int, n int) (err error)
    27  //sys	Pause() (err error)
    28  //sys	pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    29  //sys	pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    30  //sys	Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
    31  //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    32  //sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
    33  //sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    34  //sys	Setfsgid(gid int) (err error)
    35  //sys	Setfsuid(uid int) (err error)
    36  //sys	Shutdown(fd int, how int) (err error)
    37  //sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    38  //sys	Statfs(path string, buf *Statfs_t) (err error)
    39  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    40  //sys	Truncate(path string, length int64) (err error)
    41  //sys	Ustat(dev int, ubuf *Ustat_t) (err error)
    42  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    43  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    44  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    45  //sys	fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
    46  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    47  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    48  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    49  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    50  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    51  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    52  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    53  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    54  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    55  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    56  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    57  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    58  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
    59  
    60  func Stat(path string, stat *Stat_t) (err error) {
    61  	return fstatat(_AT_FDCWD, path, stat, 0)
    62  }
    63  
    64  func Lchown(path string, uid int, gid int) (err error) {
    65  	return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
    66  }
    67  
    68  func Lstat(path string, stat *Stat_t) (err error) {
    69  	return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
    70  }
    71  
    72  //sys	futimesat(dirfd int, path string, times *[2]Timeval) (err error)
    73  
    74  //go:noescape
    75  func gettimeofday(tv *Timeval) (err Errno)
    76  
    77  func Gettimeofday(tv *Timeval) (err error) {
    78  	errno := gettimeofday(tv)
    79  	if errno != 0 {
    80  		return errno
    81  	}
    82  	return nil
    83  }
    84  
    85  func Time(t *Time_t) (tt Time_t, err error) {
    86  	var tv Timeval
    87  	errno := gettimeofday(&tv)
    88  	if errno != 0 {
    89  		return 0, errno
    90  	}
    91  	if t != nil {
    92  		*t = Time_t(tv.Sec)
    93  	}
    94  	return Time_t(tv.Sec), nil
    95  }
    96  
    97  //sys	Utime(path string, buf *Utimbuf) (err error)
    98  //sys	utimes(path string, times *[2]Timeval) (err error)
    99  
   100  func setTimespec(sec, nsec int64) Timespec {
   101  	return Timespec{Sec: sec, Nsec: nsec}
   102  }
   103  
   104  func setTimeval(sec, usec int64) Timeval {
   105  	return Timeval{Sec: sec, Usec: usec}
   106  }
   107  
   108  func (r *PtraceRegs) PC() uint64 { return r.Rip }
   109  
   110  func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
   111  
   112  func (iov *Iovec) SetLen(length int) {
   113  	iov.Len = uint64(length)
   114  }
   115  
   116  func (msghdr *Msghdr) SetControllen(length int) {
   117  	msghdr.Controllen = uint64(length)
   118  }
   119  
   120  func (cmsg *Cmsghdr) SetLen(length int) {
   121  	cmsg.Len = uint64(length)
   122  }
   123  

View as plain text