Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/string.c

    r1b55da67 r087c4c56  
    553553char *posix_strerror(int errnum)
    554554{
    555         static const char *error_msgs[] = {
    556                 [E2BIG] = "[E2BIG] Argument list too long",
    557                 [EACCES] = "[EACCES] Permission denied",
    558                 [EADDRINUSE] = "[EADDRINUSE] Address in use",
    559                 [EADDRNOTAVAIL] = "[EADDRNOTAVAIL] Address not available",
    560                 [EAFNOSUPPORT] = "[EAFNOSUPPORT] Address family not supported",
    561                 [EAGAIN] = "[EAGAIN] Resource unavailable, try again",
    562                 [EALREADY] = "[EALREADY] Connection already in progress",
    563                 [EBADF] = "[EBADF] Bad file descriptor",
    564                 [EBADMSG] = "[EBADMSG] Bad message",
    565                 [EBUSY] = "[EBUSY] Device or resource busy",
    566                 [ECANCELED] = "[ECANCELED] Operation canceled",
    567                 [ECHILD] = "[ECHILD] No child processes",
    568                 [ECONNABORTED] = "[ECONNABORTED] Connection aborted",
    569                 [ECONNREFUSED] = "[ECONNREFUSED] Connection refused",
    570                 [ECONNRESET] = "[ECONNRESET] Connection reset",
    571                 [EDEADLK] = "[EDEADLK] Resource deadlock would occur",
    572                 [EDESTADDRREQ] = "[EDESTADDRREQ] Destination address required",
    573                 [EDOM] = "[EDOM] Mathematics argument out of domain of function",
    574                 [EDQUOT] = "[EDQUOT] Reserved",
    575                 [EEXIST] = "[EEXIST] File exists",
    576                 [EFAULT] = "[EFAULT] Bad address",
    577                 [EFBIG] = "[EFBIG] File too large",
    578                 [EHOSTUNREACH] = "[EHOSTUNREACH] Host is unreachable",
    579                 [EIDRM] = "[EIDRM] Identifier removed",
    580                 [EILSEQ] = "[EILSEQ] Illegal byte sequence",
    581                 [EINPROGRESS] = "[EINPROGRESS] Operation in progress",
    582                 [EINTR] = "[EINTR] Interrupted function",
    583                 [EINVAL] = "[EINVAL] Invalid argument",
    584                 [EIO] = "[EIO] I/O error",
    585                 [EISCONN] = "[EISCONN] Socket is connected",
    586                 [EISDIR] = "[EISDIR] Is a directory",
    587                 [ELOOP] = "[ELOOP] Too many levels of symbolic links",
    588                 [EMFILE] = "[EMFILE] File descriptor value too large",
    589                 [EMLINK] = "[EMLINK] Too many links",
    590                 [EMSGSIZE] = "[EMSGSIZE] Message too large",
    591                 [EMULTIHOP] = "[EMULTIHOP] Reserved",
    592                 [ENAMETOOLONG] = "[ENAMETOOLONG] Filename too long",
    593                 [ENETDOWN] = "[ENETDOWN] Network is down",
    594                 [ENETRESET] = "[ENETRESET] Connection aborted by network",
    595                 [ENETUNREACH] = "[ENETUNREACH] Network unreachable",
    596                 [ENFILE] = "[ENFILE] Too many files open in system",
    597                 [ENOBUFS] = "[ENOBUFS] No buffer space available",
    598                 [ENODATA] = "[ENODATA] No message is available on the STREAM head read queue",
    599                 [ENODEV] = "[ENODEV] No such device",
    600                 [ENOENT] = "[ENOENT] No such file or directory",
    601                 [ENOEXEC] = "[ENOEXEC] Executable file format error",
    602                 [ENOLCK] = "[ENOLCK] No locks available",
    603                 [ENOLINK] = "[ENOLINK] Reserved",
    604                 [ENOMEM] = "[ENOMEM] Not enough space",
    605                 [ENOMSG] = "[ENOMSG] No message of the desired type",
    606                 [ENOPROTOOPT] = "[ENOPROTOOPT] Protocol not available",
    607                 [ENOSPC] = "[ENOSPC] No space left on device",
    608                 [ENOSR] = "[ENOSR] No STREAM resources.",
    609                 [ENOSTR] = "[ENOSTR] Not a STREAM",
    610                 [ENOSYS] = "[ENOSYS] Function not supported",
    611                 [ENOTCONN] = "[ENOTCONN] The socket is not connected",
    612                 [ENOTDIR] = "[ENOTDIR] Not a directory",
    613                 [ENOTEMPTY] = "[ENOTEMPTY] Directory not empty",
    614                 [ENOTRECOVERABLE] = "[ENOTRECOVERABLE] State not recoverable",
    615                 [ENOTSOCK] = "[ENOTSOCK] Not a socket",
    616                 [ENOTSUP] = "[ENOTSUP] Not supported",
    617                 [ENOTTY] = "[ENOTTY] Inappropriate I/O control operation",
    618                 [ENXIO] = "[ENXIO] No such device or address",
    619                 [EOPNOTSUPP] = "[EOPNOTSUPP] Operation not supported",
    620                 [EOVERFLOW] = "[EOVERFLOW] Value too large to be stored in data type",
    621                 [EOWNERDEAD] = "[EOWNERDEAD] Previous owned died",
    622                 [EPERM] = "[EPERM] Operation not permitted",
    623                 [EPIPE] = "[EPIPE] Broken pipe",
    624                 [EPROTO] = "[EPROTO] Protocol error",
    625                 [EPROTONOSUPPORT] = "[EPROTONOSUPPORT] Protocol not supported",
    626                 [EPROTOTYPE] = "[EPROTOTYPE] Protocol wrong type for socket",
    627                 [ERANGE] = "[ERANGE] Result too large",
    628                 [EROFS] = "[EROFS] Read-only file system",
    629                 [ESPIPE] = "[ESPIPE] Invalid seek",
    630                 [ESRCH] = "[ESRCH] No such process",
    631                 [ESTALE] = "[ESTALE] Reserved",
    632                 [ETIME] = "[ETIME] Stream ioctl() timeout",
    633                 [ETIMEDOUT] = "[ETIMEDOUT] Connection timed out",
    634                 [ETXTBSY] = "[ETXTBSY] Text file busy",
    635                 [EWOULDBLOCK] = "[EWOULDBLOCK] Operation would block",
    636                 [EXDEV] = "[EXDEV] Cross-device link",
    637         };
    638 
    639         return (char *) error_msgs[posix_abs(errnum)];
     555        /* Uses function from libc, we just have to negate errno
     556         * (POSIX uses positive errorcodes, HelenOS has negative).
     557         */
     558        // FIXME: not all POSIX error codes are in libc
     559        return (char *) str_error(-posix_abs(errnum));
    640560}
    641561
     
    653573       
    654574        char *errstr = posix_strerror(errnum);
     575        /* HelenOS str_error can't fail */
    655576       
    656577        if (posix_strlen(errstr) + 1 > bufsz) {
    657                 return ERANGE;
     578                return -ERANGE;
    658579        } else {
    659580                posix_strcpy(buf, errstr);
Note: See TracChangeset for help on using the changeset viewer.