X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2Ferrno.c;h=295183c4310c578594bc3809067432e7618d3f7f;hb=ba78deafcc3016555469ed263d7a0370fa99db4b;hp=b4a4f0198abe1c6f3ceb56632ba8dc49a06451c6;hpb=cff93fad3a4fc50cae99938d869356af2ab8a2e9;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc.so_src/errno.c b/Usermode/Libraries/libc.so_src/errno.c index b4a4f019..295183c4 100644 --- a/Usermode/Libraries/libc.so_src/errno.c +++ b/Usermode/Libraries/libc.so_src/errno.c @@ -9,24 +9,70 @@ #include #include #include +#include EXPORT int *libc_geterrno() { return &_errno; } -EXPORT const char *strerror(int errnum) +EXPORT char *strerror(int errnum) { - switch(errnum) + switch((enum libc_eErrorNumbers)errnum) { + case EOK: return "Success"; + case ERANGE: return "Value out of range"; + case EDOM: return "Value out of domain"; + case EILSEQ: return "Illegal character sequence"; + case ENOSYS: return "Invalid instruction/syscall"; + case EINVAL: return "Bad argument(s)"; + case EBADF: return "Invalid file"; + case ENOMEM: return "No free memory"; + case EACCES: return "Not permitted"; + case EBUSY: return "Resource is busy"; + case ENOTFOUND: return "Item not found"; + case EROFS: return "Read only filesystem"; + case ENOTIMPL: return "Not implimented"; case ENOENT: return "No such file or directory"; - case EINVAL: return "Bad arguments"; - case EPERM: return "Permissions error"; - default: - _SysDebug("strerror: errnum=%i unk", errnum); - return "unknown error"; + case EEXIST: return "Already exists"; + case ENFILE: return "Too many open files"; + case ENOTDIR: return "Not a directory"; + case EISDIR: return "Is a directory"; + case EIO: return "IO Error"; + case EINTR: return "Interrupted"; + case EWOULDBLOCK: return "Operation would have blocked"; + case ENODEV: return "No such device"; + case EADDRNOTAVAIL: return "Address not avaliable"; + case EINPROGRESS: return "Operation in process"; + case EPERM: return "Operation not permitted"; + case ENOTTY: return "Not a TTY"; + case EAGAIN: return "Try again"; + case EFBIG: return "File too big"; + case E2BIG: return "Value too big"; + case EALREADY: return "Operation was no-op"; + case ENOSPC: return "No space left on the device"; + + case EAFNOSUPPORT: return "Address family not supported"; + case EADDRINUSE: return "Address already in use"; + case ETIMEDOUT: return "Operation timed out"; + case EOPNOTSUPP: return "Operation not supported on socket"; + + case EINTERNAL: return "Internal error"; } + _SysDebug("strerror: errnum=%i unk", errnum); + errno = EINVAL; + return "unknown error"; +} + +EXPORT int strerror_r(int errnum, char *buf, size_t bufsiz) +{ + const char *str = strerror(errnum); + if(!str) + return -1; + + strncpy(buf, str, bufsiz); + return 0; } // stdio.h