diff options
author | 1996-03-03 17:19:36 +0000 | |
---|---|---|
committer | 1996-03-03 17:19:36 +0000 | |
commit | 5ac46f4a009be3bdcce4d951fbd0eed1cac71377 (patch) | |
tree | 1ebbc69319978d4a58e8f853e4ee407742c40cbd /sys/kern/kern_sysctl.c | |
parent | From NetBSD: Use const qualifier with conversion, args and clist tables (diff) | |
download | wireguard-openbsd-5ac46f4a009be3bdcce4d951fbd0eed1cac71377.tar.xz wireguard-openbsd-5ac46f4a009be3bdcce4d951fbd0eed1cac71377.zip |
From NetBSD: 960217 merge
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7849091829c..79a2fc09975 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,5 @@ -/* $NetBSD: kern_sysctl.c,v 1.12 1995/10/07 06:28:27 mycroft Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.2 1996/03/03 17:19:56 niklas Exp $ */ +/* $NetBSD: kern_sysctl.c,v 1.14 1996/02/09 18:59:52 christos Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -60,16 +61,6 @@ #include <sys/mount.h> #include <sys/syscallargs.h> -sysctlfn kern_sysctl; -sysctlfn hw_sysctl; -#ifdef DEBUG -sysctlfn debug_sysctl; -#endif -extern sysctlfn vm_sysctl; -extern sysctlfn fs_sysctl; -extern sysctlfn net_sysctl; -extern sysctlfn cpu_sysctl; - /* * Locking and stats */ @@ -94,7 +85,7 @@ sys___sysctl(p, v, retval) syscallarg(size_t) newlen; } */ *uap = v; int error, dolock = 1; - size_t savelen, oldlen = 0; + size_t savelen = 0, oldlen = 0; sysctlfn *fn; int name[CTL_MAXNAME]; @@ -106,8 +97,9 @@ sys___sysctl(p, v, retval) */ if (SCARG(uap, namelen) > CTL_MAXNAME || SCARG(uap, namelen) < 2) return (EINVAL); - if (error = - copyin(SCARG(uap, name), &name, SCARG(uap, namelen) * sizeof(int))) + error = copyin(SCARG(uap, name), &name, + SCARG(uap, namelen) * sizeof(int)); + if (error) return (error); switch (name[0]) { @@ -162,7 +154,7 @@ sys___sysctl(p, v, retval) &oldlen, SCARG(uap, new), SCARG(uap, newlen), p); if (SCARG(uap, old) != NULL) { if (dolock) - vsunlock(SCARG(uap, old), savelen, B_WRITE); + vsunlock(SCARG(uap, old), savelen); memlock.sl_lock = 0; if (memlock.sl_want) { memlock.sl_want = 0; @@ -194,6 +186,7 @@ int securelevel; /* * kernel related system variables. */ +int kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) int *name; u_int namelen; @@ -294,6 +287,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) /* * hardware related system variables. */ +int hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) int *name; u_int namelen; @@ -379,6 +373,7 @@ debug_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) * Validate parameters and get old / set new parameters * for an integer-valued sysctl function. */ +int sysctl_int(oldp, oldlenp, newp, newlen, valp) void *oldp; size_t *oldlenp; @@ -403,6 +398,7 @@ sysctl_int(oldp, oldlenp, newp, newlen, valp) /* * As above, but read-only. */ +int sysctl_rdint(oldp, oldlenp, newp, val) void *oldp; size_t *oldlenp; @@ -425,6 +421,7 @@ sysctl_rdint(oldp, oldlenp, newp, val) * Validate parameters and get old / set new parameters * for a string-valued sysctl function. */ +int sysctl_string(oldp, oldlenp, newp, newlen, str, maxlen) void *oldp; size_t *oldlenp; @@ -454,6 +451,7 @@ sysctl_string(oldp, oldlenp, newp, newlen, str, maxlen) /* * As above, but read-only. */ +int sysctl_rdstring(oldp, oldlenp, newp, str) void *oldp; size_t *oldlenp; @@ -477,6 +475,7 @@ sysctl_rdstring(oldp, oldlenp, newp, str) * Validate parameters and get old / set new parameters * for a structure oriented sysctl function. */ +int sysctl_struct(oldp, oldlenp, newp, newlen, sp, len) void *oldp; size_t *oldlenp; @@ -504,6 +503,7 @@ sysctl_struct(oldp, oldlenp, newp, newlen, sp, len) * Validate parameters and get old parameters * for a structure oriented sysctl function. */ +int sysctl_rdstruct(oldp, oldlenp, newp, sp, len) void *oldp; size_t *oldlenp; @@ -525,6 +525,7 @@ sysctl_rdstruct(oldp, oldlenp, newp, sp, len) /* * Get file structures. */ +int sysctl_file(where, sizep) char *where; size_t *sizep; @@ -549,7 +550,8 @@ sysctl_file(where, sizep) *sizep = 0; return (0); } - if (error = copyout((caddr_t)&filehead, where, sizeof(filehead))) + error = copyout((caddr_t)&filehead, where, sizeof(filehead)); + if (error) return (error); buflen -= sizeof(filehead); where += sizeof(filehead); @@ -562,7 +564,8 @@ sysctl_file(where, sizep) *sizep = where - start; return (ENOMEM); } - if (error = copyout((caddr_t)fp, where, sizeof (struct file))) + error = copyout((caddr_t)fp, where, sizeof (struct file)); + if (error) return (error); buflen -= sizeof(struct file); where += sizeof(struct file); @@ -576,6 +579,7 @@ sysctl_file(where, sizep) */ #define KERN_PROCSLOP (5 * sizeof (struct kinfo_proc)) +int sysctl_doproc(name, namelen, where, sizep) int *name; u_int namelen; @@ -638,11 +642,13 @@ again: } if (buflen >= sizeof(struct kinfo_proc)) { fill_eproc(p, &eproc); - if (error = copyout((caddr_t)p, &dp->kp_proc, - sizeof(struct proc))) + error = copyout((caddr_t)p, &dp->kp_proc, + sizeof(struct proc)); + if (error) return (error); - if (error = copyout((caddr_t)&eproc, &dp->kp_eproc, - sizeof(eproc))) + error = copyout((caddr_t)&eproc, &dp->kp_eproc, + sizeof(eproc)); + if (error) return (error); dp++; buflen -= sizeof(struct kinfo_proc); |