Sysctls for accessing/clearing the msgbuf */
| 1049 | |
| 1050 | /* Sysctls for accessing/clearing the msgbuf */ |
| 1051 | static int |
| 1052 | sysctl_kern_msgbuf(SYSCTL_HANDLER_ARGS) |
| 1053 | { |
| 1054 | char buf[128]; |
| 1055 | u_int seq; |
| 1056 | int error, len; |
| 1057 | |
| 1058 | error = priv_check(req->td, PRIV_MSGBUF); |
| 1059 | if (error) |
| 1060 | return (error); |
| 1061 | |
| 1062 | /* Read the whole buffer, one chunk at a time. */ |
| 1063 | mtx_lock(&msgbuf_lock); |
| 1064 | msgbuf_peekbytes(msgbufp, NULL, 0, &seq); |
| 1065 | for (;;) { |
| 1066 | len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq); |
| 1067 | mtx_unlock(&msgbuf_lock); |
| 1068 | if (len == 0) |
| 1069 | return (SYSCTL_OUT(req, "", 1)); /* add nulterm */ |
| 1070 | |
| 1071 | error = sysctl_handle_opaque(oidp, buf, len, req); |
| 1072 | if (error) |
| 1073 | return (error); |
| 1074 | |
| 1075 | mtx_lock(&msgbuf_lock); |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | SYSCTL_PROC(_kern, OID_AUTO, msgbuf, |
| 1080 | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, |
nothing calls this directly
no test coverage detected