diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2006-12-08 02:39:47 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 08:29:02 -0800 |
commit | f4f154fd920b2178382a6a24a236348e4429ebc1 (patch) | |
tree | 0bba747eb50b5d7e18d2b828f8c707b2781d7544 /lib/fault-inject.c | |
parent | c17bb4951752d3e0f49cd1ea9d2e868422f9e0d6 (diff) |
[PATCH] fault injection: process filtering for fault-injection capabilities
This patch provides process filtering feature.
The process filter allows failing only permitted processes
by /proc/<pid>/make-it-fail
Please see the example that demostrates how to inject slab allocation
failures into module init/cleanup code
in Documentation/fault-injection/fault-injection.txt
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib/fault-inject.c')
-rw-r--r-- | lib/fault-inject.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index a7cb3afd132..03468609d70 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c @@ -5,6 +5,7 @@ #include <linux/types.h> #include <linux/fs.h> #include <linux/module.h> +#include <linux/interrupt.h> #include <linux/fault-inject.h> /* @@ -44,6 +45,11 @@ static void fail_dump(struct fault_attr *attr) #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) +static int fail_task(struct fault_attr *attr, struct task_struct *task) +{ + return !in_interrupt() && task->make_it_fail; +} + /* * This code is stolen from failmalloc-1.0 * http://www.nongnu.org/failmalloc/ @@ -51,6 +57,9 @@ static void fail_dump(struct fault_attr *attr) int should_fail(struct fault_attr *attr, ssize_t size) { + if (attr->task_filter && !fail_task(attr, current)) + return 0; + if (atomic_read(&attr->times) == 0) return 0; @@ -135,6 +144,9 @@ void cleanup_fault_attr_dentries(struct fault_attr *attr) debugfs_remove(attr->dentries.verbose_file); attr->dentries.verbose_file = NULL; + debugfs_remove(attr->dentries.task_filter_file); + attr->dentries.task_filter_file = NULL; + if (attr->dentries.dir) WARN_ON(!simple_empty(attr->dentries.dir)); @@ -169,9 +181,12 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name) attr->dentries.verbose_file = debugfs_create_ul("verbose", mode, dir, &attr->verbose); + attr->dentries.task_filter_file = debugfs_create_bool("task-filter", + mode, dir, &attr->task_filter); + if (!attr->dentries.probability_file || !attr->dentries.interval_file || !attr->dentries.times_file || !attr->dentries.space_file - || !attr->dentries.verbose_file) + || !attr->dentries.verbose_file || !attr->dentries.task_filter_file) goto fail; return 0; |