]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/compat.c
preadv/pwritev: create compat_writev()
[linux-2.6-omap-h63xx.git] / fs / compat.c
index e99048c21c56b75fe1897b1c0bab40d790c0f749..e04b4660db846527f81f995de39a5e52f16b2e7f 100644 (file)
@@ -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;
 }