diff options
author | Richard Braun <rbraun@sceen.net> | 2018-02-24 06:45:44 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-02-24 06:48:21 +0100 |
commit | 7dcf6715ffb3cc2f00f6327b896d16f173a1b082 (patch) | |
tree | 210570e98e074d7abade0d22c64e05b9c02435ba /kern/string.c | |
parent | be5b9d6ab9f7e7a81c367e4bb0823ba11f85940f (diff) |
New errno.h standard header
Use standard errno codes. This change also adds strerror to string.h.
Diffstat (limited to 'kern/string.c')
-rw-r--r-- | kern/string.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/kern/string.c b/kern/string.c index 70d03d02..0d3b735b 100644 --- a/kern/string.c +++ b/kern/string.c @@ -18,6 +18,7 @@ * Trivial, portable implementations. */ +#include <errno.h> #include <stddef.h> #include <string.h> @@ -226,3 +227,34 @@ strchr(const char *s, int c) } } #endif /* STRING_ARCH_STRCHR */ + +const char * +strerror(int error) +{ + switch (error) { + case 0: + return "success"; + case ENOMEM: + return "out of memory"; + case EAGAIN: + return "resource temporarily unavailable"; + case EINVAL: + return "invalid argument"; + case EBUSY: + return "device or resource busy"; + case EFAULT: + return "bad address"; + case ENODEV: + return "no such device"; + case EEXIST: + return "entry exists"; + case EIO: + return "input/output error"; + case ESRCH: + return "no such process"; + case ETIMEDOUT: + return "timeout error"; + default: + return "unknown error"; + } +} |