summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabial <abial@FreeBSD.org>1998-09-29 11:20:16 +0000
committerabial <abial@FreeBSD.org>1998-09-29 11:20:16 +0000
commit68f6143093387a48263cbf7a14bc2dbd77f508f1 (patch)
tree9521540c0c76c8bd58a681ae27653b5c840f959d
parentc461716e6acb521d277ae6a3d823ce53cdaaacc3 (diff)
downloadFreeBSD-src-68f6143093387a48263cbf7a14bc2dbd77f508f1.zip
FreeBSD-src-68f6143093387a48263cbf7a14bc2dbd77f508f1.tar.gz
Add sysctl 'machdep.msgbuf_clear'. Setting it to anything causes the
kernel message buffer to be cleared. It comes handy in situations when the only logging facility you have is the msgbuf. Reviewed by: jkh
-rw-r--r--sys/amd64/amd64/machdep.c29
-rw-r--r--sys/i386/i386/machdep.c29
2 files changed, 50 insertions, 8 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 37bc7dc..d2d2025 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $Id: machdep.c,v 1.309 1998/09/14 22:43:32 jdp Exp $
+ * $Id: machdep.c,v 1.310 1998/09/25 17:34:48 peter Exp $
*/
#include "apm.h"
@@ -207,8 +207,8 @@ sysctl_machdep_msgbuf SYSCTL_HANDLER_ARGS
{
int error;
- /* Unwind the buffer, so that is linear (possibly starting with
- * some initial nulls.
+ /* 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);
@@ -221,7 +221,28 @@ sysctl_machdep_msgbuf SYSCTL_HANDLER_ARGS
}
SYSCTL_PROC(_machdep, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD,
- 0, 0, sysctl_machdep_msgbuf, "A","");
+ 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 bootverbose = 0, Maxmem = 0;
long dumplo;
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 37bc7dc..d2d2025 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $Id: machdep.c,v 1.309 1998/09/14 22:43:32 jdp Exp $
+ * $Id: machdep.c,v 1.310 1998/09/25 17:34:48 peter Exp $
*/
#include "apm.h"
@@ -207,8 +207,8 @@ sysctl_machdep_msgbuf SYSCTL_HANDLER_ARGS
{
int error;
- /* Unwind the buffer, so that is linear (possibly starting with
- * some initial nulls.
+ /* 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);
@@ -221,7 +221,28 @@ sysctl_machdep_msgbuf SYSCTL_HANDLER_ARGS
}
SYSCTL_PROC(_machdep, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD,
- 0, 0, sysctl_machdep_msgbuf, "A","");
+ 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 bootverbose = 0, Maxmem = 0;
long dumplo;
OpenPOWER on IntegriCloud