mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
b79dec8138
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
31 lines
668 B
Go
31 lines
668 B
Go
package btf
|
|
|
|
import (
|
|
"fmt"
|
|
"unsafe"
|
|
|
|
"github.com/cilium/ebpf/internal"
|
|
)
|
|
|
|
type bpfBTFInfo struct {
|
|
btf internal.Pointer
|
|
btfSize uint32
|
|
id uint32
|
|
name internal.Pointer
|
|
nameLen uint32
|
|
kernelBTF uint32
|
|
}
|
|
|
|
func bpfGetBTFInfoByFD(fd *internal.FD, btf, name []byte) (*bpfBTFInfo, error) {
|
|
info := bpfBTFInfo{
|
|
btf: internal.NewSlicePointer(btf),
|
|
btfSize: uint32(len(btf)),
|
|
name: internal.NewSlicePointer(name),
|
|
nameLen: uint32(len(name)),
|
|
}
|
|
if err := internal.BPFObjGetInfoByFD(fd, unsafe.Pointer(&info), unsafe.Sizeof(info)); err != nil {
|
|
return nil, fmt.Errorf("can't get program info: %w", err)
|
|
}
|
|
|
|
return &info, nil
|
|
}
|