Add sysctl_move_oid() which reparents an existing OID.
This commit is contained in:
parent
b7db4d0723
commit
21885af505
@ -415,6 +415,26 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
|
|||||||
return (oidp);
|
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.
|
* Register the kernel's oids on startup.
|
||||||
*/
|
*/
|
||||||
|
@ -603,6 +603,8 @@ struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,
|
|||||||
int kind, void *arg1, int arg2,
|
int kind, void *arg1, int arg2,
|
||||||
int (*handler) (SYSCTL_HANDLER_ARGS),
|
int (*handler) (SYSCTL_HANDLER_ARGS),
|
||||||
const char *fmt, const char *descr);
|
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_remove_oid(struct sysctl_oid *oidp, int del, int recurse);
|
||||||
int sysctl_ctx_init(struct sysctl_ctx_list *clist);
|
int sysctl_ctx_init(struct sysctl_ctx_list *clist);
|
||||||
int sysctl_ctx_free(struct sysctl_ctx_list *clist);
|
int sysctl_ctx_free(struct sysctl_ctx_list *clist);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user