Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sysctl.c
Show First 20 Lines • Show All 672 Lines • ▼ Show 20 Lines | if (del) { | ||||
*/ | */ | ||||
while (oidp->oid_running > 0) { | while (oidp->oid_running > 0) { | ||||
oidp->oid_kind |= CTLFLAG_DYING; | oidp->oid_kind |= CTLFLAG_DYING; | ||||
SYSCTL_SLEEP(&oidp->oid_running, "oidrm", 0); | SYSCTL_SLEEP(&oidp->oid_running, "oidrm", 0); | ||||
} | } | ||||
if (oidp->oid_descr) | if (oidp->oid_descr) | ||||
free(__DECONST(char *, oidp->oid_descr), | free(__DECONST(char *, oidp->oid_descr), | ||||
M_SYSCTLOID); | M_SYSCTLOID); | ||||
if (oidp->oid_label) | |||||
free(__DECONST(char *, oidp->oid_label), | |||||
M_SYSCTLOID); | |||||
free(__DECONST(char *, oidp->oid_name), M_SYSCTLOID); | free(__DECONST(char *, oidp->oid_name), M_SYSCTLOID); | ||||
free(oidp, M_SYSCTLOID); | free(oidp, M_SYSCTLOID); | ||||
} | } | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Create new sysctls at run time. | * Create new sysctls at run time. | ||||
* clist may point to a valid context initialized with sysctl_ctx_init(). | * clist may point to a valid context initialized with sysctl_ctx_init(). | ||||
*/ | */ | ||||
struct sysctl_oid * | struct sysctl_oid * | ||||
sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, | sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, | ||||
int number, const char *name, int kind, void *arg1, intmax_t arg2, | int number, const char *name, int kind, void *arg1, intmax_t arg2, | ||||
int (*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr) | int (*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr, | ||||
const char *label) | |||||
{ | { | ||||
struct sysctl_oid *oidp; | struct sysctl_oid *oidp; | ||||
/* You have to hook up somewhere.. */ | /* You have to hook up somewhere.. */ | ||||
if (parent == NULL) | if (parent == NULL) | ||||
return(NULL); | return(NULL); | ||||
/* Check if the node already exists, otherwise create it */ | /* Check if the node already exists, otherwise create it */ | ||||
SYSCTL_WLOCK(); | SYSCTL_WLOCK(); | ||||
Show All 20 Lines | sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, | ||||
oidp->oid_name = strdup(name, M_SYSCTLOID); | oidp->oid_name = strdup(name, M_SYSCTLOID); | ||||
oidp->oid_handler = handler; | oidp->oid_handler = handler; | ||||
oidp->oid_kind = CTLFLAG_DYN | kind; | oidp->oid_kind = CTLFLAG_DYN | kind; | ||||
oidp->oid_arg1 = arg1; | oidp->oid_arg1 = arg1; | ||||
oidp->oid_arg2 = arg2; | oidp->oid_arg2 = arg2; | ||||
oidp->oid_fmt = fmt; | oidp->oid_fmt = fmt; | ||||
if (descr != NULL) | if (descr != NULL) | ||||
oidp->oid_descr = strdup(descr, M_SYSCTLOID); | oidp->oid_descr = strdup(descr, M_SYSCTLOID); | ||||
if (label != NULL) | |||||
oidp->oid_label = strdup(label, M_SYSCTLOID); | |||||
/* Update the context, if used */ | /* Update the context, if used */ | ||||
if (clist != NULL) | if (clist != NULL) | ||||
sysctl_ctx_entry_add(clist, oidp); | sysctl_ctx_entry_add(clist, oidp); | ||||
/* Register this oid */ | /* Register this oid */ | ||||
sysctl_register_oid(oidp); | sysctl_register_oid(oidp); | ||||
SYSCTL_WUNLOCK(); | SYSCTL_WUNLOCK(); | ||||
return (oidp); | return (oidp); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | sysctl_sysctl_oiddescr(SYSCTL_HANDLER_ARGS) | ||||
error = SYSCTL_OUT(req, oid->oid_descr, strlen(oid->oid_descr) + 1); | error = SYSCTL_OUT(req, oid->oid_descr, strlen(oid->oid_descr) + 1); | ||||
out: | out: | ||||
SYSCTL_RUNLOCK(&tracker); | SYSCTL_RUNLOCK(&tracker); | ||||
return (error); | return (error); | ||||
} | } | ||||
static SYSCTL_NODE(_sysctl, 5, oiddescr, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, | static SYSCTL_NODE(_sysctl, 5, oiddescr, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, | ||||
sysctl_sysctl_oiddescr, ""); | sysctl_sysctl_oiddescr, ""); | ||||
static int | |||||
sysctl_sysctl_oidlabel(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
struct sysctl_oid *oid; | |||||
struct rm_priotracker tracker; | |||||
int error; | |||||
SYSCTL_RLOCK(&tracker); | |||||
error = sysctl_find_oid(arg1, arg2, &oid, NULL, req); | |||||
if (error) | |||||
goto out; | |||||
if (oid->oid_label == NULL) { | |||||
error = ENOENT; | |||||
goto out; | |||||
} | |||||
error = SYSCTL_OUT(req, oid->oid_label, strlen(oid->oid_label) + 1); | |||||
out: | |||||
SYSCTL_RUNLOCK(&tracker); | |||||
return (error); | |||||
} | |||||
static SYSCTL_NODE(_sysctl, 6, oidlabel, | |||||
CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, sysctl_sysctl_oidlabel, ""); | |||||
/* | /* | ||||
* Default "handler" functions. | * Default "handler" functions. | ||||
*/ | */ | ||||
/* | /* | ||||
* Handle a bool. | * Handle a bool. | ||||
* Two cases: | * Two cases: | ||||
▲ Show 20 Lines • Show All 845 Lines • Show Last 20 Lines |