[project @ 1998-04-10 11:04:49 by simonm]
[ghc-hetmet.git] / ghc / lib / std / cbits / errno.c
1 /* 
2  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
3  *
4  * $Id: errno.c,v 1.1 1998/04/10 10:54:18 simonm Exp $
5  *
6  * GHC Error Number Conversion
7  */
8
9 #include "Rts.h"
10 #include "stgio.h"
11
12 int ghc_errno = 0;
13 int ghc_errtype = 0;
14
15 char *ghc_errstr = NULL;
16
17 /* Collect all of the grotty #ifdef's in one place. */
18
19 void cvtErrno(void)
20 {
21     switch(errno) {
22 #ifdef E2BIG
23     case E2BIG:
24         ghc_errno = GHC_E2BIG;
25         break;
26 #endif
27 #ifdef EACCES
28     case EACCES:
29         ghc_errno = GHC_EACCES;
30         break;
31 #endif
32 #ifdef EADDRINUSE
33     case EADDRINUSE:
34         ghc_errno = GHC_EADDRINUSE;
35         break;
36 #endif
37 #ifdef EADDRNOTAVAIL
38     case EADDRNOTAVAIL:
39         ghc_errno = GHC_EADDRNOTAVAIL;
40         break;
41 #endif
42 #ifdef EADV
43     case EADV:
44         ghc_errno = GHC_EADV;
45         break;
46 #endif
47 #ifdef EAFNOSUPPORT
48     case EAFNOSUPPORT:
49         ghc_errno = GHC_EAFNOSUPPORT;
50         break;
51 #endif
52 #ifdef EAGAIN
53     case EAGAIN:
54         ghc_errno = GHC_EAGAIN;
55         break;
56 #endif
57 #ifdef EALREADY
58     case EALREADY:
59         ghc_errno = GHC_EALREADY;
60         break;
61 #endif
62 #ifdef EBADF
63     case EBADF:
64         ghc_errno = GHC_EBADF;
65         break;
66 #endif
67 #ifdef EBADMSG
68     case EBADMSG:
69         ghc_errno = GHC_EBADMSG;
70         break;
71 #endif
72 #ifdef EBADRPC
73     case EBADRPC:
74         ghc_errno = GHC_EBADRPC;
75         break;
76 #endif
77 #ifdef EBUSY
78     case EBUSY:
79         ghc_errno = GHC_EBUSY;
80         break;
81 #endif
82 #ifdef ECHILD
83     case ECHILD:
84         ghc_errno = GHC_ECHILD;
85         break;
86 #endif
87 #ifdef ECOMM
88     case ECOMM:
89         ghc_errno = GHC_ECOMM;
90         break;
91 #endif
92 #ifdef ECONNABORTED
93     case ECONNABORTED:
94         ghc_errno = GHC_ECONNABORTED;
95         break;
96 #endif
97 #ifdef ECONNREFUSED
98     case ECONNREFUSED:
99         ghc_errno = GHC_ECONNREFUSED;
100         break;
101 #endif
102 #ifdef ECONNRESET
103     case ECONNRESET:
104         ghc_errno = GHC_ECONNRESET;
105         break;
106 #endif
107 #ifdef EDEADLK
108     case EDEADLK:
109         ghc_errno = GHC_EDEADLK;
110         break;
111 #endif
112 #ifdef EDESTADDRREQ
113     case EDESTADDRREQ:
114         ghc_errno = GHC_EDESTADDRREQ;
115         break;
116 #endif
117 #ifdef EDIRTY
118     case EDIRTY:
119         ghc_errno = GHC_EDIRTY;
120         break;
121 #endif
122 #ifdef EDOM
123     case EDOM:
124         ghc_errno = GHC_EDOM;
125         break;
126 #endif
127 #ifdef EDQUOT
128     case EDQUOT:
129         ghc_errno = GHC_EDQUOT;
130         break;
131 #endif
132 #ifdef EEXIST
133     case EEXIST:
134         ghc_errno = GHC_EEXIST;
135         break;
136 #endif
137 #ifdef EFAULT
138     case EFAULT:
139         ghc_errno = GHC_EFAULT;
140         break;
141 #endif
142 #ifdef EFBIG
143     case EFBIG:
144         ghc_errno = GHC_EFBIG;
145         break;
146 #endif
147 #ifdef EFTYPE
148     case EFTYPE:
149         ghc_errno = GHC_EFTYPE;
150         break;
151 #endif
152 #ifdef EHOSTDOWN
153     case EHOSTDOWN:
154         ghc_errno = GHC_EHOSTDOWN;
155         break;
156 #endif
157 #ifdef EHOSTUNREACH
158     case EHOSTUNREACH:
159         ghc_errno = GHC_EHOSTUNREACH;
160         break;
161 #endif
162 #ifdef EIDRM
163     case EIDRM:
164         ghc_errno = GHC_EIDRM;
165         break;
166 #endif
167 #ifdef EILSEQ
168     case EILSEQ:
169         ghc_errno = GHC_EILSEQ;
170         break;
171 #endif
172 #ifdef EINPROGRESS
173     case EINPROGRESS:
174         ghc_errno = GHC_EINPROGRESS;
175         break;
176 #endif
177 #ifdef EINTR
178     case EINTR:
179         ghc_errno = GHC_EINTR;
180         break;
181 #endif
182 #ifdef EINVAL
183     case EINVAL:
184         ghc_errno = GHC_EINVAL;
185         break;
186 #endif
187 #ifdef EIO
188     case EIO:
189         ghc_errno = GHC_EIO;
190         break;
191 #endif
192 #ifdef EISCONN
193     case EISCONN:
194         ghc_errno = GHC_EISCONN;
195         break;
196 #endif
197 #ifdef EISDIR
198     case EISDIR:
199         ghc_errno = GHC_EISDIR;
200         break;
201 #endif
202 #ifdef ELOOP
203     case ELOOP:
204         ghc_errno = GHC_ELOOP;
205         break;
206 #endif
207 #ifdef EMFILE
208     case EMFILE:
209         ghc_errno = GHC_EMFILE;
210         break;
211 #endif
212 #ifdef EMLINK
213     case EMLINK:
214         ghc_errno = GHC_EMLINK;
215         break;
216 #endif
217 #ifdef EMSGSIZE
218     case EMSGSIZE:
219         ghc_errno = GHC_EMSGSIZE;
220         break;
221 #endif
222 #ifdef EMULTIHOP
223     case EMULTIHOP:
224         ghc_errno = GHC_EMULTIHOP;
225         break;
226 #endif
227 #ifdef ENAMETOOLONG
228     case ENAMETOOLONG:
229         ghc_errno = GHC_ENAMETOOLONG;
230         break;
231 #endif
232 #ifdef ENETDOWN
233     case ENETDOWN:
234         ghc_errno = GHC_ENETDOWN;
235         break;
236 #endif
237 #ifdef ENETRESET
238     case ENETRESET:
239         ghc_errno = GHC_ENETRESET;
240         break;
241 #endif
242 #ifdef ENETUNREACH
243     case ENETUNREACH:
244         ghc_errno = GHC_ENETUNREACH;
245         break;
246 #endif
247 #ifdef ENFILE
248     case ENFILE:
249         ghc_errno = GHC_ENFILE;
250         break;
251 #endif
252 #ifdef ENOBUFS
253     case ENOBUFS:
254         ghc_errno = GHC_ENOBUFS;
255         break;
256 #endif
257 #ifdef ENODATA
258     case ENODATA:
259         ghc_errno = GHC_ENODATA;
260         break;
261 #endif
262 #ifdef ENODEV
263     case ENODEV:
264         ghc_errno = GHC_ENODEV;
265         break;
266 #endif
267 #ifdef ENOENT
268     case ENOENT:
269         ghc_errno = GHC_ENOENT;
270         break;
271 #endif
272 #ifdef ENOEXEC
273     case ENOEXEC:
274         ghc_errno = GHC_ENOEXEC;
275         break;
276 #endif
277 #ifdef ENOLCK
278     case ENOLCK:
279         ghc_errno = GHC_ENOLCK;
280         break;
281 #endif
282 #ifdef ENOLINK
283     case ENOLINK:
284         ghc_errno = GHC_ENOLINK;
285         break;
286 #endif
287 #ifdef ENOMEM
288     case ENOMEM:
289         ghc_errno = GHC_ENOMEM;
290         break;
291 #endif
292 #ifdef ENOMSG
293     case ENOMSG:
294         ghc_errno = GHC_ENOMSG;
295         break;
296 #endif
297 #ifdef ENONET
298     case ENONET:
299         ghc_errno = GHC_ENONET;
300         break;
301 #endif
302 #ifdef ENOPROTOOPT
303     case ENOPROTOOPT:
304         ghc_errno = GHC_ENOPROTOOPT;
305         break;
306 #endif
307 #ifdef ENOSPC
308     case ENOSPC:
309         ghc_errno = GHC_ENOSPC;
310         break;
311 #endif
312 #ifdef ENOSR
313     case ENOSR:
314         ghc_errno = GHC_ENOSR;
315         break;
316 #endif
317 #ifdef ENOSTR
318     case ENOSTR:
319         ghc_errno = GHC_ENOSTR;
320         break;
321 #endif
322 #ifdef ENOSYS
323     case ENOSYS:
324         ghc_errno = GHC_ENOSYS;
325         break;
326 #endif
327 #ifdef ENOTBLK
328     case ENOTBLK:
329         ghc_errno = GHC_ENOTBLK;
330         break;
331 #endif
332 #ifdef ENOTCONN
333     case ENOTCONN:
334         ghc_errno = GHC_ENOTCONN;
335         break;
336 #endif
337 #ifdef ENOTDIR
338     case ENOTDIR:
339         ghc_errno = GHC_ENOTDIR;
340         break;
341 #endif
342 #ifndef aix_TARGET_OS
343 /* AIX returns EEXIST where 4.3BSD used ENOTEMPTY.
344  * there is an ENOTEMPTY defined as the same as EEXIST, and
345  * therefore it won't work properly on a case statement.
346  * another option is to define _ALL_SOURCE for aix, which
347  * gives a different number for ENOTEMPTY.
348  * I haven't tried that. -- andre.
349  */
350 #ifdef ENOTEMPTY
351     case ENOTEMPTY:
352         ghc_errno = GHC_ENOTEMPTY;
353         break;
354 #endif
355 #endif
356 #ifdef ENOTSOCK
357     case ENOTSOCK:
358         ghc_errno = GHC_ENOTSOCK;
359         break;
360 #endif
361 #ifdef ENOTTY
362     case ENOTTY:
363         ghc_errno = GHC_ENOTTY;
364         break;
365 #endif
366 #ifdef ENXIO
367     case ENXIO:
368         ghc_errno = GHC_ENXIO;
369         break;
370 #endif
371 #ifdef EOPNOTSUPP
372     case EOPNOTSUPP:
373         ghc_errno = GHC_EOPNOTSUPP;
374         break;
375 #endif
376 #ifdef EPERM
377     case EPERM:
378         ghc_errno = GHC_EPERM;
379         break;
380 #endif
381 #ifdef EPFNOSUPPORT
382     case EPFNOSUPPORT:
383         ghc_errno = GHC_EPFNOSUPPORT;
384         break;
385 #endif
386 #ifdef EPIPE
387     case EPIPE:
388         ghc_errno = GHC_EPIPE;
389         break;
390 #endif
391 #ifdef EPROCLIM
392     case EPROCLIM:
393         ghc_errno = GHC_EPROCLIM;
394         break;
395 #endif
396 #ifdef EPROCUNAVAIL
397     case EPROCUNAVAIL:
398         ghc_errno = GHC_EPROCUNAVAIL;
399         break;
400 #endif
401 #ifdef EPROGMISMATCH
402     case EPROGMISMATCH:
403         ghc_errno = GHC_EPROGMISMATCH;
404         break;
405 #endif
406 #ifdef EPROGUNAVAIL
407     case EPROGUNAVAIL:
408         ghc_errno = GHC_EPROGUNAVAIL;
409         break;
410 #endif
411 #ifdef EPROTO
412     case EPROTO:
413         ghc_errno = GHC_EPROTO;
414         break;
415 #endif
416 #ifdef EPROTONOSUPPORT
417     case EPROTONOSUPPORT:
418         ghc_errno = GHC_EPROTONOSUPPORT;
419         break;
420 #endif
421 #ifdef EPROTOTYPE
422     case EPROTOTYPE:
423         ghc_errno = GHC_EPROTOTYPE;
424         break;
425 #endif
426 #ifdef ERANGE
427     case ERANGE:
428         ghc_errno = GHC_ERANGE;
429         break;
430 #endif
431 #ifdef EREMCHG
432     case EREMCHG:
433         ghc_errno = GHC_EREMCHG;
434         break;
435 #endif
436 #ifdef EREMOTE
437     case EREMOTE:
438         ghc_errno = GHC_EREMOTE;
439         break;
440 #endif
441 #ifdef EROFS
442     case EROFS:
443         ghc_errno = GHC_EROFS;
444         break;
445 #endif
446 #ifdef ERPCMISMATCH
447     case ERPCMISMATCH:
448         ghc_errno = GHC_ERPCMISMATCH;
449         break;
450 #endif
451 #ifdef ERREMOTE
452     case ERREMOTE:
453         ghc_errno = GHC_ERREMOTE;
454         break;
455 #endif
456 #ifdef ESHUTDOWN
457     case ESHUTDOWN:
458         ghc_errno = GHC_ESHUTDOWN;
459         break;
460 #endif
461 #ifdef ESOCKTNOSUPPORT
462     case ESOCKTNOSUPPORT:
463         ghc_errno = GHC_ESOCKTNOSUPPORT;
464         break;
465 #endif
466 #ifdef ESPIPE
467     case ESPIPE:
468         ghc_errno = GHC_ESPIPE;
469         break;
470 #endif
471 #ifdef ESRCH
472     case ESRCH:
473         ghc_errno = GHC_ESRCH;
474         break;
475 #endif
476 #ifdef ESRMNT
477     case ESRMNT:
478         ghc_errno = GHC_ESRMNT;
479         break;
480 #endif
481 #ifdef ESTALE
482     case ESTALE:
483         ghc_errno = GHC_ESTALE;
484         break;
485 #endif
486 #ifdef ETIME
487     case ETIME:
488         ghc_errno = GHC_ETIME;
489         break;
490 #endif
491 #ifdef ETIMEDOUT
492     case ETIMEDOUT:
493         ghc_errno = GHC_ETIMEDOUT;
494         break;
495 #endif
496 #ifdef ETOOMANYREFS
497     case ETOOMANYREFS:
498         ghc_errno = GHC_ETOOMANYREFS;
499         break;
500 #endif
501 #ifdef ETXTBSY
502     case ETXTBSY:
503         ghc_errno = GHC_ETXTBSY;
504         break;
505 #endif
506 #ifdef EUSERS
507     case EUSERS:
508         ghc_errno = GHC_EUSERS;
509         break;
510 #endif
511 #if 0
512 #ifdef EWOULDBLOCK
513     case EWOULDBLOCK:
514         ghc_errno = GHC_EWOULDBLOCK;
515         break;
516 #endif
517 #endif
518 #ifdef EXDEV
519     case EXDEV:
520         ghc_errno = GHC_EXDEV;
521         break;
522 #endif
523     default:
524         ghc_errno = errno;
525         break;
526     }
527 }
528
529 void
530 stdErrno(void)
531 {
532     switch(ghc_errno) {
533     default:
534         ghc_errtype = ERR_OTHERERROR;
535         ghc_errstr = "unexpected error";
536         break;
537     case 0:
538         ghc_errtype = ERR_OTHERERROR;
539         ghc_errstr = "no error";
540     case GHC_E2BIG:
541         ghc_errtype = ERR_RESOURCEEXHAUSTED;
542         ghc_errstr = "argument list too long";
543         break;
544     case GHC_EACCES:
545         ghc_errtype = ERR_PERMISSIONDENIED;
546         ghc_errstr = "inadequate access permission";
547         break;
548     case GHC_EADDRINUSE:
549         ghc_errtype = ERR_RESOURCEBUSY;
550         ghc_errstr = "address already in use";
551         break;
552     case GHC_EADDRNOTAVAIL:
553         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
554         ghc_errstr = "address not available";
555         break;
556     case GHC_EADV:
557         ghc_errtype = ERR_OTHERERROR;
558         ghc_errstr = "RFS advertise error";
559         break;
560     case GHC_EAFNOSUPPORT:
561         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
562         ghc_errstr = "address family not supported by protocol family";
563         break;
564     case GHC_EAGAIN:
565         ghc_errtype = ERR_RESOURCEEXHAUSTED;
566         ghc_errstr = "insufficient resources";
567         break;
568     case GHC_EALREADY:
569         ghc_errtype = ERR_ALREADYEXISTS;
570         ghc_errstr = "operation already in progress";
571         break;
572     case GHC_EBADF:
573         ghc_errtype = ERR_OTHERERROR;
574         ghc_errstr = "internal error (EBADF)";
575         break;
576     case GHC_EBADMSG:
577         ghc_errtype = ERR_INAPPROPRIATETYPE;
578         ghc_errstr = "next message has wrong type";
579         break;
580     case GHC_EBADRPC:
581         ghc_errtype = ERR_OTHERERROR;
582         ghc_errstr = "invalid RPC request or response";
583         break;
584     case GHC_EBUSY:
585         ghc_errtype = ERR_RESOURCEBUSY;
586         ghc_errstr = "device busy";
587         break;
588     case GHC_ECHILD:
589         ghc_errtype = ERR_NOSUCHTHING;
590         ghc_errstr = "no child processes";
591         break;
592     case GHC_ECOMM:
593         ghc_errtype = ERR_RESOURCEVANISHED;
594         ghc_errstr = "no virtual circuit could be found";
595         break;
596     case GHC_ECONNABORTED:
597         ghc_errtype = ERR_OTHERERROR;
598         ghc_errstr = "aborted connection";
599         break;
600     case GHC_ECONNREFUSED:
601         ghc_errtype = ERR_NOSUCHTHING;
602         ghc_errstr = "no listener on remote host";
603         break;
604     case GHC_ECONNRESET:
605         ghc_errtype = ERR_RESOURCEVANISHED;
606         ghc_errstr = "connection reset by peer";
607         break;
608     case GHC_EDEADLK:
609         ghc_errtype = ERR_RESOURCEBUSY;
610         ghc_errstr = "resource deadlock avoided";
611         break;
612     case GHC_EDESTADDRREQ:
613         ghc_errtype = ERR_INVALIDARGUMENT;
614         ghc_errstr = "destination address required";
615         break;
616     case GHC_EDIRTY:
617         ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
618         ghc_errstr = "file system dirty";
619         break;
620     case GHC_EDOM:
621         ghc_errtype = ERR_INVALIDARGUMENT;
622         ghc_errstr = "argument too large";
623         break;
624     case GHC_EDQUOT:
625         ghc_errtype = ERR_PERMISSIONDENIED;
626         ghc_errstr = "quota exceeded";
627         break;
628     case GHC_EEXIST:
629         ghc_errtype = ERR_ALREADYEXISTS;
630         ghc_errstr = "file already exists";
631         break;
632     case GHC_EFAULT:
633         ghc_errtype = ERR_OTHERERROR;
634         ghc_errstr = "internal error (EFAULT)";
635         break;
636     case GHC_EFBIG:
637         ghc_errtype = ERR_PERMISSIONDENIED;
638         ghc_errstr = "file too large";
639         break;
640     case GHC_EFTYPE:
641         ghc_errtype = ERR_INAPPROPRIATETYPE;
642         ghc_errstr = "inappropriate NFS file type or format";
643         break;
644     case GHC_EHOSTDOWN:
645         ghc_errtype = ERR_NOSUCHTHING;
646         ghc_errstr = "destination host down";
647         break;
648     case GHC_EHOSTUNREACH:
649         ghc_errtype = ERR_NOSUCHTHING;
650         ghc_errstr = "remote host is unreachable";
651         break;
652     case GHC_EIDRM:
653         ghc_errtype = ERR_RESOURCEVANISHED;
654         ghc_errstr = "IPC identifier removed";
655         break;
656     case GHC_EILSEQ:
657         ghc_errtype = ERR_INVALIDARGUMENT;
658         ghc_errstr = "invalid wide character";
659         break;
660     case GHC_EINPROGRESS:
661         ghc_errtype = ERR_ALREADYEXISTS;
662         ghc_errstr = "operation now in progress";
663         break;
664     case GHC_EINTR:
665         ghc_errtype = ERR_INTERRUPTED;
666         ghc_errstr = "interrupted system call";
667         break;
668     case GHC_EINVAL:
669         ghc_errtype = ERR_INVALIDARGUMENT;
670         ghc_errstr = "invalid argument";
671         break;
672     case GHC_EIO:
673         ghc_errtype = ERR_HARDWAREFAULT;
674         ghc_errstr = "unknown I/O fault";
675         break;
676     case GHC_EISCONN:
677         ghc_errtype = ERR_ALREADYEXISTS;
678         ghc_errstr = "socket is already connected";
679         break;
680     case GHC_EISDIR:
681         ghc_errtype = ERR_INAPPROPRIATETYPE;
682         ghc_errstr = "file is a directory";
683         break;
684     case GHC_ELOOP:
685         ghc_errtype = ERR_INVALIDARGUMENT;
686         ghc_errstr = "too many symbolic links";
687         break;
688     case GHC_EMFILE:
689         ghc_errtype = ERR_RESOURCEEXHAUSTED;
690         ghc_errstr = "process file table full";
691         break;
692     case GHC_EMLINK:
693         ghc_errtype = ERR_RESOURCEEXHAUSTED;
694         ghc_errstr = "too many links";
695         break;
696     case GHC_EMSGSIZE:
697         ghc_errtype = ERR_RESOURCEEXHAUSTED;
698         ghc_errstr = "message too long";
699         break;
700     case GHC_EMULTIHOP:
701         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
702         ghc_errstr = "multi-hop RFS request";
703         break;
704     case GHC_ENAMETOOLONG:
705         ghc_errtype = ERR_INVALIDARGUMENT;
706         ghc_errstr = "filename too long";
707         break;
708     case GHC_ENETDOWN:
709         ghc_errtype = ERR_RESOURCEVANISHED;
710         ghc_errstr = "network is down";
711         break;
712     case GHC_ENETRESET:
713         ghc_errtype = ERR_RESOURCEVANISHED;
714         ghc_errstr = "remote host rebooted; connection lost";
715         break;
716     case GHC_ENETUNREACH:
717         ghc_errtype = ERR_NOSUCHTHING;
718         ghc_errstr = "remote network is unreachable";
719         break;
720     case GHC_ENFILE:
721         ghc_errtype = ERR_RESOURCEEXHAUSTED;
722         ghc_errstr = "system file table full";
723         break;
724     case GHC_ENOBUFS:
725         ghc_errtype = ERR_RESOURCEEXHAUSTED;
726         ghc_errstr = "no buffer space available";
727         break;
728     case GHC_ENODATA:
729         ghc_errtype = ERR_NOSUCHTHING;
730         ghc_errstr = "no message on the stream head read queue";
731         break;
732     case GHC_ENODEV:
733         ghc_errtype = ERR_NOSUCHTHING;
734         ghc_errstr = "no such device";
735         break;
736     case GHC_ENOENT:
737         ghc_errtype = ERR_NOSUCHTHING;
738         ghc_errstr = "no such file or directory";
739         break;
740     case GHC_ENOEXEC:
741         ghc_errtype = ERR_INVALIDARGUMENT;
742         ghc_errstr = "not an executable file";
743         break;
744     case GHC_ENOLCK:
745         ghc_errtype = ERR_RESOURCEEXHAUSTED;
746         ghc_errstr = "no file locks available";
747         break;
748     case GHC_ENOLINK:
749         ghc_errtype = ERR_RESOURCEVANISHED;
750         ghc_errstr = "RFS link has been severed";
751         break;
752     case GHC_ENOMEM:
753         ghc_errtype = ERR_RESOURCEEXHAUSTED;
754         ghc_errstr = "not enough virtual memory";
755         break;
756     case GHC_ENOMSG:
757         ghc_errtype = ERR_NOSUCHTHING;
758         ghc_errstr = "no message of desired type";
759         break;
760     case GHC_ENONET:
761         ghc_errtype = ERR_NOSUCHTHING;
762         ghc_errstr = "host is not on a network";
763         break;
764     case GHC_ENOPROTOOPT:
765         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
766         ghc_errstr = "operation not supported by protocol";
767         break;
768     case GHC_ENOSPC:
769         ghc_errtype = ERR_RESOURCEEXHAUSTED;
770         ghc_errstr = "no space left on device";
771         break;
772     case GHC_ENOSR:
773         ghc_errtype = ERR_RESOURCEEXHAUSTED;
774         ghc_errstr = "out of stream resources";
775         break;
776     case GHC_ENOSTR:
777         ghc_errtype = ERR_INVALIDARGUMENT;
778         ghc_errstr = "not a stream device";
779         break;
780     case GHC_ENOSYS:
781         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
782         ghc_errstr = "function not implemented";
783         break;
784     case GHC_ENOTBLK:
785         ghc_errtype = ERR_INVALIDARGUMENT;
786         ghc_errstr = "not a block device";
787         break;
788     case GHC_ENOTCONN:
789         ghc_errtype = ERR_INVALIDARGUMENT;
790         ghc_errstr = "socket is not connected";
791         break;
792     case GHC_ENOTDIR:
793         ghc_errtype = ERR_INAPPROPRIATETYPE;
794         ghc_errstr = "not a directory";
795         break;
796     case GHC_ENOTEMPTY:
797         ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
798         ghc_errstr = "directory not empty";
799         break;
800     case GHC_ENOTSOCK:
801         ghc_errtype = ERR_INVALIDARGUMENT;
802         ghc_errstr = "not a socket";
803         break;
804     case GHC_ENOTTY:
805         ghc_errtype = ERR_ILLEGALOPERATION;
806         ghc_errstr = "inappropriate ioctl for device";
807         break;
808     case GHC_ENXIO:
809         ghc_errtype = ERR_NOSUCHTHING;
810         ghc_errstr = "no such device or address";
811         break;
812     case GHC_EOPNOTSUPP:
813         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
814         ghc_errstr = "operation not supported on socket";
815         break;
816     case GHC_EPERM:
817         ghc_errtype = ERR_PERMISSIONDENIED;
818         ghc_errstr = "privileged operation";
819         break;
820     case GHC_EPFNOSUPPORT:
821         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
822         ghc_errstr = "protocol family not supported";
823         break;
824     case GHC_EPIPE:
825         ghc_errtype = ERR_RESOURCEVANISHED;
826         ghc_errstr = "broken pipe";
827         break;
828     case GHC_EPROCLIM:
829         ghc_errtype = ERR_PERMISSIONDENIED;
830         ghc_errstr = "too many processes";
831         break;
832     case GHC_EPROCUNAVAIL:
833         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
834         ghc_errstr = "unimplemented RPC procedure";
835         break;
836     case GHC_EPROGMISMATCH:
837         ghc_errtype = ERR_PROTOCOLERROR;
838         ghc_errstr = "unsupported RPC program version";
839         break;
840     case GHC_EPROGUNAVAIL:
841         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
842         ghc_errstr = "RPC program unavailable";
843         break;
844     case GHC_EPROTO:
845         ghc_errtype = ERR_PROTOCOLERROR;
846         ghc_errstr = "error in streams protocol";
847         break;
848     case GHC_EPROTONOSUPPORT:
849         ghc_errtype = ERR_PROTOCOLERROR;
850         ghc_errstr = "protocol not supported";
851         break;
852     case GHC_EPROTOTYPE:
853         ghc_errtype = ERR_PROTOCOLERROR;
854         ghc_errstr = "wrong protocol for socket";
855         break;
856     case GHC_ERANGE:
857         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
858         ghc_errstr = "result too large";
859         break;
860     case GHC_EREMCHG:
861         ghc_errtype = ERR_RESOURCEVANISHED;
862         ghc_errstr = "remote address changed";
863         break;
864     case GHC_EREMOTE:
865         ghc_errtype = ERR_ILLEGALOPERATION;
866         ghc_errstr = "too many levels of remote in path";
867         break;
868     case GHC_EROFS:
869         ghc_errtype = ERR_PERMISSIONDENIED;
870         ghc_errstr = "read-only file system";
871         break;
872     case GHC_ERPCMISMATCH:
873         ghc_errtype = ERR_PROTOCOLERROR;
874         ghc_errstr = "RPC version is wrong";
875         break;
876     case GHC_ERREMOTE:
877         ghc_errtype = ERR_ILLEGALOPERATION;
878         ghc_errstr = "object is remote";
879         break;
880     case GHC_ESHUTDOWN:
881         ghc_errtype = ERR_ILLEGALOPERATION;
882         ghc_errstr = "can't send after socket shutdown";
883         break;
884     case GHC_ESOCKTNOSUPPORT:
885         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
886         ghc_errstr = "socket type not supported";
887         break;
888     case GHC_ESPIPE:
889         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
890         ghc_errstr = "can't seek on a pipe";
891         break;
892     case GHC_ESRCH:
893         ghc_errtype = ERR_NOSUCHTHING;
894         ghc_errstr = "no such process";
895         break;
896     case GHC_ESRMNT:
897         ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
898         ghc_errstr = "RFS resources still mounted by remote host(s)";
899         break;
900     case GHC_ESTALE:
901         ghc_errtype = ERR_RESOURCEVANISHED;
902         ghc_errstr = "stale NFS file handle";
903         break;
904     case GHC_ETIME:
905         ghc_errtype = ERR_TIMEEXPIRED;
906         ghc_errstr = "timer expired";
907         break;
908     case GHC_ETIMEDOUT:
909         ghc_errtype = ERR_TIMEEXPIRED;
910         ghc_errstr = "connection timed out";
911         break;
912     case GHC_ETOOMANYREFS:
913         ghc_errtype = ERR_RESOURCEEXHAUSTED;
914         ghc_errstr = "too many references; can't splice";
915         break;
916     case GHC_ETXTBSY:
917         ghc_errtype = ERR_RESOURCEBUSY;
918         ghc_errstr = "text file in-use";
919         break;
920     case GHC_EUSERS:
921         ghc_errtype = ERR_RESOURCEEXHAUSTED;
922         ghc_errstr = "quota table full";
923         break;
924     case GHC_EWOULDBLOCK:
925         ghc_errtype = ERR_OTHERERROR;
926         ghc_errstr = "operation would block";
927         break;
928     case GHC_EXDEV:
929         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
930         ghc_errstr = "can't make a cross-device link";
931         break;
932     }
933 }