3063127a5f946db8acedd179a3039f10f5107db2
[unix-history] / usr / src / sys / sys / sysctl.h
/*
* Copyright (c) 1989, 1993 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Karels at Berkeley Software Design, Inc.
*
* %sccs.include.redist.c%
*
* @(#)sysctl.h 7.20 (Berkeley) %G%
*/
/*
* Definitions for sysctl call. The sysctl call uses a hierarchical name
* for objects that can be examined or modified. The name is expressed as
* a sequence of integers. Like a file path name, the meaning of each
* component depends on its place in the hierarchy. The top-level and kern
* identifiers are defined here, and other identifiers are defined in the
* respective subsystem header files.
*/
#define CTL_MAXNAME 12 /* largest number of components supported */
/*
* Each subsystem defined by sysctl defines a list of variables
* for that subsystem. Each name is either a node with further
* levels defined below it, or it is a leaf of some particular
* type given below. Each sysctl level defines a set of name/type
* pairs to be used by sysctl(1) in manipulating the subsystem.
*/
struct ctlname {
char *ctl_name; /* subsystem name */
int ctl_type; /* type of name */
};
#define CTLTYPE_NODE 1 /* name is a node */
#define CTLTYPE_INT 2 /* name describes an integer */
#define CTLTYPE_STRING 3 /* name describes a string */
#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
#define CTLTYPE_STRUCT 5 /* name describes a structure */
/*
* Top-level identifiers
*/
#define CTL_UNSPEC 0 /* unused */
#define CTL_KERN 1 /* "high kernel": proc, limits */
#define CTL_VM 2 /* virtual memory */
#define CTL_FS 3 /* file system, mount type is next */
#define CTL_NET 4 /* network, see socket.h */
#define CTL_DEBUG 5 /* debugging parameters */
#define CTL_HW 6 /* generic cpu/io */
#define CTL_MACHDEP 7 /* machine dependent */
#define CTL_MAXID 8 /* number of valid top-level ids */
#define CTL_NAMES { \
{ 0, 0 }, \
{ "kern", CTLTYPE_NODE }, \
{ "vm", CTLTYPE_NODE }, \
{ "fs", CTLTYPE_NODE }, \
{ "net", CTLTYPE_NODE }, \
{ "debug", CTLTYPE_NODE }, \
{ "hw", CTLTYPE_NODE }, \
{ "machdep", CTLTYPE_NODE }, \
}
/*
* CTL_KERN identifiers
*/
#define KERN_OSTYPE 1 /* string: system version */
#define KERN_OSRELEASE 2 /* string: system release */
#define KERN_OSREV 3 /* int: system revision */
#define KERN_VERSION 4 /* string: compile time info */
#define KERN_MAXVNODES 5 /* int: max vnodes */
#define KERN_MAXPROC 6 /* int: max simultaneous processes */
#define KERN_MAXFILES 7 /* int: max open files */
#define KERN_ARGMAX 8 /* int: max arguments to exec */
#define KERN_SECURELVL 9 /* int: system security level */
#define KERN_HOSTNAME 10 /* string: hostname */
#define KERN_HOSTID 11 /* int: host identifier */
#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
#define KERN_VNODE 13 /* struct: vnode structures */
#define KERN_PROC 14 /* struct: process entries */
#define KERN_FILE 15 /* struct: file entries */
#define KERN_PROF 16 /* node: kernel profiling info */
#define KERN_POSIX1 17 /* int: POSIX.1 version */
#define KERN_MAXID 18 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
{ "ostype", CTLTYPE_STRING }, \
{ "osrelease", CTLTYPE_STRING }, \
{ "osrevision", CTLTYPE_INT }, \
{ "version", CTLTYPE_STRING }, \
{ "maxvnodes", CTLTYPE_INT }, \
{ "maxproc", CTLTYPE_INT }, \
{ "maxfiles", CTLTYPE_INT }, \
{ "argmax", CTLTYPE_INT }, \
{ "securelevel", CTLTYPE_INT }, \
{ "hostname", CTLTYPE_STRING }, \
{ "hostid", CTLTYPE_INT }, \
{ "clockrate", CTLTYPE_STRUCT }, \
{ "vnode", CTLTYPE_STRUCT }, \
{ "proc", CTLTYPE_STRUCT }, \
{ "file", CTLTYPE_STRUCT }, \
{ "profiling", CTLTYPE_NODE }, \
{ "posix1version", CTLTYPE_INT }, \
}
/*
* KERN_PROC subtypes
*/
#define KERN_PROC_ALL 0 /* everything */
#define KERN_PROC_PID 1 /* by process id */
#define KERN_PROC_PGRP 2 /* by process group id */
#define KERN_PROC_SESSION 3 /* by session of pid */
#define KERN_PROC_TTY 4 /* by controlling tty */
#define KERN_PROC_UID 5 /* by effective uid */
#define KERN_PROC_RUID 6 /* by real uid */
/*
* CTL_HW identifiers
*/
#define HW_MACHINE 1 /* string: machine class */
#define HW_MODEL 2 /* string: specific machine model */
#define HW_NCPU 3 /* int: number of cpus */
#define HW_CPUSPEED 4 /* int: relative cpuspeed */
#define HW_PHYSMEM 5 /* int: total memory */
#define HW_USERMEM 6 /* int: non-kernel memory */
#define HW_PAGESIZE 7 /* int: software page size */
#define HW_DISKNAMES 8 /* strings: disk drive names */
#define HW_DISKSTATS 9 /* diskstats[] */
#define HW_MAXID 10 /* number of valid hw ids */
#define CTL_HW_NAMES { \
{ 0, 0 }, \
{ "machine", CTLTYPE_STRING }, \
{ "model", CTLTYPE_STRING }, \
{ "ncpu", CTLTYPE_INT }, \
{ "cpuspeed", CTLTYPE_INT }, \
{ "physmem", CTLTYPE_INT }, \
{ "usermem", CTLTYPE_INT }, \
{ "pagesize", CTLTYPE_INT }, \
{ "disknames", CTLTYPE_STRUCT }, \
{ "diskstats", CTLTYPE_STRUCT }, \
}
/*
* CTL_DEBUG definitions
*
* Second level identifier specifies which debug variable.
* Third level identifier specifies which stucture component.
*/
#define CTL_DEBUG_NAME 0 /* string: variable name */
#define CTL_DEBUG_VALUE 1 /* int: variable value */
#define CTL_DEBUG_MAXID 20
#ifdef KERNEL
#ifdef DEBUG
/*
* CTL_DEBUG variables.
*
* These are declared as separate variables so that they can be
* individually initialized at the location of their associated
* variable. The loader prevents multiple use by issuing errors
* if a variable is initialized in more than one place. They are
* aggregated into an array in debug_sysctl(), so that it can
* conveniently locate them when querried. If more debugging
* variables are added, they must also be declared here and also
* entered into the array.
*/
struct ctldebug {
char *debugname; /* name of debugging variable */
int *debugvar; /* pointer to debugging variable */
};
extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
#endif /* DEBUG */
/*
* Internal sysctl function calling convention:
*
* (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
*
* The name parameter points at the next component of the name to be
* interpreted. The namelen parameter is the number of integers in
* the name.
*/
typedef int (sysctlfn)
__P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
int sysctl_int __P((void *, size_t *, void *, size_t, int *));
int sysctl_rdint __P((void *, size_t *, void *, int));
int sysctl_string __P((void *, size_t *, void *, size_t, char *, int));
int sysctl_rdstring __P((void *, size_t *, void *, char *));
int sysctl_rdstruct __P((void *, size_t *, void *, void *, int));
#else /* !KERNEL */
#include <sys/cdefs.h>
__BEGIN_DECLS
int sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
__END_DECLS
#endif /* KERNEL */