Add sysctl_move_oid() which reparents an existing OID.

This commit is contained in:
Dag-Erling Smørgrav 2004-02-27 17:13:23 +00:00
parent b7db4d0723
commit 21885af505
2 changed files with 22 additions and 0 deletions

View File

@ -415,6 +415,26 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
return (oidp);
}
/*
* Reparent an existing oid.
*/
int
sysctl_move_oid(struct sysctl_oid *oid, struct sysctl_oid_list *parent)
{
struct sysctl_oid *oidp;
if (oid->oid_parent == parent)
return (0);
oidp = sysctl_find_oidname(oid->oid_name, parent);
if (oidp != NULL)
return (EEXIST);
sysctl_unregister_oid(oid);
oid->oid_parent = parent;
oid->oid_number = OID_AUTO;
sysctl_register_oid(oid);
return (0);
}
/*
* Register the kernel's oids on startup.
*/

View File

@ -603,6 +603,8 @@ struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,
int kind, void *arg1, int arg2,
int (*handler) (SYSCTL_HANDLER_ARGS),
const char *fmt, const char *descr);
int sysctl_move_oid(struct sysctl_oid *oidp,
struct sysctl_oid_list *parent);
int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse);
int sysctl_ctx_init(struct sysctl_ctx_list *clist);
int sysctl_ctx_free(struct sysctl_ctx_list *clist);