[PATCH -mm 5/5] fault-inject: add /proc/<pid>/fail-nth

From: Akinobu Mita
Date: Thu Apr 06 2017 - 10:57:35 EST


fail-nth interface is only created in /proc/self/task/<current-tid>/.
This change also adds it in /proc/<pid>/.

This makes shell based tool a bit simpler.

$ bash -c "builtin echo 100 > /proc/self/fail-nth && exec ls /"

Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
---
Documentation/fault-injection/fault-injection.txt | 3 ++-
fs/proc/base.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt
index 370ddcb..918972b 100644
--- a/Documentation/fault-injection/fault-injection.txt
+++ b/Documentation/fault-injection/fault-injection.txt
@@ -136,7 +136,8 @@ use the boot option:

o proc entries

-- /proc/self/task/<current-tid>/fail-nth:
+- /proc/<pid>/fail-nth:
+- /proc/self/task/<tid>/fail-nth:

Write to this file of integer N makes N-th call in the task fail.
Read from this file returns a integer value. A value of '0' indicates
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 14e7b73..ea1039d 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2964,6 +2964,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#endif
#ifdef CONFIG_FAULT_INJECTION
REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
+ REG("fail-nth", 0644, proc_fail_nth_operations),
#endif
#ifdef CONFIG_ELF_CORE
REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations),
--
2.7.4