mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-03-20 20:05:56 +08:00
* Initial plan * Fix tutorial 1 compilation by including vmlinux.h Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> * Update README documentation to reference vmlinux.h consistently Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
22 lines
526 B
C
22 lines
526 B
C
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
|
|
#define BPF_NO_GLOBAL_DATA
|
|
#include "vmlinux.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
|
|
typedef unsigned int u32;
|
|
typedef int pid_t;
|
|
const pid_t pid_filter = 0;
|
|
|
|
char LICENSE[] SEC("license") = "Dual BSD/GPL";
|
|
|
|
SEC("tp/syscalls/sys_enter_write")
|
|
int handle_tp(void *ctx)
|
|
{
|
|
pid_t pid = bpf_get_current_pid_tgid() >> 32;
|
|
if (pid_filter && pid != pid_filter)
|
|
return 0;
|
|
bpf_printk("BPF triggered sys_enter_write from PID %d.\n", pid);
|
|
return 0;
|
|
}
|