...

Source file src/golang.org/x/sys/unix/syscall_linux_amd64.go

Documentation: golang.org/x/sys/unix

     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  //go:build amd64 && linux
     6  // +build amd64,linux
     7  
     8  package unix
     9  
    10  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
    11  //sys	Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
    12  //sys	Fchown(fd int, uid int, gid int) (err error)
    13  //sys	Fstat(fd int, stat *Stat_t) (err error)
    14  //sys	Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
    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  //sys	Ioperm(from int, num int, on int) (err error)
    23  //sys	Iopl(level int) (err error)
    24  //sys	Lchown(path string, uid int, gid int) (err error)
    25  //sys	Listen(s int, n int) (err error)
    26  
    27  func Lstat(path string, stat *Stat_t) (err error) {
    28  	return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
    29  }
    30  
    31  //sys	MemfdSecret(flags int) (fd int, err error)
    32  //sys	Pause() (err error)
    33  //sys	pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    34  //sys	pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    35  //sys	Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
    36  //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    37  
    38  func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
    39  	var ts *Timespec
    40  	if timeout != nil {
    41  		ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
    42  	}
    43  	return Pselect(nfd, r, w, e, ts, nil)
    44  }
    45  
    46  //sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    47  //sys	setfsgid(gid int) (prev int, err error)
    48  //sys	setfsuid(uid int) (prev int, err error)
    49  //sysnb	Setrlimit(resource int, rlim *Rlimit) (err error)
    50  //sys	Shutdown(fd int, how int) (err error)
    51  //sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    52  
    53  func Stat(path string, stat *Stat_t) (err error) {
    54  	// Use fstatat, because Android's seccomp policy blocks stat.
    55  	return Fstatat(AT_FDCWD, path, stat, 0)
    56  }
    57  
    58  //sys	Statfs(path string, buf *Statfs_t) (err error)
    59  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    60  //sys	Truncate(path string, length int64) (err error)
    61  //sys	Ustat(dev int, ubuf *Ustat_t) (err error)
    62  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    63  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    64  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    65  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    66  //sysnb	setgroups(n int, list *_Gid_t) (err error)
    67  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    68  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    69  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    70  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    71  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    72  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    73  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    74  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    75  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    76  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    77  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    78  
    79  //sys	futimesat(dirfd int, path string, times *[2]Timeval) (err error)
    80  
    81  func Gettimeofday(tv *Timeval) (err error) {
    82  	errno := gettimeofday(tv)
    83  	if errno != 0 {
    84  		return errno
    85  	}
    86  	return nil
    87  }
    88  
    89  func Time(t *Time_t) (tt Time_t, err error) {
    90  	var tv Timeval
    91  	errno := gettimeofday(&tv)
    92  	if errno != 0 {
    93  		return 0, errno
    94  	}
    95  	if t != nil {
    96  		*t = Time_t(tv.Sec)
    97  	}
    98  	return Time_t(tv.Sec), nil
    99  }
   100  
   101  //sys	Utime(path string, buf *Utimbuf) (err error)
   102  //sys	utimes(path string, times *[2]Timeval) (err error)
   103  
   104  func setTimespec(sec, nsec int64) Timespec {
   105  	return Timespec{Sec: sec, Nsec: nsec}
   106  }
   107  
   108  func setTimeval(sec, usec int64) Timeval {
   109  	return Timeval{Sec: sec, Usec: usec}
   110  }
   111  
   112  func (r *PtraceRegs) PC() uint64 { return r.Rip }
   113  
   114  func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
   115  
   116  func (iov *Iovec) SetLen(length int) {
   117  	iov.Len = uint64(length)
   118  }
   119  
   120  func (msghdr *Msghdr) SetControllen(length int) {
   121  	msghdr.Controllen = uint64(length)
   122  }
   123  
   124  func (msghdr *Msghdr) SetIovlen(length int) {
   125  	msghdr.Iovlen = uint64(length)
   126  }
   127  
   128  func (cmsg *Cmsghdr) SetLen(length int) {
   129  	cmsg.Len = uint64(length)
   130  }
   131  
   132  func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) {
   133  	rsa.Service_name_len = uint64(length)
   134  }
   135  
   136  //sys	kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error)
   137  
   138  func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
   139  	cmdlineLen := len(cmdline)
   140  	if cmdlineLen > 0 {
   141  		// Account for the additional NULL byte added by
   142  		// BytePtrFromString in kexecFileLoad. The kexec_file_load
   143  		// syscall expects a NULL-terminated string.
   144  		cmdlineLen++
   145  	}
   146  	return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
   147  }
   148  

View as plain text