fault-inject.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _LINUX_FAULT_INJECT_H
  2. #define _LINUX_FAULT_INJECT_H
  3. #ifdef CONFIG_FAULT_INJECTION
  4. #include <linux/types.h>
  5. #include <linux/debugfs.h>
  6. #include <asm/atomic.h>
  7. /*
  8. * For explanation of the elements of this struct, see
  9. * Documentation/fault-injection/fault-injection.txt
  10. */
  11. struct fault_attr {
  12. unsigned long probability;
  13. unsigned long interval;
  14. atomic_t times;
  15. atomic_t space;
  16. unsigned long verbose;
  17. u32 task_filter;
  18. unsigned long stacktrace_depth;
  19. unsigned long require_start;
  20. unsigned long require_end;
  21. unsigned long reject_start;
  22. unsigned long reject_end;
  23. unsigned long count;
  24. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  25. struct {
  26. struct dentry *dir;
  27. struct dentry *probability_file;
  28. struct dentry *interval_file;
  29. struct dentry *times_file;
  30. struct dentry *space_file;
  31. struct dentry *verbose_file;
  32. struct dentry *task_filter_file;
  33. struct dentry *stacktrace_depth_file;
  34. struct dentry *require_start_file;
  35. struct dentry *require_end_file;
  36. struct dentry *reject_start_file;
  37. struct dentry *reject_end_file;
  38. } dentries;
  39. #endif
  40. };
  41. #define FAULT_ATTR_INITIALIZER { \
  42. .interval = 1, \
  43. .times = ATOMIC_INIT(1), \
  44. .require_end = ULONG_MAX, \
  45. .stacktrace_depth = 32, \
  46. .verbose = 2, \
  47. }
  48. #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
  49. int setup_fault_attr(struct fault_attr *attr, char *str);
  50. void should_fail_srandom(unsigned long entropy);
  51. bool should_fail(struct fault_attr *attr, ssize_t size);
  52. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  53. int init_fault_attr_dentries(struct fault_attr *attr, const char *name);
  54. void cleanup_fault_attr_dentries(struct fault_attr *attr);
  55. #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
  56. static inline int init_fault_attr_dentries(struct fault_attr *attr,
  57. const char *name)
  58. {
  59. return -ENODEV;
  60. }
  61. static inline void cleanup_fault_attr_dentries(struct fault_attr *attr)
  62. {
  63. }
  64. #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
  65. #endif /* CONFIG_FAULT_INJECTION */
  66. #endif /* _LINUX_FAULT_INJECT_H */