diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2012-09-13 09:51:10 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2012-09-14 14:53:05 +0100 |
commit | d85a06d5ef792f53b674dd7dfda92726dba5f761 (patch) | |
tree | 4357af7ecd1449321b6b109792eac88778997a2f | |
parent | 8c39fdd6055b5cdb31b352c7ecad4cc719651597 (diff) | |
download | linux-aarch64-d85a06d5ef792f53b674dd7dfda92726dba5f761.tar.gz |
Add generic compat_sys_sendfile implementation
This function is used by other architectures requiring compat support,
so just make it generic.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | fs/read_write.c | 22 | ||||
-rw-r--r-- | 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 1adfb691e4f..91b91c4a9ed 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 09b28b7369d..5f2d2ccf8db 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -590,6 +590,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) |