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