Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # Check open filename arg using perf trace + vfs_getname
0003 
0004 # Uses the 'perf test shell' library to add probe:vfs_getname to the system
0005 # then use it with 'perf trace' using 'touch' to write to a temp file, then
0006 # checks that that was captured by the vfs_getname was used by 'perf trace',
0007 # that already handles "probe:vfs_getname" if present, and used in the
0008 # "open" syscall "filename" argument beautifier.
0009 
0010 # SPDX-License-Identifier: GPL-2.0
0011 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
0012 
0013 . $(dirname $0)/lib/probe.sh
0014 
0015 skip_if_no_perf_probe || exit 2
0016 skip_if_no_perf_trace || exit 2
0017 
0018 . $(dirname $0)/lib/probe_vfs_getname.sh
0019 
0020 trace_open_vfs_getname() {
0021         evts=$(echo $(perf list syscalls:sys_enter_open* 2>/dev/null | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/')
0022         perf trace -e $evts touch $file 2>&1 | \
0023         egrep " +[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]+$"
0024 }
0025 
0026 
0027 add_probe_vfs_getname || skip_if_no_debuginfo
0028 err=$?
0029 if [ $err -ne 0 ] ; then
0030         exit $err
0031 fi
0032 
0033 file=$(mktemp /tmp/temporary_file.XXXXX)
0034 
0035 # Do not use whatever ~/.perfconfig file, it may change the output
0036 # via trace.{show_timestamp,show_prefix,etc}
0037 export PERF_CONFIG=/dev/null
0038 
0039 trace_open_vfs_getname
0040 err=$?
0041 rm -f ${file}
0042 cleanup_probe_vfs_getname
0043 exit $err