Print this page
8115 parallel zfs mount
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libfakekernel/common/printf.c
+++ new/usr/src/lib/libfakekernel/common/printf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 24 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 + * Copyright 2017 RackTop Systems.
25 26 */
26 27
27 28 #include <sys/param.h>
28 29 #include <sys/types.h>
29 30 #include <sys/varargs.h>
30 31 #include <sys/systm.h>
31 32 #include <sys/cmn_err.h>
32 33 #include <sys/log.h>
33 34
34 35 #include <fakekernel.h>
35 36
36 37 void abort(void) __NORETURN;
37 38
38 39 char *volatile panicstr;
39 40 va_list panicargs;
40 41 char panicbuf[512];
41 42
42 43 volatile int aok;
43 44
44 45 static const int
45 46 ce_flags[CE_IGNORE] = { SL_NOTE, SL_NOTE, SL_WARN, SL_FATAL };
46 47 static const char
47 48 ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" };
48 49 static const char
49 50 ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
50 51
51 52
52 53 /*
53 54 * This function is just a stub, exported NODIRECT so that
54 55 * comsumers like fksmbd can provide their own.
55 56 * (One that actually prints the messages.)
56 57 *
57 58 * It's used by fakekernel_cprintf() below.
58 59 * The flags are SL_... from strlog.h
59 60 */
60 61 /* ARGSUSED */
61 62 void
62 63 fakekernel_putlog(char *msg, size_t len, int flags)
63 64 {
64 65 }
65 66
66 67 /*
67 68 * fakekernel_cprintf() corresponds to os/printf.c:cprintf()
68 69 * This formats the message and calls fakekernel_putlog().
69 70 * It's exported NODIRECT to allow replacment.
70 71 * The flags are SL_... from strlog.h
71 72 */
72 73 void
73 74 fakekernel_cprintf(const char *fmt, va_list adx, int flags,
74 75 const char *prefix, const char *suffix)
75 76 {
76 77 size_t bufsize = LOG_MSGSIZE;
77 78 char buf[LOG_MSGSIZE];
78 79 char *bufp = buf;
79 80 char *msgp, *bufend;
80 81 size_t len;
81 82
82 83 if (strchr("^!?", fmt[0]) != NULL) {
83 84 if (fmt[0] == '^')
84 85 flags |= SL_CONSONLY;
85 86 else if (fmt[0] == '!')
86 87 flags |= SL_LOGONLY;
87 88 fmt++;
88 89 }
89 90
90 91 bufend = bufp + bufsize;
91 92 msgp = bufp;
92 93 msgp += snprintf(msgp, bufend - msgp, "[fake_kernel] ");
93 94 msgp += snprintf(msgp, bufend - msgp, prefix);
94 95 msgp += vsnprintf(msgp, bufend - msgp, fmt, adx);
95 96 msgp += snprintf(msgp, bufend - msgp, suffix);
96 97 len = msgp - bufp;
97 98
98 99 fakekernel_putlog(bufp, len, flags);
99 100 }
100 101
101 102 /*
102 103 * "User-level crash dump", if you will.
103 104 */
104 105 void
105 106 vpanic(const char *fmt, va_list adx)
106 107 {
107 108 va_list tmpargs;
108 109
109 110 panicstr = (char *)fmt;
110 111 va_copy(panicargs, adx);
111 112
112 113 va_copy(tmpargs, adx);
113 114 fakekernel_cprintf(fmt, tmpargs, SL_FATAL, "fatal: ", "\n");
114 115
115 116 /* Call libc`assfail() so that mdb ::status works */
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
116 117 (void) vsnprintf(panicbuf, sizeof (panicbuf), fmt, adx);
117 118 assfail(panicbuf, "(panic)", 0);
118 119
119 120 abort(); /* avoid "noreturn" warnings */
120 121 }
121 122
122 123 void
123 124 panic(const char *fmt, ...)
124 125 {
125 126 va_list adx;
127 +
128 + va_start(adx, fmt);
129 + vpanic(fmt, adx);
130 + va_end(adx);
131 +}
132 +
133 +void
134 +fm_panic(const char *fmt, ...)
135 +{
136 + va_list adx;
126 137
127 138 va_start(adx, fmt);
128 139 vpanic(fmt, adx);
129 140 va_end(adx);
130 141 }
131 142
132 143 void
133 144 vcmn_err(int ce, const char *fmt, va_list adx)
134 145 {
135 146
136 147 if (ce == CE_PANIC)
137 148 vpanic(fmt, adx);
138 149 if (ce >= CE_IGNORE)
139 150 return;
140 151
141 152 fakekernel_cprintf(fmt, adx, ce_flags[ce] | SL_CONSOLE,
142 153 ce_prefix[ce], ce_suffix[ce]);
143 154 }
144 155
145 156 /*PRINTFLIKE2*/
146 157 void
147 158 cmn_err(int ce, const char *fmt, ...)
148 159 {
149 160 va_list adx;
150 161
151 162 va_start(adx, fmt);
152 163 vcmn_err(ce, fmt, adx);
153 164 va_end(adx);
154 165 }
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX