From 0f64e5c39d3a7803df49724f36170770f4ae1d48 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 6 Apr 2009 11:54:08 +0200 Subject: add strerror function Signed-off-by: Sascha Hauer --- common/misc.c | 15 +++++++++++---- include/errno.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/misc.c b/common/misc.c index 43c1a0c62b..6754696598 100644 --- a/common/misc.c +++ b/common/misc.c @@ -75,13 +75,13 @@ int errno; EXPORT_SYMBOL(errno); -const char *errno_str(void) +const char *strerror(int errnum) { static char errno_string[10]; #ifdef CONFIG_ERRNO_MESSAGES char *str; - switch(-errno) { + switch(errnum) { case 0 : str = "No error"; break; case EPERM : str = "Operation not permitted"; break; case ENOENT : str = "No such file or directory"; break; @@ -145,16 +145,23 @@ const char *errno_str(void) case EREMOTEIO : str = "Remote I/O error"; break; #endif default: - sprintf(errno_string, "error %d", errno); + sprintf(errno_string, "error %d", errnum); return errno_string; }; return str; #else - sprintf(errno_string, "error %d", errno); + sprintf(errno_string, "error %d", errnum); + return errno_string; #endif } +EXPORT_SYMBOL(strerror); + +const char *errno_str(void) +{ + return strerror(-errno); +} EXPORT_SYMBOL(errno_str); void perror(const char *s) diff --git a/include/errno.h b/include/errno.h index 56614262ef..025816e067 100644 --- a/include/errno.h +++ b/include/errno.h @@ -7,5 +7,6 @@ extern int errno; void perror(const char *s); const char *errno_str(void); +const char *strerror(int errnum); #endif /* __ERRNO_H */ -- cgit v1.2.3