1 /*
2 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2016-2017 The strace developers.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "tests.h"
30 #include <errno.h>
31
32 #define CASE(x) case x: return #x
33
34 const char *
errno2name(void)35 errno2name(void)
36 {
37 switch (errno) {
38 /* names taken from linux/errnoent.h */
39 #ifdef E2BIG
40 CASE(E2BIG);
41 #endif
42 #ifdef EACCES
43 CASE(EACCES);
44 #endif
45 #ifdef EADDRINUSE
46 CASE(EADDRINUSE);
47 #endif
48 #ifdef EADDRNOTAVAIL
49 CASE(EADDRNOTAVAIL);
50 #endif
51 #ifdef EADV
52 CASE(EADV);
53 #endif
54 #ifdef EAFNOSUPPORT
55 CASE(EAFNOSUPPORT);
56 #endif
57 #ifdef EAGAIN
58 CASE(EAGAIN);
59 #endif
60 #ifdef EALREADY
61 CASE(EALREADY);
62 #endif
63 #ifdef EBADCOOKIE
64 CASE(EBADCOOKIE);
65 #endif
66 #ifdef EBADE
67 CASE(EBADE);
68 #endif
69 #ifdef EBADF
70 CASE(EBADF);
71 #endif
72 #ifdef EBADFD
73 CASE(EBADFD);
74 #endif
75 #ifdef EBADHANDLE
76 CASE(EBADHANDLE);
77 #endif
78 #ifdef EBADMSG
79 CASE(EBADMSG);
80 #endif
81 #ifdef EBADR
82 CASE(EBADR);
83 #endif
84 #ifdef EBADRQC
85 CASE(EBADRQC);
86 #endif
87 #ifdef EBADSLT
88 CASE(EBADSLT);
89 #endif
90 #ifdef EBADTYPE
91 CASE(EBADTYPE);
92 #endif
93 #ifdef EBFONT
94 CASE(EBFONT);
95 #endif
96 #ifdef EBUSY
97 CASE(EBUSY);
98 #endif
99 #ifdef ECANCELED
100 CASE(ECANCELED);
101 #endif
102 #ifdef ECHILD
103 CASE(ECHILD);
104 #endif
105 #ifdef ECHRNG
106 CASE(ECHRNG);
107 #endif
108 #ifdef ECOMM
109 CASE(ECOMM);
110 #endif
111 #ifdef ECONNABORTED
112 CASE(ECONNABORTED);
113 #endif
114 #ifdef ECONNREFUSED
115 CASE(ECONNREFUSED);
116 #endif
117 #ifdef ECONNRESET
118 CASE(ECONNRESET);
119 #endif
120 #ifdef EDEADLK
121 CASE(EDEADLK);
122 #endif
123 #ifdef EDESTADDRREQ
124 CASE(EDESTADDRREQ);
125 #endif
126 #ifdef EDOM
127 CASE(EDOM);
128 #endif
129 #ifdef EDOTDOT
130 CASE(EDOTDOT);
131 #endif
132 #ifdef EDQUOT
133 CASE(EDQUOT);
134 #endif
135 #ifdef EEXIST
136 CASE(EEXIST);
137 #endif
138 #ifdef EFAULT
139 CASE(EFAULT);
140 #endif
141 #ifdef EFBIG
142 CASE(EFBIG);
143 #endif
144 #ifdef EHOSTDOWN
145 CASE(EHOSTDOWN);
146 #endif
147 #ifdef EHOSTUNREACH
148 CASE(EHOSTUNREACH);
149 #endif
150 #ifdef EHWPOISON
151 CASE(EHWPOISON);
152 #endif
153 #ifdef EIDRM
154 CASE(EIDRM);
155 #endif
156 #ifdef EILSEQ
157 CASE(EILSEQ);
158 #endif
159 #ifdef EINPROGRESS
160 CASE(EINPROGRESS);
161 #endif
162 #ifdef EINTR
163 CASE(EINTR);
164 #endif
165 #ifdef EINVAL
166 CASE(EINVAL);
167 #endif
168 #ifdef EIO
169 CASE(EIO);
170 #endif
171 #ifdef EIOCBQUEUED
172 CASE(EIOCBQUEUED);
173 #endif
174 #ifdef EISCONN
175 CASE(EISCONN);
176 #endif
177 #ifdef EISDIR
178 CASE(EISDIR);
179 #endif
180 #ifdef EISNAM
181 CASE(EISNAM);
182 #endif
183 #ifdef EJUKEBOX
184 CASE(EJUKEBOX);
185 #endif
186 #ifdef EKEYEXPIRED
187 CASE(EKEYEXPIRED);
188 #endif
189 #ifdef EKEYREJECTED
190 CASE(EKEYREJECTED);
191 #endif
192 #ifdef EKEYREVOKED
193 CASE(EKEYREVOKED);
194 #endif
195 #ifdef EL2HLT
196 CASE(EL2HLT);
197 #endif
198 #ifdef EL2NSYNC
199 CASE(EL2NSYNC);
200 #endif
201 #ifdef EL3HLT
202 CASE(EL3HLT);
203 #endif
204 #ifdef EL3RST
205 CASE(EL3RST);
206 #endif
207 #ifdef ELIBACC
208 CASE(ELIBACC);
209 #endif
210 #ifdef ELIBBAD
211 CASE(ELIBBAD);
212 #endif
213 #ifdef ELIBEXEC
214 CASE(ELIBEXEC);
215 #endif
216 #ifdef ELIBMAX
217 CASE(ELIBMAX);
218 #endif
219 #ifdef ELIBSCN
220 CASE(ELIBSCN);
221 #endif
222 #ifdef ELNRNG
223 CASE(ELNRNG);
224 #endif
225 #ifdef ELOOP
226 CASE(ELOOP);
227 #endif
228 #ifdef EMEDIUMTYPE
229 CASE(EMEDIUMTYPE);
230 #endif
231 #ifdef EMFILE
232 CASE(EMFILE);
233 #endif
234 #ifdef EMLINK
235 CASE(EMLINK);
236 #endif
237 #ifdef EMSGSIZE
238 CASE(EMSGSIZE);
239 #endif
240 #ifdef EMULTIHOP
241 CASE(EMULTIHOP);
242 #endif
243 #ifdef ENAMETOOLONG
244 CASE(ENAMETOOLONG);
245 #endif
246 #ifdef ENAVAIL
247 CASE(ENAVAIL);
248 #endif
249 #ifdef ENETDOWN
250 CASE(ENETDOWN);
251 #endif
252 #ifdef ENETRESET
253 CASE(ENETRESET);
254 #endif
255 #ifdef ENETUNREACH
256 CASE(ENETUNREACH);
257 #endif
258 #ifdef ENFILE
259 CASE(ENFILE);
260 #endif
261 #ifdef ENOANO
262 CASE(ENOANO);
263 #endif
264 #ifdef ENOBUFS
265 CASE(ENOBUFS);
266 #endif
267 #ifdef ENOCSI
268 CASE(ENOCSI);
269 #endif
270 #ifdef ENODATA
271 CASE(ENODATA);
272 #endif
273 #ifdef ENODEV
274 CASE(ENODEV);
275 #endif
276 #ifdef ENOENT
277 CASE(ENOENT);
278 #endif
279 #ifdef ENOEXEC
280 CASE(ENOEXEC);
281 #endif
282 #ifdef ENOIOCTLCMD
283 CASE(ENOIOCTLCMD);
284 #endif
285 #ifdef ENOKEY
286 CASE(ENOKEY);
287 #endif
288 #ifdef ENOLCK
289 CASE(ENOLCK);
290 #endif
291 #ifdef ENOLINK
292 CASE(ENOLINK);
293 #endif
294 #ifdef ENOMEDIUM
295 CASE(ENOMEDIUM);
296 #endif
297 #ifdef ENOMEM
298 CASE(ENOMEM);
299 #endif
300 #ifdef ENOMSG
301 CASE(ENOMSG);
302 #endif
303 #ifdef ENONET
304 CASE(ENONET);
305 #endif
306 #ifdef ENOPKG
307 CASE(ENOPKG);
308 #endif
309 #ifdef ENOPROTOOPT
310 CASE(ENOPROTOOPT);
311 #endif
312 #ifdef ENOSPC
313 CASE(ENOSPC);
314 #endif
315 #ifdef ENOSR
316 CASE(ENOSR);
317 #endif
318 #ifdef ENOSTR
319 CASE(ENOSTR);
320 #endif
321 #ifdef ENOSYS
322 CASE(ENOSYS);
323 #endif
324 #ifdef ENOTBLK
325 CASE(ENOTBLK);
326 #endif
327 #ifdef ENOTCONN
328 CASE(ENOTCONN);
329 #endif
330 #ifdef ENOTDIR
331 CASE(ENOTDIR);
332 #endif
333 #ifdef ENOTEMPTY
334 CASE(ENOTEMPTY);
335 #endif
336 #ifdef ENOTNAM
337 CASE(ENOTNAM);
338 #endif
339 #ifdef ENOTRECOVERABLE
340 CASE(ENOTRECOVERABLE);
341 #endif
342 #ifdef ENOTSOCK
343 CASE(ENOTSOCK);
344 #endif
345 #ifdef ENOTSUPP
346 CASE(ENOTSUPP);
347 #endif
348 #ifdef ENOTSYNC
349 CASE(ENOTSYNC);
350 #endif
351 #ifdef ENOTTY
352 CASE(ENOTTY);
353 #endif
354 #ifdef ENOTUNIQ
355 CASE(ENOTUNIQ);
356 #endif
357 #ifdef ENXIO
358 CASE(ENXIO);
359 #endif
360 #ifdef EOPENSTALE
361 CASE(EOPENSTALE);
362 #endif
363 #ifdef EOPNOTSUPP
364 CASE(EOPNOTSUPP);
365 #endif
366 #ifdef EOVERFLOW
367 CASE(EOVERFLOW);
368 #endif
369 #ifdef EOWNERDEAD
370 CASE(EOWNERDEAD);
371 #endif
372 #ifdef EPERM
373 CASE(EPERM);
374 #endif
375 #ifdef EPFNOSUPPORT
376 CASE(EPFNOSUPPORT);
377 #endif
378 #ifdef EPIPE
379 CASE(EPIPE);
380 #endif
381 #ifdef EPROBE_DEFER
382 CASE(EPROBE_DEFER);
383 #endif
384 #ifdef EPROTO
385 CASE(EPROTO);
386 #endif
387 #ifdef EPROTONOSUPPORT
388 CASE(EPROTONOSUPPORT);
389 #endif
390 #ifdef EPROTOTYPE
391 CASE(EPROTOTYPE);
392 #endif
393 #ifdef ERANGE
394 CASE(ERANGE);
395 #endif
396 #ifdef EREMCHG
397 CASE(EREMCHG);
398 #endif
399 #ifdef EREMOTE
400 CASE(EREMOTE);
401 #endif
402 #ifdef EREMOTEIO
403 CASE(EREMOTEIO);
404 #endif
405 #ifdef ERESTART
406 CASE(ERESTART);
407 #endif
408 #ifdef ERESTARTNOHAND
409 CASE(ERESTARTNOHAND);
410 #endif
411 #ifdef ERESTARTNOINTR
412 CASE(ERESTARTNOINTR);
413 #endif
414 #ifdef ERESTARTSYS
415 CASE(ERESTARTSYS);
416 #endif
417 #ifdef ERESTART_RESTARTBLOCK
418 CASE(ERESTART_RESTARTBLOCK);
419 #endif
420 #ifdef ERFKILL
421 CASE(ERFKILL);
422 #endif
423 #ifdef EROFS
424 CASE(EROFS);
425 #endif
426 #ifdef ESERVERFAULT
427 CASE(ESERVERFAULT);
428 #endif
429 #ifdef ESHUTDOWN
430 CASE(ESHUTDOWN);
431 #endif
432 #ifdef ESOCKTNOSUPPORT
433 CASE(ESOCKTNOSUPPORT);
434 #endif
435 #ifdef ESPIPE
436 CASE(ESPIPE);
437 #endif
438 #ifdef ESRCH
439 CASE(ESRCH);
440 #endif
441 #ifdef ESRMNT
442 CASE(ESRMNT);
443 #endif
444 #ifdef ESTALE
445 CASE(ESTALE);
446 #endif
447 #ifdef ESTRPIPE
448 CASE(ESTRPIPE);
449 #endif
450 #ifdef ETIME
451 CASE(ETIME);
452 #endif
453 #ifdef ETIMEDOUT
454 CASE(ETIMEDOUT);
455 #endif
456 #ifdef ETOOMANYREFS
457 CASE(ETOOMANYREFS);
458 #endif
459 #ifdef ETOOSMALL
460 CASE(ETOOSMALL);
461 #endif
462 #ifdef ETXTBSY
463 CASE(ETXTBSY);
464 #endif
465 #ifdef EUCLEAN
466 CASE(EUCLEAN);
467 #endif
468 #ifdef EUNATCH
469 CASE(EUNATCH);
470 #endif
471 #ifdef EUSERS
472 CASE(EUSERS);
473 #endif
474 #ifdef EXDEV
475 CASE(EXDEV);
476 #endif
477 #ifdef EXFULL
478 CASE(EXFULL);
479 #endif
480 default:
481 perror_msg_and_fail("unknown errno %d", errno);
482 }
483 }
484