NetBSD Problem Report #46539
From www@NetBSD.org Mon Jun 4 05:56:33 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 0694F63BEE1
for <gnats-bugs@gnats.NetBSD.org>; Mon, 4 Jun 2012 05:56:33 +0000 (UTC)
Message-Id: <20120604055631.7E1E063BA27@www.NetBSD.org>
Date: Mon, 4 Jun 2012 05:56:31 +0000 (UTC)
From: nathanialsloss@yahoo.com.au
Reply-To: nathanialsloss@yahoo.com.au
To: gnats-bugs@NetBSD.org
Subject: Kernel messages: sysctl to change verbosity
X-Send-Pr-Version: www-1.0
>Number: 46539
>Category: kern
>Synopsis: Kernel messages: sysctl to change verbosity
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: pgoyette
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Jun 04 06:00:01 +0000 2012
>Closed-Date: Tue May 31 05:46:12 +0000 2016
>Last-Modified: Tue May 31 05:46:12 +0000 2016
>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.
>Release-Note:
>Audit-Trail:
From: Jukka Ruohonen <jruohonen@iki.fi>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/46539: Kernel messages: sysctl to change verbosity
Date: Mon, 4 Jun 2012 09:08:24 +0300
On Mon, Jun 04, 2012 at 09:04:29AM +0300, Jukka Ruohonen wrote:
>
> > I would also like to ask if it is considered could NetBSD 6 be pulled up
> > as this feature is very useful.
>
> Documentation in sysctl(7) manual page is missing.
>
From: Nat Sloss <nathanialsloss@yahoo.com.au>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/46539: Kernel messages: sysctl to change verbosity
Date: Mon, 4 Jun 2012 18:41:52 +1000
Hi.
I've modified sysctl.7 with the settings.
This is my first attempt at such a thing, I hope you like it :)
Index: share/man/man7/sysctl.7
===================================================================
RCS file: /cvsroot/src/share/man/man7/sysctl.7,v
retrieving revision 1.69
diff -u -r1.69 sysctl.7
--- share/man/man7/sysctl.7 22 Mar 2012 07:58:18 -0000 1.69
+++ share/man/man7/sysctl.7 4 Jun 2012 08:40:48 -0000
@@ -311,6 +311,7 @@
.It kern.maxproc integer yes
.It kern.maxptys integer yes
.It kern.maxvnodes integer yes
+.It kern.messages integer yes
.It kern.mbuf node not applicable
.It kern.memlock integer no
.It kern.memlock_range integer no
@@ -729,6 +730,18 @@
.St -p1003.1b-93
Memory Protection Option is available on this system,
otherwise\ 0.
+.It Li kern.messages
+Kernel console message verbosity.
+See
+.Sy \<sys/reboot.h\>
+.Bl -column "verbosity" "setting" -offset indent
+.It Sy Verbosity Setting
+.It \ \ \ \ 0 Silent Sy AB_SILENT
+.It \ \ \ \ 1 Quiet Sy AB_QUIET
+.It \ \ \ \ 2 Normal Sy AB_NORMAL
+.It \ \ \ \ 3 Verbose Sy AB_VERBOSE
+.It \ \ \ \ 4 Debug Sy AB_DEBUG
+.El
.It Li kern.module
Settings related to kernel modules.
The third level names for the settings are described below.
Note: This submission is my own work which I submit under the NetBSD license.
Where do I find out more about man page macros etc like ".Sy"?
Regards,
Nat.
From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/46539: Kernel messages: sysctl to change verbosity
Date: Mon, 4 Jun 2012 11:38:07 +0200
On Mon, Jun 04, 2012 at 08:50:04AM +0000, Nat Sloss wrote:
> Where do I find out more about man page macros etc like ".Sy"?
man 7 mdoc
Thomas
Responsible-Changed-From-To: kern-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Tue, 31 May 2016 01:02:37 +0000
Responsible-Changed-Why:
I'll integrate the enclosed patches.
From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/46539 CVS commit: src
Date: Tue, 31 May 2016 05:44:19 +0000
Module Name: src
Committed By: pgoyette
Date: Tue May 31 05:44:19 UTC 2016
Modified Files:
src/share/man/man7: sysctl.7
src/sys/kern: init_sysctl.c
Log Message:
Add a new kern.messages sysctl to allow kernel message verbosity to be
altered after boot.
Fixes PR kern/46539 using patch submitted by Nat Sloss.
To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.210 -r1.211 src/sys/kern/init_sysctl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 31 May 2016 05:46:12 +0000
State-Changed-Why:
Patch has been committed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.