1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3 * CDDL HEADER START
4 *
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or https://opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 *
22 * $FreeBSD$
23 */
24 /*
25 * Copyright 2007 John Birrell <jb@FreeBSD.org>. All rights reserved.
26 * Copyright 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
27 */
28
29 #include <sys/cdefs.h>
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/cmn_err.h>
33
34 void
vcmn_err(int ce,const char * fmt,va_list adx)35 vcmn_err(int ce, const char *fmt, va_list adx)
36 {
37 char buf[256];
38 const char *prefix;
39
40 prefix = NULL; /* silence unwitty compilers */
41 switch (ce) {
42 case CE_CONT:
43 prefix = "Solaris(cont): ";
44 break;
45 case CE_NOTE:
46 prefix = "Solaris: NOTICE: ";
47 break;
48 case CE_WARN:
49 prefix = "Solaris: WARNING: ";
50 break;
51 case CE_PANIC:
52 prefix = "Solaris(panic): ";
53 break;
54 case CE_IGNORE:
55 break;
56 default:
57 panic("Solaris: unknown severity level");
58 }
59 if (ce == CE_PANIC) {
60 vsnprintf(buf, sizeof (buf), fmt, adx);
61 panic("%s%s", prefix, buf);
62 }
63 if (ce != CE_IGNORE) {
64 printf("%s", prefix);
65 vprintf(fmt, adx);
66 printf("\n");
67 }
68 }
69
70 void
cmn_err(int type,const char * fmt,...)71 cmn_err(int type, const char *fmt, ...)
72 {
73 va_list ap;
74
75 va_start(ap, fmt);
76 vcmn_err(type, fmt, ap);
77 va_end(ap);
78 }
79