Skip to content

Commit

Permalink
binfmt_misc: use simple_read_from_buffer()
Browse files Browse the repository at this point in the history
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
mita authored and torvalds committed Jul 24, 2008
1 parent 76a6f3d commit 6e2c10a
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions fs/binfmt_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/namei.h>
#include <linux/mount.h>
#include <linux/syscalls.h>
#include <linux/fs.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -535,31 +536,16 @@ static ssize_t
bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
{
Node *e = file->f_path.dentry->d_inode->i_private;
loff_t pos = *ppos;
ssize_t res;
char *page;
int len;

if (!(page = (char*) __get_free_page(GFP_KERNEL)))
return -ENOMEM;

entry_status(e, page);
len = strlen(page);

res = -EINVAL;
if (pos < 0)
goto out;
res = 0;
if (pos >= len)
goto out;
if (len < pos + nbytes)
nbytes = len - pos;
res = -EFAULT;
if (copy_to_user(buf, page + pos, nbytes))
goto out;
*ppos = pos + nbytes;
res = nbytes;
out:
res = simple_read_from_buffer(buf, nbytes, ppos, page, strlen(page));

free_page((unsigned long) page);
return res;
}
Expand Down

0 comments on commit 6e2c10a

Please sign in to comment.