From d61448ec88f064eba898b566f68324859df5f7ac Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 11 Nov 2026 21:02:25 +0100 Subject: syscallcompat: drop Faccessat helper, use unix.Faccessat with AT_SYMLINK_NOFOLLOW Our helper did Fstatat(AT_SYMLINK_NOFOLLOW) followed by a symlink-following unix.Faccessat(..., 0). If the file is swapped for a symlink in between, we check access on the symlink target. x/sys now handles AT_SYMLINK_NOFOLLOW on all our platforms: faccessat2 with fallback emulation on Linux, libc faccessat on Darwin, and the native syscall on FreeBSD. The Darwin breakage that caused the revert in 3d6b2685 should no longer apply. Co-Authored-By: Claude Opus 5.5 --- internal/syscallcompat/sys_common.go | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'internal/syscallcompat/sys_common.go') diff --git a/internal/syscallcompat/sys_common.go b/internal/syscallcompat/sys_common.go index 4f84d98..bdd2dac 100644 --- a/internal/syscallcompat/sys_common.go +++ b/internal/syscallcompat/sys_common.go @@ -29,21 +29,6 @@ func Readlinkat(dirfd int, path string) (string, error) { } } -// Faccessat exists both in Linux and in MacOS 10.10+, but the Linux version -// DOES NOT support any flags. Emulate AT_SYMLINK_NOFOLLOW like glibc does. -func Faccessat(dirfd int, path string, mode uint32) error { - var st unix.Stat_t - err := Fstatat(dirfd, path, &st, unix.AT_SYMLINK_NOFOLLOW) - if err != nil { - return err - } - if st.Mode&syscall.S_IFMT == syscall.S_IFLNK { - // Pretend that a symlink is always accessible - return nil - } - return unix.Faccessat(dirfd, path, mode, 0) -} - // Openat wraps the Openat syscall. // Retries on EINTR. func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { -- cgit v1.2.3