| 502 | "List of defined scripts"); |
| 503 | |
| 504 | static int |
| 505 | sysctl_debug_ddb_scripting_script(SYSCTL_HANDLER_ARGS) |
| 506 | { |
| 507 | char *buffer, *script, *scriptname; |
| 508 | int error, len; |
| 509 | |
| 510 | /* |
| 511 | * Maximum length for an input string is DB_MAXSCRIPTNAME + '=' |
| 512 | * symbol + DB_MAXSCRIPT. |
| 513 | */ |
| 514 | len = DB_MAXSCRIPTNAME + DB_MAXSCRIPTLEN + 1; |
| 515 | buffer = malloc(len, M_TEMP, M_WAITOK | M_ZERO); |
| 516 | error = sysctl_handle_string(oidp, buffer, len, req); |
| 517 | if (error) |
| 518 | goto out; |
| 519 | |
| 520 | /* |
| 521 | * Argument will be in form scriptname=script, so split into the |
| 522 | * scriptname and script. |
| 523 | */ |
| 524 | script = buffer; |
| 525 | scriptname = strsep(&script, "="); |
| 526 | if (script == NULL) { |
| 527 | error = EINVAL; |
| 528 | goto out; |
| 529 | } |
| 530 | mtx_lock(&db_script_mtx); |
| 531 | error = db_script_set(scriptname, script); |
| 532 | mtx_unlock(&db_script_mtx); |
| 533 | out: |
| 534 | free(buffer, M_TEMP); |
| 535 | return (error); |
| 536 | } |
| 537 | SYSCTL_PROC(_debug_ddb_scripting, OID_AUTO, script, |
| 538 | CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, |
| 539 | sysctl_debug_ddb_scripting_script, "A", |
nothing calls this directly
no test coverage detected