2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: errno.c,v 1.4 2001/01/26 17:51:40 rrt Exp $
6 * GHC Error Number Conversion
25 char *ghc_errstr = NULL;
29 { return ((StgAddr)ghc_errstr); }
33 { return ((StgInt)ghc_errno); }
37 { return ((StgInt)ghc_errtype); }
40 /* Collect all of the grotty #ifdef's in one place. */
47 ghc_errno = GHC_E2BIG;
52 ghc_errno = GHC_EACCES;
57 ghc_errno = GHC_EADDRINUSE;
62 ghc_errno = GHC_EADDRNOTAVAIL;
72 ghc_errno = GHC_EAFNOSUPPORT;
77 ghc_errno = GHC_EAGAIN;
82 ghc_errno = GHC_EALREADY;
87 ghc_errno = GHC_EBADF;
92 ghc_errno = GHC_EBADMSG;
97 ghc_errno = GHC_EBADRPC;
102 ghc_errno = GHC_EBUSY;
107 ghc_errno = GHC_ECHILD;
112 ghc_errno = GHC_ECOMM;
117 ghc_errno = GHC_ECONNABORTED;
122 ghc_errno = GHC_ECONNREFUSED;
127 ghc_errno = GHC_ECONNRESET;
132 ghc_errno = GHC_EDEADLK;
137 ghc_errno = GHC_EDESTADDRREQ;
142 ghc_errno = GHC_EDIRTY;
147 ghc_errno = GHC_EDOM;
152 ghc_errno = GHC_EDQUOT;
157 ghc_errno = GHC_EEXIST;
162 ghc_errno = GHC_EFAULT;
167 ghc_errno = GHC_EFBIG;
172 ghc_errno = GHC_EFTYPE;
177 ghc_errno = GHC_EHOSTDOWN;
182 ghc_errno = GHC_EHOSTUNREACH;
187 ghc_errno = GHC_EIDRM;
192 ghc_errno = GHC_EILSEQ;
197 ghc_errno = GHC_EINPROGRESS;
202 ghc_errno = GHC_EINTR;
207 ghc_errno = GHC_EINVAL;
217 ghc_errno = GHC_EISCONN;
222 ghc_errno = GHC_EISDIR;
227 ghc_errno = GHC_ELOOP;
232 ghc_errno = GHC_EMFILE;
237 ghc_errno = GHC_EMLINK;
242 ghc_errno = GHC_EMSGSIZE;
247 ghc_errno = GHC_EMULTIHOP;
252 ghc_errno = GHC_ENAMETOOLONG;
257 ghc_errno = GHC_ENETDOWN;
262 ghc_errno = GHC_ENETRESET;
267 ghc_errno = GHC_ENETUNREACH;
272 ghc_errno = GHC_ENFILE;
277 ghc_errno = GHC_ENOBUFS;
282 ghc_errno = GHC_ENODATA;
287 ghc_errno = GHC_ENODEV;
292 ghc_errno = GHC_ENOENT;
297 ghc_errno = GHC_ENOEXEC;
302 ghc_errno = GHC_ENOLCK;
307 ghc_errno = GHC_ENOLINK;
312 ghc_errno = GHC_ENOMEM;
317 ghc_errno = GHC_ENOMSG;
322 ghc_errno = GHC_ENONET;
327 ghc_errno = GHC_ENOPROTOOPT;
332 ghc_errno = GHC_ENOSPC;
337 ghc_errno = GHC_ENOSR;
342 ghc_errno = GHC_ENOSTR;
347 ghc_errno = GHC_ENOSYS;
352 ghc_errno = GHC_ENOTBLK;
357 ghc_errno = GHC_ENOTCONN;
362 ghc_errno = GHC_ENOTDIR;
365 #ifndef aix_TARGET_OS
366 /* AIX returns EEXIST where 4.3BSD used ENOTEMPTY.
367 * there is an ENOTEMPTY defined as the same as EEXIST, and
368 * therefore it won't work properly on a case statement.
369 * another option is to define _ALL_SOURCE for aix, which
370 * gives a different number for ENOTEMPTY.
371 * I haven't tried that. -- andre.
375 ghc_errno = GHC_ENOTEMPTY;
381 ghc_errno = GHC_ENOTSOCK;
386 ghc_errno = GHC_ENOTTY;
391 ghc_errno = GHC_ENXIO;
396 ghc_errno = GHC_EOPNOTSUPP;
401 ghc_errno = GHC_EPERM;
406 ghc_errno = GHC_EPFNOSUPPORT;
411 ghc_errno = GHC_EPIPE;
416 ghc_errno = GHC_EPROCLIM;
421 ghc_errno = GHC_EPROCUNAVAIL;
426 ghc_errno = GHC_EPROGMISMATCH;
431 ghc_errno = GHC_EPROGUNAVAIL;
436 ghc_errno = GHC_EPROTO;
439 #ifdef EPROTONOSUPPORT
440 case EPROTONOSUPPORT:
441 ghc_errno = GHC_EPROTONOSUPPORT;
446 ghc_errno = GHC_EPROTOTYPE;
451 ghc_errno = GHC_ERANGE;
456 ghc_errno = GHC_EREMCHG;
461 ghc_errno = GHC_EREMOTE;
466 ghc_errno = GHC_EROFS;
471 ghc_errno = GHC_ERPCMISMATCH;
476 ghc_errno = GHC_ERREMOTE;
481 ghc_errno = GHC_ESHUTDOWN;
484 #ifdef ESOCKTNOSUPPORT
485 case ESOCKTNOSUPPORT:
486 ghc_errno = GHC_ESOCKTNOSUPPORT;
491 ghc_errno = GHC_ESPIPE;
496 ghc_errno = GHC_ESRCH;
501 ghc_errno = GHC_ESRMNT;
506 ghc_errno = GHC_ESTALE;
511 ghc_errno = GHC_ETIME;
516 ghc_errno = GHC_ETIMEDOUT;
521 ghc_errno = GHC_ETOOMANYREFS;
526 ghc_errno = GHC_ETXTBSY;
531 ghc_errno = GHC_EUSERS;
537 ghc_errno = GHC_EWOULDBLOCK;
543 ghc_errno = GHC_EXDEV;
557 ghc_errtype = ERR_OTHERERROR;
558 ghc_errstr = "unexpected error";
561 ghc_errtype = ERR_OTHERERROR;
562 ghc_errstr = "no error";
564 ghc_errtype = ERR_RESOURCEEXHAUSTED;
565 ghc_errstr = "argument list too long";
568 ghc_errtype = ERR_PERMISSIONDENIED;
569 ghc_errstr = "inadequate access permission";
572 ghc_errtype = ERR_RESOURCEBUSY;
573 ghc_errstr = "address already in use";
575 case GHC_EADDRNOTAVAIL:
576 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
577 ghc_errstr = "address not available";
580 ghc_errtype = ERR_OTHERERROR;
581 ghc_errstr = "RFS advertise error";
583 case GHC_EAFNOSUPPORT:
584 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
585 ghc_errstr = "address family not supported by protocol family";
588 ghc_errtype = ERR_RESOURCEEXHAUSTED;
589 ghc_errstr = "insufficient resources";
592 ghc_errtype = ERR_ALREADYEXISTS;
593 ghc_errstr = "operation already in progress";
596 ghc_errtype = ERR_OTHERERROR;
597 ghc_errstr = "internal error (EBADF)";
600 ghc_errtype = ERR_INAPPROPRIATETYPE;
601 ghc_errstr = "next message has wrong type";
604 ghc_errtype = ERR_OTHERERROR;
605 ghc_errstr = "invalid RPC request or response";
608 ghc_errtype = ERR_RESOURCEBUSY;
609 ghc_errstr = "device busy";
612 ghc_errtype = ERR_NOSUCHTHING;
613 ghc_errstr = "no child processes";
616 ghc_errtype = ERR_RESOURCEVANISHED;
617 ghc_errstr = "no virtual circuit could be found";
619 case GHC_ECONNABORTED:
620 ghc_errtype = ERR_OTHERERROR;
621 ghc_errstr = "aborted connection";
623 case GHC_ECONNREFUSED:
624 ghc_errtype = ERR_NOSUCHTHING;
625 ghc_errstr = "no listener on remote host";
628 ghc_errtype = ERR_RESOURCEVANISHED;
629 ghc_errstr = "connection reset by peer";
632 ghc_errtype = ERR_RESOURCEBUSY;
633 ghc_errstr = "resource deadlock avoided";
635 case GHC_EDESTADDRREQ:
636 ghc_errtype = ERR_INVALIDARGUMENT;
637 ghc_errstr = "destination address required";
640 ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
641 ghc_errstr = "file system dirty";
644 ghc_errtype = ERR_INVALIDARGUMENT;
645 ghc_errstr = "argument too large";
648 ghc_errtype = ERR_PERMISSIONDENIED;
649 ghc_errstr = "quota exceeded";
652 ghc_errtype = ERR_ALREADYEXISTS;
653 ghc_errstr = "file already exists";
656 ghc_errtype = ERR_OTHERERROR;
657 ghc_errstr = "internal error (EFAULT)";
660 ghc_errtype = ERR_PERMISSIONDENIED;
661 ghc_errstr = "file too large";
664 ghc_errtype = ERR_INAPPROPRIATETYPE;
665 ghc_errstr = "inappropriate NFS file type or format";
668 ghc_errtype = ERR_NOSUCHTHING;
669 ghc_errstr = "destination host down";
671 case GHC_EHOSTUNREACH:
672 ghc_errtype = ERR_NOSUCHTHING;
673 ghc_errstr = "remote host is unreachable";
676 ghc_errtype = ERR_RESOURCEVANISHED;
677 ghc_errstr = "IPC identifier removed";
680 ghc_errtype = ERR_INVALIDARGUMENT;
681 ghc_errstr = "invalid wide character";
683 case GHC_EINPROGRESS:
684 ghc_errtype = ERR_ALREADYEXISTS;
685 ghc_errstr = "operation now in progress";
688 ghc_errtype = ERR_INTERRUPTED;
689 ghc_errstr = "interrupted system call";
692 ghc_errtype = ERR_INVALIDARGUMENT;
693 ghc_errstr = "invalid argument";
696 ghc_errtype = ERR_HARDWAREFAULT;
697 ghc_errstr = "unknown I/O fault";
700 ghc_errtype = ERR_ALREADYEXISTS;
701 ghc_errstr = "socket is already connected";
704 ghc_errtype = ERR_INAPPROPRIATETYPE;
705 ghc_errstr = "file is a directory";
708 ghc_errtype = ERR_INVALIDARGUMENT;
709 ghc_errstr = "too many symbolic links";
712 ghc_errtype = ERR_RESOURCEEXHAUSTED;
713 ghc_errstr = "process file table full";
716 ghc_errtype = ERR_RESOURCEEXHAUSTED;
717 ghc_errstr = "too many links";
720 ghc_errtype = ERR_RESOURCEEXHAUSTED;
721 ghc_errstr = "message too long";
724 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
725 ghc_errstr = "multi-hop RFS request";
727 case GHC_ENAMETOOLONG:
728 ghc_errtype = ERR_INVALIDARGUMENT;
729 ghc_errstr = "filename too long";
732 ghc_errtype = ERR_RESOURCEVANISHED;
733 ghc_errstr = "network is down";
736 ghc_errtype = ERR_RESOURCEVANISHED;
737 ghc_errstr = "remote host rebooted; connection lost";
739 case GHC_ENETUNREACH:
740 ghc_errtype = ERR_NOSUCHTHING;
741 ghc_errstr = "remote network is unreachable";
744 ghc_errtype = ERR_RESOURCEEXHAUSTED;
745 ghc_errstr = "system file table full";
748 ghc_errtype = ERR_RESOURCEEXHAUSTED;
749 ghc_errstr = "no buffer space available";
752 ghc_errtype = ERR_NOSUCHTHING;
753 ghc_errstr = "no message on the stream head read queue";
756 ghc_errtype = ERR_NOSUCHTHING;
757 ghc_errstr = "no such device";
760 ghc_errtype = ERR_NOSUCHTHING;
761 ghc_errstr = "no such file or directory";
764 ghc_errtype = ERR_INVALIDARGUMENT;
765 ghc_errstr = "not an executable file";
768 ghc_errtype = ERR_RESOURCEEXHAUSTED;
769 ghc_errstr = "no file locks available";
772 ghc_errtype = ERR_RESOURCEVANISHED;
773 ghc_errstr = "RFS link has been severed";
776 ghc_errtype = ERR_RESOURCEEXHAUSTED;
777 ghc_errstr = "not enough virtual memory";
780 ghc_errtype = ERR_NOSUCHTHING;
781 ghc_errstr = "no message of desired type";
784 ghc_errtype = ERR_NOSUCHTHING;
785 ghc_errstr = "host is not on a network";
787 case GHC_ENOPROTOOPT:
788 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
789 ghc_errstr = "operation not supported by protocol";
792 ghc_errtype = ERR_RESOURCEEXHAUSTED;
793 ghc_errstr = "no space left on device";
796 ghc_errtype = ERR_RESOURCEEXHAUSTED;
797 ghc_errstr = "out of stream resources";
800 ghc_errtype = ERR_INVALIDARGUMENT;
801 ghc_errstr = "not a stream device";
804 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
805 ghc_errstr = "function not implemented";
808 ghc_errtype = ERR_INVALIDARGUMENT;
809 ghc_errstr = "not a block device";
812 ghc_errtype = ERR_INVALIDARGUMENT;
813 ghc_errstr = "socket is not connected";
816 ghc_errtype = ERR_INAPPROPRIATETYPE;
817 ghc_errstr = "not a directory";
820 ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
821 ghc_errstr = "directory not empty";
824 ghc_errtype = ERR_INVALIDARGUMENT;
825 ghc_errstr = "not a socket";
828 ghc_errtype = ERR_ILLEGALOPERATION;
829 ghc_errstr = "inappropriate ioctl for device";
832 ghc_errtype = ERR_NOSUCHTHING;
833 ghc_errstr = "no such device or address";
836 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
837 ghc_errstr = "operation not supported on socket";
840 ghc_errtype = ERR_PERMISSIONDENIED;
841 ghc_errstr = "privileged operation";
843 case GHC_EPFNOSUPPORT:
844 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
845 ghc_errstr = "protocol family not supported";
848 ghc_errtype = ERR_RESOURCEVANISHED;
849 ghc_errstr = "broken pipe";
852 ghc_errtype = ERR_PERMISSIONDENIED;
853 ghc_errstr = "too many processes";
855 case GHC_EPROCUNAVAIL:
856 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
857 ghc_errstr = "unimplemented RPC procedure";
859 case GHC_EPROGMISMATCH:
860 ghc_errtype = ERR_PROTOCOLERROR;
861 ghc_errstr = "unsupported RPC program version";
863 case GHC_EPROGUNAVAIL:
864 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
865 ghc_errstr = "RPC program unavailable";
868 ghc_errtype = ERR_PROTOCOLERROR;
869 ghc_errstr = "error in streams protocol";
871 case GHC_EPROTONOSUPPORT:
872 ghc_errtype = ERR_PROTOCOLERROR;
873 ghc_errstr = "protocol not supported";
876 ghc_errtype = ERR_PROTOCOLERROR;
877 ghc_errstr = "wrong protocol for socket";
880 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
881 ghc_errstr = "result too large";
884 ghc_errtype = ERR_RESOURCEVANISHED;
885 ghc_errstr = "remote address changed";
888 ghc_errtype = ERR_ILLEGALOPERATION;
889 ghc_errstr = "too many levels of remote in path";
892 ghc_errtype = ERR_PERMISSIONDENIED;
893 ghc_errstr = "read-only file system";
895 case GHC_ERPCMISMATCH:
896 ghc_errtype = ERR_PROTOCOLERROR;
897 ghc_errstr = "RPC version is wrong";
900 ghc_errtype = ERR_ILLEGALOPERATION;
901 ghc_errstr = "object is remote";
904 ghc_errtype = ERR_ILLEGALOPERATION;
905 ghc_errstr = "can't send after socket shutdown";
907 case GHC_ESOCKTNOSUPPORT:
908 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
909 ghc_errstr = "socket type not supported";
912 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
913 ghc_errstr = "can't seek on a pipe";
916 ghc_errtype = ERR_NOSUCHTHING;
917 ghc_errstr = "no such process";
920 ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
921 ghc_errstr = "RFS resources still mounted by remote host(s)";
924 ghc_errtype = ERR_RESOURCEVANISHED;
925 ghc_errstr = "stale NFS file handle";
928 ghc_errtype = ERR_TIMEEXPIRED;
929 ghc_errstr = "timer expired";
932 ghc_errtype = ERR_TIMEEXPIRED;
933 ghc_errstr = "connection timed out";
935 case GHC_ETOOMANYREFS:
936 ghc_errtype = ERR_RESOURCEEXHAUSTED;
937 ghc_errstr = "too many references; can't splice";
940 ghc_errtype = ERR_RESOURCEBUSY;
941 ghc_errstr = "text file in-use";
944 ghc_errtype = ERR_RESOURCEEXHAUSTED;
945 ghc_errstr = "quota table full";
947 case GHC_EWOULDBLOCK:
948 ghc_errtype = ERR_OTHERERROR;
949 ghc_errstr = "operation would block";
952 ghc_errtype = ERR_UNSUPPORTEDOPERATION;
953 ghc_errstr = "can't make a cross-device link";