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 * BSD 3 Clause License
2N/A *
2N/A * Copyright (c) 2007, The Storage Networking Industry Association.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions
2N/A * are met:
2N/A * - Redistributions of source code must retain the above copyright
2N/A * notice, this list of conditions and the following disclaimer.
2N/A *
2N/A * - Redistributions in binary form must reproduce the above copyright
2N/A * notice, this list of conditions and the following disclaimer in
2N/A * the documentation and/or other materials provided with the
2N/A * distribution.
2N/A *
2N/A * - Neither the name of The Storage Networking Industry Association (SNIA)
2N/A * nor the names of its contributors may be used to endorse or promote
2N/A * products derived from this software without specific prior written
2N/A * permission.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2N/A * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2N/A * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2N/A * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2N/A * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2N/A * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2N/A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2N/A * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2N/A * POSSIBILITY OF SUCH DAMAGE.
2N/A */
2N/A
2N/A#include <string.h>
2N/A#include <libndmp.h>
2N/A
2N/Aint ndmp_errno;
2N/A
2N/Astatic const struct {
2N/A int err;
2N/A const char *msg;
2N/A} ndmp_errlist[] = {
2N/A { ENDMP_DOOR_SRV_TIMEOUT, "No answer from ndmpd service." },
2N/A { ENDMP_INVALID_ARG, "Invalid argument." },
2N/A { ENDMP_DOOR_SRV_OPERATION, "NDMP server operation failed." },
2N/A { ENDMP_DOOR_OPEN, "Door file open error." },
2N/A { ENDMP_MEM_ALLOC, "Out of memory." },
2N/A { ENDMP_DOOR_ENCODE_START, "Data encode start failed." },
2N/A { ENDMP_DOOR_ENCODE_FINISH, "Data encode finish failed." },
2N/A { ENDMP_DOOR_DECODE_FINISH, "Data decode finish failed." },
2N/A { ENDMP_SMF_PERM, "SMF permission denied." },
2N/A { ENDMP_SMF_INTERNAL, "SMF internal error." },
2N/A { ENDMP_SMF_PROP, "SMF property not set." },
2N/A { ENDMP_SMF_PROP_GRP, "Invalid SMF property group" },
2N/A { ENDMP_ENOENT, "No such file or directory" },
2N/A { ENDMP_INVALID_PROPVAL, "Invalid property value" },
2N/A { ENDMP_INVALID_DTYPE, "Invalid drive-type" }
2N/A};
2N/A
2N/Astatic const int ndmp_nerr = sizeof (ndmp_errlist) / sizeof (ndmp_errlist[0]);
2N/A
2N/Aconst char *
2N/Andmp_strerror(int errnum)
2N/A{
2N/A int i;
2N/A
2N/A if (((errnum >= ENDMP_BASE) && (errnum - ENDMP_BASE)) < ndmp_nerr) {
2N/A for (i = 0; i < ndmp_nerr; i++) {
2N/A if (ndmp_errlist[i].err == errnum)
2N/A return (ndmp_errlist[i].msg);
2N/A }
2N/A }
2N/A return ("Unknown error");
2N/A}