sysctl.h revision 1541
1/* 2 * Copyright (c) 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 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by the University of 19 * California, Berkeley and its contributors. 20 * 4. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 37 */ 38 39#ifndef _SYS_SYSCTL_H_ 40#define _SYS_SYSCTL_H_ 41 42/* 43 * These are for the eproc structure defined below. 44 */ 45#ifndef KERNEL 46#include <sys/time.h> 47#include <sys/ucred.h> 48#include <sys/proc.h> 49#include <vm/vm.h> 50#endif 51 52/* 53 * Definitions for sysctl call. The sysctl call uses a hierarchical name 54 * for objects that can be examined or modified. The name is expressed as 55 * a sequence of integers. Like a file path name, the meaning of each 56 * component depends on its place in the hierarchy. The top-level and kern 57 * identifiers are defined here, and other identifiers are defined in the 58 * respective subsystem header files. 59 */ 60 61#define CTL_MAXNAME 12 /* largest number of components supported */ 62 63/* 64 * Each subsystem defined by sysctl defines a list of variables 65 * for that subsystem. Each name is either a node with further 66 * levels defined below it, or it is a leaf of some particular 67 * type given below. Each sysctl level defines a set of name/type 68 * pairs to be used by sysctl(1) in manipulating the subsystem. 69 */ 70struct ctlname { 71 char *ctl_name; /* subsystem name */ 72 int ctl_type; /* type of name */ 73}; 74#define CTLTYPE_NODE 1 /* name is a node */ 75#define CTLTYPE_INT 2 /* name describes an integer */ 76#define CTLTYPE_STRING 3 /* name describes a string */ 77#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ 78#define CTLTYPE_STRUCT 5 /* name describes a structure */ 79 80/* 81 * Top-level identifiers 82 */ 83#define CTL_UNSPEC 0 /* unused */ 84#define CTL_KERN 1 /* "high kernel": proc, limits */ 85#define CTL_VM 2 /* virtual memory */ 86#define CTL_FS 3 /* file system, mount type is next */ 87#define CTL_NET 4 /* network, see socket.h */ 88#define CTL_DEBUG 5 /* debugging parameters */ 89#define CTL_HW 6 /* generic cpu/io */ 90#define CTL_MACHDEP 7 /* machine dependent */ 91#define CTL_USER 8 /* user-level */ 92#define CTL_MAXID 9 /* number of valid top-level ids */ 93 94#define CTL_NAMES { \ 95 { 0, 0 }, \ 96 { "kern", CTLTYPE_NODE }, \ 97 { "vm", CTLTYPE_NODE }, \ 98 { "fs", CTLTYPE_NODE }, \ 99 { "net", CTLTYPE_NODE }, \ 100 { "debug", CTLTYPE_NODE }, \ 101 { "hw", CTLTYPE_NODE }, \ 102 { "machdep", CTLTYPE_NODE }, \ 103 { "user", CTLTYPE_NODE }, \ 104} 105 106/* 107 * CTL_KERN identifiers 108 */ 109#define KERN_OSTYPE 1 /* string: system version */ 110#define KERN_OSRELEASE 2 /* string: system release */ 111#define KERN_OSREV 3 /* int: system revision */ 112#define KERN_VERSION 4 /* string: compile time info */ 113#define KERN_MAXVNODES 5 /* int: max vnodes */ 114#define KERN_MAXPROC 6 /* int: max processes */ 115#define KERN_MAXFILES 7 /* int: max open files */ 116#define KERN_ARGMAX 8 /* int: max arguments to exec */ 117#define KERN_SECURELVL 9 /* int: system security level */ 118#define KERN_HOSTNAME 10 /* string: hostname */ 119#define KERN_HOSTID 11 /* int: host identifier */ 120#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ 121#define KERN_VNODE 13 /* struct: vnode structures */ 122#define KERN_PROC 14 /* struct: process entries */ 123#define KERN_FILE 15 /* struct: file entries */ 124#define KERN_PROF 16 /* node: kernel profiling info */ 125#define KERN_POSIX1 17 /* int: POSIX.1 version */ 126#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ 127#define KERN_JOB_CONTROL 19 /* int: is job control available */ 128#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ 129#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ 130#define KERN_MAXID 22 /* number of valid kern ids */ 131 132#define CTL_KERN_NAMES { \ 133 { 0, 0 }, \ 134 { "ostype", CTLTYPE_STRING }, \ 135 { "osrelease", CTLTYPE_STRING }, \ 136 { "osrevision", CTLTYPE_INT }, \ 137 { "version", CTLTYPE_STRING }, \ 138 { "maxvnodes", CTLTYPE_INT }, \ 139 { "maxproc", CTLTYPE_INT }, \ 140 { "maxfiles", CTLTYPE_INT }, \ 141 { "argmax", CTLTYPE_INT }, \ 142 { "securelevel", CTLTYPE_INT }, \ 143 { "hostname", CTLTYPE_STRING }, \ 144 { "hostid", CTLTYPE_INT }, \ 145 { "clockrate", CTLTYPE_STRUCT }, \ 146 { "vnode", CTLTYPE_STRUCT }, \ 147 { "proc", CTLTYPE_STRUCT }, \ 148 { "file", CTLTYPE_STRUCT }, \ 149 { "profiling", CTLTYPE_NODE }, \ 150 { "posix1version", CTLTYPE_INT }, \ 151 { "ngroups", CTLTYPE_INT }, \ 152 { "job_control", CTLTYPE_INT }, \ 153 { "saved_ids", CTLTYPE_INT }, \ 154 { "boottime", CTLTYPE_STRUCT }, \ 155} 156 157/* 158 * KERN_PROC subtypes 159 */ 160#define KERN_PROC_ALL 0 /* everything */ 161#define KERN_PROC_PID 1 /* by process id */ 162#define KERN_PROC_PGRP 2 /* by process group id */ 163#define KERN_PROC_SESSION 3 /* by session of pid */ 164#define KERN_PROC_TTY 4 /* by controlling tty */ 165#define KERN_PROC_UID 5 /* by effective uid */ 166#define KERN_PROC_RUID 6 /* by real uid */ 167 168/* 169 * KERN_PROC subtype ops return arrays of augmented proc structures: 170 */ 171struct kinfo_proc { 172 struct proc kp_proc; /* proc structure */ 173 struct eproc { 174 struct proc *e_paddr; /* address of proc */ 175 struct session *e_sess; /* session pointer */ 176 struct pcred e_pcred; /* process credentials */ 177 struct ucred e_ucred; /* current credentials */ 178#ifdef sparc 179 struct { 180 segsz_t vm_rssize; /* resident set size */ 181 segsz_t vm_tsize; /* text size */ 182 segsz_t vm_dsize; /* data size */ 183 segsz_t vm_ssize; /* stack size */ 184 } e_vm; 185#else 186 struct vmspace e_vm; /* address space */ 187#endif 188 pid_t e_ppid; /* parent process id */ 189 pid_t e_pgid; /* process group id */ 190 short e_jobc; /* job control counter */ 191 dev_t e_tdev; /* controlling tty dev */ 192 pid_t e_tpgid; /* tty process group id */ 193 struct session *e_tsess; /* tty session pointer */ 194#define WMESGLEN 7 195 char e_wmesg[WMESGLEN+1]; /* wchan message */ 196 segsz_t e_xsize; /* text size */ 197 short e_xrssize; /* text rss */ 198 short e_xccount; /* text references */ 199 short e_xswrss; 200 long e_flag; 201#define EPROC_CTTY 0x01 /* controlling tty vnode active */ 202#define EPROC_SLEADER 0x02 /* session leader */ 203 char e_login[MAXLOGNAME]; /* setlogin() name */ 204 long e_spare[4]; 205 } kp_eproc; 206}; 207 208/* 209 * CTL_HW identifiers 210 */ 211#define HW_MACHINE 1 /* string: machine class */ 212#define HW_MODEL 2 /* string: specific machine model */ 213#define HW_NCPU 3 /* int: number of cpus */ 214#define HW_BYTEORDER 4 /* int: machine byte order */ 215#define HW_PHYSMEM 5 /* int: total memory */ 216#define HW_USERMEM 6 /* int: non-kernel memory */ 217#define HW_PAGESIZE 7 /* int: software page size */ 218#define HW_DISKNAMES 8 /* strings: disk drive names */ 219#define HW_DISKSTATS 9 /* struct: diskstats[] */ 220#define HW_MAXID 10 /* number of valid hw ids */ 221 222#define CTL_HW_NAMES { \ 223 { 0, 0 }, \ 224 { "machine", CTLTYPE_STRING }, \ 225 { "model", CTLTYPE_STRING }, \ 226 { "ncpu", CTLTYPE_INT }, \ 227 { "byteorder", CTLTYPE_INT }, \ 228 { "physmem", CTLTYPE_INT }, \ 229 { "usermem", CTLTYPE_INT }, \ 230 { "pagesize", CTLTYPE_INT }, \ 231 { "disknames", CTLTYPE_STRUCT }, \ 232 { "diskstats", CTLTYPE_STRUCT }, \ 233} 234 235/* 236 * CTL_USER definitions 237 */ 238#define USER_CS_PATH 1 /* string: _CS_PATH */ 239#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ 240#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ 241#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ 242#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ 243#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ 244#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ 245#define USER_LINE_MAX 8 /* int: LINE_MAX */ 246#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ 247#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ 248#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ 249#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ 250#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ 251#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ 252#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ 253#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ 254#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ 255#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ 256#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ 257#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ 258#define USER_MAXID 21 /* number of valid user ids */ 259 260#define CTL_USER_NAMES { \ 261 { 0, 0 }, \ 262 { "cs_path", CTLTYPE_STRING }, \ 263 { "bc_base_max", CTLTYPE_INT }, \ 264 { "bc_dim_max", CTLTYPE_INT }, \ 265 { "bc_scale_max", CTLTYPE_INT }, \ 266 { "bc_string_max", CTLTYPE_INT }, \ 267 { "coll_weights_max", CTLTYPE_INT }, \ 268 { "expr_nest_max", CTLTYPE_INT }, \ 269 { "line_max", CTLTYPE_INT }, \ 270 { "re_dup_max", CTLTYPE_INT }, \ 271 { "posix2_version", CTLTYPE_INT }, \ 272 { "posix2_c_bind", CTLTYPE_INT }, \ 273 { "posix2_c_dev", CTLTYPE_INT }, \ 274 { "posix2_char_term", CTLTYPE_INT }, \ 275 { "posix2_fort_dev", CTLTYPE_INT }, \ 276 { "posix2_fort_run", CTLTYPE_INT }, \ 277 { "posix2_localedef", CTLTYPE_INT }, \ 278 { "posix2_sw_dev", CTLTYPE_INT }, \ 279 { "posix2_upe", CTLTYPE_INT }, \ 280 { "stream_max", CTLTYPE_INT }, \ 281 { "tzname_max", CTLTYPE_INT }, \ 282} 283 284/* 285 * CTL_DEBUG definitions 286 * 287 * Second level identifier specifies which debug variable. 288 * Third level identifier specifies which stucture component. 289 */ 290#define CTL_DEBUG_NAME 0 /* string: variable name */ 291#define CTL_DEBUG_VALUE 1 /* int: variable value */ 292#define CTL_DEBUG_MAXID 20 293 294#ifdef KERNEL 295#ifdef DEBUG 296/* 297 * CTL_DEBUG variables. 298 * 299 * These are declared as separate variables so that they can be 300 * individually initialized at the location of their associated 301 * variable. The loader prevents multiple use by issuing errors 302 * if a variable is initialized in more than one place. They are 303 * aggregated into an array in debug_sysctl(), so that it can 304 * conveniently locate them when querried. If more debugging 305 * variables are added, they must also be declared here and also 306 * entered into the array. 307 */ 308struct ctldebug { 309 char *debugname; /* name of debugging variable */ 310 int *debugvar; /* pointer to debugging variable */ 311}; 312extern struct ctldebug debug0, debug1, debug2, debug3, debug4; 313extern struct ctldebug debug5, debug6, debug7, debug8, debug9; 314extern struct ctldebug debug10, debug11, debug12, debug13, debug14; 315extern struct ctldebug debug15, debug16, debug17, debug18, debug19; 316#endif /* DEBUG */ 317 318/* 319 * Internal sysctl function calling convention: 320 * 321 * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen); 322 * 323 * The name parameter points at the next component of the name to be 324 * interpreted. The namelen parameter is the number of integers in 325 * the name. 326 */ 327typedef int (sysctlfn) 328 __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *)); 329 330int sysctl_int __P((void *, size_t *, void *, size_t, int *)); 331int sysctl_rdint __P((void *, size_t *, void *, int)); 332int sysctl_string __P((void *, size_t *, void *, size_t, char *, int)); 333int sysctl_rdstring __P((void *, size_t *, void *, char *)); 334int sysctl_rdstruct __P((void *, size_t *, void *, void *, int)); 335void fill_eproc __P((struct proc *, struct eproc *)); 336 337#else /* !KERNEL */ 338#include <sys/cdefs.h> 339 340__BEGIN_DECLS 341int sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 342__END_DECLS 343#endif /* KERNEL */ 344#endif /* !_SYS_SYSCTL_H_ */ 345