128 lines
3.3 KiB
Go
128 lines
3.3 KiB
Go
// Code generated by bpf2go; DO NOT EDIT.
|
|
//go:build arm64be || armbe || mips || mips64 || mips64p32 || ppc64 || s390 || s390x || sparc || sparc64
|
|
|
|
package main
|
|
|
|
import (
|
|
"bytes"
|
|
_ "embed"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/cilium/ebpf"
|
|
)
|
|
|
|
type FileProtectorFileProtectState uint32
|
|
|
|
// LoadFileProtector returns the embedded CollectionSpec for FileProtector.
|
|
func LoadFileProtector() (*ebpf.CollectionSpec, error) {
|
|
reader := bytes.NewReader(_FileProtectorBytes)
|
|
spec, err := ebpf.LoadCollectionSpecFromReader(reader)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("can't load FileProtector: %w", err)
|
|
}
|
|
|
|
return spec, err
|
|
}
|
|
|
|
// LoadFileProtectorObjects loads FileProtector and converts it into a struct.
|
|
//
|
|
// The following types are suitable as obj argument:
|
|
//
|
|
// *FileProtectorObjects
|
|
// *FileProtectorPrograms
|
|
// *FileProtectorMaps
|
|
//
|
|
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
|
|
func LoadFileProtectorObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
|
|
spec, err := LoadFileProtector()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return spec.LoadAndAssign(obj, opts)
|
|
}
|
|
|
|
// FileProtectorSpecs contains maps and programs before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type FileProtectorSpecs struct {
|
|
FileProtectorProgramSpecs
|
|
FileProtectorMapSpecs
|
|
}
|
|
|
|
// FileProtectorSpecs contains programs before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type FileProtectorProgramSpecs struct {
|
|
CheckFileOpen *ebpf.ProgramSpec `ebpf:"check_file_open"`
|
|
}
|
|
|
|
// FileProtectorMapSpecs contains maps before they are loaded into the kernel.
|
|
//
|
|
// It can be passed ebpf.CollectionSpec.Assign.
|
|
type FileProtectorMapSpecs struct {
|
|
BannedAccess *ebpf.MapSpec `ebpf:"banned_access"`
|
|
Roots *ebpf.MapSpec `ebpf:"roots"`
|
|
States *ebpf.MapSpec `ebpf:"states"`
|
|
}
|
|
|
|
// FileProtectorObjects contains all objects after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadFileProtectorObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type FileProtectorObjects struct {
|
|
FileProtectorPrograms
|
|
FileProtectorMaps
|
|
}
|
|
|
|
func (o *FileProtectorObjects) Close() error {
|
|
return _FileProtectorClose(
|
|
&o.FileProtectorPrograms,
|
|
&o.FileProtectorMaps,
|
|
)
|
|
}
|
|
|
|
// FileProtectorMaps contains all maps after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadFileProtectorObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type FileProtectorMaps struct {
|
|
BannedAccess *ebpf.Map `ebpf:"banned_access"`
|
|
Roots *ebpf.Map `ebpf:"roots"`
|
|
States *ebpf.Map `ebpf:"states"`
|
|
}
|
|
|
|
func (m *FileProtectorMaps) Close() error {
|
|
return _FileProtectorClose(
|
|
m.BannedAccess,
|
|
m.Roots,
|
|
m.States,
|
|
)
|
|
}
|
|
|
|
// FileProtectorPrograms contains all programs after they have been loaded into the kernel.
|
|
//
|
|
// It can be passed to LoadFileProtectorObjects or ebpf.CollectionSpec.LoadAndAssign.
|
|
type FileProtectorPrograms struct {
|
|
CheckFileOpen *ebpf.Program `ebpf:"check_file_open"`
|
|
}
|
|
|
|
func (p *FileProtectorPrograms) Close() error {
|
|
return _FileProtectorClose(
|
|
p.CheckFileOpen,
|
|
)
|
|
}
|
|
|
|
func _FileProtectorClose(closers ...io.Closer) error {
|
|
for _, closer := range closers {
|
|
if err := closer.Close(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Do not access this directly.
|
|
//
|
|
//go:embed fileprotector_bpfeb.o
|
|
var _FileProtectorBytes []byte
|