fault-inject.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 count;
  19. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  20. struct {
  21. struct dentry *dir;
  22. struct dentry *probability_file;
  23. struct dentry *interval_file;
  24. struct dentry *times_file;
  25. struct dentry *space_file;
  26. struct dentry *verbose_file;
  27. struct dentry *task_filter_file;
  28. } dentries;
  29. #endif
  30. };
  31. #define FAULT_ATTR_INITIALIZER { \
  32. .interval = 1, \
  33. .times = ATOMIC_INIT(1), \
  34. }
  35. #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
  36. int setup_fault_attr(struct fault_attr *attr, char *str);
  37. void should_fail_srandom(unsigned long entropy);
  38. int should_fail(struct fault_attr *attr, ssize_t size);
  39. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  40. int init_fault_attr_dentries(struct fault_attr *attr, const char *name);
  41. void cleanup_fault_attr_dentries(struct fault_attr *attr);
  42. #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
  43. static inline int init_fault_attr_dentries(struct fault_attr *attr,
  44. const char *name)
  45. {
  46. return -ENODEV;
  47. }
  48. static inline void cleanup_fault_attr_dentries(struct fault_attr *attr)
  49. {
  50. }
  51. #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
  52. #endif /* CONFIG_FAULT_INJECTION */
  53. #endif /* _LINUX_FAULT_INJECT_H */