]>
Commit | Line | Data |
---|---|---|
715f6251 | 1 | /* |
2 | * This file is part of the SPL: Solaris Porting Layer. | |
3 | * | |
4 | * Copyright (c) 2008 Lawrence Livermore National Security, LLC. | |
5 | * Produced at Lawrence Livermore National Laboratory | |
6 | * Written by: | |
7 | * Brian Behlendorf <behlendorf1@llnl.gov>, | |
8 | * Herb Wartens <wartens2@llnl.gov>, | |
9 | * Jim Garlick <garlick@llnl.gov> | |
10 | * UCRL-CODE-235197 | |
11 | * | |
12 | * This is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This is distributed in the hope that it will be useful, but WITHOUT | |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License along | |
23 | * with this program; if not, write to the Free Software Foundation, Inc., | |
24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
25 | */ | |
26 | ||
05ae387b | 27 | #include <sys/sysmacros.h> |
28 | #include <sys/cmn_err.h> | |
29 | #include "config.h" | |
30 | ||
937879f1 | 31 | #ifdef DEBUG_SUBSYSTEM |
32 | #undef DEBUG_SUBSYSTEM | |
33 | #endif | |
34 | ||
35 | #define DEBUG_SUBSYSTEM S_GENERIC | |
36 | ||
cc7449cc | 37 | #ifndef NDEBUG |
05ae387b | 38 | static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" }; |
39 | static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; | |
cc7449cc | 40 | #endif |
05ae387b | 41 | |
42 | void | |
43 | vpanic(const char *fmt, va_list ap) | |
44 | { | |
45 | char msg[MAXMSGLEN]; | |
46 | ||
47 | vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); | |
48 | panic(msg); | |
49 | } /* vpanic() */ | |
50 | EXPORT_SYMBOL(vpanic); | |
51 | ||
52 | void | |
53 | cmn_err(int ce, const char *fmt, ...) | |
54 | { | |
55 | char msg[MAXMSGLEN]; | |
56 | va_list ap; | |
57 | ||
58 | va_start(ap, fmt); | |
59 | vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); | |
60 | va_end(ap); | |
61 | ||
937879f1 | 62 | CERROR("%s", msg); |
05ae387b | 63 | } /* cmn_err() */ |
64 | EXPORT_SYMBOL(cmn_err); | |
65 | ||
66 | void | |
67 | vcmn_err(int ce, const char *fmt, va_list ap) | |
68 | { | |
69 | char msg[MAXMSGLEN]; | |
70 | ||
71 | if (ce == CE_PANIC) | |
72 | vpanic(fmt, ap); | |
73 | ||
74 | if (ce != CE_NOTE) { /* suppress noise in stress testing */ | |
75 | vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); | |
937879f1 | 76 | CERROR("%s%s%s", ce_prefix[ce], msg, ce_suffix[ce]); |
05ae387b | 77 | } |
78 | } /* vcmn_err() */ | |
79 | EXPORT_SYMBOL(vcmn_err); |