failmodule.sh 774 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. #
  3. # Usage: failmodule <failname> <modulename> [stacktrace-depth]
  4. #
  5. # <failname>: "failslab", "fail_alloc_page", or "fail_make_request"
  6. #
  7. # <modulename>: module name that you want to inject faults.
  8. #
  9. # [stacktrace-depth]: the maximum number of stacktrace walking allowed
  10. #
  11. STACKTRACE_DEPTH=5
  12. if [ $# -gt 2 ]; then
  13. STACKTRACE_DEPTH=$3
  14. fi
  15. if [ ! -d /debug/$1 ]; then
  16. echo "Fault-injection $1 does not exist" >&2
  17. exit 1
  18. fi
  19. if [ ! -d /sys/module/$2 ]; then
  20. echo "Module $2 does not exist" >&2
  21. exit 1
  22. fi
  23. # Disable any fault injection
  24. echo 0 > /debug/$1/stacktrace-depth
  25. echo `cat /sys/module/$2/sections/.text` > /debug/$1/require-start
  26. echo `cat /sys/module/$2/sections/.exit.text` > /debug/$1/require-end
  27. echo $STACKTRACE_DEPTH > /debug/$1/stacktrace-depth