xref: /titanic_41/usr/src/lib/libbc/libc/sys/common/maperror.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1995 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Include the SVR4/5.0 errno.h
29  */
30 
31 #include "s5errno.h"
32 
33 /*	from UCB 4.1 82/12/28	*/
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 /*
38  * XError codes from 4.1
39  */
40 
41 #define XEPERM		1		/* Not owner */
42 #define XENOENT		2		/* No such file or directory */
43 #define XESRCH		3		/* No such process */
44 #define XEINTR		4		/* Interrupted system call */
45 #define XEIO		5		/* I/O error */
46 #define XENXIO		6		/* No such device or address */
47 #define XE2BIG		7		/* Arg list too long */
48 #define XENOEXEC	8		/* Exec format error */
49 #define XEBADF		9		/* Bad file number */
50 #define XECHILD		10		/* No children */
51 #define XEAGAIN		11		/* No more processes */
52 #define XENOMEM		12		/* Not enough core */
53 #define XEACCES		13		/* Permission denied */
54 #define XEFAULT		14		/* Bad address */
55 #define XENOTBLK	15		/* Block device required */
56 #define XEBUSY		16		/* Mount device busy */
57 #define XEEXIST		17		/* File exists */
58 #define XEXDEV		18		/* Cross-device link */
59 #define XENODEV		19		/* No such device */
60 #define XENOTDIR	20		/* Not a directory*/
61 #define XEISDIR		21		/* Is a directory */
62 #define XEINVAL		22		/* Invalid argument */
63 #define XENFILE		23		/* File table overflow */
64 #define XEMFILE		24		/* Too many open files */
65 #define XENOTTY		25		/* Not a typewriter */
66 #define XETXTBSY	26		/* Text file busy */
67 #define XEFBIG		27		/* File too large */
68 #define XENOSPC		28		/* No space left on device */
69 #define XESPIPE		29		/* Illegal seek */
70 #define XEROFS		30		/* Read-only file system */
71 #define XEMLINK		31		/* Too many links */
72 #define XEPIPE		32		/* Broken pipe */
73 
74 /* math software */
75 #define XEDOM		33		/* Argument too large */
76 #define XERANGE		34		/* Result too large */
77 
78 /* non-blocking and interrupt i/o */
79 #define XEWOULDBLOCK	35		/* Operation would block */
80 #define XEINPROGRESS	36		/* Operation now in progress */
81 #define XEALREADY	37		/* Operation already in progress */
82 /* ipc/network software */
83 
84 	/* argument errors */
85 #define XENOTSOCK	38		/* Socket operation on non-socket */
86 #define XEDESTADDRREQ	39		/* Destination address required */
87 #define XEMSGSIZE	40		/* Message too long */
88 #define XEPROTOTYPE	41		/* Protocol wrong type for socket */
89 #define XENOPROTOOPT	42		/* Protocol not available */
90 #define XEPROTONOSUPPORT	43		/* Protocol not supported */
91 #define XESOCKTNOSUPPORT	44		/* Socket type not supported */
92 #define XEOPNOTSUPP	45		/* Operation not supported on socket */
93 #define XEPFNOSUPPORT	46		/* Protocol family not supported */
94 #define XEAFNOSUPPORT	47		/* Address family not supported by protocol family */
95 #define XEADDRINUSE	48		/* Address already in use */
96 #define XEADDRNOTAVAIL	49		/* Can't assign requested address */
97 
98 	/* operational errors */
99 #define XENETDOWN	50		/* Network is down */
100 #define XENETUNREACH	51		/* Network is unreachable */
101 #define XENETRESET	52		/* Network dropped connection on reset */
102 #define XECONNABORTED	53		/* Software caused connection abort */
103 #define XECONNRESET	54		/* Connection reset by peer */
104 #define XENOBUFS	55		/* No buffer space available */
105 #define XEISCONN	56		/* Socket is already connected */
106 #define XENOTCONN	57		/* Socket is not connected */
107 #define XESHUTDOWN	58		/* Can't send after socket shutdown */
108 #define XETOOMANYREFS	59		/* Too many references: can't splice */
109 #define XETIMEDOUT	60		/* Connection timed out */
110 #define XECONNREFUSED	61		/* Connection refused */
111 
112 	/* */
113 #define XELOOP		62		/* Too many levels of symbolic links */
114 #define XENAMETOOLONG	63		/* File name too long */
115 
116 /* should be rearranged */
117 #define XEHOSTDOWN	64		/* Host is down */
118 #define XEHOSTUNREACH	65		/* No route to host */
119 #define XENOTEMPTY	66		/* Directory not empty */
120 
121 /* quotas & mush */
122 #define XEPROCLIM	67		/* Too many processes */
123 #define XEUSERS		68		/* Too many users */
124 #define XEDQUOT		69		/* Disc quota exceeded */
125 
126 /* Network File System */
127 #define XESTALE		70		/* Stale NFS file handle */
128 #define XEREMOTE	71		/* Too many levels of remote in path */
129 
130 /* streams */
131 #define XENOSTR		72		/* Device is not a stream */
132 #define XETIME		73		/* Timer expired */
133 #define XENOSR		74		/* Out of streams resources */
134 #define XENOMSG		75		/* No message of desired type */
135 #define XEBADMSG	76		/* Trying to read unreadable message */
136 
137 /* SystemV IPC */
138 #define XEIDRM		77		/* Identifier removed */
139 
140 /* SystemV Record Locking */
141 #define XEDEADLK	78		/* Deadlock condition. */
142 #define XENOLCK		79		/* No record locks available. */
143 
144 /* POSIX */
145 #define XENOSYS		90		/* function not implemented */
146 
147 
maperror()148 void	maperror()
149 {
150 	extern int errno;
151 
152 	if (errno == 0)
153 	return;
154 
155 	switch (errno) {
156 	case ENOMSG:
157 		errno = XENOMSG;	/* No message of desired type */
158 		break;
159 	case EIDRM:
160 		errno = XEIDRM;		/* Identifier removed */
161 		break;
162 	case EDEADLK:
163 		errno = XEDEADLK;	/* Deadlock condition. */
164 		break;
165 	case ENOLCK:
166 		errno = XENOLCK;	/* No record locks available. */
167 		break;
168 	case ENOSTR:
169 		errno = XENOSTR;	/* Device not a stream */
170 		break;
171 	case ETIME:
172 		errno = XETIME;		/* timer expired */
173 		break;
174 	case ENOSR:
175 		errno = XENOSR;		/* out of streams resources */
176 		break;
177 	case EBADMSG:
178 		errno = XEBADMSG;	/* trying to read unreadable message */
179 		break;
180 	case ENOSYS:
181 		errno = XENOSYS;	/* Unsupported file system operation */
182 		break;
183 	case ELOOP:
184 		errno = XELOOP;		/* Symbolic link loop */
185 		break;
186 	case ERESTART:
187 		errno = XEINTR;		/* Convert ERESTART to EINTR for
188 					   interrupted system calls */
189 		break;
190 	case ENAMETOOLONG:
191 		errno = XENAMETOOLONG; /* File name too long */
192 		break;
193 	case ENOTEMPTY:
194 		errno = XENOTEMPTY;	/* directory not empty */
195 		break;
196 	case EUSERS:
197 		errno = XEUSERS;	/* Too many users (for UFS) */
198 		break;
199 	case ENOTSOCK:
200 		errno = XENOTSOCK;	/* Socket operation on non-socket */
201 		break;
202 	case EDESTADDRREQ:
203 		errno = XEDESTADDRREQ;	/* Destination address required */
204 		break;
205 	case EMSGSIZE:
206 		errno = XEMSGSIZE;	/* Message too long */
207 		break;
208 	case EPROTOTYPE:
209 		errno = XEPROTOTYPE;	/* Protocol wrong type for socket */
210 		break;
211 	case ENOPROTOOPT:
212 		errno = XENOPROTOOPT;	/* Protocol not available */
213 		break;
214 	case EPROTONOSUPPORT:
215 		errno = XEPROTONOSUPPORT;	/* Protocol not supported */
216 		break;
217 	case ESOCKTNOSUPPORT:
218 		errno = XESOCKTNOSUPPORT;	/* Socket type not supported */
219 		break;
220 	case EOPNOTSUPP:
221 		errno = XEOPNOTSUPP;	/* Operation not supported on socket */
222 		break;
223 	case EPFNOSUPPORT:
224 		errno = XEPFNOSUPPORT;	/* Protocol family not supported */
225 		break;
226 	case EAFNOSUPPORT:
227 		errno = XEAFNOSUPPORT;	/* Address family not supported by */
228 		break;
229 	case EADDRINUSE:
230 		errno = XEADDRINUSE;	/* Address already in use */
231 		break;
232 	case EADDRNOTAVAIL:
233 		errno = XEADDRNOTAVAIL; /* Can't assign requested address */
234 		break;
235 	case ENETDOWN:
236 		errno = XENETDOWN;	/* Network is down */
237 		break;
238 	case ENETUNREACH:
239 		errno = XENETUNREACH;	/* Network is unreachable */
240 		break;
241 	case ENETRESET:
242 		errno = XENETRESET;	/* Dropped connection due to reset */
243 		break;
244 	case ECONNABORTED:
245 		errno = XECONNABORTED;	/* Software caused connection abort */
246 		break;
247 	case ECONNRESET:
248 		errno = XECONNRESET;	/* Connection reset by peer */
249 		break;
250 	case ENOBUFS:
251 		errno = XENOBUFS;	/* No buffer space available */
252 		break;
253 	case EISCONN:
254 		errno = XEISCONN;	/* Socket is already connected */
255 		break;
256 	case ENOTCONN:
257 		errno = XENOTCONN;	/* Socket is not connected */
258 		break;
259 	case ESHUTDOWN:
260 		errno = XESHUTDOWN;	/* Can't send after socket shutdown */
261 		break;
262 	case ETOOMANYREFS:
263 		errno = XETOOMANYREFS;	/* Too many references: can't splice */
264 		break;
265 	case ETIMEDOUT:
266 		errno = XETIMEDOUT;	/* Connection timed out */
267 		break;
268 	case ECONNREFUSED:
269 		errno = XECONNREFUSED;	/* Connection refused */
270 		break;
271 	case EHOSTDOWN:
272 		errno = XEHOSTDOWN;	/* Host is down */
273 		break;
274 	case EHOSTUNREACH:
275 		errno = XEHOSTUNREACH;	/* No route to host */
276 		break;
277 	case EALREADY:
278 		errno = XEALREADY;
279 		break;
280 	case EINPROGRESS:
281 		errno = XEINPROGRESS;
282 		break;
283 	case ESTALE:
284 		errno = XESTALE;	/* Stale NFS file handle */
285 		break;
286 	case EDQUOT:
287 		errno = XEDQUOT;	/* Disc quota exceeded */
288 		break;
289 	default:
290 		break;
291 	}
292 
293 	return;
294 
295 }
296