[PATCH] fault injection: process filtering for fault-injection capabilities
[linux-2.6/linux-loongson.git] / include / linux / fault-inject.h
bloba525f9b9f015798383c81f227402c40249555a6b
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 <asm/atomic.h>
11 * For explanation of the elements of this struct, see
12 * Documentation/fault-injection/fault-injection.txt
14 struct fault_attr {
15 unsigned long probability;
16 unsigned long interval;
17 atomic_t times;
18 atomic_t space;
19 unsigned long verbose;
20 u32 task_filter;
22 unsigned long count;
24 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
26 struct {
27 struct dentry *dir;
29 struct dentry *probability_file;
30 struct dentry *interval_file;
31 struct dentry *times_file;
32 struct dentry *space_file;
33 struct dentry *verbose_file;
34 struct dentry *task_filter_file;
35 } dentries;
37 #endif
40 #define FAULT_ATTR_INITIALIZER { \
41 .interval = 1, \
42 .times = ATOMIC_INIT(1), \
45 #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
46 int setup_fault_attr(struct fault_attr *attr, char *str);
47 void should_fail_srandom(unsigned long entropy);
48 int should_fail(struct fault_attr *attr, ssize_t size);
50 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
52 int init_fault_attr_dentries(struct fault_attr *attr, const char *name);
53 void cleanup_fault_attr_dentries(struct fault_attr *attr);
55 #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
57 static inline int init_fault_attr_dentries(struct fault_attr *attr,
58 const char *name)
60 return -ENODEV;
63 static inline void cleanup_fault_attr_dentries(struct fault_attr *attr)
67 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
69 #endif /* CONFIG_FAULT_INJECTION */
71 #endif /* _LINUX_FAULT_INJECT_H */