]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/read_write.c
Merge tag 'devdax-for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
[linux.git] / fs / read_write.c
index ff3c5e6f87cfaa7c84064161c08d1b76de314505..177ccc3d405a33b425998e400b105418d8f537a4 100644 (file)
@@ -426,7 +426,7 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
        ssize_t result;
 
        old_fs = get_fs();
-       set_fs(get_ds());
+       set_fs(KERNEL_DS);
        /* The cast to a user pointer is valid due to the set_fs() */
        result = vfs_read(file, (void __user *)buf, count, pos);
        set_fs(old_fs);
@@ -478,8 +478,8 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
        return ret;
 }
 
-ssize_t __vfs_write(struct file *file, const char __user *p, size_t count,
-                   loff_t *pos)
+static ssize_t __vfs_write(struct file *file, const char __user *p,
+                          size_t count, loff_t *pos)
 {
        if (file->f_op->write)
                return file->f_op->write(file, p, count, pos);
@@ -499,7 +499,7 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t
                return -EINVAL;
 
        old_fs = get_fs();
-       set_fs(get_ds());
+       set_fs(KERNEL_DS);
        p = (__force const char __user *)buf;
        if (count > MAX_RW_COUNT)
                count =  MAX_RW_COUNT;
@@ -521,7 +521,7 @@ ssize_t kernel_write(struct file *file, const void *buf, size_t count,
        ssize_t res;
 
        old_fs = get_fs();
-       set_fs(get_ds());
+       set_fs(KERNEL_DS);
        /* The cast to a user pointer is valid due to the set_fs() */
        res = vfs_write(file, (__force const char __user *)buf, count, pos);
        set_fs(old_fs);
@@ -1238,6 +1238,9 @@ COMPAT_SYSCALL_DEFINE5(preadv64v2, unsigned long, fd,
                const struct compat_iovec __user *,vec,
                unsigned long, vlen, loff_t, pos, rwf_t, flags)
 {
+       if (pos == -1)
+               return do_compat_readv(fd, vec, vlen, flags);
+
        return do_compat_preadv64(fd, vec, vlen, pos, flags);
 }
 #endif
@@ -1344,6 +1347,9 @@ COMPAT_SYSCALL_DEFINE5(pwritev64v2, unsigned long, fd,
                const struct compat_iovec __user *,vec,
                unsigned long, vlen, loff_t, pos, rwf_t, flags)
 {
+       if (pos == -1)
+               return do_compat_writev(fd, vec, vlen, flags);
+
        return do_compat_pwritev64(fd, vec, vlen, pos, flags);
 }
 #endif