2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 const char *strerror(int errnum
)
31 static char errno_string
[10];
33 #ifdef CONFIG_ERRNO_MESSAGES
36 case 0 : str
= "No error"; break;
37 case EPERM
: str
= "Operation not permitted"; break;
38 case ENOENT
: str
= "No such file or directory"; break;
39 case EIO
: str
= "I/O error"; break;
40 case ENXIO
: str
= "No such device or address"; break;
41 case E2BIG
: str
= "Arg list too long"; break;
42 case ENOEXEC
: str
= "Exec format error"; break;
43 case EBADF
: str
= "Bad file number"; break;
44 case ENOMEM
: str
= "Out of memory"; break;
45 case EACCES
: str
= "Permission denied"; break;
46 case EFAULT
: str
= "Bad address"; break;
47 case EBUSY
: str
= "Device or resource busy"; break;
48 case EEXIST
: str
= "File exists"; break;
49 case ENODEV
: str
= "No such device"; break;
50 case ENOTDIR
: str
= "Not a directory"; break;
51 case EISDIR
: str
= "Is a directory"; break;
52 case EINVAL
: str
= "Invalid argument"; break;
53 case ENOSPC
: str
= "No space left on device"; break;
54 case ESPIPE
: str
= "Illegal seek"; break;
55 case EROFS
: str
= "Read-only file system"; break;
56 case ENAMETOOLONG
: str
= "File name too long"; break;
57 case ENOSYS
: str
= "Function not implemented"; break;
58 case ENOTEMPTY
: str
= "Directory not empty"; break;
59 case EHOSTUNREACH
: str
= "No route to host"; break;
60 case EINTR
: str
= "Interrupted system call"; break;
61 case ENETUNREACH
: str
= "Network is unreachable"; break;
62 case ENETDOWN
: str
= "Network is down"; break;
63 #if 0 /* These are probably not needed */
64 case ENOTBLK
: str
= "Block device required"; break;
65 case EFBIG
: str
= "File too large"; break;
66 case EBADSLT
: str
= "Invalid slot"; break;
67 case ENODATA
: str
= "No data available"; break;
68 case ETIME
: str
= "Timer expired"; break;
69 case ENONET
: str
= "Machine is not on the network"; break;
70 case EADV
: str
= "Advertise error"; break;
71 case ECOMM
: str
= "Communication error on send"; break;
72 case EPROTO
: str
= "Protocol error"; break;
73 case EBADMSG
: str
= "Not a data message"; break;
74 case EOVERFLOW
: str
= "Value too large for defined data type"; break;
75 case EBADFD
: str
= "File descriptor in bad state"; break;
76 case EREMCHG
: str
= "Remote address changed"; break;
77 case EMSGSIZE
: str
= "Message too long"; break;
78 case EPROTOTYPE
: str
= "Protocol wrong type for socket"; break;
79 case ENOPROTOOPT
: str
= "Protocol not available"; break;
80 case EPROTONOSUPPORT
: str
= "Protocol not supported"; break;
81 case ESOCKTNOSUPPORT
: str
= "Socket type not supported"; break;
82 case EPFNOSUPPORT
: str
= "Protocol family not supported"; break;
83 case EAFNOSUPPORT
: str
= "Address family not supported by protocol"; break;
84 case EADDRINUSE
: str
= "Address already in use"; break;
85 case EADDRNOTAVAIL
: str
= "Cannot assign requested address"; break;
86 case ENETRESET
: str
= "Network dropped connection because of reset"; break;
87 case ECONNABORTED
: str
= "Software caused connection abort"; break;
88 case ECONNRESET
: str
= "Connection reset by peer"; break;
89 case ENOBUFS
: str
= "No buffer space available"; break;
90 case ETIMEDOUT
: str
= "Connection timed out"; break;
91 case ECONNREFUSED
: str
= "Connection refused"; break;
92 case EHOSTDOWN
: str
= "Host is down"; break;
93 case EALREADY
: str
= "Operation already in progress"; break;
94 case EINPROGRESS
: str
= "Operation now in progress"; break;
95 case ESTALE
: str
= "Stale NFS file handle"; break;
96 case EISNAM
: str
= "Is a named type file"; break;
97 case EREMOTEIO
: str
= "Remote I/O error"; break;
100 sprintf(errno_string
, "error %d", errnum
);
106 sprintf(errno_string
, "error %d", errnum
);
111 EXPORT_SYMBOL(strerror
);
113 const char *errno_str(void)
115 return strerror(-errno
);
117 EXPORT_SYMBOL(errno_str
);
119 void perror(const char *s
)
121 #ifdef CONFIG_ERRNO_MESSAGES
122 printf("%s: %s\n", s
, errno_str());
124 printf("%s returned with %d\n", s
, errno
);
127 EXPORT_SYMBOL(perror
);