Date: Sun, 11 Aug 2002 23:34:24 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Maxim Konovalov <maxim@FreeBSD.ORG> Cc: Gavin Atkinson <gavin@ury.york.ac.uk>, <current@FreeBSD.ORG>, <rwatson@FreeBSD.ORG> Subject: Re: sendfile(2) is broken (Was: ftpd problem: Input/output error) Message-ID: <20020811232049.B20418-100000@gamplex.bde.org> In-Reply-To: <20020811140826.J68457-100000@news1.macomnet.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020811232049.B20418-100000>