sys_enter_openat.c 764 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Hook into 'openat' syscall entry tracepoint
  4. *
  5. * Test it with:
  6. *
  7. * perf trace -e tools/perf/examples/bpf/sys_enter_openat.c cat /etc/passwd > /dev/null
  8. *
  9. * It'll catch some openat syscalls related to the dynamic linked and
  10. * the last one should be the one for '/etc/passwd'.
  11. *
  12. * The syscall_enter_openat_args can be used to get the syscall fields
  13. * and use them for filtering calls, i.e. use in expressions for
  14. * the return value.
  15. */
  16. #include <bpf.h>
  17. struct syscall_enter_openat_args {
  18. unsigned long long unused;
  19. long syscall_nr;
  20. long dfd;
  21. char *filename_ptr;
  22. long flags;
  23. long mode;
  24. };
  25. int syscall_enter(openat)(struct syscall_enter_openat_args *args)
  26. {
  27. return 1;
  28. }
  29. license(GPL);