Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/common/brand/lx/lx_errno.c
+++ new/usr/src/common/brand/lx/lx_errno.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2015 Joyent, Inc.
14 14 */
15 15
16 16 /*
17 17 * This file contains a mapping table and lookup function for converting
18 18 * illumos native error numbers into error numbers appropriate for Linux
19 19 * emulation.
20 20 *
21 21 * The translation table is generated by the "gen_errno", built from and
22 22 * documented in "usr/src/common/brand/lx/tools".
23 23 */
24 24
25 25 #include <sys/debug.h>
26 26
27 27 const int
28 28 lx_stol_errno[] = {
29 29 0, /* 0: No Error */
30 30 1, /* 1: EPERM --> 1: EPERM */
31 31 2, /* 2: ENOENT --> 2: ENOENT */
32 32 3, /* 3: ESRCH --> 3: ESRCH */
33 33 4, /* 4: EINTR --> 4: EINTR */
34 34 5, /* 5: EIO --> 5: EIO */
35 35 6, /* 6: ENXIO --> 6: ENXIO */
36 36 7, /* 7: E2BIG --> 7: E2BIG */
37 37 8, /* 8: ENOEXEC --> 8: ENOEXEC */
38 38 9, /* 9: EBADF --> 9: EBADF */
39 39 10, /* 10: ECHILD --> 10: ECHILD */
40 40 11, /* 11: EAGAIN --> 11: EAGAIN */
41 41 12, /* 12: ENOMEM --> 12: ENOMEM */
42 42 13, /* 13: EACCES --> 13: EACCES */
43 43 14, /* 14: EFAULT --> 14: EFAULT */
44 44 15, /* 15: ENOTBLK --> 15: ENOTBLK */
45 45 16, /* 16: EBUSY --> 16: EBUSY */
46 46 17, /* 17: EEXIST --> 17: EEXIST */
47 47 18, /* 18: EXDEV --> 18: EXDEV */
48 48 19, /* 19: ENODEV --> 19: ENODEV */
49 49 20, /* 20: ENOTDIR --> 20: ENOTDIR */
50 50 21, /* 21: EISDIR --> 21: EISDIR */
51 51 22, /* 22: EINVAL --> 22: EINVAL */
52 52 23, /* 23: ENFILE --> 23: ENFILE */
53 53 24, /* 24: EMFILE --> 24: EMFILE */
54 54 25, /* 25: ENOTTY --> 25: ENOTTY */
55 55 26, /* 26: ETXTBSY --> 26: ETXTBSY */
56 56 27, /* 27: EFBIG --> 27: EFBIG */
57 57 28, /* 28: ENOSPC --> 28: ENOSPC */
58 58 29, /* 29: ESPIPE --> 29: ESPIPE */
59 59 30, /* 30: EROFS --> 30: EROFS */
60 60 31, /* 31: EMLINK --> 31: EMLINK */
61 61 32, /* 32: EPIPE --> 32: EPIPE */
62 62 33, /* 33: EDOM --> 33: EDOM */
63 63 34, /* 34: ERANGE --> 34: ERANGE */
64 64 42, /* 35: ENOMSG --> 42: ENOMSG */
65 65 43, /* 36: EIDRM --> 43: EIDRM */
66 66 44, /* 37: ECHRNG --> 44: ECHRNG */
67 67 45, /* 38: EL2NSYNC --> 45: EL2NSYNC */
68 68 46, /* 39: EL3HLT --> 46: EL3HLT */
69 69 47, /* 40: EL3RST --> 47: EL3RST */
70 70 48, /* 41: ELNRNG --> 48: ELNRNG */
71 71 49, /* 42: EUNATCH --> 49: EUNATCH */
72 72 50, /* 43: ENOCSI --> 50: ENOCSI */
73 73 51, /* 44: EL2HLT --> 51: EL2HLT */
74 74 35, /* 45: EDEADLK --> 35: EDEADLK */
75 75 37, /* 46: ENOLCK --> 37: ENOLCK */
76 76 125, /* 47: ECANCELED --> 125: ECANCELED */
77 77 38, /* 48: ENOTSUP --> 38: ENOSYS */
78 78 122, /* 49: EDQUOT --> 122: EDQUOT */
79 79 52, /* 50: EBADE --> 52: EBADE */
80 80 53, /* 51: EBADR --> 53: EBADR */
81 81 54, /* 52: EXFULL --> 54: EXFULL */
82 82 55, /* 53: ENOANO --> 55: ENOANO */
83 83 56, /* 54: EBADRQC --> 56: EBADRQC */
84 84 57, /* 55: EBADSLT --> 57: EBADSLT */
85 85 35, /* 56: EDEADLOCK --> 35: EDEADLK */
86 86 59, /* 57: EBFONT --> 59: EBFONT */
87 87 130, /* 58: EOWNERDEAD --> 130: EOWNERDEAD */
88 88 131, /* 59: ENOTRECOVERABLE --> 131: ENOTRECOVERABLE */
89 89 60, /* 60: ENOSTR --> 60: ENOSTR */
90 90 61, /* 61: ENODATA --> 61: ENODATA */
91 91 62, /* 62: ETIME --> 62: ETIME */
92 92 63, /* 63: ENOSR --> 63: ENOSR */
93 93 64, /* 64: ENONET --> 64: ENONET */
94 94 65, /* 65: ENOPKG --> 65: ENOPKG */
95 95 66, /* 66: EREMOTE --> 66: EREMOTE */
96 96 67, /* 67: ENOLINK --> 67: ENOLINK */
97 97 68, /* 68: EADV --> 68: EADV */
98 98 69, /* 69: ESRMNT --> 69: ESRMNT */
99 99 70, /* 70: ECOMM --> 70: ECOMM */
100 100 71, /* 71: EPROTO --> 71: EPROTO */
101 101 -2, /* 72: ELOCKUNMAPPED --> -2: No Analogue */
102 102 -2, /* 73: ENOTACTIVE --> -2: No Analogue */
103 103 72, /* 74: EMULTIHOP --> 72: EMULTIHOP */
104 104 -1, /* 75: Unused Number */
105 105 -1, /* 76: Unused Number */
106 106 74, /* 77: EBADMSG --> 74: EBADMSG */
107 107 36, /* 78: ENAMETOOLONG --> 36: ENAMETOOLONG */
108 108 75, /* 79: EOVERFLOW --> 75: EOVERFLOW */
109 109 76, /* 80: ENOTUNIQ --> 76: ENOTUNIQ */
110 110 77, /* 81: EBADFD --> 77: EBADFD */
111 111 78, /* 82: EREMCHG --> 78: EREMCHG */
112 112 79, /* 83: ELIBACC --> 79: ELIBACC */
113 113 80, /* 84: ELIBBAD --> 80: ELIBBAD */
114 114 81, /* 85: ELIBSCN --> 81: ELIBSCN */
115 115 82, /* 86: ELIBMAX --> 82: ELIBMAX */
116 116 83, /* 87: ELIBEXEC --> 83: ELIBEXEC */
117 117 84, /* 88: EILSEQ --> 84: EILSEQ */
118 118 38, /* 89: ENOSYS --> 38: ENOSYS */
119 119 40, /* 90: ELOOP --> 40: ELOOP */
120 120 85, /* 91: ERESTART --> 85: ERESTART */
121 121 86, /* 92: ESTRPIPE --> 86: ESTRPIPE */
122 122 39, /* 93: ENOTEMPTY --> 39: ENOTEMPTY */
123 123 87, /* 94: EUSERS --> 87: EUSERS */
124 124 88, /* 95: ENOTSOCK --> 88: ENOTSOCK */
125 125 89, /* 96: EDESTADDRREQ --> 89: EDESTADDRREQ */
126 126 90, /* 97: EMSGSIZE --> 90: EMSGSIZE */
127 127 91, /* 98: EPROTOTYPE --> 91: EPROTOTYPE */
128 128 92, /* 99: ENOPROTOOPT --> 92: ENOPROTOOPT */
129 129 -1, /* 100: Unused Number */
130 130 -1, /* 101: Unused Number */
131 131 -1, /* 102: Unused Number */
132 132 -1, /* 103: Unused Number */
133 133 -1, /* 104: Unused Number */
134 134 -1, /* 105: Unused Number */
135 135 -1, /* 106: Unused Number */
136 136 -1, /* 107: Unused Number */
137 137 -1, /* 108: Unused Number */
138 138 -1, /* 109: Unused Number */
139 139 -1, /* 110: Unused Number */
140 140 -1, /* 111: Unused Number */
141 141 -1, /* 112: Unused Number */
142 142 -1, /* 113: Unused Number */
143 143 -1, /* 114: Unused Number */
144 144 -1, /* 115: Unused Number */
145 145 -1, /* 116: Unused Number */
146 146 -1, /* 117: Unused Number */
147 147 -1, /* 118: Unused Number */
148 148 -1, /* 119: Unused Number */
149 149 93, /* 120: EPROTONOSUPPORT --> 93: EPROTONOSUPPORT */
150 150 94, /* 121: ESOCKTNOSUPPORT --> 94: ESOCKTNOSUPPORT */
151 151 95, /* 122: EOPNOTSUPP --> 95: EOPNOTSUPP */
152 152 96, /* 123: EPFNOSUPPORT --> 96: EPFNOSUPPORT */
153 153 97, /* 124: EAFNOSUPPORT --> 97: EAFNOSUPPORT */
154 154 98, /* 125: EADDRINUSE --> 98: EADDRINUSE */
155 155 99, /* 126: EADDRNOTAVAIL --> 99: EADDRNOTAVAIL */
156 156 100, /* 127: ENETDOWN --> 100: ENETDOWN */
157 157 101, /* 128: ENETUNREACH --> 101: ENETUNREACH */
158 158 102, /* 129: ENETRESET --> 102: ENETRESET */
159 159 103, /* 130: ECONNABORTED --> 103: ECONNABORTED */
160 160 104, /* 131: ECONNRESET --> 104: ECONNRESET */
161 161 105, /* 132: ENOBUFS --> 105: ENOBUFS */
162 162 106, /* 133: EISCONN --> 106: EISCONN */
163 163 107, /* 134: ENOTCONN --> 107: ENOTCONN */
164 164 -1, /* 135: Unused Number */
165 165 -1, /* 136: Unused Number */
166 166 -1, /* 137: Unused Number */
167 167 -1, /* 138: Unused Number */
168 168 -1, /* 139: Unused Number */
169 169 -1, /* 140: Unused Number */
170 170 -1, /* 141: Unused Number */
171 171 -1, /* 142: Unused Number */
172 172 108, /* 143: ESHUTDOWN --> 108: ESHUTDOWN */
173 173 109, /* 144: ETOOMANYREFS --> 109: ETOOMANYREFS */
174 174 110, /* 145: ETIMEDOUT --> 110: ETIMEDOUT */
175 175 111, /* 146: ECONNREFUSED --> 111: ECONNREFUSED */
176 176 112, /* 147: EHOSTDOWN --> 112: EHOSTDOWN */
177 177 113, /* 148: EHOSTUNREACH --> 113: EHOSTUNREACH */
178 178 114, /* 149: EALREADY --> 114: EALREADY */
179 179 115, /* 150: EINPROGRESS --> 115: EINPROGRESS */
180 180 116 /* 151: ESTALE --> 116: ESTALE */
181 181 };
182 182
183 183 /*
184 184 * Convert an illumos native error number to a Linux error number and return
185 185 * it. If no valid conversion is possible, the function fails back to the
186 186 * value of "defval". In userland, passing a default error number of "-1"
187 187 * will abort the program if the error number could not be converted.
188 188 */
189 189 int
190 190 lx_errno(int native_errno, int defval)
191 191 {
192 192 #ifdef _KERNEL
193 193 VERIFY3S(defval, >=, 0);
194 194 #endif
195 195
196 196 if (native_errno < 0 || native_errno >= (sizeof (lx_stol_errno) /
197 197 sizeof (lx_stol_errno[0]))) {
198 198 #ifndef _KERNEL
199 199 VERIFY3S(defval, >=, 0);
200 200 #endif
201 201
202 202 return (defval);
203 203 }
204 204
205 205 return (lx_stol_errno[native_errno]);
206 206 }
|
↓ open down ↓ |
206 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX