diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2012-09-19 07:01:52 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-02 21:35:55 -0400 |
commit | 8f9c0119d7ba94c3ad13876acc240d7f12b6d8e1 (patch) | |
tree | 44d618a21b60c5a268088bfae6c78c591f1e4334 /arch/sparc/kernel | |
parent | 8c0a85377048b64c880e76ec7368904fe46d0b94 (diff) |
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 <catalin.marinas@arm.com>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r-- | arch/sparc/kernel/sys32.S | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc32.c | 46 |
2 files changed, 1 insertions, 47 deletions
diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S index d97f3eb72e0..44025f4ba41 100644 --- a/arch/sparc/kernel/sys32.S +++ b/arch/sparc/kernel/sys32.S | |||
@@ -90,7 +90,7 @@ SIGN1(sys32_mkdir, sys_mkdir, %o1) | |||
90 | SIGN3(sys32_futex, compat_sys_futex, %o1, %o2, %o5) | 90 | SIGN3(sys32_futex, compat_sys_futex, %o1, %o2, %o5) |
91 | SIGN1(sys32_sysfs, compat_sys_sysfs, %o0) | 91 | SIGN1(sys32_sysfs, compat_sys_sysfs, %o0) |
92 | SIGN2(sys32_sendfile, compat_sys_sendfile, %o0, %o1) | 92 | SIGN2(sys32_sendfile, compat_sys_sendfile, %o0, %o1) |
93 | SIGN2(sys32_sendfile64, compat_sys_sendfile64, %o0, %o1) | 93 | SIGN2(sys32_sendfile64, sys_sendfile, %o0, %o1) |
94 | SIGN1(sys32_prctl, sys_prctl, %o0) | 94 | SIGN1(sys32_prctl, sys_prctl, %o0) |
95 | SIGN1(sys32_sched_rr_get_interval, compat_sys_sched_rr_get_interval, %o0) | 95 | SIGN1(sys32_sched_rr_get_interval, compat_sys_sched_rr_get_interval, %o0) |
96 | SIGN2(sys32_waitpid, sys_waitpid, %o0, %o2) | 96 | SIGN2(sys32_waitpid, sys_waitpid, %o0, %o2) |
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c index f7392336961..d862499eb01 100644 --- a/arch/sparc/kernel/sys_sparc32.c +++ b/arch/sparc/kernel/sys_sparc32.c | |||
@@ -506,52 +506,6 @@ long compat_sys_fadvise64_64(int fd, | |||
506 | advice); | 506 | advice); |
507 | } | 507 | } |
508 | 508 | ||
509 | asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, | ||
510 | compat_off_t __user *offset, | ||
511 | compat_size_t count) | ||
512 | { | ||
513 | mm_segment_t old_fs = get_fs(); | ||
514 | int ret; | ||
515 | off_t of; | ||
516 | |||
517 | if (offset && get_user(of, offset)) | ||
518 | return -EFAULT; | ||
519 | |||
520 | set_fs(KERNEL_DS); | ||
521 | ret = sys_sendfile(out_fd, in_fd, | ||
522 | offset ? (off_t __user *) &of : NULL, | ||
523 | count); | ||
524 | set_fs(old_fs); | ||
525 | |||
526 | if (offset && put_user(of, offset)) | ||
527 | return -EFAULT; | ||
528 | |||
529 | return ret; | ||
530 | } | ||
531 | |||
532 | asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd, | ||
533 | compat_loff_t __user *offset, | ||
534 | compat_size_t count) | ||
535 | { | ||
536 | mm_segment_t old_fs = get_fs(); | ||
537 | int ret; | ||
538 | loff_t lof; | ||
539 | |||
540 | if (offset && get_user(lof, offset)) | ||
541 | return -EFAULT; | ||
542 | |||
543 | set_fs(KERNEL_DS); | ||
544 | ret = sys_sendfile64(out_fd, in_fd, | ||
545 | offset ? (loff_t __user *) &lof : NULL, | ||
546 | count); | ||
547 | set_fs(old_fs); | ||
548 | |||
549 | if (offset && put_user(lof, offset)) | ||
550 | return -EFAULT; | ||
551 | |||
552 | return ret; | ||
553 | } | ||
554 | |||
555 | /* This is just a version for 32-bit applications which does | 509 | /* This is just a version for 32-bit applications which does |
556 | * not force O_LARGEFILE on. | 510 | * not force O_LARGEFILE on. |
557 | */ | 511 | */ |