Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm allow SWAP_GETDUMPDEV for all users.
details: https://anonhg.NetBSD.org/src/rev/873dcb241e7e
branches: trunk
changeset: 516881:873dcb241e7e
user: chs <chs%NetBSD.org@localhost>
date: Thu Nov 01 03:49:30 2001 +0000
description:
allow SWAP_GETDUMPDEV for all users.
use {LIST,TAILQ}_FOREACH where appropriate.
diffstat:
sys/uvm/uvm_swap.c | 50 +++++++++++++++++++++-----------------------------
1 files changed, 21 insertions(+), 29 deletions(-)
diffs (134 lines):
diff -r c56b33b4ee36 -r 873dcb241e7e sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c Thu Nov 01 03:00:51 2001 +0000
+++ b/sys/uvm/uvm_swap.c Thu Nov 01 03:49:30 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_swap.c,v 1.54 2001/09/15 20:36:47 chs Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.55 2001/11/01 03:49:30 chs Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -313,8 +313,8 @@
/*
* find entry at or after which to insert the new device.
*/
- for (pspp = NULL, spp = LIST_FIRST(&swap_priority); spp != NULL;
- spp = LIST_NEXT(spp, spi_swappri)) {
+ pspp = NULL;
+ LIST_FOREACH(spp, &swap_priority, spi_swappri) {
if (priority <= spp->spi_priority)
break;
pspp = spp;
@@ -367,11 +367,9 @@
/*
* search the lists for the requested vp
*/
- for (spp = LIST_FIRST(&swap_priority); spp != NULL;
- spp = LIST_NEXT(spp, spi_swappri)) {
- for (sdp = CIRCLEQ_FIRST(&spp->spi_swapdev);
- sdp != (void *)&spp->spi_swapdev;
- sdp = CIRCLEQ_NEXT(sdp, swd_next))
+
+ LIST_FOREACH(spp, &swap_priority, spi_swappri) {
+ CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
if (sdp->swd_vp == vp) {
if (remove) {
CIRCLEQ_REMOVE(&spp->spi_swapdev,
@@ -380,6 +378,7 @@
}
return(sdp);
}
+ }
}
return (NULL);
}
@@ -420,11 +419,8 @@
struct swapdev *sdp;
struct swappri *spp;
- for (spp = LIST_FIRST(&swap_priority); spp != NULL;
- spp = LIST_NEXT(spp, spi_swappri))
- for (sdp = CIRCLEQ_FIRST(&spp->spi_swapdev);
- sdp != (void *)&spp->spi_swapdev;
- sdp = CIRCLEQ_NEXT(sdp, swd_next)) {
+ LIST_FOREACH(spp, &swap_priority, spi_swappri) {
+ CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
if (sdp->swd_flags & SWF_FAKE)
continue;
if (pgno >= sdp->swd_drumoffset &&
@@ -432,6 +428,7 @@
return sdp;
}
}
+ }
return NULL;
}
@@ -499,8 +496,7 @@
sep = (struct swapent *)SCARG(uap, arg);
count = 0;
- for (spp = LIST_FIRST(&swap_priority); spp != NULL;
- spp = LIST_NEXT(spp, spi_swappri)) {
+ LIST_FOREACH(spp, &swap_priority, spi_swappri) {
for (sdp = CIRCLEQ_FIRST(&spp->spi_swapdev);
sdp != (void *)&spp->spi_swapdev && misc-- > 0;
sdp = CIRCLEQ_NEXT(sdp, swd_next)) {
@@ -546,6 +542,12 @@
error = 0;
goto out;
}
+ if (SCARG(uap, cmd) == SWAP_GETDUMPDEV) {
+ dev_t *devp = (dev_t *)SCARG(uap, arg);
+
+ error = copyout(&dumpdev, devp, sizeof(dumpdev));
+ goto out;
+ }
/*
* all other requests require superuser privs. verify.
@@ -553,13 +555,6 @@
if ((error = suser(p->p_ucred, &p->p_acflag)))
goto out;
- if (SCARG(uap, cmd) == SWAP_GETDUMPDEV) {
- dev_t *devp = (dev_t *)SCARG(uap, arg);
-
- error = copyout(&dumpdev, devp, sizeof(dumpdev));
- goto out;
- }
-
/*
* at this point we expect a path name in arg. we will
* use namei() to gain a vnode reference (vref), and lock
@@ -1439,11 +1434,8 @@
simple_lock(&uvm.swap_data_lock);
ReTry: /* XXXMRG */
- for (spp = LIST_FIRST(&swap_priority); spp != NULL;
- spp = LIST_NEXT(spp, spi_swappri)) {
- for (sdp = CIRCLEQ_FIRST(&spp->spi_swapdev);
- sdp != (void *)&spp->spi_swapdev;
- sdp = CIRCLEQ_NEXT(sdp,swd_next)) {
+ LIST_FOREACH(spp, &swap_priority, spi_swappri) {
+ CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
/* if it's not enabled, then we can't swap from it */
if ((sdp->swd_flags & SWF_ENABLE) == 0)
continue;
@@ -1467,7 +1459,7 @@
UVMHIST_LOG(pdhist,
"success! returning %d slots starting at %d",
*nslots, result + sdp->swd_drumoffset, 0, 0);
- return(result + sdp->swd_drumoffset);
+ return (result + sdp->swd_drumoffset);
}
}
@@ -1479,7 +1471,7 @@
/* XXXMRG: END HACK */
simple_unlock(&uvm.swap_data_lock);
- return 0; /* failed */
+ return 0;
}
/*
Home |
Main Index |
Thread Index |
Old Index