Commit | Line | Data |
---|---|---|
6ff1cb35 AM |
1 | #ifndef _LINUX_FAULT_INJECT_H |
2 | #define _LINUX_FAULT_INJECT_H | |
3 | ||
4 | #ifdef CONFIG_FAULT_INJECTION | |
5 | ||
6 | #include <linux/types.h> | |
7 | #include <linux/debugfs.h> | |
8 | #include <asm/atomic.h> | |
9 | ||
10 | /* | |
11 | * For explanation of the elements of this struct, see | |
12 | * Documentation/fault-injection/fault-injection.txt | |
13 | */ | |
14 | struct fault_attr { | |
15 | unsigned long probability; | |
16 | unsigned long interval; | |
17 | atomic_t times; | |
18 | atomic_t space; | |
19 | unsigned long verbose; | |
f4f154fd | 20 | u32 task_filter; |
329409ae AM |
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; | |
6ff1cb35 AM |
26 | |
27 | unsigned long count; | |
28 | ||
29 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | |
30 | ||
31 | struct { | |
32 | struct dentry *dir; | |
33 | ||
34 | struct dentry *probability_file; | |
35 | struct dentry *interval_file; | |
36 | struct dentry *times_file; | |
37 | struct dentry *space_file; | |
38 | struct dentry *verbose_file; | |
f4f154fd | 39 | struct dentry *task_filter_file; |
329409ae AM |
40 | struct dentry *stacktrace_depth_file; |
41 | struct dentry *require_start_file; | |
42 | struct dentry *require_end_file; | |
43 | struct dentry *reject_start_file; | |
44 | struct dentry *reject_end_file; | |
6ff1cb35 AM |
45 | } dentries; |
46 | ||
47 | #endif | |
48 | }; | |
49 | ||
50 | #define FAULT_ATTR_INITIALIZER { \ | |
51 | .interval = 1, \ | |
52 | .times = ATOMIC_INIT(1), \ | |
329409ae AM |
53 | .require_end = ULONG_MAX, \ |
54 | .stacktrace_depth = 32, \ | |
6ff1cb35 AM |
55 | } |
56 | ||
57 | #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER | |
58 | int setup_fault_attr(struct fault_attr *attr, char *str); | |
59 | void should_fail_srandom(unsigned long entropy); | |
60 | int should_fail(struct fault_attr *attr, ssize_t size); | |
61 | ||
62 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | |
63 | ||
64 | int init_fault_attr_dentries(struct fault_attr *attr, const char *name); | |
65 | void cleanup_fault_attr_dentries(struct fault_attr *attr); | |
66 | ||
67 | #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */ | |
68 | ||
69 | static inline int init_fault_attr_dentries(struct fault_attr *attr, | |
70 | const char *name) | |
71 | { | |
72 | return -ENODEV; | |
73 | } | |
74 | ||
75 | static inline void cleanup_fault_attr_dentries(struct fault_attr *attr) | |
76 | { | |
77 | } | |
78 | ||
79 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ | |
80 | ||
81 | #endif /* CONFIG_FAULT_INJECTION */ | |
82 | ||
83 | #endif /* _LINUX_FAULT_INJECT_H */ |