1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

Make the code to read the kernel message buffer via sysctl machine-

independent and rename the corresponding sysctls from machdep.msgbuf and
machdep.msgbuf_clear (i386 only) to kern.msgbuf and kern.msgbuf_clear.
This commit is contained in:
Thomas Moestl 2001-07-03 19:44:07 +00:00
parent 4b68082379
commit 948d3d9484
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=79153
3 changed files with 45 additions and 84 deletions

View File

@ -184,48 +184,6 @@ sysctl_hw_availpages(SYSCTL_HANDLER_ARGS)
SYSCTL_PROC(_hw, OID_AUTO, availpages, CTLTYPE_INT|CTLFLAG_RD,
0, 0, sysctl_hw_availpages, "I", "");
static int
sysctl_machdep_msgbuf(SYSCTL_HANDLER_ARGS)
{
int error;
/* Unwind the buffer, so that it's linear (possibly starting with
* some initial nulls).
*/
error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr+msgbufp->msg_bufr,
msgbufp->msg_size-msgbufp->msg_bufr,req);
if(error) return(error);
if(msgbufp->msg_bufr>0) {
error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr,
msgbufp->msg_bufr,req);
}
return(error);
}
SYSCTL_PROC(_machdep, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD,
0, 0, sysctl_machdep_msgbuf, "A","Contents of kernel message buffer");
static int msgbuf_clear;
static int
sysctl_machdep_msgbuf_clear(SYSCTL_HANDLER_ARGS)
{
int error;
error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
req);
if (!error && req->newptr) {
/* Clear the buffer and reset write pointer */
bzero(msgbufp->msg_ptr,msgbufp->msg_size);
msgbufp->msg_bufr=msgbufp->msg_bufx=0;
msgbuf_clear=0;
}
return (error);
}
SYSCTL_PROC(_machdep, OID_AUTO, msgbuf_clear, CTLTYPE_INT|CTLFLAG_RW,
&msgbuf_clear, 0, sysctl_machdep_msgbuf_clear, "I",
"Clear kernel message buffer");
int Maxmem = 0;
long dumplo;

View File

@ -184,48 +184,6 @@ sysctl_hw_availpages(SYSCTL_HANDLER_ARGS)
SYSCTL_PROC(_hw, OID_AUTO, availpages, CTLTYPE_INT|CTLFLAG_RD,
0, 0, sysctl_hw_availpages, "I", "");
static int
sysctl_machdep_msgbuf(SYSCTL_HANDLER_ARGS)
{
int error;
/* Unwind the buffer, so that it's linear (possibly starting with
* some initial nulls).
*/
error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr+msgbufp->msg_bufr,
msgbufp->msg_size-msgbufp->msg_bufr,req);
if(error) return(error);
if(msgbufp->msg_bufr>0) {
error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr,
msgbufp->msg_bufr,req);
}
return(error);
}
SYSCTL_PROC(_machdep, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD,
0, 0, sysctl_machdep_msgbuf, "A","Contents of kernel message buffer");
static int msgbuf_clear;
static int
sysctl_machdep_msgbuf_clear(SYSCTL_HANDLER_ARGS)
{
int error;
error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
req);
if (!error && req->newptr) {
/* Clear the buffer and reset write pointer */
bzero(msgbufp->msg_ptr,msgbufp->msg_size);
msgbufp->msg_bufr=msgbufp->msg_bufx=0;
msgbuf_clear=0;
}
return (error);
}
SYSCTL_PROC(_machdep, OID_AUTO, msgbuf_clear, CTLTYPE_INT|CTLFLAG_RW,
&msgbuf_clear, 0, sysctl_machdep_msgbuf_clear, "I",
"Clear kernel message buffer");
int Maxmem = 0;
long dumplo;

View File

@ -49,6 +49,7 @@
#include <sys/syslog.h>
#include <sys/cons.h>
#include <sys/uio.h>
#include <sys/sysctl.h>
/*
* Note that stdarg.h and the ANSI style va_start macro is used for both
@ -814,6 +815,50 @@ msgbufinit(void *ptr, size_t size)
oldp = msgbufp;
}
/* Sysctls for accessing/clearing the msgbuf */
static int
sysctl_kern_msgbuf(SYSCTL_HANDLER_ARGS)
{
int error;
/*
* Unwind the buffer, so that it's linear (possibly starting with
* some initial nulls).
*/
error = sysctl_handle_opaque(oidp, msgbufp->msg_ptr + msgbufp->msg_bufx,
msgbufp->msg_size - msgbufp->msg_bufx, req);
if (error)
return (error);
if (msgbufp->msg_bufx > 0) {
error = sysctl_handle_opaque(oidp, msgbufp->msg_ptr,
msgbufp->msg_bufx, req);
}
return (error);
}
SYSCTL_PROC(_kern, OID_AUTO, msgbuf, CTLTYPE_STRING | CTLFLAG_RD,
0, 0, sysctl_kern_msgbuf, "A", "Contents of kernel message buffer");
static int msgbuf_clear;
static int
sysctl_kern_msgbuf_clear(SYSCTL_HANDLER_ARGS)
{
int error;
error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
if (!error && req->newptr) {
/* Clear the buffer and reset write pointer */
bzero(msgbufp->msg_ptr, msgbufp->msg_size);
msgbufp->msg_bufr = msgbufp->msg_bufx = 0;
msgbuf_clear = 0;
}
return (error);
}
SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0,
sysctl_kern_msgbuf_clear, "I", "Clear kernel message buffer");
#include "opt_ddb.h"
#ifdef DDB
#include <ddb/ddb.h>