2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A
2N/A#include <sys/types.h>
2N/A#include <stdio.h>
2N/A#include <errno.h>
2N/A#include <libintl.h>
2N/A#include <locale.h>
2N/A#include <stdlib.h>
2N/A#include <stdarg.h>
2N/A
2N/A#include <sys/nsctl/rdcerr.h>
2N/A#include <sys/nsctl/cfg.h>
2N/A
2N/A#include <sys/unistat/spcs_dtrinkets.h>
2N/A#include <sys/unistat/spcs_etrinkets.h>
2N/A#include <sys/unistat/spcs_s.h>
2N/A#include <sys/unistat/spcs_s_u.h>
2N/A#include <sys/unistat/spcs_s_impl.h>
2N/A#include <sys/unistat/spcs_errors.h>
2N/A
2N/A
2N/Aint rdc_severity;
2N/Achar *rdc_error_str;
2N/Achar err[RDC_ERR_SIZE];
2N/A
2N/Avoid
2N/Ardc_set_error(spcs_s_info_t *ustatus, int context, int severity,
2N/A char *errorstr, ...)
2N/A{
2N/A char msg[1024];
2N/A va_list ap;
2N/A
2N/A bzero(err, RDC_ERR_SIZE);
2N/A switch (context) {
2N/A case RDC_INTERNAL:
2N/A rdc_severity = severity;
2N/A if (errorstr) {
2N/A va_start(ap, errorstr);
2N/A vsprintf(err, errorstr, ap);
2N/A va_end(ap);
2N/A }
2N/A rdc_error_str = dgettext("librdc", err ? err : "");
2N/A break;
2N/A
2N/A case RDC_OS:
2N/A rdc_severity = severity ? severity : RDC_FATAL;
2N/A rdc_error_str = strerror(errno);
2N/A break;
2N/A
2N/A case RDC_SPCS:
2N/A rdc_severity = severity ? severity : RDC_FATAL;
2N/A rdc_error_str = spcs_s_string(*ustatus, msg);
2N/A break;
2N/A
2N/A case RDC_DSCFG:
2N/A rdc_error_str = cfg_error(&rdc_severity);
2N/A break;
2N/A
2N/A default:
2N/A break;
2N/A }
2N/A
2N/A spcs_log("librdc", NULL, dgettext("librdc", "%s"),
2N/A rdc_error_str ? rdc_error_str : "");
2N/A
2N/A}
2N/A
2N/Achar *
2N/Ardc_error(int *severity)
2N/A{
2N/A if (severity != NULL)
2N/A *severity = rdc_severity;
2N/A return (rdc_error_str ? rdc_error_str : "");
2N/A}