-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/syscall/unix: implement Eaccess on all unix platforms
Eaccess, initially added by CL 414824 for linux only, was later implemented for freebsd (CL 531155), netbsd (CL 531876), dragonfly (CL 532675), openbsd (CL 538836), and darwin (CL 579976). The only unix platforms which lack Eaccess are Solaris/Illumos and AIX. For AIX, syscall.Faccessat is already available, the only missing piece was AT_EACCESS constant. Let's take it from [1], which, judging by a few other known AT_ constants, appears to be accurate. For Solaris, wire the faccessat using the same logic as in the syscall package. Now, when we have faccessat for every unix, we can drop eaccess_other.go and consolidate Eaccess implementations to use faccessat. [1]: https://github.com/rust-lang/libc/blob/main/src/unix/aix/mod.rs Change-Id: I7e1b90dedc5d8174235d3a79d5c662f3dcb909c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/611295 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
- Loading branch information
Showing
9 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/internal/syscall/unix/eaccess_linux.go → src/internal/syscall/unix/eaccess.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package unix | ||
//go:build unix | ||
|
||
import "syscall" | ||
package unix | ||
|
||
func Eaccess(path string, mode uint32) error { | ||
return syscall.Faccessat(AT_FDCWD, path, mode, AT_EACCESS) | ||
return faccessat(AT_FDCWD, path, mode, AT_EACCESS) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package unix | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
//go:linkname procFaccessat libc_faccessat | ||
|
||
var procFaccessat uintptr | ||
|
||
func faccessat(dirfd int, path string, mode uint32, flags int) error { | ||
p, err := syscall.BytePtrFromString(path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, _, errno := syscall6(uintptr(unsafe.Pointer(&procFaccessat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(mode), uintptr(flags), 0, 0) | ||
if errno != 0 { | ||
return errno | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build aix || linux | ||
|
||
package unix | ||
|
||
import "syscall" | ||
|
||
var faccessat = syscall.Faccessat |