aboutsummaryrefslogtreecommitdiff
path: root/Documentation/fault-injection/failmodule.sh
blob: 474a8b971f9ca82ad722e4166e6d323cee368a36 (plain)
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
#!/bin/bash
#
# Usage: failmodule <failname> <modulename> [stacktrace-depth]
#
#	<failname>: "failslab", "fail_alloc_page", or "fail_make_request"
#
#	<modulename>: module name that you want to inject faults.
#
#	[stacktrace-depth]: the maximum number of stacktrace walking allowed
#

STACKTRACE_DEPTH=5
if [ $# -gt 2 ]; then
	STACKTRACE_DEPTH=$3
fi

if [ ! -d /debug/$1 ]; then
	echo "Fault-injection $1 does not exist" >&2
	exit 1
fi
if [ ! -d /sys/module/$2 ]; then
	echo "Module $2 does not exist" >&2
	exit 1
fi

# Disable any fault injection
echo 0 > /debug/$1/stacktrace-depth

echo `cat /sys/module/$2/sections/.text` > /debug/$1/require-start
echo `cat /sys/module/$2/sections/.exit.text` > /debug/$1/require-end
echo $STACKTRACE_DEPTH > /debug/$1/stacktrace-depth