mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
compat: fs: Generic compat_sys_sendfile implementation
This function is used by sparc, powerpc and arm64 for compat support. The patch adds a generic implementation which calls do_sendfile() directly and avoids set_fs(). The sparc architecture has wrappers for the sign extensions while powerpc relies on the compiler to do the this. The patch adds wrappers for powerpc to handle the u32->int type conversion. compat_sys_sendfile64() can be replaced by a sys_sendfile() call since compat_loff_t has the same size as off_t on a 64-bit system. On powerpc, the patch also changes the 64-bit sendfile call from sys_sendile64 to sys_sendfile. Signed-off-by: Catalin Marinas <[email protected]> Acked-by: David S. Miller <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
8c0a853770
commit
8f9c0119d7
10 changed files with 41 additions and 89 deletions
22
fs/compat.c
22
fs/compat.c
|
|
@ -1792,3 +1792,25 @@ compat_sys_open_by_handle_at(int mountdirfd,
|
|||
return do_handle_open(mountdirfd, handle, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __ARCH_WANT_COMPAT_SYS_SENDFILE
|
||||
asmlinkage long 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 */
|
||||
|
|
|
|||
|
|
@ -862,8 +862,8 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
|
||||
size_t count, loff_t max)
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -12,3 +12,5 @@ ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
|
|||
unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn);
|
||||
ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov,
|
||||
unsigned long nr_segs, loff_t *ppos, io_fn_t fn);
|
||||
ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count,
|
||||
loff_t max);
|
||||
|
|
|
|||
Loading…
Reference in a new issue