2010-05-18 02:18:00 +04:00
|
|
|
/*****************************************************************************\
|
|
|
|
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Copyright (C) 2007 The Regents of the University of California.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
2008-05-26 08:38:26 +04:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
|
|
|
* For details, see <http://github.com/behlendorf/spl/>.
|
|
|
|
*
|
|
|
|
* The SPL is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
2008-05-26 08:38:26 +04:00
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 08:38:26 +04:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2010-05-18 02:18:00 +04:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************
|
|
|
|
* Solaris Porting Layer (SPL) Error Implementation.
|
|
|
|
\*****************************************************************************/
|
2008-05-26 08:38:26 +04:00
|
|
|
|
2008-03-08 03:18:21 +03:00
|
|
|
#include <sys/sysmacros.h>
|
|
|
|
#include <sys/cmn_err.h>
|
2010-07-20 01:16:05 +04:00
|
|
|
#include <spl-debug.h>
|
2008-03-08 03:18:21 +03:00
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
#ifdef SS_DEBUG_SUBSYS
|
|
|
|
#undef SS_DEBUG_SUBSYS
|
2008-04-21 21:29:47 +04:00
|
|
|
#endif
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
#define SS_DEBUG_SUBSYS SS_GENERIC
|
2008-04-21 21:29:47 +04:00
|
|
|
|
2009-10-28 02:17:06 +03:00
|
|
|
#ifndef NDEBUG
|
2008-03-08 03:18:21 +03:00
|
|
|
static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" };
|
|
|
|
static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
|
2009-10-28 02:17:06 +03:00
|
|
|
#endif
|
2008-03-08 03:18:21 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
vpanic(const char *fmt, va_list ap)
|
|
|
|
{
|
|
|
|
char msg[MAXMSGLEN];
|
|
|
|
|
|
|
|
vsnprintf(msg, MAXMSGLEN - 1, fmt, ap);
|
2010-07-20 01:16:05 +04:00
|
|
|
PANIC("%s", msg);
|
2008-03-08 03:18:21 +03:00
|
|
|
} /* vpanic() */
|
|
|
|
EXPORT_SYMBOL(vpanic);
|
|
|
|
|
|
|
|
void
|
|
|
|
vcmn_err(int ce, const char *fmt, va_list ap)
|
|
|
|
{
|
|
|
|
char msg[MAXMSGLEN];
|
|
|
|
|
2010-01-07 19:58:30 +03:00
|
|
|
if (ce == CE_PANIC)
|
|
|
|
vpanic(fmt, ap);
|
2008-03-08 03:18:21 +03:00
|
|
|
|
2010-01-07 19:58:30 +03:00
|
|
|
if (ce != CE_NOTE) {
|
2008-03-08 03:18:21 +03:00
|
|
|
vsnprintf(msg, MAXMSGLEN - 1, fmt, ap);
|
2009-10-28 01:54:45 +03:00
|
|
|
|
|
|
|
if (fmt[0] == '!')
|
2010-07-20 22:55:37 +04:00
|
|
|
SDEBUG(SD_INFO, "%s%s%s",
|
2009-10-28 01:54:45 +03:00
|
|
|
ce_prefix[ce], msg, ce_suffix[ce]);
|
|
|
|
else
|
2010-07-20 22:55:37 +04:00
|
|
|
SERROR("%s%s%s", ce_prefix[ce], msg, ce_suffix[ce]);
|
2010-01-07 19:58:30 +03:00
|
|
|
}
|
2008-03-08 03:18:21 +03:00
|
|
|
} /* vcmn_err() */
|
|
|
|
EXPORT_SYMBOL(vcmn_err);
|
2009-10-28 01:54:45 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
cmn_err(int ce, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vcmn_err(ce, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
} /* cmn_err() */
|
|
|
|
EXPORT_SYMBOL(cmn_err);
|
|
|
|
|