1 package wasip1
2
3 import (
4 "fmt"
5
6 "github.com/tetratelabs/wazero/experimental/sys"
7 )
8
9
10 type Errno = uint32
11
12
13
14 func ErrnoName(errno uint32) string {
15 if int(errno) < len(errnoToString) {
16 return errnoToString[errno]
17 }
18 return fmt.Sprintf("errno(%d)", errno)
19 }
20
21
22
23
24 const (
25
26 ErrnoSuccess Errno = iota
27
28 Errno2big
29
30 ErrnoAcces
31
32 ErrnoAddrinuse
33
34 ErrnoAddrnotavail
35
36 ErrnoAfnosupport
37
38 ErrnoAgain
39
40 ErrnoAlready
41
42 ErrnoBadf
43
44 ErrnoBadmsg
45
46 ErrnoBusy
47
48 ErrnoCanceled
49
50 ErrnoChild
51
52 ErrnoConnaborted
53
54 ErrnoConnrefused
55
56 ErrnoConnreset
57
58 ErrnoDeadlk
59
60 ErrnoDestaddrreq
61
62 ErrnoDom
63
64 ErrnoDquot
65
66 ErrnoExist
67
68 ErrnoFault
69
70 ErrnoFbig
71
72 ErrnoHostunreach
73
74 ErrnoIdrm
75
76 ErrnoIlseq
77
78 ErrnoInprogress
79
80 ErrnoIntr
81
82 ErrnoInval
83
84 ErrnoIo
85
86 ErrnoIsconn
87
88 ErrnoIsdir
89
90 ErrnoLoop
91
92 ErrnoMfile
93
94 ErrnoMlink
95
96 ErrnoMsgsize
97
98 ErrnoMultihop
99
100 ErrnoNametoolong
101
102 ErrnoNetdown
103
104 ErrnoNetreset
105
106 ErrnoNetunreach
107
108 ErrnoNfile
109
110 ErrnoNobufs
111
112 ErrnoNodev
113
114 ErrnoNoent
115
116 ErrnoNoexec
117
118 ErrnoNolck
119
120 ErrnoNolink
121
122 ErrnoNomem
123
124 ErrnoNomsg
125
126 ErrnoNoprotoopt
127
128 ErrnoNospc
129
130 ErrnoNosys
131
132 ErrnoNotconn
133
134 ErrnoNotdir
135
136 ErrnoNotempty
137
138 ErrnoNotrecoverable
139
140 ErrnoNotsock
141
142 ErrnoNotsup
143
144 ErrnoNotty
145
146 ErrnoNxio
147
148 ErrnoOverflow
149
150 ErrnoOwnerdead
151
152 ErrnoPerm
153
154 ErrnoPipe
155
156 ErrnoProto
157
158 ErrnoProtonosupport
159
160 ErrnoPrototype
161
162 ErrnoRange
163
164 ErrnoRofs
165
166 ErrnoSpipe
167
168 ErrnoSrch
169
170 ErrnoStale
171
172 ErrnoTimedout
173
174 ErrnoTxtbsy
175
176 ErrnoXdev
177
178
179
180 )
181
182 var errnoToString = [...]string{
183 "ESUCCESS",
184 "E2BIG",
185 "EACCES",
186 "EADDRINUSE",
187 "EADDRNOTAVAIL",
188 "EAFNOSUPPORT",
189 "EAGAIN",
190 "EALREADY",
191 "EBADF",
192 "EBADMSG",
193 "EBUSY",
194 "ECANCELED",
195 "ECHILD",
196 "ECONNABORTED",
197 "ECONNREFUSED",
198 "ECONNRESET",
199 "EDEADLK",
200 "EDESTADDRREQ",
201 "EDOM",
202 "EDQUOT",
203 "EEXIST",
204 "EFAULT",
205 "EFBIG",
206 "EHOSTUNREACH",
207 "EIDRM",
208 "EILSEQ",
209 "EINPROGRESS",
210 "EINTR",
211 "EINVAL",
212 "EIO",
213 "EISCONN",
214 "EISDIR",
215 "ELOOP",
216 "EMFILE",
217 "EMLINK",
218 "EMSGSIZE",
219 "EMULTIHOP",
220 "ENAMETOOLONG",
221 "ENETDOWN",
222 "ENETRESET",
223 "ENETUNREACH",
224 "ENFILE",
225 "ENOBUFS",
226 "ENODEV",
227 "ENOENT",
228 "ENOEXEC",
229 "ENOLCK",
230 "ENOLINK",
231 "ENOMEM",
232 "ENOMSG",
233 "ENOPROTOOPT",
234 "ENOSPC",
235 "ENOSYS",
236 "ENOTCONN",
237 "ENOTDIR",
238 "ENOTEMPTY",
239 "ENOTRECOVERABLE",
240 "ENOTSOCK",
241 "ENOTSUP",
242 "ENOTTY",
243 "ENXIO",
244 "EOVERFLOW",
245 "EOWNERDEAD",
246 "EPERM",
247 "EPIPE",
248 "EPROTO",
249 "EPROTONOSUPPORT",
250 "EPROTOTYPE",
251 "ERANGE",
252 "EROFS",
253 "ESPIPE",
254 "ESRCH",
255 "ESTALE",
256 "ETIMEDOUT",
257 "ETXTBSY",
258 "EXDEV",
259 "ENOTCAPABLE",
260 }
261
262
263
264
265
266
267 func ToErrno(errno sys.Errno) Errno {
268 switch errno {
269 case 0:
270 return ErrnoSuccess
271 case sys.EACCES:
272 return ErrnoAcces
273 case sys.EAGAIN:
274 return ErrnoAgain
275 case sys.EBADF:
276 return ErrnoBadf
277 case sys.EEXIST:
278 return ErrnoExist
279 case sys.EFAULT:
280 return ErrnoFault
281 case sys.EINTR:
282 return ErrnoIntr
283 case sys.EINVAL:
284 return ErrnoInval
285 case sys.EIO:
286 return ErrnoIo
287 case sys.EISDIR:
288 return ErrnoIsdir
289 case sys.ELOOP:
290 return ErrnoLoop
291 case sys.ENAMETOOLONG:
292 return ErrnoNametoolong
293 case sys.ENOENT:
294 return ErrnoNoent
295 case sys.ENOSYS:
296 return ErrnoNosys
297 case sys.ENOTDIR:
298 return ErrnoNotdir
299 case sys.ERANGE:
300 return ErrnoRange
301 case sys.ENOTEMPTY:
302 return ErrnoNotempty
303 case sys.ENOTSOCK:
304 return ErrnoNotsock
305 case sys.ENOTSUP:
306 return ErrnoNotsup
307 case sys.EPERM:
308 return ErrnoPerm
309 case sys.EROFS:
310 return ErrnoRofs
311 default:
312 return ErrnoIo
313 }
314 }
315
View as plain text