Add sysctl_rename_oid() to support device_set_unit() usage. Otherwise,
when unit numbers are changed, the sysctl devinfo tree gets out of sync and duplicate trees are attempted to be attached with the original name.
This commit is contained in:
parent
eb63e604ea
commit
cd17ceaab8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174113
@ -414,6 +414,25 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
|
||||
return (oidp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename an existing oid.
|
||||
*/
|
||||
void
|
||||
sysctl_rename_oid(struct sysctl_oid *oidp, const char *name)
|
||||
{
|
||||
ssize_t len;
|
||||
char *newname;
|
||||
void *oldname;
|
||||
|
||||
oldname = (void *)(uintptr_t)(const void *)oidp->oid_name;
|
||||
len = strlen(name);
|
||||
newname = malloc(len + 1, M_SYSCTLOID, M_WAITOK);
|
||||
bcopy(name, newname, len + 1);
|
||||
newname[len] = '\0';
|
||||
oidp->oid_name = newname;
|
||||
free(oldname, M_SYSCTLOID);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reparent an existing oid.
|
||||
*/
|
||||
|
@ -647,6 +647,7 @@ 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);
|
||||
void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user