1*7917SReza.Sabdar@Sun.COM /*
2*7917SReza.Sabdar@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3*7917SReza.Sabdar@Sun.COM * Use is subject to license terms.
4*7917SReza.Sabdar@Sun.COM */
5*7917SReza.Sabdar@Sun.COM
6*7917SReza.Sabdar@Sun.COM /*
7*7917SReza.Sabdar@Sun.COM * BSD 3 Clause License
8*7917SReza.Sabdar@Sun.COM *
9*7917SReza.Sabdar@Sun.COM * Copyright (c) 2007, The Storage Networking Industry Association.
10*7917SReza.Sabdar@Sun.COM *
11*7917SReza.Sabdar@Sun.COM * Redistribution and use in source and binary forms, with or without
12*7917SReza.Sabdar@Sun.COM * modification, are permitted provided that the following conditions
13*7917SReza.Sabdar@Sun.COM * are met:
14*7917SReza.Sabdar@Sun.COM * - Redistributions of source code must retain the above copyright
15*7917SReza.Sabdar@Sun.COM * notice, this list of conditions and the following disclaimer.
16*7917SReza.Sabdar@Sun.COM *
17*7917SReza.Sabdar@Sun.COM * - Redistributions in binary form must reproduce the above copyright
18*7917SReza.Sabdar@Sun.COM * notice, this list of conditions and the following disclaimer in
19*7917SReza.Sabdar@Sun.COM * the documentation and/or other materials provided with the
20*7917SReza.Sabdar@Sun.COM * distribution.
21*7917SReza.Sabdar@Sun.COM *
22*7917SReza.Sabdar@Sun.COM * - Neither the name of The Storage Networking Industry Association (SNIA)
23*7917SReza.Sabdar@Sun.COM * nor the names of its contributors may be used to endorse or promote
24*7917SReza.Sabdar@Sun.COM * products derived from this software without specific prior written
25*7917SReza.Sabdar@Sun.COM * permission.
26*7917SReza.Sabdar@Sun.COM *
27*7917SReza.Sabdar@Sun.COM * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28*7917SReza.Sabdar@Sun.COM * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29*7917SReza.Sabdar@Sun.COM * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30*7917SReza.Sabdar@Sun.COM * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31*7917SReza.Sabdar@Sun.COM * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32*7917SReza.Sabdar@Sun.COM * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33*7917SReza.Sabdar@Sun.COM * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34*7917SReza.Sabdar@Sun.COM * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35*7917SReza.Sabdar@Sun.COM * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36*7917SReza.Sabdar@Sun.COM * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37*7917SReza.Sabdar@Sun.COM * POSSIBILITY OF SUCH DAMAGE.
38*7917SReza.Sabdar@Sun.COM */
39*7917SReza.Sabdar@Sun.COM
40*7917SReza.Sabdar@Sun.COM #include <string.h>
41*7917SReza.Sabdar@Sun.COM #include <libndmp.h>
42*7917SReza.Sabdar@Sun.COM
43*7917SReza.Sabdar@Sun.COM int ndmp_errno;
44*7917SReza.Sabdar@Sun.COM
45*7917SReza.Sabdar@Sun.COM static const struct {
46*7917SReza.Sabdar@Sun.COM int err;
47*7917SReza.Sabdar@Sun.COM const char *msg;
48*7917SReza.Sabdar@Sun.COM } ndmp_errlist[] = {
49*7917SReza.Sabdar@Sun.COM { ENDMP_DOOR_SRV_TIMEOUT, "No answer from ndmpd service." },
50*7917SReza.Sabdar@Sun.COM { ENDMP_INVALID_ARG, "Invalid argument." },
51*7917SReza.Sabdar@Sun.COM { ENDMP_DOOR_SRV_OPERATION, "NDMP server operation failed." },
52*7917SReza.Sabdar@Sun.COM { ENDMP_DOOR_OPEN, "Door file open error." },
53*7917SReza.Sabdar@Sun.COM { ENDMP_MEM_ALLOC, "Out of memory." },
54*7917SReza.Sabdar@Sun.COM { ENDMP_DOOR_ENCODE_START, "Data encode start failed." },
55*7917SReza.Sabdar@Sun.COM { ENDMP_DOOR_ENCODE_FINISH, "Data encode finish failed." },
56*7917SReza.Sabdar@Sun.COM { ENDMP_DOOR_DECODE_FINISH, "Data decode finish failed." },
57*7917SReza.Sabdar@Sun.COM { ENDMP_SMF_PERM, "SMF permission denied." },
58*7917SReza.Sabdar@Sun.COM { ENDMP_SMF_INTERNAL, "SMF internal error." },
59*7917SReza.Sabdar@Sun.COM { ENDMP_SMF_PROP, "SMF property not set." },
60*7917SReza.Sabdar@Sun.COM { ENDMP_SMF_PROP_GRP, "Invalid SMF property group" }
61*7917SReza.Sabdar@Sun.COM };
62*7917SReza.Sabdar@Sun.COM
63*7917SReza.Sabdar@Sun.COM static const int ndmp_nerr = sizeof (ndmp_errlist) / sizeof (ndmp_errlist[0]);
64*7917SReza.Sabdar@Sun.COM
65*7917SReza.Sabdar@Sun.COM const char *
ndmp_strerror(int errnum)66*7917SReza.Sabdar@Sun.COM ndmp_strerror(int errnum)
67*7917SReza.Sabdar@Sun.COM {
68*7917SReza.Sabdar@Sun.COM int i;
69*7917SReza.Sabdar@Sun.COM
70*7917SReza.Sabdar@Sun.COM if (((errnum >= ENDMP_BASE) && (errnum - ENDMP_BASE)) < ndmp_nerr) {
71*7917SReza.Sabdar@Sun.COM for (i = 0; i < ndmp_nerr; i++) {
72*7917SReza.Sabdar@Sun.COM if (ndmp_errlist[i].err == errnum)
73*7917SReza.Sabdar@Sun.COM return (ndmp_errlist[i].msg);
74*7917SReza.Sabdar@Sun.COM }
75*7917SReza.Sabdar@Sun.COM }
76*7917SReza.Sabdar@Sun.COM return ("Unknown error");
77*7917SReza.Sabdar@Sun.COM }
78