9
0
Fork 0

add strerror function

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2009-04-06 11:54:08 +02:00
parent 31c25dd6a3
commit 0f64e5c39d
2 changed files with 12 additions and 4 deletions

View File

@ -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)

View File

@ -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 */