diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/compat.c | 22 | ||||
-rw-r--r-- | fs/read_write.c | 44 | ||||
-rw-r--r-- | fs/read_write.h | 2 |
3 files changed, 42 insertions, 26 deletions
diff --git a/fs/compat.c b/fs/compat.c index cc09312f9aed..2ae2a98891cd 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1718,25 +1718,3 @@ COMPAT_SYSCALL_DEFINE3(open_by_handle_at, int, mountdirfd, | |||
1718 | return do_handle_open(mountdirfd, handle, flags); | 1718 | return do_handle_open(mountdirfd, handle, flags); |
1719 | } | 1719 | } |
1720 | #endif | 1720 | #endif |
1721 | |||
1722 | #ifdef __ARCH_WANT_COMPAT_SYS_SENDFILE | ||
1723 | asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, | ||
1724 | compat_off_t __user *offset, compat_size_t count) | ||
1725 | { | ||
1726 | loff_t pos; | ||
1727 | off_t off; | ||
1728 | ssize_t ret; | ||
1729 | |||
1730 | if (offset) { | ||
1731 | if (unlikely(get_user(off, offset))) | ||
1732 | return -EFAULT; | ||
1733 | pos = off; | ||
1734 | ret = do_sendfile(out_fd, in_fd, &pos, count, MAX_NON_LFS); | ||
1735 | if (unlikely(put_user(pos, offset))) | ||
1736 | return -EFAULT; | ||
1737 | return ret; | ||
1738 | } | ||
1739 | |||
1740 | return do_sendfile(out_fd, in_fd, NULL, count, 0); | ||
1741 | } | ||
1742 | #endif /* __ARCH_WANT_COMPAT_SYS_SENDFILE */ | ||
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 | ||
diff --git a/fs/read_write.h b/fs/read_write.h index d3e00ef67420..d07b954c6e0c 100644 --- a/fs/read_write.h +++ b/fs/read_write.h | |||
@@ -12,5 +12,3 @@ ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, | |||
12 | unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn); | 12 | unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn); |
13 | ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, | 13 | ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov, |
14 | unsigned long nr_segs, loff_t *ppos, io_fn_t fn); | 14 | unsigned long nr_segs, loff_t *ppos, io_fn_t fn); |
15 | ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count, | ||
16 | loff_t max); | ||