From 58da1121af381632b48b2843aeb16299f2e1dc50 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Thu, 30 Jul 2015 10:23:51 +1000 Subject: [PATCH] unix: use fchownat(2) in place of lchown(2) for linux/arm64 Updates #11918 Replace calls to lchown(2) with fchownat(2) for linux/arm64 as the former is not suppored. This is a companion to CL 12833 which is ready to be applied to the main repo, and verified by CL 12834 which can be applied once this change and CL 12833 have landed. Change-Id: I63de3d0da1e4b4e1f253e51e0ed8e0cd0e56d63a Reviewed-on: https://go-review.googlesource.com/12837 Reviewed-by: Rob Pike --- unix/syscall_linux_arm64.go | 5 ++++- unix/zsyscall_linux_arm64.go | 16 ---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/unix/syscall_linux_arm64.go b/unix/syscall_linux_arm64.go index fa1228e3..f3d72dfd 100644 --- a/unix/syscall_linux_arm64.go +++ b/unix/syscall_linux_arm64.go @@ -18,7 +18,6 @@ const _SYS_dup = SYS_DUP3 //sysnb Getgid() (gid int) //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) -//sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 @@ -39,6 +38,10 @@ func Stat(path string, stat *Stat_t) (err error) { return Fstatat(AT_FDCWD, path, stat, 0) } +func Lchown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) +} + func Lstat(path string, stat *Stat_t) (err error) { return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) } diff --git a/unix/zsyscall_linux_arm64.go b/unix/zsyscall_linux_arm64.go index 9b14ee5c..8eafcebc 100644 --- a/unix/zsyscall_linux_arm64.go +++ b/unix/zsyscall_linux_arm64.go @@ -1310,22 +1310,6 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Lchown(path string, uid int, gid int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) - 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 Listen(s int, n int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) if e1 != 0 {