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 freebsd
Like on linux, use faccessat(AT_FDCWD, path, mode, AT_EACCESS) Change-Id: I98c8af5008bfa7940abffa6fcb3766254955cb08 Reviewed-on: https://go-review.googlesource.com/c/go/+/531155 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 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" | ||
) | ||
|
||
func faccessat(dirfd int, path string, mode uint32, flags int) error { | ||
p, err := syscall.BytePtrFromString(path) | ||
if err != nil { | ||
return err | ||
} | ||
_, _, errno := syscall.Syscall6(syscall.SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(mode), uintptr(flags), 0, 0) | ||
if errno != 0 { | ||
return errno | ||
} | ||
return err | ||
} | ||
|
||
func Eaccess(path string, mode uint32) error { | ||
return faccessat(AT_FDCWD, path, mode, AT_EACCESS) | ||
} |
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