summaryrefslogtreecommitdiff
path: root/sys/kern/subr_pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/subr_pool.c')
-rw-r--r--sys/kern/subr_pool.c57
1 files changed, 21 insertions, 36 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index 40f0968d5f8..cca9d0fcba8 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.140 2014/08/11 13:31:42 dlg Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.141 2014/08/12 00:59:27 dlg Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -1423,57 +1423,40 @@ pool_walk(struct pool *pp, int full,
* kern.pool.name.<pool#> - the name for pool#.
*/
int
-sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep)
+sysctl_dopool(int *name, u_int namelen, char *oldp, size_t *oldlenp)
{
struct kinfo_pool pi;
struct pool *pp;
- size_t buflen = where != NULL ? *sizep : 0;
- int npools = 0, s;
- unsigned int lookfor;
- size_t len;
+ int rv;
+ int s;
- switch (*name) {
+ switch (name[0]) {
case KERN_POOL_NPOOLS:
- if (namelen != 1 || buflen != sizeof(int))
- return (EINVAL);
- lookfor = 0;
- break;
+ if (namelen != 1)
+ return (ENOTDIR);
+ return (sysctl_rdint(oldp, oldlenp, NULL, pool_count));
+
case KERN_POOL_NAME:
- if (namelen != 2 || buflen < 1)
- return (EINVAL);
- lookfor = name[1];
- break;
case KERN_POOL_POOL:
- if (namelen != 2 || buflen != sizeof(pi))
- return (EINVAL);
- lookfor = name[1];
break;
default:
return (EINVAL);
}
+ if (namelen != 2)
+ return (ENOTDIR);
+
s = splvm();
SIMPLEQ_FOREACH(pp, &pool_head, pr_poollist) {
- npools++;
- if (lookfor == pp->pr_serial)
+ if (name[1] == pp->pr_serial)
break;
}
- splx(s);
-
- if (*name != KERN_POOL_NPOOLS && pp == NULL)
- return (ENOENT);
-
- switch (*name) {
- case KERN_POOL_NPOOLS:
- return copyout(&npools, where, buflen);
+ switch (name[0]) {
case KERN_POOL_NAME:
- len = strlen(pp->pr_wchan) + 1;
- if (*sizep < len)
- return (ENOMEM);
- *sizep = len;
- return copyout(pp->pr_wchan, where, len);
+ rv = sysctl_rdstring(oldp, oldlenp, NULL, pp->pr_wchan);
+ break;
case KERN_POOL_POOL:
memset(&pi, 0, sizeof(pi));
@@ -1495,10 +1478,12 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep)
pi.pr_nidle = pp->pr_nidle;
mtx_leave(&pp->pr_mtx);
- return copyout(&pi, where, buflen);
+ rv = sysctl_rdstruct(oldp, oldlenp, NULL, &pi, sizeof(pi));
}
- /* NOTREACHED */
- return (0); /* XXX - Stupid gcc */
+
+ splx(s);
+
+ return (rv);
}
/*