iPXE
linux_strerror.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Piotr JaroszyƄski <p.jaroszynski@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 FILE_LICENCE(GPL2_OR_LATER);
20 
21 /** @file
22  *
23  * linux_strerror implementation
24  */
25 
26 #include <linux_api.h>
27 #include <stdio.h>
28 
29 /** Error names from glibc */
30 static const char *errors[] = {
31  "Success",
32  "Operation not permitted",
33  "No such file or directory",
34  "No such process",
35  "Interrupted system call",
36  "Input/output error",
37  "No such device or address",
38  "Argument list too long",
39  "Exec format error",
40  "Bad file descriptor",
41  "No child processes",
42  "Resource temporarily unavailable",
43  "Cannot allocate memory",
44  "Permission denied",
45  "Bad address",
46  "Block device required",
47  "Device or resource busy",
48  "File exists",
49  "Invalid cross-device link",
50  "No such device",
51  "Not a directory",
52  "Is a directory",
53  "Invalid argument",
54  "Too many open files in system",
55  "Too many open files",
56  "Inappropriate ioctl for device",
57  "Text file busy",
58  "File too large",
59  "No space left on device",
60  "Illegal seek",
61  "Read-only file system",
62  "Too many links",
63  "Broken pipe",
64  "Numerical argument out of domain",
65  "Numerical result out of range",
66  "Resource deadlock avoided",
67  "File name too long",
68  "No locks available",
69  "Function not implemented",
70  "Directory not empty",
71  "Too many levels of symbolic links",
72  "",
73  "No message of desired type",
74  "Identifier removed",
75  "Channel number out of range",
76  "Level 2 not synchronized",
77  "Level 3 halted",
78  "Level 3 reset",
79  "Link number out of range",
80  "Protocol driver not attached",
81  "No CSI structure available",
82  "Level 2 halted",
83  "Invalid exchange",
84  "Invalid request descriptor",
85  "Exchange full",
86  "No anode",
87  "Invalid request code",
88  "Invalid slot",
89  "",
90  "Bad font file format",
91  "Device not a stream",
92  "No data available",
93  "Timer expired",
94  "Out of streams resources",
95  "Machine is not on the network",
96  "Package not installed",
97  "Object is remote",
98  "Link has been severed",
99  "Advertise error",
100  "Srmount error",
101  "Communication error on send",
102  "Protocol error",
103  "Multihop attempted",
104  "RFS specific error",
105  "Bad message",
106  "Value too large for defined data type",
107  "Name not unique on network",
108  "File descriptor in bad state",
109  "Remote address changed",
110  "Can not access a needed shared library",
111  "Accessing a corrupted shared library",
112  ".lib section in a.out corrupted",
113  "Attempting to link in too many shared libraries",
114  "Cannot exec a shared library directly",
115  "Invalid or incomplete multibyte or wide character",
116  "Interrupted system call should be restarted",
117  "Streams pipe error",
118  "Too many users",
119  "Socket operation on non-socket",
120  "Destination address required",
121  "Message too long",
122  "Protocol wrong type for socket",
123  "Protocol not available",
124  "Protocol not supported",
125  "Socket type not supported",
126  "Operation not supported",
127  "Protocol family not supported",
128  "Address family not supported by protocol",
129  "Address already in use",
130  "Cannot assign requested address",
131  "Network is down",
132  "Network is unreachable",
133  "Network dropped connection on reset",
134  "Software caused connection abort",
135  "Connection reset by peer",
136  "No buffer space available",
137  "Transport endpoint is already connected",
138  "Transport endpoint is not connected",
139  "Cannot send after transport endpoint shutdown",
140  "Too many references: cannot splice",
141  "Connection timed out",
142  "Connection refused",
143  "Host is down",
144  "No route to host",
145  "Operation already in progress",
146  "Operation now in progress",
147  "Stale NFS file handle",
148  "Structure needs cleaning",
149  "Not a XENIX named type file",
150  "No XENIX semaphores available",
151  "Is a named type file",
152  "Remote I/O error",
153  "Disk quota exceeded",
154  "No medium found",
155  "Wrong medium type",
156 };
157 
158 const char *linux_strerror(int errnum)
159 {
160  static char errbuf[64];
161  static int errors_size = sizeof(errors) / sizeof(*errors);
162 
163  if (errnum >= errors_size || errnum < 0) {
164  snprintf(errbuf, sizeof(errbuf), "Error %#08x", errnum);
165  return errbuf;
166  } else {
167  return errors[errnum];
168  }
169 }
static const char * errors[]
Error names from glibc.
FILE_LICENCE(GPL2_OR_LATER)
const char * linux_strerror(int errnum)
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382