kern_mib.c revision 197316
115103Sphk/*-
215103Sphk * Copyright (c) 1982, 1986, 1989, 1993
315103Sphk *	The Regents of the University of California.  All rights reserved.
415103Sphk *
515103Sphk * This code is derived from software contributed to Berkeley by
615103Sphk * Mike Karels at Berkeley Software Design, Inc.
715103Sphk *
815103Sphk * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD
915103Sphk * project, to make these variables more userfriendly.
1015103Sphk *
1115103Sphk * Redistribution and use in source and binary forms, with or without
1215103Sphk * modification, are permitted provided that the following conditions
1315103Sphk * are met:
1415103Sphk * 1. Redistributions of source code must retain the above copyright
1515103Sphk *    notice, this list of conditions and the following disclaimer.
1615103Sphk * 2. Redistributions in binary form must reproduce the above copyright
1715103Sphk *    notice, this list of conditions and the following disclaimer in the
1815103Sphk *    documentation and/or other materials provided with the distribution.
1915103Sphk * 4. Neither the name of the University nor the names of its contributors
2015103Sphk *    may be used to endorse or promote products derived from this software
2115103Sphk *    without specific prior written permission.
2215103Sphk *
2315103Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2415103Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2515103Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2615103Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2715103Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2815103Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2915103Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3015103Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3115103Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3215103Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3315103Sphk * SUCH DAMAGE.
3415103Sphk *
3515103Sphk *	@(#)kern_sysctl.c	8.4 (Berkeley) 4/14/94
3615103Sphk */
3715103Sphk
38116182Sobrien#include <sys/cdefs.h>
39116182Sobrien__FBSDID("$FreeBSD: head/sys/kern/kern_mib.c 197316 2009-09-18 17:04:57Z alc $");
40116182Sobrien
41175417Sjhb#include "opt_compat.h"
4286190Srwatson#include "opt_posix.h"
43169604Swkoszek#include "opt_config.h"
4484611Srwatson
4515103Sphk#include <sys/param.h>
4615103Sphk#include <sys/kernel.h>
47169507Swkoszek#include <sys/sbuf.h>
4815103Sphk#include <sys/systm.h>
4915103Sphk#include <sys/sysctl.h>
5015103Sphk#include <sys/proc.h>
5187275Srwatson#include <sys/lock.h>
5287275Srwatson#include <sys/mutex.h>
5346155Sphk#include <sys/jail.h>
5476078Sjhb#include <sys/smp.h>
55192895Sjamie#include <sys/sx.h>
56105046Smike#include <sys/unistd.h>
5728918Skato
5815103SphkSYSCTL_NODE(, 0,	  sysctl, CTLFLAG_RW, 0,
5915103Sphk	"Sysctl internal magic");
6015103SphkSYSCTL_NODE(, CTL_KERN,	  kern,   CTLFLAG_RW, 0,
6115103Sphk	"High kernel, proc, limits &c");
6215103SphkSYSCTL_NODE(, CTL_VM,	  vm,     CTLFLAG_RW, 0,
6315103Sphk	"Virtual memory");
6423382SbdeSYSCTL_NODE(, CTL_VFS,	  vfs,     CTLFLAG_RW, 0,
6515103Sphk	"File system");
6615103SphkSYSCTL_NODE(, CTL_NET,	  net,    CTLFLAG_RW, 0,
6715103Sphk	"Network, (see socket.h)");
6815103SphkSYSCTL_NODE(, CTL_DEBUG,  debug,  CTLFLAG_RW, 0,
6915103Sphk	"Debugging");
7048891SphkSYSCTL_NODE(_debug, OID_AUTO,  sizeof,  CTLFLAG_RW, 0,
7148891Sphk	"Sizeof various things");
7215103SphkSYSCTL_NODE(, CTL_HW,	  hw,     CTLFLAG_RW, 0,
7315103Sphk	"hardware");
7415103SphkSYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0,
7515103Sphk	"machine dependent");
7615103SphkSYSCTL_NODE(, CTL_USER,	  user,   CTLFLAG_RW, 0,
7715103Sphk	"user-level");
7834925SdufaultSYSCTL_NODE(, CTL_P1003_1B,  p1003_1b,   CTLFLAG_RW, 0,
7934925Sdufault	"p1003_1b, (see p1003_1b.h)");
8034029Sdufault
8150465SmarcelSYSCTL_NODE(, OID_AUTO,  compat, CTLFLAG_RW, 0,
8250465Smarcel	"Compatibility code");
8389414SarrSYSCTL_NODE(, OID_AUTO, security, CTLFLAG_RW, 0,
8489414Sarr     	"Security");
8586190Srwatson#ifdef REGRESSION
8686190SrwatsonSYSCTL_NODE(, OID_AUTO, regression, CTLFLAG_RW, 0,
8786190Srwatson     "Regression test MIB");
8886190Srwatson#endif
8950465Smarcel
90187864SedSYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD|CTLFLAG_MPSAFE,
91116105Sjmallett    kern_ident, 0, "Kernel identifier");
92116090Sjmallett
93187864SedSYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD|CTLFLAG_MPSAFE,
9488019Sluigi    osrelease, 0, "Operating system release");
9515103Sphk
9686189SrwatsonSYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD,
9746381Sbillf    0, BSD, "Operating system revision");
9815103Sphk
99187864SedSYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD|CTLFLAG_MPSAFE,
10046381Sbillf    version, 0, "Kernel version");
10115103Sphk
102187864SedSYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE,
10346381Sbillf    ostype, 0, "Operating system type");
10415103Sphk
105119203Seivind/*
106119203Seivind * NOTICE: The *userland* release date is available in
107119203Seivind * /usr/include/osreldate.h
108119203Seivind */
10986189SrwatsonSYSCTL_INT(_kern, KERN_OSRELDATE, osreldate, CTLFLAG_RD,
110119203Seivind    &osreldate, 0, "Kernel release date");
11115103Sphk
112121307SsilbySYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN,
11346381Sbillf    &maxproc, 0, "Maximum number of processes");
11415103Sphk
11586189SrwatsonSYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW,
11646381Sbillf    &maxprocperuid, 0, "Maximum processes allowed per userid");
11715103Sphk
118121307SsilbySYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN,
11980418Speter    &maxusers, 0, "Hint for kernel tuning");
12080418Speter
12186189SrwatsonSYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD,
12246381Sbillf    0, ARG_MAX, "Maximum bytes of argument to execve(2)");
12315103Sphk
12486189SrwatsonSYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD,
125105046Smike    0, _POSIX_VERSION, "Version of POSIX attempting to comply to");
12615103Sphk
12786189SrwatsonSYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RD,
12846381Sbillf    0, NGROUPS_MAX, "Maximum number of groups a user can belong to");
12915103Sphk
13086189SrwatsonSYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD,
13146381Sbillf    0, 1, "Whether job control is available");
13215103Sphk
13315103Sphk#ifdef _POSIX_SAVED_IDS
13486189SrwatsonSYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD,
13546381Sbillf    0, 1, "Whether saved set-group/user ID is available");
13615103Sphk#else
13786189SrwatsonSYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD,
13846381Sbillf    0, 0, "Whether saved set-group/user ID is available");
13915103Sphk#endif
14015103Sphk
14115103Sphkchar kernelname[MAXPATHLEN] = "/kernel";	/* XXX bloat */
14215103Sphk
14386189SrwatsonSYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW,
14446381Sbillf    kernelname, sizeof kernelname, "Name of kernel file booted");
14515103Sphk
14686189SrwatsonSYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD,
14746381Sbillf    &mp_ncpus, 0, "Number of active CPUs");
14815103Sphk
14986189SrwatsonSYSCTL_INT(_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD,
15046381Sbillf    0, BYTE_ORDER, "System byte order");
15115103Sphk
15286189SrwatsonSYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD,
15346381Sbillf    0, PAGE_SIZE, "System memory page size");
15415103Sphk
155106605Stmmstatic int
156169727Skansysctl_kern_arnd(SYSCTL_HANDLER_ARGS)
157169727Skan{
158176367Santoine	char buf[256];
159176367Santoine	size_t len;
160169727Skan
161176367Santoine	len = req->oldlen;
162176367Santoine	if (len > sizeof(buf))
163176367Santoine		len = sizeof(buf);
164176367Santoine	arc4rand(buf, len, 0);
165176367Santoine	return (SYSCTL_OUT(req, buf, len));
166169727Skan}
167169727Skan
168187864SedSYSCTL_PROC(_kern, KERN_ARND, arandom,
169187864Sed    CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
170187864Sed    sysctl_kern_arnd, "", "arc4rand");
171169727Skan
172169727Skanstatic int
173106605Stmmsysctl_hw_physmem(SYSCTL_HANDLER_ARGS)
174106605Stmm{
175106605Stmm	u_long val;
176106605Stmm
177106605Stmm	val = ctob(physmem);
178106605Stmm	return (sysctl_handle_long(oidp, &val, 0, req));
179106605Stmm}
180106605Stmm
181106605StmmSYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_ULONG | CTLFLAG_RD,
182106605Stmm	0, 0, sysctl_hw_physmem, "LU", "");
183106605Stmm
184106605Stmmstatic int
185142834Swessysctl_hw_realmem(SYSCTL_HANDLER_ARGS)
186142834Swes{
187142834Swes	u_long val;
188142834Swes	val = ctob(realmem);
189142834Swes	return (sysctl_handle_long(oidp, &val, 0, req));
190142834Swes}
191142834SwesSYSCTL_PROC(_hw, HW_REALMEM, realmem, CTLTYPE_ULONG | CTLFLAG_RD,
192142834Swes	0, 0, sysctl_hw_realmem, "LU", "");
193142834Swesstatic int
194106605Stmmsysctl_hw_usermem(SYSCTL_HANDLER_ARGS)
195106605Stmm{
196106605Stmm	u_long val;
197106605Stmm
198170170Sattilio	val = ctob(physmem - cnt.v_wire_count);
199106605Stmm	return (sysctl_handle_long(oidp, &val, 0, req));
200106605Stmm}
201106605Stmm
202106605StmmSYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_ULONG | CTLFLAG_RD,
203106605Stmm	0, 0, sysctl_hw_usermem, "LU", "");
204106605Stmm
205106605StmmSYSCTL_ULONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, "");
206106605Stmm
207197316Salcu_long pagesizes[MAXPAGESIZES] = { PAGE_SIZE };
208197316Salc
209197316Salcstatic int
210197316Salcsysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS)
211197316Salc{
212197316Salc	int error;
213197316Salc#ifdef SCTL_MASK32
214197316Salc	int i;
215197316Salc	uint32_t pagesizes32[MAXPAGESIZES];
216197316Salc
217197316Salc	if (req->flags & SCTL_MASK32) {
218197316Salc		/*
219197316Salc		 * Recreate the "pagesizes" array with 32-bit elements.  Truncate
220197316Salc		 * any page size greater than UINT32_MAX to zero.
221197316Salc		 */
222197316Salc		for (i = 0; i < MAXPAGESIZES; i++)
223197316Salc			pagesizes32[i] = (uint32_t)pagesizes[i];
224197316Salc
225197316Salc		error = SYSCTL_OUT(req, pagesizes32, sizeof(pagesizes32));
226197316Salc	} else
227197316Salc#endif
228197316Salc		error = SYSCTL_OUT(req, pagesizes, sizeof(pagesizes));
229197316Salc	return (error);
230197316Salc}
231197316SalcSYSCTL_PROC(_hw, OID_AUTO, pagesizes, CTLTYPE_ULONG | CTLFLAG_RD,
232197316Salc    NULL, 0, sysctl_hw_pagesizes, "LU", "Supported page sizes");
233197316Salc
23428885Skatostatic char	machine_arch[] = MACHINE_ARCH;
23528885SkatoSYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
23646381Sbillf    machine_arch, 0, "System architecture");
23728885Skato
23846155Sphkstatic int
23962573Sphksysctl_hostname(SYSCTL_HANDLER_ARGS)
24046155Sphk{
241193066Sjamie	struct prison *pr, *cpr;
242193066Sjamie	size_t pr_offset;
243193066Sjamie	char tmpname[MAXHOSTNAMELEN];
244193066Sjamie	int descend, error, len;
24515103Sphk
246193066Sjamie	/*
247193066Sjamie	 * This function can set: hostname domainname hostuuid.
248193066Sjamie	 * Keep that in mind when comments say "hostname".
249193066Sjamie	 */
250193066Sjamie	pr_offset = (size_t)arg1;
251193066Sjamie	len = arg2;
252193066Sjamie	KASSERT(len <= sizeof(tmpname),
253193066Sjamie	    ("length %d too long for %s", len, __func__));
254193066Sjamie
25591406Sjhb	pr = req->td->td_ucred->cr_prison;
256193066Sjamie	if (!(pr->pr_allow & PR_ALLOW_SET_HOSTNAME) && req->newptr)
257193066Sjamie		return (EPERM);
258193066Sjamie	/*
259193066Sjamie	 * Make a local copy of hostname to get/set so we don't have to hold
260193066Sjamie	 * the jail mutex during the sysctl copyin/copyout activities.
261193066Sjamie	 */
262193066Sjamie	mtx_lock(&pr->pr_mtx);
263193066Sjamie	bcopy((char *)pr + pr_offset, tmpname, len);
264193066Sjamie	mtx_unlock(&pr->pr_mtx);
265193066Sjamie
266193066Sjamie	error = sysctl_handle_string(oidp, tmpname, len, req);
267193066Sjamie
268193066Sjamie	if (req->newptr != NULL && error == 0) {
26987275Srwatson		/*
270193066Sjamie		 * Copy the locally set hostname to all jails that share
271193066Sjamie		 * this host info.
27287275Srwatson		 */
273193066Sjamie		sx_slock(&allprison_lock);
274193066Sjamie		while (!(pr->pr_flags & PR_HOST))
275193066Sjamie			pr = pr->pr_parent;
27687275Srwatson		mtx_lock(&pr->pr_mtx);
277193066Sjamie		bcopy(tmpname, (char *)pr + pr_offset, len);
278193066Sjamie		FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend)
279193066Sjamie			if (cpr->pr_flags & PR_HOST)
280193066Sjamie				descend = 0;
281193066Sjamie			else
282193066Sjamie				bcopy(tmpname, (char *)cpr + pr_offset, len);
28387275Srwatson		mtx_unlock(&pr->pr_mtx);
284193066Sjamie		sx_sunlock(&allprison_lock);
285180291Srwatson	}
28646155Sphk	return (error);
28746155Sphk}
28846155Sphk
28986189SrwatsonSYSCTL_PROC(_kern, KERN_HOSTNAME, hostname,
290193066Sjamie    CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
291194118Sjamie    (void *)(offsetof(struct prison, pr_hostname)), MAXHOSTNAMELEN,
292193066Sjamie    sysctl_hostname, "A", "Hostname");
293193066SjamieSYSCTL_PROC(_kern, KERN_NISDOMAINNAME, domainname,
294193066Sjamie    CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
295194118Sjamie    (void *)(offsetof(struct prison, pr_domainname)), MAXHOSTNAMELEN,
296193066Sjamie    sysctl_hostname, "A", "Name of the current YP/NIS domain");
297193066SjamieSYSCTL_PROC(_kern, KERN_HOSTUUID, hostuuid,
298193066Sjamie    CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
299194118Sjamie    (void *)(offsetof(struct prison, pr_hostuuid)), HOSTUUIDLEN,
300193066Sjamie    sysctl_hostname, "A", "Host UUID");
30146155Sphk
30286190Srwatsonstatic int	regression_securelevel_nonmonotonic = 0;
30384611Srwatson
30487072Srwatson#ifdef REGRESSION
30584611SrwatsonSYSCTL_INT(_regression, OID_AUTO, securelevel_nonmonotonic, CTLFLAG_RW,
30684611Srwatson    &regression_securelevel_nonmonotonic, 0, "securelevel may be lowered");
30786190Srwatson#endif
30884611Srwatson
30915103Sphkstatic int
31062573Sphksysctl_kern_securelvl(SYSCTL_HANDLER_ARGS)
31115103Sphk{
312192895Sjamie	struct prison *pr, *cpr;
313192895Sjamie	int descend, error, level;
31415103Sphk
31591406Sjhb	pr = req->td->td_ucred->cr_prison;
31686145Srwatson
31786140Srwatson	/*
318192895Sjamie	 * Reading the securelevel is easy, since the current jail's level
319192895Sjamie	 * is known to be at least as secure as any higher levels.  Perform
320192895Sjamie	 * a lockless read since the securelevel is an integer.
32186140Srwatson	 */
322192895Sjamie	level = pr->pr_securelevel;
32386140Srwatson	error = sysctl_handle_int(oidp, &level, 0, req);
32486140Srwatson	if (error || !req->newptr)
32586140Srwatson		return (error);
326192895Sjamie	/* Permit update only if the new securelevel exceeds the old. */
327192895Sjamie	sx_slock(&allprison_lock);
328192895Sjamie	mtx_lock(&pr->pr_mtx);
329192895Sjamie	if (!regression_securelevel_nonmonotonic &&
330192895Sjamie	    level < pr->pr_securelevel) {
331192895Sjamie		mtx_unlock(&pr->pr_mtx);
332192895Sjamie		sx_sunlock(&allprison_lock);
333192895Sjamie		return (EPERM);
334192895Sjamie	}
335192895Sjamie	pr->pr_securelevel = level;
33686140Srwatson	/*
337192895Sjamie	 * Set all child jails to be at least this level, but do not lower
338192895Sjamie	 * them (even if regression_securelevel_nonmonotonic).
33986140Srwatson	 */
340192895Sjamie	FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) {
341192895Sjamie		if (cpr->pr_securelevel < level)
342192895Sjamie			cpr->pr_securelevel = level;
34386140Srwatson	}
344192895Sjamie	mtx_unlock(&pr->pr_mtx);
345192895Sjamie	sx_sunlock(&allprison_lock);
34686140Srwatson	return (error);
34715103Sphk}
34815103Sphk
34983990SrwatsonSYSCTL_PROC(_kern, KERN_SECURELVL, securelevel,
35083990Srwatson    CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, sysctl_kern_securelvl,
35183990Srwatson    "I", "Current secure level");
35261370Srwatson
353169604Swkoszek#ifdef INCLUDE_CONFIG_FILE
354169507Swkoszek/* Actual kernel configuration options. */
355169507Swkoszekextern char kernconfstring[];
356169507Swkoszek
357169507Swkoszekstatic int
358169507Swkoszeksysctl_kern_config(SYSCTL_HANDLER_ARGS)
359169507Swkoszek{
360170071Simp	return (sysctl_handle_string(oidp, kernconfstring,
361170071Simp	    strlen(kernconfstring), req));
362170071Simp}
363169507Swkoszek
364169507SwkoszekSYSCTL_PROC(_kern, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RW,
365169507Swkoszek    0, 0, sysctl_kern_config, "", "Kernel configuration file");
366169650Simp#endif
367169507Swkoszek
368180291Srwatsonstatic int
369193066Sjamiesysctl_hostid(SYSCTL_HANDLER_ARGS)
370180291Srwatson{
371193066Sjamie	struct prison *pr, *cpr;
372193066Sjamie	u_long tmpid;
373193066Sjamie	int descend, error;
374180291Srwatson
375193066Sjamie	/*
376193066Sjamie	 * Like sysctl_hostname, except it operates on a u_long
377193066Sjamie	 * instead of a string, and is used only for hostid.
378193066Sjamie	 */
379193066Sjamie	pr = req->td->td_ucred->cr_prison;
380193066Sjamie	if (!(pr->pr_allow & PR_ALLOW_SET_HOSTNAME) && req->newptr)
381193066Sjamie		return (EPERM);
382193066Sjamie	tmpid = pr->pr_hostid;
383193066Sjamie	error = sysctl_handle_long(oidp, &tmpid, 0, req);
384193066Sjamie
385180291Srwatson	if (req->newptr != NULL && error == 0) {
386193066Sjamie		sx_slock(&allprison_lock);
387193066Sjamie		while (!(pr->pr_flags & PR_HOST))
388193066Sjamie			pr = pr->pr_parent;
389193066Sjamie		mtx_lock(&pr->pr_mtx);
390193066Sjamie		pr->pr_hostid = tmpid;
391193066Sjamie		FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend)
392193066Sjamie			if (cpr->pr_flags & PR_HOST)
393193066Sjamie				descend = 0;
394193066Sjamie			else
395193066Sjamie				cpr->pr_hostid = tmpid;
396193066Sjamie		mtx_unlock(&pr->pr_mtx);
397193066Sjamie		sx_sunlock(&allprison_lock);
398180291Srwatson	}
399180291Srwatson	return (error);
400180291Srwatson}
401180291Srwatson
402193066SjamieSYSCTL_PROC(_kern, KERN_HOSTID, hostid,
403193066Sjamie    CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
404193066Sjamie    NULL, 0, sysctl_hostid, "LU", "Host ID");
405180291Srwatson
406175021SjhbSYSCTL_NODE(_kern, OID_AUTO, features, CTLFLAG_RD, 0, "Kernel Features");
407175021Sjhb
408175417Sjhb#ifdef COMPAT_FREEBSD4
409175417SjhbFEATURE(compat_freebsd4, "Compatible with FreeBSD 4");
410175417Sjhb#endif
411175417Sjhb
412175417Sjhb#ifdef COMPAT_FREEBSD5
413175417SjhbFEATURE(compat_freebsd5, "Compatible with FreeBSD 5");
414175417Sjhb#endif
415175417Sjhb
416175417Sjhb#ifdef COMPAT_FREEBSD6
417175417SjhbFEATURE(compat_freebsd6, "Compatible with FreeBSD 6");
418175417Sjhb#endif
419175417Sjhb
420175417Sjhb#ifdef COMPAT_FREEBSD7
421175417SjhbFEATURE(compat_freebsd7, "Compatible with FreeBSD 7");
422175417Sjhb#endif
423175417Sjhb
42415103Sphk/*
42515103Sphk * This is really cheating.  These actually live in the libc, something
42686189Srwatson * which I'm not quite sure is a good idea anyway, but in order for
42715103Sphk * getnext and friends to actually work, we define dummies here.
42815103Sphk */
42986189SrwatsonSYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RD,
43046381Sbillf    "", 0, "PATH that finds all the standard utilities");
43186189SrwatsonSYSCTL_INT(_user, USER_BC_BASE_MAX, bc_base_max, CTLFLAG_RD,
43246381Sbillf    0, 0, "Max ibase/obase values in bc(1)");
43386189SrwatsonSYSCTL_INT(_user, USER_BC_DIM_MAX, bc_dim_max, CTLFLAG_RD,
43446381Sbillf    0, 0, "Max array size in bc(1)");
43586189SrwatsonSYSCTL_INT(_user, USER_BC_SCALE_MAX, bc_scale_max, CTLFLAG_RD,
43646381Sbillf    0, 0, "Max scale value in bc(1)");
43786189SrwatsonSYSCTL_INT(_user, USER_BC_STRING_MAX, bc_string_max, CTLFLAG_RD,
43846381Sbillf    0, 0, "Max string length in bc(1)");
43986189SrwatsonSYSCTL_INT(_user, USER_COLL_WEIGHTS_MAX, coll_weights_max, CTLFLAG_RD,
44046381Sbillf    0, 0, "Maximum number of weights assigned to an LC_COLLATE locale entry");
44118540SbdeSYSCTL_INT(_user, USER_EXPR_NEST_MAX, expr_nest_max, CTLFLAG_RD, 0, 0, "");
44286189SrwatsonSYSCTL_INT(_user, USER_LINE_MAX, line_max, CTLFLAG_RD,
44346381Sbillf    0, 0, "Max length (bytes) of a text-processing utility's input line");
44486189SrwatsonSYSCTL_INT(_user, USER_RE_DUP_MAX, re_dup_max, CTLFLAG_RD,
44546381Sbillf    0, 0, "Maximum number of repeats of a regexp permitted");
44686189SrwatsonSYSCTL_INT(_user, USER_POSIX2_VERSION, posix2_version, CTLFLAG_RD,
44786189Srwatson    0, 0,
44846381Sbillf    "The version of POSIX 1003.2 with which the system attempts to comply");
44986189SrwatsonSYSCTL_INT(_user, USER_POSIX2_C_BIND, posix2_c_bind, CTLFLAG_RD,
45046381Sbillf    0, 0, "Whether C development supports the C bindings option");
45186189SrwatsonSYSCTL_INT(_user, USER_POSIX2_C_DEV, posix2_c_dev, CTLFLAG_RD,
45246381Sbillf    0, 0, "Whether system supports the C development utilities option");
45386189SrwatsonSYSCTL_INT(_user, USER_POSIX2_CHAR_TERM, posix2_char_term, CTLFLAG_RD,
45446381Sbillf    0, 0, "");
45586189SrwatsonSYSCTL_INT(_user, USER_POSIX2_FORT_DEV, posix2_fort_dev, CTLFLAG_RD,
45646381Sbillf    0, 0, "Whether system supports FORTRAN development utilities");
45786189SrwatsonSYSCTL_INT(_user, USER_POSIX2_FORT_RUN, posix2_fort_run, CTLFLAG_RD,
45846381Sbillf    0, 0, "Whether system supports FORTRAN runtime utilities");
45986189SrwatsonSYSCTL_INT(_user, USER_POSIX2_LOCALEDEF, posix2_localedef, CTLFLAG_RD,
46046381Sbillf    0, 0, "Whether system supports creation of locales");
46186189SrwatsonSYSCTL_INT(_user, USER_POSIX2_SW_DEV, posix2_sw_dev, CTLFLAG_RD,
46246381Sbillf    0, 0, "Whether system supports software development utilities");
46386189SrwatsonSYSCTL_INT(_user, USER_POSIX2_UPE, posix2_upe, CTLFLAG_RD,
46446381Sbillf    0, 0, "Whether system supports the user portability utilities");
46586189SrwatsonSYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RD,
46646381Sbillf    0, 0, "Min Maximum number of streams a process may have open at one time");
46786189SrwatsonSYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD,
46846381Sbillf    0, 0, "Min Maximum number of types supported for timezone names");
46948891Sphk
47048891Sphk#include <sys/vnode.h>
47186189SrwatsonSYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD,
47248891Sphk    0, sizeof(struct vnode), "sizeof(struct vnode)");
47348891Sphk
47486189SrwatsonSYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD,
47548891Sphk    0, sizeof(struct proc), "sizeof(struct proc)");
47648927Sphk
47760041Sphk#include <sys/bio.h>
47858926Sphk#include <sys/buf.h>
47958926SphkSYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD,
48058926Sphk    0, sizeof(struct bio), "sizeof(struct bio)");
48158926SphkSYSCTL_INT(_debug_sizeof, OID_AUTO, buf, CTLFLAG_RD,
48258926Sphk    0, sizeof(struct buf), "sizeof(struct buf)");
48372376Sjake
48472376Sjake#include <sys/user.h>
48572376SjakeSYSCTL_INT(_debug_sizeof, OID_AUTO, kinfo_proc, CTLFLAG_RD,
48672376Sjake    0, sizeof(struct kinfo_proc), "sizeof(struct kinfo_proc)");
487108685Sjake
488108696Sjake/* XXX compatibility, remove for 6.0 */
489108696Sjake#include <sys/imgact.h>
490108696Sjake#include <sys/imgact_elf.h>
491108696SjakeSYSCTL_INT(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW,
492108696Sjake    &__elfN(fallback_brand), sizeof(__elfN(fallback_brand)),
493108696Sjake    "compatibility for kern.fallback_elf_brand");
494