Commit | Line | Data |
---|---|---|
6d2cb789 | 1 | /* |
590d1545 | 2 | * Copyright (c) 1989, 1993 The Regents of the University of California. |
6d2cb789 MT |
3 | * All rights reserved. |
4 | * | |
590d1545 KM |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Mike Karels at Berkeley Software Design, Inc. | |
7 | * | |
6dc0e27a | 8 | * %sccs.include.redist.c% |
6d2cb789 | 9 | * |
8e67f223 | 10 | * @(#)sysctl.h 7.25 (Berkeley) %G% |
6d2cb789 MT |
11 | */ |
12 | ||
30c53d9a KB |
13 | #ifndef _SYS_SYSCTL_H_ |
14 | #define _SYS_SYSCTL_H_ | |
15 | ||
ca708784 KM |
16 | /* |
17 | * These are for the eproc structure defined below. | |
18 | */ | |
19 | #ifndef KERNEL | |
20 | #include <sys/time.h> | |
21 | #include <sys/ucred.h> | |
22 | #include <sys/proc.h> | |
23 | #include <vm/vm.h> | |
24 | #endif | |
25 | ||
6d2cb789 | 26 | /* |
2632c247 KB |
27 | * Definitions for sysctl call. The sysctl call uses a hierarchical name |
28 | * for objects that can be examined or modified. The name is expressed as | |
29 | * a sequence of integers. Like a file path name, the meaning of each | |
30 | * component depends on its place in the hierarchy. The top-level and kern | |
31 | * identifiers are defined here, and other identifiers are defined in the | |
32 | * respective subsystem header files. | |
6d2cb789 | 33 | */ |
6d2cb789 | 34 | |
590d1545 | 35 | #define CTL_MAXNAME 12 /* largest number of components supported */ |
6d2cb789 | 36 | |
58cee51a KM |
37 | /* |
38 | * Each subsystem defined by sysctl defines a list of variables | |
39 | * for that subsystem. Each name is either a node with further | |
40 | * levels defined below it, or it is a leaf of some particular | |
41 | * type given below. Each sysctl level defines a set of name/type | |
42 | * pairs to be used by sysctl(1) in manipulating the subsystem. | |
43 | */ | |
44 | struct ctlname { | |
45 | char *ctl_name; /* subsystem name */ | |
46 | int ctl_type; /* type of name */ | |
47 | }; | |
48 | #define CTLTYPE_NODE 1 /* name is a node */ | |
49 | #define CTLTYPE_INT 2 /* name describes an integer */ | |
50 | #define CTLTYPE_STRING 3 /* name describes a string */ | |
51 | #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ | |
52 | #define CTLTYPE_STRUCT 5 /* name describes a structure */ | |
53 | ||
99285ae8 | 54 | /* |
590d1545 | 55 | * Top-level identifiers |
99285ae8 | 56 | */ |
590d1545 KM |
57 | #define CTL_UNSPEC 0 /* unused */ |
58 | #define CTL_KERN 1 /* "high kernel": proc, limits */ | |
59 | #define CTL_VM 2 /* virtual memory */ | |
60 | #define CTL_FS 3 /* file system, mount type is next */ | |
61 | #define CTL_NET 4 /* network, see socket.h */ | |
62 | #define CTL_DEBUG 5 /* debugging parameters */ | |
63 | #define CTL_HW 6 /* generic cpu/io */ | |
64 | #define CTL_MACHDEP 7 /* machine dependent */ | |
7de147d6 KB |
65 | #define CTL_USER 8 /* user-level */ |
66 | #define CTL_MAXID 9 /* number of valid top-level ids */ | |
99285ae8 | 67 | |
590d1545 | 68 | #define CTL_NAMES { \ |
58cee51a KM |
69 | { 0, 0 }, \ |
70 | { "kern", CTLTYPE_NODE }, \ | |
71 | { "vm", CTLTYPE_NODE }, \ | |
72 | { "fs", CTLTYPE_NODE }, \ | |
73 | { "net", CTLTYPE_NODE }, \ | |
74 | { "debug", CTLTYPE_NODE }, \ | |
75 | { "hw", CTLTYPE_NODE }, \ | |
76 | { "machdep", CTLTYPE_NODE }, \ | |
7de147d6 | 77 | { "user", CTLTYPE_NODE }, \ |
590d1545 | 78 | } |
2ad9de87 | 79 | |
ff1b45bf | 80 | /* |
590d1545 | 81 | * CTL_KERN identifiers |
ff1b45bf | 82 | */ |
7de147d6 KB |
83 | #define KERN_OSTYPE 1 /* string: system version */ |
84 | #define KERN_OSRELEASE 2 /* string: system release */ | |
85 | #define KERN_OSREV 3 /* int: system revision */ | |
86 | #define KERN_VERSION 4 /* string: compile time info */ | |
87 | #define KERN_MAXVNODES 5 /* int: max vnodes */ | |
88 | #define KERN_MAXPROC 6 /* int: max simultaneous processes */ | |
89 | #define KERN_MAXFILES 7 /* int: max open files */ | |
90 | #define KERN_ARGMAX 8 /* int: max arguments to exec */ | |
91 | #define KERN_SECURELVL 9 /* int: system security level */ | |
92 | #define KERN_HOSTNAME 10 /* string: hostname */ | |
93 | #define KERN_HOSTID 11 /* int: host identifier */ | |
94 | #define KERN_CLOCKRATE 12 /* struct: struct clockrate */ | |
95 | #define KERN_VNODE 13 /* struct: vnode structures */ | |
96 | #define KERN_PROC 14 /* struct: process entries */ | |
97 | #define KERN_FILE 15 /* struct: file entries */ | |
98 | #define KERN_PROF 16 /* node: kernel profiling info */ | |
99 | #define KERN_POSIX1 17 /* int: POSIX.1 version */ | |
100 | #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ | |
101 | #define KERN_JOB_CONTROL 19 /* int: is job control available */ | |
102 | #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ | |
103 | #define KERN_LINK_MAX 21 /* int: max file link count */ | |
104 | #define KERN_MAX_CANON 22 /* int: max bytes in term canon input */ | |
105 | #define KERN_MAX_INPUT 23 /* int: max bytes in term input */ | |
106 | #define KERN_NAME_MAX 24 /* int: max bytes in file name */ | |
107 | #define KERN_PATH_MAX 25 /* int: max bytes in pathname */ | |
108 | #define KERN_PIPE_BUF 26 /* int: max bytes for atomic pipe */ | |
109 | #define KERN_CHOWN_RESTRICTED 27 /* int: chown requires privilege */ | |
110 | #define KERN_NO_TRUNC 28 /* int: no path truncation */ | |
111 | #define KERN_VDISABLE 29 /* int: terminal character disable */ | |
8e67f223 KM |
112 | #define KERN_BOOTTIME 30 /* struct: time kernel was booted */ |
113 | #define KERN_MAXID 31 /* number of valid kern ids */ | |
ff1b45bf | 114 | |
590d1545 | 115 | #define CTL_KERN_NAMES { \ |
58cee51a KM |
116 | { 0, 0 }, \ |
117 | { "ostype", CTLTYPE_STRING }, \ | |
118 | { "osrelease", CTLTYPE_STRING }, \ | |
119 | { "osrevision", CTLTYPE_INT }, \ | |
120 | { "version", CTLTYPE_STRING }, \ | |
a563bb07 | 121 | { "maxvnodes", CTLTYPE_INT }, \ |
58cee51a KM |
122 | { "maxproc", CTLTYPE_INT }, \ |
123 | { "maxfiles", CTLTYPE_INT }, \ | |
124 | { "argmax", CTLTYPE_INT }, \ | |
125 | { "securelevel", CTLTYPE_INT }, \ | |
126 | { "hostname", CTLTYPE_STRING }, \ | |
127 | { "hostid", CTLTYPE_INT }, \ | |
128 | { "clockrate", CTLTYPE_STRUCT }, \ | |
129 | { "vnode", CTLTYPE_STRUCT }, \ | |
130 | { "proc", CTLTYPE_STRUCT }, \ | |
131 | { "file", CTLTYPE_STRUCT }, \ | |
231f58da | 132 | { "profiling", CTLTYPE_NODE }, \ |
a563bb07 | 133 | { "posix1version", CTLTYPE_INT }, \ |
7de147d6 KB |
134 | { "ngroups", CTLTYPE_INT }, \ |
135 | { "job_control", CTLTYPE_INT }, \ | |
136 | { "saved_ids", CTLTYPE_INT }, \ | |
137 | { "link_max", CTLTYPE_INT }, \ | |
138 | { "max_canon", CTLTYPE_INT }, \ | |
139 | { "max_input", CTLTYPE_INT }, \ | |
140 | { "name_max", CTLTYPE_INT }, \ | |
141 | { "path_max", CTLTYPE_INT }, \ | |
142 | { "pipe_buf", CTLTYPE_INT }, \ | |
143 | { "chown_restricted", CTLTYPE_INT }, \ | |
144 | { "no_trunc", CTLTYPE_INT }, \ | |
145 | { "vdisable", CTLTYPE_INT }, \ | |
8e67f223 | 146 | { "boottime", CTLTYPE_STRUCT }, \ |
590d1545 | 147 | } |
61ece7fc | 148 | |
590d1545 KM |
149 | /* |
150 | * KERN_PROC subtypes | |
61ece7fc | 151 | */ |
590d1545 KM |
152 | #define KERN_PROC_ALL 0 /* everything */ |
153 | #define KERN_PROC_PID 1 /* by process id */ | |
154 | #define KERN_PROC_PGRP 2 /* by process group id */ | |
155 | #define KERN_PROC_SESSION 3 /* by session of pid */ | |
156 | #define KERN_PROC_TTY 4 /* by controlling tty */ | |
157 | #define KERN_PROC_UID 5 /* by effective uid */ | |
158 | #define KERN_PROC_RUID 6 /* by real uid */ | |
61ece7fc | 159 | |
ca708784 KM |
160 | /* |
161 | * KERN_PROC subtype ops return arrays of augmented proc structures: | |
162 | */ | |
163 | struct kinfo_proc { | |
164 | struct proc kp_proc; /* proc structure */ | |
165 | struct eproc { | |
166 | struct proc *e_paddr; /* address of proc */ | |
167 | struct session *e_sess; /* session pointer */ | |
168 | struct pcred e_pcred; /* process credentials */ | |
169 | struct ucred e_ucred; /* current credentials */ | |
170 | #ifdef sparc | |
171 | struct { | |
172 | segsz_t vm_rssize; /* resident set size */ | |
173 | segsz_t vm_tsize; /* text size */ | |
174 | segsz_t vm_dsize; /* data size */ | |
175 | segsz_t vm_ssize; /* stack size */ | |
176 | } e_vm; | |
177 | #else | |
178 | struct vmspace e_vm; /* address space */ | |
179 | #endif | |
180 | pid_t e_ppid; /* parent process id */ | |
181 | pid_t e_pgid; /* process group id */ | |
182 | short e_jobc; /* job control counter */ | |
183 | dev_t e_tdev; /* controlling tty dev */ | |
184 | pid_t e_tpgid; /* tty process group id */ | |
185 | struct session *e_tsess; /* tty session pointer */ | |
186 | #define WMESGLEN 7 | |
187 | char e_wmesg[WMESGLEN+1]; /* wchan message */ | |
188 | segsz_t e_xsize; /* text size */ | |
189 | short e_xrssize; /* text rss */ | |
190 | short e_xccount; /* text references */ | |
191 | short e_xswrss; | |
192 | long e_flag; | |
193 | #define EPROC_CTTY 0x01 /* controlling tty vnode active */ | |
194 | #define EPROC_SLEADER 0x02 /* session leader */ | |
195 | char e_login[MAXLOGNAME]; /* setlogin() name */ | |
196 | long e_spare[4]; | |
197 | } kp_eproc; | |
198 | }; | |
199 | ||
99285ae8 | 200 | /* |
590d1545 | 201 | * CTL_HW identifiers |
99285ae8 | 202 | */ |
590d1545 KM |
203 | #define HW_MACHINE 1 /* string: machine class */ |
204 | #define HW_MODEL 2 /* string: specific machine model */ | |
205 | #define HW_NCPU 3 /* int: number of cpus */ | |
c99af07b | 206 | #define HW_BYTEORDER 4 /* int: machine byte order */ |
590d1545 KM |
207 | #define HW_PHYSMEM 5 /* int: total memory */ |
208 | #define HW_USERMEM 6 /* int: non-kernel memory */ | |
209 | #define HW_PAGESIZE 7 /* int: software page size */ | |
210 | #define HW_DISKNAMES 8 /* strings: disk drive names */ | |
c99af07b | 211 | #define HW_DISKSTATS 9 /* struct: diskstats[] */ |
590d1545 | 212 | #define HW_MAXID 10 /* number of valid hw ids */ |
99285ae8 | 213 | |
590d1545 | 214 | #define CTL_HW_NAMES { \ |
58cee51a KM |
215 | { 0, 0 }, \ |
216 | { "machine", CTLTYPE_STRING }, \ | |
217 | { "model", CTLTYPE_STRING }, \ | |
218 | { "ncpu", CTLTYPE_INT }, \ | |
c99af07b | 219 | { "byteorder", CTLTYPE_INT }, \ |
58cee51a KM |
220 | { "physmem", CTLTYPE_INT }, \ |
221 | { "usermem", CTLTYPE_INT }, \ | |
222 | { "pagesize", CTLTYPE_INT }, \ | |
223 | { "disknames", CTLTYPE_STRUCT }, \ | |
224 | { "diskstats", CTLTYPE_STRUCT }, \ | |
590d1545 | 225 | } |
99285ae8 | 226 | |
7de147d6 KB |
227 | /* |
228 | * CTL_USER definitions | |
229 | */ | |
230 | #define USER_CS_PATH 1 /* string: _CS_PATH */ | |
231 | #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ | |
232 | #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ | |
233 | #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ | |
234 | #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ | |
235 | #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ | |
236 | #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ | |
237 | #define USER_LINE_MAX 8 /* int: LINE_MAX */ | |
238 | #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ | |
239 | #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ | |
240 | #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ | |
241 | #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ | |
242 | #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ | |
243 | #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ | |
244 | #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ | |
245 | #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ | |
246 | #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ | |
247 | #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ | |
248 | #define USER_MAXID 19 /* number of valid user ids */ | |
249 | ||
250 | #define CTL_USER_NAMES { \ | |
251 | { 0, 0 }, \ | |
252 | { "cs_path", CTLTYPE_STRING }, \ | |
253 | { "bc_base_max", CTLTYPE_INT }, \ | |
254 | { "bc_dim_max", CTLTYPE_INT }, \ | |
255 | { "bc_scale_max", CTLTYPE_INT }, \ | |
256 | { "bc_string_max", CTLTYPE_INT }, \ | |
257 | { "coll_weights_max", CTLTYPE_INT }, \ | |
258 | { "expr_nest_max", CTLTYPE_INT }, \ | |
259 | { "line_max", CTLTYPE_INT }, \ | |
260 | { "re_dup_max", CTLTYPE_INT }, \ | |
261 | { "posix2_version", CTLTYPE_INT }, \ | |
262 | { "posix2_c_bind", CTLTYPE_INT }, \ | |
263 | { "posix2_c_dev", CTLTYPE_INT }, \ | |
264 | { "posix2_char_term", CTLTYPE_INT }, \ | |
265 | { "posix2_fort_dev", CTLTYPE_INT }, \ | |
266 | { "posix2_fort_run", CTLTYPE_INT }, \ | |
267 | { "posix2_localedef", CTLTYPE_INT }, \ | |
268 | { "posix2_sw_dev", CTLTYPE_INT }, \ | |
269 | { "posix2_upe", CTLTYPE_INT }, \ | |
270 | } | |
271 | ||
5da5c832 KM |
272 | /* |
273 | * CTL_DEBUG definitions | |
274 | * | |
275 | * Second level identifier specifies which debug variable. | |
276 | * Third level identifier specifies which stucture component. | |
277 | */ | |
278 | #define CTL_DEBUG_NAME 0 /* string: variable name */ | |
279 | #define CTL_DEBUG_VALUE 1 /* int: variable value */ | |
280 | #define CTL_DEBUG_MAXID 20 | |
281 | ||
30c53d9a KB |
282 | #ifdef KERNEL |
283 | #ifdef DEBUG | |
5da5c832 KM |
284 | /* |
285 | * CTL_DEBUG variables. | |
286 | * | |
287 | * These are declared as separate variables so that they can be | |
288 | * individually initialized at the location of their associated | |
289 | * variable. The loader prevents multiple use by issuing errors | |
290 | * if a variable is initialized in more than one place. They are | |
291 | * aggregated into an array in debug_sysctl(), so that it can | |
292 | * conveniently locate them when querried. If more debugging | |
293 | * variables are added, they must also be declared here and also | |
294 | * entered into the array. | |
295 | */ | |
296 | struct ctldebug { | |
297 | char *debugname; /* name of debugging variable */ | |
298 | int *debugvar; /* pointer to debugging variable */ | |
299 | }; | |
300 | extern struct ctldebug debug0, debug1, debug2, debug3, debug4; | |
301 | extern struct ctldebug debug5, debug6, debug7, debug8, debug9; | |
302 | extern struct ctldebug debug10, debug11, debug12, debug13, debug14; | |
303 | extern struct ctldebug debug15, debug16, debug17, debug18, debug19; | |
30c53d9a | 304 | #endif /* DEBUG */ |
5da5c832 | 305 | |
590d1545 KM |
306 | /* |
307 | * Internal sysctl function calling convention: | |
2632c247 | 308 | * |
590d1545 | 309 | * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen); |
2632c247 KB |
310 | * |
311 | * The name parameter points at the next component of the name to be | |
312 | * interpreted. The namelen parameter is the number of integers in | |
313 | * the name. | |
590d1545 | 314 | */ |
2632c247 KB |
315 | typedef int (sysctlfn) |
316 | __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *)); | |
317 | ||
318 | int sysctl_int __P((void *, size_t *, void *, size_t, int *)); | |
319 | int sysctl_rdint __P((void *, size_t *, void *, int)); | |
320 | int sysctl_string __P((void *, size_t *, void *, size_t, char *, int)); | |
321 | int sysctl_rdstring __P((void *, size_t *, void *, char *)); | |
322 | int sysctl_rdstruct __P((void *, size_t *, void *, void *, int)); | |
ca708784 | 323 | void fill_eproc __P((struct proc *, struct eproc *)); |
d43b4894 | 324 | |
30c53d9a | 325 | #else /* !KERNEL */ |
d43b4894 DS |
326 | #include <sys/cdefs.h> |
327 | ||
328 | __BEGIN_DECLS | |
2632c247 | 329 | int sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); |
d43b4894 | 330 | __END_DECLS |
30c53d9a KB |
331 | #endif /* KERNEL */ |
332 | #endif /* !_SYS_SYSCTL_H_ */ |