summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-04-02 16:59:21 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-02 19:05:07 -0700
commit6949a6318e60aeb9c755679ac7f978aefe8c1722 (patch)
tree97fdbd5d494c5bc99145d5caed28be4ad0e467db
parentdac1213842f5caf081804a11d87d2a39a21d6f55 (diff)
downloadlinux-6949a6318e60aeb9c755679ac7f978aefe8c1722.tar.gz
linux-6949a6318e60aeb9c755679ac7f978aefe8c1722.tar.bz2
linux-6949a6318e60aeb9c755679ac7f978aefe8c1722.zip
preadv/pwritev: create compat_writev()
Factor out some code from compat_sys_writev() which can be shared with the upcoming compat_sys_pwritev(). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: <linux-api@vger.kernel.org> Cc: <linux-arch@vger.kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/compat.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/compat.c b/fs/compat.c
index e99048c21c56..e04b4660db84 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1232,15 +1232,12 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,
return ret;
}
-asmlinkage ssize_t
-compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen)
+static size_t compat_writev(struct file *file,
+ const struct compat_iovec __user *vec,
+ unsigned long vlen, loff_t *pos)
{
- struct file *file;
ssize_t ret = -EBADF;
- file = fget(fd);
- if (!file)
- return -EBADF;
if (!(file->f_mode & FMODE_WRITE))
goto out;
@@ -1248,12 +1245,26 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsig
if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write))
goto out;
- ret = compat_do_readv_writev(WRITE, file, vec, vlen, &file->f_pos);
+ ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos);
out:
if (ret > 0)
add_wchar(current, ret);
inc_syscw(current);
+ return ret;
+}
+
+asmlinkage ssize_t
+compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,
+ unsigned long vlen)
+{
+ struct file *file;
+ ssize_t ret;
+
+ file = fget(fd);
+ if (!file)
+ return -EBADF;
+ ret = compat_writev(file, vec, vlen, &file->f_pos);
fput(file);
return ret;
}