Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # Use vfs_getname probe to get syscall args filenames
0003 
0004 # Uses the 'perf test shell' library to add probe:vfs_getname to the system
0005 # then use it with 'perf record' using 'touch' to write to a temp file, then
0006 # checks that that was captured by the vfs_getname probe in the generated
0007 # perf.data file, with the temp file name as the pathname argument.
0008 
0009 # SPDX-License-Identifier: GPL-2.0
0010 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
0011 
0012 . $(dirname $0)/lib/probe.sh
0013 
0014 skip_if_no_perf_probe || exit 2
0015 
0016 . $(dirname $0)/lib/probe_vfs_getname.sh
0017 
0018 record_open_file() {
0019         echo "Recording open file:"
0020         perf record -o ${perfdata} -e probe:vfs_getname\* touch $file
0021 }
0022 
0023 perf_script_filenames() {
0024         echo "Looking at perf.data file for vfs_getname records for the file we touched:"
0025         perf script -i ${perfdata} | \
0026         egrep " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:vfs_getname[_0-9]*: +\([[:xdigit:]]+\) +pathname=\"${file}\""
0027 }
0028 
0029 add_probe_vfs_getname || skip_if_no_debuginfo
0030 err=$?
0031 if [ $err -ne 0 ] ; then
0032         exit $err
0033 fi
0034 
0035 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
0036 file=$(mktemp /tmp/temporary_file.XXXXX)
0037 
0038 record_open_file && perf_script_filenames
0039 err=$?
0040 rm -f ${perfdata}
0041 rm -f ${file}
0042 cleanup_probe_vfs_getname
0043 exit $err