Files
nfs/internal/nfsfs/symlinkrefused_bsd.go
T

24 lines
794 B
Go
Raw Normal View History

// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: MIT
//go:build freebsd || netbsd || openbsd || darwin
package nfsfs
import (
"errors"
"syscall"
)
// symlinkRefused reports whether an open refused a final component that is
// a symlink, the answer O_NOFOLLOW exists for. The systems disagree on the
// answer: FreeBSD and OpenBSD answer EMLINK, NetBSD answers EFTYPE, darwin
// names EMLINK in its open(2), and the ELOOP spelling stays in the check
// for the lineage it came from. FreeBSD, OpenBSD and NetBSD are verified
// live; the darwin answer rests on its manual.
func symlinkRefused(err error) bool {
return errors.Is(err, syscall.ELOOP) ||
errors.Is(err, syscall.EMLINK) ||
errors.Is(err, syscall.EFTYPE)
}