Skip to content

Instantly share code, notes, and snippets.

@alessandrogario
Created July 24, 2020 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessandrogario/968b9c3ea78559f470bc650c8496449e to your computer and use it in GitHub Desktop.
Save alessandrogario/968b9c3ea78559f470bc650c8496449e to your computer and use it in GitHub Desktop.
BCC script to trace openat
#!/usr/bin/env python3
from bcc import BPF
b = BPF(text="""
TRACEPOINT_PROBE(syscalls, sys_enter_openat) {
bpf_trace_printk("sys_enter_openat mode:%ld filename:%s (%ld)\\n", args->mode, args->filename, args->filename);
return 0;
}
""")
while 1:
try:
(task, pid, cpu, flags, ts, msg) = b.trace_fields()
except ValueError:
continue
print("%-18.9f %-16s %-6d %s" % (ts, task, pid, msg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment