github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/trace/mount/tracer/mountsnoop_bpfel.go (about)

     1  // Code generated by bpf2go; DO NOT EDIT.
     2  //go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64
     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 mountsnoopEvent struct {
    16  	Delta     uint64
    17  	Flags     uint64
    18  	Pid       uint32
    19  	Tid       uint32
    20  	MountNsId uint64
    21  	Timestamp uint64
    22  	Ret       int32
    23  	Comm      [16]uint8
    24  	Fs        [8]uint8
    25  	Src       [4096]uint8
    26  	Dest      [4096]uint8
    27  	Data      [512]uint8
    28  	Op        mountsnoopOp
    29  }
    30  
    31  type mountsnoopOp uint32
    32  
    33  const (
    34  	mountsnoopOpMOUNT  mountsnoopOp = 0
    35  	mountsnoopOpUMOUNT mountsnoopOp = 1
    36  )
    37  
    38  // loadMountsnoop returns the embedded CollectionSpec for mountsnoop.
    39  func loadMountsnoop() (*ebpf.CollectionSpec, error) {
    40  	reader := bytes.NewReader(_MountsnoopBytes)
    41  	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
    42  	if err != nil {
    43  		return nil, fmt.Errorf("can't load mountsnoop: %w", err)
    44  	}
    45  
    46  	return spec, err
    47  }
    48  
    49  // loadMountsnoopObjects loads mountsnoop and converts it into a struct.
    50  //
    51  // The following types are suitable as obj argument:
    52  //
    53  //	*mountsnoopObjects
    54  //	*mountsnoopPrograms
    55  //	*mountsnoopMaps
    56  //
    57  // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
    58  func loadMountsnoopObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
    59  	spec, err := loadMountsnoop()
    60  	if err != nil {
    61  		return err
    62  	}
    63  
    64  	return spec.LoadAndAssign(obj, opts)
    65  }
    66  
    67  // mountsnoopSpecs contains maps and programs before they are loaded into the kernel.
    68  //
    69  // It can be passed ebpf.CollectionSpec.Assign.
    70  type mountsnoopSpecs struct {
    71  	mountsnoopProgramSpecs
    72  	mountsnoopMapSpecs
    73  }
    74  
    75  // mountsnoopSpecs contains programs before they are loaded into the kernel.
    76  //
    77  // It can be passed ebpf.CollectionSpec.Assign.
    78  type mountsnoopProgramSpecs struct {
    79  	IgMountE  *ebpf.ProgramSpec `ebpf:"ig_mount_e"`
    80  	IgMountX  *ebpf.ProgramSpec `ebpf:"ig_mount_x"`
    81  	IgUmountE *ebpf.ProgramSpec `ebpf:"ig_umount_e"`
    82  	IgUmountX *ebpf.ProgramSpec `ebpf:"ig_umount_x"`
    83  }
    84  
    85  // mountsnoopMapSpecs contains maps before they are loaded into the kernel.
    86  //
    87  // It can be passed ebpf.CollectionSpec.Assign.
    88  type mountsnoopMapSpecs struct {
    89  	Args                 *ebpf.MapSpec `ebpf:"args"`
    90  	Events               *ebpf.MapSpec `ebpf:"events"`
    91  	GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"`
    92  	Heap                 *ebpf.MapSpec `ebpf:"heap"`
    93  }
    94  
    95  // mountsnoopObjects contains all objects after they have been loaded into the kernel.
    96  //
    97  // It can be passed to loadMountsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
    98  type mountsnoopObjects struct {
    99  	mountsnoopPrograms
   100  	mountsnoopMaps
   101  }
   102  
   103  func (o *mountsnoopObjects) Close() error {
   104  	return _MountsnoopClose(
   105  		&o.mountsnoopPrograms,
   106  		&o.mountsnoopMaps,
   107  	)
   108  }
   109  
   110  // mountsnoopMaps contains all maps after they have been loaded into the kernel.
   111  //
   112  // It can be passed to loadMountsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
   113  type mountsnoopMaps struct {
   114  	Args                 *ebpf.Map `ebpf:"args"`
   115  	Events               *ebpf.Map `ebpf:"events"`
   116  	GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"`
   117  	Heap                 *ebpf.Map `ebpf:"heap"`
   118  }
   119  
   120  func (m *mountsnoopMaps) Close() error {
   121  	return _MountsnoopClose(
   122  		m.Args,
   123  		m.Events,
   124  		m.GadgetMntnsFilterMap,
   125  		m.Heap,
   126  	)
   127  }
   128  
   129  // mountsnoopPrograms contains all programs after they have been loaded into the kernel.
   130  //
   131  // It can be passed to loadMountsnoopObjects or ebpf.CollectionSpec.LoadAndAssign.
   132  type mountsnoopPrograms struct {
   133  	IgMountE  *ebpf.Program `ebpf:"ig_mount_e"`
   134  	IgMountX  *ebpf.Program `ebpf:"ig_mount_x"`
   135  	IgUmountE *ebpf.Program `ebpf:"ig_umount_e"`
   136  	IgUmountX *ebpf.Program `ebpf:"ig_umount_x"`
   137  }
   138  
   139  func (p *mountsnoopPrograms) Close() error {
   140  	return _MountsnoopClose(
   141  		p.IgMountE,
   142  		p.IgMountX,
   143  		p.IgUmountE,
   144  		p.IgUmountX,
   145  	)
   146  }
   147  
   148  func _MountsnoopClose(closers ...io.Closer) error {
   149  	for _, closer := range closers {
   150  		if err := closer.Close(); err != nil {
   151  			return err
   152  		}
   153  	}
   154  	return nil
   155  }
   156  
   157  // Do not access this directly.
   158  //
   159  //go:embed mountsnoop_bpfel.o
   160  var _MountsnoopBytes []byte