summaryrefslogtreecommitdiff
path: root/fs/read_write.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-05-27 11:16:47 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2017-06-30 00:49:21 +0300
commit26c87fb7d10dadc59a475c7809adc05303bf951e (patch)
tree4e9ff5c7208689d1f5ea6b1be535b97219fd380a /fs/read_write.c
parent251b42a1dc641fac3fe412515233d60456180011 (diff)
downloadlinux-26c87fb7d10dadc59a475c7809adc05303bf951e.tar.xz
fs: remove do_compat_readv_writev
opencode it in both callers to simplify the call stack a bit. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r--fs/read_write.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 94cb71058098..5cbdf23d924f 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1142,32 +1142,13 @@ SYSCALL_DEFINE6(pwritev2, unsigned long, fd, const struct iovec __user *, vec,
}
#ifdef CONFIG_COMPAT
-
-static ssize_t compat_do_readv_writev(int type, struct file *file,
- const struct compat_iovec __user *uvector,
- unsigned long nr_segs, loff_t *pos,
- int flags)
-{
- struct iovec iovstack[UIO_FASTIOV];
- struct iovec *iov = iovstack;
- struct iov_iter iter;
- ssize_t ret;
-
- ret = compat_import_iovec(type, uvector, nr_segs,
- UIO_FASTIOV, &iov, &iter);
- if (ret < 0)
- return ret;
-
- ret = __do_readv_writev(type, file, &iter, pos, flags);
- kfree(iov);
-
- return ret;
-}
-
static size_t compat_readv(struct file *file,
const struct compat_iovec __user *vec,
unsigned long vlen, loff_t *pos, int flags)
{
+ struct iovec iovstack[UIO_FASTIOV];
+ struct iovec *iov = iovstack;
+ struct iov_iter iter;
ssize_t ret = -EBADF;
if (!(file->f_mode & FMODE_READ))
@@ -1177,8 +1158,11 @@ static size_t compat_readv(struct file *file,
if (!(file->f_mode & FMODE_CAN_READ))
goto out;
- ret = compat_do_readv_writev(READ, file, vec, vlen, pos, flags);
-
+ ret = compat_import_iovec(READ, vec, vlen, UIO_FASTIOV, &iov, &iter);
+ if (ret < 0)
+ goto out;
+ ret = __do_readv_writev(READ, file, &iter, pos, flags);
+ kfree(iov);
out:
if (ret > 0)
add_rchar(current, ret);
@@ -1275,6 +1259,9 @@ static size_t compat_writev(struct file *file,
const struct compat_iovec __user *vec,
unsigned long vlen, loff_t *pos, int flags)
{
+ struct iovec iovstack[UIO_FASTIOV];
+ struct iovec *iov = iovstack;
+ struct iov_iter iter;
ssize_t ret = -EBADF;
if (!(file->f_mode & FMODE_WRITE))
@@ -1284,8 +1271,11 @@ static size_t compat_writev(struct file *file,
if (!(file->f_mode & FMODE_CAN_WRITE))
goto out;
- ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos, flags);
-
+ ret = compat_import_iovec(WRITE, vec, vlen, UIO_FASTIOV, &iov, &iter);
+ if (ret < 0)
+ goto out;
+ ret = __do_readv_writev(WRITE, file, &iter, pos, flags);
+ kfree(iov);
out:
if (ret > 0)
add_wchar(current, ret);