diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-01-18 14:51:44 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-01-18 14:51:44 +0000 |
commit | e3799e7d78d29d70fcf1a5e5c843cd9b5aa1c297 (patch) | |
tree | e66579dff7ffe5ff3840ee9df87d857387f4a79b /share/man/man9 | |
parent | 0e45d1767640de9d1271dc56304826773b3911ff (diff) |
internal sysctl functions and etc
Diffstat (limited to 'share/man/man9')
-rw-r--r-- | share/man/man9/Makefile | 9 | ||||
-rw-r--r-- | share/man/man9/syscall.9 | 3 | ||||
-rw-r--r-- | share/man/man9/sysctl_int.9 | 205 | ||||
-rw-r--r-- | share/man/man9/wdog_register.9 | 3 |
4 files changed, 216 insertions, 4 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index fd44cdcf4b4..1967a0b27e8 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.110 2006/01/12 00:17:17 dlg Exp $ +# $OpenBSD: Makefile,v 1.111 2006/01/18 14:51:42 mickey Exp $ # $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -21,7 +21,7 @@ MAN= altq.9 audio.9 autoconf.9 boot.9 buffercache.9 bus_dma.9 bus_space.9 \ pool.9 powerhook_establish.9 ppsratecheck.9 printf.9 psignal.9 \ radio.9 random.9 rasops.9 ratecheck.9 resettodr.9 rssadapt.9 \ shutdownhook_establish.9 sleep.9 spl.9 startuphook_establish.9 \ - style.9 syscall.9 systrace.9 \ + style.9 syscall.9 systrace.9 sysctl_int.9 \ tc_init.9 time.9 timeout.9 tvtohz.9 uiomove.9 uvm.9 vfs.9 vfs_cache.9 \ vaccess.9 vclean.9 vcount.9 vdevgone.9 vfinddev.9 vflush.9 \ vflushbuf.9 vget.9 vgone.9 vhold.9 vinvalbuf.9 vnode.9 vnsubr.9 \ @@ -251,6 +251,11 @@ MLINKS+=spl.9 spl0.9 spl.9 splassert.9 spl.9 splbio.9 spl.9 splclock.9 \ MLINKS+=startuphook_establish.9 startuphook_disestablish.9 MLINKS+=systrace.9 systrace_redirect.9 \ systrace.9 systrace_fork.9 systrace.9 systrace_exit.9 +MLINKS+=sysctl_int.9 sysctl_int_arr.9 sysctl_int.9 sysctl_quad.9 \ + sysctl_int.9 sysctl_string.9 sysctl_int.9 sysctl_tstring.9 \ + sysctl_int.9 sysctl_rdint.9 sysctl_int.9 sysctl_rdquad.9 \ + sysctl_int.9 sysctl_rdstring.9 sysctl_int.9 sysctl_rdstruct.9 \ + sysctl_int.9 sysctl_struct.9 sysctl_int.9 ctlname.9 MLINKS+=time.9 boottime.9 time.9 mono_time.9 time.9 runtime.9 MLINKS+=timeout.9 timeout_add.9 timeout.9 timeout_set.9 \ timeout.9 timeout_pending.9 timeout.9 timeout_del.9 \ diff --git a/share/man/man9/syscall.9 b/share/man/man9/syscall.9 index 2c496cdb531..dbf828c1021 100644 --- a/share/man/man9/syscall.9 +++ b/share/man/man9/syscall.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: syscall.9,v 1.5 2003/11/08 19:17:28 jmc Exp $ +.\" $OpenBSD: syscall.9,v 1.6 2006/01/18 14:51:42 mickey Exp $ .\" .\" Copyright (c) 2003 Michael Shalayeff .\" @@ -243,6 +243,7 @@ system call numbers. .Xr syscall 2 , .Xr systrace 4 , .Xr ktrace 9 , +.Xr sysctl_int 9 , .Xr systrace 9 .Sh HISTORY The diff --git a/share/man/man9/sysctl_int.9 b/share/man/man9/sysctl_int.9 new file mode 100644 index 00000000000..2a8fbf19038 --- /dev/null +++ b/share/man/man9/sysctl_int.9 @@ -0,0 +1,205 @@ +.\" $OpenBSD: sysctl_int.9,v 1.1 2006/01/18 14:51:43 mickey Exp $ +.\" +.\" Copyright (c) 2006 Michael Shalayeff +.\" All rights reserved. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd January 20, 2006 +.Dt SYSCTL_INT 9 +.Os +.Sh NAME +.Nm sysctl_int , +.Nm sysctl_int_arr , +.Nm sysctl_quad , +.Nm sysctl_string , +.Nm sysctl_tstring , +.Nm sysctl_rdint , +.Nm sysctl_rdquad , +.Nm sysctl_rdstring , +.Nm sysctl_rdstruct , +.Nm sysctl_struct +.Nd kernel sysctl interface +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/sysctl.h> +.Ft int +.Fn sysctl_int "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "int *valp" +.Ft int +.Fn sysctl_int_arr "int **valpp" "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" +.Ft int +.Fn sysctl_quad "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "int64_t *valp" +.Ft int +.Fn sysctl_string "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "char *str" "int maxlen" +.Ft int +.Fn sysctl_tstring "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "char *str" "int maxlen" +.Ft int +.Fn sysctl_rdint "void *oldp" "size_t *oldlenp" "void *newp" "int val" +.Ft int +.Fn sysctl_rdquad "void *oldp" "size_t *oldlenp" "void *newp" "int64_t val" +.Ft int +.Fn sysctl_rdstring "void *oldp" "size_t *oldlenp" "void *newp" "const char *str" +.Ft int +.Fn sysctl_rdstruct "void *oldp" "size_t *oldlenp" "void *newp" "const void *sp" "int len" +.Ft int +.Fn sysctl_struct "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "void *sp" "int len" +.Sh DESCRIPTION +These functions and data structures are aimed to simplify and partially +implement oprations for kernel and user implementation of sysctl interface. +Single +.Xr syscall 9 +is used to request and modify kernel variables. +The +.Nm mib +argument is recursively scanned as an array of integers either calling +futher function for parsing the rest of the MIB for nodes or operating +on kernel data for leaf nodes. +.Ss Data Structures +For each level of MIB tree kernel header files provide a +.Nm cpp 1 +macro initialiser for an array of the following data structures: +.Bd -literal -offset indent +struct ctlname { + char *ctl_name; /* subsystem name */ + int ctl_type; /* type of name */ +}; +.Ed +.Pp +For example: +.Bd -literal -offset indent +#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 }, \\ + { "user", CTLTYPE_NODE }, \\ + { "ddb", CTLTYPE_NODE }, \\ + { "vfs", CTLTYPE_NODE }, \\ +} +.Ed +.Pp +Each array element initialiser maps the correspondent MIB identifier. +The +.Nm ctl_name +field provides a string name. +The +.Nm ctl_type +field describes the identifier type where possible values are: +.Bl -tag -width CTLTYPE_STRING_ -compact -offset indent +.It CTLTYPE_NODE +The name is a node; +.It CTLTYPE_INT +The name describes an integer; +.It CTLTYPE_STRING +The name describes a string; +.It CTLTYPE_QUAD +The name describes a 64-bit number; +.It CTLTYPE_STRUCT +The name describes a structure. +.El +For each of the types there are two functions provided to perform both +read and write or only a read operations on the identifier (see the +following subsection). +.Pp +These data structures are used by the +.Xr sysctl 8 +program to provide mapping into MIB identifiers. +.Ss Functions +All of the functions perform a write shall +.Ar newp +argument be not +.Nm NULL +pointer and +.Ar newlen +be specifies appropriate data length. +All read-only versions of the functions return +.Nm EPERM +shall a write operation be requested. +.Pp +The following helper functions are provided to aid operating on the +kernel data variables referenced by the leaf nodes in the MIBs: +.Bl -tag -width sysctl_ +.It Fn sysctl_int "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "int *valp" +The variable referenced by the +.Ar valp +is a 32-bit integer. +Read or write returning previous value in the user memory location +pointed by the +.Ar oldp +argument. +The value pointed to by the +.Ar oldlenp +has to be no less then four. +.It Fn sysctl_rdint "void *oldp" "size_t *oldlenp" "void *newp" "int val" +A read-only version of the above. +.\" .It sysctl_int_arr +.It Fn sysctl_quad "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "int64_t *valp" +The variable referenced is a 64-bit integer. +Read or write returning previous value in the user memory location +pointed by the +.Ar oldp +argument. +The value pointed to by the +.Ar oldlenp +has to be no less then eight. +.It Fn sysctl_rdquad "void *oldp" "size_t *oldlenp" "void *newp" "int64_t val" +A read-only version of the above. +.It Fn sysctl_string "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "char *str" "int maxlen" +The variable referenced by the +.Ar str +argument is a string of maximum length of +.Ar maxlen . +Copy out old value into user buffer pointed to by the +.Ar oldp +argument. +If there is not enough space to store that a +.Nm ENOMEM +is returned. +If +.Ar newlen +larger than +.Ar maxlen +a +.Nm EINVAL +error is returned. +.It Fn sysctl_tstring "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "char *str" "int maxlen" +A version of the above that truncates the old value that does not fit +into the buffer provided byt +.Ar oldp +instead of returning +.Nm ENOMEM . +.It Fn sysctl_rdstring "void *oldp" "size_t *oldlenp" "void *newp" "const char *str" +A read-only version of the +.Nm sysctl_string . +.It Fn sysctl_struct "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" "void *sp" "int len" +Aassume the area pointed to by the +.Ar sp +argument be an opaque array of byte of size +.Ar len . +Old and new length checks are performed and data is copied in and/or out. +.It Fn sysctl_rdstruct "void *oldp" "size_t *oldlenp" "void *newp" "const void *sp" "int len" +A read-only version of the above. +.El +.Sh SEE ALSO +.Xr sysctl 3 , +.Xr sysctl.conf 5 , +.Xr sysctl 8 , +.Xr syscall 9 +.Sh HISTORY +These functions first appeared in +.Bx 4.4 . +.\" .Sh AUTHORS diff --git a/share/man/man9/wdog_register.9 b/share/man/man9/wdog_register.9 index 914270999dd..b9345a4f044 100644 --- a/share/man/man9/wdog_register.9 +++ b/share/man/man9/wdog_register.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: wdog_register.9,v 1.2 2005/05/25 07:54:25 david Exp $ +.\" $OpenBSD: wdog_register.9,v 1.3 2006/01/18 14:51:43 mickey Exp $ .\" .\" Copyright (c) 2004 Michael Knudsen <mk@molioner.dk> .\" @@ -57,6 +57,7 @@ The framework is implemented in the file .Pa sys/kern/kern_watchdog.c . .Sh SEE ALSO .Xr watchdog 4 , +.Xr sysctl_int 9 , .Xr timeout 9 .Sh HISTORY The watchdog timer framework was written by |