1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1997,2008 Oracle.  All rights reserved.
5 */
6/*
7 * Copyright (c) 1988, 1993
8 *	The Regents of the University of California.  All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 *    may be used to endorse or promote products derived from this software
20 *    without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $Id: strerror.c,v 12.14 2008/01/08 20:58:08 bostic Exp $
35 */
36
37/*
38 * Copyright (c) 1982, 1985, 1993
39 *	The Regents of the University of California.  All rights reserved.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the above copyright
45 *    notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 *    notice, this list of conditions and the following disclaimer in the
48 *    documentation and/or other materials provided with the distribution.
49 * 3. All advertising materials mentioning features or use of this software
50 *    must display the following acknowledgement:
51 *	This product includes software developed by the University of
52 *	California, Berkeley and its contributors.
53 * 4. Neither the name of the University nor the names of its contributors
54 *    may be used to endorse or promote products derived from this software
55 *    without specific prior written permission.
56 *
57 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
58 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
61 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
62 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
63 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
65 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * SUCH DAMAGE.
68 *
69 * __FBSDID("FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/errlst.c,v 1.8 2005/04/02 12:33:28 das Exp $");
70 */
71
72#include "db_config.h"
73
74#include "db_int.h"
75
76/*
77 * __db_strerror --
78 *	Return the string associated with an errno.
79 *
80 * PUBLIC: #ifndef HAVE_STRERROR
81 * PUBLIC: char *strerror __P((int));
82 * PUBLIC: #endif
83 */
84char *
85strerror(num)
86	int num;
87{
88#define	ERRSTR(v, s) do {						\
89	if (num == (v))							\
90		return (s);						\
91} while (0)
92	ERRSTR(0, "Undefined error: 0");
93	ERRSTR(EPERM, "Operation not permitted");
94	ERRSTR(ENOENT, "No such file or directory");
95	ERRSTR(ESRCH, "No such process");
96	ERRSTR(EINTR, "Interrupted system call");
97	ERRSTR(EIO, "Input/output error");
98	ERRSTR(ENXIO, "Device not configured");
99	ERRSTR(E2BIG, "Argument list too long");
100	ERRSTR(ENOEXEC, "Exec format error");
101	ERRSTR(EBADF, "Bad file descriptor");
102	ERRSTR(ECHILD, "No child processes");
103	ERRSTR(EDEADLK, "Resource deadlock avoided");
104	ERRSTR(ENOMEM, "Cannot allocate memory");
105	ERRSTR(EACCES, "Permission denied");
106	ERRSTR(EFAULT, "Bad address");
107	ERRSTR(ENOTBLK, "Block device required");
108	ERRSTR(EBUSY, "Device busy");
109	ERRSTR(EEXIST, "File exists");
110	ERRSTR(EXDEV, "Cross-device link");
111	ERRSTR(ENODEV, "Operation not supported by device");
112	ERRSTR(ENOTDIR, "Not a directory");
113	ERRSTR(EISDIR, "Is a directory");
114	ERRSTR(EINVAL, "Invalid argument");
115	ERRSTR(ENFILE, "Too many open files in system");
116	ERRSTR(EMFILE, "Too many open files");
117	ERRSTR(ENOTTY, "Inappropriate ioctl for device");
118	ERRSTR(ETXTBSY, "Text file busy");
119	ERRSTR(EFBIG, "File too large");
120	ERRSTR(ENOSPC, "No space left on device");
121	ERRSTR(ESPIPE, "Illegal seek");
122	ERRSTR(EROFS, "Read-only file system");
123	ERRSTR(EMLINK, "Too many links");
124	ERRSTR(EPIPE, "Broken pipe");
125
126/* math software */
127	ERRSTR(EDOM, "Numerical argument out of domain");
128	ERRSTR(ERANGE, "Result too large");
129
130/* non-blocking and interrupt i/o */
131	ERRSTR(EAGAIN, "Resource temporarily unavailable");
132	ERRSTR(EWOULDBLOCK, "Resource temporarily unavailable");
133	ERRSTR(EINPROGRESS, "Operation now in progress");
134	ERRSTR(EALREADY, "Operation already in progress");
135
136/* ipc/network software -- argument errors */
137	ERRSTR(ENOTSOCK, "Socket operation on non-socket");
138	ERRSTR(EDESTADDRREQ, "Destination address required");
139	ERRSTR(EMSGSIZE, "Message too long");
140	ERRSTR(EPROTOTYPE, "Protocol wrong type for socket");
141	ERRSTR(ENOPROTOOPT, "Protocol not available");
142	ERRSTR(EPROTONOSUPPORT, "Protocol not supported");
143	ERRSTR(ESOCKTNOSUPPORT, "Socket type not supported");
144	ERRSTR(EOPNOTSUPP, "Operation not supported");
145	ERRSTR(EPFNOSUPPORT, "Protocol family not supported");
146	ERRSTR(EAFNOSUPPORT, "Address family not supported by protocol family");
147	ERRSTR(EADDRINUSE, "Address already in use");
148	ERRSTR(EADDRNOTAVAIL, "Can't assign requested address");
149
150/* ipc/network software -- operational errors */
151	ERRSTR(ENETDOWN, "Network is down");
152	ERRSTR(ENETUNREACH, "Network is unreachable");
153	ERRSTR(ENETRESET, "Network dropped connection on reset");
154	ERRSTR(ECONNABORTED, "Software caused connection abort");
155	ERRSTR(ECONNRESET, "Connection reset by peer");
156	ERRSTR(ENOBUFS, "No buffer space available");
157	ERRSTR(EISCONN, "Socket is already connected");
158	ERRSTR(ENOTCONN, "Socket is not connected");
159	ERRSTR(ESHUTDOWN, "Can't send after socket shutdown");
160	ERRSTR(ETOOMANYREFS, "Too many references: can't splice");
161	ERRSTR(ETIMEDOUT, "Operation timed out");
162	ERRSTR(ECONNREFUSED, "Connection refused");
163
164	ERRSTR(ELOOP, "Too many levels of symbolic links");
165	ERRSTR(ENAMETOOLONG, "File name too long");
166
167/* should be rearranged */
168	ERRSTR(EHOSTDOWN, "Host is down");
169	ERRSTR(EHOSTUNREACH, "No route to host");
170	ERRSTR(ENOTEMPTY, "Directory not empty");
171
172/* quotas & mush */
173	ERRSTR(EPROCLIM, "Too many processes");
174	ERRSTR(EUSERS, "Too many users");
175	ERRSTR(EDQUOT, "Disc quota exceeded");
176
177/* Network File System */
178	ERRSTR(ESTALE, "Stale NFS file handle");
179	ERRSTR(EREMOTE, "Too many levels of remote in path");
180	ERRSTR(EBADRPC, "RPC struct is bad");
181	ERRSTR(ERPCMISMATCH, "RPC version wrong");
182	ERRSTR(EPROGUNAVAIL, "RPC prog. not avail");
183	ERRSTR(EPROGMISMATCH, "Program version wrong");
184	ERRSTR(EPROCUNAVAIL, "Bad procedure for program");
185
186	ERRSTR(ENOLCK, "No locks available");
187	ERRSTR(ENOSYS, "Function not implemented");
188	ERRSTR(EFTYPE, "Inappropriate file type or format");
189#ifdef EAUTH
190	ERRSTR(EAUTH, "Authentication error");
191#endif
192#ifdef ENEEDAUTH
193	ERRSTR(ENEEDAUTH, "Need authenticator");
194#endif
195	ERRSTR(EIDRM, "Identifier removed");
196	ERRSTR(ENOMSG, "No message of desired type");
197#ifdef EOVERFLOW
198	ERRSTR(EOVERFLOW, "Value too large to be stored in data type");
199#endif
200	ERRSTR(ECANCELED, "Operation canceled");
201	ERRSTR(EILSEQ, "Illegal byte sequence");
202#ifdef ENOATTR
203	ERRSTR(ENOATTR, "Attribute not found");
204#endif
205
206/* General */
207#ifdef EDOOFUS
208	ERRSTR(EDOOFUS, "Programming error");
209#endif
210
211#ifdef EBADMSG
212	ERRSTR(EBADMSG, "Bad message");
213#endif
214#ifdef EMULTIHOP
215	ERRSTR(EMULTIHOP, "Multihop attempted");
216#endif
217#ifdef ENOLINK
218	ERRSTR(ENOLINK, "Link has been severed");
219#endif
220#ifdef EPROTO
221	ERRSTR(EPROTO, "Protocol error");
222#endif
223
224	return (__db_unknown_error(num));
225}
226