aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce M Simpson <bms@FreeBSD.org>2003-10-05 05:38:30 +0000
committerBruce M Simpson <bms@FreeBSD.org>2003-10-05 05:38:30 +0000
commit5be99846fcd30bd1eedccb045f90511dd4c430f2 (patch)
tree3a787c9dad91309eb4eecbabf9d5ed06c34b815e
parent45503a37dd97a5ab468885a9be1188c15579dee8 (diff)
Notes
-rw-r--r--sys/kern/kern_sysctl.c17
-rw-r--r--sys/sys/sysctl.h7
2 files changed, 15 insertions, 9 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 9195e4363695..3c62d40ff290 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -970,13 +970,13 @@ kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
req.oldfunc = sysctl_old_kernel;
req.newfunc = sysctl_new_kernel;
- req.lock = 1;
+ req.lock = REQ_LOCKED;
SYSCTL_LOCK();
error = sysctl_root(0, name, namelen, &req);
- if (req.lock == 2)
+ if (req.lock == REQ_WIRED)
vsunlock(req.oldptr, req.oldlen);
SYSCTL_UNLOCK();
@@ -1024,7 +1024,7 @@ sysctl_old_user(struct sysctl_req *req, const void *p, size_t l)
int error = 0;
size_t i = 0;
- if (req->lock == 1 && req->oldptr)
+ if (req->lock == REQ_LOCKED && req->oldptr)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"sysctl_old_user()");
if (req->oldptr) {
@@ -1071,9 +1071,10 @@ sysctl_new_user(struct sysctl_req *req, void *p, size_t l)
void
sysctl_wire_old_buffer(struct sysctl_req *req, size_t len)
{
- if (req->lock == 1 && req->oldptr && req->oldfunc == sysctl_old_user) {
+ if (req->lock == REQ_LOCKED && req->oldptr &&
+ req->oldfunc == sysctl_old_user) {
vslock(req->oldptr, req->oldlen);
- req->lock = 2;
+ req->lock = REQ_WIRED;
}
}
@@ -1090,7 +1091,7 @@ sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
if (oid->oid_number == name[indx]) {
indx++;
if (oid->oid_kind & CTLFLAG_NOLOCK)
- req->lock = 0;
+ req->lock = REQ_UNLOCKED;
if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
if (oid->oid_handler != NULL ||
indx == namelen) {
@@ -1264,7 +1265,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
req.oldfunc = sysctl_old_user;
req.newfunc = sysctl_new_user;
- req.lock = 1;
+ req.lock = REQ_LOCKED;
SYSCTL_LOCK();
@@ -1283,7 +1284,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
} while (error == EAGAIN);
req = req2;
- if (req.lock == 2)
+ if (req.lock == REQ_WIRED)
vsunlock(req.oldptr, req.oldlen);
SYSCTL_UNLOCK();
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index e2c6c4925ec2..b570b8c3b451 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -117,13 +117,18 @@ struct ctlname {
#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \
struct sysctl_req *req
+/* definitions for sysctl_req 'lock' member */
+#define REQ_UNLOCKED 0 /* not locked and not wired */
+#define REQ_LOCKED 1 /* locked and not wired */
+#define REQ_WIRED 2 /* locked and wired */
+
/*
* This describes the access space for a sysctl request. This is needed
* so that we can use the interface from the kernel or from user-space.
*/
struct sysctl_req {
struct thread *td; /* used for access checking */
- int lock;
+ int lock; /* locking/wiring state */
void *oldptr;
size_t oldlen;
size_t oldidx;