Skip to content

Commit

Permalink
parisc: sendfile and sendfile64 syscall cleanups
Browse files Browse the repository at this point in the history
Utilize the existing compat_sys_sendfile function for 64bit kernel and add
wrappers for sendfile and sendfile64 to correctly handle the 32/64 bit sign
extension.

Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
Helge Deller committed Feb 20, 2013
1 parent e27da28 commit f03d70a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 33 deletions.
1 change: 1 addition & 0 deletions arch/parisc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_COMPAT_SYS_SENDFILE

#endif /* __ASSEMBLY__ */

Expand Down
45 changes: 13 additions & 32 deletions arch/parisc/kernel/sys_parisc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,23 @@ asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,
return -ENOSYS;
}

asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
/* Note: it is necessary to treat out_fd and in_fd as unsigned ints, with the
* corresponding cast to a signed int to insure that the proper conversion
* (sign extension) between the register representation of a signed int (msr in
* 32-bit mode) and the register representation of a signed int (msr in 64-bit
* mode) is performed.
*/
asmlinkage long sys32_sendfile(u32 out_fd, u32 in_fd,
compat_off_t __user *offset, compat_size_t count)
{
mm_segment_t old_fs = get_fs();
int ret;
off_t of;

if (offset && get_user(of, offset))
return -EFAULT;

set_fs(KERNEL_DS);
ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count);
set_fs(old_fs);

if (offset && put_user(of, offset))
return -EFAULT;

return ret;
return compat_sys_sendfile((int)out_fd, (int)in_fd, offset, count);
}

asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
asmlinkage long sys32_sendfile64(u32 out_fd, u32 in_fd,
compat_loff_t __user *offset, compat_size_t count)
{
mm_segment_t old_fs = get_fs();
int ret;
loff_t lof;

if (offset && get_user(lof, offset))
return -EFAULT;

set_fs(KERNEL_DS);
ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count);
set_fs(old_fs);

if (offset && put_user(lof, offset))
return -EFAULT;

return ret;
return sys_sendfile64((int)out_fd, (int)in_fd,
(loff_t __user *)offset, count);
}


Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/syscall_table.S
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
ENTRY_SAME(gettid)
ENTRY_OURS(readahead)
ENTRY_SAME(tkill)
ENTRY_SAME(sendfile64)
ENTRY_DIFF(sendfile64)
ENTRY_COMP(futex) /* 210 */
ENTRY_COMP(sched_setaffinity)
ENTRY_COMP(sched_getaffinity)
Expand Down

0 comments on commit f03d70a

Please sign in to comment.