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.
This commit is contained in:
parent
89ef67a28c
commit
f631b51555
|
@ -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"
|
||||
|
@ -154,6 +154,25 @@ tablefull(tab, hint)
|
|||
log(LOG_ERR, "%s: table is full\n", tab);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
|
@ -618,6 +637,59 @@ aprint_normal(fmt, va_alist)
|
|||
logwakeup();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
@ -702,6 +774,31 @@ aprint_debug(fmt, va_alist)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
|
|
@ -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 @@ int sys_nosys __P((struct proc *, void *, register_t *));
|
|||
#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 @@ void vprintf __P((const char *, _BSD_VA_LIST_));
|
|||
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 *, ...))
|
||||
|
|
Loading…
Reference in New Issue