[PATCH 1/3] Add generic compat_sys_sendfile implementation

From: Catalin Marinas
Date: Thu Sep 13 2012 - 04:51:10 EST


This function is used by other architectures requiring compat support,
so just make it generic.

Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
---
fs/read_write.c | 22 ++++++++++++++++++++++
include/linux/compat.h | 3 +++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 1adfb69..91b91c4 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1007,3 +1007,25 @@ SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset, si

return do_sendfile(out_fd, in_fd, NULL, count, 0);
}
+
+#ifdef __ARCH_WANT_COMPAT_SYS_SENDFILE
+asmlinkage int compat_sys_sendfile(int out_fd, int in_fd,
+ compat_off_t __user *offset, compat_size_t count)
+{
+ loff_t pos;
+ off_t off;
+ ssize_t ret;
+
+ if (offset) {
+ if (unlikely(get_user(off, offset)))
+ return -EFAULT;
+ pos = off;
+ ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS);
+ if (unlikely(put_user(pos, offset)))
+ return -EFAULT;
+ return ret;
+ }
+
+ return do_sendfile(out_fd, in_fd, NULL, count, 0);
+}
+#endif /* __ARCH_WANT_COMPAT_SYS_SENDFILE */
diff --git a/include/linux/compat.h b/include/linux/compat.h
index c4be3f5..f386e82 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -594,6 +594,9 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
unsigned long liovcnt, const struct compat_iovec __user *rvec,
unsigned long riovcnt, unsigned long flags);

+asmlinkage int compat_sys_sendfile(int out_fd, int in_fd,
+ compat_off_t __user *offset, s32 count);
+
#else

#define is_compat_task() (0)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/