From a0ed95c2dbc4714990220eab4b0771ad1813c8a4 Mon Sep 17 00:00:00 2001 From: Paul Osmialowski Date: Thu, 16 Apr 2015 16:47:03 +0200 Subject: Import vfs_iter_* functions from Linux 4.0 These 2 functions are used by kdbus and backporting patches that add desired functions (with dependencies) would introduce too many changes for 3.10. Change-Id: I8554252cdf819a329088a8a083ebdb32e8a19727 Signed-off-by: Paul Osmialowski --- compat/Makefile | 1 + compat/fs/Makefile | 1 + compat/fs/read_write.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 compat/fs/Makefile create mode 100644 compat/fs/read_write.c (limited to 'compat') diff --git a/compat/Makefile b/compat/Makefile index 35a2017a7d4..4d550a1abfb 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -1,4 +1,5 @@ ifdef CONFIG_KDBUS override LINUXINCLUDE := $(patsubst -Iinclude, -Icompat/include -Iinclude , $(LINUXINCLUDE)) +obj-y += fs/ obj-y += lib/ endif diff --git a/compat/fs/Makefile b/compat/fs/Makefile new file mode 100644 index 00000000000..689a5f05ec8 --- /dev/null +++ b/compat/fs/Makefile @@ -0,0 +1 @@ +obj-y += read_write.o diff --git a/compat/fs/read_write.c b/compat/fs/read_write.c new file mode 100644 index 00000000000..f3c31c69682 --- /dev/null +++ b/compat/fs/read_write.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos) +{ + struct kiocb kiocb; + ssize_t ret; + + if (!file->f_op->read_iter) + return -EINVAL; + + init_sync_kiocb(&kiocb, file); + kiocb.ki_pos = *ppos; + + iter->type |= READ; + ret = file->f_op->read_iter(&kiocb, iter); + BUG_ON(ret == -EIOCBQUEUED); + if (ret > 0) + *ppos = kiocb.ki_pos; + return ret; +} +EXPORT_SYMBOL(vfs_iter_read); + +ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos) +{ + struct kiocb kiocb; + ssize_t ret; + + if (!file->f_op->write_iter) + return -EINVAL; + + init_sync_kiocb(&kiocb, file); + kiocb.ki_pos = *ppos; + + iter->type |= WRITE; + ret = file->f_op->write_iter(&kiocb, iter); + BUG_ON(ret == -EIOCBQUEUED); + if (ret > 0) + *ppos = kiocb.ki_pos; + return ret; +} +EXPORT_SYMBOL(vfs_iter_write); -- cgit v1.2.3