diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-24 02:17:03 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-03 22:58:46 -0500 |
commit | 19f4fc3aee180000fe45952691bbe69dde1d9e95 (patch) | |
tree | 195578ae347797f6aeb66f237aeea7e0eae9847c /fs/read_write.c | |
parent | 7d197ed4a68e76000070979563051e08bf6fc0aa (diff) |
convert sendfile{,64} to COMPAT_SYSCALL_DEFINE
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index dcfd58d95f44..f738e4dccfab 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -853,8 +853,8 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec, | |||
853 | return ret; | 853 | return ret; |
854 | } | 854 | } |
855 | 855 | ||
856 | ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count, | 856 | static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, |
857 | loff_t max) | 857 | size_t count, loff_t max) |
858 | { | 858 | { |
859 | struct fd in, out; | 859 | struct fd in, out; |
860 | struct inode *in_inode, *out_inode; | 860 | struct inode *in_inode, *out_inode; |
@@ -978,3 +978,43 @@ SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset, si | |||
978 | 978 | ||
979 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | 979 | return do_sendfile(out_fd, in_fd, NULL, count, 0); |
980 | } | 980 | } |
981 | |||
982 | #ifdef CONFIG_COMPAT | ||
983 | COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd, | ||
984 | compat_off_t __user *, offset, compat_size_t, count) | ||
985 | { | ||
986 | loff_t pos; | ||
987 | off_t off; | ||
988 | ssize_t ret; | ||
989 | |||
990 | if (offset) { | ||
991 | if (unlikely(get_user(off, offset))) | ||
992 | return -EFAULT; | ||
993 | pos = off; | ||
994 | ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS); | ||
995 | if (unlikely(put_user(pos, offset))) | ||
996 | return -EFAULT; | ||
997 | return ret; | ||
998 | } | ||
999 | |||
1000 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | ||
1001 | } | ||
1002 | |||
1003 | COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, | ||
1004 | compat_loff_t __user *, offset, compat_size_t, count) | ||
1005 | { | ||
1006 | loff_t pos; | ||
1007 | ssize_t ret; | ||
1008 | |||
1009 | if (offset) { | ||
1010 | if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t)))) | ||
1011 | return -EFAULT; | ||
1012 | ret = do_sendfile(out_fd, in_fd, &pos, count, 0); | ||
1013 | if (unlikely(put_user(pos, offset))) | ||
1014 | return -EFAULT; | ||
1015 | return ret; | ||
1016 | } | ||
1017 | |||
1018 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | ||
1019 | } | ||
1020 | #endif | ||