diff options
author | Peter Wemm <peter@FreeBSD.org> | 2007-11-30 21:29:08 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2007-11-30 21:29:08 +0000 |
commit | cd17ceaab8065e3073d30c35e92c6556c99121a2 (patch) | |
tree | fa5a1febb46ea7a786316238e6e1cd3b887169d7 /sys/kern/kern_sysctl.c | |
parent | eb63e604ea287ed64a1f0d5ad0dc137af8ffa31f (diff) | |
download | src-cd17ceaab8065e3073d30c35e92c6556c99121a2.tar.gz src-cd17ceaab8065e3073d30c35e92c6556c99121a2.zip |
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.
Notes
Notes:
svn path=/head/; revision=174113
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2ce6f7e4607d..d71c746a0881 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -415,6 +415,25 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, } /* + * 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. */ int |