#!/bin/bash # # Copyright (c) 2011 Bryan Schumaker # # Script for easier NFSD fault injection # Check that debugfs has been mounted setglobal DEBUGFS = $[cat /proc/mounts | grep debugfs] if test $DEBUGFS == "" { echo "debugfs does not appear to be mounted!" echo "Please mount debugfs and try again" exit 1 } # Check that the fault injection directory exists setglobal DEBUGDIR = "$[echo $DEBUGFS | awk '{print $2}]/nfsd" if test ! -d $DEBUGDIR { echo "$DEBUGDIR does not exist" echo "Check that your .config selects CONFIG_NFSD_FAULT_INJECTION" exit 1 } proc help { echo "Usage $0 injection_type [count]" echo "" echo "Injection types are:" ls $DEBUGDIR exit 1 } if test $Argc == 0 { help } elif test ! -f $DEBUGDIR/$1 { help } elif test $Argc != 2 { setglobal COUNT = '0' } else { setglobal COUNT = $2 } setglobal BEFORE = $[mktemp] setglobal AFTER = $[mktemp] dmesg > $BEFORE echo $COUNT > $DEBUGDIR/$1 dmesg > $AFTER # Capture lines that only exist in the $AFTER file diff $BEFORE $AFTER | grep ">" rm -f $BEFORE $AFTER