These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.\"
|
2000-10-27 16:05:39 +00:00
|
|
|
.\" Copyright (c) 2000, Andrzej Bialecki <abial@FreeBSD.org>
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2014-07-31 17:18:40 +00:00
|
|
|
.Dd July 31, 2014
|
2000-07-19 06:33:34 +00:00
|
|
|
.Dt SYSCTL_CTX_INIT 9
|
|
|
|
.Os
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm sysctl_ctx_init ,
|
|
|
|
.Nm sysctl_ctx_free ,
|
|
|
|
.Nm sysctl_ctx_entry_add ,
|
|
|
|
.Nm sysctl_ctx_entry_find ,
|
2000-07-19 06:33:34 +00:00
|
|
|
.Nm sysctl_ctx_entry_del
|
2014-07-31 17:18:40 +00:00
|
|
|
.Nd "sysctl context for managing dynamically created sysctl OIDs"
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In sys/sysctl.h
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Ft int
|
|
|
|
.Fo sysctl_ctx_init
|
|
|
|
.Fa "struct sysctl_ctx_list *clist"
|
|
|
|
.Fc
|
|
|
|
.Ft int
|
|
|
|
.Fo sysctl_ctx_free
|
|
|
|
.Fa "struct sysctl_ctx_list *clist"
|
|
|
|
.Fc
|
|
|
|
.Ft struct sysctl_ctx_entry *
|
|
|
|
.Fo sysctl_ctx_entry_add
|
|
|
|
.Fa "struct sysctl_ctx_list *clist"
|
|
|
|
.Fa "struct sysctl_oid *oidp"
|
|
|
|
.Fc
|
|
|
|
.Ft struct sysctl_ctx_entry *
|
|
|
|
.Fo sysctl_ctx_entry_find
|
|
|
|
.Fa "struct sysctl_ctx_list *clist"
|
|
|
|
.Fa "struct sysctl_oid *oidp"
|
|
|
|
.Fc
|
|
|
|
.Ft int
|
|
|
|
.Fo sysctl_ctx_entry_del
|
|
|
|
.Fa "struct sysctl_ctx_list *clist"
|
|
|
|
.Fa "struct sysctl_oid *oidp"
|
|
|
|
.Fc
|
|
|
|
.Sh DESCRIPTION
|
2000-07-19 06:33:34 +00:00
|
|
|
These functions provide an interface
|
2014-07-31 17:18:40 +00:00
|
|
|
for managing dynamically created OIDs.
|
|
|
|
The sysctl context is responsible for keeping track of created OIDs,
|
2000-07-19 06:33:34 +00:00
|
|
|
as well as their proper removal when needed.
|
2014-07-31 17:18:40 +00:00
|
|
|
It adds a simple transactional aspect to OID removal operations;
|
2004-07-03 18:29:24 +00:00
|
|
|
i.e., if a removal operation fails part way,
|
2000-07-19 06:33:34 +00:00
|
|
|
it is possible to roll back the sysctl tree
|
|
|
|
to its previous state.
|
|
|
|
.Pp
|
|
|
|
The
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Fn sysctl_ctx_init
|
2000-07-19 06:33:34 +00:00
|
|
|
function initializes a sysctl context.
|
|
|
|
The
|
|
|
|
.Fa clist
|
|
|
|
argument must point to an already allocated variable.
|
|
|
|
A context
|
|
|
|
.Em must
|
|
|
|
be initialized before use.
|
|
|
|
Once it is initialized,
|
|
|
|
a pointer to the context can be passed as an argument to all the
|
|
|
|
.Fa SYSCTL_ADD_*
|
|
|
|
macros (see
|
|
|
|
.Xr sysctl_add_oid 9 ) ,
|
2014-07-31 17:18:40 +00:00
|
|
|
and it will be updated with entries pointing to newly created OIDS.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Pp
|
2000-07-19 06:33:34 +00:00
|
|
|
Internally, the context is represented as a
|
|
|
|
.Xr queue 3
|
|
|
|
TAILQ linked list.
|
|
|
|
The list consists of
|
|
|
|
.Li struct sysctl_ctx_entry
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
entries:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct sysctl_ctx_entry {
|
|
|
|
struct sysctl_oid *entry;
|
|
|
|
TAILQ_ENTRY(sysctl_ctx_entry) link;
|
|
|
|
};
|
|
|
|
|
|
|
|
TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2014-07-31 17:18:40 +00:00
|
|
|
Each context entry points to one dynamic OID that it manages.
|
|
|
|
Newly created OIDs are always inserted in the front of the list.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Pp
|
2000-07-19 06:33:34 +00:00
|
|
|
The
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Fn sysctl_ctx_free
|
2014-07-31 17:18:40 +00:00
|
|
|
function removes the context and associated OIDs it manages.
|
2002-01-09 11:43:48 +00:00
|
|
|
If the function completes successfully,
|
2014-07-31 17:18:40 +00:00
|
|
|
all managed OIDs have been unregistered
|
2000-07-19 06:33:34 +00:00
|
|
|
(removed from the tree)
|
|
|
|
and freed,
|
|
|
|
together with all their allocated memory,
|
|
|
|
and the entries of the context have been freed as well.
|
|
|
|
.Pp
|
|
|
|
The removal operation is performed in two steps.
|
|
|
|
First, for each context entry, the function
|
|
|
|
.Xr sysctl_remove_oid 9
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
is executed, with parameter
|
2000-07-19 06:33:34 +00:00
|
|
|
.Fa del
|
|
|
|
set to 0, which inhibits the freeing of resources.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
If there are no errors during this step,
|
2000-07-19 06:33:34 +00:00
|
|
|
.Fn sysctl_ctx_free
|
|
|
|
proceeds to the next step.
|
|
|
|
If the first step fails,
|
2014-07-31 17:18:40 +00:00
|
|
|
all unregistered OIDs associated with the context are registered again.
|
2000-07-19 06:33:34 +00:00
|
|
|
.Pp
|
|
|
|
.Em Note :
|
|
|
|
in most cases, the programmer specifies
|
|
|
|
.Dv OID_AUTO
|
2014-07-31 17:18:40 +00:00
|
|
|
as the OID number when creating an OID.
|
|
|
|
However, during registration of the OID in the tree,
|
2000-07-19 06:33:34 +00:00
|
|
|
this number is changed to the first available number
|
2012-03-29 05:02:12 +00:00
|
|
|
greater than or equal to
|
2007-07-27 19:55:42 +00:00
|
|
|
.Dv CTL_AUTO_START .
|
2000-07-19 06:33:34 +00:00
|
|
|
If the first step of context deletion fails,
|
2014-07-31 17:18:40 +00:00
|
|
|
re-registration of the OID does not change the already assigned OID number
|
2000-07-19 06:33:34 +00:00
|
|
|
(which is different from OID_AUTO).
|
|
|
|
This ensures that re-registered entries
|
|
|
|
maintain their original positions in the tree.
|
|
|
|
.Pp
|
2014-07-31 17:18:40 +00:00
|
|
|
The second step actually performs the deletion of the dynamic OIDs.
|
2000-07-19 06:33:34 +00:00
|
|
|
.Xr sysctl_remove_oid 9
|
|
|
|
iterates through the context list,
|
2004-07-03 18:29:24 +00:00
|
|
|
starting from beginning (i.e., the newest entries).
|
2000-07-19 06:33:34 +00:00
|
|
|
.Em Important :
|
2014-07-31 17:18:40 +00:00
|
|
|
this time, the function not only deletes the OIDs from the tree,
|
2000-07-19 06:33:34 +00:00
|
|
|
but also frees their memory (provided that oid_refcnt == 0),
|
|
|
|
as well as the memory of all context entries.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn sysctl_ctx_entry_add
|
2014-07-31 17:18:40 +00:00
|
|
|
function allows the addition of an existing dynamic OID to a context.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn sysctl_ctx_entry_del
|
2000-07-19 06:33:34 +00:00
|
|
|
function removes an entry from the context.
|
|
|
|
.Em Important :
|
|
|
|
in this case, only the corresponding
|
|
|
|
.Li struct sysctl_ctx_entry
|
|
|
|
is freed, but the
|
|
|
|
.Fa oidp
|
|
|
|
pointer remains intact.
|
|
|
|
Thereafter, the programmer is responsible for managing the resources
|
2014-07-31 17:18:40 +00:00
|
|
|
allocated to this OID.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn sysctl_ctx_entry_find
|
2000-07-19 06:33:34 +00:00
|
|
|
function searches for a given
|
|
|
|
.Fa oidp
|
2002-01-09 11:43:48 +00:00
|
|
|
within a context list,
|
2000-07-19 06:33:34 +00:00
|
|
|
either returning a pointer to the
|
|
|
|
.Fa struct sysctl_ctx_entry
|
|
|
|
found,
|
|
|
|
or
|
|
|
|
.Dv NULL .
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh EXAMPLES
|
2000-07-19 06:33:34 +00:00
|
|
|
The following is an example of how to create a new top-level category
|
|
|
|
and how to hook up another subtree to an existing static node.
|
2014-07-31 17:18:40 +00:00
|
|
|
This example uses contexts to keep track of the OIDs.
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Bd -literal
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
...
|
2014-07-31 17:18:40 +00:00
|
|
|
static struct sysctl_ctx_list clist;
|
|
|
|
static struct sysctl_oid *oidp;
|
|
|
|
static int a_int;
|
|
|
|
static const char *string = "dynamic sysctl";
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
sysctl_ctx_init(&clist);
|
2014-07-31 17:18:40 +00:00
|
|
|
oidp = SYSCTL_ADD_ROOT_NODE(&clist,
|
2010-11-02 12:40:13 +00:00
|
|
|
OID_AUTO, "newtree", CTLFLAG_RW, 0, "new top level tree");
|
|
|
|
oidp = SYSCTL_ADD_INT(&clist, SYSCTL_CHILDREN(oidp),
|
2004-04-06 20:16:10 +00:00
|
|
|
OID_AUTO, "newint", CTLFLAG_RW, &a_int, 0, "new int leaf");
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
...
|
2010-11-02 12:40:13 +00:00
|
|
|
oidp = SYSCTL_ADD_NODE(&clist, SYSCTL_STATIC_CHILDREN(_debug),
|
|
|
|
OID_AUTO, "newtree", CTLFLAG_RW, 0, "new tree under debug");
|
|
|
|
oidp = SYSCTL_ADD_STRING(&clist, SYSCTL_CHILDREN(oidp),
|
|
|
|
OID_AUTO, "newstring", CTLFLAG_RD, string, 0, "new string leaf");
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
...
|
2014-07-31 17:18:40 +00:00
|
|
|
/* Now we can free up the OIDs */
|
2010-11-02 12:40:13 +00:00
|
|
|
if (sysctl_ctx_free(&clist)) {
|
2014-07-31 17:18:40 +00:00
|
|
|
printf("can't free this context - other OIDs depend on it");
|
2010-11-02 12:40:13 +00:00
|
|
|
return (ENOTEMPTY);
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
} else {
|
2010-11-02 12:40:13 +00:00
|
|
|
printf("Success!\\n");
|
|
|
|
return (0);
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
This example creates the following subtrees:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
debug.newtree.newstring
|
|
|
|
newtree.newint
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2000-07-19 06:33:34 +00:00
|
|
|
Note that both trees are removed, and their resources freed,
|
|
|
|
through one
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Fn sysctl_ctx_free
|
2000-07-19 06:33:34 +00:00
|
|
|
call, which starts by freeing the newest entries (leaves)
|
|
|
|
and then proceeds to free the older entries (in this case the nodes).
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh SEE ALSO
|
2000-07-19 06:33:34 +00:00
|
|
|
.Xr queue 3 ,
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Xr sysctl 8 ,
|
2006-04-28 10:45:27 +00:00
|
|
|
.Xr sysctl 9 ,
|
2000-07-19 06:33:34 +00:00
|
|
|
.Xr sysctl_add_oid 9 ,
|
|
|
|
.Xr sysctl_remove_oid 9
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh HISTORY
|
2000-07-19 06:33:34 +00:00
|
|
|
These functions first appeared in
|
2001-08-01 12:15:21 +00:00
|
|
|
.Fx 4.2 .
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh AUTHORS
|
2014-06-26 21:44:30 +00:00
|
|
|
.An Andrzej Bialecki Aq Mt abial@FreeBSD.org
|
These patches implement dynamic sysctls. It's possible now to add
and remove sysctl oids at will during runtime - they don't rely on
linker sets. Also, the node oids can be referenced by more than
one kernel user, which means that it's possible to create partially
overlapping trees.
Add sysctl contexts to help programmers manage multiple dynamic
oids in convenient way.
Please see the manpages for detailed discussion, and example module
for typical use.
This work is based on ideas and code snippets coming from many
people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson,
Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like
to specially thank Brian Feldman for detailed review and style
fixes.
PR: kern/16928
Reviewed by: dfr, green, phk
2000-07-15 10:26:04 +00:00
|
|
|
.Sh BUGS
|
2000-07-19 06:33:34 +00:00
|
|
|
The current removal algorithm is somewhat heavy.
|
|
|
|
In the worst case,
|
2014-07-31 17:18:40 +00:00
|
|
|
all OIDs need to be unregistered, registered again,
|
2000-07-19 06:33:34 +00:00
|
|
|
and then unregistered and deleted.
|
|
|
|
However, the algorithm does guarantee transactional properties
|
|
|
|
for removal operations.
|
|
|
|
.Pp
|
|
|
|
All operations on contexts involve linked list traversal.
|
|
|
|
For this reason,
|
|
|
|
creation and removal of entries is relatively costly.
|