]> git.proxmox.com Git - mirror_spl.git/blame - modules/spl/spl-err.c
Update SPL to use new debug infrastructure. This means:
[mirror_spl.git] / modules / spl / spl-err.c
CommitLineData
05ae387b 1#include <sys/sysmacros.h>
2#include <sys/cmn_err.h>
3#include "config.h"
4
937879f1 5#ifdef DEBUG_SUBSYSTEM
6#undef DEBUG_SUBSYSTEM
7#endif
8
9#define DEBUG_SUBSYSTEM S_GENERIC
10
05ae387b 11static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" };
12static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
13
14void
15vpanic(const char *fmt, va_list ap)
16{
17 char msg[MAXMSGLEN];
18
19 vsnprintf(msg, MAXMSGLEN - 1, fmt, ap);
20 panic(msg);
21} /* vpanic() */
22EXPORT_SYMBOL(vpanic);
23
24void
25cmn_err(int ce, const char *fmt, ...)
26{
27 char msg[MAXMSGLEN];
28 va_list ap;
29
30 va_start(ap, fmt);
31 vsnprintf(msg, MAXMSGLEN - 1, fmt, ap);
32 va_end(ap);
33
937879f1 34 CERROR("%s", msg);
05ae387b 35} /* cmn_err() */
36EXPORT_SYMBOL(cmn_err);
37
38void
39vcmn_err(int ce, const char *fmt, va_list ap)
40{
41 char msg[MAXMSGLEN];
42
43 if (ce == CE_PANIC)
44 vpanic(fmt, ap);
45
46 if (ce != CE_NOTE) { /* suppress noise in stress testing */
47 vsnprintf(msg, MAXMSGLEN - 1, fmt, ap);
937879f1 48 CERROR("%s%s%s", ce_prefix[ce], msg, ce_suffix[ce]);
05ae387b 49 }
50} /* vcmn_err() */
51EXPORT_SYMBOL(vcmn_err);