| 1 |
// Copyright 2024 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build aix || darwin || dragonfly || freebsd || linux || openbsd || solaris || wasip1 |
| 6 |
|
| 7 |
package os |
| 8 |
|
| 9 |
import ( |
| 10 |
"runtime" |
| 11 |
"syscall" |
| 12 |
) |
| 13 |
|
| 14 |
// isNoFollowErr reports whether err may result from O_NOFOLLOW blocking an open operation. |
| 15 |
func isNoFollowErr(err error) bool { |
| 16 |
switch err { |
| 17 |
case syscall.ELOOP, syscall.EMLINK: |
| 18 |
return true |
| 19 |
} |
| 20 |
if runtime.GOOS == "dragonfly" { |
| 21 |
// Dragonfly appears to return EINVAL from openat in this case. |
| 22 |
if err == syscall.EINVAL { |
| 23 |
return true |
| 24 |
} |
| 25 |
} |
| 26 |
return false |
| 27 |
} |