| 1 | package unix |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "runtime" |
| 6 | "strings" |
| 7 | |
| 8 | "github.com/cilium/ebpf/internal" |
| 9 | ) |
| 10 | |
| 11 | // errNonLinux returns an error which wraps [internal.ErrNotSupportedOnOS] and |
| 12 | // includes the name of the calling function. |
| 13 | func errNonLinux() error { |
| 14 | name := "unknown" |
| 15 | pc, _, _, ok := runtime.Caller(1) |
| 16 | if ok { |
| 17 | name = runtime.FuncForPC(pc).Name() |
| 18 | if pos := strings.LastIndexByte(name, '.'); pos != -1 { |
| 19 | name = name[pos+1:] |
| 20 | } |
| 21 | } |
| 22 | return fmt.Errorf("unix: %s: %w", name, internal.ErrNotSupportedOnOS) |
| 23 | } |