1 /* VirtualBox driver - by D.C. van Moolenbroek */
2 #include <minix/drivers.h>
3 #include <errno.h>
4
5 #include "vmmdev.h"
6 #include "proto.h"
7
8 static int codes[] = {
9 OK, /* 0: success */
10 EGENERIC, /* -1: general failure */
11 EINVAL, /* -2: invalid parameter */
12 EINVAL, /* -3: invalid magic */
13 EBADF, /* -4: invalid handle */
14 ENOLCK, /* -5: lock failed */
15 EFAULT, /* -6: invalid pointer */
16 EGENERIC, /* -7: patching IDT failed */
17 ENOMEM, /* -8: memory allocation failed */
18 EEXIST, /* -9: already loaded */
19 EPERM, /* -10: permission denied */
20 EINVAL, /* -11: version mismatch */
21 ENOSYS, /* -12: function not implemented */
22 EGENERIC, /* -13 */
23 EGENERIC, /* -14 */
24 EGENERIC, /* -15 */
25 EGENERIC, /* -16 */
26 EGENERIC, /* -17 */
27 EGENERIC, /* -18: not equal */
28 EINVAL, /* -19: not a symlink */
29 ENOMEM, /* -20: temporary memory allocation failed */
30 EINVAL, /* -21: invalid file mode */
31 EINVAL, /* -22: incorrect call order */
32 EGENERIC, /* -23: no TLS available */
33 EGENERIC, /* -24: failed to set TLS */
34 EGENERIC, /* -25 */
35 ENOMEM, /* -26: contiguous memory allocation failed */
36 ENOMEM, /* -27: no memory available for page table */
37 EGENERIC, /* -28 */
38 ESRCH, /* -29: thread is dead */
39 EINVAL, /* -30: thread is not waitable */
40 EGENERIC, /* -31: page table not present */
41 EINVAL, /* -32: invalid context */
42 EBUSY, /* -33: timer is busy */
43 EGENERIC, /* -34: address conflict */
44 EGENERIC, /* -35: unresolved error */
45 ENOTTY, /* -36: invalid function */
46 EINVAL, /* -37: not supported */
47 EACCES, /* -38: access denied */
48 EINTR, /* -39: interrupted */
49 ETIMEDOUT, /* -40: timeout */
50 E2BIG, /* -41: buffer overflow */
51 E2BIG, /* -42: too much data */
52 EAGAIN, /* -43: max thread number reached */
53 EAGAIN, /* -44: max process number reached */
54 EGENERIC, /* -45: signal refused */
55 EBUSY, /* -46: signal already pending */
56 EINVAL, /* -47: invalid signal */
57 EGENERIC, /* -48: state changed */
58 EINVAL, /* -49: invalid UUID format */
59 ESRCH, /* -50: process not found */
60 OK, /* -51: waited-for process is still running */
61 EAGAIN, /* -52: try again */
62 EGENERIC, /* -53: generic parse error */
63 ERANGE, /* -54: value out of range */
64 EOVERFLOW, /* -55: value too big */
65 EGENERIC, /* -56: no digits in string */
66 ERANGE, /* -57: minus sign in unsigned value */
67 EILSEQ, /* -58: character translation failed */
68 EGENERIC, /* -59: encountered unicode byte order mark */
69 EGENERIC, /* -60: encountered unicode surrogate */
70 EILSEQ, /* -61: invalid UTF8 encoding */
71 EILSEQ, /* -62: invalid UTF16 encoding */
72 EGENERIC, /* -63: no UTF16 for character */
73 ENOMEM, /* -64: string memory allocation failed */
74 ENOMEM, /* -65: UTF16 string memory allocation failed */
75 ENOMEM, /* -66: code point array allocation failed */
76 EBUSY, /* -67: cannot free in-use memory */
77 EGENERIC, /* -68: timer already active */
78 EGENERIC, /* -69: timer already suspended */
79 ECANCELED, /* -70: operation cancelled */
80 ENOMEM, /* -71: failed to initialize memory object */
81 ENOMEM, /* -72: low physical memory allocation failed */
82 ENOMEM, /* -73: physical memory allocation failed */
83 EGENERIC, /* -74: address too big */
84 EGENERIC, /* -75: memory mapping failed */
85 EGENERIC, /* -76: trailing characters */
86 EGENERIC, /* -77: trailing spaces */
87 ESRCH, /* -78: not found */
88 EGENERIC, /* -79: invalid state */
89 ENOMEM, /* -80: out of resources */
90 ENFILE, /* -81: no more handles */
91 EGENERIC, /* -82: preemption disabled */
92 EGENERIC, /* -83: end of string */
93 EGENERIC, /* -84: page count out of range */
94 EGENERIC, /* -85: object destroyed */
95 EGENERIC, /* -86: dangling objects */
96 EGENERIC, /* -87: invalid Base64 encoding */
97 EGENERIC, /* -88: return triggered by callback */
98 EGENERIC, /* -89: authentication failure */
99 EGENERIC, /* -90: not a power of two */
100 EGENERIC, /* -91: ignored */
101 EGENERIC, /* -92: concurrent access not allowed */
102 EGENERIC, /* -93: invalid reference sharing */
103 EGENERIC, /* -94 */
104 EGENERIC, /* -95: no change */
105 ENOMEM, /* -96: executable memory allocation failed */
106 EINVAL, /* -97: unsupported alignment */
107 EGENERIC, /* -98: duplicate */
108 EGENERIC, /* -99: missing */
109 EIO, /* -100: I/O error */
110 ENXIO, /* -101: open failed */
111 ENOENT, /* -102: file not found */
112 ENOTDIR, /* -103: path not found (may also mean ENOENT) */
113 EINVAL, /* -104: invalid name */
114 EEXIST, /* -105: already exists */
115 ENFILE, /* -106: too many open files */
116 EIO, /* -107: seek error */
117 EINVAL, /* -108: negative seek */
118 ESPIPE, /* -109: seek on device */
119 EGENERIC, /* -110: end of file */
120 EIO, /* -111: generic read error */
121 EIO, /* -112: generic write error */
122 EROFS, /* -113: write protected */
123 ETXTBSY, /* -114: sharing violation */
124 ENOLCK, /* -115: file lock failed */
125 EAGAIN, /* -116: file lock violation */
126 EIO, /* -117: cannot create file */
127 EIO, /* -118: cannot delete directory */
128 EXDEV, /* -119: not the same device */
129 ENAMETOOLONG, /* -120: file name too long */
130 ENXIO, /* -121: media not present */
131 EIO, /* -122: media not recognized */
132 OK, /* -123: nothing to unlocked */
133 EGENERIC, /* -124: lock lost */
134 ENOTEMPTY, /* -125: directory not empty */
135 ENOTDIR, /* -126: not a directory */
136 EISDIR, /* -127: is a directory */
137 EFBIG, /* -128: file too big */
138 EGENERIC, /* -129: no asynchronous I/O request */
139 EGENERIC, /* -130: asynchronous I/O in progress */
140 EGENERIC, /* -131: asynchronous I/O completed */
141 EGENERIC, /* -132: asynchronous I/O busy */
142 EGENERIC, /* -133: asynchronous I/O limit exceeded */
143 EGENERIC, /* -134: asynchronous I/O canceled */
144 EGENERIC, /* -135: asynchronous I/O not submitted */
145 EGENERIC, /* -136: asynchronous I/O not prepared */
146 EGENERIC, /* -137: asynchronous I/O out of resources */
147 EBUSY, /* -138: device or resource busy */
148 EGENERIC, /* -139: not a file */
149 EGENERIC, /* -140: is a file */
150 EGENERIC, /* -141: unexpected file type */
151 EGENERIC, /* -142: missing path root specification */
152 EGENERIC, /* -143: path is relative */
153 EGENERIC, /* -144: path is not relative */
154 EGENERIC, /* -145 */
155 EGENERIC, /* -146 */
156 EGENERIC, /* -147 */
157 EGENERIC, /* -148 */
158 EGENERIC, /* -149 */
159 EIO, /* -150: disk I/O error */
160 ENXIO, /* -151: invalid drive number */
161 ENOSPC, /* -152: disk full */
162 EIO, /* -153: disk changed */
163 EGENERIC, /* -154: drive locked */
164 ENXIO, /* -155: invalid disk format */
165 ELOOP, /* -156: too many symlinks */
166 EOPNOTSUPP, /* -157: can not set symlink file times */
167 EOPNOTSUPP, /* -158: can not change symlink owner */
168 EGENERIC, /* -159 */
169 EGENERIC, /* -160 */
170 EGENERIC, /* -161 */
171 EGENERIC, /* -162 */
172 EGENERIC, /* -163 */
173 EGENERIC, /* -164 */
174 EGENERIC, /* -165 */
175 EGENERIC, /* -166 */
176 EGENERIC, /* -167 */
177 EGENERIC, /* -168 */
178 EGENERIC, /* -169 */
179 EGENERIC, /* -170 */
180 EGENERIC, /* -171 */
181 EGENERIC, /* -172 */
182 EGENERIC, /* -173 */
183 EGENERIC, /* -174 */
184 EGENERIC, /* -175 */
185 EGENERIC, /* -176 */
186 EGENERIC, /* -177 */
187 EGENERIC, /* -178 */
188 EGENERIC, /* -179 */
189 EGENERIC, /* -180 */
190 EGENERIC, /* -181 */
191 EGENERIC, /* -182 */
192 EGENERIC, /* -183 */
193 EGENERIC, /* -184 */
194 EGENERIC, /* -185 */
195 EGENERIC, /* -186 */
196 EGENERIC, /* -187 */
197 EGENERIC, /* -188 */
198 EGENERIC, /* -189 */
199 EGENERIC, /* -190 */
200 EGENERIC, /* -191 */
201 EGENERIC, /* -192 */
202 EGENERIC, /* -193 */
203 EGENERIC, /* -194 */
204 EGENERIC, /* -195 */
205 EGENERIC, /* -196 */
206 EGENERIC, /* -197 */
207 EGENERIC, /* -198 */
208 EGENERIC, /* -199 */
209 EGENERIC, /* -200: search error */
210 OK, /* -201: no more files */
211 ENFILE, /* -202: no more search handles available */
212 };
213
convert_err(int code)214 int convert_err(int code)
215 {
216 /* Return a POSIX error code for the given VirtualBox error code.
217 */
218 unsigned int index;
219
220 index = -code;
221
222 if (index < sizeof(codes) / sizeof(codes[0]))
223 return codes[index];
224
225 return EGENERIC;
226 }
227