From c41fbad015dabb0a40ecca50c3ff5658eb6471ff Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 1 Sep 2017 17:39:12 +0200 Subject: fs: move kernel_read to fs/read_write.c Signed-off-by: Christoph Hellwig Signed-off-by: Al Viro --- fs/read_write.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'fs/read_write.c') diff --git a/fs/read_write.c b/fs/read_write.c index 417dbe199505..1ea862bc7efd 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -415,6 +415,22 @@ ssize_t __vfs_read(struct file *file, char __user *buf, size_t count, } EXPORT_SYMBOL(__vfs_read); +int kernel_read(struct file *file, loff_t offset, char *addr, + unsigned long count) +{ + mm_segment_t old_fs; + loff_t pos = offset; + int result; + + old_fs = get_fs(); + set_fs(get_ds()); + /* The cast to a user pointer is valid due to the set_fs() */ + result = vfs_read(file, (void __user *)addr, count, &pos); + set_fs(old_fs); + return result; +} +EXPORT_SYMBOL(kernel_read); + ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { ssize_t ret; -- cgit v1.2.3