Merge tag 'drm-amdkfd-fixes-2017-11-26' of git://people.freedesktop.org/~gabbayo...
[linux-2.6-microblaze.git] / tools / nfsd / inject_fault.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # Copyright (c) 2011 Bryan Schumaker <bjschuma@netapp.com>
5 #
6 # Script for easier NFSD fault injection
7
8 # Check that debugfs has been mounted
9 DEBUGFS=`cat /proc/mounts | grep debugfs`
10 if [ "$DEBUGFS" == "" ]; then
11         echo "debugfs does not appear to be mounted!"
12         echo "Please mount debugfs and try again"
13         exit 1
14 fi
15
16 # Check that the fault injection directory exists
17 DEBUGDIR=`echo $DEBUGFS | awk '{print $2}'`/nfsd
18 if [ ! -d "$DEBUGDIR" ]; then
19         echo "$DEBUGDIR does not exist"
20         echo "Check that your .config selects CONFIG_NFSD_FAULT_INJECTION"
21         exit 1
22 fi
23
24 function help()
25 {
26         echo "Usage $0 injection_type [count]"
27         echo ""
28         echo "Injection types are:"
29         ls $DEBUGDIR
30         exit 1
31 }
32
33 if [ $# == 0 ]; then
34         help
35 elif [ ! -f $DEBUGDIR/$1 ]; then
36         help
37 elif [ $# != 2 ]; then
38         COUNT=0
39 else
40         COUNT=$2
41 fi
42
43 BEFORE=`mktemp`
44 AFTER=`mktemp`
45 dmesg > $BEFORE
46 echo $COUNT > $DEBUGDIR/$1
47 dmesg > $AFTER
48 # Capture lines that only exist in the $AFTER file
49 diff $BEFORE $AFTER | grep ">"
50 rm -f $BEFORE $AFTER