Browse Source

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 <r@golang.org>
Dave Cheney 10 years ago
parent
commit
58da1121af
2 changed files with 4 additions and 17 deletions
  1. 4 1
      unix/syscall_linux_arm64.go
  2. 0 16
      unix/zsyscall_linux_arm64.go

+ 4 - 1
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)
 }

+ 0 - 16
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 {