b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * CDDL HEADER START
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The contents of this file are subject to the terms of the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Common Development and Distribution License (the "License").
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You may not use this file except in compliance with the License.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * See the License for the specific language governing permissions
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * and limitations under the License.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * When distributing Covered Code, include this CDDL HEADER in each
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * If applicable, add the following below this CDDL HEADER, with the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner]
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * CDDL HEADER END
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright (c) 2012 by Delphix. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossstatic const int
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossce_flags[CE_IGNORE] = { SL_NOTE, SL_NOTE, SL_WARN, SL_FATAL };
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossstatic const char
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" };
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossstatic const char
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * This function is just a stub, exported NODIRECT so that
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * comsumers like fksmbd can provide their own.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * (One that actually prints the messages.)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * It's used by fakekernel_cprintf() below.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The flags are SL_... from strlog.h
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/* ARGSUSED */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossfakekernel_putlog(char *msg, size_t len, int flags)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * fakekernel_cprintf() corresponds to os/printf.c:cprintf()
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * This formats the message and calls fakekernel_putlog().
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * It's exported NODIRECT to allow replacment.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The flags are SL_... from strlog.h
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossfakekernel_cprintf(const char *fmt, va_list adx, int flags,
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross msgp += snprintf(msgp, bufend - msgp, "[fake_kernel] ");
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross msgp += vsnprintf(msgp, bufend - msgp, fmt, adx);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * "User-level crash dump", if you will.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross fakekernel_cprintf(fmt, tmpargs, SL_FATAL, "fatal: ", "\n");
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross /* Call libc`assfail() so that mdb ::status works */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross (void) vsnprintf(panicbuf, sizeof (panicbuf), fmt, adx);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross fakekernel_cprintf(fmt, adx, ce_flags[ce] | SL_CONSOLE,
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/*PRINTFLIKE2*/