Debian Codegraph @

internal/sys/pinning_windows.go

raw symbols SCIP
1 package sys
2
3 import (
4 "errors"
5 "runtime"
6
7 "github.com/cilium/ebpf/internal/efw"
8 )
9
10 func Pin(currentPath, newPath string, fd *FD) error {
11 defer runtime.KeepAlive(fd)
12
13 if newPath == "" {
14 return errors.New("given pinning path cannot be empty")
15 }
16 if currentPath == newPath {
17 return nil
18 }
19
20 if currentPath == "" {
21 return ObjPin(&ObjPinAttr{
22 Pathname: NewStringPointer(newPath),
23 BpfFd: fd.Uint(),
24 })
25 }
26
27 return ObjPin(&ObjPinAttr{
28 Pathname: NewStringPointer(newPath),
29 BpfFd: fd.Uint(),
30 })
31 }
32
33 func Unpin(pinnedPath string) error {
34 if pinnedPath == "" {
35 return nil
36 }
37
38 err := efw.EbpfObjectUnpin(pinnedPath)
39 if err != nil && !errors.Is(err, efw.EBPF_KEY_NOT_FOUND) {
40 return err
41 }
42
43 return nil
44 }