Skip to content

Commit 38f54c7

Browse files
committed
Add fchmodat system calls for darwin
Expose Fchmodat for linux and darwin through sysx package Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
1 parent d3228ee commit 38f54c7

6 files changed

Lines changed: 81 additions & 0 deletions

File tree

sysx/chmod_darwin.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package sysx
2+
3+
const (
4+
// AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in <sys/fcntl.h>
5+
AtSymlinkNofollow = 0x20
6+
)
7+
8+
const (
9+
10+
// SYS_FCHMODAT defined from golang.org/sys/unix
11+
SYS_FCHMODAT = 467
12+
)
13+
14+
// These functions will be generated by generate.sh
15+
// $ GOOS=darwin GOARCH=386 ./generate.sh chmod
16+
// $ GOOS=darwin GOARCH=amd64 ./generate.sh chmod
17+
18+
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)

sysx/chmod_darwin_386.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// mksyscall.pl -l32 chmod_darwin.go
2+
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3+
4+
package sysx
5+
6+
import (
7+
"syscall"
8+
"unsafe"
9+
)
10+
11+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
12+
13+
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
14+
var _p0 *byte
15+
_p0, err = syscall.BytePtrFromString(path)
16+
if err != nil {
17+
return
18+
}
19+
_, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
20+
use(unsafe.Pointer(_p0))
21+
if e1 != 0 {
22+
err = errnoErr(e1)
23+
}
24+
return
25+
}

sysx/chmod_darwin_amd64.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// mksyscall.pl chmod_darwin.go
2+
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3+
4+
package sysx
5+
6+
import (
7+
"syscall"
8+
"unsafe"
9+
)
10+
11+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
12+
13+
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
14+
var _p0 *byte
15+
_p0, err = syscall.BytePtrFromString(path)
16+
if err != nil {
17+
return
18+
}
19+
_, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
20+
use(unsafe.Pointer(_p0))
21+
if e1 != 0 {
22+
err = errnoErr(e1)
23+
}
24+
return
25+
}

sysx/chmod_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package sysx
2+
3+
import "syscall"
4+
5+
const (
6+
// AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in /usr/include/linux/fcntl.h
7+
AtSymlinkNofollow = 0x100
8+
)
9+
10+
func Fchmodat(dirfd int, path string, mode uint32, flags int) error {
11+
return syscall.Fchmodat(dirfd, path, mode, flags)
12+
}

sysx/generate.sh

100644100755
File mode changed.

sysx/xattr_darwin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package sysx
88
//sys setxattr(path string, attr string, data []byte, flags int) (err error)
99
//sys removexattr(path string, attr string, options int) (err error)
1010
//sys listxattr(path string, dest []byte, options int) (sz int, err error)
11+
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
1112

1213
const (
1314
xattrNoFollow = 0x01

0 commit comments

Comments
 (0)