| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_sysctl.c,v 1.250 2014/05/16 12:22:32 martin Exp $ */ | | 1 | /* $NetBSD: kern_sysctl.c,v 1.251 2014/06/12 22:10:04 joerg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Brown. | | 8 | * by Andrew Brown. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -58,27 +58,27 @@ | | | @@ -58,27 +58,27 @@ |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
61 | * SUCH DAMAGE. | | 61 | * SUCH DAMAGE. |
62 | * | | 62 | * |
63 | * @(#)kern_sysctl.c 8.9 (Berkeley) 5/20/95 | | 63 | * @(#)kern_sysctl.c 8.9 (Berkeley) 5/20/95 |
64 | */ | | 64 | */ |
65 | | | 65 | |
66 | /* | | 66 | /* |
67 | * sysctl system call. | | 67 | * sysctl system call. |
68 | */ | | 68 | */ |
69 | | | 69 | |
70 | #include <sys/cdefs.h> | | 70 | #include <sys/cdefs.h> |
71 | __KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.250 2014/05/16 12:22:32 martin Exp $"); | | 71 | __KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.251 2014/06/12 22:10:04 joerg Exp $"); |
72 | | | 72 | |
73 | #include "opt_defcorename.h" | | 73 | #include "opt_defcorename.h" |
74 | #include "ksyms.h" | | 74 | #include "ksyms.h" |
75 | | | 75 | |
76 | #include <sys/param.h> | | 76 | #include <sys/param.h> |
77 | #define __COMPAT_SYSCTL | | 77 | #define __COMPAT_SYSCTL |
78 | #include <sys/sysctl.h> | | 78 | #include <sys/sysctl.h> |
79 | #include <sys/systm.h> | | 79 | #include <sys/systm.h> |
80 | #include <sys/buf.h> | | 80 | #include <sys/buf.h> |
81 | #include <sys/ksyms.h> | | 81 | #include <sys/ksyms.h> |
82 | #include <sys/malloc.h> | | 82 | #include <sys/malloc.h> |
83 | #include <sys/mount.h> | | 83 | #include <sys/mount.h> |
84 | #include <sys/syscallargs.h> | | 84 | #include <sys/syscallargs.h> |
| @@ -288,57 +288,57 @@ sys___sysctl(struct lwp *l, const struct | | | @@ -288,57 +288,57 @@ sys___sysctl(struct lwp *l, const struct |
288 | /* | | 288 | /* |
289 | * top-level sysctl names may or may not be non-terminal, but | | 289 | * top-level sysctl names may or may not be non-terminal, but |
290 | * we don't care | | 290 | * we don't care |
291 | */ | | 291 | */ |
292 | if (SCARG(uap, namelen) > CTL_MAXNAME || SCARG(uap, namelen) < 1) | | 292 | if (SCARG(uap, namelen) > CTL_MAXNAME || SCARG(uap, namelen) < 1) |
293 | return (EINVAL); | | 293 | return (EINVAL); |
294 | error = copyin(SCARG(uap, name), &name, | | 294 | error = copyin(SCARG(uap, name), &name, |
295 | SCARG(uap, namelen) * sizeof(int)); | | 295 | SCARG(uap, namelen) * sizeof(int)); |
296 | if (error) | | 296 | if (error) |
297 | return (error); | | 297 | return (error); |
298 | | | 298 | |
299 | ktrmib(name, SCARG(uap, namelen)); | | 299 | ktrmib(name, SCARG(uap, namelen)); |
300 | | | 300 | |
301 | sysctl_lock(SCARG(uap, new) != NULL); | | 301 | sysctl_lock(SCARG(uap, newv) != NULL); |
302 | | | 302 | |
303 | /* | | 303 | /* |
304 | * do sysctl work (NULL means main built-in default tree) | | 304 | * do sysctl work (NULL means main built-in default tree) |
305 | */ | | 305 | */ |
306 | error = sysctl_dispatch(&name[0], SCARG(uap, namelen), | | 306 | error = sysctl_dispatch(&name[0], SCARG(uap, namelen), |
307 | SCARG(uap, old), &oldlen, | | 307 | SCARG(uap, oldv), &oldlen, |
308 | SCARG(uap, new), SCARG(uap, newlen), | | 308 | SCARG(uap, newv), SCARG(uap, newlen), |
309 | &name[0], l, NULL); | | 309 | &name[0], l, NULL); |
310 | | | 310 | |
311 | /* | | 311 | /* |
312 | * release the sysctl lock | | 312 | * release the sysctl lock |
313 | */ | | 313 | */ |
314 | sysctl_unlock(); | | 314 | sysctl_unlock(); |
315 | | | 315 | |
316 | /* | | 316 | /* |
317 | * set caller's oldlen to new value even in the face of an | | 317 | * set caller's oldlen to new value even in the face of an |
318 | * error (if this gets an error and they didn't have one, they | | 318 | * error (if this gets an error and they didn't have one, they |
319 | * get this one) | | 319 | * get this one) |
320 | */ | | 320 | */ |
321 | if (oldlenp) { | | 321 | if (oldlenp) { |
322 | nerror = copyout(&oldlen, oldlenp, sizeof(oldlen)); | | 322 | nerror = copyout(&oldlen, oldlenp, sizeof(oldlen)); |
323 | if (error == 0) | | 323 | if (error == 0) |
324 | error = nerror; | | 324 | error = nerror; |
325 | } | | 325 | } |
326 | | | 326 | |
327 | /* | | 327 | /* |
328 | * if the only problem is that we weren't given enough space, | | 328 | * if the only problem is that we weren't given enough space, |
329 | * that's an ENOMEM error | | 329 | * that's an ENOMEM error |
330 | */ | | 330 | */ |
331 | if (error == 0 && SCARG(uap, old) != NULL && savelen < oldlen) | | 331 | if (error == 0 && SCARG(uap, oldv) != NULL && savelen < oldlen) |
332 | error = ENOMEM; | | 332 | error = ENOMEM; |
333 | | | 333 | |
334 | return (error); | | 334 | return (error); |
335 | } | | 335 | } |
336 | | | 336 | |
337 | /* | | 337 | /* |
338 | * ******************************************************************** | | 338 | * ******************************************************************** |
339 | * Section 1: How the tree is used | | 339 | * Section 1: How the tree is used |
340 | * ******************************************************************** | | 340 | * ******************************************************************** |
341 | * Implementations of sysctl for emulations should typically need only | | 341 | * Implementations of sysctl for emulations should typically need only |
342 | * these three functions in this order: lock the tree, dispatch | | 342 | * these three functions in this order: lock the tree, dispatch |
343 | * request into it, unlock the tree. | | 343 | * request into it, unlock the tree. |
344 | * ******************************************************************** | | 344 | * ******************************************************************** |