Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add a new kern.messages sysctl to allow kernel message verbo...
details: https://anonhg.NetBSD.org/src/rev/bd4f9bb20e8b
branches: trunk
changeset: 345525:bd4f9bb20e8b
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue May 31 05:44:19 2016 +0000
description:
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.
diffstat:
share/man/man7/sysctl.7 | 17 +++++++++-
sys/kern/init_sysctl.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 91 insertions(+), 4 deletions(-)
diffs (165 lines):
diff -r 583b74ff0081 -r bd4f9bb20e8b share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7 Tue May 31 04:14:12 2016 +0000
+++ b/share/man/man7/sysctl.7 Tue May 31 05:44:19 2016 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysctl.7,v 1.101 2016/05/25 20:47:57 wiz Exp $
+.\" $NetBSD: sysctl.7,v 1.102 2016/05/31 05:44:19 pgoyette Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\"
-.Dd May 25, 2016
+.Dd May 31, 2016
.Dt SYSCTL 7
.Os
.Sh NAME
@@ -315,6 +315,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
@@ -739,6 +740,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.
diff -r 583b74ff0081 -r bd4f9bb20e8b sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c Tue May 31 04:14:12 2016 +0000
+++ b/sys/kern/init_sysctl.c Tue May 31 05:44:19 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_sysctl.c,v 1.210 2015/11/09 01:21:18 pgoyette Exp $ */
+/* $NetBSD: init_sysctl.c,v 1.211 2016/05/31 05:44:19 pgoyette Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.210 2015/11/09 01:21:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.211 2016/05/31 05:44:19 pgoyette Exp $");
#include "opt_sysv.h"
#include "opt_compat_netbsd.h"
@@ -56,6 +56,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>
@@ -110,6 +111,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);
@@ -590,6 +592,12 @@
SYSCTL_DESCR("Information from build environment"),
NULL, 0, __UNCONST(buildinfo), 0,
CTL_KERN, 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_misc_setup, "sysctl hw subtree misc setup")
@@ -760,6 +768,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
Home |
Main Index |
Thread Index |
Old Index