Previously a read of zero bytes got handled in devfs:vop_read() but I

missed that when the vnode bypass was introduced.

Deal with zero length transfers before we even get to fo_ops->fo_read().

Found by:	Slawa Olhovchenkov <slwzxy.spb.ru@zxy.spb.ru>
PR:	75758
This commit is contained in:
Poul-Henning Kamp 2005-01-25 09:15:32 +00:00
parent 8924340f2f
commit 4f8d23d662
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140800

View file

@ -167,6 +167,11 @@ dofileread(td, fp, fd, buf, nbyte, offset, flags)
struct uio *ktruio = NULL;
#endif
/* Finish zero length reads right here */
if (nbyte == 0) {
td->td_retval[0] = 0;
return(0);
}
aiov.iov_base = buf;
aiov.iov_len = nbyte;
auio.uio_iov = &aiov;
@ -232,6 +237,13 @@ readv(struct thread *td, struct readv_args *uap)
fdrop(fp, td);
return (error);
}
/* Finish zero length reads right here */
if (auio->uio_resid == 0) {
td->td_retval[0] = 0;
free(auio, M_IOV);
fdrop(fp, td);
return(0);
}
auio->uio_rw = UIO_READ;
auio->uio_td = td;
#ifdef KTRACE