summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortmm <tmm@FreeBSD.org>2001-07-03 19:44:07 +0000
committertmm <tmm@FreeBSD.org>2001-07-03 19:44:07 +0000
commit6dd375961b07fa6608ebb267904bfd314b0e4c55 (patch)
treed8e729d020ba0e0a230b079811d64621eb089600
parent16f7cc2d2283209c8013c00af6771c98240991ee (diff)
downloadFreeBSD-src-6dd375961b07fa6608ebb267904bfd314b0e4c55.zip
FreeBSD-src-6dd375961b07fa6608ebb267904bfd314b0e4c55.tar.gz
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.
-rw-r--r--sys/amd64/amd64/machdep.c42
-rw-r--r--sys/i386/i386/machdep.c42
-rw-r--r--sys/kern/subr_prf.c45
3 files changed, 45 insertions, 84 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index e5eb21e..73b8052 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -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;
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index e5eb21e..73b8052 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -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;
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 86a53766..3ce2d7d 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -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>
OpenPOWER on IntegriCloud