* Handle kernel failpoint set/get. */
| 865 | * Handle kernel failpoint set/get. |
| 866 | */ |
| 867 | int |
| 868 | fail_point_sysctl(SYSCTL_HANDLER_ARGS) |
| 869 | { |
| 870 | struct fail_point *fp; |
| 871 | char *buf; |
| 872 | struct sbuf sb, *sb_check; |
| 873 | int error; |
| 874 | |
| 875 | buf = NULL; |
| 876 | error = 0; |
| 877 | fp = arg1; |
| 878 | |
| 879 | sb_check = sbuf_new(&sb, NULL, 1024, SBUF_AUTOEXTEND); |
| 880 | if (sb_check != &sb) |
| 881 | return (ENOMEM); |
| 882 | |
| 883 | sbuf_set_drain(&sb, (sbuf_drain_func *)fail_sysctl_drain_func, req); |
| 884 | |
| 885 | /* Setting */ |
| 886 | /** |
| 887 | * Lock protects any new entries from being garbage collected before we |
| 888 | * can link them to the fail point. |
| 889 | */ |
| 890 | sx_xlock(&sx_fp_set); |
| 891 | if (req->newptr) { |
| 892 | if (req->newlen > MAX_FAIL_POINT_BUF) { |
| 893 | error = EINVAL; |
| 894 | goto out; |
| 895 | } |
| 896 | |
| 897 | buf = fp_malloc(req->newlen + 1, M_WAITOK); |
| 898 | |
| 899 | error = SYSCTL_IN(req, buf, req->newlen); |
| 900 | if (error) |
| 901 | goto out; |
| 902 | buf[req->newlen] = '\0'; |
| 903 | |
| 904 | error = fail_point_set(fp, buf); |
| 905 | } |
| 906 | |
| 907 | fail_point_garbage_collect(); |
| 908 | sx_xunlock(&sx_fp_set); |
| 909 | |
| 910 | /* Retrieving. */ |
| 911 | fail_point_get(fp, &sb, false); |
| 912 | |
| 913 | out: |
| 914 | sbuf_finish(&sb); |
| 915 | sbuf_delete(&sb); |
| 916 | |
| 917 | if (buf) |
| 918 | fp_free(buf); |
| 919 | |
| 920 | return (error); |
| 921 | } |
| 922 | |
| 923 | int |
| 924 | fail_point_sysctl_status(SYSCTL_HANDLER_ARGS) |
nothing calls this directly
no test coverage detected