mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add barebones python skeleton for kfuncs
This commit is contained in:
28
examples/execve4.py
Normal file
28
examples/execve4.py
Normal file
@ -0,0 +1,28 @@
|
||||
from pythonbpf import bpf, map, section, bpfglobal, compile
|
||||
from pythonbpf.helpers import ktime, deref
|
||||
from pythonbpf.maps import HashMap
|
||||
|
||||
from ctypes import c_void_p, c_int64, c_int32, c_uint64
|
||||
|
||||
|
||||
@bpf
|
||||
@map
|
||||
def last() -> HashMap:
|
||||
return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=3)
|
||||
|
||||
|
||||
@bpf
|
||||
@section("blk_start_request")
|
||||
def trace_start(ctx: c_void_p) -> c_int32:
|
||||
ts = ktime()
|
||||
print("req started")
|
||||
return c_int32(0)
|
||||
|
||||
|
||||
@bpf
|
||||
@bpfglobal
|
||||
def LICENSE() -> str:
|
||||
return "GPL"
|
||||
|
||||
|
||||
compile()
|
||||
Reference in New Issue
Block a user