diff options
| author | Jakob Unterwurzacher | 2019-01-20 13:10:59 +0100 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2019-01-20 13:10:59 +0100 | 
| commit | 3d6b2685fb926b40b4eb528a8cbdc3871444d492 (patch) | |
| tree | 8617e715beb8695248ccaac14b76cd6eb5ca756d /internal/syscallcompat | |
| parent | 0805a63df1b5f915b228727f6074c2506922d0ad (diff) | |
Revert "syscallcompat: drop Faccessat AT_SYMLINK_NOFOLLOW helper"
Breaks mounting on MacOS: unix.Faccessat on Darwin does NOT (yet)
support AT_SYMLINK_NOFOLLOW. See d44fe89ba4f3252c5bd00c4f7730197732f2a26a .
This reverts commit 0805a63df1b5f915b228727f6074c2506922d0ad.
Diffstat (limited to 'internal/syscallcompat')
| -rw-r--r-- | internal/syscallcompat/sys_common.go | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/internal/syscallcompat/sys_common.go b/internal/syscallcompat/sys_common.go index aedc4da..b6bbdff 100644 --- a/internal/syscallcompat/sys_common.go +++ b/internal/syscallcompat/sys_common.go @@ -29,6 +29,21 @@ 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.  func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {  	if flags&syscall.O_CREAT != 0 { | 
