/*
 * Build the .o bytecode with:
 *
 * clang -g -target bpf -O2 -c hello.c
 *
 * Or get it pre-compiled:
 *
 * wget http://vger.kernel.org/~acme/bpf/hello.o
 *
 * Then run it with:
 *
 * perf trace -e hello.o
 *
 * See the output with:
 *
 * bpftool prog tracelog
 *
 * or:
 *
 * cat /sys/kernel/debug/tracing/trace_pipe
 *
 * Or do all at once:
 *
 * perf trace -e hello.c & cat /sys/kernel/debug/tracing/trace_pipe
 */

#include <linux/bpf.h>

static void (*trace_printk)(const char *fmt, int fmt_size, ...) = (void *)BPF_FUNC_trace_printk;

#define SEC(NAME) __attribute__((section(NAME),  used))

SEC("syscalls:sys_enter_openat") int func(void *args)
{
	char msg[] = "Hello, world\n";
	trace_printk(msg, sizeof(msg));
	return 0;
}

char _license[] SEC("license") = "GPL";
