kern_mib.c revision 23382
1101704Smjacob/*- 2139749Simp * Copyright (c) 1982, 1986, 1989, 1993 3147883Sscottl * The Regents of the University of California. All rights reserved. 4147883Sscottl * 5147883Sscottl * This code is derived from software contributed to Berkeley by 6102599Smjacob * Mike Karels at Berkeley Software Design, Inc. 7147883Sscottl * 8147883Sscottl * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD 9102599Smjacob * project, to make these variables more userfriendly. 10147883Sscottl * 11147883Sscottl * Redistribution and use in source and binary forms, with or without 12147883Sscottl * modification, are permitted provided that the following conditions 13147883Sscottl * are met: 14147883Sscottl * 1. Redistributions of source code must retain the above copyright 15147883Sscottl * notice, this list of conditions and the following disclaimer. 16147883Sscottl * 2. Redistributions in binary form must reproduce the above copyright 17147883Sscottl * notice, this list of conditions and the following disclaimer in the 18147883Sscottl * documentation and/or other materials provided with the distribution. 19147883Sscottl * 3. All advertising materials mentioning features or use of this software 20147883Sscottl * must display the following acknowledgement: 21147883Sscottl * This product includes software developed by the University of 22102599Smjacob * California, Berkeley and its contributors. 23147883Sscottl * 4. Neither the name of the University nor the names of its contributors 24147883Sscottl * may be used to endorse or promote products derived from this software 25147883Sscottl * without specific prior written permission. 26147883Sscottl * 27147883Sscottl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28147883Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29147883Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30147883Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31170251Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32154603Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33101704Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34101704Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35101704Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36233425Smarius * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37101704Smjacob * SUCH DAMAGE. 38101704Smjacob * 39101704Smjacob * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 40101704Smjacob * $Id: kern_mib.c,v 1.7 1997/03/03 12:58:19 bde Exp $ 41101704Smjacob */ 42101704Smjacob 43101704Smjacob#include <sys/param.h> 44101704Smjacob#include <sys/kernel.h> 45101704Smjacob#include <sys/systm.h> 46101704Smjacob#include <sys/sysctl.h> 47101704Smjacob#include <sys/proc.h> 48101704Smjacob#include <sys/unistd.h> 49101704Smjacob 50115778SmjacobSYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0, 51115778Smjacob "Sysctl internal magic"); 52115778SmjacobSYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, 53115778Smjacob "High kernel, proc, limits &c"); 54115778SmjacobSYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, 55115778Smjacob "Virtual memory"); 56115778SmjacobSYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, 57115778Smjacob "File system"); 58154603SmjacobSYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, 59154603Smjacob "Network, (see socket.h)"); 60154603SmjacobSYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW, 0, 61154603Smjacob "Debugging"); 62170251SscottlSYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW, 0, 63170251Sscottl "hardware"); 64233425SmariusSYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0, 65233425Smarius "machine dependent"); 66233425SmariusSYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0, 67101704Smjacob "user-level"); 68101704Smjacob 69101704SmjacobSYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD, osrelease, 0, ""); 70101704Smjacob 71101704SmjacobSYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD, 0, BSD, ""); 72101704Smjacob 73101704SmjacobSYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD, version, 0, ""); 74101704Smjacob 75101704SmjacobSYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD, ostype, 0, ""); 76101704Smjacob 77101704Smjacobextern int osreldate; 78101704SmjacobSYSCTL_INT(_kern, KERN_OSRELDATE, osreldate, CTLFLAG_RD, &osreldate, 0, ""); 79101704Smjacob 80101704SmjacobSYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RW, &maxproc, 0, ""); 81101704Smjacob 82154603SmjacobSYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, 83101704Smjacob CTLFLAG_RW, &maxprocperuid, 0, ""); 84101704Smjacob 85101704SmjacobSYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD, 0, ARG_MAX, ""); 86101704Smjacob 87101704SmjacobSYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD, 0, _POSIX_VERSION, ""); 88101704Smjacob 89101704SmjacobSYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RD, 0, NGROUPS_MAX, ""); 90101704Smjacob 91101704SmjacobSYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD, 0, 1, ""); 92101704Smjacob 93101704Smjacob#ifdef _POSIX_SAVED_IDS 94101704SmjacobSYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD, 0, 1, ""); 95101704Smjacob#else 96101704SmjacobSYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD, 0, 0, ""); 97101704Smjacob#endif 98101704Smjacob 99101704Smjacobchar kernelname[MAXPATHLEN] = "/kernel"; /* XXX bloat */ 100101704Smjacob 101101704SmjacobSYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, 102101704Smjacob CTLFLAG_RW, kernelname, sizeof kernelname, ""); 103101704Smjacob 104101704SmjacobSYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD, 0, 1, ""); 105101704Smjacob 106101704SmjacobSYSCTL_INT(_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD, 0, BYTE_ORDER, ""); 107101704Smjacob 108101704SmjacobSYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD, 0, PAGE_SIZE, ""); 109101704Smjacob 110101704Smjacobchar hostname[MAXHOSTNAMELEN]; 111101704Smjacob 112101704SmjacobSYSCTL_STRING(_kern, KERN_HOSTNAME, hostname, CTLFLAG_RW, 113101704Smjacob hostname, sizeof(hostname), ""); 114101704Smjacob 115101704Smjacobint securelevel = -1; 116101704Smjacob 117101704Smjacobstatic int 118101704Smjacobsysctl_kern_securelvl SYSCTL_HANDLER_ARGS 119101704Smjacob{ 120101704Smjacob int error, level; 121115778Smjacob 122115778Smjacob level = securelevel; 123147883Sscottl error = sysctl_handle_int(oidp, &level, 0, req); 124147883Sscottl if (error || !req->newptr) 125170251Sscottl return (error); 126233425Smarius if (level < securelevel && req->p->p_pid != 1) 127101704Smjacob return (EPERM); 128101704Smjacob securelevel = level; 129101704Smjacob return (error); 130115778Smjacob} 131101704Smjacob 132101704SmjacobSYSCTL_PROC(_kern, KERN_SECURELVL, securelevel, CTLTYPE_INT|CTLFLAG_RW, 133101704Smjacob 0, 0, sysctl_kern_securelvl, "I", ""); 134101704Smjacob 135101704Smjacobchar domainname[MAXHOSTNAMELEN]; 136115778SmjacobSYSCTL_STRING(_kern, KERN_NISDOMAINNAME, domainname, CTLFLAG_RW, 137115778Smjacob &domainname, sizeof(domainname), ""); 138101704Smjacob 139233425Smariuslong hostid; 140233425Smarius/* Some trouble here, if sizeof (int) != sizeof (long) */ 141233425SmariusSYSCTL_INT(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, ""); 142115778Smjacob 143115778Smjacob/* 144115778Smjacob * This is really cheating. These actually live in the libc, something 145154603Smjacob * which I'm not quite sure is a good idea anyway, but in order for 146154603Smjacob * getnext and friends to actually work, we define dummies here. 147115778Smjacob */ 148154603SmjacobSYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RD, "", 0, ""); 149154603SmjacobSYSCTL_INT(_user, USER_BC_BASE_MAX, bc_base_max, CTLFLAG_RD, 0, 0, ""); 150154603SmjacobSYSCTL_INT(_user, USER_BC_DIM_MAX, bc_dim_max, CTLFLAG_RD, 0, 0, ""); 151170251SscottlSYSCTL_INT(_user, USER_BC_SCALE_MAX, bc_scale_max, CTLFLAG_RD, 0, 0, ""); 152170251SscottlSYSCTL_INT(_user, USER_BC_STRING_MAX, bc_string_max, CTLFLAG_RD, 0, 0, ""); 153170251SscottlSYSCTL_INT(_user, USER_COLL_WEIGHTS_MAX, coll_weights_max, CTLFLAG_RD, 0, 0, ""); 154170251SscottlSYSCTL_INT(_user, USER_EXPR_NEST_MAX, expr_nest_max, CTLFLAG_RD, 0, 0, ""); 155154603SmjacobSYSCTL_INT(_user, USER_LINE_MAX, line_max, CTLFLAG_RD, 0, 0, ""); 156154603SmjacobSYSCTL_INT(_user, USER_RE_DUP_MAX, re_dup_max, CTLFLAG_RD, 0, 0, ""); 157101704SmjacobSYSCTL_INT(_user, USER_POSIX2_VERSION, posix2_version, CTLFLAG_RD, 0, 0, ""); 158101704SmjacobSYSCTL_INT(_user, USER_POSIX2_C_BIND, posix2_c_bind, CTLFLAG_RD, 0, 0, ""); 159101704SmjacobSYSCTL_INT(_user, USER_POSIX2_C_DEV, posix2_c_dev, CTLFLAG_RD, 0, 0, ""); 160101704SmjacobSYSCTL_INT(_user, USER_POSIX2_CHAR_TERM, posix2_char_term, CTLFLAG_RD, 0, 0, ""); 161101704SmjacobSYSCTL_INT(_user, USER_POSIX2_FORT_DEV, posix2_fort_dev, CTLFLAG_RD, 0, 0, ""); 162101704SmjacobSYSCTL_INT(_user, USER_POSIX2_FORT_RUN, posix2_fort_run, CTLFLAG_RD, 0, 0, ""); 163101704SmjacobSYSCTL_INT(_user, USER_POSIX2_LOCALEDEF, posix2_localedef, CTLFLAG_RD, 0, 0, ""); 164101704SmjacobSYSCTL_INT(_user, USER_POSIX2_SW_DEV, posix2_sw_dev, CTLFLAG_RD, 0, 0, ""); 165101704SmjacobSYSCTL_INT(_user, USER_POSIX2_UPE, posix2_upe, CTLFLAG_RD, 0, 0, ""); 166101704SmjacobSYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RD, 0, 0, ""); 167101704SmjacobSYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD, 0, 0, ""); 168101704Smjacob