//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.a/shr_64.o"
const (
+ AT_EACCESS = 0x1
+ AT_FDCWD = -0x02
AT_REMOVEDIR = 0x1
AT_SYMLINK_NOFOLLOW = 0x1
UTIME_OMIT = -0x3
// Implemented as rawsysvicall6 in runtime/syscall_solaris.go.
func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+//go:cgo_import_dynamic libc_faccessat faccessat "libc.so"
//go:cgo_import_dynamic libc_fstatat fstatat "libc.so"
//go:cgo_import_dynamic libc_openat openat "libc.so"
//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so"
//go:cgo_import_dynamic libc_uname uname "libc.so"
const (
+ AT_EACCESS = 0x4
+ AT_FDCWD = 0xffd19553
AT_REMOVEDIR = 0x1
AT_SYMLINK_NOFOLLOW = 0x1000
-// 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)
}
+++ /dev/null
-// Copyright 2022 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 unix && !darwin && !dragonfly && !freebsd && !linux && !openbsd && !netbsd
-
-package unix
-
-import "syscall"
-
-func Eaccess(path string, mode uint32) error {
- return syscall.ENOSYS
-}
}
return err
}
-
-func Eaccess(path string, mode uint32) error {
- return faccessat(AT_FDCWD, path, mode, AT_EACCESS)
-}
}
return nil
}
-
-func Eaccess(path string, mode uint32) error {
- return faccessat(AT_FDCWD, path, mode, AT_EACCESS)
-}
}
return err
}
-
-func Eaccess(path string, mode uint32) error {
- return faccessat(AT_FDCWD, path, mode, AT_EACCESS)
-}
--- /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.
+
+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
+}
--- /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 aix || linux
+
+package unix
+
+import "syscall"
+
+var faccessat = syscall.Faccessat