1 /* $OpenBSD: db_usrreq.c,v 1.8 2003/06/28 01:52:18 tedu Exp $ */ 2 3 /* 4 * Copyright (c) 1996 Michael Shalayeff. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #include <sys/param.h> 28 #include <sys/types.h> 29 #include <sys/kernel.h> 30 #include <sys/proc.h> 31 #include <uvm/uvm_extern.h> 32 #include <sys/sysctl.h> 33 34 #include <ddb/db_var.h> 35 36 int db_log; 37 38 int 39 ddb_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) 40 int *name; 41 u_int namelen; 42 void *oldp; 43 size_t *oldlenp; 44 void *newp; 45 size_t newlen; 46 struct proc *p; 47 { 48 int error, ctlval; 49 50 /* All sysctl names at this level are terminal. */ 51 if (namelen != 1) 52 return (ENOTDIR); 53 54 switch (name[0]) { 55 56 case DBCTL_RADIX: 57 return sysctl_int(oldp, oldlenp, newp, newlen, &db_radix); 58 case DBCTL_MAXWIDTH: 59 return sysctl_int(oldp, oldlenp, newp, newlen, &db_max_width); 60 case DBCTL_TABSTOP: 61 return sysctl_int(oldp, oldlenp, newp, newlen, &db_tab_stop_width); 62 case DBCTL_MAXLINE: 63 return sysctl_int(oldp, oldlenp, newp, newlen, &db_max_line); 64 case DBCTL_PANIC: 65 ctlval = db_panic; 66 if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &ctlval)) || 67 newp == NULL) 68 return (error); 69 if (ctlval != 1 && ctlval != 0) 70 return (EINVAL); 71 if (ctlval > db_panic && securelevel > 1) 72 return (EPERM); 73 db_panic = ctlval; 74 return (0); 75 case DBCTL_CONSOLE: 76 ctlval = db_console; 77 if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &ctlval)) || 78 newp == NULL) 79 return (error); 80 if (ctlval != 1 && ctlval != 0) 81 return (EINVAL); 82 if (ctlval > db_console && securelevel > 1) 83 return (EPERM); 84 db_console = ctlval; 85 return (0); 86 case DBCTL_LOG: 87 return (sysctl_int(oldp, oldlenp, newp, newlen, &db_log)); 88 default: 89 return (EOPNOTSUPP); 90 } 91 /* NOTREACHED */ 92 } 93