1 /* 2 * Copyright (c) 1989, 1993 The Regents of the University of California. 3 * 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 * %sccs.include.redist.c% 9 * 10 * @(#)sysctl.h 7.24 (Berkeley) 05/04/93 11 */ 12 13 #ifndef _SYS_SYSCTL_H_ 14 #define _SYS_SYSCTL_H_ 15 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 26 /* 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. 33 */ 34 35 #define CTL_MAXNAME 12 /* largest number of components supported */ 36 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 54 /* 55 * Top-level identifiers 56 */ 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 */ 65 #define CTL_USER 8 /* user-level */ 66 #define CTL_MAXID 9 /* number of valid top-level ids */ 67 68 #define CTL_NAMES { \ 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 }, \ 77 { "user", CTLTYPE_NODE }, \ 78 } 79 80 /* 81 * CTL_KERN identifiers 82 */ 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 */ 112 #define KERN_MAXID 30 /* number of valid kern ids */ 113 114 #define CTL_KERN_NAMES { \ 115 { 0, 0 }, \ 116 { "ostype", CTLTYPE_STRING }, \ 117 { "osrelease", CTLTYPE_STRING }, \ 118 { "osrevision", CTLTYPE_INT }, \ 119 { "version", CTLTYPE_STRING }, \ 120 { "maxvnodes", CTLTYPE_INT }, \ 121 { "maxproc", CTLTYPE_INT }, \ 122 { "maxfiles", CTLTYPE_INT }, \ 123 { "argmax", CTLTYPE_INT }, \ 124 { "securelevel", CTLTYPE_INT }, \ 125 { "hostname", CTLTYPE_STRING }, \ 126 { "hostid", CTLTYPE_INT }, \ 127 { "clockrate", CTLTYPE_STRUCT }, \ 128 { "vnode", CTLTYPE_STRUCT }, \ 129 { "proc", CTLTYPE_STRUCT }, \ 130 { "file", CTLTYPE_STRUCT }, \ 131 { "profiling", CTLTYPE_NODE }, \ 132 { "posix1version", CTLTYPE_INT }, \ 133 { "ngroups", CTLTYPE_INT }, \ 134 { "job_control", CTLTYPE_INT }, \ 135 { "saved_ids", CTLTYPE_INT }, \ 136 { "link_max", CTLTYPE_INT }, \ 137 { "max_canon", CTLTYPE_INT }, \ 138 { "max_input", CTLTYPE_INT }, \ 139 { "name_max", CTLTYPE_INT }, \ 140 { "path_max", CTLTYPE_INT }, \ 141 { "pipe_buf", CTLTYPE_INT }, \ 142 { "chown_restricted", CTLTYPE_INT }, \ 143 { "no_trunc", CTLTYPE_INT }, \ 144 { "vdisable", CTLTYPE_INT }, \ 145 } 146 147 /* 148 * KERN_PROC subtypes 149 */ 150 #define KERN_PROC_ALL 0 /* everything */ 151 #define KERN_PROC_PID 1 /* by process id */ 152 #define KERN_PROC_PGRP 2 /* by process group id */ 153 #define KERN_PROC_SESSION 3 /* by session of pid */ 154 #define KERN_PROC_TTY 4 /* by controlling tty */ 155 #define KERN_PROC_UID 5 /* by effective uid */ 156 #define KERN_PROC_RUID 6 /* by real uid */ 157 158 /* 159 * KERN_PROC subtype ops return arrays of augmented proc structures: 160 */ 161 struct kinfo_proc { 162 struct proc kp_proc; /* proc structure */ 163 struct eproc { 164 struct proc *e_paddr; /* address of proc */ 165 struct session *e_sess; /* session pointer */ 166 struct pcred e_pcred; /* process credentials */ 167 struct ucred e_ucred; /* current credentials */ 168 #ifdef sparc 169 struct { 170 segsz_t vm_rssize; /* resident set size */ 171 segsz_t vm_tsize; /* text size */ 172 segsz_t vm_dsize; /* data size */ 173 segsz_t vm_ssize; /* stack size */ 174 } e_vm; 175 #else 176 struct vmspace e_vm; /* address space */ 177 #endif 178 pid_t e_ppid; /* parent process id */ 179 pid_t e_pgid; /* process group id */ 180 short e_jobc; /* job control counter */ 181 dev_t e_tdev; /* controlling tty dev */ 182 pid_t e_tpgid; /* tty process group id */ 183 struct session *e_tsess; /* tty session pointer */ 184 #define WMESGLEN 7 185 char e_wmesg[WMESGLEN+1]; /* wchan message */ 186 segsz_t e_xsize; /* text size */ 187 short e_xrssize; /* text rss */ 188 short e_xccount; /* text references */ 189 short e_xswrss; 190 long e_flag; 191 #define EPROC_CTTY 0x01 /* controlling tty vnode active */ 192 #define EPROC_SLEADER 0x02 /* session leader */ 193 char e_login[MAXLOGNAME]; /* setlogin() name */ 194 long e_spare[4]; 195 } kp_eproc; 196 }; 197 198 /* 199 * CTL_HW identifiers 200 */ 201 #define HW_MACHINE 1 /* string: machine class */ 202 #define HW_MODEL 2 /* string: specific machine model */ 203 #define HW_NCPU 3 /* int: number of cpus */ 204 #define HW_BYTEORDER 4 /* int: machine byte order */ 205 #define HW_PHYSMEM 5 /* int: total memory */ 206 #define HW_USERMEM 6 /* int: non-kernel memory */ 207 #define HW_PAGESIZE 7 /* int: software page size */ 208 #define HW_DISKNAMES 8 /* strings: disk drive names */ 209 #define HW_DISKSTATS 9 /* struct: diskstats[] */ 210 #define HW_MAXID 10 /* number of valid hw ids */ 211 212 #define CTL_HW_NAMES { \ 213 { 0, 0 }, \ 214 { "machine", CTLTYPE_STRING }, \ 215 { "model", CTLTYPE_STRING }, \ 216 { "ncpu", CTLTYPE_INT }, \ 217 { "byteorder", CTLTYPE_INT }, \ 218 { "physmem", CTLTYPE_INT }, \ 219 { "usermem", CTLTYPE_INT }, \ 220 { "pagesize", CTLTYPE_INT }, \ 221 { "disknames", CTLTYPE_STRUCT }, \ 222 { "diskstats", CTLTYPE_STRUCT }, \ 223 } 224 225 /* 226 * CTL_USER definitions 227 */ 228 #define USER_CS_PATH 1 /* string: _CS_PATH */ 229 #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ 230 #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ 231 #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ 232 #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ 233 #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ 234 #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ 235 #define USER_LINE_MAX 8 /* int: LINE_MAX */ 236 #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ 237 #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ 238 #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ 239 #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ 240 #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ 241 #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ 242 #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ 243 #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ 244 #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ 245 #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ 246 #define USER_MAXID 19 /* number of valid user ids */ 247 248 #define CTL_USER_NAMES { \ 249 { 0, 0 }, \ 250 { "cs_path", CTLTYPE_STRING }, \ 251 { "bc_base_max", CTLTYPE_INT }, \ 252 { "bc_dim_max", CTLTYPE_INT }, \ 253 { "bc_scale_max", CTLTYPE_INT }, \ 254 { "bc_string_max", CTLTYPE_INT }, \ 255 { "coll_weights_max", CTLTYPE_INT }, \ 256 { "expr_nest_max", CTLTYPE_INT }, \ 257 { "line_max", CTLTYPE_INT }, \ 258 { "re_dup_max", CTLTYPE_INT }, \ 259 { "posix2_version", CTLTYPE_INT }, \ 260 { "posix2_c_bind", CTLTYPE_INT }, \ 261 { "posix2_c_dev", CTLTYPE_INT }, \ 262 { "posix2_char_term", CTLTYPE_INT }, \ 263 { "posix2_fort_dev", CTLTYPE_INT }, \ 264 { "posix2_fort_run", CTLTYPE_INT }, \ 265 { "posix2_localedef", CTLTYPE_INT }, \ 266 { "posix2_sw_dev", CTLTYPE_INT }, \ 267 { "posix2_upe", CTLTYPE_INT }, \ 268 } 269 270 /* 271 * CTL_DEBUG definitions 272 * 273 * Second level identifier specifies which debug variable. 274 * Third level identifier specifies which stucture component. 275 */ 276 #define CTL_DEBUG_NAME 0 /* string: variable name */ 277 #define CTL_DEBUG_VALUE 1 /* int: variable value */ 278 #define CTL_DEBUG_MAXID 20 279 280 #ifdef KERNEL 281 #ifdef DEBUG 282 /* 283 * CTL_DEBUG variables. 284 * 285 * These are declared as separate variables so that they can be 286 * individually initialized at the location of their associated 287 * variable. The loader prevents multiple use by issuing errors 288 * if a variable is initialized in more than one place. They are 289 * aggregated into an array in debug_sysctl(), so that it can 290 * conveniently locate them when querried. If more debugging 291 * variables are added, they must also be declared here and also 292 * entered into the array. 293 */ 294 struct ctldebug { 295 char *debugname; /* name of debugging variable */ 296 int *debugvar; /* pointer to debugging variable */ 297 }; 298 extern struct ctldebug debug0, debug1, debug2, debug3, debug4; 299 extern struct ctldebug debug5, debug6, debug7, debug8, debug9; 300 extern struct ctldebug debug10, debug11, debug12, debug13, debug14; 301 extern struct ctldebug debug15, debug16, debug17, debug18, debug19; 302 #endif /* DEBUG */ 303 304 /* 305 * Internal sysctl function calling convention: 306 * 307 * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen); 308 * 309 * The name parameter points at the next component of the name to be 310 * interpreted. The namelen parameter is the number of integers in 311 * the name. 312 */ 313 typedef int (sysctlfn) 314 __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *)); 315 316 int sysctl_int __P((void *, size_t *, void *, size_t, int *)); 317 int sysctl_rdint __P((void *, size_t *, void *, int)); 318 int sysctl_string __P((void *, size_t *, void *, size_t, char *, int)); 319 int sysctl_rdstring __P((void *, size_t *, void *, char *)); 320 int sysctl_rdstruct __P((void *, size_t *, void *, void *, int)); 321 void fill_eproc __P((struct proc *, struct eproc *)); 322 323 #else /* !KERNEL */ 324 #include <sys/cdefs.h> 325 326 __BEGIN_DECLS 327 int sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 328 __END_DECLS 329 #endif /* KERNEL */ 330 #endif /* !_SYS_SYSCTL_H_ */ 331