kern_sysctl.c (14499) | kern_sysctl.c (15103) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Karels at Berkeley Software Design, Inc. 7 * 8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD --- 23 unchanged lines hidden (view full) --- 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 | 1/*- 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Karels at Berkeley Software Design, Inc. 7 * 8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD --- 23 unchanged lines hidden (view full) --- 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 |
40 * $Id: kern_sysctl.c,v 1.60 1996/02/25 07:03:59 hsu Exp $ | 40 * $Id: kern_sysctl.c,v 1.60 1996/03/11 02:18:22 hsu Exp $ |
41 */ 42 43#include <sys/param.h> | 41 */ 42 43#include <sys/param.h> |
44#include <sys/systm.h> 45#include <sys/sysproto.h> | |
46#include <sys/kernel.h> | 44#include <sys/kernel.h> |
47#include <sys/vnode.h> 48#include <sys/unistd.h> 49#include <sys/conf.h> | |
50#include <sys/sysctl.h> 51#include <sys/malloc.h> 52#include <sys/proc.h> | 45#include <sys/sysctl.h> 46#include <sys/malloc.h> 47#include <sys/proc.h> |
53 | 48#include <sys/systm.h> 49#include <sys/sysproto.h> |
54#include <vm/vm.h> | 50#include <vm/vm.h> |
55#include <vm/vm_param.h> | |
56#include <vm/vm_extern.h> | 51#include <vm/vm_extern.h> |
52#include <sys/vnode.h> |
|
57 58/* 59 * Locking and stats 60 */ 61static struct sysctl_lock { 62 int sl_lock; 63 int sl_want; 64 int sl_locked; 65} memlock; 66 67static int sysctl_root SYSCTL_HANDLER_ARGS; 68 69extern struct linker_set sysctl_; 70 71/* | 53 54/* 55 * Locking and stats 56 */ 57static struct sysctl_lock { 58 int sl_lock; 59 int sl_want; 60 int sl_locked; 61} memlock; 62 63static int sysctl_root SYSCTL_HANDLER_ARGS; 64 65extern struct linker_set sysctl_; 66 67/* |
72 * MIB definitions. XXX Very few of these, if any, belong here. 73 */ 74SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0, 75 "Sysctl internal magic"); 76SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, 77 "High kernel, proc, limits &c"); 78SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, 79 "Virtual memory"); 80SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, 81 "File system"); 82SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, 83 "Network, (see socket.h)"); 84SYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW, 0, 85 "Debugging"); 86SYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW, 0, 87 "hardware"); 88SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0, 89 "machine dependent"); 90SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0, 91 "user-level"); 92 93SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD, osrelease, 0, ""); 94 95SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD, 0, BSD, ""); 96 97SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD, version, 0, ""); 98 99SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD, ostype, 0, ""); 100 101extern int osreldate; 102SYSCTL_INT(_kern, KERN_OSRELDATE, osreldate, CTLFLAG_RD, &osreldate, 0, ""); 103 104SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RD, &maxproc, 0, ""); 105 106SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, 107 CTLFLAG_RD, &maxprocperuid, 0, ""); 108 109SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD, 0, ARG_MAX, ""); 110 111SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD, 0, _POSIX_VERSION, ""); 112 113SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RD, 0, NGROUPS_MAX, ""); 114 115SYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD, 0, 1, ""); 116 117#ifdef _POSIX_SAVED_IDS 118SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD, 0, 1, ""); 119#else 120SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD, 0, 0, ""); 121#endif 122 123char kernelname[MAXPATHLEN] = "/kernel"; /* XXX bloat */ 124 125SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, 126 CTLFLAG_RW, kernelname, sizeof kernelname, ""); 127 128SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD, 0, 1, ""); 129 130SYSCTL_INT(_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD, 0, BYTE_ORDER, ""); 131 132SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD, 0, PAGE_SIZE, ""); 133 134char hostname[MAXHOSTNAMELEN]; 135 136SYSCTL_STRING(_kern, KERN_HOSTNAME, hostname, CTLFLAG_RW, 137 hostname, sizeof(hostname), ""); 138 139int securelevel = -1; 140 141static int 142sysctl_kern_securelvl SYSCTL_HANDLER_ARGS 143{ 144 int error, level; 145 146 level = securelevel; 147 error = sysctl_handle_int(oidp, &level, 0, req); 148 if (error || !req->newptr) 149 return (error); 150 if (level < securelevel && req->p->p_pid != 1) 151 return (EPERM); 152 securelevel = level; 153 return (error); 154} 155 156SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel, CTLTYPE_INT|CTLFLAG_RW, 157 0, 0, sysctl_kern_securelvl, "I", ""); 158 159char domainname[MAXHOSTNAMELEN]; 160SYSCTL_STRING(_kern, KERN_DOMAINNAME, domainname, CTLFLAG_RW, 161 &domainname, sizeof(domainname), ""); 162 163long hostid; 164/* Some trouble here, if sizeof (int) != sizeof (long) */ 165SYSCTL_INT(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, ""); 166 167/* 168 * This is really cheating. These actually live in the libc, something 169 * which I'm not quite sure is a good idea anyway, but in order for 170 * getnext and friends to actually work, we define dummies here. 171 */ 172 173SYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RW, "", 0, ""); 174SYSCTL_INT(_user, USER_BC_BASE_MAX, bc_base_max, CTLFLAG_RW, 0, 0, ""); 175SYSCTL_INT(_user, USER_BC_DIM_MAX, bc_dim_max, CTLFLAG_RW, 0, 0, ""); 176SYSCTL_INT(_user, USER_BC_SCALE_MAX, bc_scale_max, CTLFLAG_RW, 0, 0, ""); 177SYSCTL_INT(_user, USER_BC_STRING_MAX, bc_string_max, CTLFLAG_RW, 0, 0, ""); 178SYSCTL_INT(_user, USER_COLL_WEIGHTS_MAX, coll_weights_max, CTLFLAG_RW, 0, 0, ""); 179SYSCTL_INT(_user, USER_EXPR_NEST_MAX, expr_nest_max, CTLFLAG_RW, 0, 0, ""); 180SYSCTL_INT(_user, USER_LINE_MAX, line_max, CTLFLAG_RW, 0, 0, ""); 181SYSCTL_INT(_user, USER_RE_DUP_MAX, re_dup_max, CTLFLAG_RW, 0, 0, ""); 182SYSCTL_INT(_user, USER_POSIX2_VERSION, posix2_version, CTLFLAG_RW, 0, 0, ""); 183SYSCTL_INT(_user, USER_POSIX2_C_BIND, posix2_c_bind, CTLFLAG_RW, 0, 0, ""); 184SYSCTL_INT(_user, USER_POSIX2_C_DEV, posix2_c_dev, CTLFLAG_RW, 0, 0, ""); 185SYSCTL_INT(_user, USER_POSIX2_CHAR_TERM, posix2_char_term, CTLFLAG_RW, 0, 0, ""); 186SYSCTL_INT(_user, USER_POSIX2_FORT_DEV, posix2_fort_dev, CTLFLAG_RW, 0, 0, ""); 187SYSCTL_INT(_user, USER_POSIX2_FORT_RUN, posix2_fort_run, CTLFLAG_RW, 0, 0, ""); 188SYSCTL_INT(_user, USER_POSIX2_LOCALEDEF, posix2_localedef, CTLFLAG_RW, 0, 0, ""); 189SYSCTL_INT(_user, USER_POSIX2_SW_DEV, posix2_sw_dev, CTLFLAG_RW, 0, 0, ""); 190SYSCTL_INT(_user, USER_POSIX2_UPE, posix2_upe, CTLFLAG_RW, 0, 0, ""); 191SYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RW, 0, 0, ""); 192SYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RW, 0, 0, ""); 193 194 195/* 196 * End of MIB definitions. 197 */ 198 199/* | |
200 * Initialization of the MIB tree. 201 * 202 * Order by number in each linker_set. 203 */ 204 205static int 206sysctl_order_cmp(const void *a, const void *b) 207{ --- 730 unchanged lines hidden (view full) --- 938 else 939 *retval = req.oldidx; 940 } 941 return (error); 942} 943 944#ifdef COMPAT_43 945#include <sys/socket.h> | 68 * Initialization of the MIB tree. 69 * 70 * Order by number in each linker_set. 71 */ 72 73static int 74sysctl_order_cmp(const void *a, const void *b) 75{ --- 730 unchanged lines hidden (view full) --- 806 else 807 *retval = req.oldidx; 808 } 809 return (error); 810} 811 812#ifdef COMPAT_43 813#include <sys/socket.h> |
814#include <vm/vm_param.h> 815 |
|
946#define KINFO_PROC (0<<8) 947#define KINFO_RT (1<<8) 948#define KINFO_VNODE (2<<8) 949#define KINFO_FILE (3<<8) 950#define KINFO_METER (4<<8) 951#define KINFO_LOADAVG (5<<8) 952#define KINFO_CLOCKRATE (6<<8) 953 --- 195 unchanged lines hidden --- | 816#define KINFO_PROC (0<<8) 817#define KINFO_RT (1<<8) 818#define KINFO_VNODE (2<<8) 819#define KINFO_FILE (3<<8) 820#define KINFO_METER (4<<8) 821#define KINFO_LOADAVG (5<<8) 822#define KINFO_CLOCKRATE (6<<8) 823 --- 195 unchanged lines hidden --- |