2 # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
5 # lttng-get-syscall-inout.sh table-syscall-inout.txt select 1
12 # Delete temp file on exit
13 trap 'rm -f "$TMPFILE"' EXIT
16 if [ x
"${FILENAME}" = x
"" ]; then
17 echo "Error: Please specify input file name as first argument" >&2
21 if [ x
"${SYSCALL_NAME}" = x
"" ]; then
22 echo "Error: Please specify system call name as second argument" >&2
26 if [[ x
"${ARG_NR}" = x
"" ||
${ARG_NR} == 0 ]]; then
27 echo "Error: Please specify argument number larger than 0 as third argument" >&2
31 # Abort on error and undefined variable
34 # Get the required syscall
35 grep "syscall ${SYSCALL_NAME} " "${FILENAME}" > "${TMPFILE}" || true
37 # Error out if we got more than one syscall
38 NR_MATCH
=$
(wc -l < "${TMPFILE}")
39 if [ "${NR_MATCH}" -gt 1 ]; then
40 echo "Error: more than one system call match" >&2
44 # Default to sc_inout for unknown syscalls
45 if [ "${NR_MATCH}" -eq 0 ]; then
46 echo "Warning: no match for syscall '${SYSCALL_NAME}', set to 'inout'" >&2
47 # no match, default to inout
52 # Get the number of argument
53 SC_ARGS
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) .*/\2/g' "${TMPFILE}")
55 if [ "${ARG_NR}" -gt "${SC_ARGS}" ]; then
56 echo "Error: argument number (${ARG_NR}) is larger than number of syscall arguments (${SC_ARGS})" >&2
60 if [ "${ARG_NR}" == 1 ]; then
61 SC_ARG_TYPE
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) rw: (\([^,)]*\).*/\3/g' "${TMPFILE}")
64 if [ "${ARG_NR}" == 2 ]; then
65 SC_ARG_TYPE
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) rw: ([^,]*, \([^,)]*\).*/\3/g' "${TMPFILE}")
68 if [ "${ARG_NR}" == 3 ]; then
69 SC_ARG_TYPE
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) rw: ([^,]*, [^,]*, \([^,)]*\).*/\3/g' "${TMPFILE}")
72 if [ "${ARG_NR}" == 4 ]; then
73 SC_ARG_TYPE
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) rw: ([^,]*, [^,]*, [^,]*, \([^,)]*\).*/\3/g' "${TMPFILE}")
76 if [ "${ARG_NR}" == 5 ]; then
77 SC_ARG_TYPE
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) rw: ([^,]*, [^,]*, [^,]*, [^,]*, \([^,)]*\).*/\3/g' "${TMPFILE}")
80 if [ "${ARG_NR}" == 6 ]; then
81 SC_ARG_TYPE
=$
(sed 's/^syscall \([^ ]*\) nbargs \([^ ]*\) rw: ([^,]*, [^,]*, [^,]*, [^,]*, [^,]*, \([^,)]*\).*/\3/g' "${TMPFILE}")
85 if [ "${SC_ARG_TYPE}" = "r" ]; then
88 if [ "${SC_ARG_TYPE}" = "w" ]; then
91 if [ "${SC_ARG_TYPE}" = "rw" ]; then
This page took 0.03179 seconds and 4 git commands to generate.