sysctl.h revision 1542
1119418Sobrien/*
2119418Sobrien * Copyright (c) 1989, 1993
393746Sjulian *	The Regents of the University of California.  All rights reserved.
493746Sjulian *
593746Sjulian * This code is derived from software contributed to Berkeley by
693746Sjulian * Mike Karels at Berkeley Software Design, Inc.
793746Sjulian *
893746Sjulian * Redistribution and use in source and binary forms, with or without
993746Sjulian * modification, are permitted provided that the following conditions
1093746Sjulian * are met:
1193746Sjulian * 1. Redistributions of source code must retain the above copyright
1293746Sjulian *    notice, this list of conditions and the following disclaimer.
1393746Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1493746Sjulian *    notice, this list of conditions and the following disclaimer in the
1593746Sjulian *    documentation and/or other materials provided with the distribution.
1693746Sjulian * 3. All advertising materials mentioning features or use of this software
1793746Sjulian *    must display the following acknowledgement:
1893746Sjulian *	This product includes software developed by the University of
1993746Sjulian *	California, Berkeley and its contributors.
2093746Sjulian * 4. Neither the name of the University nor the names of its contributors
2193746Sjulian *    may be used to endorse or promote products derived from this software
2293746Sjulian *    without specific prior written permission.
2393746Sjulian *
2493746Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2593746Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2693746Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27119418Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2893746Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29113038Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30113038Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31113038Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32113038Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3393746Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3493746Sjulian * SUCH DAMAGE.
3593746Sjulian *
3693746Sjulian *	@(#)sysctl.h	8.1 (Berkeley) 6/2/93
3793746Sjulian */
3893746Sjulian
3993746Sjulian#ifndef _SYS_SYSCTL_H_
4093746Sjulian#define	_SYS_SYSCTL_H_
4193746Sjulian
4293746Sjulian/*
4393746Sjulian * These are for the eproc structure defined below.
4495807Sjulian */
4595807Sjulian#ifndef KERNEL
4693746Sjulian#include <sys/time.h>
4793746Sjulian#include <sys/ucred.h>
4893746Sjulian#include <sys/proc.h>
4993746Sjulian#include <vm/vm.h>
5093746Sjulian#endif
5193746Sjulian
5293746Sjulian/*
53147256Sbrooks * Definitions for sysctl call.  The sysctl call uses a hierarchical name
5493746Sjulian * for objects that can be examined or modified.  The name is expressed as
5593746Sjulian * a sequence of integers.  Like a file path name, the meaning of each
5693746Sjulian * component depends on its place in the hierarchy.  The top-level and kern
5793746Sjulian * identifiers are defined here, and other identifiers are defined in the
5893746Sjulian * respective subsystem header files.
5993746Sjulian */
6093746Sjulian
6193746Sjulian#define CTL_MAXNAME	12	/* largest number of components supported */
6293746Sjulian
6393746Sjulian/*
64119285Simp * Each subsystem defined by sysctl defines a list of variables
65119285Simp * for that subsystem. Each name is either a node with further
6693746Sjulian * levels defined below it, or it is a leaf of some particular
6793746Sjulian * type given below. Each sysctl level defines a set of name/type
6893746Sjulian * pairs to be used by sysctl(1) in manipulating the subsystem.
6993746Sjulian */
7093746Sjulianstruct ctlname {
7193746Sjulian	char	*ctl_name;	/* subsystem name */
7293746Sjulian	int	ctl_type;	/* type of name */
73153084Sru};
7494904Sjulian#define	CTLTYPE_NODE	1	/* name is a node */
7594904Sjulian#define	CTLTYPE_INT	2	/* name describes an integer */
7693746Sjulian#define	CTLTYPE_STRING	3	/* name describes a string */
7794904Sjulian#define	CTLTYPE_QUAD	4	/* name describes a 64-bit number */
7894904Sjulian#define	CTLTYPE_STRUCT	5	/* name describes a structure */
7993746Sjulian
8093746Sjulian/*
8193746Sjulian * Top-level identifiers
8293746Sjulian */
8393746Sjulian#define	CTL_UNSPEC	0		/* unused */
8493746Sjulian#define	CTL_KERN	1		/* "high kernel": proc, limits */
8593746Sjulian#define	CTL_VM		2		/* virtual memory */
86119285Simp#define	CTL_FS		3		/* file system, mount type is next */
8793746Sjulian#define	CTL_NET		4		/* network, see socket.h */
8893746Sjulian#define	CTL_DEBUG	5		/* debugging parameters */
8993746Sjulian#define	CTL_HW		6		/* generic cpu/io */
9093746Sjulian#define	CTL_MACHDEP	7		/* machine dependent */
9193746Sjulian#define	CTL_USER	8		/* user-level */
9293746Sjulian#define	CTL_MAXID	9		/* number of valid top-level ids */
9393746Sjulian
9493746Sjulian#define CTL_NAMES { \
9593746Sjulian	{ 0, 0 }, \
9693746Sjulian	{ "kern", CTLTYPE_NODE }, \
9793746Sjulian	{ "vm", CTLTYPE_NODE }, \
9893746Sjulian	{ "fs", CTLTYPE_NODE }, \
9993746Sjulian	{ "net", CTLTYPE_NODE }, \
10093746Sjulian	{ "debug", CTLTYPE_NODE }, \
10193746Sjulian	{ "hw", CTLTYPE_NODE }, \
10293746Sjulian	{ "machdep", CTLTYPE_NODE }, \
10393746Sjulian	{ "user", CTLTYPE_NODE }, \
10493746Sjulian}
10593746Sjulian
10693746Sjulian/*
10793746Sjulian * CTL_KERN identifiers
10893746Sjulian */
10993746Sjulian#define	KERN_OSTYPE	 	 1	/* string: system version */
11093746Sjulian#define	KERN_OSRELEASE	 	 2	/* string: system release */
11193746Sjulian#define	KERN_OSREV	 	 3	/* int: system revision */
11293746Sjulian#define	KERN_VERSION	 	 4	/* string: compile time info */
11393746Sjulian#define	KERN_MAXVNODES	 	 5	/* int: max vnodes */
11493746Sjulian#define	KERN_MAXPROC	 	 6	/* int: max processes */
11593746Sjulian#define	KERN_MAXFILES	 	 7	/* int: max open files */
11693746Sjulian#define	KERN_ARGMAX	 	 8	/* int: max arguments to exec */
11793746Sjulian#define	KERN_SECURELVL	 	 9	/* int: system security level */
11893746Sjulian#define	KERN_HOSTNAME		10	/* string: hostname */
11993746Sjulian#define	KERN_HOSTID		11	/* int: host identifier */
12093746Sjulian#define	KERN_CLOCKRATE		12	/* struct: struct clockrate */
12193746Sjulian#define	KERN_VNODE		13	/* struct: vnode structures */
12293746Sjulian#define	KERN_PROC		14	/* struct: process entries */
12393746Sjulian#define	KERN_FILE		15	/* struct: file entries */
124149151Sjhb#define	KERN_PROF		16	/* node: kernel profiling info */
12593746Sjulian#define	KERN_POSIX1		17	/* int: POSIX.1 version */
12693746Sjulian#define	KERN_NGROUPS		18	/* int: # of supplemental group ids */
127149151Sjhb#define	KERN_JOB_CONTROL	19	/* int: is job control available */
12893746Sjulian#define	KERN_SAVED_IDS		20	/* int: saved set-user/group-ID */
12993746Sjulian#define	KERN_BOOTTIME		21	/* struct: time kernel was booted */
130188172Simp#define	KERN_MAXID		22	/* number of valid kern ids */
13193746Sjulian
13293746Sjulian#define CTL_KERN_NAMES { \
13393746Sjulian	{ 0, 0 }, \
13493746Sjulian	{ "ostype", CTLTYPE_STRING }, \
13593746Sjulian	{ "osrelease", CTLTYPE_STRING }, \
13693746Sjulian	{ "osrevision", CTLTYPE_INT }, \
13793746Sjulian	{ "version", CTLTYPE_STRING }, \
13893746Sjulian	{ "maxvnodes", CTLTYPE_INT }, \
13993746Sjulian	{ "maxproc", CTLTYPE_INT }, \
14093746Sjulian	{ "maxfiles", CTLTYPE_INT }, \
14193746Sjulian	{ "argmax", CTLTYPE_INT }, \
14293746Sjulian	{ "securelevel", CTLTYPE_INT }, \
14393746Sjulian	{ "hostname", CTLTYPE_STRING }, \
14493746Sjulian	{ "hostid", CTLTYPE_INT }, \
14593746Sjulian	{ "clockrate", CTLTYPE_STRUCT }, \
146106696Salfred	{ "vnode", CTLTYPE_STRUCT }, \
147106696Salfred	{ "proc", CTLTYPE_STRUCT }, \
14893746Sjulian	{ "file", CTLTYPE_STRUCT }, \
14993746Sjulian	{ "profiling", CTLTYPE_NODE }, \
15093746Sjulian	{ "posix1version", CTLTYPE_INT }, \
15193746Sjulian	{ "ngroups", CTLTYPE_INT }, \
15293746Sjulian	{ "job_control", CTLTYPE_INT }, \
15393746Sjulian	{ "saved_ids", CTLTYPE_INT }, \
15493746Sjulian	{ "boottime", CTLTYPE_STRUCT }, \
15593746Sjulian}
15693746Sjulian
15793746Sjulian/*
15893746Sjulian * KERN_PROC subtypes
15993746Sjulian */
16093746Sjulian#define KERN_PROC_ALL		0	/* everything */
16193746Sjulian#define	KERN_PROC_PID		1	/* by process id */
16293746Sjulian#define	KERN_PROC_PGRP		2	/* by process group id */
16393746Sjulian#define	KERN_PROC_SESSION	3	/* by session of pid */
16493746Sjulian#define	KERN_PROC_TTY		4	/* by controlling tty */
16593746Sjulian#define	KERN_PROC_UID		5	/* by effective uid */
16693746Sjulian#define	KERN_PROC_RUID		6	/* by real uid */
167113506Smdodd
168113506Smdodd/*
169113506Smdodd * KERN_PROC subtype ops return arrays of augmented proc structures:
17093746Sjulian */
17193746Sjulianstruct kinfo_proc {
17293746Sjulian	struct	proc kp_proc;			/* proc structure */
17393746Sjulian	struct	eproc {
17493746Sjulian		struct	proc *e_paddr;		/* address of proc */
17593746Sjulian		struct	session *e_sess;	/* session pointer */
17693746Sjulian		struct	pcred e_pcred;		/* process credentials */
17793746Sjulian		struct	ucred e_ucred;		/* current credentials */
178149151Sjhb#ifdef sparc
17993746Sjulian		struct {
18093746Sjulian			segsz_t	vm_rssize;	/* resident set size */
18193746Sjulian			segsz_t	vm_tsize;	/* text size */
18293746Sjulian			segsz_t	vm_dsize;	/* data size */
18393746Sjulian			segsz_t	vm_ssize;	/* stack size */
18493746Sjulian		} e_vm;
18593746Sjulian#else
18693746Sjulian		struct	vmspace e_vm;		/* address space */
18793746Sjulian#endif
18893746Sjulian		pid_t	e_ppid;			/* parent process id */
18993746Sjulian		pid_t	e_pgid;			/* process group id */
19093746Sjulian		short	e_jobc;			/* job control counter */
19193746Sjulian		dev_t	e_tdev;			/* controlling tty dev */
19293746Sjulian		pid_t	e_tpgid;		/* tty process group id */
19393746Sjulian		struct	session *e_tsess;	/* tty session pointer */
19493746Sjulian#define	WMESGLEN	7
19593746Sjulian		char	e_wmesg[WMESGLEN+1];	/* wchan message */
19693746Sjulian		segsz_t e_xsize;		/* text size */
19793746Sjulian		short	e_xrssize;		/* text rss */
19893746Sjulian		short	e_xccount;		/* text references */
19993746Sjulian		short	e_xswrss;
20093746Sjulian		long	e_flag;
20193746Sjulian#define	EPROC_CTTY	0x01	/* controlling tty vnode active */
20293746Sjulian#define	EPROC_SLEADER	0x02	/* session leader */
20393746Sjulian		char	e_login[MAXLOGNAME];	/* setlogin() name */
20493746Sjulian		long	e_spare[4];
20593746Sjulian	} kp_eproc;
20693746Sjulian};
20793746Sjulian
20893746Sjulian/*
20993746Sjulian * CTL_HW identifiers
21093746Sjulian */
21193746Sjulian#define	HW_MACHINE	 1		/* string: machine class */
21293746Sjulian#define	HW_MODEL	 2		/* string: specific machine model */
21393746Sjulian#define	HW_NCPU		 3		/* int: number of cpus */
21493746Sjulian#define	HW_BYTEORDER	 4		/* int: machine byte order */
21593746Sjulian#define	HW_PHYSMEM	 5		/* int: total memory */
21693746Sjulian#define	HW_USERMEM	 6		/* int: non-kernel memory */
21793746Sjulian#define	HW_PAGESIZE	 7		/* int: software page size */
21893746Sjulian#define	HW_DISKNAMES	 8		/* strings: disk drive names */
21993746Sjulian#define	HW_DISKSTATS	 9		/* struct: diskstats[] */
22093746Sjulian#define	HW_MAXID	10		/* number of valid hw ids */
22193746Sjulian
22293746Sjulian#define CTL_HW_NAMES { \
22393746Sjulian	{ 0, 0 }, \
224148945Sjhb	{ "machine", CTLTYPE_STRING }, \
22593746Sjulian	{ "model", CTLTYPE_STRING }, \
22693746Sjulian	{ "ncpu", CTLTYPE_INT }, \
22793746Sjulian	{ "byteorder", CTLTYPE_INT }, \
22893746Sjulian	{ "physmem", CTLTYPE_INT }, \
22993746Sjulian	{ "usermem", CTLTYPE_INT }, \
230149151Sjhb	{ "pagesize", CTLTYPE_INT }, \
23193746Sjulian	{ "disknames", CTLTYPE_STRUCT }, \
23293746Sjulian	{ "diskstats", CTLTYPE_STRUCT }, \
23393746Sjulian}
23493746Sjulian
23593746Sjulian/*
23693746Sjulian * CTL_USER definitions
23793746Sjulian */
23893746Sjulian#define	USER_CS_PATH		 1	/* string: _CS_PATH */
23993746Sjulian#define	USER_BC_BASE_MAX	 2	/* int: BC_BASE_MAX */
24093746Sjulian#define	USER_BC_DIM_MAX		 3	/* int: BC_DIM_MAX */
24193746Sjulian#define	USER_BC_SCALE_MAX	 4	/* int: BC_SCALE_MAX */
24293746Sjulian#define	USER_BC_STRING_MAX	 5	/* int: BC_STRING_MAX */
24393746Sjulian#define	USER_COLL_WEIGHTS_MAX	 6	/* int: COLL_WEIGHTS_MAX */
24493746Sjulian#define	USER_EXPR_NEST_MAX	 7	/* int: EXPR_NEST_MAX */
24593746Sjulian#define	USER_LINE_MAX		 8	/* int: LINE_MAX */
24693746Sjulian#define	USER_RE_DUP_MAX		 9	/* int: RE_DUP_MAX */
24793746Sjulian#define	USER_POSIX2_VERSION	10	/* int: POSIX2_VERSION */
24893746Sjulian#define	USER_POSIX2_C_BIND	11	/* int: POSIX2_C_BIND */
24993746Sjulian#define	USER_POSIX2_C_DEV	12	/* int: POSIX2_C_DEV */
25093746Sjulian#define	USER_POSIX2_CHAR_TERM	13	/* int: POSIX2_CHAR_TERM */
25193746Sjulian#define	USER_POSIX2_FORT_DEV	14	/* int: POSIX2_FORT_DEV */
25293746Sjulian#define	USER_POSIX2_FORT_RUN	15	/* int: POSIX2_FORT_RUN */
25393746Sjulian#define	USER_POSIX2_LOCALEDEF	16	/* int: POSIX2_LOCALEDEF */
25493746Sjulian#define	USER_POSIX2_SW_DEV	17	/* int: POSIX2_SW_DEV */
25593746Sjulian#define	USER_POSIX2_UPE		18	/* int: POSIX2_UPE */
25693746Sjulian#define	USER_STREAM_MAX		19	/* int: POSIX2_STREAM_MAX */
25793746Sjulian#define	USER_TZNAME_MAX		20	/* int: POSIX2_TZNAME_MAX */
25893746Sjulian#define	USER_MAXID		21	/* number of valid user ids */
25993746Sjulian
26093746Sjulian#define	CTL_USER_NAMES { \
26193746Sjulian	{ 0, 0 }, \
26293746Sjulian	{ "cs_path", CTLTYPE_STRING }, \
26393746Sjulian	{ "bc_base_max", CTLTYPE_INT }, \
26493746Sjulian	{ "bc_dim_max", CTLTYPE_INT }, \
26593746Sjulian	{ "bc_scale_max", CTLTYPE_INT }, \
26693746Sjulian	{ "bc_string_max", CTLTYPE_INT }, \
26793746Sjulian	{ "coll_weights_max", CTLTYPE_INT }, \
26893746Sjulian	{ "expr_nest_max", CTLTYPE_INT }, \
26993746Sjulian	{ "line_max", CTLTYPE_INT }, \
27093746Sjulian	{ "re_dup_max", CTLTYPE_INT }, \
27193746Sjulian	{ "posix2_version", CTLTYPE_INT }, \
27293746Sjulian	{ "posix2_c_bind", CTLTYPE_INT }, \
27393746Sjulian	{ "posix2_c_dev", CTLTYPE_INT }, \
274149151Sjhb	{ "posix2_char_term", CTLTYPE_INT }, \
27593746Sjulian	{ "posix2_fort_dev", CTLTYPE_INT }, \
27693746Sjulian	{ "posix2_fort_run", CTLTYPE_INT }, \
27793746Sjulian	{ "posix2_localedef", CTLTYPE_INT }, \
27893746Sjulian	{ "posix2_sw_dev", CTLTYPE_INT }, \
27993746Sjulian	{ "posix2_upe", CTLTYPE_INT }, \
28093746Sjulian	{ "stream_max", CTLTYPE_INT }, \
28193746Sjulian	{ "tzname_max", CTLTYPE_INT }, \
28293746Sjulian}
28393746Sjulian
28493746Sjulian/*
28593746Sjulian * CTL_DEBUG definitions
28693746Sjulian *
28793746Sjulian * Second level identifier specifies which debug variable.
28893746Sjulian * Third level identifier specifies which stucture component.
28993746Sjulian */
29093746Sjulian#define	CTL_DEBUG_NAME		0	/* string: variable name */
29193746Sjulian#define	CTL_DEBUG_VALUE		1	/* int: variable value */
29293746Sjulian#define	CTL_DEBUG_MAXID		20
29393746Sjulian
29493746Sjulian#ifdef	KERNEL
29593746Sjulian#ifdef	DEBUG
29693746Sjulian/*
29793746Sjulian * CTL_DEBUG variables.
29893746Sjulian *
29993746Sjulian * These are declared as separate variables so that they can be
30093746Sjulian * individually initialized at the location of their associated
30193746Sjulian * variable. The loader prevents multiple use by issuing errors
30293746Sjulian * if a variable is initialized in more than one place. They are
30393746Sjulian * aggregated into an array in debug_sysctl(), so that it can
30493746Sjulian * conveniently locate them when querried. If more debugging
30593746Sjulian * variables are added, they must also be declared here and also
30693746Sjulian * entered into the array.
30793746Sjulian */
30893746Sjulianstruct ctldebug {
30993746Sjulian	char	*debugname;	/* name of debugging variable */
31093746Sjulian	int	*debugvar;	/* pointer to debugging variable */
31193746Sjulian};
31293746Sjulianextern struct ctldebug debug0, debug1, debug2, debug3, debug4;
31393746Sjulianextern struct ctldebug debug5, debug6, debug7, debug8, debug9;
31493746Sjulianextern struct ctldebug debug10, debug11, debug12, debug13, debug14;
31593746Sjulianextern struct ctldebug debug15, debug16, debug17, debug18, debug19;
31693746Sjulian#endif	/* DEBUG */
31793746Sjulian
31893746Sjulian/*
31993746Sjulian * Internal sysctl function calling convention:
32093746Sjulian *
321149151Sjhb *	(*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
32293746Sjulian *
323147256Sbrooks * The name parameter points at the next component of the name to be
32493746Sjulian * interpreted.  The namelen parameter is the number of integers in
32593746Sjulian * the name.
32693746Sjulian */
32793746Sjuliantypedef int (sysctlfn)
32893746Sjulian    __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
32993746Sjulian
33093746Sjulianint sysctl_int __P((void *, size_t *, void *, size_t, int *));
33193746Sjulianint sysctl_rdint __P((void *, size_t *, void *, int));
33293746Sjulianint sysctl_string __P((void *, size_t *, void *, size_t, char *, int));
33393746Sjulianint sysctl_rdstring __P((void *, size_t *, void *, char *));
33493746Sjulianint sysctl_rdstruct __P((void *, size_t *, void *, void *, int));
33593746Sjulianvoid fill_eproc __P((struct proc *, struct eproc *));
33693746Sjulian
33793746Sjulian#else	/* !KERNEL */
33893746Sjulian#include <sys/cdefs.h>
33993746Sjulian
340148654Srwatson__BEGIN_DECLS
34193746Sjulianint	sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
34293746Sjulian__END_DECLS
34393746Sjulian#endif	/* KERNEL */
344130270Snaddy#endif	/* !_SYS_SYSCTL_H_ */
345130270Snaddy