2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: errno.c,v 1.3 1998/12/02 13:27:20 simonm Exp $
6 * GHC Error Number Conversion
15 char *ghc_errstr = NULL;
19 { return ((StgAddr)ghc_errstr); }
23 { return ((StgInt)ghc_errno); }
27 { return ((StgInt)ghc_errtype); }
30 /* Collect all of the grotty #ifdef's in one place. */
37 ghc_errno = GHC_E2BIG;
42 ghc_errno = GHC_EACCES;
47 ghc_errno = GHC_EADDRINUSE;
52 ghc_errno = GHC_EADDRNOTAVAIL;
62 ghc_errno = GHC_EAFNOSUPPORT;
67 ghc_errno = GHC_EAGAIN;
72 ghc_errno = GHC_EALREADY;
77 ghc_errno = GHC_EBADF;
82 ghc_errno = GHC_EBADMSG;
87 ghc_errno = GHC_EBADRPC;
92 ghc_errno = GHC_EBUSY;
97 ghc_errno = GHC_ECHILD;
102 ghc_errno = GHC_ECOMM;
107 ghc_errno = GHC_ECONNABORTED;
112 ghc_errno = GHC_ECONNREFUSED;
117 ghc_errno = GHC_ECONNRESET;
122 ghc_errno = GHC_EDEADLK;
127 ghc_errno = GHC_EDESTADDRREQ;
132 ghc_errno = GHC_EDIRTY;
137 ghc_errno = GHC_EDOM;
142 ghc_errno = GHC_EDQUOT;
147 ghc_errno = GHC_EEXIST;
152 ghc_errno = GHC_EFAULT;
157 ghc_errno = GHC_EFBIG;
162 ghc_errno = GHC_EFTYPE;
167 ghc_errno = GHC_EHOSTDOWN;
172 ghc_errno = GHC_EHOSTUNREACH;
177 ghc_errno = GHC_EIDRM;
182 ghc_errno = GHC_EILSEQ;
187 ghc_errno = GHC_EINPROGRESS;
192 ghc_errno = GHC_EINTR;
197 ghc_errno = GHC_EINVAL;
207 ghc_errno = GHC_EISCONN;
212 ghc_errno = GHC_EISDIR;
217 ghc_errno = GHC_ELOOP;
222 ghc_errno = GHC_EMFILE;
227 ghc_errno = GHC_EMLINK;
232 ghc_errno = GHC_EMSGSIZE;
237 ghc_errno = GHC_EMULTIHOP;
242 ghc_errno = GHC_ENAMETOOLONG;
247 ghc_errno = GHC_ENETDOWN;
252 ghc_errno = GHC_ENETRESET;
257 ghc_errno = GHC_ENETUNREACH;
262 ghc_errno = GHC_ENFILE;
267 ghc_errno = GHC_ENOBUFS;
272 ghc_errno = GHC_ENODATA;
277 ghc_errno = GHC_ENODEV;
282 ghc_errno = GHC_ENOENT;
287 ghc_errno = GHC_ENOEXEC;
292 ghc_errno = GHC_ENOLCK;
297 ghc_errno = GHC_ENOLINK;
302 ghc_errno = GHC_ENOMEM;
307 ghc_errno = GHC_ENOMSG;
312 ghc_errno = GHC_ENONET;
317 ghc_errno = GHC_ENOPROTOOPT;
322 ghc_errno = GHC_ENOSPC;
327 ghc_errno = GHC_ENOSR;
332 ghc_errno = GHC_ENOSTR;
337 ghc_errno = GHC_ENOSYS;
342 ghc_errno = GHC_ENOTBLK;
347 ghc_errno = GHC_ENOTCONN;
352 ghc_errno = GHC_ENOTDIR;
355 #ifndef aix_TARGET_OS
356 /* AIX returns EEXIST where 4.3BSD used ENOTEMPTY.
357 * there is an ENOTEMPTY defined as the same as EEXIST, and
358 * therefore it won't work properly on a case statement.
359 * another option is to define _ALL_SOURCE for aix, which
360 * gives a different number for ENOTEMPTY.
361 * I haven't tried that. -- andre.
365 ghc_errno = GHC_ENOTEMPTY;
371 ghc_errno = GHC_ENOTSOCK;
376 ghc_errno = GHC_ENOTTY;
381 ghc_errno = GHC_ENXIO;
386 ghc_errno = GHC_EOPNOTSUPP;
391 ghc_errno = GHC_EPERM;
396 ghc_errno = GHC_EPFNOSUPPORT;
401 ghc_errno = GHC_EPIPE;
406 ghc_errno = GHC_EPROCLIM;
411 ghc_errno = GHC_EPROCUNAVAIL;
416 ghc_errno = GHC_EPROGMISMATCH;
421 ghc_errno = GHC_EPROGUNAVAIL;
426 ghc_errno = GHC_EPROTO;
429 #ifdef EPROTONOSUPPORT
430 case EPROTONOSUPPORT:
431 ghc_errno = GHC_EPROTONOSUPPORT;
436 ghc_errno = GHC_EPROTOTYPE;
441 ghc_errno = GHC_ERANGE;
446 ghc_errno = GHC_EREMCHG;
451 ghc_errno = GHC_EREMOTE;
456 ghc_errno = GHC_EROFS;
461 ghc_errno = GHC_ERPCMISMATCH;
466 ghc_errno = GHC_ERREMOTE;
471 ghc_errno = GHC_ESHUTDOWN;
474 #ifdef ESOCKTNOSUPPORT
475 case ESOCKTNOSUPPORT:
476 ghc_errno = GHC_ESOCKTNOSUPPORT;
481 ghc_errno = GHC_ESPIPE;
486 ghc_errno = GHC_ESRCH;
491 ghc_errno = GHC_ESRMNT;
496 ghc_errno = GHC_ESTALE;
501 ghc_errno = GHC_ETIME;
506 ghc_errno = GHC_ETIMEDOUT;
511 ghc_errno = GHC_ETOOMANYREFS;
516 ghc_errno = GHC_ETXTBSY;
521 ghc_errno = GHC_EUSERS;
527 ghc_errno = GHC_EWOULDBLOCK;
533 ghc_errno = GHC_EXDEV;
547 ghc_errtype = ERR_OTHERERROR;
548 ghc_errstr = "unexpected error";
551 ghc_errtype = ERR_OTHERERROR;
552 ghc_errstr = "no error";
554 ghc_errtype = ERR_RESOURCEEXHAUSTED;
555 ghc_errstr = "argument list too long";
558 ghc_errtype = ERR_PERMISSIONDENIED;
559 ghc_errstr = "inadequate access permission";
562 ghc_errtype = ERR_RESOURCEBUSY;
563 ghc_errstr = "address already in use";
565 case GHC_EADDRNOTAVAIL:
566 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
567 ghc_errstr = "address not available";
570 ghc_errtype = ERR_OTHERERROR;
571 ghc_errstr = "RFS advertise error";
573 case GHC_EAFNOSUPPORT:
574 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
575 ghc_errstr = "address family not supported by protocol family";
578 ghc_errtype = ERR_RESOURCEEXHAUSTED;
579 ghc_errstr = "insufficient resources";
582 ghc_errtype = ERR_ALREADYEXISTS;
583 ghc_errstr = "operation already in progress";
586 ghc_errtype = ERR_OTHERERROR;
587 ghc_errstr = "internal error (EBADF)";
590 ghc_errtype = ERR_INAPPROPRIATETYPE;
591 ghc_errstr = "next message has wrong type";
594 ghc_errtype = ERR_OTHERERROR;
595 ghc_errstr = "invalid RPC request or response";
598 ghc_errtype = ERR_RESOURCEBUSY;
599 ghc_errstr = "device busy";
602 ghc_errtype = ERR_NOSUCHTHING;
603 ghc_errstr = "no child processes";
606 ghc_errtype = ERR_RESOURCEVANISHED;
607 ghc_errstr = "no virtual circuit could be found";
609 case GHC_ECONNABORTED:
610 ghc_errtype = ERR_OTHERERROR;
611 ghc_errstr = "aborted connection";
613 case GHC_ECONNREFUSED:
614 ghc_errtype = ERR_NOSUCHTHING;
615 ghc_errstr = "no listener on remote host";
618 ghc_errtype = ERR_RESOURCEVANISHED;
619 ghc_errstr = "connection reset by peer";
622 ghc_errtype = ERR_RESOURCEBUSY;
623 ghc_errstr = "resource deadlock avoided";
625 case GHC_EDESTADDRREQ:
626 ghc_errtype = ERR_INVALIDARGUMENT;
627 ghc_errstr = "destination address required";
630 ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
631 ghc_errstr = "file system dirty";
634 ghc_errtype = ERR_INVALIDARGUMENT;
635 ghc_errstr = "argument too large";
638 ghc_errtype = ERR_PERMISSIONDENIED;
639 ghc_errstr = "quota exceeded";
642 ghc_errtype = ERR_ALREADYEXISTS;
643 ghc_errstr = "file already exists";
646 ghc_errtype = ERR_OTHERERROR;
647 ghc_errstr = "internal error (EFAULT)";
650 ghc_errtype = ERR_PERMISSIONDENIED;
651 ghc_errstr = "file too large";
654 ghc_errtype = ERR_INAPPROPRIATETYPE;
655 ghc_errstr = "inappropriate NFS file type or format";
658 ghc_errtype = ERR_NOSUCHTHING;
659 ghc_errstr = "destination host down";
661 case GHC_EHOSTUNREACH:
662 ghc_errtype = ERR_NOSUCHTHING;
663 ghc_errstr = "remote host is unreachable";
666 ghc_errtype = ERR_RESOURCEVANISHED;
667 ghc_errstr = "IPC identifier removed";
670 ghc_errtype = ERR_INVALIDARGUMENT;
671 ghc_errstr = "invalid wide character";
673 case GHC_EINPROGRESS:
674 ghc_errtype = ERR_ALREADYEXISTS;
675 ghc_errstr = "operation now in progress";
678 ghc_errtype = ERR_INTERRUPTED;
679 ghc_errstr = "interrupted system call";
682 ghc_errtype = ERR_INVALIDARGUMENT;
683 ghc_errstr = "invalid argument";
686 ghc_errtype = ERR_HARDWAREFAULT;
687 ghc_errstr = "unknown I/O fault";
690 ghc_errtype = ERR_ALREADYEXISTS;
691 ghc_errstr = "socket is already connected";
694 ghc_errtype = ERR_INAPPROPRIATETYPE;
695 ghc_errstr = "file is a directory";
698 ghc_errtype = ERR_INVALIDARGUMENT;
699 ghc_errstr = "too many symbolic links";
702 ghc_errtype = ERR_RESOURCEEXHAUSTED;
703 ghc_errstr = "process file table full";
706 ghc_errtype = ERR_RESOURCEEXHAUSTED;
707 ghc_errstr = "too many links";
710 ghc_errtype = ERR_RESOURCEEXHAUSTED;
711 ghc_errstr = "message too long";
714 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
715 ghc_errstr = "multi-hop RFS request";
717 case GHC_ENAMETOOLONG:
718 ghc_errtype = ERR_INVALIDARGUMENT;
719 ghc_errstr = "filename too long";
722 ghc_errtype = ERR_RESOURCEVANISHED;
723 ghc_errstr = "network is down";
726 ghc_errtype = ERR_RESOURCEVANISHED;
727 ghc_errstr = "remote host rebooted; connection lost";
729 case GHC_ENETUNREACH:
730 ghc_errtype = ERR_NOSUCHTHING;
731 ghc_errstr = "remote network is unreachable";
734 ghc_errtype = ERR_RESOURCEEXHAUSTED;
735 ghc_errstr = "system file table full";
738 ghc_errtype = ERR_RESOURCEEXHAUSTED;
739 ghc_errstr = "no buffer space available";
742 ghc_errtype = ERR_NOSUCHTHING;
743 ghc_errstr = "no message on the stream head read queue";
746 ghc_errtype = ERR_NOSUCHTHING;
747 ghc_errstr = "no such device";
750 ghc_errtype = ERR_NOSUCHTHING;
751 ghc_errstr = "no such file or directory";
754 ghc_errtype = ERR_INVALIDARGUMENT;
755 ghc_errstr = "not an executable file";
758 ghc_errtype = ERR_RESOURCEEXHAUSTED;
759 ghc_errstr = "no file locks available";
762 ghc_errtype = ERR_RESOURCEVANISHED;
763 ghc_errstr = "RFS link has been severed";
766 ghc_errtype = ERR_RESOURCEEXHAUSTED;
767 ghc_errstr = "not enough virtual memory";
770 ghc_errtype = ERR_NOSUCHTHING;
771 ghc_errstr = "no message of desired type";
774 ghc_errtype = ERR_NOSUCHTHING;
775 ghc_errstr = "host is not on a network";
777 case GHC_ENOPROTOOPT:
778 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
779 ghc_errstr = "operation not supported by protocol";
782 ghc_errtype = ERR_RESOURCEEXHAUSTED;
783 ghc_errstr = "no space left on device";
786 ghc_errtype = ERR_RESOURCEEXHAUSTED;
787 ghc_errstr = "out of stream resources";
790 ghc_errtype = ERR_INVALIDARGUMENT;
791 ghc_errstr = "not a stream device";
794 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
795 ghc_errstr = "function not implemented";
798 ghc_errtype = ERR_INVALIDARGUMENT;
799 ghc_errstr = "not a block device";
802 ghc_errtype = ERR_INVALIDARGUMENT;
803 ghc_errstr = "socket is not connected";
806 ghc_errtype = ERR_INAPPROPRIATETYPE;
807 ghc_errstr = "not a directory";
810 ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
811 ghc_errstr = "directory not empty";
814 ghc_errtype = ERR_INVALIDARGUMENT;
815 ghc_errstr = "not a socket";
818 ghc_errtype = ERR_ILLEGALOPERATION;
819 ghc_errstr = "inappropriate ioctl for device";
822 ghc_errtype = ERR_NOSUCHTHING;
823 ghc_errstr = "no such device or address";
826 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
827 ghc_errstr = "operation not supported on socket";
830 ghc_errtype = ERR_PERMISSIONDENIED;
831 ghc_errstr = "privileged operation";
833 case GHC_EPFNOSUPPORT:
834 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
835 ghc_errstr = "protocol family not supported";
838 ghc_errtype = ERR_RESOURCEVANISHED;
839 ghc_errstr = "broken pipe";
842 ghc_errtype = ERR_PERMISSIONDENIED;
843 ghc_errstr = "too many processes";
845 case GHC_EPROCUNAVAIL:
846 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
847 ghc_errstr = "unimplemented RPC procedure";
849 case GHC_EPROGMISMATCH:
850 ghc_errtype = ERR_PROTOCOLERROR;
851 ghc_errstr = "unsupported RPC program version";
853 case GHC_EPROGUNAVAIL:
854 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
855 ghc_errstr = "RPC program unavailable";
858 ghc_errtype = ERR_PROTOCOLERROR;
859 ghc_errstr = "error in streams protocol";
861 case GHC_EPROTONOSUPPORT:
862 ghc_errtype = ERR_PROTOCOLERROR;
863 ghc_errstr = "protocol not supported";
866 ghc_errtype = ERR_PROTOCOLERROR;
867 ghc_errstr = "wrong protocol for socket";
870 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
871 ghc_errstr = "result too large";
874 ghc_errtype = ERR_RESOURCEVANISHED;
875 ghc_errstr = "remote address changed";
878 ghc_errtype = ERR_ILLEGALOPERATION;
879 ghc_errstr = "too many levels of remote in path";
882 ghc_errtype = ERR_PERMISSIONDENIED;
883 ghc_errstr = "read-only file system";
885 case GHC_ERPCMISMATCH:
886 ghc_errtype = ERR_PROTOCOLERROR;
887 ghc_errstr = "RPC version is wrong";
890 ghc_errtype = ERR_ILLEGALOPERATION;
891 ghc_errstr = "object is remote";
894 ghc_errtype = ERR_ILLEGALOPERATION;
895 ghc_errstr = "can't send after socket shutdown";
897 case GHC_ESOCKTNOSUPPORT:
898 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
899 ghc_errstr = "socket type not supported";
902 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
903 ghc_errstr = "can't seek on a pipe";
906 ghc_errtype = ERR_NOSUCHTHING;
907 ghc_errstr = "no such process";
910 ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
911 ghc_errstr = "RFS resources still mounted by remote host(s)";
914 ghc_errtype = ERR_RESOURCEVANISHED;
915 ghc_errstr = "stale NFS file handle";
918 ghc_errtype = ERR_TIMEEXPIRED;
919 ghc_errstr = "timer expired";
922 ghc_errtype = ERR_TIMEEXPIRED;
923 ghc_errstr = "connection timed out";
925 case GHC_ETOOMANYREFS:
926 ghc_errtype = ERR_RESOURCEEXHAUSTED;
927 ghc_errstr = "too many references; can't splice";
930 ghc_errtype = ERR_RESOURCEBUSY;
931 ghc_errstr = "text file in-use";
934 ghc_errtype = ERR_RESOURCEEXHAUSTED;
935 ghc_errstr = "quota table full";
937 case GHC_EWOULDBLOCK:
938 ghc_errtype = ERR_OTHERERROR;
939 ghc_errstr = "operation would block";
942 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
943 ghc_errstr = "can't make a cross-device link";