github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/top/file/tracer/filetop_x86_bpfel.go (about)

     1  // Code generated by bpf2go; DO NOT EDIT.
     2  //go:build 386 || amd64
     3  
     4  package tracer
     5  
     6  import (
     7  	"bytes"
     8  	_ "embed"
     9  	"fmt"
    10  	"io"
    11  
    12  	"github.com/cilium/ebpf"
    13  )
    14  
    15  type filetopFileId struct {
    16  	Inode uint64
    17  	Dev   uint32
    18  	Pid   uint32
    19  	Tid   uint32
    20  	_     [4]byte
    21  }
    22  
    23  type filetopFileStat struct {
    24  	Reads      uint64
    25  	ReadBytes  uint64
    26  	Writes     uint64
    27  	WriteBytes uint64
    28  	Pid        uint32
    29  	Tid        uint32
    30  	MntnsId    uint64
    31  	Filename   [4096]uint8
    32  	Comm       [16]uint8
    33  	Type       int8
    34  	_          [7]byte
    35  }
    36  
    37  // loadFiletop returns the embedded CollectionSpec for filetop.
    38  func loadFiletop() (*ebpf.CollectionSpec, error) {
    39  	reader := bytes.NewReader(_FiletopBytes)
    40  	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
    41  	if err != nil {
    42  		return nil, fmt.Errorf("can't load filetop: %w", err)
    43  	}
    44  
    45  	return spec, err
    46  }
    47  
    48  // loadFiletopObjects loads filetop and converts it into a struct.
    49  //
    50  // The following types are suitable as obj argument:
    51  //
    52  //	*filetopObjects
    53  //	*filetopPrograms
    54  //	*filetopMaps
    55  //
    56  // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
    57  func loadFiletopObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
    58  	spec, err := loadFiletop()
    59  	if err != nil {
    60  		return err
    61  	}
    62  
    63  	return spec.LoadAndAssign(obj, opts)
    64  }
    65  
    66  // filetopSpecs contains maps and programs before they are loaded into the kernel.
    67  //
    68  // It can be passed ebpf.CollectionSpec.Assign.
    69  type filetopSpecs struct {
    70  	filetopProgramSpecs
    71  	filetopMapSpecs
    72  }
    73  
    74  // filetopSpecs contains programs before they are loaded into the kernel.
    75  //
    76  // It can be passed ebpf.CollectionSpec.Assign.
    77  type filetopProgramSpecs struct {
    78  	IgTopfileRdE *ebpf.ProgramSpec `ebpf:"ig_topfile_rd_e"`
    79  	IgTopfileWrE *ebpf.ProgramSpec `ebpf:"ig_topfile_wr_e"`
    80  }
    81  
    82  // filetopMapSpecs contains maps before they are loaded into the kernel.
    83  //
    84  // It can be passed ebpf.CollectionSpec.Assign.
    85  type filetopMapSpecs struct {
    86  	Entries              *ebpf.MapSpec `ebpf:"entries"`
    87  	GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"`
    88  }
    89  
    90  // filetopObjects contains all objects after they have been loaded into the kernel.
    91  //
    92  // It can be passed to loadFiletopObjects or ebpf.CollectionSpec.LoadAndAssign.
    93  type filetopObjects struct {
    94  	filetopPrograms
    95  	filetopMaps
    96  }
    97  
    98  func (o *filetopObjects) Close() error {
    99  	return _FiletopClose(
   100  		&o.filetopPrograms,
   101  		&o.filetopMaps,
   102  	)
   103  }
   104  
   105  // filetopMaps contains all maps after they have been loaded into the kernel.
   106  //
   107  // It can be passed to loadFiletopObjects or ebpf.CollectionSpec.LoadAndAssign.
   108  type filetopMaps struct {
   109  	Entries              *ebpf.Map `ebpf:"entries"`
   110  	GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"`
   111  }
   112  
   113  func (m *filetopMaps) Close() error {
   114  	return _FiletopClose(
   115  		m.Entries,
   116  		m.GadgetMntnsFilterMap,
   117  	)
   118  }
   119  
   120  // filetopPrograms contains all programs after they have been loaded into the kernel.
   121  //
   122  // It can be passed to loadFiletopObjects or ebpf.CollectionSpec.LoadAndAssign.
   123  type filetopPrograms struct {
   124  	IgTopfileRdE *ebpf.Program `ebpf:"ig_topfile_rd_e"`
   125  	IgTopfileWrE *ebpf.Program `ebpf:"ig_topfile_wr_e"`
   126  }
   127  
   128  func (p *filetopPrograms) Close() error {
   129  	return _FiletopClose(
   130  		p.IgTopfileRdE,
   131  		p.IgTopfileWrE,
   132  	)
   133  }
   134  
   135  func _FiletopClose(closers ...io.Closer) error {
   136  	for _, closer := range closers {
   137  		if err := closer.Close(); err != nil {
   138  			return err
   139  		}
   140  	}
   141  	return nil
   142  }
   143  
   144  // Do not access this directly.
   145  //
   146  //go:embed filetop_x86_bpfel.o
   147  var _FiletopBytes []byte