[PATCH] sys_sendfile fix

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Thu, 30 Jul 1998 20:35:52 +0200 (MET DST)


To get sendfile working on sparc64 under 32bit emulation, I need to
call sys_sendfile already with set_fs(KERNEL_DS), but sendfile then comes
back into USER_DS. Can you apply the following simple patch?
It is done in the way as it is done in most places in the kernel. If
you don't accept it, we'd have to copy the whole sys_sendfile code into
sys_sparc32.c and edit it there, and duplicating of code is usually bad.
Below the patch is code which depends on this patch.


--- mm/filemap.c.jj Tue Jul 28 10:24:17 1998
+++ mm/filemap.c Tue Jul 28 14:22:05 1998
@@ -859,15 +859,13 @@
unsigned long count = desc->count;
struct file *file = (struct file *) desc->buf;
struct inode *inode = file->f_dentry->d_inode;
- mm_segment_t old_fs;

if (size > count)
size = count;
- old_fs = get_fs();
written = file->f_op->write(file, area, size, &file->f_pos);
- set_fs(old_fs);
+ set_fs(USER_DS);
if (written < 0) {
desc->error = written;

asmlinkage int sys32_sendfile(int out_fd, int in_fd, u32 offset, s32 count)
mm_segment_t old_fs = get_fs();
int ret;
off_t of;

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

ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);

if (!ret && offset && put_user(of, (__kernel_off_t32 *)A(offset)))
return -EFAULT;

return ret;

Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
Ultralinux - first 64bit OS to take full power of the UltraSparc
Linux version 2.1.112 on a sparc64 machine (498.80 BogoMips).

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html