From 7dcf6715ffb3cc2f00f6327b896d16f173a1b082 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sat, 24 Feb 2018 06:45:44 +0100 Subject: New errno.h standard header Use standard errno codes. This change also adds strerror to string.h. --- kern/string.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'kern/string.c') 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 #include #include @@ -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"; + } +} -- cgit v1.2.3