X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=ghc%2Flib%2Fmisc%2Fcbits%2FreadDescriptor.c;h=d5358980d732d78632fb501096d59fd213747d34;hp=bfc26cb169d84e84d430ff2c3caefa6acc438982;hb=438596897ebbe25a07e1c82085cfbc5bdb00f09e;hpb=967cc47f37cb93a5e2b6df7822c9a646f0428247 diff --git a/ghc/lib/misc/cbits/readDescriptor.c b/ghc/lib/misc/cbits/readDescriptor.c index bfc26cb..d535898 100644 --- a/ghc/lib/misc/cbits/readDescriptor.c +++ b/ghc/lib/misc/cbits/readDescriptor.c @@ -8,8 +8,9 @@ #endif #define NON_POSIX_SOURCE -#include "rtsdefs.h" +#include "Rts.h" #include "ghcSockets.h" +#include "stgio.h" StgInt readDescriptor(I_ fd, A_ buf, I_ nbytes) @@ -19,7 +20,40 @@ readDescriptor(I_ fd, A_ buf, I_ nbytes) while ((sucked = read((int) fd, (char *) buf, (int) nbytes)) < 0) { if (errno != EINTR) { cvtErrno(); - stdErrno(); + switch (ghc_errno) { + default: + stdErrno(); + break; + case GHC_EBADF: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Not a valid write descriptor"; + break; + case GHC_EBADMSG: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Message waiting to be read is not a data message"; + break; + case GHC_EFAULT: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Data buffer not in writeable part of user address space"; + break; + case GHC_EINVAL: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Seek pointer associated with descriptor negative"; + break; + case GHC_EIO: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "I/O error occurred while writing to file system"; + break; + case GHC_EISDIR: + ghc_errtype = ERR_INAPPROPRIATETYPE; + ghc_errstr = "Descriptor refers to a directory"; + break; + case GHC_EAGAIN: + case GHC_EWOULDBLOCK: + ghc_errtype = ERR_OTHERERROR; + ghc_errstr = "No data could be written immediately"; + break; + } return -1; } }