1 #ifndef _LINUX_FAULT_INJECT_H
2 #define _LINUX_FAULT_INJECT_H
4 #ifdef CONFIG_FAULT_INJECTION
6 #include <linux/types.h>
7 #include <linux/debugfs.h>
8 #include <linux/atomic.h>
11 * For explanation of the elements of this struct, see
12 * Documentation/fault-injection/fault-injection.txt
15 unsigned long probability;
16 unsigned long interval;
19 unsigned long verbose;
21 unsigned long stacktrace_depth;
22 unsigned long require_start;
23 unsigned long require_end;
24 unsigned long reject_start;
25 unsigned long reject_end;
30 #define FAULT_ATTR_INITIALIZER { \
32 .times = ATOMIC_INIT(1), \
33 .require_end = ULONG_MAX, \
34 .stacktrace_depth = 32, \
38 #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
39 int setup_fault_attr(struct fault_attr *attr, char *str);
40 bool should_fail(struct fault_attr *attr, ssize_t size);
42 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
44 struct dentry *fault_create_debugfs_attr(const char *name,
45 struct dentry *parent, struct fault_attr *attr);
47 #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
49 static inline struct dentry *fault_create_debugfs_attr(const char *name,
50 struct dentry *parent, struct fault_attr *attr)
52 return ERR_PTR(-ENODEV);
55 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
57 #endif /* CONFIG_FAULT_INJECTION */
59 #ifdef CONFIG_FAILSLAB
60 extern bool should_failslab(size_t size, gfp_t gfpflags, unsigned long flags);
62 static inline bool should_failslab(size_t size, gfp_t gfpflags,
67 #endif /* CONFIG_FAILSLAB */
69 #endif /* _LINUX_FAULT_INJECT_H */