]>
Commit | Line | Data |
---|---|---|
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 | ||
cc7449cc | 11 | #ifndef NDEBUG |
05ae387b | 12 | static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" }; |
13 | static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; | |
cc7449cc | 14 | #endif |
05ae387b | 15 | |
16 | void | |
17 | vpanic(const char *fmt, va_list ap) | |
18 | { | |
19 | char msg[MAXMSGLEN]; | |
20 | ||
21 | vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); | |
22 | panic(msg); | |
23 | } /* vpanic() */ | |
24 | EXPORT_SYMBOL(vpanic); | |
25 | ||
26 | void | |
27 | cmn_err(int ce, const char *fmt, ...) | |
28 | { | |
29 | char msg[MAXMSGLEN]; | |
30 | va_list ap; | |
31 | ||
32 | va_start(ap, fmt); | |
33 | vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); | |
34 | va_end(ap); | |
35 | ||
937879f1 | 36 | CERROR("%s", msg); |
05ae387b | 37 | } /* cmn_err() */ |
38 | EXPORT_SYMBOL(cmn_err); | |
39 | ||
40 | void | |
41 | vcmn_err(int ce, const char *fmt, va_list ap) | |
42 | { | |
43 | char msg[MAXMSGLEN]; | |
44 | ||
45 | if (ce == CE_PANIC) | |
46 | vpanic(fmt, ap); | |
47 | ||
48 | if (ce != CE_NOTE) { /* suppress noise in stress testing */ | |
49 | vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); | |
937879f1 | 50 | CERROR("%s%s%s", ce_prefix[ce], msg, ce_suffix[ce]); |
05ae387b | 51 | } |
52 | } /* vcmn_err() */ | |
53 | EXPORT_SYMBOL(vcmn_err); |