Browse Source

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/14092
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Aaron Jacobs 10 years ago
parent
commit
e6e5e023fc

+ 2 - 0
unix/syscall_darwin_amd64.go

@@ -11,6 +11,8 @@ import (
 	"unsafe"
 	"unsafe"
 )
 )
 
 
+//sys	Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
+
 func Getpagesize() int { return 4096 }
 func Getpagesize() int { return 4096 }
 
 
 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }

+ 7 - 0
unix/types_darwin.go

@@ -241,3 +241,10 @@ type BpfHdr C.struct_bpf_hdr
 // Terminal handling
 // Terminal handling
 
 
 type Termios C.struct_termios
 type Termios C.struct_termios
+
+// fchmodat-like syscalls.
+
+const (
+	AT_FDCWD            = C.AT_FDCWD
+	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
+)

+ 16 - 0
unix/zsyscall_darwin_amd64.go

@@ -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
 // 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) {
 func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
 	r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
 	r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
 	sec = int64(r0)
 	sec = int64(r0)

+ 5 - 0
unix/ztypes_darwin_amd64.go

@@ -455,3 +455,8 @@ type Termios struct {
 	Ispeed    uint64
 	Ispeed    uint64
 	Ospeed    uint64
 	Ospeed    uint64
 }
 }
+
+const (
+	AT_FDCWD            = -0x2
+	AT_SYMLINK_NOFOLLOW = 0x20
+)