trace+probe_vfs_getname.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. # Check open filename arg using perf trace + vfs_getname
  3. # Uses the 'perf test shell' library to add probe:vfs_getname to the system
  4. # then use it with 'perf trace' using 'touch' to write to a temp file, then
  5. # checks that that was captured by the vfs_getname was used by 'perf trace',
  6. # that already handles "probe:vfs_getname" if present, and used in the
  7. # "open" syscall "filename" argument beautifier.
  8. # SPDX-License-Identifier: GPL-2.0
  9. # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
  10. # shellcheck source=lib/probe.sh
  11. . "$(dirname $0)"/lib/probe.sh
  12. skip_if_no_perf_probe || exit 2
  13. skip_if_no_perf_trace || exit 2
  14. . "$(dirname $0)"/lib/probe_vfs_getname.sh
  15. trace_open_vfs_getname() {
  16. evts="$(echo "$(perf list syscalls:sys_enter_open* 2>/dev/null | grep -E 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/')" | sed ':a;N;s:\n:,:g')"
  17. perf trace -e $evts touch $file 2>&1 | \
  18. grep -E " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +\"?${file}\"?, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
  19. }
  20. add_probe_vfs_getname || skip_if_no_debuginfo
  21. err=$?
  22. if [ $err -ne 0 ] ; then
  23. exit $err
  24. fi
  25. file=$(mktemp /tmp/temporary_file.XXXXX)
  26. # Do not use whatever ~/.perfconfig file, it may change the output
  27. # via trace.{show_timestamp,show_prefix,etc}
  28. export PERF_CONFIG=/dev/null
  29. trace_open_vfs_getname
  30. err=$?
  31. rm -f ${file}
  32. cleanup_probe_vfs_getname
  33. exit $err