NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/46539: Kernel messages: sysctl to change verbosity
>Number: 46539
>Category: kern
>Synopsis: Kernel messages: sysctl to change verbosity
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Jun 04 06:00:01 +0000 2012
>Originator: Nat Sloss
>Release: NetBSD Current 6.99.7
>Organization:
>Environment:
NetBSD beast 6.99.7 NetBSD 6.99.7 (LOCKDEBUG) #59: Mon Jun 4 13:15:47 EST 2012
build@beast:/usr/src/sys/arch/i386/compile/obj/LOCKDEBUG i386
>Description:
I like the splash screen feature and I boot silently to suppress kernel boot up
messages, but I would also like to see kernel messages once booted up.
>How-To-Repeat:
Boot up silently (-z) and you then have no way to get kernel messages back on
the console.
>Fix:
I patched init_sysctl.c to add a sysctl to alter boothowto to change kernel
message verbosity from 0 silent to 4 debug.
So here's my patch:
Index: sys/kern/init_sysctl.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_sysctl.c,v
retrieving revision 1.189
diff -u -r1.189 init_sysctl.c
--- sys/kern/init_sysctl.c 7 Apr 2012 05:38:49 -0000 1.189
+++ sys/kern/init_sysctl.c 4 Jun 2012 05:41:24 -0000
@@ -57,6 +57,7 @@
#include <sys/filedesc.h>
#include <sys/tty.h>
#include <sys/kmem.h>
+#include <sys/reboot.h>
#include <sys/resource.h>
#include <sys/resourcevar.h>
#include <sys/exec.h>
@@ -145,6 +146,7 @@
static int sysctl_kern_trigger_panic(SYSCTLFN_PROTO);
#endif
static int sysctl_kern_maxvnodes(SYSCTLFN_PROTO);
+static int sysctl_kern_messages(SYSCTLFN_PROTO);
static int sysctl_kern_rtc_offset(SYSCTLFN_PROTO);
static int sysctl_kern_maxproc(SYSCTLFN_PROTO);
static int sysctl_kern_hostid(SYSCTLFN_PROTO);
@@ -747,6 +749,12 @@
SYSCTL_DESCR("Maximal number of semaphores"),
NULL, 0, &ksem_max, 0,
CTL_CREATE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "messages",
+ SYSCTL_DESCR("Kernel message verbosity"),
+ sysctl_kern_messages, 0, NULL, 0,
+ CTL_KERN, CTL_CREATE, CTL_EOL);
}
SYSCTL_SETUP(sysctl_hw_setup, "sysctl hw subtree setup")
@@ -989,6 +997,72 @@
}
/*
+ * sysctl helper routine for kern.messages.
+ * Alters boothowto to display kernel messages in increasing verbosity
+ * from 0 to 4.
+ */
+
+#define MAXMESSAGES 4
+static int
+sysctl_kern_messages(SYSCTLFN_ARGS)
+{
+ int error, messageverbose, messagemask, newboothowto;
+ struct sysctlnode node;
+
+ messagemask = (AB_NORMAL|AB_QUIET|AB_SILENT|AB_VERBOSE|AB_DEBUG);
+ switch (boothowto & messagemask) {
+ case AB_SILENT:
+ messageverbose = 0;
+ break;
+ case AB_QUIET:
+ messageverbose = 1;
+ break;
+ case AB_VERBOSE:
+ messageverbose = 3;
+ break;
+ case AB_DEBUG:
+ messageverbose = 4;
+ break;
+ case AB_NORMAL:
+ default:
+ messageverbose = 2;
+ }
+
+ node = *rnode;
+ node.sysctl_data = &messageverbose;
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error || newp == NULL)
+ return (error);
+ if (messageverbose < 0 || messageverbose > MAXMESSAGES)
+ return EINVAL;
+
+ /* Set boothowto */
+ newboothowto = boothowto & ~messagemask;
+
+ switch (messageverbose) {
+ case 0:
+ newboothowto |= AB_SILENT;
+ break;
+ case 1:
+ newboothowto |= AB_QUIET;
+ break;
+ case 3:
+ newboothowto |= AB_VERBOSE;
+ break;
+ case 4:
+ newboothowto |= AB_DEBUG;
+ break;
+ case 2:
+ default: /* Messages default to normal. */
+ break;
+ }
+
+ boothowto = newboothowto;
+
+ return (0);
+}
+
+/*
* sysctl helper routine for rtc_offset - set time after changes
*/
static int
Note: This patch is my own work which I submit under the NetBSD license.
I would also like to ask if it is considered could NetBSD 6 be pulled up as
this feature is very useful.
Regards,
Nat.
Home |
Main Index |
Thread Index |
Old Index