Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add aprint_error(), which is like aprint_normal(), but a...
details: https://anonhg.NetBSD.org/src/rev/97a82634dbbe
branches: trunk
changeset: 541048:97a82634dbbe
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Dec 31 23:45:36 2002 +0000
description:
Add aprint_error(), which is like aprint_normal(), but also records
the number of times it is called. This allows subsystems to report
the number of errors that occurred during a quiet/silent subsystem
startup. aprint_get_error_count() reports this count and resets it
to 0.
Also add printf_nolog(), which is like printf(), but prevents the
output from hitting the system log.
diffstat:
sys/kern/subr_prf.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++-
sys/sys/systm.h | 12 +++++-
2 files changed, 110 insertions(+), 3 deletions(-)
diffs (175 lines):
diff -r b7dce2323a10 -r 97a82634dbbe sys/kern/subr_prf.c
--- a/sys/kern/subr_prf.c Tue Dec 31 22:47:48 2002 +0000
+++ b/sys/kern/subr_prf.c Tue Dec 31 23:45:36 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_prf.c,v 1.88 2002/12/31 17:48:03 thorpej Exp $ */
+/* $NetBSD: subr_prf.c,v 1.89 2002/12/31 23:45:36 thorpej Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.88 2002/12/31 17:48:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.89 2002/12/31 23:45:36 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_ipkdb.h"
@@ -155,6 +155,25 @@
}
/*
+ * twiddle: spin a little propellor on the console.
+ */
+
+void
+twiddle(void)
+{
+ static const char twiddle_chars[] = "|/-\\";
+ static int pos;
+ int s;
+
+ KPRINTF_MUTEX_ENTER(s);
+
+ putchar(twiddle_chars[pos++ & 3], TOCONS, NULL);
+ putchar('\b', TOCONS, NULL);
+
+ KPRINTF_MUTEX_EXIT(s);
+}
+
+/*
* panic: handle an unresolvable fatal error
*
* prints "panic: <message>" and reboots. if called twice (i.e. recursive
@@ -619,6 +638,59 @@
}
/*
+ * aprint_error: Send to console unless AB_QUIET. Always goes
+ * to the log. Also counts the number of times called so other
+ * parts of the kernel can report the number of errors during a
+ * given phase of system startup.
+ */
+static int aprint_error_count;
+
+int
+aprint_get_error_count(void)
+{
+ int count, s;
+
+ KPRINTF_MUTEX_ENTER(s);
+
+ count = aprint_error_count;
+ aprint_error_count = 0;
+
+ KPRINTF_MUTEX_EXIT(s);
+
+ return (count);
+}
+
+void
+#ifdef __STDC__
+aprint_error(const char *fmt, ...)
+#else
+aprint_error(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
+{
+ va_list ap;
+ int s, flags = TOLOG;
+
+ if ((boothowto & (AB_SILENT|AB_QUIET)) == 0 ||
+ (boothowto & AB_VERBOSE) != 0)
+ flags |= TOCONS;
+
+ KPRINTF_MUTEX_ENTER(s);
+
+ aprint_error_count++;
+
+ va_start(ap, fmt);
+ kprintf(fmt, flags, NULL, NULL, ap);
+ va_end(ap);
+
+ KPRINTF_MUTEX_EXIT(s);
+
+ if (!panicstr)
+ logwakeup();
+}
+
+/*
* aprint_naive: Send to console only if AB_QUIET. Never goes
* to the log.
*/
@@ -703,6 +775,31 @@
}
/*
+ * printf_nolog: Like printf(), but does not send message to the log.
+ */
+
+void
+#ifdef __STDC__
+printf_nolog(const char *fmt, ...)
+#else
+printf_nolog(fmt, va_alist)
+ char *fmt;
+ va_dcl;
+#endif
+{
+ va_list ap;
+ int s;
+
+ KPRINTF_MUTEX_ENTER(s);
+
+ va_start(ap, fmt);
+ kprintf(fmt, TOCONS, NULL, NULL, ap);
+ va_end(ap);
+
+ KPRINTF_MUTEX_EXIT(s);
+}
+
+/*
* normal kernel printf functions: printf, vprintf, snprintf, vsnprintf
*/
diff -r b7dce2323a10 -r 97a82634dbbe sys/sys/systm.h
--- a/sys/sys/systm.h Tue Dec 31 22:47:48 2002 +0000
+++ b/sys/sys/systm.h Tue Dec 31 23:45:36 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.154 2002/12/31 17:48:04 thorpej Exp $ */
+/* $NetBSD: systm.h,v 1.155 2002/12/31 23:45:36 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -182,12 +182,20 @@
#ifdef _KERNEL
void aprint_normal __P((const char *, ...))
__attribute__((__format__(__printf__,1,2)));
+void aprint_error __P((const char *, ...))
+ __attribute__((__format__(__printf__,1,2)));
void aprint_naive __P((const char *, ...))
__attribute__((__format__(__printf__,1,2)));
void aprint_verbose __P((const char *, ...))
__attribute__((__format__(__printf__,1,2)));
void aprint_debug __P((const char *, ...))
__attribute__((__format__(__printf__,1,2)));
+
+int aprint_get_error_count __P((void));
+
+void printf_nolog __P((const char *, ...))
+ __attribute__((__format__(__printf__,1,2)));
+
void printf __P((const char *, ...))
__attribute__((__format__(__printf__,1,2)));
int sprintf __P((char *, const char *, ...))
@@ -198,6 +206,8 @@
int vsprintf __P((char *, const char *, _BSD_VA_LIST_));
int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_));
int humanize_number __P((char *, size_t, u_int64_t, const char *, int));
+
+void twiddle __P((void));
#endif /* _KERNEL */
void panic __P((const char *, ...))
Home |
Main Index |
Thread Index |
Old Index