aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/internal/syscall/unix/asm_darwin.s1
-rw-r--r--src/internal/syscall/unix/at_sysnum_darwin.go10
-rw-r--r--src/internal/syscall/unix/eaccess_darwin.go31
-rw-r--r--src/internal/syscall/unix/eaccess_other.go2
4 files changed, 40 insertions, 4 deletions
diff --git a/src/internal/syscall/unix/asm_darwin.s b/src/internal/syscall/unix/asm_darwin.s
index 0b8efb1506d..99f28765fe0 100644
--- a/src/internal/syscall/unix/asm_darwin.s
+++ b/src/internal/syscall/unix/asm_darwin.s
@@ -22,3 +22,4 @@ TEXT ·libc_getpwuid_r_trampoline(SB),NOSPLIT,$0-0; JMP libc_getpwuid_r(SB)
TEXT ·libc_getgrnam_r_trampoline(SB),NOSPLIT,$0-0; JMP libc_getgrnam_r(SB)
TEXT ·libc_getgrgid_r_trampoline(SB),NOSPLIT,$0-0; JMP libc_getgrgid_r(SB)
TEXT ·libc_sysconf_trampoline(SB),NOSPLIT,$0-0; JMP libc_sysconf(SB)
+TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0; JMP libc_faccessat(SB)
diff --git a/src/internal/syscall/unix/at_sysnum_darwin.go b/src/internal/syscall/unix/at_sysnum_darwin.go
index 208ff34d038..77b0af80b5d 100644
--- a/src/internal/syscall/unix/at_sysnum_darwin.go
+++ b/src/internal/syscall/unix/at_sysnum_darwin.go
@@ -4,7 +4,11 @@
package unix
-const AT_REMOVEDIR = 0x80
-const AT_SYMLINK_NOFOLLOW = 0x0020
+const (
+ AT_EACCESS = 0x10
+ AT_FDCWD = -0x2
+ AT_REMOVEDIR = 0x80
+ AT_SYMLINK_NOFOLLOW = 0x0020
-const UTIME_OMIT = -0x2
+ UTIME_OMIT = -0x2
+)
diff --git a/src/internal/syscall/unix/eaccess_darwin.go b/src/internal/syscall/unix/eaccess_darwin.go
new file mode 100644
index 00000000000..0fa8d17afea
--- /dev/null
+++ b/src/internal/syscall/unix/eaccess_darwin.go
@@ -0,0 +1,31 @@
+// 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 (
+ "internal/abi"
+ "syscall"
+ "unsafe"
+)
+
+func libc_faccessat_trampoline()
+
+//go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib"
+
+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 nil
+}
+
+func Eaccess(path string, mode uint32) error {
+ return faccessat(AT_FDCWD, path, mode, AT_EACCESS)
+}
diff --git a/src/internal/syscall/unix/eaccess_other.go b/src/internal/syscall/unix/eaccess_other.go
index 1a633ae857a..3da3a64f0e6 100644
--- a/src/internal/syscall/unix/eaccess_other.go
+++ b/src/internal/syscall/unix/eaccess_other.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build unix && !dragonfly && !freebsd && !linux && !openbsd && !netbsd
+//go:build unix && !darwin && !dragonfly && !freebsd && !linux && !openbsd && !netbsd
package unix