Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/lib9p/pytest/lerrno.py
39483 views
1
#! /usr/bin/env python
2
3
"""
4
Error number definitions for Linux.
5
"""
6
7
EPERM = 1
8
ENOENT = 2
9
ESRCH = 3
10
EINTR = 4
11
EIO = 5
12
ENXIO = 6
13
E2BIG = 7
14
ENOEXEC = 8
15
EBADF = 9
16
ECHILD = 10
17
EAGAIN = 11
18
ENOMEM = 12
19
EACCES = 13
20
EFAULT = 14
21
ENOTBLK = 15
22
EBUSY = 16
23
EEXIST = 17
24
EXDEV = 18
25
ENODEV = 19
26
ENOTDIR = 20
27
EISDIR = 21
28
EINVAL = 22
29
ENFILE = 23
30
EMFILE = 24
31
ENOTTY = 25
32
ETXTBSY = 26
33
EFBIG = 27
34
ENOSPC = 28
35
ESPIPE = 29
36
EROFS = 30
37
EMLINK = 31
38
EPIPE = 32
39
EDOM = 33
40
ERANGE = 34
41
EDEADLK = 35
42
ENAMETOOLONG = 36
43
ENOLCK = 37
44
ENOSYS = 38
45
ENOTEMPTY = 39
46
ELOOP = 40
47
# 41 unused
48
ENOMSG = 42
49
EIDRM = 43
50
ECHRNG = 44
51
EL2NSYNC = 45
52
EL3HLT = 46
53
EL3RST = 47
54
ELNRNG = 48
55
EUNATCH = 49
56
ENOCSI = 50
57
EL2HLT = 51
58
EBADE = 52
59
EBADR = 53
60
EXFULL = 54
61
ENOANO = 55
62
EBADRQC = 56
63
EBADSLT = 57
64
# 58 unused
65
EBFONT = 59
66
ENOSTR = 60
67
ENODATA = 61
68
ETIME = 62
69
ENOSR = 63
70
ENONET = 64
71
ENOPKG = 65
72
EREMOTE = 66
73
ENOLINK = 67
74
EADV = 68
75
ESRMNT = 69
76
ECOMM = 70
77
EPROTO = 71
78
EMULTIHOP = 72
79
EDOTDOT = 73
80
EBADMSG = 74
81
EOVERFLOW = 75
82
ENOTUNIQ = 76
83
EBADFD = 77
84
EREMCHG = 78
85
ELIBACC = 79
86
ELIBBAD = 80
87
ELIBSCN = 81
88
ELIBMAX = 82
89
ELIBEXEC = 83
90
EILSEQ = 84
91
ERESTART = 85
92
ESTRPIPE = 86
93
EUSERS = 87
94
ENOTSOCK = 88
95
EDESTADDRREQ = 89
96
EMSGSIZE = 90
97
EPROTOTYPE = 91
98
ENOPROTOOPT = 92
99
EPROTONOSUPPORT = 93
100
ESOCKTNOSUPPORT = 94
101
EOPNOTSUPP = 95
102
EPFNOSUPPORT = 96
103
EAFNOSUPPORT = 97
104
EADDRINUSE = 98
105
EADDRNOTAVAIL = 99
106
ENETDOWN = 100
107
ENETUNREACH = 101
108
ENETRESET = 102
109
ECONNABORTED = 103
110
ECONNRESET = 104
111
ENOBUFS = 105
112
EISCONN = 106
113
ENOTCONN = 107
114
ESHUTDOWN = 108
115
ETOOMANYREFS = 109
116
ETIMEDOUT = 110
117
ECONNREFUSED = 111
118
EHOSTDOWN = 112
119
EHOSTUNREACH = 113
120
EALREADY = 114
121
EINPROGRESS = 115
122
ESTALE = 116
123
EUCLEAN = 117
124
ENOTNAM = 118
125
ENAVAIL = 119
126
EISNAM = 120
127
EREMOTEIO = 121
128
EDQUOT = 122
129
ENOMEDIUM = 123
130
EMEDIUMTYPE = 124
131
ECANCELED = 125
132
ENOKEY = 126
133
EKEYEXPIRED = 127
134
EKEYREVOKED = 128
135
EKEYREJECTED = 129
136
EOWNERDEAD = 130
137
ENOTRECOVERABLE = 131
138
ERFKILL = 132
139
EHWPOISON = 133
140
141
_strerror = {
142
EPERM: 'Permission denied',
143
ENOENT: 'No such file or directory',
144
ESRCH: 'No such process',
145
EINTR: 'Interrupted system call',
146
EIO: 'Input/output error',
147
ENXIO: 'Device not configured',
148
E2BIG: 'Argument list too long',
149
ENOEXEC: 'Exec format error',
150
EBADF: 'Bad file descriptor',
151
ECHILD: 'No child processes',
152
EAGAIN: 'Resource temporarily unavailable',
153
ENOMEM: 'Cannot allocate memory',
154
EACCES: 'Permission denied',
155
EFAULT: 'Bad address',
156
ENOTBLK: 'Block device required',
157
EBUSY: 'Device busy',
158
EEXIST: 'File exists',
159
EXDEV: 'Cross-device link',
160
ENODEV: 'Operation not supported by device',
161
ENOTDIR: 'Not a directory',
162
EISDIR: 'Is a directory',
163
EINVAL: 'Invalid argument',
164
ENFILE: 'Too many open files in system',
165
EMFILE: 'Too many open files',
166
ENOTTY: 'Inappropriate ioctl for device',
167
ETXTBSY: 'Text file busy',
168
EFBIG: 'File too large',
169
ENOSPC: 'No space left on device',
170
ESPIPE: 'Illegal seek',
171
EROFS: 'Read-only filesystem',
172
EMLINK: 'Too many links',
173
EPIPE: 'Broken pipe',
174
EDOM: 'Numerical argument out of domain',
175
ERANGE: 'Result too large',
176
EDEADLK: 'Resource deadlock avoided',
177
ENAMETOOLONG: 'File name too long',
178
ENOLCK: 'No locks available',
179
ENOSYS: 'Function not implemented',
180
ENOTEMPTY: 'Directory not empty',
181
ELOOP: 'Too many levels of symbolic links',
182
ENOMSG: 'No message of desired type',
183
EIDRM: 'Identifier removed',
184
ECHRNG: 'Channel number out of range',
185
EL2NSYNC: 'Level 2 not synchronized',
186
EL3HLT: 'Level 3 halted',
187
EL3RST: 'Level 3 reset',
188
ELNRNG: 'Link number out of range',
189
EUNATCH: 'Protocol driver not attached',
190
ENOCSI: 'No CSI structure available',
191
EL2HLT: 'Level 2 halted',
192
EBADE: 'Invalid exchange',
193
EBADR: 'Invalid request descriptor',
194
EXFULL: 'Exchange full',
195
ENOANO: 'No anode',
196
EBADRQC: 'Invalid request code',
197
EBADSLT: 'Invalid slot',
198
EBFONT: 'Bad font file format',
199
ENOSTR: 'Device not a stream',
200
ENODATA: 'No data available',
201
ETIME: 'Timer expired',
202
ENOSR: 'Out of streams resources',
203
ENONET: 'Machine is not on the network',
204
ENOPKG: 'Package not installed',
205
EREMOTE: 'Object is remote',
206
ENOLINK: 'Link has been severed',
207
EADV: 'Advertise error',
208
ESRMNT: 'Srmount error',
209
ECOMM: 'Communication error on send',
210
EPROTO: 'Protocol error',
211
EMULTIHOP: 'Multihop attempted',
212
EDOTDOT: 'RFS specific error',
213
EBADMSG: 'Bad message',
214
EOVERFLOW: 'Value too large for defined data type',
215
ENOTUNIQ: 'Name not unique on network',
216
EBADFD: 'File descriptor in bad state',
217
EREMCHG: 'Remote address changed',
218
ELIBACC: 'Can not access a needed shared library',
219
ELIBBAD: 'Accessing a corrupted shared library',
220
ELIBSCN: '.lib section in a.out corrupted',
221
ELIBMAX: 'Attempting to link in too many shared libraries',
222
ELIBEXEC: 'Cannot exec a shared library directly',
223
EILSEQ: 'Invalid or incomplete multibyte or wide character',
224
ERESTART: 'Interrupted system call should be restarted',
225
ESTRPIPE: 'Streams pipe error',
226
EUSERS: 'Too many users',
227
ENOTSOCK: 'Socket operation on non-socket',
228
EDESTADDRREQ: 'Destination address required',
229
EMSGSIZE: 'Message too long',
230
EPROTOTYPE: 'Protocol wrong type for socket',
231
ENOPROTOOPT: 'Protocol not available',
232
EPROTONOSUPPORT: 'Protocol not supported',
233
ESOCKTNOSUPPORT: 'Socket type not supported',
234
EOPNOTSUPP: 'Operation not supported',
235
EPFNOSUPPORT: 'Protocol family not supported',
236
EAFNOSUPPORT: 'Address family not supported by protocol',
237
EADDRINUSE: 'Address already in use',
238
EADDRNOTAVAIL: 'Cannot assign requested address',
239
ENETDOWN: 'Network is down',
240
ENETUNREACH: 'Network is unreachable',
241
ENETRESET: 'Network dropped connection on reset',
242
ECONNABORTED: 'Software caused connection abort',
243
ECONNRESET: 'Connection reset by peer',
244
ENOBUFS: 'No buffer space available',
245
EISCONN: 'Transport endpoint is already connected',
246
ENOTCONN: 'Transport endpoint is not connected',
247
ESHUTDOWN: 'Cannot send after transport endpoint shutdown',
248
ETOOMANYREFS: 'Too many references: cannot splice',
249
ETIMEDOUT: 'Connection timed out',
250
ECONNREFUSED: 'Connection refused',
251
EHOSTDOWN: 'Host is down',
252
EHOSTUNREACH: 'No route to host',
253
EALREADY: 'Operation already in progress',
254
EINPROGRESS: 'Operation now in progress',
255
ESTALE: 'Stale file handle',
256
EUCLEAN: 'Structure needs cleaning',
257
ENOTNAM: 'Not a XENIX named type file',
258
ENAVAIL: 'No XENIX semaphores available',
259
EISNAM: 'Is a named type file',
260
EREMOTEIO: 'Remote I/O error',
261
EDQUOT: 'Quota exceeded',
262
ENOMEDIUM: 'No medium found',
263
EMEDIUMTYPE: 'Wrong medium type',
264
ECANCELED: 'Operation canceled',
265
ENOKEY: 'Required key not available',
266
EKEYEXPIRED: 'Key has expired',
267
EKEYREVOKED: 'Key has been revoked',
268
EKEYREJECTED: 'Key was rejected by service',
269
EOWNERDEAD: 'Owner died',
270
ENOTRECOVERABLE: 'State not recoverable',
271
ERFKILL: 'Operation not possible due to RF-kill',
272
EHWPOISON: 'Memory page has hardware error',
273
}
274
275
def strerror(errnum):
276
"""
277
Translate Linux errno to string.
278
279
>>> strerror(ENOKEY)
280
'Required key not available'
281
>>> strerror(41)
282
'Unknown error 41'
283
"""
284
ret = _strerror.get(errnum)
285
if ret:
286
return ret
287
return 'Unknown error {0}'.format(errnum)
288
289
if __name__ == '__main__':
290
import doctest
291
doctest.testmod()
292
293