2011-03-21 14:02:10 -06:00
|
|
|
// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
|
2009-06-01 23:15:08 -06:00
|
|
|
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
|
|
|
|
|
|
|
package syscall
|
|
|
|
|
2009-08-12 14:19:17 -06:00
|
|
|
import "unsafe"
|
2009-06-01 23:15:08 -06:00
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func setgroups(ngid int, gid *_Gid_t) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
|
|
|
|
wpid = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
|
|
|
|
fd = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2014-01-21 19:54:49 -07:00
|
|
|
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2014-01-21 19:54:49 -07:00
|
|
|
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func socket(domain int, typ int, proto int) (fd int, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
|
2009-12-15 16:40:16 -07:00
|
|
|
fd = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
2010-06-30 15:58:21 -06:00
|
|
|
|
2014-01-21 19:54:49 -07:00
|
|
|
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
|
2011-03-25 12:43:59 -06:00
|
|
|
_, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-03-25 12:43:59 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2014-01-21 19:54:49 -07:00
|
|
|
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-17 22:44:26 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-17 22:44:26 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Shutdown(s int, how int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-12-01 17:53:43 -07:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2012-09-23 22:06:22 -06:00
|
|
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-11-01 12:13:27 -07:00
|
|
|
if len(p) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&p[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-11-01 12:13:27 -07:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-11-01 12:13:27 -07:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2014-01-21 19:54:49 -07:00
|
|
|
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-11-01 12:13:27 -07:00
|
|
|
if len(buf) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&buf[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-11-01 12:13:27 -07:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
_, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-11-01 12:13:27 -07:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
2011-06-20 16:40:20 -06:00
|
|
|
r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
|
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-06-20 16:40:20 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2014-03-28 18:28:40 -06:00
|
|
|
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
|
|
|
|
r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
|
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-06-20 16:40:20 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2014-01-22 11:35:41 -07:00
|
|
|
func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
|
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(mib) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&mib[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
_, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-29 14:44:46 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func utimes(path string, timeval *[2]Timeval) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2010-05-19 18:47:57 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func futimes(fd int, timeval *[2]Timeval) (err error) {
|
2010-05-19 18:47:57 -06:00
|
|
|
_, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2010-05-19 18:47:57 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
2010-03-26 14:23:54 -06:00
|
|
|
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
|
|
|
|
val = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2010-03-24 22:59:21 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
|
2011-06-14 10:56:46 -06:00
|
|
|
_, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-06-14 10:56:46 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func pipe() (r int, w int, err error) {
|
2011-08-03 22:22:48 -06:00
|
|
|
r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
|
|
|
|
r = int(r0)
|
|
|
|
w = int(r1)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-08-03 22:22:48 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func kill(pid int, signum int, posix int) (err error) {
|
2010-03-26 14:23:54 -06:00
|
|
|
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Access(path string, mode uint32) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Chdir(path string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Chflags(path string, flags int) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Chmod(path string, mode uint32) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Chown(path string, uid int, gid int) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Chroot(path string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Close(fd int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Dup(fd int) (nfd int, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, e1 := RawSyscall(SYS_DUP, uintptr(fd), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
nfd = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Dup2(from int, to int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Exchangedata(path1 string, path2 string, options int) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path1)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var _p1 *byte
|
|
|
|
_p1, err = BytePtrFromString(path2)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
|
|
|
use(unsafe.Pointer(_p1))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-10-06 20:38:30 -06:00
|
|
|
func Exit(code int) {
|
2009-12-15 16:40:16 -07:00
|
|
|
Syscall(SYS_EXIT, uintptr(code), 0, 0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fchdir(fd int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2013-05-06 15:20:00 -06:00
|
|
|
func Fchflags(fd int, flags int) (err error) {
|
|
|
|
_, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fchmod(fd int, mode uint32) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fchown(fd int, uid int, gid int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Flock(fd int, how int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fpathconf(fd int, name int) (val int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
|
|
|
|
val = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fstat(fd int, stat *Stat_t) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fstatfs(fd int, stat *Statfs_t) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Fsync(fd int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Ftruncate(fd int, length int64) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(buf) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&buf[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getdtablesize() (size int) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
|
|
|
|
size = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getegid() (egid int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
egid = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Geteuid() (uid int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
uid = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getgid() (gid int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
gid = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Getpgid(pid int) (pgid int, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
pgid = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getpgrp() (pgrp int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
pgrp = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getpid() (pid int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
pid = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getppid() (ppid int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
ppid = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Getpriority(which int, who int) (prio int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
|
|
|
|
prio = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Getrlimit(which int, lim *Rlimit) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Getrusage(who int, rusage *Rusage) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Getsid(pid int) (sid int, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
sid = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Getuid() (uid int) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
uid = int(r0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2009-06-01 23:15:08 -06:00
|
|
|
func Issetugid() (tainted bool) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
tainted = bool(r0 != 0)
|
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Kqueue() (fd int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
|
|
|
|
fd = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Lchown(path string, uid int, gid int) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Link(path string, link string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var _p1 *byte
|
|
|
|
_p1, err = BytePtrFromString(link)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
|
|
|
use(unsafe.Pointer(_p1))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Listen(s int, backlog int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Lstat(path string, stat *Stat_t) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Mkdir(path string, mode uint32) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Mkfifo(path string, mode uint32) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Mknod(path string, mode uint32, dev int) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
2014-02-27 11:13:41 -07:00
|
|
|
|
|
|
|
func Mlock(b []byte) (err error) {
|
|
|
|
var _p0 unsafe.Pointer
|
|
|
|
if len(b) > 0 {
|
|
|
|
_p0 = unsafe.Pointer(&b[0])
|
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
|
|
|
func Mlockall(flags int) (err error) {
|
|
|
|
_, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
|
|
|
func Mprotect(b []byte, prot int) (err error) {
|
|
|
|
var _p0 unsafe.Pointer
|
|
|
|
if len(b) > 0 {
|
|
|
|
_p0 = unsafe.Pointer(&b[0])
|
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
|
|
|
func Munlock(b []byte) (err error) {
|
|
|
|
var _p0 unsafe.Pointer
|
|
|
|
if len(b) > 0 {
|
|
|
|
_p0 = unsafe.Pointer(&b[0])
|
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
|
|
|
func Munlockall() (err error) {
|
|
|
|
_, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
2010-09-24 13:17:20 -06:00
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Open(path string, mode int, perm uint32) (fd int, err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2009-12-15 16:40:16 -07:00
|
|
|
fd = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Pathconf(path string, name int) (val int, err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2009-12-15 16:40:16 -07:00
|
|
|
val = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Pread(fd int, p []byte, offset int64) (n int, err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(p) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&p[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(p) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&p[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2012-10-09 10:51:58 -06:00
|
|
|
func read(fd int, p []byte) (n int, err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(p) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&p[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Readlink(path string, buf []byte) (n int, err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var _p1 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(buf) > 0 {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
_p1 = unsafe.Pointer(&buf[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
_p1 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Rename(from string, to string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(from)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var _p1 *byte
|
|
|
|
_p1, err = BytePtrFromString(to)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
|
|
|
use(unsafe.Pointer(_p1))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Revoke(path string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Rmdir(path string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
|
|
|
|
newoffset = int64(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-16 18:17:02 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setegid(egid int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Seteuid(euid int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setgid(gid int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setlogin(name string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(name)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setpgid(pid int, pgid int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setpriority(which int, who int, prio int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setprivexec(flag int) (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setregid(rgid int, egid int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setreuid(ruid int, euid int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setrlimit(which int, lim *Rlimit) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setsid() (pid int, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
pid = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Settimeofday(tp *Timeval) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Setuid(uid int) (err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
_, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Stat(path string, stat *Stat_t) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Statfs(path string, stat *Statfs_t) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Symlink(path string, link string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var _p1 *byte
|
|
|
|
_p1, err = BytePtrFromString(link)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
|
|
|
use(unsafe.Pointer(_p1))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Sync() (err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
_, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Truncate(path string, length int64) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2010-02-16 12:43:25 -07:00
|
|
|
func Umask(newmask int) (oldmask int) {
|
|
|
|
r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
|
|
|
|
oldmask = int(r0)
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Undelete(path string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Unlink(path string) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func Unmount(path string, flags int) (err error) {
|
syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.
R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 15:24:32 -06:00
|
|
|
var _p0 *byte
|
|
|
|
_p0, err = BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
_, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
|
syscall: keep allocated C string live across call to Syscall
Given:
p := alloc()
fn_taking_ptr(p)
p is NOT recorded as live at the call to fn_taking_ptr:
it's not needed by the code following the call.
p was passed to fn_taking_ptr, and fn_taking_ptr must keep
it alive as long as it needs it.
In practice, fn_taking_ptr will keep its own arguments live
for as long as the function is executing.
But if instead you have:
p := alloc()
i := uintptr(unsafe.Pointer(p))
fn_taking_int(i)
p is STILL NOT recorded as live at the call to fn_taking_int:
it's not needed by the code following the call.
fn_taking_int is responsible for keeping its own arguments
live, but fn_taking_int is written to take an integer, so even
though fn_taking_int does keep its argument live, that argument
does not keep the allocated memory live, because the garbage
collector does not dereference integers.
The shorter form:
p := alloc()
fn_taking_int(uintptr(unsafe.Pointer(p)))
and the even shorter form:
fn_taking_int(uintptr(unsafe.Pointer(alloc())))
are both the same as the 3-line form above.
syscall.Syscall is like fn_taking_int: it is written to take a list
of integers, and yet those integers are sometimes pointers.
If there is no other copy of those pointers being kept live,
the memory they point at may be garbage collected during
the call to syscall.Syscall.
This is happening on Solaris: for whatever reason, the timing
is such that the garbage collector manages to free the string
argument to the open(2) system call before the system call
has been invoked.
Change the system call wrappers to insert explicit references
that will keep the allocations alive in the original frame
(and therefore preserve the memory) until after syscall.Syscall
has returned.
Should fix Solaris flakiness.
This is not a problem for cgo, because cgo wrappers have
correctly typed arguments.
LGTM=iant, khr, aram, rlh
R=iant, khr, bradfitz, aram, rlh
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139360044
2014-09-08 14:59:59 -06:00
|
|
|
use(unsafe.Pointer(_p0))
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2012-10-09 10:51:58 -06:00
|
|
|
func write(fd int, p []byte) (n int, err error) {
|
2010-09-24 13:17:20 -06:00
|
|
|
var _p0 unsafe.Pointer
|
2009-10-06 20:38:30 -06:00
|
|
|
if len(p) > 0 {
|
2010-09-24 13:17:20 -06:00
|
|
|
_p0 = unsafe.Pointer(&p[0])
|
2011-02-09 12:28:47 -07:00
|
|
|
} else {
|
|
|
|
_p0 = unsafe.Pointer(&_zero)
|
2009-10-06 20:38:30 -06:00
|
|
|
}
|
2010-09-24 13:17:20 -06:00
|
|
|
r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
|
2009-12-15 16:40:16 -07:00
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
|
2011-08-08 07:56:45 -06:00
|
|
|
r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
|
|
|
|
ret = uintptr(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-08-08 07:56:45 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func munmap(addr uintptr, length uintptr) (err error) {
|
2011-08-08 07:56:45 -06:00
|
|
|
_, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2011-08-08 07:56:45 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2012-10-09 10:51:58 -06:00
|
|
|
func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
|
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2012-10-09 10:51:58 -06:00
|
|
|
func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
|
2009-12-15 16:40:16 -07:00
|
|
|
r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
|
|
|
|
n = int(r0)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-01 23:15:08 -06:00
|
|
|
}
|
|
|
|
|
2010-09-24 13:17:20 -06:00
|
|
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
|
2011-03-16 20:03:01 -06:00
|
|
|
r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
|
2009-12-15 16:40:16 -07:00
|
|
|
sec = int64(r0)
|
|
|
|
usec = int32(r1)
|
2011-11-13 20:44:52 -07:00
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
2009-12-15 16:40:16 -07:00
|
|
|
return
|
2009-06-08 23:10:48 -06:00
|
|
|
}
|