Skip to content

Commit

Permalink
procfs: use simple_read_from_buffer()
Browse files Browse the repository at this point in the history
Cleanup using simple_read_from_buffer() in procfs.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed May 8, 2007
1 parent 3463399 commit 0c28f28
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,22 +660,15 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
char buffer[PROC_NUMBUF];
size_t len;
int oom_adjust;
loff_t __ppos = *ppos;

if (!task)
return -ESRCH;
oom_adjust = task->oomkilladj;
put_task_struct(task);

len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
if (__ppos >= len)
return 0;
if (count > len-__ppos)
count = len-__ppos;
if (copy_to_user(buf, buffer + __ppos, count))
return -EFAULT;
*ppos = __ppos + count;
return count;

return simple_read_from_buffer(buf, count, ppos, buffer, len);
}

static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
Expand Down Expand Up @@ -823,22 +816,15 @@ static ssize_t seccomp_read(struct file *file, char __user *buf,
{
struct task_struct *tsk = get_proc_task(file->f_dentry->d_inode);
char __buf[20];
loff_t __ppos = *ppos;
size_t len;

if (!tsk)
return -ESRCH;
/* no need to print the trailing zero, so use only len */
len = sprintf(__buf, "%u\n", tsk->seccomp.mode);
put_task_struct(tsk);
if (__ppos >= len)
return 0;
if (count > len - __ppos)
count = len - __ppos;
if (copy_to_user(buf, __buf + __ppos, count))
return -EFAULT;
*ppos = __ppos + count;
return count;

return simple_read_from_buffer(buf, count, ppos, __buf, len);
}

static ssize_t seccomp_write(struct file *file, const char __user *buf,
Expand Down Expand Up @@ -897,22 +883,15 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
char buffer[PROC_NUMBUF];
size_t len;
int make_it_fail;
loff_t __ppos = *ppos;

if (!task)
return -ESRCH;
make_it_fail = task->make_it_fail;
put_task_struct(task);

len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail);
if (__ppos >= len)
return 0;
if (count > len-__ppos)
count = len-__ppos;
if (copy_to_user(buf, buffer + __ppos, count))
return -EFAULT;
*ppos = __ppos + count;
return count;

return simple_read_from_buffer(buf, count, ppos, buffer, len);
}

static ssize_t proc_fault_inject_write(struct file * file,
Expand Down Expand Up @@ -975,7 +954,7 @@ static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,

if (!tmp)
return -ENOMEM;

inode = dentry->d_inode;
path = d_path(dentry, mnt, tmp, PAGE_SIZE);
len = PTR_ERR(path);
Expand Down

0 comments on commit 0c28f28

Please sign in to comment.