mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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/[email protected] Signed-off-by: Akinobu Mita <[email protected]> Cc: Dmitry Vyukov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
9049f2f6e7
commit
bfc740938d
2 changed files with 13 additions and 14 deletions
|
|
@ -1380,7 +1380,8 @@ static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
|
|||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct task_struct *task;
|
||||
int err;
|
||||
char numbuf[PROC_NUMBUF];
|
||||
ssize_t len;
|
||||
|
||||
task = get_proc_task(file_inode(file));
|
||||
if (!task)
|
||||
|
|
@ -1388,13 +1389,10 @@ static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
|
|||
put_task_struct(task);
|
||||
if (task != current)
|
||||
return -EPERM;
|
||||
if (count < 1)
|
||||
return -EINVAL;
|
||||
err = put_user((char)(current->fail_nth ? 'N' : 'Y'), buf);
|
||||
if (err)
|
||||
return err;
|
||||
current->fail_nth = 0;
|
||||
return 1;
|
||||
len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth);
|
||||
len = simple_read_from_buffer(buf, count, ppos, numbuf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static const struct file_operations proc_fail_nth_operations = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue