On Sun, 11 Aug 2002, Maxim Konovalov wrote: > This is sendfile(2) mis-behaviour arised after rev.1.109 > sys/kern/uipc_syscalls.c but I think the real problem in vn_rdwr(), > sys/kern/vfs_vnops.c. Here is my patch but I really need somebody with > vfs clue. I CC'ed Robert Watson as an author of sendfile(2) > modification and our vfs expert. > > Index: sys/kern/vfs_vnops.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/vfs_vnops.c,v > retrieving revision 1.159 > diff -u -r1.159 vfs_vnops.c > --- sys/kern/vfs_vnops.c 8 Aug 2002 12:45:30 -0000 1.159 > +++ sys/kern/vfs_vnops.c 11 Aug 2002 10:19:47 -0000 > @@ -401,7 +401,7 @@ > if (aresid) > *aresid = auio.uio_resid; > else > - if (auio.uio_resid && error == 0) > + if (auio.uio_resid && error != 0) > error = EIO; > if ((ioflg & IO_NODELOCKED) == 0) { > if (rw == UIO_WRITE) > > %%% > > With this patch sendfile(2) and ftpd(8) work as expected but I cannot > believe vn_rdwr() has been broken since 1994.
I think the caller (do_sendfile() here?) is at fault for not passing a non-NULL aresid. The EIO case is basically a kludge to handle short i/o's. Since the caller hasn't passed a place to return the (residual) i/o count, it can't even tell if a short i/o occurred, so we pretend that short i/o's are i/o errors. There are a lot of sloppy callers that pass a null aresid. But these are less broken than link_aout_load_file() and link_elf_load_file which pass a non-null one and then never check it. Bruce To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message