Deleted Added
full compact
bsm_errno.c (186647) bsm_errno.c (187214)
1/*-
2 * Copyright (c) 2008 Apple Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 2008 Apple Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_errno.c#12 $
29 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_errno.c#16 $
30 */
31
32#include <sys/types.h>
33
34#include <config/config.h>
35
36#include <bsm/audit_errno.h>
37#include <bsm/libbsm.h>
38
39#include <errno.h>
40#include <string.h>
41
42/*
43 * Different operating systems use different numeric constants for different
44 * error numbers, and sometimes error numbers don't exist in more than one
45 * operating system. These routines convert between BSM and local error
46 * number spaces, subject to the above realities. BSM error numbers are
47 * stored in a single 8-bit character, so don't have a byte order.
30 */
31
32#include <sys/types.h>
33
34#include <config/config.h>
35
36#include <bsm/audit_errno.h>
37#include <bsm/libbsm.h>
38
39#include <errno.h>
40#include <string.h>
41
42/*
43 * Different operating systems use different numeric constants for different
44 * error numbers, and sometimes error numbers don't exist in more than one
45 * operating system. These routines convert between BSM and local error
46 * number spaces, subject to the above realities. BSM error numbers are
47 * stored in a single 8-bit character, so don't have a byte order.
48 *
49 * Don't include string definitions when this code is compiled into a kernel.
48 */
50 */
49
50struct bsm_errors {
51 int be_bsm_error;
52 int be_os_error;
51struct bsm_errno {
52 int be_bsm_errno;
53 int be_local_errno;
54#if !defined(KERNEL) && !defined(_KERNEL)
53 const char *be_strerror;
55 const char *be_strerror;
56#endif
54};
55
56#define ERRNO_NO_LOCAL_MAPPING -600
57
57};
58
59#define ERRNO_NO_LOCAL_MAPPING -600
60
61#if !defined(KERNEL) && !defined(_KERNEL)
62#define ES(x) x
63#else
64#define ES(x)
65#endif
66
58/*
59 * Mapping table -- please maintain in numeric sorted order with respect to
60 * the BSM constant. Today we do a linear lookup, but could switch to a
61 * binary search if it makes sense. We only ifdef errors that aren't
62 * generally available, but it does make the table a lot more ugly.
63 *
64 * XXXRW: It would be nice to have a similar ordered table mapping to BSM
65 * constant from local constant, but the order of local constants varies by
66 * OS. Really we need to build that table at compile-time but don't do that
67 * yet.
68 *
69 * XXXRW: We currently embed English-language error strings here, but should
70 * support catalogues; these are only used if the OS doesn't have an error
71 * string using strerror(3).
72 */
67/*
68 * Mapping table -- please maintain in numeric sorted order with respect to
69 * the BSM constant. Today we do a linear lookup, but could switch to a
70 * binary search if it makes sense. We only ifdef errors that aren't
71 * generally available, but it does make the table a lot more ugly.
72 *
73 * XXXRW: It would be nice to have a similar ordered table mapping to BSM
74 * constant from local constant, but the order of local constants varies by
75 * OS. Really we need to build that table at compile-time but don't do that
76 * yet.
77 *
78 * XXXRW: We currently embed English-language error strings here, but should
79 * support catalogues; these are only used if the OS doesn't have an error
80 * string using strerror(3).
81 */
73static const struct bsm_errors bsm_errors[] = {
74 { BSM_ESUCCESS, 0, "Success" },
75 { BSM_EPERM, EPERM, "Operation not permitted" },
76 { BSM_ENOENT, ENOENT, "No such file or directory" },
77 { BSM_ESRCH, ESRCH, "No such process" },
78 { BSM_EINTR, EINTR, "Interrupted system call" },
79 { BSM_EIO, EIO, "Input/output error" },
80 { BSM_ENXIO, ENXIO, "Device not configured" },
81 { BSM_E2BIG, E2BIG, "Argument list too long" },
82 { BSM_ENOEXEC, ENOEXEC, "Exec format error" },
83 { BSM_EBADF, EBADF, "BAd file descriptor" },
84 { BSM_ECHILD, ECHILD, "No child processes" },
85 { BSM_EAGAIN, EAGAIN, "Resource temporarily unavailable" },
86 { BSM_ENOMEM, ENOMEM, "Cannot allocate memory" },
87 { BSM_EACCES, EACCES, "Permission denied" },
88 { BSM_EFAULT, EFAULT, "Bad address" },
89 { BSM_ENOTBLK, ENOTBLK, "Block device required" },
90 { BSM_EBUSY, EBUSY, "Device busy" },
91 { BSM_EEXIST, EEXIST, "File exists" },
92 { BSM_EXDEV, EXDEV, "Cross-device link" },
93 { BSM_ENODEV, ENODEV, "Operation not supported by device" },
94 { BSM_ENOTDIR, ENOTDIR, "Not a directory" },
95 { BSM_EISDIR, EISDIR, "Is a directory" },
96 { BSM_EINVAL, EINVAL, "Invalid argument" },
97 { BSM_ENFILE, ENFILE, "Too many open files in system" },
98 { BSM_EMFILE, EMFILE, "Too many open files" },
99 { BSM_ENOTTY, ENOTTY, "Inappropriate ioctl for device" },
100 { BSM_ETXTBSY, ETXTBSY, "Text file busy" },
101 { BSM_EFBIG, EFBIG, "File too large" },
102 { BSM_ENOSPC, ENOSPC, "No space left on device" },
103 { BSM_ESPIPE, ESPIPE, "Illegal seek" },
104 { BSM_EROFS, EROFS, "Read-only file system" },
105 { BSM_EMLINK, EMLINK, "Too many links" },
106 { BSM_EPIPE, EPIPE, "Broken pipe" },
107 { BSM_EDOM, EDOM, "Numerical argument out of domain" },
108 { BSM_ERANGE, ERANGE, "Result too large" },
109 { BSM_ENOMSG, ENOMSG, "No message of desired type" },
110 { BSM_EIDRM, EIDRM, "Identifier removed" },
111 { BSM_ECHRNG,
82static const struct bsm_errno bsm_errnos[] = {
83 { BSM_ERRNO_ESUCCESS, 0, ES("Success") },
84 { BSM_ERRNO_EPERM, EPERM, ES("Operation not permitted") },
85 { BSM_ERRNO_ENOENT, ENOENT, ES("No such file or directory") },
86 { BSM_ERRNO_ESRCH, ESRCH, ES("No such process") },
87 { BSM_ERRNO_EINTR, EINTR, ES("Interrupted system call") },
88 { BSM_ERRNO_EIO, EIO, ES("Input/output error") },
89 { BSM_ERRNO_ENXIO, ENXIO, ES("Device not configured") },
90 { BSM_ERRNO_E2BIG, E2BIG, ES("Argument list too long") },
91 { BSM_ERRNO_ENOEXEC, ENOEXEC, ES("Exec format error") },
92 { BSM_ERRNO_EBADF, EBADF, ES("Bad file descriptor") },
93 { BSM_ERRNO_ECHILD, ECHILD, ES("No child processes") },
94 { BSM_ERRNO_EAGAIN, EAGAIN, ES("Resource temporarily unavailable") },
95 { BSM_ERRNO_ENOMEM, ENOMEM, ES("Cannot allocate memory") },
96 { BSM_ERRNO_EACCES, EACCES, ES("Permission denied") },
97 { BSM_ERRNO_EFAULT, EFAULT, ES("Bad address") },
98 { BSM_ERRNO_ENOTBLK, ENOTBLK, ES("Block device required") },
99 { BSM_ERRNO_EBUSY, EBUSY, ES("Device busy") },
100 { BSM_ERRNO_EEXIST, EEXIST, ES("File exists") },
101 { BSM_ERRNO_EXDEV, EXDEV, ES("Cross-device link") },
102 { BSM_ERRNO_ENODEV, ENODEV, ES("Operation not supported by device") },
103 { BSM_ERRNO_ENOTDIR, ENOTDIR, ES("Not a directory") },
104 { BSM_ERRNO_EISDIR, EISDIR, ES("Is a directory") },
105 { BSM_ERRNO_EINVAL, EINVAL, ES("Invalid argument") },
106 { BSM_ERRNO_ENFILE, ENFILE, ES("Too many open files in system") },
107 { BSM_ERRNO_EMFILE, EMFILE, ES("Too many open files") },
108 { BSM_ERRNO_ENOTTY, ENOTTY, ES("Inappropriate ioctl for device") },
109 { BSM_ERRNO_ETXTBSY, ETXTBSY, ES("Text file busy") },
110 { BSM_ERRNO_EFBIG, EFBIG, ES("File too large") },
111 { BSM_ERRNO_ENOSPC, ENOSPC, ES("No space left on device") },
112 { BSM_ERRNO_ESPIPE, ESPIPE, ES("Illegal seek") },
113 { BSM_ERRNO_EROFS, EROFS, ES("Read-only file system") },
114 { BSM_ERRNO_EMLINK, EMLINK, ES("Too many links") },
115 { BSM_ERRNO_EPIPE, EPIPE, ES("Broken pipe") },
116 { BSM_ERRNO_EDOM, EDOM, ES("Numerical argument out of domain") },
117 { BSM_ERRNO_ERANGE, ERANGE, ES("Result too large") },
118 { BSM_ERRNO_ENOMSG, ENOMSG, ES("No message of desired type") },
119 { BSM_ERRNO_EIDRM, EIDRM, ES("Identifier removed") },
120 { BSM_ERRNO_ECHRNG,
112#ifdef ECHRNG
113 ECHRNG,
114#else
115 ERRNO_NO_LOCAL_MAPPING,
116#endif
121#ifdef ECHRNG
122 ECHRNG,
123#else
124 ERRNO_NO_LOCAL_MAPPING,
125#endif
117 "Channel number out of range" },
118 { BSM_EL2NSYNC,
126 ES("Channel number out of range") },
127 { BSM_ERRNO_EL2NSYNC,
119#ifdef EL2NSYNC
120 EL2NSYNC,
121#else
122 ERRNO_NO_LOCAL_MAPPING,
123#endif
128#ifdef EL2NSYNC
129 EL2NSYNC,
130#else
131 ERRNO_NO_LOCAL_MAPPING,
132#endif
124 "Level 2 not synchronized" },
125 { BSM_EL3HLT,
133 ES("Level 2 not synchronized") },
134 { BSM_ERRNO_EL3HLT,
126#ifdef EL3HLT
127 EL3HLT,
128#else
129 ERRNO_NO_LOCAL_MAPPING,
130#endif
135#ifdef EL3HLT
136 EL3HLT,
137#else
138 ERRNO_NO_LOCAL_MAPPING,
139#endif
131 "Level 3 halted" },
132 { BSM_EL3RST,
140 ES("Level 3 halted") },
141 { BSM_ERRNO_EL3RST,
133#ifdef EL3RST
134 EL3RST,
135#else
136 ERRNO_NO_LOCAL_MAPPING,
137#endif
142#ifdef EL3RST
143 EL3RST,
144#else
145 ERRNO_NO_LOCAL_MAPPING,
146#endif
138 "Level 3 reset" },
139 { BSM_ELNRNG,
147 ES("Level 3 reset") },
148 { BSM_ERRNO_ELNRNG,
140#ifdef ELNRNG
141 ELNRNG,
142#else
143 ERRNO_NO_LOCAL_MAPPING,
144#endif
149#ifdef ELNRNG
150 ELNRNG,
151#else
152 ERRNO_NO_LOCAL_MAPPING,
153#endif
145 "Link number out of range" },
146 { BSM_EUNATCH,
154 ES("Link number out of range") },
155 { BSM_ERRNO_EUNATCH,
147#ifdef EUNATCH
148 EUNATCH,
149#else
150 ERRNO_NO_LOCAL_MAPPING,
151#endif
156#ifdef EUNATCH
157 EUNATCH,
158#else
159 ERRNO_NO_LOCAL_MAPPING,
160#endif
152 "Protocol driver not attached" },
153 { BSM_ENOCSI,
161 ES("Protocol driver not attached") },
162 { BSM_ERRNO_ENOCSI,
154#ifdef ENOCSI
155 ENOCSI,
156#else
157 ERRNO_NO_LOCAL_MAPPING,
158#endif
163#ifdef ENOCSI
164 ENOCSI,
165#else
166 ERRNO_NO_LOCAL_MAPPING,
167#endif
159 "No CSI structure available" },
160 { BSM_EL2HLT,
168 ES("No CSI structure available") },
169 { BSM_ERRNO_EL2HLT,
161#ifdef EL2HLT
162 EL2HLT,
163#else
164 ERRNO_NO_LOCAL_MAPPING,
165#endif
170#ifdef EL2HLT
171 EL2HLT,
172#else
173 ERRNO_NO_LOCAL_MAPPING,
174#endif
166 "Level 2 halted" },
167 { BSM_EDEADLK, EDEADLK, "Resource deadlock avoided" },
168 { BSM_ENOLCK, ENOLCK, "No locks available" },
169 { BSM_ECANCELED, ECANCELED, "Operation canceled" },
170 { BSM_ENOTSUP, ENOTSUP, "Operation not supported" },
171 { BSM_EDQUOT, EDQUOT, "Disc quota exceeded" },
172 { BSM_EBADE,
175 ES("Level 2 halted") },
176 { BSM_ERRNO_EDEADLK, EDEADLK, ES("Resource deadlock avoided") },
177 { BSM_ERRNO_ENOLCK, ENOLCK, ES("No locks available") },
178 { BSM_ERRNO_ECANCELED, ECANCELED, ES("Operation canceled") },
179 { BSM_ERRNO_ENOTSUP, ENOTSUP, ES("Operation not supported") },
180 { BSM_ERRNO_EDQUOT, EDQUOT, ES("Disc quota exceeded") },
181 { BSM_ERRNO_EBADE,
173#ifdef EBADE
174 EBADE,
175#else
176 ERRNO_NO_LOCAL_MAPPING,
177#endif
182#ifdef EBADE
183 EBADE,
184#else
185 ERRNO_NO_LOCAL_MAPPING,
186#endif
178 "Invalid exchange" },
179 { BSM_EBADR,
187 ES("Invalid exchange") },
188 { BSM_ERRNO_EBADR,
180#ifdef EBADR
181 EBADR,
182#else
183 ERRNO_NO_LOCAL_MAPPING,
184#endif
189#ifdef EBADR
190 EBADR,
191#else
192 ERRNO_NO_LOCAL_MAPPING,
193#endif
185 "Invalid request descriptor" },
186 { BSM_EXFULL,
194 ES("Invalid request descriptor") },
195 { BSM_ERRNO_EXFULL,
187#ifdef EXFULL
188 EXFULL,
189#else
190 ERRNO_NO_LOCAL_MAPPING,
191#endif
196#ifdef EXFULL
197 EXFULL,
198#else
199 ERRNO_NO_LOCAL_MAPPING,
200#endif
192 "Exchange full" },
193 { BSM_ENOANO,
201 ES("Exchange full") },
202 { BSM_ERRNO_ENOANO,
194#ifdef ENOANO
195 ENOANO,
196#else
197 ERRNO_NO_LOCAL_MAPPING,
198#endif
203#ifdef ENOANO
204 ENOANO,
205#else
206 ERRNO_NO_LOCAL_MAPPING,
207#endif
199 "No anode" },
200 { BSM_EBADRQC,
208 ES("No anode") },
209 { BSM_ERRNO_EBADRQC,
201#ifdef EBADRQC
202 EBADRQC,
203#else
204 ERRNO_NO_LOCAL_MAPPING,
205#endif
210#ifdef EBADRQC
211 EBADRQC,
212#else
213 ERRNO_NO_LOCAL_MAPPING,
214#endif
206 "Invalid request descriptor" },
207 { BSM_EBADSLT,
215 ES("Invalid request descriptor") },
216 { BSM_ERRNO_EBADSLT,
208#ifdef EBADSLT
209 EBADSLT,
210#else
211 ERRNO_NO_LOCAL_MAPPING,
212#endif
217#ifdef EBADSLT
218 EBADSLT,
219#else
220 ERRNO_NO_LOCAL_MAPPING,
221#endif
213 "Invalid slot" },
214 { BSM_EDEADLOCK,
222 ES("Invalid slot") },
223 { BSM_ERRNO_EDEADLOCK,
215#ifdef EDEADLOCK
216 EDEADLOCK,
217#else
218 ERRNO_NO_LOCAL_MAPPING,
219#endif
224#ifdef EDEADLOCK
225 EDEADLOCK,
226#else
227 ERRNO_NO_LOCAL_MAPPING,
228#endif
220 "Resource deadlock avoided" },
221 { BSM_EBFONT,
229 ES("Resource deadlock avoided") },
230 { BSM_ERRNO_EBFONT,
222#ifdef EBFONT
223 EBFONT,
224#else
225 ERRNO_NO_LOCAL_MAPPING,
226#endif
231#ifdef EBFONT
232 EBFONT,
233#else
234 ERRNO_NO_LOCAL_MAPPING,
235#endif
227 "Bad font file format" },
228 { BSM_EOWNERDEAD,
236 ES("Bad font file format") },
237 { BSM_ERRNO_EOWNERDEAD,
229#ifdef EOWNERDEAD
230 EOWNERDEAD,
231#else
232 ERRNO_NO_LOCAL_MAPPING,
233#endif
238#ifdef EOWNERDEAD
239 EOWNERDEAD,
240#else
241 ERRNO_NO_LOCAL_MAPPING,
242#endif
234 "Process died with the lock" },
235 { BSM_ENOTRECOVERABLE,
243 ES("Process died with the lock") },
244 { BSM_ERRNO_ENOTRECOVERABLE,
236#ifdef ENOTRECOVERABLE
237 ENOTRECOVERABLE,
238#else
239 ERRNO_NO_LOCAL_MAPPING,
240#endif
245#ifdef ENOTRECOVERABLE
246 ENOTRECOVERABLE,
247#else
248 ERRNO_NO_LOCAL_MAPPING,
249#endif
241 "Lock is not recoverable" },
242 { BSM_ENOSTR,
250 ES("Lock is not recoverable") },
251 { BSM_ERRNO_ENOSTR,
243#ifdef ENOSTR
244 ENOSTR,
245#else
246 ERRNO_NO_LOCAL_MAPPING,
247#endif
252#ifdef ENOSTR
253 ENOSTR,
254#else
255 ERRNO_NO_LOCAL_MAPPING,
256#endif
248 "Device not a stream" },
249 { BSM_ENONET,
257 ES("Device not a stream") },
258 { BSM_ERRNO_ENONET,
250#ifdef ENONET
251 ENONET,
252#else
253 ERRNO_NO_LOCAL_MAPPING,
254#endif
259#ifdef ENONET
260 ENONET,
261#else
262 ERRNO_NO_LOCAL_MAPPING,
263#endif
255 "Machine is not on the network" },
256 { BSM_ENOPKG,
264 ES("Machine is not on the network") },
265 { BSM_ERRNO_ENOPKG,
257#ifdef ENOPKG
258 ENOPKG,
259#else
260 ERRNO_NO_LOCAL_MAPPING,
261#endif
266#ifdef ENOPKG
267 ENOPKG,
268#else
269 ERRNO_NO_LOCAL_MAPPING,
270#endif
262 "Package not installed" },
263 { BSM_EREMOTE, EREMOTE, "Too many levels of remote in path" },
264 { BSM_ENOLINK,
271 ES("Package not installed") },
272 { BSM_ERRNO_EREMOTE, EREMOTE,
273 ES("Too many levels of remote in path") },
274 { BSM_ERRNO_ENOLINK,
265#ifdef ENOLINK
266 ENOLINK,
267#else
268 ERRNO_NO_LOCAL_MAPPING,
269#endif
275#ifdef ENOLINK
276 ENOLINK,
277#else
278 ERRNO_NO_LOCAL_MAPPING,
279#endif
270 "Link has been severed" },
271 { BSM_EADV,
280 ES("Link has been severed") },
281 { BSM_ERRNO_EADV,
272#ifdef EADV
273 EADV,
274#else
275 ERRNO_NO_LOCAL_MAPPING,
276#endif
282#ifdef EADV
283 EADV,
284#else
285 ERRNO_NO_LOCAL_MAPPING,
286#endif
277 "Advertise error" },
278 { BSM_ESRMNT,
287 ES("Advertise error") },
288 { BSM_ERRNO_ESRMNT,
279#ifdef ESRMNT
280 ESRMNT,
281#else
282 ERRNO_NO_LOCAL_MAPPING,
283#endif
289#ifdef ESRMNT
290 ESRMNT,
291#else
292 ERRNO_NO_LOCAL_MAPPING,
293#endif
284 "srmount error" },
285 { BSM_ECOMM,
294 ES("srmount error") },
295 { BSM_ERRNO_ECOMM,
286#ifdef ECOMM
287 ECOMM,
288#else
289 ERRNO_NO_LOCAL_MAPPING,
290#endif
296#ifdef ECOMM
297 ECOMM,
298#else
299 ERRNO_NO_LOCAL_MAPPING,
300#endif
291 "Communication error on send" },
292 { BSM_EPROTO,
301 ES("Communication error on send") },
302 { BSM_ERRNO_EPROTO,
293#ifdef EPROTO
294 EPROTO,
295#else
296 ERRNO_NO_LOCAL_MAPPING,
297#endif
303#ifdef EPROTO
304 EPROTO,
305#else
306 ERRNO_NO_LOCAL_MAPPING,
307#endif
298 "Protocol error" },
299 { BSM_ELOCKUNMAPPED,
308 ES("Protocol error") },
309 { BSM_ERRNO_ELOCKUNMAPPED,
300#ifdef ELOCKUNMAPPED
301 ELOCKUNMAPPED,
302#else
303 ERRNO_NO_LOCAL_MAPPING,
304#endif
310#ifdef ELOCKUNMAPPED
311 ELOCKUNMAPPED,
312#else
313 ERRNO_NO_LOCAL_MAPPING,
314#endif
305 "Locked lock was unmapped" },
306 { BSM_ENOTACTIVE,
315 ES("Locked lock was unmapped") },
316 { BSM_ERRNO_ENOTACTIVE,
307#ifdef ENOTACTIVE
308 ENOTACTIVE,
309#else
310 ERRNO_NO_LOCAL_MAPPING,
311#endif
317#ifdef ENOTACTIVE
318 ENOTACTIVE,
319#else
320 ERRNO_NO_LOCAL_MAPPING,
321#endif
312 "Facility is not active" },
313 { BSM_EMULTIHOP,
322 ES("Facility is not active") },
323 { BSM_ERRNO_EMULTIHOP,
314#ifdef EMULTIHOP
315 EMULTIHOP,
316#else
317 ERRNO_NO_LOCAL_MAPPING,
318#endif
324#ifdef EMULTIHOP
325 EMULTIHOP,
326#else
327 ERRNO_NO_LOCAL_MAPPING,
328#endif
319 "Multihop attempted" },
320 { BSM_EBADMSG,
329 ES("Multihop attempted") },
330 { BSM_ERRNO_EBADMSG,
321#ifdef EBADMSG
322 EBADMSG,
323#else
324 ERRNO_NO_LOCAL_MAPPING,
325#endif
331#ifdef EBADMSG
332 EBADMSG,
333#else
334 ERRNO_NO_LOCAL_MAPPING,
335#endif
326 "Bad message" },
327 { BSM_ENAMETOOLONG, ENAMETOOLONG, "File name too long" },
328 { BSM_EOVERFLOW, EOVERFLOW, "Value too large to be stored in data type" },
329 { BSM_ENOTUNIQ,
336 ES("Bad message") },
337 { BSM_ERRNO_ENAMETOOLONG, ENAMETOOLONG, ES("File name too long") },
338 { BSM_ERRNO_EOVERFLOW, EOVERFLOW,
339 ES("Value too large to be stored in data type") },
340 { BSM_ERRNO_ENOTUNIQ,
330#ifdef ENOTUNIQ
331 ENOTUNIQ,
332#else
333 ERRNO_NO_LOCAL_MAPPING,
334#endif
341#ifdef ENOTUNIQ
342 ENOTUNIQ,
343#else
344 ERRNO_NO_LOCAL_MAPPING,
345#endif
335 "Given log name not unique" },
336 { BSM_EBADFD,
346 ES("Given log name not unique") },
347 { BSM_ERRNO_EBADFD,
337#ifdef EBADFD
338 EBADFD,
339#else
340 ERRNO_NO_LOCAL_MAPPING,
341#endif
348#ifdef EBADFD
349 EBADFD,
350#else
351 ERRNO_NO_LOCAL_MAPPING,
352#endif
342 "Given f.d. invalid for this operation" },
343 { BSM_EREMCHG,
353 ES("Given f.d. invalid for this operation") },
354 { BSM_ERRNO_EREMCHG,
344#ifdef EREMCHG
345 EREMCHG,
346#else
347 ERRNO_NO_LOCAL_MAPPING,
348#endif
355#ifdef EREMCHG
356 EREMCHG,
357#else
358 ERRNO_NO_LOCAL_MAPPING,
359#endif
349 "Remote address changed" },
350 { BSM_ELIBACC,
360 ES("Remote address changed") },
361 { BSM_ERRNO_ELIBACC,
351#ifdef ELIBACC
352 ELIBACC,
353#else
354 ERRNO_NO_LOCAL_MAPPING,
355#endif
362#ifdef ELIBACC
363 ELIBACC,
364#else
365 ERRNO_NO_LOCAL_MAPPING,
366#endif
356 "Can't access a needed shared lib" },
357 { BSM_ELIBBAD,
367 ES("Can't access a needed shared lib") },
368 { BSM_ERRNO_ELIBBAD,
358#ifdef ELIBBAD
359 ELIBBAD,
360#else
361 ERRNO_NO_LOCAL_MAPPING,
362#endif
369#ifdef ELIBBAD
370 ELIBBAD,
371#else
372 ERRNO_NO_LOCAL_MAPPING,
373#endif
363 "Accessing a corrupted shared lib" },
364 { BSM_ELIBSCN,
374 ES("Accessing a corrupted shared lib") },
375 { BSM_ERRNO_ELIBSCN,
365#ifdef ELIBSCN
366 ELIBSCN,
367#else
368 ERRNO_NO_LOCAL_MAPPING,
369#endif
376#ifdef ELIBSCN
377 ELIBSCN,
378#else
379 ERRNO_NO_LOCAL_MAPPING,
380#endif
370 ".lib section in a.out corrupted" },
371 { BSM_ELIBMAX,
381 ES(".lib section in a.out corrupted") },
382 { BSM_ERRNO_ELIBMAX,
372#ifdef ELIBMAX
373 ELIBMAX,
374#else
375 ERRNO_NO_LOCAL_MAPPING,
376#endif
383#ifdef ELIBMAX
384 ELIBMAX,
385#else
386 ERRNO_NO_LOCAL_MAPPING,
387#endif
377 "Attempting to link in too many libs" },
378 { BSM_ELIBEXEC,
388 ES("Attempting to link in too many libs") },
389 { BSM_ERRNO_ELIBEXEC,
379#ifdef ELIBEXEC
380 ELIBEXEC,
381#else
382 ERRNO_NO_LOCAL_MAPPING,
383#endif
390#ifdef ELIBEXEC
391 ELIBEXEC,
392#else
393 ERRNO_NO_LOCAL_MAPPING,
394#endif
384 "Attempting to exec a shared library" },
385 { BSM_EILSEQ, EILSEQ, "Illegal byte sequence" },
386 { BSM_ENOSYS, ENOSYS, "Function not implemented" },
387 { BSM_ELOOP, ELOOP, "Too many levels of symbolic links" },
388 { BSM_ERESTART,
395 ES("Attempting to exec a shared library") },
396 { BSM_ERRNO_EILSEQ, EILSEQ, ES("Illegal byte sequence") },
397 { BSM_ERRNO_ENOSYS, ENOSYS, ES("Function not implemented") },
398 { BSM_ERRNO_ELOOP, ELOOP, ES("Too many levels of symbolic links") },
399 { BSM_ERRNO_ERESTART,
389#ifdef ERESTART
390 ERESTART,
391#else
392 ERRNO_NO_LOCAL_MAPPING,
393#endif
400#ifdef ERESTART
401 ERESTART,
402#else
403 ERRNO_NO_LOCAL_MAPPING,
404#endif
394 "Restart syscall" },
395 { BSM_ESTRPIPE,
405 ES("Restart syscall") },
406 { BSM_ERRNO_ESTRPIPE,
396#ifdef ESTRPIPE
397 ESTRPIPE,
398#else
399 ERRNO_NO_LOCAL_MAPPING,
400#endif
407#ifdef ESTRPIPE
408 ESTRPIPE,
409#else
410 ERRNO_NO_LOCAL_MAPPING,
411#endif
401 "If pipe/FIFO, don't sleep in stream head" },
402 { BSM_ENOTEMPTY, ENOTEMPTY, "Directory not empty" },
403 { BSM_EUSERS, EUSERS, "Too many users" },
404 { BSM_ENOTSOCK, ENOTSOCK, "Socket operation on non-socket" },
405 { BSM_EDESTADDRREQ, EDESTADDRREQ, "Destination address required" },
406 { BSM_EMSGSIZE, EMSGSIZE, "Message too long" },
407 { BSM_EPROTOTYPE, EPROTOTYPE, "Protocol wrong type for socket" },
408 { BSM_ENOPROTOOPT, ENOPROTOOPT, "Protocol not available" },
409 { BSM_EPROTONOSUPPORT, EPROTONOSUPPORT, "Protocol not supported" },
410 { BSM_ESOCKTNOSUPPORT, ESOCKTNOSUPPORT, "Socket type not supported" },
411 { BSM_EOPNOTSUPP, EOPNOTSUPP, "Operation not supported" },
412 { BSM_EPFNOSUPPORT, EPFNOSUPPORT, "Protocol family not supported" },
413 { BSM_EAFNOSUPPORT, EAFNOSUPPORT, "Address family not supported by protocol family" },
414 { BSM_EADDRINUSE, EADDRINUSE, "Address already in use" },
415 { BSM_EADDRNOTAVAIL, EADDRNOTAVAIL, "Can't assign requested address" },
416 { BSM_ENETDOWN, ENETDOWN, "Network is down" },
417 { BSM_ENETRESET, ENETRESET, "Network dropped connection on reset" },
418 { BSM_ECONNABORTED, ECONNABORTED, "Software caused connection abort" },
419 { BSM_ECONNRESET, ECONNRESET, "Connection reset by peer" },
420 { BSM_ENOBUFS, ENOBUFS, "No buffer space available" },
421 { BSM_EISCONN, EISCONN, "Socket is already connected" },
422 { BSM_ENOTCONN, ENOTCONN, "Socket is not connected" },
423 { BSM_ESHUTDOWN, ESHUTDOWN, "Can't send after socket shutdown" },
424 { BSM_ETOOMANYREFS, ETOOMANYREFS, "Too many references: can't splice" },
425 { BSM_ETIMEDOUT, ETIMEDOUT, "Operation timed out" },
426 { BSM_ECONNREFUSED, ECONNREFUSED, "Connection refused" },
427 { BSM_EHOSTDOWN, EHOSTDOWN, "Host is down" },
428 { BSM_EHOSTUNREACH, EHOSTUNREACH, "No route to host" },
429 { BSM_EALREADY, EALREADY, "Operation already in progress" },
430 { BSM_EINPROGRESS, EINPROGRESS, "Operation now in progress" },
431 { BSM_ESTALE, ESTALE, "Stale NFS file handle" },
432 { BSM_EPWROFF,
412 ES("If pipe/FIFO, don't sleep in stream head") },
413 { BSM_ERRNO_ENOTEMPTY, ENOTEMPTY, ES("Directory not empty") },
414 { BSM_ERRNO_EUSERS, EUSERS, ES("Too many users") },
415 { BSM_ERRNO_ENOTSOCK, ENOTSOCK,
416 ES("Socket operation on non-socket") },
417 { BSM_ERRNO_EDESTADDRREQ, EDESTADDRREQ,
418 ES("Destination address required") },
419 { BSM_ERRNO_EMSGSIZE, EMSGSIZE, ES("Message too long") },
420 { BSM_ERRNO_EPROTOTYPE, EPROTOTYPE,
421 ES("Protocol wrong type for socket") },
422 { BSM_ERRNO_ENOPROTOOPT, ENOPROTOOPT, ES("Protocol not available") },
423 { BSM_ERRNO_EPROTONOSUPPORT, EPROTONOSUPPORT,
424 ES("Protocol not supported") },
425 { BSM_ERRNO_ESOCKTNOSUPPORT, ESOCKTNOSUPPORT,
426 ES("Socket type not supported") },
427 { BSM_ERRNO_EOPNOTSUPP, EOPNOTSUPP, ES("Operation not supported") },
428 { BSM_ERRNO_EPFNOSUPPORT, EPFNOSUPPORT,
429 ES("Protocol family not supported") },
430 { BSM_ERRNO_EAFNOSUPPORT, EAFNOSUPPORT,
431 ES("Address family not supported by protocol family") },
432 { BSM_ERRNO_EADDRINUSE, EADDRINUSE, ES("Address already in use") },
433 { BSM_ERRNO_EADDRNOTAVAIL, EADDRNOTAVAIL,
434 ES("Can't assign requested address") },
435 { BSM_ERRNO_ENETDOWN, ENETDOWN, ES("Network is down") },
436 { BSM_ERRNO_ENETRESET, ENETRESET,
437 ES("Network dropped connection on reset") },
438 { BSM_ERRNO_ECONNABORTED, ECONNABORTED,
439 ES("Software caused connection abort") },
440 { BSM_ERRNO_ECONNRESET, ECONNRESET, ES("Connection reset by peer") },
441 { BSM_ERRNO_ENOBUFS, ENOBUFS, ES("No buffer space available") },
442 { BSM_ERRNO_EISCONN, EISCONN, ES("Socket is already connected") },
443 { BSM_ERRNO_ENOTCONN, ENOTCONN, ES("Socket is not connected") },
444 { BSM_ERRNO_ESHUTDOWN, ESHUTDOWN,
445 ES("Can't send after socket shutdown") },
446 { BSM_ERRNO_ETOOMANYREFS, ETOOMANYREFS,
447 ES("Too many references: can't splice") },
448 { BSM_ERRNO_ETIMEDOUT, ETIMEDOUT, ES("Operation timed out") },
449 { BSM_ERRNO_ECONNREFUSED, ECONNREFUSED, ES("Connection refused") },
450 { BSM_ERRNO_EHOSTDOWN, EHOSTDOWN, ES("Host is down") },
451 { BSM_ERRNO_EHOSTUNREACH, EHOSTUNREACH, ES("No route to host") },
452 { BSM_ERRNO_EALREADY, EALREADY, ES("Operation already in progress") },
453 { BSM_ERRNO_EINPROGRESS, EINPROGRESS,
454 ES("Operation now in progress") },
455 { BSM_ERRNO_ESTALE, ESTALE, ES("Stale NFS file handle") },
456 { BSM_ERRNO_EPWROFF,
433#ifdef EPWROFF
434 EPWROFF,
435#else
436 ERRNO_NO_LOCAL_MAPPING,
437#endif
457#ifdef EPWROFF
458 EPWROFF,
459#else
460 ERRNO_NO_LOCAL_MAPPING,
461#endif
438 "Device power is off" },
439 { BSM_EDEVERR,
462 ES("Device power is off") },
463 { BSM_ERRNO_EDEVERR,
440#ifdef EDEVERR
441 EDEVERR,
442#else
443 ERRNO_NO_LOCAL_MAPPING,
444#endif
464#ifdef EDEVERR
465 EDEVERR,
466#else
467 ERRNO_NO_LOCAL_MAPPING,
468#endif
445 "Device error" },
446 { BSM_EBADEXEC,
469 ES("Device error") },
470 { BSM_ERRNO_EBADEXEC,
447#ifdef EBADEXEC
448 EBADEXEC,
449#else
450 ERRNO_NO_LOCAL_MAPPING,
451#endif
471#ifdef EBADEXEC
472 EBADEXEC,
473#else
474 ERRNO_NO_LOCAL_MAPPING,
475#endif
452 "Bad executable" },
453 { BSM_EBADARCH,
476 ES("Bad executable") },
477 { BSM_ERRNO_EBADARCH,
454#ifdef EBADARCH
455 EBADARCH,
456#else
457 ERRNO_NO_LOCAL_MAPPING,
458#endif
478#ifdef EBADARCH
479 EBADARCH,
480#else
481 ERRNO_NO_LOCAL_MAPPING,
482#endif
459 "Bad CPU type in executable" },
460 { BSM_ESHLIBVERS,
483 ES("Bad CPU type in executable") },
484 { BSM_ERRNO_ESHLIBVERS,
461#ifdef ESHLIBVERS
462 ESHLIBVERS,
463#else
464 ERRNO_NO_LOCAL_MAPPING,
465#endif
485#ifdef ESHLIBVERS
486 ESHLIBVERS,
487#else
488 ERRNO_NO_LOCAL_MAPPING,
489#endif
466 "Shared library version mismatch" },
467 { BSM_EBADMACHO,
490 ES("Shared library version mismatch") },
491 { BSM_ERRNO_EBADMACHO,
468#ifdef EBADMACHO
469 EBADMACHO,
470#else
471 ERRNO_NO_LOCAL_MAPPING,
472#endif
492#ifdef EBADMACHO
493 EBADMACHO,
494#else
495 ERRNO_NO_LOCAL_MAPPING,
496#endif
473 "Malfored Macho file" },
474 { BSM_EPOLICY,
497 ES("Malfored Macho file") },
498 { BSM_ERRNO_EPOLICY,
475#ifdef EPOLICY
476 EPOLICY,
477#else
478 ERRNO_NO_LOCAL_MAPPING,
479#endif
499#ifdef EPOLICY
500 EPOLICY,
501#else
502 ERRNO_NO_LOCAL_MAPPING,
503#endif
480 "Operation failed by policy" },
481 { BSM_EDOTDOT,
504 ES("Operation failed by policy") },
505 { BSM_ERRNO_EDOTDOT,
482#ifdef EDOTDOT
483 EDOTDOT,
484#else
485 ERRNO_NO_LOCAL_MAPPING,
486#endif
506#ifdef EDOTDOT
507 EDOTDOT,
508#else
509 ERRNO_NO_LOCAL_MAPPING,
510#endif
487 "RFS specific error" },
488 { BSM_EUCLEAN,
511 ES("RFS specific error") },
512 { BSM_ERRNO_EUCLEAN,
489#ifdef EUCLEAN
490 EUCLEAN,
491#else
492 ERRNO_NO_LOCAL_MAPPING,
493#endif
513#ifdef EUCLEAN
514 EUCLEAN,
515#else
516 ERRNO_NO_LOCAL_MAPPING,
517#endif
494 "Structure needs cleaning" },
495 { BSM_ENOTNAM,
518 ES("Structure needs cleaning") },
519 { BSM_ERRNO_ENOTNAM,
496#ifdef ENOTNAM
497 ENOTNAM,
498#else
499 ERRNO_NO_LOCAL_MAPPING,
500#endif
520#ifdef ENOTNAM
521 ENOTNAM,
522#else
523 ERRNO_NO_LOCAL_MAPPING,
524#endif
501 "Not a XENIX named type file" },
502 { BSM_ENAVAIL,
525 ES("Not a XENIX named type file") },
526 { BSM_ERRNO_ENAVAIL,
503#ifdef ENAVAIL
504 ENAVAIL,
505#else
506 ERRNO_NO_LOCAL_MAPPING,
507#endif
527#ifdef ENAVAIL
528 ENAVAIL,
529#else
530 ERRNO_NO_LOCAL_MAPPING,
531#endif
508 "No XENIX semaphores available" },
509 { BSM_EISNAM,
532 ES("No XENIX semaphores available") },
533 { BSM_ERRNO_EISNAM,
510#ifdef EISNAM
511 EISNAM,
512#else
513 ERRNO_NO_LOCAL_MAPPING,
514#endif
534#ifdef EISNAM
535 EISNAM,
536#else
537 ERRNO_NO_LOCAL_MAPPING,
538#endif
515 "Is a named type file" },
516 { BSM_EREMOTEIO,
539 ES("Is a named type file") },
540 { BSM_ERRNO_EREMOTEIO,
517#ifdef EREMOTEIO
518 EREMOTEIO,
519#else
520 ERRNO_NO_LOCAL_MAPPING,
521#endif
541#ifdef EREMOTEIO
542 EREMOTEIO,
543#else
544 ERRNO_NO_LOCAL_MAPPING,
545#endif
522 "Remote I/O error" },
523 { BSM_ENOMEDIUM,
546 ES("Remote I/O error") },
547 { BSM_ERRNO_ENOMEDIUM,
524#ifdef ENOMEDIUM
525 ENOMEDIUM,
526#else
527 ERRNO_NO_LOCAL_MAPPING,
528#endif
548#ifdef ENOMEDIUM
549 ENOMEDIUM,
550#else
551 ERRNO_NO_LOCAL_MAPPING,
552#endif
529 "No medium found" },
530 { BSM_EMEDIUMTYPE,
553 ES("No medium found") },
554 { BSM_ERRNO_EMEDIUMTYPE,
531#ifdef EMEDIUMTYPE
532 EMEDIUMTYPE,
533#else
534 ERRNO_NO_LOCAL_MAPPING,
535#endif
555#ifdef EMEDIUMTYPE
556 EMEDIUMTYPE,
557#else
558 ERRNO_NO_LOCAL_MAPPING,
559#endif
536 "Wrong medium type" },
537 { BSM_ENOKEY,
560 ES("Wrong medium type") },
561 { BSM_ERRNO_ENOKEY,
538#ifdef ENOKEY
539 ENOKEY,
540#else
541 ERRNO_NO_LOCAL_MAPPING,
542#endif
562#ifdef ENOKEY
563 ENOKEY,
564#else
565 ERRNO_NO_LOCAL_MAPPING,
566#endif
543 "Required key not available" },
544 { BSM_EKEYEXPIRED,
567 ES("Required key not available") },
568 { BSM_ERRNO_EKEYEXPIRED,
545#ifdef EKEEXPIRED
546 EKEYEXPIRED,
547#else
548 ERRNO_NO_LOCAL_MAPPING,
549#endif
569#ifdef EKEEXPIRED
570 EKEYEXPIRED,
571#else
572 ERRNO_NO_LOCAL_MAPPING,
573#endif
550 "Key has expired" },
551 { BSM_EKEYREVOKED,
574 ES("Key has expired") },
575 { BSM_ERRNO_EKEYREVOKED,
552#ifdef EKEYREVOKED
553 EKEYREVOKED,
554#else
555 ERRNO_NO_LOCAL_MAPPING,
556#endif
576#ifdef EKEYREVOKED
577 EKEYREVOKED,
578#else
579 ERRNO_NO_LOCAL_MAPPING,
580#endif
557 "Key has been revoked" },
558 { BSM_EKEYREJECTED,
581 ES("Key has been revoked") },
582 { BSM_ERRNO_EKEYREJECTED,
559#ifdef EKEREJECTED
560 EKEYREJECTED,
561#else
562 ERRNO_NO_LOCAL_MAPPING,
563#endif
583#ifdef EKEREJECTED
584 EKEYREJECTED,
585#else
586 ERRNO_NO_LOCAL_MAPPING,
587#endif
564 "Key was rejected by service" },
588 ES("Key was rejected by service") },
565};
589};
566static const int bsm_errors_count = sizeof(bsm_errors) / sizeof(bsm_errors[0]);
590static const int bsm_errnos_count = sizeof(bsm_errnos) / sizeof(bsm_errnos[0]);
567
591
568static const struct bsm_errors *
569au_bsm_error_lookup_errno(int error)
592static const struct bsm_errno *
593bsm_lookup_errno_local(int local_errno)
570{
571 int i;
572
594{
595 int i;
596
573 if (error == ERRNO_NO_LOCAL_MAPPING)
574 return (NULL);
575 for (i = 0; i < bsm_errors_count; i++) {
576 if (bsm_errors[i].be_os_error == error)
577 return (&bsm_errors[i]);
597 for (i = 0; i < bsm_errnos_count; i++) {
598 if (bsm_errnos[i].be_local_errno == local_errno)
599 return (&bsm_errnos[i]);
578 }
579 return (NULL);
580}
581
600 }
601 return (NULL);
602}
603
582static const struct bsm_errors *
583au_bsm_error_lookup_bsm(u_char bsm_error)
604/*
605 * Conversion to the BSM errno space isn't allowed to fail; we simply map to
606 * BSM_ERRNO_UNKNOWN and let the remote endpoint deal with it.
607 */
608u_char
609au_errno_to_bsm(int local_errno)
584{
610{
611 const struct bsm_errno *bsme;
612
613 bsme = bsm_lookup_errno_local(local_errno);
614 if (bsme == NULL)
615 return (BSM_ERRNO_UNKNOWN);
616 return (bsme->be_bsm_errno);
617}
618
619static const struct bsm_errno *
620bsm_lookup_errno_bsm(u_char bsm_errno)
621{
585 int i;
586
622 int i;
623
587 for (i = 0; i < bsm_errors_count; i++) {
588 if (bsm_errors[i].be_bsm_error == bsm_error)
589 return (&bsm_errors[i]);
624 for (i = 0; i < bsm_errnos_count; i++) {
625 if (bsm_errnos[i].be_bsm_errno == bsm_errno)
626 return (&bsm_errnos[i]);
590 }
591 return (NULL);
592}
593
594/*
595 * Converstion from a BSM error to a local error number may fail if either
596 * OpenBSM doesn't recognize the error on the wire, or because there is no
627 }
628 return (NULL);
629}
630
631/*
632 * Converstion from a BSM error to a local error number may fail if either
633 * OpenBSM doesn't recognize the error on the wire, or because there is no
597 * appropriate local mapping. However, we don't allow conversion to BSM to
598 * fail, we just convert to BSM_UKNOWNERR.
634 * appropriate local mapping.
599 */
600int
635 */
636int
601au_bsm_to_errno(u_char bsm_error, int *errorp)
637au_bsm_to_errno(u_char bsm_errno, int *errorp)
602{
638{
603 const struct bsm_errors *bsme;
639 const struct bsm_errno *bsme;
604
640
605 bsme = au_bsm_error_lookup_bsm(bsm_error);
606 if (bsme == NULL || bsme->be_os_error == ERRNO_NO_LOCAL_MAPPING)
641 bsme = bsm_lookup_errno_bsm(bsm_errno);
642 if (bsme == NULL || bsme->be_local_errno == ERRNO_NO_LOCAL_MAPPING)
607 return (-1);
643 return (-1);
608 *errorp = bsme->be_os_error;
644 *errorp = bsme->be_local_errno;
609 return (0);
610}
611
645 return (0);
646}
647
612u_char
613au_errno_to_bsm(int error)
614{
615 const struct bsm_errors *bsme;
616
617 /*
618 * We should never be passed this libbsm-internal constant, and
619 * because it is ambiguous we just return an error.
620 */
621 if (error == ERRNO_NO_LOCAL_MAPPING)
622 return (BSM_UNKNOWNERR);
623 bsme = au_bsm_error_lookup_errno(error);
624 if (bsme == NULL)
625 return (BSM_UNKNOWNERR);
626 return (bsme->be_bsm_error);
627}
628
629#if !defined(KERNEL) && !defined(_KERNEL)
630const char *
648#if !defined(KERNEL) && !defined(_KERNEL)
649const char *
631au_strerror(u_char bsm_error)
650au_strerror(u_char bsm_errno)
632{
651{
633 const struct bsm_errors *bsme;
652 const struct bsm_errno *bsme;
634
653
635 bsme = au_bsm_error_lookup_bsm(bsm_error);
654 bsme = bsm_lookup_errno_bsm(bsm_errno);
636 if (bsme == NULL)
637 return ("Unrecognized BSM error");
655 if (bsme == NULL)
656 return ("Unrecognized BSM error");
638 if (bsme->be_os_error != ERRNO_NO_LOCAL_MAPPING)
639 return (strerror(bsme->be_os_error));
657 if (bsme->be_local_errno != ERRNO_NO_LOCAL_MAPPING)
658 return (strerror(bsme->be_local_errno));
640 return (bsme->be_strerror);
641}
642#endif
659 return (bsme->be_strerror);
660}
661#endif