|
@@ -853,8 +853,8 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count,
|
|
|
- loff_t max)
|
|
|
+static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
|
|
|
+ size_t count, loff_t max)
|
|
|
{
|
|
|
struct fd in, out;
|
|
|
struct inode *in_inode, *out_inode;
|
|
@@ -978,3 +978,43 @@ 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 CONFIG_COMPAT
|
|
|
+COMPAT_SYSCALL_DEFINE4(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);
|
|
|
+}
|
|
|
+
|
|
|
+COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
|
|
|
+ compat_loff_t __user *, offset, compat_size_t, count)
|
|
|
+{
|
|
|
+ loff_t pos;
|
|
|
+ ssize_t ret;
|
|
|
+
|
|
|
+ if (offset) {
|
|
|
+ if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
|
|
|
+ return -EFAULT;
|
|
|
+ ret = do_sendfile(out_fd, in_fd, &pos, count, 0);
|
|
|
+ if (unlikely(put_user(pos, offset)))
|
|
|
+ return -EFAULT;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ return do_sendfile(out_fd, in_fd, NULL, count, 0);
|
|
|
+}
|
|
|
+#endif
|