Optimize the case of writing to /dev/zero, and clean up the
surrounding code a bit. Partly suggested by gwr.
This commit is contained in:
parent
f17ca2c65c
commit
46f55019b7
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */
|
||||
/* $NetBSD: mem.c,v 1.32 1997/03/24 21:16:59 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -121,7 +121,7 @@ mmrw(dev, uio, flags)
|
||||
}
|
||||
physlock = 1;
|
||||
}
|
||||
while (uio->uio_resid > 0 && error == 0) {
|
||||
while (uio->uio_resid > 0 && !error) {
|
||||
iov = uio->uio_iov;
|
||||
if (iov->iov_len == 0) {
|
||||
uio->uio_iov++;
|
||||
@ -143,7 +143,7 @@ mmrw(dev, uio, flags)
|
||||
error = uiomove((caddr_t)vmmap + o, c, uio);
|
||||
pmap_remove(pmap_kernel(), (vm_offset_t)vmmap,
|
||||
(vm_offset_t)vmmap + NBPG);
|
||||
continue;
|
||||
break;
|
||||
|
||||
/* minor device 1 is kernel memory */
|
||||
case 1:
|
||||
@ -153,9 +153,9 @@ mmrw(dev, uio, flags)
|
||||
uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
|
||||
return (EFAULT);
|
||||
error = uiomove((caddr_t)v, c, uio);
|
||||
continue;
|
||||
break;
|
||||
|
||||
/* minor device 2 is EOF/RATHOLE */
|
||||
/* minor device 2 is EOF/rathole */
|
||||
case 2:
|
||||
if (uio->uio_rw == UIO_WRITE)
|
||||
uio->uio_resid = 0;
|
||||
@ -164,8 +164,8 @@ mmrw(dev, uio, flags)
|
||||
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
|
||||
case 12:
|
||||
if (uio->uio_rw == UIO_WRITE) {
|
||||
c = iov->iov_len;
|
||||
break;
|
||||
uio->uio_resid = 0;
|
||||
return (0);
|
||||
}
|
||||
if (zeropage == NULL) {
|
||||
zeropage = (caddr_t)
|
||||
@ -174,17 +174,11 @@ mmrw(dev, uio, flags)
|
||||
}
|
||||
c = min(iov->iov_len, CLBYTES);
|
||||
error = uiomove(zeropage, c, uio);
|
||||
continue;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (ENXIO);
|
||||
}
|
||||
if (error)
|
||||
break;
|
||||
iov->iov_base += c;
|
||||
iov->iov_len -= c;
|
||||
uio->uio_offset += c;
|
||||
uio->uio_resid -= c;
|
||||
}
|
||||
if (minor(dev) == 0) {
|
||||
if (physlock > 1)
|
||||
|
Loading…
Reference in New Issue
Block a user