/usr/src/lttng-modules-2.7.1/instrumentation/syscalls/lttng-get-syscall-inout.sh is in lttng-modules-dkms 2.7.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #!/bin/bash
# example usage:
# lttng-get-syscall-inout.sh table-syscall-inout.txt select 1
FILENAME=$1
SYSCALL_NAME=$2
ARG_NR=$3
TMPFILE=inout.tmp.1
TMPFILE2=inout.tmp.2
if [ x"${FILENAME}" = x"" ]; then
echo "Error: Please specify input file name as first argument"
exit 1
fi
if [ x"${SYSCALL_NAME}" = x"" ]; then
echo "Error: Please specify system call name as second argument"
exit 1
fi
if [[ x"${ARG_NR}" = x"" || ${ARG_NR} == 0 ]]; then
echo "Error: Please specify argument number larger than 0 as 3rd argument"
exit 1
fi
grep "syscall ${SYSCALL_NAME} " ${FILENAME} > ${TMPFILE}
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) .*/'\
'$2/g' ${TMPFILE} > ${TMPFILE2}
NR_MATCH=$(wc -l ${TMPFILE} | perl -p -e 's/^([^ ])*.*/$1/g')
if [ ${NR_MATCH} -gt 1 ]; then
echo "Error: more than one system call match"
exit 1
fi
if [ ${NR_MATCH} -eq 0 ]; then
# no match, default to inout
echo "sc_inout"
exit 0
fi
SC_ARGS=$(cat ${TMPFILE2})
if [ ${ARG_NR} -gt ${SC_ARGS} ]; then
echo "Error: argument number (${ARG_NR}) is larger than number of syscall arguments (${SC_ARGS})"
exit 1
fi
if [ ${ARG_NR} == 1 ]; then
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) rw: \(([^,\)]*).*/$3/g' ${TMPFILE} > ${TMPFILE2}
fi
if [ ${ARG_NR} == 2 ]; then
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) rw: \([^,]*, ([^,\)]*).*/$3/g' ${TMPFILE} > ${TMPFILE2}
fi
if [ ${ARG_NR} == 3 ]; then
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) rw: \([^,]*, [^,]*, ([^,\)]*).*/$3/g' ${TMPFILE} > ${TMPFILE2}
fi
if [ ${ARG_NR} == 4 ]; then
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) rw: \([^,]*, [^,]*, [^,]*, ([^,\)]*).*/$3/g' ${TMPFILE} > ${TMPFILE2}
fi
if [ ${ARG_NR} == 5 ]; then
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) rw: \([^,]*, [^,]*, [^,]*, [^,]*, ([^,\)]*).*/$3/g' ${TMPFILE} > ${TMPFILE2}
fi
if [ ${ARG_NR} == 6 ]; then
perl -p -e 's/^syscall ([^ ]*) nbargs ([^ ]*) rw: \([^,]*, [^,]*, [^,]*, [^,]*, [^,]*, ([^,\)]*).*/$3/g' ${TMPFILE} > ${TMPFILE2}
fi
SC_ARG_TYPE=$(cat ${TMPFILE2})
if [ ${SC_ARG_TYPE} = "r" ]; then
echo "sc_in"
fi
if [ ${SC_ARG_TYPE} = "w" ]; then
echo "sc_out"
fi
if [ ${SC_ARG_TYPE} = "rw" ]; then
echo "sc_inout"
fi
rm -f ${TMPFILE} ${TMPFILE2}
|