Commit e6e5e023 authored by Aaron Jacobs's avatar Aaron Jacobs Committed by Ian Lance Taylor

x/sys/unix: expose fchmodat(2) and related constants on darwin/amd64

These are already exposed on Linux. I believe they were left out of
darwin because fchmodat didn't exist on older versions of XNU.

Change-Id: I166f2b23270937c1b6cc3bd73e7f7b72d2d488e9
Reviewed-on: https://go-review.googlesource.com/14092Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 2ac7e535
......@@ -11,6 +11,8 @@ import (
"unsafe"
)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
func Getpagesize() int { return 4096 }
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
......
......@@ -241,3 +241,10 @@ type BpfHdr C.struct_bpf_hdr
// Terminal handling
type Termios C.struct_termios
// fchmodat-like syscalls.
const (
AT_FDCWD = C.AT_FDCWD
AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
)
......@@ -1415,6 +1415,22 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
use(unsafe.Pointer(_p0))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
sec = int64(r0)
......
......@@ -455,3 +455,8 @@ type Termios struct {
Ispeed uint64
Ospeed uint64
}
const (
AT_FDCWD = -0x2
AT_SYMLINK_NOFOLLOW = 0x20
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment