aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2017-07-14 17:49:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-14 18:05:13 -0400
commitbfc740938d151001cb1158580796f8f3be3bf0c1 (patch)
tree3a0f549da5213fca25afe2ea9a8d4c20b7cc9b99 /fs/proc
parent9049f2f6e7bdfb5de0c63c2635bf3cdb70c4efb5 (diff)
fault-inject: make fail-nth read/write interface symmetric
The read interface for fail-nth looks a bit odd. Read from this file returns "NYYYY..." or "YYYYY..." (this makes me surprise when cat this file). Because there is no EOF condition. The first character indicates current->fail_nth is zero or not, and then current->fail_nth is reset to zero. Just returning task->fail_nth value is more natural to understand. Link: http://lkml.kernel.org/r/1491490561-10485-4-git-send-email-akinobu.mita@gmail.com Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index c1fdaecb8d23..7d795d28dd02 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1380,7 +1380,8 @@ static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
1380 size_t count, loff_t *ppos) 1380 size_t count, loff_t *ppos)
1381{ 1381{
1382 struct task_struct *task; 1382 struct task_struct *task;
1383 int err; 1383 char numbuf[PROC_NUMBUF];
1384 ssize_t len;
1384 1385
1385 task = get_proc_task(file_inode(file)); 1386 task = get_proc_task(file_inode(file));
1386 if (!task) 1387 if (!task)
@@ -1388,13 +1389,10 @@ static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
1388 put_task_struct(task); 1389 put_task_struct(task);
1389 if (task != current) 1390 if (task != current)
1390 return -EPERM; 1391 return -EPERM;
1391 if (count < 1) 1392 len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth);
1392 return -EINVAL; 1393 len = simple_read_from_buffer(buf, count, ppos, numbuf, len);
1393 err = put_user((char)(current->fail_nth ? 'N' : 'Y'), buf); 1394
1394 if (err) 1395 return len;
1395 return err;
1396 current->fail_nth = 0;
1397 return 1;
1398} 1396}
1399 1397
1400static const struct file_operations proc_fail_nth_operations = { 1398static const struct file_operations proc_fail_nth_operations = {