]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/compat.c
preadv/pwritev: create compat_readv()
[linux-2.6-omap-h63xx.git] / fs / compat.c
index 55efdfebdf5ae14f5937add03075fdc8e716819d..e99048c21c56b75fe1897b1c0bab40d790c0f749 100644 (file)
@@ -1195,16 +1195,12 @@ out:
        return ret;
 }
 
-asmlinkage ssize_t
-compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen)
+static size_t compat_readv(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_READ))
                goto out;
 
@@ -1212,12 +1208,26 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsign
        if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read))
                goto out;
 
-       ret = compat_do_readv_writev(READ, file, vec, vlen, &file->f_pos);
+       ret = compat_do_readv_writev(READ, file, vec, vlen, pos);
 
 out:
        if (ret > 0)
                add_rchar(current, ret);
        inc_syscr(current);
+       return ret;
+}
+
+asmlinkage ssize_t
+compat_sys_readv(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_readv(file, vec, vlen, &file->f_pos);
        fput(file);
        return ret;
 }