2011-10-23 21:04:37 +02:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// GNU/Linux library calls.
|
|
|
|
|
|
|
|
package syscall
|
|
|
|
|
2016-02-03 22:58:02 +01:00
|
|
|
import (
|
|
|
|
"internal/race"
|
|
|
|
"unsafe"
|
|
|
|
)
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
2013-11-24 03:38:28 +01:00
|
|
|
//__go_openat(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//futimesat(dirfd _C_int, path *byte, times *[2]Timeval) _C_int
|
2011-12-13 00:40:51 +01:00
|
|
|
func Futimesat(dirfd int, path string, tv []Timeval) (err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
if len(tv) != 2 {
|
|
|
|
return EINVAL
|
|
|
|
}
|
|
|
|
return futimesat(dirfd, StringBytePtr(path), (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func Futimes(fd int, tv []Timeval) (err error) {
|
2011-10-27 01:57:58 +02:00
|
|
|
// Believe it or not, this is the best we can do on GNU/Linux
|
2011-10-23 21:04:37 +02:00
|
|
|
// (and is what glibc does).
|
|
|
|
return Utimes("/proc/self/fd/"+itoa(fd), tv)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
|
2013-02-08 20:24:26 +01:00
|
|
|
//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
|
2011-10-25 20:06:32 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
// The peek requests are machine-size oriented, so we wrap it
|
|
|
|
// to retrieve arbitrary-length data.
|
|
|
|
|
|
|
|
// The ptrace syscall differs from glibc's ptrace.
|
|
|
|
// Peeks returns the word in *data, not as the return value.
|
|
|
|
|
|
|
|
var buf [sizeofPtr]byte
|
|
|
|
|
|
|
|
// Leading edge. PEEKTEXT/PEEKDATA don't require aligned
|
|
|
|
// access (PEEKUSER warns that it might), but if we don't
|
|
|
|
// align our reads, we might straddle an unmapped page
|
|
|
|
// boundary and not get the bytes leading up to the page
|
|
|
|
// boundary.
|
|
|
|
n := 0
|
|
|
|
if addr%sizeofPtr != 0 {
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0])))
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
n += copy(out, buf[addr%sizeofPtr:])
|
|
|
|
out = out[n:]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remainder.
|
|
|
|
for len(out) > 0 {
|
|
|
|
// We use an internal buffer to gaurantee alignment.
|
|
|
|
// It's not documented if this is necessary, but we're paranoid.
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(req, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0])))
|
|
|
|
if err != nil {
|
|
|
|
return n, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
copied := copy(out, buf[0:])
|
|
|
|
n += copied
|
|
|
|
out = out[copied:]
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
return n, nil
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return ptracePeek(PTRACE_PEEKTEXT, pid, addr, out)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return ptracePeek(PTRACE_PEEKDATA, pid, addr, out)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (count int, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
// As for ptracePeek, we need to align our accesses to deal
|
|
|
|
// with the possibility of straddling an invalid page.
|
|
|
|
|
|
|
|
// Leading edge.
|
|
|
|
n := 0
|
|
|
|
if addr%sizeofPtr != 0 {
|
|
|
|
var buf [sizeofPtr]byte
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0])))
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
n += copy(buf[addr%sizeofPtr:], data)
|
|
|
|
word := *((*uintptr)(unsafe.Pointer(&buf[0])))
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
data = data[n:]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Interior.
|
|
|
|
for len(data) > int(sizeofPtr) {
|
|
|
|
word := *((*uintptr)(unsafe.Pointer(&data[0])))
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(pokeReq, pid, addr+uintptr(n), word)
|
|
|
|
if err != nil {
|
|
|
|
return n, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
n += int(sizeofPtr)
|
|
|
|
data = data[sizeofPtr:]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trailing edge.
|
|
|
|
if len(data) > 0 {
|
|
|
|
var buf [sizeofPtr]byte
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0])))
|
|
|
|
if err != nil {
|
|
|
|
return n, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
copy(buf[0:], data)
|
|
|
|
word := *((*uintptr)(unsafe.Pointer(&buf[0])))
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(pokeReq, pid, addr+uintptr(n), word)
|
|
|
|
if err != nil {
|
|
|
|
return n, err
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
n += len(data)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
return n, nil
|
2011-10-23 21:04:37 +02:00
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return ptracePoke(PTRACE_POKETEXT, PTRACE_PEEKTEXT, pid, addr, data)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtraceSetOptions(pid int, options int) (err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options))
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtraceGetEventMsg(pid int) (msg uint, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
var data _C_long
|
2011-12-13 00:40:51 +01:00
|
|
|
err = ptrace(PTRACE_GETEVENTMSG, pid, 0, uintptr(unsafe.Pointer(&data)))
|
2011-10-23 21:04:37 +02:00
|
|
|
msg = uint(data)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtraceCont(pid int, signal int) (err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return ptrace(PTRACE_CONT, pid, 0, uintptr(signal))
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtraceSingleStep(pid int) (err error) { return ptrace(PTRACE_SINGLESTEP, pid, 0, 0) }
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtraceAttach(pid int) (err error) { return ptrace(PTRACE_ATTACH, pid, 0, 0) }
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) }
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
//sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//reboot(magic1 _C_uint, magic2 _C_uint, cmd _C_int, arg *byte) _C_int
|
2012-02-29 21:02:31 +01:00
|
|
|
func Reboot(cmd int) (err error) {
|
|
|
|
return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "")
|
|
|
|
}
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2013-01-29 21:52:43 +01:00
|
|
|
//sys accept4(fd int, sa *RawSockaddrAny, len *Socklen_t, flags int) (nfd int, err error)
|
|
|
|
//accept4(fd _C_int, sa *RawSockaddrAny, len *Socklen_t, flags _C_int) _C_int
|
|
|
|
|
|
|
|
func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
|
|
|
|
var rsa RawSockaddrAny
|
|
|
|
var len Socklen_t = SizeofSockaddrAny
|
|
|
|
nfd, err = accept4(fd, &rsa, &len, flags)
|
|
|
|
if err != nil {
|
|
|
|
return -1, nil, err
|
|
|
|
}
|
|
|
|
sa, err = anyToSockaddr(&rsa)
|
|
|
|
if err != nil {
|
|
|
|
Close(nfd)
|
|
|
|
return -1, nil, err
|
|
|
|
}
|
|
|
|
return nfd, sa, nil
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Acct(path string) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//acct(path *byte) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
//sys Adjtimex(buf *Timex) (state int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//adjtimex(buf *Timex) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2013-10-17 20:41:12 +02:00
|
|
|
//sysnb Dup3(oldfd int, newfd int, flags int) (err error)
|
|
|
|
//dup3(oldfd _C_int, newfd _C_int, flags _C_int) _C_int
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//faccessat(dirfd _C_int, pathname *byte, mode _C_int, flags _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-02-18 02:22:02 +01:00
|
|
|
//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//fallocate(fd _C_int, mode _C_int, offset Offset_t, len Offset_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//fchmodat(dirfd _C_int, pathname *byte, mode Mode_t, flags _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//fchownat(dirfd _C_int, path *byte, owner Uid_t, group Gid_t, flags _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Flock(fd int, how int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//flock(fd _C_int, how _C_int) _C_int
|
2011-10-25 20:06:32 +02:00
|
|
|
|
2012-02-18 02:22:02 +01:00
|
|
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
2017-07-21 22:25:13 +02:00
|
|
|
//fstatfs64(fd _C_int, buf *Statfs_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-01-31 21:47:55 +01:00
|
|
|
func Gettid() (tid int) {
|
|
|
|
r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0)
|
|
|
|
return int(r1)
|
|
|
|
}
|
2011-10-24 06:57:08 +02:00
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
func Getdents(fd int, buf []byte) (n int, err error) {
|
|
|
|
var p *byte
|
|
|
|
if len(buf) > 0 {
|
|
|
|
p = &buf[0]
|
|
|
|
} else {
|
|
|
|
p = (*byte)(unsafe.Pointer(&_zero))
|
|
|
|
}
|
2012-04-30 18:04:17 +02:00
|
|
|
s := SYS_GETDENTS64
|
|
|
|
if s == 0 {
|
|
|
|
s = SYS_GETDENTS
|
|
|
|
}
|
|
|
|
r1, _, errno := Syscall(uintptr(s), uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(buf)))
|
2012-02-29 21:02:31 +01:00
|
|
|
n = int(r1)
|
|
|
|
if n < 0 {
|
|
|
|
err = errno
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
|
|
|
return Getdents(fd, buf)
|
|
|
|
}
|
|
|
|
|
2013-10-17 20:41:12 +02:00
|
|
|
//sys Getxattr(path string, attr string, dest []byte) (sz int, err error)
|
|
|
|
//getxattr(path *byte, attr *byte, buf *byte, count Size_t) Ssize_t
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//inotify_add_watch(fd _C_int, pathname *byte, mask uint32) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sysnb InotifyInit() (fd int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//inotify_init() _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
//sysnb InotifyInit1(flags int) (fd int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//inotify_init1(flags _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//inotify_rm_watch(fd _C_int, wd uint32) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Klogctl(typ int, buf []byte) (n int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//klogctl(typ _C_int, bufp *byte, len _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2013-10-17 20:41:12 +02:00
|
|
|
//sys Listxattr(path string, dest []byte) (sz int, err error)
|
|
|
|
//listxattr(path *byte, list *byte, size Size_t) Ssize_t
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//mkdirat(dirfd _C_int, path *byte, mode Mode_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//mknodat(dirfd _C_int, path *byte, mode Mode_t, dev _dev_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2013-01-29 21:52:43 +01:00
|
|
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
|
|
|
//pipe2(p *[2]_C_int, flags _C_int) _C_int
|
|
|
|
func Pipe2(p []int, flags int) (err error) {
|
|
|
|
if len(p) != 2 {
|
|
|
|
return EINVAL
|
|
|
|
}
|
|
|
|
var pp [2]_C_int
|
|
|
|
err = pipe2(&pp, flags)
|
|
|
|
p[0] = int(pp[0])
|
|
|
|
p[1] = int(pp[1])
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys PivotRoot(newroot string, putold string) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//pivot_root(newroot *byte, putold *byte) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2013-10-17 20:41:12 +02:00
|
|
|
//sys Removexattr(path string, attr string) (err error)
|
|
|
|
//removexattr(path *byte, name *byte) _C_int
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//renameat(olddirfd _C_int, oldpath *byte, newdirfd _C_int, newpath *byte) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//sendfile64(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t
|
2011-12-13 00:40:51 +01:00
|
|
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
2016-02-03 22:58:02 +01:00
|
|
|
if race.Enabled {
|
|
|
|
race.ReleaseMerge(unsafe.Pointer(&ioSync))
|
2012-11-21 08:03:38 +01:00
|
|
|
}
|
2011-10-23 21:04:37 +02:00
|
|
|
var soff Offset_t
|
|
|
|
var psoff *Offset_t
|
|
|
|
if offset != nil {
|
2015-11-21 05:43:50 +01:00
|
|
|
soff = Offset_t(*offset)
|
2011-10-23 21:04:37 +02:00
|
|
|
psoff = &soff
|
|
|
|
}
|
2011-12-13 00:40:51 +01:00
|
|
|
written, err = sendfile(outfd, infd, psoff, count)
|
2011-10-23 21:04:37 +02:00
|
|
|
if offset != nil {
|
|
|
|
*offset = int64(soff)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Setfsgid(gid int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//setfsgid(gid Gid_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Setfsuid(uid int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//setfsuid(uid Uid_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//setresgid(rgid Gid_t, egid Gid_t, sgid Gid_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sysnb Setresuid(ruid int, eguid int, suid int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//setresuid(ruid Uid_t, euid Uid_t, suid Uid_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2013-10-17 20:41:12 +02:00
|
|
|
//sys Setxattr(path string, attr string, data []byte, flags int) (err error)
|
|
|
|
//setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
|
2011-12-13 00:40:51 +01:00
|
|
|
func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
var lroff _loff_t
|
|
|
|
var plroff *_loff_t
|
2012-01-14 00:35:44 +01:00
|
|
|
if roff != nil {
|
2012-12-05 09:49:01 +01:00
|
|
|
lroff = _loff_t(*roff)
|
2011-10-23 21:04:37 +02:00
|
|
|
plroff = &lroff
|
|
|
|
}
|
|
|
|
var lwoff _loff_t
|
|
|
|
var plwoff *_loff_t
|
2012-01-14 00:35:44 +01:00
|
|
|
if woff != nil {
|
2012-12-05 09:49:01 +01:00
|
|
|
lwoff = _loff_t(*woff)
|
2011-10-23 21:04:37 +02:00
|
|
|
plwoff = &lwoff
|
|
|
|
}
|
2011-12-13 00:40:51 +01:00
|
|
|
n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
|
2012-01-14 00:35:44 +01:00
|
|
|
if roff != nil {
|
2011-10-23 21:04:37 +02:00
|
|
|
*roff = int64(lroff)
|
|
|
|
}
|
2012-01-14 00:35:44 +01:00
|
|
|
if woff != nil {
|
2011-10-23 21:04:37 +02:00
|
|
|
*woff = int64(lwoff)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2012-02-18 02:22:02 +01:00
|
|
|
//sys Statfs(path string, buf *Statfs_t) (err error)
|
2017-07-21 22:25:13 +02:00
|
|
|
//statfs64(path *byte, buf *Statfs_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//sync_file_range(fd _C_int, off Offset_t, n Offset_t, flags _C_uint) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-02-29 21:02:31 +01:00
|
|
|
//sysnb Sysinfo(info *Sysinfo_t) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//sysinfo(info *Sysinfo_t) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//tee(rfd _C_int, wfd _C_int, len Size_t, flags _C_uint) Ssize_t
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2012-04-22 22:07:23 +02:00
|
|
|
func Tgkill(tgid int, tid int, sig Signal) error {
|
2012-02-29 21:02:31 +01:00
|
|
|
r1, _, errno := Syscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
|
|
|
|
if r1 < 0 {
|
|
|
|
return errno
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys unlinkat(dirfd int, path string, flags int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//unlinkat(dirfd _C_int, path *byte, flags _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
func Unlinkat(dirfd int, path string) (err error) {
|
2011-10-23 21:04:37 +02:00
|
|
|
return unlinkat(dirfd, path, 0)
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2
|
2013-02-08 20:24:26 +01:00
|
|
|
//umount2(target *byte, flags _C_int) _C_int
|
2011-10-23 21:04:37 +02:00
|
|
|
|
2011-12-13 00:40:51 +01:00
|
|
|
//sys Unshare(flags int) (err error)
|
2013-02-08 20:24:26 +01:00
|
|
|
//unshare(flags _C_int) _C_int
|