aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/unix/syscall_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/syscall_linux.go')
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_linux.go117
1 files changed, 103 insertions, 14 deletions
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go
index bfa20a9..a07ee49 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux.go
@@ -12,6 +12,9 @@
12package unix 12package unix
13 13
14import ( 14import (
15 "encoding/binary"
16 "net"
17 "runtime"
15 "syscall" 18 "syscall"
16 "unsafe" 19 "unsafe"
17) 20)
@@ -55,6 +58,15 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
55// ioctl itself should not be exposed directly, but additional get/set 58// ioctl itself should not be exposed directly, but additional get/set
56// functions for specific types are permissible. 59// functions for specific types are permissible.
57 60
61// IoctlSetPointerInt performs an ioctl operation which sets an
62// integer value on fd, using the specified request number. The ioctl
63// argument is called with a pointer to the integer value, rather than
64// passing the integer value directly.
65func IoctlSetPointerInt(fd int, req uint, value int) error {
66 v := int32(value)
67 return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
68}
69
58// IoctlSetInt performs an ioctl operation which sets an integer value 70// IoctlSetInt performs an ioctl operation which sets an integer value
59// on fd, using the specified request number. 71// on fd, using the specified request number.
60func IoctlSetInt(fd int, req uint, value int) error { 72func IoctlSetInt(fd int, req uint, value int) error {
@@ -69,6 +81,12 @@ func ioctlSetTermios(fd int, req uint, value *Termios) error {
69 return ioctl(fd, req, uintptr(unsafe.Pointer(value))) 81 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
70} 82}
71 83
84func IoctlSetRTCTime(fd int, value *RTCTime) error {
85 err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value)))
86 runtime.KeepAlive(value)
87 return err
88}
89
72// IoctlGetInt performs an ioctl operation which gets an integer value 90// IoctlGetInt performs an ioctl operation which gets an integer value
73// from fd, using the specified request number. 91// from fd, using the specified request number.
74func IoctlGetInt(fd int, req uint) (int, error) { 92func IoctlGetInt(fd int, req uint) (int, error) {
@@ -89,6 +107,12 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
89 return &value, err 107 return &value, err
90} 108}
91 109
110func IoctlGetRTCTime(fd int) (*RTCTime, error) {
111 var value RTCTime
112 err := ioctl(fd, RTC_RD_TIME, uintptr(unsafe.Pointer(&value)))
113 return &value, err
114}
115
92//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) 116//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
93 117
94func Link(oldpath string, newpath string) (err error) { 118func Link(oldpath string, newpath string) (err error) {
@@ -710,6 +734,51 @@ func (sa *SockaddrXDP) sockaddr() (unsafe.Pointer, _Socklen, error) {
710 return unsafe.Pointer(&sa.raw), SizeofSockaddrXDP, nil 734 return unsafe.Pointer(&sa.raw), SizeofSockaddrXDP, nil
711} 735}
712 736
737// This constant mirrors the #define of PX_PROTO_OE in
738// linux/if_pppox.h. We're defining this by hand here instead of
739// autogenerating through mkerrors.sh because including
740// linux/if_pppox.h causes some declaration conflicts with other
741// includes (linux/if_pppox.h includes linux/in.h, which conflicts
742// with netinet/in.h). Given that we only need a single zero constant
743// out of that file, it's cleaner to just define it by hand here.
744const px_proto_oe = 0
745
746type SockaddrPPPoE struct {
747 SID uint16
748 Remote net.HardwareAddr
749 Dev string
750 raw RawSockaddrPPPoX
751}
752
753func (sa *SockaddrPPPoE) sockaddr() (unsafe.Pointer, _Socklen, error) {
754 if len(sa.Remote) != 6 {
755 return nil, 0, EINVAL
756 }
757 if len(sa.Dev) > IFNAMSIZ-1 {
758 return nil, 0, EINVAL
759 }
760
761 *(*uint16)(unsafe.Pointer(&sa.raw[0])) = AF_PPPOX
762 // This next field is in host-endian byte order. We can't use the
763 // same unsafe pointer cast as above, because this value is not
764 // 32-bit aligned and some architectures don't allow unaligned
765 // access.
766 //
767 // However, the value of px_proto_oe is 0, so we can use
768 // encoding/binary helpers to write the bytes without worrying
769 // about the ordering.
770 binary.BigEndian.PutUint32(sa.raw[2:6], px_proto_oe)
771 // This field is deliberately big-endian, unlike the previous
772 // one. The kernel expects SID to be in network byte order.
773 binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID)
774 copy(sa.raw[8:14], sa.Remote)
775 for i := 14; i < 14+IFNAMSIZ; i++ {
776 sa.raw[i] = 0
777 }
778 copy(sa.raw[14:], sa.Dev)
779 return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil
780}
781
713func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { 782func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
714 switch rsa.Addr.Family { 783 switch rsa.Addr.Family {
715 case AF_NETLINK: 784 case AF_NETLINK:
@@ -820,6 +889,22 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
820 SharedUmemFD: pp.Shared_umem_fd, 889 SharedUmemFD: pp.Shared_umem_fd,
821 } 890 }
822 return sa, nil 891 return sa, nil
892 case AF_PPPOX:
893 pp := (*RawSockaddrPPPoX)(unsafe.Pointer(rsa))
894 if binary.BigEndian.Uint32(pp[2:6]) != px_proto_oe {
895 return nil, EINVAL
896 }
897 sa := &SockaddrPPPoE{
898 SID: binary.BigEndian.Uint16(pp[6:8]),
899 Remote: net.HardwareAddr(pp[8:14]),
900 }
901 for i := 14; i < 14+IFNAMSIZ; i++ {
902 if pp[i] == 0 {
903 sa.Dev = string(pp[14:i])
904 break
905 }
906 }
907 return sa, nil
823 } 908 }
824 return nil, EAFNOSUPPORT 909 return nil, EAFNOSUPPORT
825} 910}
@@ -1288,6 +1373,13 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
1288 return mount(source, target, fstype, flags, datap) 1373 return mount(source, target, fstype, flags, datap)
1289} 1374}
1290 1375
1376func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
1377 if raceenabled {
1378 raceReleaseMerge(unsafe.Pointer(&ioSync))
1379 }
1380 return sendfile(outfd, infd, offset, count)
1381}
1382
1291// Sendto 1383// Sendto
1292// Recvfrom 1384// Recvfrom
1293// Socketpair 1385// Socketpair
@@ -1302,8 +1394,10 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
1302//sys Chroot(path string) (err error) 1394//sys Chroot(path string) (err error)
1303//sys ClockGetres(clockid int32, res *Timespec) (err error) 1395//sys ClockGetres(clockid int32, res *Timespec) (err error)
1304//sys ClockGettime(clockid int32, time *Timespec) (err error) 1396//sys ClockGettime(clockid int32, time *Timespec) (err error)
1397//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
1305//sys Close(fd int) (err error) 1398//sys Close(fd int) (err error)
1306//sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) 1399//sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
1400//sys DeleteModule(name string, flags int) (err error)
1307//sys Dup(oldfd int) (fd int, err error) 1401//sys Dup(oldfd int) (fd int, err error)
1308//sys Dup3(oldfd int, newfd int, flags int) (err error) 1402//sys Dup3(oldfd int, newfd int, flags int) (err error)
1309//sysnb EpollCreate1(flag int) (fd int, err error) 1403//sysnb EpollCreate1(flag int) (fd int, err error)
@@ -1317,6 +1411,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
1317//sys fcntl(fd int, cmd int, arg int) (val int, err error) 1411//sys fcntl(fd int, cmd int, arg int) (val int, err error)
1318//sys Fdatasync(fd int) (err error) 1412//sys Fdatasync(fd int) (err error)
1319//sys Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) 1413//sys Fgetxattr(fd int, attr string, dest []byte) (sz int, err error)
1414//sys FinitModule(fd int, params string, flags int) (err error)
1320//sys Flistxattr(fd int, dest []byte) (sz int, err error) 1415//sys Flistxattr(fd int, dest []byte) (sz int, err error)
1321//sys Flock(fd int, how int) (err error) 1416//sys Flock(fd int, how int) (err error)
1322//sys Fremovexattr(fd int, attr string) (err error) 1417//sys Fremovexattr(fd int, attr string) (err error)
@@ -1338,6 +1433,7 @@ func Getpgrp() (pid int) {
1338//sysnb Getsid(pid int) (sid int, err error) 1433//sysnb Getsid(pid int) (sid int, err error)
1339//sysnb Gettid() (tid int) 1434//sysnb Gettid() (tid int)
1340//sys Getxattr(path string, attr string, dest []byte) (sz int, err error) 1435//sys Getxattr(path string, attr string, dest []byte) (sz int, err error)
1436//sys InitModule(moduleImage []byte, params string) (err error)
1341//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) 1437//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error)
1342//sysnb InotifyInit1(flags int) (fd int, err error) 1438//sysnb InotifyInit1(flags int) (fd int, err error)
1343//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) 1439//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error)
@@ -1359,7 +1455,6 @@ func Getpgrp() (pid int) {
1359//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) = SYS_PSELECT6 1455//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) = SYS_PSELECT6
1360//sys read(fd int, p []byte) (n int, err error) 1456//sys read(fd int, p []byte) (n int, err error)
1361//sys Removexattr(path string, attr string) (err error) 1457//sys Removexattr(path string, attr string) (err error)
1362//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
1363//sys Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) 1458//sys Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error)
1364//sys RequestKey(keyType string, description string, callback string, destRingid int) (id int, err error) 1459//sys RequestKey(keyType string, description string, callback string, destRingid int) (id int, err error)
1365//sys Setdomainname(p []byte) (err error) 1460//sys Setdomainname(p []byte) (err error)
@@ -1384,6 +1479,7 @@ func Setgid(uid int) (err error) {
1384 1479
1385//sys Setpriority(which int, who int, prio int) (err error) 1480//sys Setpriority(which int, who int, prio int) (err error)
1386//sys Setxattr(path string, attr string, data []byte, flags int) (err error) 1481//sys Setxattr(path string, attr string, data []byte, flags int) (err error)
1482//sys Signalfd(fd int, mask *Sigset_t, flags int) = SYS_SIGNALFD4
1387//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error) 1483//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error)
1388//sys Sync() 1484//sys Sync()
1389//sys Syncfs(fd int) (err error) 1485//sys Syncfs(fd int) (err error)
@@ -1428,15 +1524,12 @@ func Munmap(b []byte) (err error) {
1428// Vmsplice splices user pages from a slice of Iovecs into a pipe specified by fd, 1524// Vmsplice splices user pages from a slice of Iovecs into a pipe specified by fd,
1429// using the specified flags. 1525// using the specified flags.
1430func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) { 1526func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
1431 n, _, errno := Syscall6( 1527 var p unsafe.Pointer
1432 SYS_VMSPLICE, 1528 if len(iovs) > 0 {
1433 uintptr(fd), 1529 p = unsafe.Pointer(&iovs[0])
1434 uintptr(unsafe.Pointer(&iovs[0])), 1530 }
1435 uintptr(len(iovs)), 1531
1436 uintptr(flags), 1532 n, _, errno := Syscall6(SYS_VMSPLICE, uintptr(fd), uintptr(p), uintptr(len(iovs)), uintptr(flags), 0, 0)
1437 0,
1438 0,
1439 )
1440 if errno != 0 { 1533 if errno != 0 {
1441 return 0, syscall.Errno(errno) 1534 return 0, syscall.Errno(errno)
1442 } 1535 }
@@ -1527,8 +1620,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
1527// ClockNanosleep 1620// ClockNanosleep
1528// ClockSettime 1621// ClockSettime
1529// Clone 1622// Clone
1530// CreateModule
1531// DeleteModule
1532// EpollCtlOld 1623// EpollCtlOld
1533// EpollPwait 1624// EpollPwait
1534// EpollWaitOld 1625// EpollWaitOld
@@ -1572,7 +1663,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
1572// Pselect6 1663// Pselect6
1573// Ptrace 1664// Ptrace
1574// Putpmsg 1665// Putpmsg
1575// QueryModule
1576// Quotactl 1666// Quotactl
1577// Readahead 1667// Readahead
1578// Readv 1668// Readv
@@ -1606,7 +1696,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
1606// Shmdt 1696// Shmdt
1607// Shmget 1697// Shmget
1608// Sigaltstack 1698// Sigaltstack
1609// Signalfd
1610// Swapoff 1699// Swapoff
1611// Swapon 1700// Swapon
1612// Sysfs 1701// Sysfs