17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
59acbbeafSnn35248 * Common Development and Distribution License (the "License").
69acbbeafSnn35248 * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
21*2235c267SYuri Pankov
227c478bd9Sstevel@tonic-gate /*
23d6c90996SAbhinandan Ekande * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25b3a7691dSAlexey Zaytsev *
26*2235c267SYuri Pankov * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
277c478bd9Sstevel@tonic-gate */
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate #include <sys/param.h>
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
327c478bd9Sstevel@tonic-gate #include <sys/inline.h>
337c478bd9Sstevel@tonic-gate #include <sys/varargs.h>
347c478bd9Sstevel@tonic-gate #include <sys/systm.h>
357c478bd9Sstevel@tonic-gate #include <sys/conf.h>
367c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
377c478bd9Sstevel@tonic-gate #include <sys/syslog.h>
387c478bd9Sstevel@tonic-gate #include <sys/log.h>
397c478bd9Sstevel@tonic-gate #include <sys/proc.h>
407c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
417c478bd9Sstevel@tonic-gate #include <sys/session.h>
427c478bd9Sstevel@tonic-gate #include <sys/stream.h>
437c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
447c478bd9Sstevel@tonic-gate #include <sys/kobj.h>
457c478bd9Sstevel@tonic-gate #include <sys/atomic.h>
467c478bd9Sstevel@tonic-gate #include <sys/console.h>
477c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
487c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
497c478bd9Sstevel@tonic-gate #include <sys/reboot.h>
507c478bd9Sstevel@tonic-gate #include <sys/debug.h>
517c478bd9Sstevel@tonic-gate #include <sys/panic.h>
527c478bd9Sstevel@tonic-gate #include <sys/spl.h>
537c478bd9Sstevel@tonic-gate #include <sys/zone.h>
54b3a7691dSAlexey Zaytsev #include <sys/sunddi.h>
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate * In some debugging situations it's useful to log all messages to panicbuf,
587c478bd9Sstevel@tonic-gate * which is persistent across reboots (on most platforms). The range
597c478bd9Sstevel@tonic-gate * panicbuf[panicbuf_log..PANICBUFSIZE-1] may be used for this purpose.
607c478bd9Sstevel@tonic-gate * By default, panicbuf_log == PANICBUFSIZE and no messages are logged.
617c478bd9Sstevel@tonic-gate * To enable panicbuf logging, set panicbuf_log to a small value, say 1K;
627c478bd9Sstevel@tonic-gate * this will reserve 1K for panic information and 7K for message logging.
637c478bd9Sstevel@tonic-gate */
647c478bd9Sstevel@tonic-gate uint32_t panicbuf_log = PANICBUFSIZE;
657c478bd9Sstevel@tonic-gate uint32_t panicbuf_index = PANICBUFSIZE;
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate static int aask, aok;
687c478bd9Sstevel@tonic-gate static int ce_to_sl[CE_IGNORE] = { SL_NOTE, SL_NOTE, SL_WARN, SL_FATAL };
697c478bd9Sstevel@tonic-gate static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" };
707c478bd9Sstevel@tonic-gate static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate static void
cprintf(const char * fmt,va_list adx,int sl,const char * prefix,const char * suffix,void * site,int mid,int sid,int level,zoneid_t zoneid,dev_info_t * dip)737c478bd9Sstevel@tonic-gate cprintf(const char *fmt, va_list adx, int sl, const char *prefix,
747c478bd9Sstevel@tonic-gate const char *suffix, void *site, int mid, int sid, int level,
75ca9a201cSHans Rosenfeld zoneid_t zoneid, dev_info_t *dip)
767c478bd9Sstevel@tonic-gate {
777c478bd9Sstevel@tonic-gate uint32_t msgid;
787c478bd9Sstevel@tonic-gate size_t bufsize = LOG_MSGSIZE;
797c478bd9Sstevel@tonic-gate char buf[LOG_MSGSIZE];
807c478bd9Sstevel@tonic-gate char *bufp = buf;
817c478bd9Sstevel@tonic-gate char *body, *msgp, *bufend;
827c478bd9Sstevel@tonic-gate mblk_t *mp;
837c478bd9Sstevel@tonic-gate int s, on_intr;
847c478bd9Sstevel@tonic-gate size_t len;
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gate s = splhi();
877c478bd9Sstevel@tonic-gate on_intr = CPU_ON_INTR(CPU) ||
887c478bd9Sstevel@tonic-gate (interrupts_unleashed && (spltoipl(s) > LOCK_LEVEL));
897c478bd9Sstevel@tonic-gate splx(s);
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate ASSERT(zoneid == GLOBAL_ZONEID || !on_intr);
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate STRLOG_MAKE_MSGID(fmt, msgid);
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate if (strchr("^!?", fmt[0]) != NULL) {
967c478bd9Sstevel@tonic-gate if (fmt[0] == '^')
977c478bd9Sstevel@tonic-gate sl |= SL_CONSONLY;
987c478bd9Sstevel@tonic-gate else if (fmt[0] == '!' ||
997c478bd9Sstevel@tonic-gate (prefix[0] == '\0' && !(boothowto & RB_VERBOSE)))
1007c478bd9Sstevel@tonic-gate sl = (sl & ~(SL_USER | SL_NOTE)) | SL_LOGONLY;
1017c478bd9Sstevel@tonic-gate fmt++;
1027c478bd9Sstevel@tonic-gate }
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate if ((sl & SL_USER) && (MUTEX_HELD(&pidlock) || on_intr)) {
1057c478bd9Sstevel@tonic-gate zoneid = getzoneid();
1067c478bd9Sstevel@tonic-gate sl = sl & ~(SL_USER | SL_LOGONLY) | SL_CONSOLE;
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate retry:
1107c478bd9Sstevel@tonic-gate bufend = bufp + bufsize;
1117c478bd9Sstevel@tonic-gate msgp = bufp;
1127c478bd9Sstevel@tonic-gate body = msgp += snprintf(msgp, bufend - msgp,
1137c478bd9Sstevel@tonic-gate "%s: [ID %u FACILITY_AND_PRIORITY] ",
1147c478bd9Sstevel@tonic-gate mod_containing_pc(site), msgid);
1157c478bd9Sstevel@tonic-gate msgp += snprintf(msgp, bufend - msgp, prefix);
1162f5a0112SHans Rosenfeld if (dip != NULL)
117ca9a201cSHans Rosenfeld msgp += snprintf(msgp, bufend - msgp, "%s%d: ",
118ca9a201cSHans Rosenfeld ddi_driver_name(dip), ddi_get_instance(dip));
1197c478bd9Sstevel@tonic-gate msgp += vsnprintf(msgp, bufend - msgp, fmt, adx);
1207c478bd9Sstevel@tonic-gate msgp += snprintf(msgp, bufend - msgp, suffix);
1217c478bd9Sstevel@tonic-gate len = strlen(body);
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate if (((sl & SL_CONSONLY) && panicstr) ||
1247c478bd9Sstevel@tonic-gate (zoneid == GLOBAL_ZONEID && log_global.lz_active == 0)) {
1257c478bd9Sstevel@tonic-gate console_printf("%s", body);
1267c478bd9Sstevel@tonic-gate goto out;
1277c478bd9Sstevel@tonic-gate }
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gate if (msgp - bufp >= bufsize && !on_intr) {
1307c478bd9Sstevel@tonic-gate ASSERT(bufp == buf);
1317c478bd9Sstevel@tonic-gate bufsize = msgp - bufp + 1;
1327c478bd9Sstevel@tonic-gate bufp = kmem_alloc(bufsize, KM_NOSLEEP);
1337c478bd9Sstevel@tonic-gate if (bufp != NULL)
1347c478bd9Sstevel@tonic-gate goto retry;
1357c478bd9Sstevel@tonic-gate bufsize = LOG_MSGSIZE;
1367c478bd9Sstevel@tonic-gate bufp = buf;
1377c478bd9Sstevel@tonic-gate }
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate mp = log_makemsg(mid, sid, level, sl, LOG_KERN, bufp,
1407c478bd9Sstevel@tonic-gate MIN(bufsize, msgp - bufp + 1), on_intr);
1417c478bd9Sstevel@tonic-gate if (mp == NULL) {
1427c478bd9Sstevel@tonic-gate if ((sl & (SL_CONSOLE | SL_LOGONLY)) == SL_CONSOLE && !on_intr)
1437c478bd9Sstevel@tonic-gate console_printf("%s", body);
1447c478bd9Sstevel@tonic-gate goto out;
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate if (sl & SL_USER) {
1487c478bd9Sstevel@tonic-gate ssize_t resid;
1499acbbeafSnn35248 sess_t *sp;
1507c478bd9Sstevel@tonic-gate
1519acbbeafSnn35248 if ((sp = tty_hold()) != NULL) {
1529acbbeafSnn35248 if (sp->s_vp != NULL)
1539acbbeafSnn35248 (void) vn_rdwr(UIO_WRITE, sp->s_vp, body,
1549acbbeafSnn35248 len, 0LL, UIO_SYSSPACE, FAPPEND,
1559acbbeafSnn35248 (rlim64_t)LOG_HIWAT, kcred, &resid);
1569acbbeafSnn35248 tty_rele(sp);
1579acbbeafSnn35248 }
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate if (on_intr && !panicstr) {
1617c478bd9Sstevel@tonic-gate (void) putq(log_intrq, mp);
1627c478bd9Sstevel@tonic-gate softcall((void (*)(void *))log_flushq, log_intrq);
1637c478bd9Sstevel@tonic-gate } else {
1647c478bd9Sstevel@tonic-gate log_sendmsg(mp, zoneid);
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate out:
1677c478bd9Sstevel@tonic-gate if (panicbuf_log + len < PANICBUFSIZE) {
1687c478bd9Sstevel@tonic-gate uint32_t old, new;
1697c478bd9Sstevel@tonic-gate do {
1707c478bd9Sstevel@tonic-gate old = panicbuf_index;
1717c478bd9Sstevel@tonic-gate new = old + len;
1727c478bd9Sstevel@tonic-gate if (new >= PANICBUFSIZE)
1737c478bd9Sstevel@tonic-gate new = panicbuf_log + len;
17475d94465SJosef 'Jeff' Sipek } while (atomic_cas_32(&panicbuf_index, old, new) != old);
1757c478bd9Sstevel@tonic-gate bcopy(body, &panicbuf[new - len], len);
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate if (bufp != buf)
1787c478bd9Sstevel@tonic-gate kmem_free(bufp, bufsize);
1797c478bd9Sstevel@tonic-gate }
1807c478bd9Sstevel@tonic-gate
1817c478bd9Sstevel@tonic-gate void
vzprintf(zoneid_t zoneid,const char * fmt,va_list adx)1827c478bd9Sstevel@tonic-gate vzprintf(zoneid_t zoneid, const char *fmt, va_list adx)
1837c478bd9Sstevel@tonic-gate {
1847c478bd9Sstevel@tonic-gate cprintf(fmt, adx, SL_CONSOLE | SL_NOTE, "", "", caller(), 0, 0, 0,
185ca9a201cSHans Rosenfeld zoneid, NULL);
1867c478bd9Sstevel@tonic-gate }
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate void
vprintf(const char * fmt,va_list adx)1897c478bd9Sstevel@tonic-gate vprintf(const char *fmt, va_list adx)
1907c478bd9Sstevel@tonic-gate {
1917c478bd9Sstevel@tonic-gate vzprintf(GLOBAL_ZONEID, fmt, adx);
1927c478bd9Sstevel@tonic-gate }
1937c478bd9Sstevel@tonic-gate
1947c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/
1957c478bd9Sstevel@tonic-gate void
printf(const char * fmt,...)1967c478bd9Sstevel@tonic-gate printf(const char *fmt, ...)
1977c478bd9Sstevel@tonic-gate {
1987c478bd9Sstevel@tonic-gate va_list adx;
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate va_start(adx, fmt);
2017c478bd9Sstevel@tonic-gate cprintf(fmt, adx, SL_CONSOLE | SL_NOTE, "", "", caller(), 0, 0, 0,
202ca9a201cSHans Rosenfeld GLOBAL_ZONEID, NULL);
2037c478bd9Sstevel@tonic-gate va_end(adx);
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate /*PRINTFLIKE2*/
2077c478bd9Sstevel@tonic-gate void
zprintf(zoneid_t zoneid,const char * fmt,...)2087c478bd9Sstevel@tonic-gate zprintf(zoneid_t zoneid, const char *fmt, ...)
2097c478bd9Sstevel@tonic-gate {
2107c478bd9Sstevel@tonic-gate va_list adx;
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate va_start(adx, fmt);
2137c478bd9Sstevel@tonic-gate cprintf(fmt, adx, SL_CONSOLE | SL_NOTE, "", "", caller(), 0, 0, 0,
214ca9a201cSHans Rosenfeld zoneid, NULL);
2157c478bd9Sstevel@tonic-gate va_end(adx);
2167c478bd9Sstevel@tonic-gate }
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gate void
vuprintf(const char * fmt,va_list adx)2197c478bd9Sstevel@tonic-gate vuprintf(const char *fmt, va_list adx)
2207c478bd9Sstevel@tonic-gate {
221d6c90996SAbhinandan Ekande va_list adxcp;
222d6c90996SAbhinandan Ekande va_copy(adxcp, adx);
223d6c90996SAbhinandan Ekande
224d6c90996SAbhinandan Ekande /* Message the user tty, if any, and the global zone syslog */
2257c478bd9Sstevel@tonic-gate cprintf(fmt, adx, SL_CONSOLE | SL_LOGONLY | SL_USER | SL_NOTE,
226ca9a201cSHans Rosenfeld "", "", caller(), 0, 0, 0, GLOBAL_ZONEID, NULL);
227d6c90996SAbhinandan Ekande
228d6c90996SAbhinandan Ekande /* Now message the local zone syslog */
229d6c90996SAbhinandan Ekande if (!INGLOBALZONE(curproc))
230d6c90996SAbhinandan Ekande cprintf(fmt, adxcp, SL_CONSOLE | SL_LOGONLY | SL_NOTE,
231ca9a201cSHans Rosenfeld "", "", caller(), 0, 0, 0, getzoneid(), NULL);
232d6c90996SAbhinandan Ekande
233d6c90996SAbhinandan Ekande va_end(adxcp);
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/
2377c478bd9Sstevel@tonic-gate void
uprintf(const char * fmt,...)2387c478bd9Sstevel@tonic-gate uprintf(const char *fmt, ...)
2397c478bd9Sstevel@tonic-gate {
2407c478bd9Sstevel@tonic-gate va_list adx;
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate va_start(adx, fmt);
243d6c90996SAbhinandan Ekande
244d6c90996SAbhinandan Ekande vuprintf(fmt, adx);
245d6c90996SAbhinandan Ekande
2467c478bd9Sstevel@tonic-gate va_end(adx);
2477c478bd9Sstevel@tonic-gate }
2487c478bd9Sstevel@tonic-gate
249ca9a201cSHans Rosenfeld static void
vzdcmn_err(zoneid_t zoneid,void * site,int ce,const char * fmt,va_list adx,dev_info_t * dip)250*2235c267SYuri Pankov vzdcmn_err(zoneid_t zoneid, void *site, int ce, const char *fmt, va_list adx,
251ca9a201cSHans Rosenfeld dev_info_t *dip)
2527c478bd9Sstevel@tonic-gate {
2537c478bd9Sstevel@tonic-gate if (ce == CE_PANIC)
2547c478bd9Sstevel@tonic-gate vpanic(fmt, adx);
255*2235c267SYuri Pankov if ((uint_t)ce < CE_IGNORE) {
2567c478bd9Sstevel@tonic-gate cprintf(fmt, adx, ce_to_sl[ce] | SL_CONSOLE,
257*2235c267SYuri Pankov ce_prefix[ce], ce_suffix[ce], site, 0, 0, 0,
258ca9a201cSHans Rosenfeld zoneid, dip);
259ca9a201cSHans Rosenfeld }
260*2235c267SYuri Pankov }
261ca9a201cSHans Rosenfeld
262ca9a201cSHans Rosenfeld void
vzcmn_err(zoneid_t zoneid,int ce,const char * fmt,va_list adx)263ca9a201cSHans Rosenfeld vzcmn_err(zoneid_t zoneid, int ce, const char *fmt, va_list adx)
264ca9a201cSHans Rosenfeld {
265*2235c267SYuri Pankov vzdcmn_err(zoneid, caller(), ce, fmt, adx, NULL);
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate void
vcmn_err(int ce,const char * fmt,va_list adx)2697c478bd9Sstevel@tonic-gate vcmn_err(int ce, const char *fmt, va_list adx)
2707c478bd9Sstevel@tonic-gate {
271*2235c267SYuri Pankov vzdcmn_err(GLOBAL_ZONEID, caller(), ce, fmt, adx, NULL);
2727c478bd9Sstevel@tonic-gate }
2737c478bd9Sstevel@tonic-gate
2747c478bd9Sstevel@tonic-gate /*PRINTFLIKE2*/
2757c478bd9Sstevel@tonic-gate void
cmn_err(int ce,const char * fmt,...)2767c478bd9Sstevel@tonic-gate cmn_err(int ce, const char *fmt, ...)
2777c478bd9Sstevel@tonic-gate {
2787c478bd9Sstevel@tonic-gate va_list adx;
2797c478bd9Sstevel@tonic-gate
2807c478bd9Sstevel@tonic-gate va_start(adx, fmt);
281*2235c267SYuri Pankov vzdcmn_err(GLOBAL_ZONEID, caller(), ce, fmt, adx, NULL);
2827c478bd9Sstevel@tonic-gate va_end(adx);
2837c478bd9Sstevel@tonic-gate }
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate /*PRINTFLIKE3*/
2867c478bd9Sstevel@tonic-gate void
zcmn_err(zoneid_t zoneid,int ce,const char * fmt,...)2877c478bd9Sstevel@tonic-gate zcmn_err(zoneid_t zoneid, int ce, const char *fmt, ...)
2887c478bd9Sstevel@tonic-gate {
2897c478bd9Sstevel@tonic-gate va_list adx;
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate va_start(adx, fmt);
292*2235c267SYuri Pankov vzdcmn_err(zoneid, caller(), ce, fmt, adx, NULL);
2937c478bd9Sstevel@tonic-gate va_end(adx);
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate
296b3a7691dSAlexey Zaytsev /*PRINTFLIKE3*/
297b3a7691dSAlexey Zaytsev void
dev_err(dev_info_t * dip,int ce,char * fmt,...)298b3a7691dSAlexey Zaytsev dev_err(dev_info_t *dip, int ce, char *fmt, ...)
299b3a7691dSAlexey Zaytsev {
300ca9a201cSHans Rosenfeld va_list adx;
301b3a7691dSAlexey Zaytsev
302ca9a201cSHans Rosenfeld va_start(adx, fmt);
303*2235c267SYuri Pankov vzdcmn_err(GLOBAL_ZONEID, caller(), ce, fmt, adx, dip);
304ca9a201cSHans Rosenfeld va_end(adx);
305b3a7691dSAlexey Zaytsev }
306b3a7691dSAlexey Zaytsev
3077c478bd9Sstevel@tonic-gate int
assfail(const char * a,const char * f,int l)3087c478bd9Sstevel@tonic-gate assfail(const char *a, const char *f, int l)
3097c478bd9Sstevel@tonic-gate {
3107c478bd9Sstevel@tonic-gate if (aask) {
3117c478bd9Sstevel@tonic-gate printf("ASSERTION CAUGHT: %s, file: %s, line: %d", a, f, l);
3127c478bd9Sstevel@tonic-gate debug_enter(NULL);
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate if (!aok && !panicstr)
3167c478bd9Sstevel@tonic-gate panic("assertion failed: %s, file: %s, line: %d", a, f, l);
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate return (0);
3197c478bd9Sstevel@tonic-gate }
3207c478bd9Sstevel@tonic-gate
321fa9e4066Sahrens void
assfail3(const char * a,uintmax_t lv,const char * op,uintmax_t rv,const char * f,int l)322fa9e4066Sahrens assfail3(const char *a, uintmax_t lv, const char *op, uintmax_t rv,
323fa9e4066Sahrens const char *f, int l)
324fa9e4066Sahrens {
325fa9e4066Sahrens if (aask) {
326fa9e4066Sahrens printf("ASSERTION CAUGHT: %s (0x%llx %s 0x%llx), file: %s, "
327fa9e4066Sahrens "line: %d", a, (u_longlong_t)lv, op, (u_longlong_t)rv,
328fa9e4066Sahrens f, l);
329fa9e4066Sahrens debug_enter(NULL);
330fa9e4066Sahrens }
331fa9e4066Sahrens
332fa9e4066Sahrens if (!aok && !panicstr)
333fa9e4066Sahrens panic("assertion failed: %s (0x%llx %s 0x%llx), file: %s, "
334fa9e4066Sahrens "line: %d", a, (u_longlong_t)lv, op, (u_longlong_t)rv,
335fa9e4066Sahrens f, l);
336fa9e4066Sahrens }
337fa9e4066Sahrens
3387c478bd9Sstevel@tonic-gate int
strlog(short mid,short sid,char level,ushort_t sl,char * fmt,...)3397c478bd9Sstevel@tonic-gate strlog(short mid, short sid, char level, ushort_t sl, char *fmt, ...)
3407c478bd9Sstevel@tonic-gate {
3417c478bd9Sstevel@tonic-gate if (sl & log_global.lz_active) {
3427c478bd9Sstevel@tonic-gate va_list adx;
3437c478bd9Sstevel@tonic-gate va_start(adx, fmt);
3447c478bd9Sstevel@tonic-gate cprintf(fmt, adx, sl, "", "", caller(), mid, sid, level,
345ca9a201cSHans Rosenfeld GLOBAL_ZONEID, NULL);
3467c478bd9Sstevel@tonic-gate va_end(adx);
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate return (1);
3497c478bd9Sstevel@tonic-gate }
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gate int
vstrlog(short mid,short sid,char level,ushort_t sl,char * fmt,va_list adx)3527c478bd9Sstevel@tonic-gate vstrlog(short mid, short sid, char level, ushort_t sl, char *fmt, va_list adx)
3537c478bd9Sstevel@tonic-gate {
3547c478bd9Sstevel@tonic-gate if (sl & log_global.lz_active)
3557c478bd9Sstevel@tonic-gate cprintf(fmt, adx, sl, "", "", caller(), mid, sid, level,
356ca9a201cSHans Rosenfeld GLOBAL_ZONEID, NULL);
3577c478bd9Sstevel@tonic-gate return (1);
3587c478bd9Sstevel@tonic-gate }
359