Changeset View
Changeset View
Standalone View
Standalone View
sys/ddb/db_script.c
Show All 12 Lines | |||||
} | } | ||||
mtx_unlock(&db_script_mtx); | mtx_unlock(&db_script_mtx); | ||||
sbuf_finish(&sb); | sbuf_finish(&sb); | ||||
error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb) + 1); | error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb) + 1); | ||||
sbuf_delete(&sb); | sbuf_delete(&sb); | ||||
free(buffer, M_TEMP); | free(buffer, M_TEMP); | ||||
return (error); | return (error); | ||||
} | } | ||||
SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, scripts, CTLTYPE_STRING | | SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, scripts, | ||||
CTLFLAG_RD, 0, 0, sysctl_debug_ddb_scripting_scripts, "A", | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, | ||||
0, 0, sysctl_debug_ddb_scripting_scripts, "A", | |||||
"List of defined scripts"); | "List of defined scripts"); | ||||
static int | static int | ||||
sysctl_debug_ddb_scripting_script(SYSCTL_HANDLER_ARGS) | sysctl_debug_ddb_scripting_script(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
char *buffer, *script, *scriptname; | char *buffer, *script, *scriptname; | ||||
int error, len; | int error, len; | ||||
Show All 19 Lines | |||||
} | } | ||||
mtx_lock(&db_script_mtx); | mtx_lock(&db_script_mtx); | ||||
error = db_script_set(scriptname, script); | error = db_script_set(scriptname, script); | ||||
mtx_unlock(&db_script_mtx); | mtx_unlock(&db_script_mtx); | ||||
out: | out: | ||||
free(buffer, M_TEMP); | free(buffer, M_TEMP); | ||||
return (error); | return (error); | ||||
} | } | ||||
SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, script, CTLTYPE_STRING | | SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, script, | ||||
CTLFLAG_RW, 0, 0, sysctl_debug_ddb_scripting_script, "A", | CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
0, 0, sysctl_debug_ddb_scripting_script, "A", | |||||
"Set a script"); | "Set a script"); | ||||
/* | /* | ||||
* debug.ddb.scripting.unscript has somewhat unusual sysctl semantics -- set | * debug.ddb.scripting.unscript has somewhat unusual sysctl semantics -- set | ||||
* the name of the script that you want to delete. | * the name of the script that you want to delete. | ||||
*/ | */ | ||||
static int | static int | ||||
sysctl_debug_ddb_scripting_unscript(SYSCTL_HANDLER_ARGS) | sysctl_debug_ddb_scripting_unscript(SYSCTL_HANDLER_ARGS) | ||||
Show All 9 Lines | |||||
return (0); | return (0); | ||||
mtx_lock(&db_script_mtx); | mtx_lock(&db_script_mtx); | ||||
error = db_script_unset(name); | error = db_script_unset(name); | ||||
mtx_unlock(&db_script_mtx); | mtx_unlock(&db_script_mtx); | ||||
if (error == ENOENT) | if (error == ENOENT) | ||||
return (EINVAL); /* Don't confuse sysctl consumers. */ | return (EINVAL); /* Don't confuse sysctl consumers. */ | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, unscript, CTLTYPE_STRING | | SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, unscript, | ||||
CTLFLAG_RW, 0, 0, sysctl_debug_ddb_scripting_unscript, "A", | CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
0, 0, sysctl_debug_ddb_scripting_unscript, "A", | |||||
"Unset a script"); | "Unset a script"); | ||||
Context not available. |