sortix-mirror/libc/string/strerror.c

123 lines
5.1 KiB
C
Raw Permalink Normal View History

/*
2022-12-04 21:10:36 +00:00
* Copyright (c) 2011-2016, 2020-2022 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* string/strerror.c
* Convert error code to a string.
*/
2011-08-05 12:25:00 +00:00
#define __SORTIX_STDLIB_REDIRECTS 0
2012-09-22 14:44:50 +00:00
#include <errno.h>
2012-09-26 15:56:39 +00:00
#include <string.h>
2016-02-28 11:11:02 +00:00
const char* sortix_strerror(int errnum)
{
switch ( errnum )
{
case ENOTBLK: return "Block device required";
case ENODEV: return "No such device";
case EBADF: return "Bad file descriptor";
case EOVERFLOW: return "Value too large to be stored in data type";
case ENOENT: return "No such file or directory";
case ENOSPC: return "No space left on device";
case EEXIST: return "File exists";
case EROFS: return "Read-only file system";
case EINVAL: return "Invalid argument";
case ENOTDIR: return "Not a directory";
case ENOMEM: return "Not enough memory";
case ERANGE: return "Result too large";
case EISDIR: return "Is a directory";
case EPERM: return "Operation not permitted";
case EIO: return "Input/output error";
case ENOEXEC: return "Exec format error";
case EACCES: return "Permission denied";
case ESRCH: return "No such process";
case ENOTTY: return "Not a tty";
case ECHILD: return "No child processes";
case ENOSYS: return "Function not implemented";
case ENOTSUP: return "Operation not supported";
case EBLOCKING: return "Operation is blocking";
case EINTR: return "Interrupted function call";
case ENOTEMPTY: return "Directory not empty";
case EBUSY: return "Device or resource busy";
case EPIPE: return "Broken pipe";
case EILSEQ: return "Invalid byte sequence";
case ELAKE: return "Sit by a lake";
case EMFILE: return "Too many open files";
case EAGAIN: return "Resource temporarily unavailable";
case EEOF: return "End of file";
case EBOUND: return "Out of bounds";
case EINIT: return "Not initialized";
2012-09-07 18:25:10 +00:00
case ENODRV: return "No such driver";
case E2BIG: return "Argument list too long";
2013-01-29 21:33:57 +00:00
case EFBIG: return "File too large";
2013-01-29 21:34:23 +00:00
case EXDEV: return "Improper link";
2013-01-29 21:34:54 +00:00
case ESPIPE: return "Cannot seek on stream";
2013-01-05 14:06:22 +00:00
case ENAMETOOLONG: return "Filename too long";
2013-01-05 14:07:35 +00:00
case ELOOP: return "Too many levels of symbolic links";
2012-12-20 01:01:29 +00:00
case EMLINK: return "Too many links";
2012-12-20 21:48:14 +00:00
case ENXIO: return "No such device or address";
2013-03-19 21:39:32 +00:00
case EPROTONOSUPPORT: return "Protocol not supported";
2013-03-19 21:39:41 +00:00
case EAFNOSUPPORT: return "Address family not supported";
2013-03-19 21:40:14 +00:00
case ENOTSOCK: return "Not a socket";
2013-02-23 13:56:34 +00:00
case EADDRINUSE: return "Address already in use";
2013-03-08 22:49:41 +00:00
case ETIMEDOUT: return "Connection timed out";
2013-03-08 22:50:26 +00:00
case ECONNREFUSED: return "Connection refused";
2013-03-23 00:35:17 +00:00
case EDOM: return "Mathematics argument out of domain of function";
2013-03-23 01:04:02 +00:00
case EINPROGRESS: return "Operation in progress";
2013-03-23 22:01:38 +00:00
case EALREADY: return "Connection already in progress";
2013-03-23 22:02:25 +00:00
case ESHUTDOWN: return "Cannot send after transport endpoint shutdown";
2013-03-23 22:03:08 +00:00
case ECONNABORTED: return "Connection aborted";
2013-03-23 22:03:53 +00:00
case ECONNRESET: return "Connection reset";
2013-04-21 21:05:43 +00:00
case EADDRNOTAVAIL: return "Address not available";
2013-04-21 21:06:13 +00:00
case EISCONN: return "Socket is connected";
2013-04-21 21:07:31 +00:00
case EFAULT: return "Bad address";
2016-12-19 22:41:40 +00:00
case EDESTADDRREQ: return "Destination address required";
2013-04-21 21:11:09 +00:00
case EHOSTUNREACH: return "Host is unreachable";
2013-04-21 21:12:04 +00:00
case EMSGSIZE: return "Message too long";
2013-04-21 21:12:43 +00:00
case ENETDOWN: return "Network is down";
2013-04-21 21:13:48 +00:00
case ENETRESET: return "Connection aborted by network";
2013-04-21 21:14:30 +00:00
case ENETUNREACH: return "Network is unreachable";
2013-04-21 21:15:20 +00:00
case ENOBUFS: return "No buffer space available";
2013-04-21 21:16:07 +00:00
case ENOMSG: return "No message of the desired type";
2013-04-21 21:16:57 +00:00
case ENOPROTOOPT: return "Protocol not available";
2013-04-21 21:17:28 +00:00
case ENOTCONN: return "Socket is not connected";
2013-04-21 21:19:39 +00:00
case EDEADLK: return "Resource deadlock avoided";
2013-04-21 21:20:34 +00:00
case ENFILE: return "Too many open files in system";
2013-04-21 21:23:24 +00:00
case EPROTOTYPE: return "Wrong protocol type for socket";
2013-04-21 22:39:03 +00:00
case ENOLCK: return "No locks available";
2014-01-30 14:07:27 +00:00
case ESIGPENDING: return "Signal is already pending";
2014-06-23 17:06:43 +00:00
case ESTALE: return "Stale file handle";
2014-08-18 17:17:11 +00:00
case EBADMSG: return "Bad message";
case ECANCELED: return "Operation canceled";
case EDQUOT: return "Disk quota exceeded";
case EIDRM: return "Identifier removed";
case EMULTIHOP: return "Multihop attempted";
case ENOLINK: return "Link has been severed";
case ENOTRECOVERABLE: return "State not recoverable";
case EOWNERDEAD: return "Previous owner died";
case EPROTO: return "Protocol error";
case ETXTBSY: return "Text file busy";
2015-07-29 23:17:36 +00:00
case ENOMOUNT: return "No such mountpoint";
2021-05-28 22:37:23 +00:00
case ENOMEDIUM: return "No medium found";
2022-12-04 21:10:36 +00:00
case EHOSTDOWN: return "Host is down";
default: return "Unknown error condition";
2011-08-05 12:25:00 +00:00
}
}
2016-02-28 11:11:02 +00:00
char* strerror(int errnum)
{
return (char*) sortix_strerror(errnum);
}