blob: 10ceee64a09a8c2ad0b3153f6bd96155ce423ee4 [file] [log] [blame]
Bryan Schumaker800b9272011-11-01 13:35:22 -04001#!/bin/bash
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Bryan Schumaker800b9272011-11-01 13:35:22 -04003#
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
9DEBUGFS=`cat /proc/mounts | grep debugfs`
10if [ "$DEBUGFS" == "" ]; then
11 echo "debugfs does not appear to be mounted!"
12 echo "Please mount debugfs and try again"
13 exit 1
14fi
15
16# Check that the fault injection directory exists
17DEBUGDIR=`echo $DEBUGFS | awk '{print $2}'`/nfsd
18if [ ! -d "$DEBUGDIR" ]; then
19 echo "$DEBUGDIR does not exist"
20 echo "Check that your .config selects CONFIG_NFSD_FAULT_INJECTION"
21 exit 1
22fi
23
24function help()
25{
26 echo "Usage $0 injection_type [count]"
27 echo ""
28 echo "Injection types are:"
29 ls $DEBUGDIR
30 exit 1
31}
32
33if [ $# == 0 ]; then
34 help
35elif [ ! -f $DEBUGDIR/$1 ]; then
36 help
37elif [ $# != 2 ]; then
38 COUNT=0
39else
40 COUNT=$2
41fi
42
43BEFORE=`mktemp`
44AFTER=`mktemp`
45dmesg > $BEFORE
46echo $COUNT > $DEBUGDIR/$1
47dmesg > $AFTER
48# Capture lines that only exist in the $AFTER file
49diff $BEFORE $AFTER | grep ">"
50rm -f $BEFORE $AFTER