Ignore:
File:
1 edited

Legend:

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

    r0d0b319 r12b29f3  
    4141
    4242#include "posix/assert.h"
    43 
    44 #include <errno.h>
    45 
     43#include "posix/errno.h"
    4644#include "posix/limits.h"
    4745#include "posix/stdlib.h"
     
    617615char *posix_strerror(int errnum)
    618616{
    619         // FIXME: move strerror() and strerror_r() to libc.
    620         return (char *) str_error(errnum);
     617        static const char *error_msgs[] = {
     618                [E2BIG] = "[E2BIG] Argument list too long",
     619                [EACCES] = "[EACCES] Permission denied",
     620                [EADDRINUSE] = "[EADDRINUSE] Address in use",
     621                [EADDRNOTAVAIL] = "[EADDRNOTAVAIL] Address not available",
     622                [EAFNOSUPPORT] = "[EAFNOSUPPORT] Address family not supported",
     623                [EAGAIN] = "[EAGAIN] Resource unavailable, try again",
     624                [EALREADY] = "[EALREADY] Connection already in progress",
     625                [EBADF] = "[EBADF] Bad file descriptor",
     626                [EBADMSG] = "[EBADMSG] Bad message",
     627                [EBUSY] = "[EBUSY] Device or resource busy",
     628                [ECANCELED] = "[ECANCELED] Operation canceled",
     629                [ECHILD] = "[ECHILD] No child processes",
     630                [ECONNABORTED] = "[ECONNABORTED] Connection aborted",
     631                [ECONNREFUSED] = "[ECONNREFUSED] Connection refused",
     632                [ECONNRESET] = "[ECONNRESET] Connection reset",
     633                [EDEADLK] = "[EDEADLK] Resource deadlock would occur",
     634                [EDESTADDRREQ] = "[EDESTADDRREQ] Destination address required",
     635                [EDOM] = "[EDOM] Mathematics argument out of domain of function",
     636                [EDQUOT] = "[EDQUOT] Reserved",
     637                [EEXIST] = "[EEXIST] File exists",
     638                [EFAULT] = "[EFAULT] Bad address",
     639                [EFBIG] = "[EFBIG] File too large",
     640                [EHOSTUNREACH] = "[EHOSTUNREACH] Host is unreachable",
     641                [EIDRM] = "[EIDRM] Identifier removed",
     642                [EILSEQ] = "[EILSEQ] Illegal byte sequence",
     643                [EINPROGRESS] = "[EINPROGRESS] Operation in progress",
     644                [EINTR] = "[EINTR] Interrupted function",
     645                [EINVAL] = "[EINVAL] Invalid argument",
     646                [EIO] = "[EIO] I/O error",
     647                [EISCONN] = "[EISCONN] Socket is connected",
     648                [EISDIR] = "[EISDIR] Is a directory",
     649                [ELOOP] = "[ELOOP] Too many levels of symbolic links",
     650                [EMFILE] = "[EMFILE] File descriptor value too large",
     651                [EMLINK] = "[EMLINK] Too many links",
     652                [EMSGSIZE] = "[EMSGSIZE] Message too large",
     653                [EMULTIHOP] = "[EMULTIHOP] Reserved",
     654                [ENAMETOOLONG] = "[ENAMETOOLONG] Filename too long",
     655                [ENETDOWN] = "[ENETDOWN] Network is down",
     656                [ENETRESET] = "[ENETRESET] Connection aborted by network",
     657                [ENETUNREACH] = "[ENETUNREACH] Network unreachable",
     658                [ENFILE] = "[ENFILE] Too many files open in system",
     659                [ENOBUFS] = "[ENOBUFS] No buffer space available",
     660                [ENODATA] = "[ENODATA] No message is available on the STREAM head read queue",
     661                [ENODEV] = "[ENODEV] No such device",
     662                [ENOENT] = "[ENOENT] No such file or directory",
     663                [ENOEXEC] = "[ENOEXEC] Executable file format error",
     664                [ENOLCK] = "[ENOLCK] No locks available",
     665                [ENOLINK] = "[ENOLINK] Reserved",
     666                [ENOMEM] = "[ENOMEM] Not enough space",
     667                [ENOMSG] = "[ENOMSG] No message of the desired type",
     668                [ENOPROTOOPT] = "[ENOPROTOOPT] Protocol not available",
     669                [ENOSPC] = "[ENOSPC] No space left on device",
     670                [ENOSR] = "[ENOSR] No STREAM resources.",
     671                [ENOSTR] = "[ENOSTR] Not a STREAM",
     672                [ENOSYS] = "[ENOSYS] Function not supported",
     673                [ENOTCONN] = "[ENOTCONN] The socket is not connected",
     674                [ENOTDIR] = "[ENOTDIR] Not a directory",
     675                [ENOTEMPTY] = "[ENOTEMPTY] Directory not empty",
     676                [ENOTRECOVERABLE] = "[ENOTRECOVERABLE] State not recoverable",
     677                [ENOTSOCK] = "[ENOTSOCK] Not a socket",
     678                [ENOTSUP] = "[ENOTSUP] Not supported",
     679                [ENOTTY] = "[ENOTTY] Inappropriate I/O control operation",
     680                [ENXIO] = "[ENXIO] No such device or address",
     681                [EOPNOTSUPP] = "[EOPNOTSUPP] Operation not supported",
     682                [EOVERFLOW] = "[EOVERFLOW] Value too large to be stored in data type",
     683                [EOWNERDEAD] = "[EOWNERDEAD] Previous owned died",
     684                [EPERM] = "[EPERM] Operation not permitted",
     685                [EPIPE] = "[EPIPE] Broken pipe",
     686                [EPROTO] = "[EPROTO] Protocol error",
     687                [EPROTONOSUPPORT] = "[EPROTONOSUPPORT] Protocol not supported",
     688                [EPROTOTYPE] = "[EPROTOTYPE] Protocol wrong type for socket",
     689                [ERANGE] = "[ERANGE] Result too large",
     690                [EROFS] = "[EROFS] Read-only file system",
     691                [ESPIPE] = "[ESPIPE] Invalid seek",
     692                [ESRCH] = "[ESRCH] No such process",
     693                [ESTALE] = "[ESTALE] Reserved",
     694                [ETIME] = "[ETIME] Stream ioctl() timeout",
     695                [ETIMEDOUT] = "[ETIMEDOUT] Connection timed out",
     696                [ETXTBSY] = "[ETXTBSY] Text file busy",
     697                [EWOULDBLOCK] = "[EWOULDBLOCK] Operation would block",
     698                [EXDEV] = "[EXDEV] Cross-device link",
     699        };
     700
     701        return (char *) error_msgs[posix_abs(errnum)];
    621702}
    622703
     
    641722        }
    642723
    643         return EOK;
     724        return 0;
    644725}
    645726
Note: See TracChangeset for help on using the changeset viewer.