github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/trace/open/tracer/opensnoop_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 opensnoopEvent struct { 16 Timestamp uint64 17 Pid uint32 18 Uid uint32 19 Gid uint32 20 _ [4]byte 21 MntnsId uint64 22 Err int32 23 Fd uint32 24 Flags int32 25 Mode uint16 26 Comm [16]uint8 27 Fname [255]uint8 28 FullFname [4096]uint8 29 _ [3]byte 30 } 31 32 type opensnoopPrefixKey struct { 33 Prefixlen uint32 34 Filename [255]uint8 35 _ [1]byte 36 } 37 38 // loadOpensnoop returns the embedded CollectionSpec for opensnoop. 39 func loadOpensnoop() (*ebpf.CollectionSpec, error) { 40 reader := bytes.NewReader(_OpensnoopBytes) 41 spec, err := ebpf.LoadCollectionSpecFromReader(reader) 42 if err != nil { 43 return nil, fmt.Errorf("can't load opensnoop: %w", err) 44 } 45 46 return spec, err 47 } 48 49 // loadOpensnoopObjects loads opensnoop and converts it into a struct. 50 // 51 // The following types are suitable as obj argument: 52 // 53 // *opensnoopObjects 54 // *opensnoopPrograms 55 // *opensnoopMaps 56 // 57 // See ebpf.CollectionSpec.LoadAndAssign documentation for details. 58 func loadOpensnoopObjects(obj interface{}, opts *ebpf.CollectionOptions) error { 59 spec, err := loadOpensnoop() 60 if err != nil { 61 return err 62 } 63 64 return spec.LoadAndAssign(obj, opts) 65 } 66 67 // opensnoopSpecs contains maps and programs before they are loaded into the kernel. 68 // 69 // It can be passed ebpf.CollectionSpec.Assign. 70 type opensnoopSpecs struct { 71 opensnoopProgramSpecs 72 opensnoopMapSpecs 73 } 74 75 // opensnoopSpecs contains programs before they are loaded into the kernel. 76 // 77 // It can be passed ebpf.CollectionSpec.Assign. 78 type opensnoopProgramSpecs struct { 79 IgOpenE *ebpf.ProgramSpec `ebpf:"ig_open_e"` 80 IgOpenX *ebpf.ProgramSpec `ebpf:"ig_open_x"` 81 IgOpenatE *ebpf.ProgramSpec `ebpf:"ig_openat_e"` 82 IgOpenatX *ebpf.ProgramSpec `ebpf:"ig_openat_x"` 83 } 84 85 // opensnoopMapSpecs contains maps before they are loaded into the kernel. 86 // 87 // It can be passed ebpf.CollectionSpec.Assign. 88 type opensnoopMapSpecs struct { 89 Bufs *ebpf.MapSpec `ebpf:"bufs"` 90 EmptyEvent *ebpf.MapSpec `ebpf:"empty_event"` 91 Events *ebpf.MapSpec `ebpf:"events"` 92 GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"` 93 PrefixKeys *ebpf.MapSpec `ebpf:"prefix_keys"` 94 Prefixes *ebpf.MapSpec `ebpf:"prefixes"` 95 Start *ebpf.MapSpec `ebpf:"start"` 96 } 97 98 // opensnoopObjects contains all objects after they have been loaded into the kernel. 99 // 100 // It can be passed to loadOpensnoopObjects or ebpf.CollectionSpec.LoadAndAssign. 101 type opensnoopObjects struct { 102 opensnoopPrograms 103 opensnoopMaps 104 } 105 106 func (o *opensnoopObjects) Close() error { 107 return _OpensnoopClose( 108 &o.opensnoopPrograms, 109 &o.opensnoopMaps, 110 ) 111 } 112 113 // opensnoopMaps contains all maps after they have been loaded into the kernel. 114 // 115 // It can be passed to loadOpensnoopObjects or ebpf.CollectionSpec.LoadAndAssign. 116 type opensnoopMaps struct { 117 Bufs *ebpf.Map `ebpf:"bufs"` 118 EmptyEvent *ebpf.Map `ebpf:"empty_event"` 119 Events *ebpf.Map `ebpf:"events"` 120 GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"` 121 PrefixKeys *ebpf.Map `ebpf:"prefix_keys"` 122 Prefixes *ebpf.Map `ebpf:"prefixes"` 123 Start *ebpf.Map `ebpf:"start"` 124 } 125 126 func (m *opensnoopMaps) Close() error { 127 return _OpensnoopClose( 128 m.Bufs, 129 m.EmptyEvent, 130 m.Events, 131 m.GadgetMntnsFilterMap, 132 m.PrefixKeys, 133 m.Prefixes, 134 m.Start, 135 ) 136 } 137 138 // opensnoopPrograms contains all programs after they have been loaded into the kernel. 139 // 140 // It can be passed to loadOpensnoopObjects or ebpf.CollectionSpec.LoadAndAssign. 141 type opensnoopPrograms struct { 142 IgOpenE *ebpf.Program `ebpf:"ig_open_e"` 143 IgOpenX *ebpf.Program `ebpf:"ig_open_x"` 144 IgOpenatE *ebpf.Program `ebpf:"ig_openat_e"` 145 IgOpenatX *ebpf.Program `ebpf:"ig_openat_x"` 146 } 147 148 func (p *opensnoopPrograms) Close() error { 149 return _OpensnoopClose( 150 p.IgOpenE, 151 p.IgOpenX, 152 p.IgOpenatE, 153 p.IgOpenatX, 154 ) 155 } 156 157 func _OpensnoopClose(closers ...io.Closer) error { 158 for _, closer := range closers { 159 if err := closer.Close(); err != nil { 160 return err 161 } 162 } 163 return nil 164 } 165 166 // Do not access this directly. 167 // 168 //go:embed opensnoop_bpfel.o 169 var _OpensnoopBytes []byte