...

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

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

View as plain text