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 (c) 1992, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * Just in case we're not in a build environment, make sure that
2N/A * TEXT_DOMAIN gets set to something.
2N/A */
2N/A#if !defined(TEXT_DOMAIN)
2N/A#define TEXT_DOMAIN "SYS_TEST"
2N/A#endif
2N/A
2N/A/*
2N/A * print metedevice errors
2N/A */
2N/A
2N/A#include <meta.h>
2N/A#include <sys/lvm/md_mddb.h>
2N/A
2N/A#include <syslog.h>
2N/A
2N/A/*
2N/A * clear error
2N/A */
2N/Avoid
2N/Amdclrerror(
2N/A md_error_t *ep
2N/A)
2N/A{
2N/A if (ep->name != NULL)
2N/A Free(ep->name);
2N/A if (ep->host != NULL)
2N/A Free(ep->host);
2N/A if (ep->extra != NULL)
2N/A Free(ep->extra);
2N/A (void) memset(ep, '\0', sizeof (*ep));
2N/A}
2N/A
2N/A/*
2N/A * cook names
2N/A */
2N/Astatic char *
2N/Amd_name(
2N/A minor_t mnum
2N/A)
2N/A{
2N/A char *name;
2N/A
2N/A /* get name, or fake it */
2N/A if ((name = get_mdname(NULL, mnum)) == NULL) {
2N/A char buf[40];
2N/A
2N/A (void) sprintf(buf, "%lu/%lu", MD_MIN2SET(mnum),
2N/A MD_MIN2UNIT(mnum));
2N/A return (Strdup(buf));
2N/A }
2N/A return (Strdup(name));
2N/A}
2N/A
2N/Astatic char *
2N/Adev_name(
2N/A set_t setno,
2N/A md_dev64_t dev
2N/A)
2N/A{
2N/A char *name;
2N/A
2N/A /* get name or fake it */
2N/A if (dev == NODEV64)
2N/A return (Strdup(dgettext(TEXT_DOMAIN, "unknown device")));
2N/A if ((name = get_devname(setno, dev)) == NULL) {
2N/A char buf[40];
2N/A
2N/A (void) sprintf(buf, "%lu.%lu", meta_getmajor(dev),
2N/A meta_getminor(dev));
2N/A return (Strdup(buf));
2N/A }
2N/A return (Strdup(name));
2N/A}
2N/A
2N/Astatic char *
2N/Ahsp_name(
2N/A hsp_t hsp
2N/A)
2N/A{
2N/A char *name;
2N/A
2N/A if ((name = get_hspname(NULL, hsp)) == NULL) {
2N/A char buf[40];
2N/A
2N/A (void) sprintf(buf, "%u/%u", HSP_SET(hsp), HSP_ID(hsp));
2N/A return (Strdup(buf));
2N/A }
2N/A return (Strdup(name));
2N/A}
2N/A
2N/Astatic char *
2N/Aset_name(
2N/A set_t setno
2N/A)
2N/A{
2N/A mdsetname_t *sp;
2N/A md_error_t xep = mdnullerror;
2N/A
2N/A if (setno == MD_SET_BAD)
2N/A return (NULL);
2N/A
2N/A if ((sp = metasetnosetname(setno, &xep)) == NULL) {
2N/A char buf[40];
2N/A
2N/A mdclrerror(&xep);
2N/A (void) sprintf(buf, "setno %u", setno);
2N/A return (Strdup(buf));
2N/A }
2N/A return (Strdup(sp->setname));
2N/A}
2N/A
2N/A/*
2N/A * fill in all the appropriate md_error_t fields
2N/A */
2N/Astatic void
2N/Ametacookerror(
2N/A md_error_t *ep, /* generic error */
2N/A char *name /* optional name or host */
2N/A)
2N/A{
2N/A /* get host name */
2N/A if (ep->host != NULL) {
2N/A Free(ep->host);
2N/A ep->host = NULL;
2N/A }
2N/A if ((ep->info.errclass == MDEC_RPC) &&
2N/A (name != NULL) && (*name != '\0')) {
2N/A ep->host = Strdup(name);
2N/A name = NULL;
2N/A } else
2N/A ep->host = Strdup(mynode());
2N/A
2N/A /* get appropriate name */
2N/A if (ep->name != NULL) {
2N/A Free(ep->name);
2N/A ep->name = NULL;
2N/A }
2N/A if ((name != NULL) && (*name != '\0')) {
2N/A ep->name = Strdup(name);
2N/A } else {
2N/A switch (ep->info.errclass) {
2N/A
2N/A /* can't do anything about these */
2N/A case MDEC_VOID:
2N/A case MDEC_SYS:
2N/A case MDEC_RPC:
2N/A default:
2N/A break;
2N/A
2N/A /* device name */
2N/A case MDEC_DEV:
2N/A {
2N/A md_dev_error_t *ip =
2N/A &ep->info.md_error_info_t_u.dev_error;
2N/A
2N/A ep->name = dev_name(MD_SET_BAD, ip->dev);
2N/A break;
2N/A }
2N/A
2N/A /* device name */
2N/A case MDEC_USE:
2N/A {
2N/A md_use_error_t *ip =
2N/A &ep->info.md_error_info_t_u.use_error;
2N/A
2N/A ep->name = dev_name(MD_SET_BAD, ip->dev);
2N/A if (ip->where == NULL) {
2N/A ip->where = Strdup(dgettext(TEXT_DOMAIN,
2N/A "unknown"));
2N/A }
2N/A break;
2N/A }
2N/A
2N/A /* metadevice name */
2N/A case MDEC_MD:
2N/A {
2N/A md_md_error_t *ip =
2N/A &ep->info.md_error_info_t_u.md_error;
2N/A
2N/A ep->name = md_name(ip->mnum);
2N/A break;
2N/A }
2N/A
2N/A /* component name */
2N/A case MDEC_COMP:
2N/A {
2N/A md_comp_error_t *ip =
2N/A &ep->info.md_error_info_t_u.comp_error;
2N/A char *mdname, *devname;
2N/A size_t len;
2N/A
2N/A mdname = md_name(ip->comp.mnum);
2N/A devname = dev_name(MD_MIN2SET(ip->comp.mnum),
2N/A ip->comp.dev);
2N/A len = strlen(mdname) + strlen(": ")
2N/A + strlen(devname) + 1;
2N/A ep->name = Malloc(len);
2N/A (void) snprintf(ep->name, len, "%s: %s",
2N/A mdname, devname);
2N/A Free(mdname);
2N/A Free(devname);
2N/A break;
2N/A }
2N/A
2N/A /* hotspare pool name */
2N/A case MDEC_HSP:
2N/A {
2N/A md_hsp_error_t *ip =
2N/A &ep->info.md_error_info_t_u.hsp_error;
2N/A
2N/A ep->name = hsp_name(ip->hsp);
2N/A break;
2N/A }
2N/A
2N/A /* hotspare name */
2N/A case MDEC_HS:
2N/A {
2N/A md_hs_error_t *ip =
2N/A &ep->info.md_error_info_t_u.hs_error;
2N/A char *hspname, *devname;
2N/A size_t len;
2N/A
2N/A hspname = hsp_name(ip->hs.hsp);
2N/A devname = dev_name(HSP_SET(ip->hs.hsp), ip->hs.dev);
2N/A len = strlen(hspname) + strlen(": ")
2N/A + strlen(devname) + 1;
2N/A ep->name = Malloc(len);
2N/A (void) snprintf(ep->name, len, "%s: %s",
2N/A hspname, devname);
2N/A Free(hspname);
2N/A Free(devname);
2N/A break;
2N/A }
2N/A
2N/A /* mddb name */
2N/A case MDEC_MDDB:
2N/A {
2N/A md_mddb_error_t *ip =
2N/A &ep->info.md_error_info_t_u.mddb_error;
2N/A if (ip->mnum != NODEV32)
2N/A ep->name = md_name(ip->mnum);
2N/A ep->name = set_name(ip->setno);
2N/A break;
2N/A }
2N/A
2N/A /* set name */
2N/A case MDEC_DS:
2N/A {
2N/A md_ds_error_t *ip =
2N/A &ep->info.md_error_info_t_u.ds_error;
2N/A
2N/A ep->name = set_name(ip->setno);
2N/A break;
2N/A }
2N/A }
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * simple error
2N/A */
2N/Aint
2N/Amderror(
2N/A md_error_t *ep,
2N/A md_void_errno_t errnum,
2N/A char *name
2N/A)
2N/A{
2N/A md_void_error_t *ip = &ep->info.md_error_info_t_u.void_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_VOID;
2N/A ip->errnum = errnum;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * system error
2N/A */
2N/Aint
2N/Amdsyserror(
2N/A md_error_t *ep,
2N/A int errnum,
2N/A char *name
2N/A)
2N/A{
2N/A md_sys_error_t *ip = &ep->info.md_error_info_t_u.sys_error;
2N/A
2N/A mdclrerror(ep);
2N/A if (errnum != 0) {
2N/A ep->info.errclass = MDEC_SYS;
2N/A ip->errnum = errnum;
2N/A }
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * RPC error
2N/A */
2N/Aint
2N/Amdrpcerror(
2N/A md_error_t *ep,
2N/A CLIENT *clntp,
2N/A char *host,
2N/A char *extra
2N/A)
2N/A{
2N/A md_rpc_error_t *ip = &ep->info.md_error_info_t_u.rpc_error;
2N/A struct rpc_err rpcerr;
2N/A
2N/A mdclrerror(ep);
2N/A clnt_geterr(clntp, &rpcerr);
2N/A ep->info.errclass = MDEC_RPC;
2N/A ip->errnum = rpcerr.re_status;
2N/A
2N/A metacookerror(ep, host);
2N/A mderrorextra(ep, extra);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * RPC create error
2N/A */
2N/Aint
2N/Amdrpccreateerror(
2N/A md_error_t *ep,
2N/A char *host,
2N/A char *extra
2N/A)
2N/A{
2N/A md_rpc_error_t *ip = &ep->info.md_error_info_t_u.rpc_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_RPC;
2N/A ip->errnum = rpc_createerr.cf_stat;
2N/A
2N/A metacookerror(ep, host);
2N/A mderrorextra(ep, extra);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * device error
2N/A */
2N/Aint
2N/Amddeverror(
2N/A md_error_t *ep,
2N/A md_dev_errno_t errnum,
2N/A md_dev64_t dev,
2N/A char *name
2N/A)
2N/A{
2N/A md_dev_error_t *ip = &ep->info.md_error_info_t_u.dev_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_DEV;
2N/A ip->errnum = errnum;
2N/A ip->dev = dev;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * use error
2N/A */
2N/Aint
2N/Amduseerror(
2N/A md_error_t *ep,
2N/A md_use_errno_t errnum,
2N/A md_dev64_t dev,
2N/A char *where,
2N/A char *name
2N/A)
2N/A{
2N/A md_use_error_t *ip = &ep->info.md_error_info_t_u.use_error;
2N/A
2N/A assert(where != NULL);
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_USE;
2N/A ip->errnum = errnum;
2N/A ip->dev = dev;
2N/A ip->where = Strdup(where);
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * overlap error
2N/A */
2N/Aint
2N/Amdoverlaperror(
2N/A md_error_t *ep,
2N/A md_overlap_errno_t errnum,
2N/A char *name,
2N/A char *where,
2N/A char *overlap
2N/A)
2N/A{
2N/A md_overlap_error_t *ip =
2N/A &ep->info.md_error_info_t_u.overlap_error;
2N/A
2N/A assert(overlap != NULL);
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_OVERLAP;
2N/A ip->errnum = errnum;
2N/A ip->overlap = Strdup(overlap);
2N/A ip->where = NULL;
2N/A if (where != NULL)
2N/A ip->where = Strdup(where);
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * metadevice error
2N/A */
2N/Aint
2N/Amdmderror(
2N/A md_error_t *ep,
2N/A md_md_errno_t errnum,
2N/A minor_t mnum,
2N/A char *name
2N/A)
2N/A{
2N/A md_md_error_t *ip = &ep->info.md_error_info_t_u.md_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_MD;
2N/A ip->errnum = errnum;
2N/A ip->mnum = mnum;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * component error
2N/A */
2N/Aint
2N/Amdcomperror(
2N/A md_error_t *ep,
2N/A md_comp_errno_t errnum,
2N/A minor_t mnum,
2N/A md_dev64_t dev,
2N/A char *name
2N/A)
2N/A{
2N/A md_comp_error_t *ip = &ep->info.md_error_info_t_u.comp_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_COMP;
2N/A ip->errnum = errnum;
2N/A ip->comp.mnum = mnum;
2N/A ip->comp.dev = dev;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * hotspare pool error
2N/A */
2N/Aint
2N/Amdhsperror(
2N/A md_error_t *ep,
2N/A md_hsp_errno_t errnum,
2N/A hsp_t hsp,
2N/A char *name
2N/A)
2N/A{
2N/A md_hsp_error_t *ip = &ep->info.md_error_info_t_u.hsp_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_HSP;
2N/A ip->errnum = errnum;
2N/A ip->hsp = hsp;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * hotspare error
2N/A */
2N/Aint
2N/Amdhserror(
2N/A md_error_t *ep,
2N/A md_hs_errno_t errnum,
2N/A hsp_t hsp,
2N/A md_dev64_t dev,
2N/A char *name
2N/A)
2N/A{
2N/A md_hs_error_t *ip = &ep->info.md_error_info_t_u.hs_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_HS;
2N/A ip->errnum = errnum;
2N/A ip->hs.hsp = hsp;
2N/A ip->hs.dev = dev;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * MDDB error
2N/A */
2N/Aint
2N/Amdmddberror(
2N/A md_error_t *ep,
2N/A md_mddb_errno_t errnum,
2N/A minor_t mnum,
2N/A set_t setno,
2N/A size_t size,
2N/A char *name
2N/A)
2N/A{
2N/A md_mddb_error_t *ip = &ep->info.md_error_info_t_u.mddb_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_MDDB;
2N/A ip->errnum = errnum;
2N/A ip->mnum = mnum;
2N/A ip->setno = setno;
2N/A ip->size = size;
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * metadevice diskset (ds) error
2N/A */
2N/Aint
2N/Amddserror(
2N/A md_error_t *ep,
2N/A md_ds_errno_t errnum,
2N/A set_t setno,
2N/A char *node,
2N/A char *drive,
2N/A char *name
2N/A)
2N/A{
2N/A md_ds_error_t *ip = &ep->info.md_error_info_t_u.ds_error;
2N/A
2N/A mdclrerror(ep);
2N/A ep->info.errclass = MDEC_DS;
2N/A ip->errnum = errnum;
2N/A ip->setno = setno;
2N/A ip->node = ((node != NULL) ? Strdup(node) : NULL);
2N/A ip->drive = ((drive != NULL) ? Strdup(drive) : NULL);
2N/A
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * clear/attach extra context information
2N/A */
2N/Avoid
2N/Amderrorextra(
2N/A md_error_t *ep,
2N/A char *extra
2N/A)
2N/A{
2N/A if (ep->extra != NULL)
2N/A Free(ep->extra);
2N/A if (extra != NULL)
2N/A ep->extra = Strdup(extra);
2N/A else
2N/A ep->extra = NULL;
2N/A}
2N/A
2N/A/*
2N/A * steal (copy) an error code safely
2N/A */
2N/Aint
2N/Amdstealerror(
2N/A md_error_t *to,
2N/A md_error_t *from
2N/A)
2N/A{
2N/A mdclrerror(to);
2N/A *to = *from;
2N/A (void) memset(from, '\0', sizeof (*from));
2N/A return (-1);
2N/A}
2N/A
2N/A/*
2N/A * do an ioctl, cook the error, and return status
2N/A */
2N/Aint
2N/Ametaioctl(
2N/A int cmd,
2N/A void *data,
2N/A md_error_t *ep,
2N/A char *name
2N/A)
2N/A{
2N/A int fd;
2N/A
2N/A /* open admin device */
2N/A if ((fd = open_admin(ep)) < 0)
2N/A return (-1);
2N/A
2N/A /* do ioctl */
2N/A mdclrerror(ep);
2N/A if (ioctl(fd, cmd, data) != 0) {
2N/A return (mdsyserror(ep, errno, name));
2N/A } else if (! mdisok(ep)) {
2N/A metacookerror(ep, name);
2N/A return (-1);
2N/A }
2N/A
2N/A /* return success */
2N/A return (0);
2N/A}
2N/A
2N/A/*
2N/A * print void class errors
2N/A */
2N/Astatic char *
2N/Avoid_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_void_error_t *ip = &ep->info.md_error_info_t_u.void_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_NONE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "no error"));
2N/A break;
2N/A case MDE_UNIT_NOT_FOUND:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit not found"));
2N/A break;
2N/A case MDE_DUPDRIVE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "drive specified more than once"));
2N/A break;
2N/A case MDE_INVAL_HSOP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "illegal hot spare operation"));
2N/A break;
2N/A case MDE_NO_SET:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "no such set"));
2N/A break;
2N/A case MDE_SET_DIFF:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "set name is inconsistent"));
2N/A break;
2N/A case MDE_BAD_RD_OPT:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid read option"));
2N/A break;
2N/A case MDE_BAD_WR_OPT:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid write option"));
2N/A break;
2N/A case MDE_BAD_PASS_NUM:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid pass number"));
2N/A break;
2N/A case MDE_BAD_RESYNC_OPT:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid resync option"));
2N/A break;
2N/A case MDE_BAD_INTERLACE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid interlace"));
2N/A break;
2N/A case MDE_NO_HSPS:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "no hotspare pools found"));
2N/A break;
2N/A case MDE_NOTENOUGH_DB:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "must have at least 1 database (-f overrides)"));
2N/A break;
2N/A case MDE_DELDB_NOTALLOWED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "cannot delete the last database replica in the diskset"));
2N/A break;
2N/A case MDE_DEL_VALIDDB_NOTALLOWED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Deleting specified valid replicas results in stale "
2N/A "state database. Configuration changes with stale "
2N/A "database result in panic(-f overrides)"));
2N/A break;
2N/A case MDE_SYSTEM_FILE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "error in system file"));
2N/A break;
2N/A case MDE_MDDB_FILE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "error in mddb.cf file"));
2N/A break;
2N/A case MDE_MDDB_CKSUM:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "checksum error in mddb.cf file"));
2N/A break;
2N/A case MDE_VFSTAB_FILE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "error in vfstab file"));
2N/A break;
2N/A case MDE_NOSLICE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "invalid slice number for drive name"));
2N/A break;
2N/A case MDE_SYNTAX:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "syntax error"));
2N/A break;
2N/A case MDE_OPTION:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "illegal option"));
2N/A break;
2N/A case MDE_TAKE_OWN:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "failed to reserve any drives"));
2N/A break;
2N/A case MDE_NOT_DRIVENAME:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not a valid drive name"));
2N/A break;
2N/A case MDE_RESERVED:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "reserved by another host"));
2N/A break;
2N/A case MDE_DVERSION:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "driver version mismatch"));
2N/A break;
2N/A case MDE_MVERSION:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice state database version mismatch"));
2N/A break;
2N/A case MDE_TESTERROR:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "TEST ERROR MESSAGE"));
2N/A break;
2N/A case MDE_BAD_ORIG_NCOL:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid column count"));
2N/A break;
2N/A case MDE_RAID_INVALID:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "devices were not RAIDed previously or "
2N/A "are specified in the wrong order"));
2N/A break;
2N/A case MDE_MED_ERROR:
2N/A break;
2N/A case MDE_TOOMANYMED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "too many mediator hosts requested"));
2N/A break;
2N/A case MDE_NOMED:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "no mediator hosts found"));
2N/A break;
2N/A case MDE_ONLYNODENAME:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "only the nodename of a host is required for deletes"));
2N/A break;
2N/A case MDE_RAID_BAD_PW_CNT:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "simultaneous writes out of range"));
2N/A break;
2N/A case MDE_DEVID_TOOBIG:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "relocation information size is greater than reported"));
2N/A break;
2N/A case MDE_NOPERM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Permission denied. You must have root privilege "
2N/A "to execute this command."));
2N/A break;
2N/A case MDE_NODEVID:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Device relocation information not available "
2N/A "for this device"));
2N/A break;
2N/A case MDE_NOROOT:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no root filesystem in /etc/mnttab"));
2N/A break;
2N/A case MDE_EOF_TRANS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A MD_EOF_TRANS_MSG));
2N/A break;
2N/A case MDE_NOT_MN:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "option only valid within a multi-owner set"));
2N/A break;
2N/A case MDE_ABR_SET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Invalid command for mirror with ABR set"));
2N/A break;
2N/A case MDE_INVAL_MNOP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Invalid operation on multi-owner set"));
2N/A break;
2N/A case MDE_MNSET_NOTRANS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Trans metadevice not supported on multi-owner set"));
2N/A break;
2N/A case MDE_MNSET_NORAID:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "RAID-5 metadevice not supported on multi-owner set"));
2N/A break;
2N/A case MDE_FORCE_DEL_ALL_DRV:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Must specify -f option to delete all drives from set"));
2N/A break;
2N/A case MDE_STRIPE_TRUNC_SINGLE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "The necessary rounding would result in data loss. "
2N/A "You can avoid this by concatenating additional devices "
2N/A "totaling at least %s blocks, or by increasing the size "
2N/A "of the specified component by exactly %s blocks."),
2N/A ep->extra, ep->extra);
2N/A break;
2N/A case MDE_STRIPE_TRUNC_MULTIPLE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "The necessary rounding would result in data loss. "
2N/A "You can avoid this by concatenating additional devices "
2N/A "totaling at least %s blocks."), ep->extra);
2N/A break;
2N/A case MDE_SMF_FAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "failed to enable/disable SVM service"));
2N/A break;
2N/A case MDE_SMF_NO_SERVICE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "service(s) not online in SMF"));
2N/A break;
2N/A case MDE_AMBIGUOUS_DEV:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Specify complete path to avoid ambiguity."));
2N/A break;
2N/A case MDE_NAME_IN_USE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Name already in use for metadevice or hot spare pool."));
2N/A break;
2N/A case MDE_NAME_ILLEGAL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Invalid name for metadevice or hot spare pool."));
2N/A break;
2N/A case MDE_ZONE_ADMIN:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Volume administration unavailable within non-global zones."));
2N/A break;
2N/A case MDE_MISSING_DEVID_DISK:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "device id does not exist."));
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown void error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print sys class errors
2N/A */
2N/Astatic char *
2N/Asys_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_sys_error_t *ip = &ep->info.md_error_info_t_u.sys_error;
2N/A char *emsg;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A if ((emsg = strerror(ip->errnum)) == NULL) {
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unknown errno %d out of range"),
2N/A ip->errnum);
2N/A } else {
2N/A (void) snprintf(p, psize, "%s", emsg);
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print RPC class errors
2N/A */
2N/Astatic char *
2N/Arpc_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_rpc_error_t *ip = &ep->info.md_error_info_t_u.rpc_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A (void) snprintf(p, psize, "%s", clnt_sperrno(ip->errnum));
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print dev class errors
2N/A */
2N/Astatic char *
2N/Adev_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_dev_error_t *ip = &ep->info.md_error_info_t_u.dev_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_INVAL_HS:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "hotspare doesn't exist"));
2N/A break;
2N/A case MDE_FIX_INVAL_STATE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "cannot enable hotspared device"));
2N/A break;
2N/A case MDE_FIX_INVAL_HS_STATE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare isn't broken, can't enable"));
2N/A break;
2N/A case MDE_NOT_META:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not a metadevice"));
2N/A break;
2N/A case MDE_IS_DUMP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "is a dump device"));
2N/A break;
2N/A case MDE_IS_META:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "is a metadevice"));
2N/A break;
2N/A case MDE_IS_SWAPPED:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "is swapped on"));
2N/A break;
2N/A case MDE_NAME_SPACE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "namespace error"));
2N/A break;
2N/A case MDE_IN_SHARED_SET:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "device in shared set"));
2N/A break;
2N/A case MDE_NOT_IN_SET:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "device not in set"));
2N/A break;
2N/A case MDE_NOT_DISK:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not a disk device"));
2N/A break;
2N/A case MDE_CANT_CONFIRM:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "can't confirm device"));
2N/A break;
2N/A case MDE_INVALID_PART:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid partition"));
2N/A break;
2N/A case MDE_HAS_MDDB:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "has a metadevice database replica"));
2N/A break;
2N/A case MDE_NO_DB:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no metadevice database replica on device"));
2N/A break;
2N/A case MDE_CANTVERIFY_VTOC:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unable to verify the vtoc"));
2N/A break;
2N/A case MDE_NOT_LOCAL:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not in local set"));
2N/A break;
2N/A case MDE_DEVICES_NAME:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "can't parse /devices name"));
2N/A break;
2N/A case MDE_REPCOMP_INVAL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "replica slice is not usable as a metadevice component"));
2N/A break;
2N/A case MDE_REPCOMP_ONLY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "only replica slice is usable for a diskset "
2N/A "database replica"));
2N/A break;
2N/A case MDE_INV_ROOT:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "invalid root device for this operation"));
2N/A break;
2N/A case MDE_MULTNM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "multiple entries for device in Solaris Volume Manager "
2N/A "configuration"));
2N/A break;
2N/A case MDE_TOO_MANY_PARTS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Disks with more than %d partitions are not supported "
2N/A "in Solaris Volume Manager"), MD_MAX_PARTS);
2N/A break;
2N/A case MDE_REPART_REPLICA:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "cannot repartition a slice with an existing replica"));
2N/A break;
2N/A case MDE_DISKNAMETOOLONG:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "disk name is too long with device ids disabled "
2N/A "in Solaris Volume Manager. Check /etc/driver/drv/md.conf "
2N/A "for md_devid_destroy, remove it and reboot"));
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unknown dev error code %d"),
2N/A ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print overlap class errors
2N/A */
2N/Astatic char *
2N/Aoverlap_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_overlap_error_t *ip =
2N/A &ep->info.md_error_info_t_u.overlap_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_OVERLAP_MOUNTED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "overlaps with %s which is mounted as \'%s\'"),
2N/A ip->overlap, ip->where);
2N/A break;
2N/A case MDE_OVERLAP_SWAP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "overlaps with %s which is a swap device"), ip->overlap);
2N/A break;
2N/A case MDE_OVERLAP_DUMP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "overlaps with %s which is the dump device"), ip->overlap);
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown overlap error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print use class errors
2N/A */
2N/Astatic char *
2N/Ause_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_use_error_t *ip = &ep->info.md_error_info_t_u.use_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_IS_MOUNTED:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "is mounted on %s"),
2N/A ip->where);
2N/A break;
2N/A case MDE_ALREADY:
2N/A /*
2N/A * when the object of the error (existing device that
2N/A * would being used by SVM) is the metadb then it is necessary
2N/A * to explicitly specify the string in the error message so
2N/A * that it can be successfully localized for the Asian locales.
2N/A */
2N/A if (strcmp(ip->where, MDB_STR) != 0) {
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "has appeared more than once in the "
2N/A "specification of %s"), ip->where);
2N/A } else {
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "has appeared more than once in the "
2N/A "specification of " MDB_STR));
2N/A }
2N/A break;
2N/A case MDE_OVERLAP:
2N/A /*
2N/A * when the object of the error (existing device that
2N/A * would overlap) is the metadb then it is necessary
2N/A * to explicitly specify the string in the error message so
2N/A * that it can be successfully localized for the Asian locales.
2N/A */
2N/A if (strcmp(ip->where, MDB_STR) != 0) {
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "overlaps with device in %s"),
2N/A ip->where);
2N/A } else {
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "overlaps with device in "
2N/A MDB_STR));
2N/A }
2N/A break;
2N/A case MDE_SAME_DEVID:
2N/A /*
2N/A * when the object of the error (existing device in the
2N/A * metaconfiguration that has the same devid)
2N/A * is the metadb then it is necessary
2N/A * to explicitly specify the string in the error message so
2N/A * that it can be successfully localized for the Asian locales.
2N/A */
2N/A if (strcmp(ip->where, MDB_STR) != 0) {
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "identical devid detected on %s"), ip->where);
2N/A } else {
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "identical devid detected in " MDB_STR));
2N/A }
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown dev error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print md class errors
2N/A */
2N/Astatic char *
2N/Amd_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_md_error_t *ip = &ep->info.md_error_info_t_u.md_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_INVAL_UNIT:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid unit"));
2N/A break;
2N/A case MDE_UNIT_NOT_SETUP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit not set up"));
2N/A break;
2N/A case MDE_UNIT_ALREADY_SETUP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit already set up"));
2N/A break;
2N/A case MDE_NOT_MM:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit is not a mirror"));
2N/A break;
2N/A case MDE_IS_SM:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "illegal to clear submirror"));
2N/A break;
2N/A case MDE_IS_OPEN:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "metadevice is open"));
2N/A break;
2N/A case MDE_C_WITH_INVAL_SM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attempted to clear mirror with submirror(s) "
2N/A "in invalid state"));
2N/A break;
2N/A case MDE_RESYNC_ACTIVE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "resync in progress"));
2N/A break;
2N/A case MDE_LAST_SM_RE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attempt to replace a component on the last "
2N/A "running submirror"));
2N/A break;
2N/A case MDE_MIRROR_FULL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "mirror has maximum number of submirrors"));
2N/A break;
2N/A case MDE_IN_UNAVAIL_STATE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "component is in unavailable state; run 'metastat -i'"));
2N/A break;
2N/A case MDE_IN_USE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice in use"));
2N/A break;
2N/A case MDE_SM_TOO_SMALL:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "submirror too small to attach"));
2N/A break;
2N/A case MDE_NO_LABELED_SM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "can't attach labeled submirror to an unlabeled mirror"));
2N/A break;
2N/A case MDE_SM_OPEN_ERR:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "submirror open error"));
2N/A break;
2N/A case MDE_CANT_FIND_SM:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "can't find submirror in mirror"));
2N/A break;
2N/A case MDE_LAST_SM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attempt to detach last running submirror"));
2N/A break;
2N/A case MDE_NO_READABLE_SM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "operation would result in no readable submirrors"));
2N/A break;
2N/A case MDE_SM_FAILED_COMPS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attempt an operation on a submirror "
2N/A "that has erred components"));
2N/A break;
2N/A case MDE_ILLEGAL_SM_STATE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attempt operation on a submirror in illegal state"));
2N/A break;
2N/A case MDE_RR_ALLOC_ERROR:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attach failed, unable to allocate new resync info"));
2N/A break;
2N/A case MDE_MIRROR_OPEN_FAILURE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "insufficient devices to open"));
2N/A break;
2N/A case MDE_MIRROR_THREAD_FAILURE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "mirror thread failure"));
2N/A break;
2N/A case MDE_GROW_DELAYED:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "growing of metadevice delayed"));
2N/A break;
2N/A case MDE_NOT_MT:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit is not a trans"));
2N/A break;
2N/A case MDE_HS_IN_USE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "can't modify hot spare pool, hot spare in use"));
2N/A break;
2N/A case MDE_HAS_LOG:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "already has log"));
2N/A break;
2N/A case MDE_UNKNOWN_TYPE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unknown metadevice type"));
2N/A break;
2N/A case MDE_NOT_STRIPE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit is not a concat/stripe"));
2N/A break;
2N/A case MDE_NOT_RAID:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit is not a RAID"));
2N/A break;
2N/A case MDE_NROWS:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not enough stripes specified"));
2N/A break;
2N/A case MDE_NCOMPS:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not enough components specified"));
2N/A break;
2N/A case MDE_NSUBMIRS:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "not enough submirrors specified"));
2N/A break;
2N/A case MDE_BAD_STRIPE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid stripe configuration"));
2N/A break;
2N/A case MDE_BAD_MIRROR:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid mirror configuration"));
2N/A break;
2N/A case MDE_BAD_TRANS:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid trans configuration"));
2N/A break;
2N/A case MDE_BAD_RAID:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "invalid RAID configuration"));
2N/A break;
2N/A case MDE_RAID_OPEN_FAILURE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "resync unable to open RAID unit"));
2N/A break;
2N/A case MDE_RAID_THREAD_FAILURE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "attempt to start resync thread failed"));
2N/A break;
2N/A case MDE_RAID_NEED_FORCE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "operation requires -f (force) flag"));
2N/A break;
2N/A case MDE_NO_LOG:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "log has already been detached"));
2N/A break;
2N/A case MDE_RAID_DOI:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "only valid action is metaclear"));
2N/A break;
2N/A case MDE_RAID_LAST_ERRED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "in Last Erred state, "
2N/A "errored components must be replaced"));
2N/A break;
2N/A case MDE_RAID_NOT_OKAY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "all components must be Okay to perform this operation"));
2N/A break;
2N/A case MDE_RENAME_BUSY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice is temporarily too busy for renames"));
2N/A break;
2N/A case MDE_RENAME_SOURCE_BAD:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "source metadevice is not able to be renamed"));
2N/A break;
2N/A case MDE_RENAME_TARGET_BAD:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "target metadevice is not able to be renamed"));
2N/A break;
2N/A case MDE_RENAME_TARGET_UNRELATED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "target metadevice is not related to source metadevice"));
2N/A break;
2N/A case MDE_RENAME_CONFIG_ERROR:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice driver configuration error; "
2N/A "rename can't occur"));
2N/A break;
2N/A case MDE_RENAME_ORDER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "units may not be renamed in that order"));
2N/A break;
2N/A case MDE_RECOVER_FAILED:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "recovery failed"));
2N/A break;
2N/A case MDE_SP_NOSPACE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "not enough space available for request"));
2N/A break;
2N/A case MDE_SP_BADWMREAD:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "error reading extent header"));
2N/A break;
2N/A case MDE_SP_BADWMWRITE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "error writing extent header"));
2N/A break;
2N/A case MDE_SP_BADWMMAGIC:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "bad magic number in extent header"));
2N/A break;
2N/A case MDE_SP_BADWMCRC:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "bad checksum in extent header"));
2N/A break;
2N/A case MDE_NOT_SP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unit is not a soft partition"));
2N/A break;
2N/A case MDE_SP_OVERLAP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "overlapping extents specified"));
2N/A break;
2N/A case MDE_SP_BAD_LENGTH:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "bad length specified"));
2N/A break;
2N/A case MDE_SP_NOSP:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "no soft partitions on this device"));
2N/A break;
2N/A case MDE_UNIT_TOO_LARGE:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "Volume size cannot exceed 1 TByte"));
2N/A break;
2N/A case MDE_LOG_TOO_LARGE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Trans log size must be less than 1 TByte"));
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize,
2N/A dgettext(TEXT_DOMAIN, "unknown md error code %d"),
2N/A ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print comp class errors
2N/A */
2N/Astatic char *
2N/Acomp_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_comp_error_t *ip = &ep->info.md_error_info_t_u.comp_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_CANT_FIND_COMP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "can't find component in unit"));
2N/A break;
2N/A case MDE_REPL_INVAL_STATE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "component in invalid state to replace - "
2N/A "Replace \"Maintenance\" components first"));
2N/A break;
2N/A case MDE_COMP_TOO_SMALL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "replace failure, new component is too small"));
2N/A break;
2N/A case MDE_COMP_OPEN_ERR:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unable to open concat/stripe component"));
2N/A break;
2N/A case MDE_RAID_COMP_ERRED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "must replace errored component first"));
2N/A break;
2N/A case MDE_MAXIO:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "maxtransfer is too small"));
2N/A break;
2N/A case MDE_SP_COMP_OPEN_ERR:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "error opening device under soft partition. Check"
2N/A " device status, then use metadevadm(1M)."));
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown comp error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print hsp class errors
2N/A */
2N/Astatic char *
2N/Ahsp_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_hsp_error_t *ip = &ep->info.md_error_info_t_u.hsp_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_HSP_CREATE_FAILURE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare pool database create failure"));
2N/A break;
2N/A case MDE_HSP_IN_USE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare pool in use"));
2N/A break;
2N/A case MDE_INVAL_HSP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "invalid hotspare pool"));
2N/A break;
2N/A case MDE_HSP_BUSY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare pool is busy"));
2N/A break;
2N/A case MDE_HSP_REF:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare pool is referenced"));
2N/A break;
2N/A case MDE_HSP_ALREADY_SETUP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare pool is already setup"));
2N/A break;
2N/A case MDE_BAD_HSP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "invalid hotspare pool configuration"));
2N/A break;
2N/A case MDE_HSP_UNIT_TOO_LARGE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "units in the hotspare pool cannot exceed 1 TByte"));
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown hsp error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print hs class errors
2N/A */
2N/Astatic char *
2N/Ahs_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_hs_error_t *ip = &ep->info.md_error_info_t_u.hs_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_HS_RESVD:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare is in use"));
2N/A break;
2N/A case MDE_HS_CREATE_FAILURE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare database create failure"));
2N/A break;
2N/A case MDE_HS_INUSE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "add or replace failed, hot spare is already in use"));
2N/A break;
2N/A case MDE_HS_UNIT_TOO_LARGE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "hotspare size cannot exceed 1 TByte"));
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown hs error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print mddb class errors
2N/A */
2N/Astatic char *
2N/Amddb_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_mddb_error_t *ip = &ep->info.md_error_info_t_u.mddb_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_TOOMANY_REPLICAS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "%d metadevice database replicas is too many; the maximum is %d"),
2N/A ip->size, MDDB_NLB);
2N/A break;
2N/A case MDE_REPLICA_TOOSMALL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "device size %d is too small for metadevice database replica"),
2N/A ip->size);
2N/A break;
2N/A case MDE_NOTVERIFIED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "data not returned correctly from disk"));
2N/A break;
2N/A case MDE_DB_INVALID:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "invalid argument"));
2N/A break;
2N/A case MDE_DB_EXISTS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice database replica exists on device"));
2N/A break;
2N/A case MDE_DB_MASTER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "has bad master block on device"));
2N/A break;
2N/A case MDE_DB_TOOSMALL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "device is too small"));
2N/A break;
2N/A case MDE_DB_NORECORD:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no such metadevice database record"));
2N/A break;
2N/A case MDE_DB_NOSPACE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice database is full, can't create new records"));
2N/A break;
2N/A case MDE_DB_NOTNOW:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metadevice database has too few replicas, for "
2N/A "metadevice database operation"));
2N/A break;
2N/A case MDE_DB_NODB:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "there are no existing databases"));
2N/A break;
2N/A case MDE_DB_NOTOWNER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "not owner of metadevice database"));
2N/A break;
2N/A case MDE_DB_STALE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "stale databases"));
2N/A break;
2N/A case MDE_DB_TOOFEW:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "not enough databases"));
2N/A break;
2N/A case MDE_DB_TAGDATA:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "tagged data detected, user intervention required"));
2N/A break;
2N/A case MDE_DB_ACCOK:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "50% replicas & 50% mediator hosts available, "
2N/A "user intervention required"));
2N/A break;
2N/A case MDE_DB_NTAGDATA:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no tagged data available or only one tag found"));
2N/A break;
2N/A case MDE_DB_ACCNOTOK:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "50% replicas & 50% mediator hosts not available"));
2N/A break;
2N/A case MDE_DB_NOLOCBLK:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no valid locator blocks were found"));
2N/A break;
2N/A case MDE_DB_NOLOCNMS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no valid locator name information was found"));
2N/A break;
2N/A case MDE_DB_NODIRBLK:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no valid directory blocks were found"));
2N/A break;
2N/A case MDE_DB_NOTAGREC:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no tag record was allocated, so data "
2N/A "tagging is disabled"));
2N/A break;
2N/A case MDE_DB_NOTAG:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no tag records exist or no matching tag was found"));
2N/A break;
2N/A case MDE_DB_BLKRANGE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "logical block number %d out of range"), ip->size);
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown mddb error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * print diskset (ds) class errors
2N/A */
2N/Astatic char *
2N/Ads_to_str(
2N/A md_error_t *ep,
2N/A char *buf,
2N/A size_t size
2N/A)
2N/A{
2N/A md_ds_error_t *ip = &ep->info.md_error_info_t_u.ds_error;
2N/A char *p = buf + strlen(buf);
2N/A size_t psize = size - strlen(buf);
2N/A
2N/A switch (ip->errnum) {
2N/A case MDE_DS_DUPHOST:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s is specified more than once"), ip->node);
2N/A break;
2N/A case MDE_DS_NOTNODENAME:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "\"%s\" is not a nodename, but a network name"), ip->node);
2N/A break;
2N/A case MDE_DS_SELFNOTIN:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "nodename of host %s creating the set must be included"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_NODEHASSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s already has set"), ip->node);
2N/A break;
2N/A case MDE_DS_NODENOSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s does not have set"), ip->node);
2N/A break;
2N/A case MDE_DS_NOOWNER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "must be owner of the set for this command"));
2N/A break;
2N/A case MDE_DS_NOTOWNER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "only the current owner %s may operate on this set"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_NODEISNOTOWNER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s is not the owner"), ip->node);
2N/A break;
2N/A case MDE_DS_NODEINSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s is already in the set"), ip->node);
2N/A break;
2N/A case MDE_DS_NODENOTINSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s is not in the set"), ip->node);
2N/A break;
2N/A case MDE_DS_SETNUMBUSY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s already has a set numbered %ld"),
2N/A ip->node, ip->setno);
2N/A break;
2N/A case MDE_DS_SETNUMNOTAVAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "no available set numbers"));
2N/A break;
2N/A case MDE_DS_SETNAMEBUSY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "set name is in-use or invalid on host %s"), ip->node);
2N/A break;
2N/A case MDE_DS_DRIVENOTCOMMON:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "drive %s is not common with host %s"),
2N/A ip->drive, ip->node);
2N/A break;
2N/A case MDE_DS_DRIVEINSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "drive %s is in set %s"), ip->drive, ip->node);
2N/A break;
2N/A case MDE_DS_DRIVENOTINSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "drive %s is not in set"), ip->drive);
2N/A break;
2N/A case MDE_DS_DRIVEINUSE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "drive %s is in use"), ip->drive);
2N/A break;
2N/A case MDE_DS_DUPDRIVE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "drive %s is specified more than once"), ip->drive);
2N/A break;
2N/A case MDE_DS_INVALIDSETNAME:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "set name contains invalid characters"));
2N/A break;
2N/A case MDE_DS_HASDRIVES:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unable to delete set, it still has drives"));
2N/A break;
2N/A case MDE_DS_SIDENUMNOTAVAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "maximum number of nodenames exceeded"));
2N/A break;
2N/A case MDE_DS_SETNAMETOOLONG:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "set name is too long"));
2N/A break;
2N/A case MDE_DS_NODENAMETOOLONG:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host name %s is too long"), ip->node);
2N/A break;
2N/A case MDE_DS_OHACANTDELSELF:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A"administrator host %s deletion disallowed in one host admin mode"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_HOSTNOSIDE:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "side information missing for host %s"), ip->node);
2N/A break;
2N/A case MDE_DS_SETLOCKED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s is modifying set - try later or restart rpc.metad"),
2N/A ip->drive);
2N/A break;
2N/A case MDE_DS_ULKSBADKEY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "set unlock failed - bad key"));
2N/A break;
2N/A case MDE_DS_LKSBADKEY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "set lock failed - bad key"));
2N/A break;
2N/A case MDE_DS_WRITEWITHSULK:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "write operation attempted on set with set unlocked"));
2N/A break;
2N/A case MDE_DS_SETCLEANUP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "set \"%s\" is out of date - cleaning up - take failed"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_CANTDELSELF:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A"administrator host %s can't be deleted, other hosts still in set\n"
2N/A"Use -f to override"), ip->node);
2N/A break;
2N/A case MDE_DS_HASMED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unable to delete set, it still has mediator hosts"));
2N/A break;
2N/A case MDE_DS_TOOMANYALIAS:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "%s causes there to be more aliases than allowed"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_ISMED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "%s is already a mediator host"), ip->node);
2N/A break;
2N/A case MDE_DS_ISNOTMED:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "%s is not a mediator host"), ip->node);
2N/A break;
2N/A case MDE_DS_INVALIDMEDNAME:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "mediator name \"%s\" contains invalid characters"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_ALIASNOMATCH:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "mediator alias \"%s\" is not an alias for host "
2N/A "\"%s\""), ip->node, ip->drive);
2N/A break;
2N/A case MDE_DS_NOMEDONHOST:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unable to contact %s on host \"%s\""),
2N/A MED_SERVNAME, ip->node);
2N/A break;
2N/A case MDE_DS_DRIVENOTONHOST:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "drive %s is not present on host %s"),
2N/A ip->drive, ip->node);
2N/A break;
2N/A case MDE_DS_CANTDELMASTER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "master %s can't be deleted, other hosts still in set"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_NOTINMEMBERLIST:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "node %s is not in membership list"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_MNCANTDELSELF:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s can't delete self from multi-owner set\n"
2N/A "while other hosts still in set"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_RPCVERSMISMATCH:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "host %s does not support multi-owner diskset"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_WITHDRAWMASTER:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "master host %s cannot withdraw from multi-owner diskset "
2N/A "when other owner nodes are still present in diskset"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_CANTRESNARF:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "imported set could not be loaded"));
2N/A break;
2N/A case MDE_DS_INSUFQUORUM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "insufficient replica quorum detected. Use "
2N/A "-f to force import of the set"));
2N/A break;
2N/A case MDE_DS_EXTENDEDNM:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "multiple namespace records detected"));
2N/A break;
2N/A case MDE_DS_COMMDCTL_SUSPEND_NYD:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "rpc.mdcommd on host %s is not yet drained during "
2N/A "suspend operation"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_COMMDCTL_SUSPEND_FAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "rpc.mdcommd on host %s failed suspend operation"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_COMMDCTL_REINIT_FAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "rpc.mdcommd on host %s failed reinitialization operation"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_COMMDCTL_RESUME_FAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "rpc.mdcommd on host %s failed resume operation"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_NOTNOW_RECONFIG:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "command terminated, host %s starting reconfig cycle"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_NOTNOW_CMD:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "metaset or metadb command already running on diskset "
2N/A "on host %s"), ip->node);
2N/A break;
2N/A case MDE_DS_COMMD_SEND_FAIL:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "rpc.mdcommd on host %s failed operation"),
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_MASTER_ONLY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "this command must be run on the master node of the set,"
2N/A " which is currently %s"), ip->node);
2N/A break;
2N/A case MDE_DS_SINGLEHOST:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "diskset is auto-take; cannot accept additional hosts"));
2N/A break;
2N/A case MDE_DS_AUTONOTSET:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "auto-take is not enabled on diskset"));
2N/A break;
2N/A case MDE_DS_INVALIDDEVID:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Invalid device id on drive %s on host %s"), ip->drive,
2N/A ip->node);
2N/A break;
2N/A case MDE_DS_SETNOTIMP:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Unable to import set on node %s"), ip->node);
2N/A break;
2N/A case MDE_DS_NOTSELFIDENTIFY:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "Drive %s won't be self identifying"), ip->drive);
2N/A break;
2N/A default:
2N/A (void) snprintf(p, psize, dgettext(TEXT_DOMAIN,
2N/A "unknown diskset error code %d"), ip->errnum);
2N/A break;
2N/A }
2N/A
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * convert error to printable string
2N/A */
2N/Astatic char *
2N/Amde_to_str(
2N/A md_error_t *ep
2N/A)
2N/A{
2N/A static char buf[BUFSIZ];
2N/A size_t bufsz;
2N/A
2N/A /* intialize buf */
2N/A buf[0] = '\0';
2N/A bufsz = sizeof (buf);
2N/A
2N/A /* class specific */
2N/A switch (ep->info.errclass) {
2N/A case MDEC_VOID:
2N/A return (void_to_str(ep, buf, bufsz));
2N/A case MDEC_SYS:
2N/A return (sys_to_str(ep, buf, bufsz));
2N/A case MDEC_RPC:
2N/A return (rpc_to_str(ep, buf, bufsz));
2N/A case MDEC_DEV:
2N/A return (dev_to_str(ep, buf, bufsz));
2N/A case MDEC_USE:
2N/A return (use_to_str(ep, buf, bufsz));
2N/A case MDEC_MD:
2N/A return (md_to_str(ep, buf, bufsz));
2N/A case MDEC_COMP:
2N/A return (comp_to_str(ep, buf, bufsz));
2N/A case MDEC_HSP:
2N/A return (hsp_to_str(ep, buf, bufsz));
2N/A case MDEC_HS:
2N/A return (hs_to_str(ep, buf, bufsz));
2N/A case MDEC_MDDB:
2N/A return (mddb_to_str(ep, buf, bufsz));
2N/A case MDEC_DS:
2N/A return (ds_to_str(ep, buf, bufsz));
2N/A case MDEC_OVERLAP:
2N/A return (overlap_to_str(ep, buf, bufsz));
2N/A default:
2N/A (void) snprintf(buf, bufsz,
2N/A dgettext(TEXT_DOMAIN, "unknown error class %d"),
2N/A ep->info.errclass);
2N/A return (buf);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * print log prefix
2N/A */
2N/Avoid
2N/Amd_logpfx(
2N/A FILE *fp
2N/A)
2N/A{
2N/A time_t t;
2N/A struct tm *tm;
2N/A char buf[100];
2N/A
2N/A if ((time(&t) != (time_t)-1) &&
2N/A ((tm = localtime(&t)) != NULL) &&
2N/A (strftime(buf, sizeof (buf), (char *)0, tm) < sizeof (buf))) {
2N/A (void) fprintf(fp, "%s: ", buf);
2N/A }
2N/A (void) fprintf(fp, "%s: ", myname);
2N/A}
2N/A
2N/A/*
2N/A * varargs sperror()
2N/A */
2N/A/*PRINTFLIKE2*/
2N/Astatic char *
2N/Amde_vsperror(
2N/A md_error_t *ep,
2N/A const char *fmt,
2N/A va_list ap
2N/A)
2N/A{
2N/A static char buf[BUFSIZ];
2N/A size_t bufsz = sizeof (buf);
2N/A char *p = buf;
2N/A char *host1 = "";
2N/A char *host2 = "";
2N/A char *extra1 = "";
2N/A char *extra2 = "";
2N/A char *name1 = "";
2N/A char *name2 = "";
2N/A
2N/A /* get stuff */
2N/A if ((ep->host != NULL) && (*(ep->host) != '\0')) {
2N/A host1 = ep->host;
2N/A host2 = ": ";
2N/A }
2N/A if ((ep->extra != NULL) && (*(ep->extra) != '\0')) {
2N/A extra1 = ep->extra;
2N/A extra2 = ": ";
2N/A }
2N/A if ((ep->name != NULL) && (*(ep->name) != '\0')) {
2N/A name1 = ep->name;
2N/A name2 = ": ";
2N/A }
2N/A
2N/A /* context */
2N/A (void) snprintf(p, bufsz, "%s%s%s%s%s%s",
2N/A host1, host2, extra1, extra2, name1, name2);
2N/A p = &buf[strlen(buf)];
2N/A bufsz -= strlen(buf);
2N/A
2N/A /* user defined part */
2N/A if ((fmt != NULL) && (*fmt != '\0')) {
2N/A (void) vsnprintf(p, bufsz, fmt, ap);
2N/A p = &buf[strlen(buf)];
2N/A bufsz = sizeof (buf) - strlen(buf);
2N/A (void) snprintf(p, bufsz, ": ");
2N/A p = &buf[strlen(buf)];
2N/A bufsz = sizeof (buf) - strlen(buf);
2N/A }
2N/A
2N/A /* error code */
2N/A (void) snprintf(p, bufsz, "%s\n", mde_to_str(ep));
2N/A
2N/A /* return error message */
2N/A return (buf);
2N/A}
2N/A
2N/A/*
2N/A * printf-like sperror()
2N/A */
2N/A/*PRINTFLIKE2*/
2N/Achar *
2N/Amde_sperror(
2N/A md_error_t *ep,
2N/A const char *fmt,
2N/A ...
2N/A)
2N/A{
2N/A va_list ap;
2N/A char *emsg;
2N/A
2N/A va_start(ap, fmt);
2N/A emsg = mde_vsperror(ep, fmt, ap);
2N/A va_end(ap);
2N/A return (emsg);
2N/A}
2N/A
2N/A/*
2N/A * printf-like perror()
2N/A */
2N/A/*PRINTFLIKE2*/
2N/Avoid
2N/Amde_perror(
2N/A md_error_t *ep,
2N/A const char *fmt,
2N/A ...
2N/A)
2N/A{
2N/A va_list ap;
2N/A char *emsg;
2N/A
2N/A /* get error message */
2N/A va_start(ap, fmt);
2N/A emsg = mde_vsperror(ep, fmt, ap);
2N/A va_end(ap);
2N/A assert((emsg != NULL) && (*emsg != '\0'));
2N/A
2N/A /* stderr */
2N/A (void) fprintf(stderr, "%s: %s\n", myname, emsg);
2N/A (void) fflush(stderr);
2N/A
2N/A /* metalog */
2N/A if (metalogfp != NULL) {
2N/A md_logpfx(metalogfp);
2N/A (void) fprintf(metalogfp, "%s\n", emsg);
2N/A (void) fflush(metalogfp);
2N/A (void) fsync(fileno(metalogfp));
2N/A }
2N/A
2N/A /* syslog */
2N/A if (metasyslog) {
2N/A syslog(LOG_ERR, emsg);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * printf-like perror()
2N/A */
2N/A/*PRINTFLIKE1*/
2N/Avoid
2N/Amd_perror(
2N/A const char *fmt,
2N/A ...
2N/A)
2N/A{
2N/A md_error_t status = mdnullerror;
2N/A va_list ap;
2N/A char *emsg;
2N/A
2N/A /* get error message */
2N/A (void) mdsyserror(&status, errno, NULL);
2N/A va_start(ap, fmt);
2N/A emsg = mde_vsperror(&status, fmt, ap);
2N/A va_end(ap);
2N/A assert((emsg != NULL) && (*emsg != '\0'));
2N/A mdclrerror(&status);
2N/A
2N/A /* stderr */
2N/A (void) fprintf(stderr, "%s: %s\n", myname, emsg);
2N/A (void) fflush(stderr);
2N/A
2N/A /* metalog */
2N/A if (metalogfp != NULL) {
2N/A md_logpfx(metalogfp);
2N/A (void) fprintf(metalogfp, "%s\n", emsg);
2N/A (void) fflush(metalogfp);
2N/A (void) fsync(fileno(metalogfp));
2N/A }
2N/A
2N/A /* syslog */
2N/A if (metasyslog) {
2N/A syslog(LOG_ERR, emsg);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * printf-like log
2N/A */
2N/A/*PRINTFLIKE1*/
2N/Avoid
2N/Amd_eprintf(
2N/A const char *fmt,
2N/A ...
2N/A)
2N/A{
2N/A va_list ap;
2N/A
2N/A /* begin */
2N/A va_start(ap, fmt);
2N/A
2N/A /* stderr */
2N/A (void) fprintf(stderr, "%s: ", myname);
2N/A (void) vfprintf(stderr, fmt, ap);
2N/A (void) fflush(stderr);
2N/A
2N/A /* metalog */
2N/A if (metalogfp != NULL) {
2N/A md_logpfx(metalogfp);
2N/A (void) vfprintf(metalogfp, fmt, ap);
2N/A (void) fflush(metalogfp);
2N/A (void) fsync(fileno(metalogfp));
2N/A }
2N/A
2N/A /* syslog */
2N/A if (metasyslog) {
2N/A vsyslog(LOG_ERR, fmt, ap);
2N/A }
2N/A
2N/A /* end */
2N/A va_end(ap);
2N/A}
2N/A
2N/A/*
2N/A * metaclust timing messages logging routine
2N/A *
2N/A * level - The class of the message to be logged. Message will be logged
2N/A * if this is less than or equal to the verbosity level.
2N/A */
2N/Avoid
2N/Ameta_mc_log(int level, const char *fmt, ...)
2N/A{
2N/A va_list args;
2N/A
2N/A va_start(args, fmt);
2N/A /*
2N/A * Log all messages upto MC_LOG2 to syslog regardless of the
2N/A * verbosity level
2N/A */
2N/A if (metasyslog && (level <= MC_LOG2)) {
2N/A if (level <= MC_LOG1)
2N/A (void) vsyslog(LOG_ERR, fmt, args);
2N/A else
2N/A (void) vsyslog(LOG_INFO, fmt, args);
2N/A }
2N/A /*
2N/A * Print all messages to stderr provided the message level is
2N/A * within the verbosity level
2N/A */
2N/A if (level <= verbosity) {
2N/A (void) fprintf(stderr, "%s: ", myname);
2N/A (void) vfprintf(stderr, fmt, args);
2N/A (void) fprintf(stderr, "\n");
2N/A (void) fflush(stderr);
2N/A }
2N/A va_end(args);
2N/A}