--- /dev/null
+// 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 openbsd && !mips64
+
+#include "textflag.h"
+
+TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_faccessat(SB)
const openatTrap uintptr = syscall.SYS_OPENAT
const fstatatTrap uintptr = syscall.SYS_FSTATAT
-const AT_REMOVEDIR = 0x08
-const AT_SYMLINK_NOFOLLOW = 0x02
+const (
+ AT_EACCESS = 0x1
+ AT_FDCWD = -0x64
+ AT_REMOVEDIR = 0x08
+ AT_SYMLINK_NOFOLLOW = 0x02
-const UTIME_OMIT = -0x1
+ UTIME_OMIT = -0x1
+)
--- /dev/null
+// 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 openbsd && !mips64
+
+package unix
+
+import (
+ "internal/abi"
+ "syscall"
+ "unsafe"
+)
+
+//go:linkname syscall_syscall6 syscall.syscall6
+func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+
+func libc_faccessat_trampoline()
+
+//go:cgo_import_dynamic libc_faccessat faccessat "libc.so"
+
+func faccessat(dirfd int, path string, mode uint32, flags int) error {
+ p, err := syscall.BytePtrFromString(path)
+ if err != nil {
+ return err
+ }
+ _, _, errno := syscall_syscall6(abi.FuncPCABI0(libc_faccessat_trampoline), 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)
+}