Mercurial > trustbridge > nss-cmake-static
comparison nspr/pr/src/md/unix/unix_errors.c @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
5 | |
6 #include "primpl.h" | |
7 #if defined(_PR_POLL_AVAILABLE) | |
8 #include <poll.h> | |
9 #endif | |
10 #include <errno.h> | |
11 | |
12 void _MD_unix_map_default_error(int err) | |
13 { | |
14 PRErrorCode prError; | |
15 | |
16 switch (err ) { | |
17 case EACCES: | |
18 prError = PR_NO_ACCESS_RIGHTS_ERROR; | |
19 break; | |
20 case EADDRINUSE: | |
21 prError = PR_ADDRESS_IN_USE_ERROR; | |
22 break; | |
23 case EADDRNOTAVAIL: | |
24 prError = PR_ADDRESS_NOT_AVAILABLE_ERROR; | |
25 break; | |
26 case EAFNOSUPPORT: | |
27 prError = PR_ADDRESS_NOT_SUPPORTED_ERROR; | |
28 break; | |
29 case EAGAIN: | |
30 prError = PR_WOULD_BLOCK_ERROR; | |
31 break; | |
32 /* | |
33 * On QNX and Neutrino, EALREADY is defined as EBUSY. | |
34 */ | |
35 #if EALREADY != EBUSY | |
36 case EALREADY: | |
37 prError = PR_ALREADY_INITIATED_ERROR; | |
38 break; | |
39 #endif | |
40 case EBADF: | |
41 prError = PR_BAD_DESCRIPTOR_ERROR; | |
42 break; | |
43 #ifdef EBADMSG | |
44 case EBADMSG: | |
45 prError = PR_IO_ERROR; | |
46 break; | |
47 #endif | |
48 case EBUSY: | |
49 prError = PR_FILESYSTEM_MOUNTED_ERROR; | |
50 break; | |
51 case ECONNABORTED: | |
52 prError = PR_CONNECT_ABORTED_ERROR; | |
53 break; | |
54 case ECONNREFUSED: | |
55 prError = PR_CONNECT_REFUSED_ERROR; | |
56 break; | |
57 case ECONNRESET: | |
58 prError = PR_CONNECT_RESET_ERROR; | |
59 break; | |
60 case EDEADLK: | |
61 prError = PR_DEADLOCK_ERROR; | |
62 break; | |
63 #ifdef EDIRCORRUPTED | |
64 case EDIRCORRUPTED: | |
65 prError = PR_DIRECTORY_CORRUPTED_ERROR; | |
66 break; | |
67 #endif | |
68 #ifdef EDQUOT | |
69 case EDQUOT: | |
70 prError = PR_NO_DEVICE_SPACE_ERROR; | |
71 break; | |
72 #endif | |
73 case EEXIST: | |
74 prError = PR_FILE_EXISTS_ERROR; | |
75 break; | |
76 case EFAULT: | |
77 prError = PR_ACCESS_FAULT_ERROR; | |
78 break; | |
79 case EFBIG: | |
80 prError = PR_FILE_TOO_BIG_ERROR; | |
81 break; | |
82 case EHOSTUNREACH: | |
83 case EHOSTDOWN: | |
84 prError = PR_HOST_UNREACHABLE_ERROR; | |
85 break; | |
86 case EINPROGRESS: | |
87 prError = PR_IN_PROGRESS_ERROR; | |
88 break; | |
89 case EINTR: | |
90 prError = PR_PENDING_INTERRUPT_ERROR; | |
91 break; | |
92 case EINVAL: | |
93 prError = PR_INVALID_ARGUMENT_ERROR; | |
94 break; | |
95 case EIO: | |
96 prError = PR_IO_ERROR; | |
97 break; | |
98 case EISCONN: | |
99 prError = PR_IS_CONNECTED_ERROR; | |
100 break; | |
101 case EISDIR: | |
102 prError = PR_IS_DIRECTORY_ERROR; | |
103 break; | |
104 case ELOOP: | |
105 prError = PR_LOOP_ERROR; | |
106 break; | |
107 case EMFILE: | |
108 prError = PR_PROC_DESC_TABLE_FULL_ERROR; | |
109 break; | |
110 case EMLINK: | |
111 prError = PR_MAX_DIRECTORY_ENTRIES_ERROR; | |
112 break; | |
113 case EMSGSIZE: | |
114 prError = PR_INVALID_ARGUMENT_ERROR; | |
115 break; | |
116 #ifdef EMULTIHOP | |
117 case EMULTIHOP: | |
118 prError = PR_REMOTE_FILE_ERROR; | |
119 break; | |
120 #endif | |
121 case ENAMETOOLONG: | |
122 prError = PR_NAME_TOO_LONG_ERROR; | |
123 break; | |
124 case ENETUNREACH: | |
125 prError = PR_NETWORK_UNREACHABLE_ERROR; | |
126 break; | |
127 case ENFILE: | |
128 prError = PR_SYS_DESC_TABLE_FULL_ERROR; | |
129 break; | |
130 /* | |
131 * On SCO OpenServer 5, ENOBUFS is defined as ENOSR. | |
132 */ | |
133 #if defined(ENOBUFS) && (ENOBUFS != ENOSR) | |
134 case ENOBUFS: | |
135 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
136 break; | |
137 #endif | |
138 case ENODEV: | |
139 prError = PR_FILE_NOT_FOUND_ERROR; | |
140 break; | |
141 case ENOENT: | |
142 prError = PR_FILE_NOT_FOUND_ERROR; | |
143 break; | |
144 case ENOLCK: | |
145 prError = PR_FILE_IS_LOCKED_ERROR; | |
146 break; | |
147 #ifdef ENOLINK | |
148 case ENOLINK: | |
149 prError = PR_REMOTE_FILE_ERROR; | |
150 break; | |
151 #endif | |
152 case ENOMEM: | |
153 prError = PR_OUT_OF_MEMORY_ERROR; | |
154 break; | |
155 case ENOPROTOOPT: | |
156 prError = PR_INVALID_ARGUMENT_ERROR; | |
157 break; | |
158 case ENOSPC: | |
159 prError = PR_NO_DEVICE_SPACE_ERROR; | |
160 break; | |
161 #ifdef ENOSR | |
162 case ENOSR: | |
163 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
164 break; | |
165 #endif | |
166 case ENOSYS: | |
167 prError = PR_NOT_IMPLEMENTED_ERROR; | |
168 break; | |
169 case ENOTCONN: | |
170 prError = PR_NOT_CONNECTED_ERROR; | |
171 break; | |
172 case ENOTDIR: | |
173 prError = PR_NOT_DIRECTORY_ERROR; | |
174 break; | |
175 case ENOTSOCK: | |
176 prError = PR_NOT_SOCKET_ERROR; | |
177 break; | |
178 case ENXIO: | |
179 prError = PR_FILE_NOT_FOUND_ERROR; | |
180 break; | |
181 case EOPNOTSUPP: | |
182 prError = PR_NOT_TCP_SOCKET_ERROR; | |
183 break; | |
184 #ifdef EOVERFLOW | |
185 case EOVERFLOW: | |
186 prError = PR_BUFFER_OVERFLOW_ERROR; | |
187 break; | |
188 #endif | |
189 case EPERM: | |
190 prError = PR_NO_ACCESS_RIGHTS_ERROR; | |
191 break; | |
192 case EPIPE: | |
193 prError = PR_CONNECT_RESET_ERROR; | |
194 break; | |
195 #ifdef EPROTO | |
196 case EPROTO: | |
197 prError = PR_IO_ERROR; | |
198 break; | |
199 #endif | |
200 case EPROTONOSUPPORT: | |
201 prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR; | |
202 break; | |
203 case EPROTOTYPE: | |
204 prError = PR_ADDRESS_NOT_SUPPORTED_ERROR; | |
205 break; | |
206 case ERANGE: | |
207 prError = PR_INVALID_METHOD_ERROR; | |
208 break; | |
209 case EROFS: | |
210 prError = PR_READ_ONLY_FILESYSTEM_ERROR; | |
211 break; | |
212 case ESPIPE: | |
213 prError = PR_INVALID_METHOD_ERROR; | |
214 break; | |
215 case ETIMEDOUT: | |
216 prError = PR_IO_TIMEOUT_ERROR; | |
217 break; | |
218 #if EWOULDBLOCK != EAGAIN | |
219 case EWOULDBLOCK: | |
220 prError = PR_WOULD_BLOCK_ERROR; | |
221 break; | |
222 #endif | |
223 case EXDEV: | |
224 prError = PR_NOT_SAME_DEVICE_ERROR; | |
225 break; | |
226 default: | |
227 prError = PR_UNKNOWN_ERROR; | |
228 break; | |
229 } | |
230 PR_SetError(prError, err); | |
231 } | |
232 | |
233 void _MD_unix_map_opendir_error(int err) | |
234 { | |
235 _MD_unix_map_default_error(err); | |
236 } | |
237 | |
238 void _MD_unix_map_closedir_error(int err) | |
239 { | |
240 PRErrorCode prError; | |
241 | |
242 switch (err) { | |
243 case EINVAL: | |
244 prError = PR_BAD_DESCRIPTOR_ERROR; | |
245 break; | |
246 default: | |
247 _MD_unix_map_default_error(err); | |
248 return; | |
249 } | |
250 PR_SetError(prError, err); | |
251 } | |
252 | |
253 void _MD_unix_readdir_error(int err) | |
254 { | |
255 PRErrorCode prError; | |
256 | |
257 switch (err) { | |
258 case 0: | |
259 case ENOENT: | |
260 prError = PR_NO_MORE_FILES_ERROR; | |
261 break; | |
262 #ifdef EOVERFLOW | |
263 case EOVERFLOW: | |
264 prError = PR_IO_ERROR; | |
265 break; | |
266 #endif | |
267 case EINVAL: | |
268 prError = PR_IO_ERROR; | |
269 break; | |
270 case ENXIO: | |
271 prError = PR_IO_ERROR; | |
272 break; | |
273 default: | |
274 _MD_unix_map_default_error(err); | |
275 return; | |
276 } | |
277 PR_SetError(prError, err); | |
278 } | |
279 | |
280 void _MD_unix_map_unlink_error(int err) | |
281 { | |
282 PRErrorCode prError; | |
283 | |
284 switch (err) { | |
285 case EPERM: | |
286 prError = PR_IS_DIRECTORY_ERROR; | |
287 break; | |
288 default: | |
289 _MD_unix_map_default_error(err); | |
290 return; | |
291 } | |
292 PR_SetError(prError, err); | |
293 } | |
294 | |
295 void _MD_unix_map_stat_error(int err) | |
296 { | |
297 PRErrorCode prError; | |
298 | |
299 switch (err) { | |
300 case ETIMEDOUT: | |
301 prError = PR_REMOTE_FILE_ERROR; | |
302 break; | |
303 default: | |
304 _MD_unix_map_default_error(err); | |
305 return; | |
306 } | |
307 PR_SetError(prError, err); | |
308 } | |
309 | |
310 void _MD_unix_map_fstat_error(int err) | |
311 { | |
312 PRErrorCode prError; | |
313 | |
314 switch (err) { | |
315 case ETIMEDOUT: | |
316 prError = PR_REMOTE_FILE_ERROR; | |
317 break; | |
318 default: | |
319 _MD_unix_map_default_error(err); | |
320 return; | |
321 } | |
322 PR_SetError(prError, err); | |
323 } | |
324 | |
325 void _MD_unix_map_rename_error(int err) | |
326 { | |
327 PRErrorCode prError; | |
328 | |
329 switch (err) { | |
330 case EEXIST: | |
331 prError = PR_DIRECTORY_NOT_EMPTY_ERROR; | |
332 break; | |
333 default: | |
334 _MD_unix_map_default_error(err); | |
335 return; | |
336 } | |
337 PR_SetError(prError, err); | |
338 } | |
339 | |
340 void _MD_unix_map_access_error(int err) | |
341 { | |
342 PRErrorCode prError; | |
343 | |
344 switch (err) { | |
345 case ETIMEDOUT: | |
346 prError = PR_REMOTE_FILE_ERROR; | |
347 break; | |
348 default: | |
349 _MD_unix_map_default_error(err); | |
350 return; | |
351 } | |
352 PR_SetError(prError, err); | |
353 } | |
354 | |
355 void _MD_unix_map_mkdir_error(int err) | |
356 { | |
357 _MD_unix_map_default_error(err); | |
358 } | |
359 | |
360 void _MD_unix_map_rmdir_error(int err) | |
361 { | |
362 PRErrorCode prError; | |
363 | |
364 switch (err) { | |
365 /* | |
366 * On AIX 4.3, ENOTEMPTY is defined as EEXIST. | |
367 */ | |
368 #if ENOTEMPTY != EEXIST | |
369 case ENOTEMPTY: | |
370 prError = PR_DIRECTORY_NOT_EMPTY_ERROR; | |
371 break; | |
372 #endif | |
373 case EEXIST: | |
374 prError = PR_DIRECTORY_NOT_EMPTY_ERROR; | |
375 break; | |
376 case EINVAL: | |
377 prError = PR_DIRECTORY_NOT_EMPTY_ERROR; | |
378 break; | |
379 case ETIMEDOUT: | |
380 prError = PR_REMOTE_FILE_ERROR; | |
381 break; | |
382 default: | |
383 _MD_unix_map_default_error(err); | |
384 return; | |
385 } | |
386 PR_SetError(prError, err); | |
387 } | |
388 | |
389 void _MD_unix_map_read_error(int err) | |
390 { | |
391 PRErrorCode prError; | |
392 | |
393 switch (err) { | |
394 case EINVAL: | |
395 prError = PR_INVALID_METHOD_ERROR; | |
396 break; | |
397 case ENXIO: | |
398 prError = PR_INVALID_ARGUMENT_ERROR; | |
399 break; | |
400 default: | |
401 _MD_unix_map_default_error(err); | |
402 return; | |
403 } | |
404 PR_SetError(prError, err); | |
405 } | |
406 | |
407 void _MD_unix_map_write_error(int err) | |
408 { | |
409 PRErrorCode prError; | |
410 | |
411 switch (err) { | |
412 case EINVAL: | |
413 prError = PR_INVALID_METHOD_ERROR; | |
414 break; | |
415 case ENXIO: | |
416 prError = PR_INVALID_METHOD_ERROR; | |
417 break; | |
418 case ETIMEDOUT: | |
419 prError = PR_REMOTE_FILE_ERROR; | |
420 break; | |
421 default: | |
422 _MD_unix_map_default_error(err); | |
423 return; | |
424 } | |
425 PR_SetError(prError, err); | |
426 } | |
427 | |
428 void _MD_unix_map_lseek_error(int err) | |
429 { | |
430 _MD_unix_map_default_error(err); | |
431 } | |
432 | |
433 void _MD_unix_map_fsync_error(int err) | |
434 { | |
435 PRErrorCode prError; | |
436 | |
437 switch (err) { | |
438 case ETIMEDOUT: | |
439 prError = PR_REMOTE_FILE_ERROR; | |
440 break; | |
441 case EINVAL: | |
442 prError = PR_INVALID_METHOD_ERROR; | |
443 break; | |
444 default: | |
445 _MD_unix_map_default_error(err); | |
446 return; | |
447 } | |
448 PR_SetError(prError, err); | |
449 } | |
450 | |
451 void _MD_unix_map_close_error(int err) | |
452 { | |
453 PRErrorCode prError; | |
454 | |
455 switch (err) { | |
456 case ETIMEDOUT: | |
457 prError = PR_REMOTE_FILE_ERROR; | |
458 break; | |
459 default: | |
460 _MD_unix_map_default_error(err); | |
461 return; | |
462 } | |
463 PR_SetError(prError, err); | |
464 } | |
465 | |
466 void _MD_unix_map_socket_error(int err) | |
467 { | |
468 PRErrorCode prError; | |
469 | |
470 switch (err) { | |
471 case ENOMEM: | |
472 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
473 break; | |
474 default: | |
475 _MD_unix_map_default_error(err); | |
476 return; | |
477 } | |
478 PR_SetError(prError, err); | |
479 } | |
480 | |
481 void _MD_unix_map_socketavailable_error(int err) | |
482 { | |
483 PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); | |
484 } | |
485 | |
486 void _MD_unix_map_recv_error(int err) | |
487 { | |
488 _MD_unix_map_default_error(err); | |
489 } | |
490 | |
491 void _MD_unix_map_recvfrom_error(int err) | |
492 { | |
493 _MD_unix_map_default_error(err); | |
494 } | |
495 | |
496 void _MD_unix_map_send_error(int err) | |
497 { | |
498 _MD_unix_map_default_error(err); | |
499 } | |
500 | |
501 void _MD_unix_map_sendto_error(int err) | |
502 { | |
503 _MD_unix_map_default_error(err); | |
504 } | |
505 | |
506 void _MD_unix_map_writev_error(int err) | |
507 { | |
508 _MD_unix_map_default_error(err); | |
509 } | |
510 | |
511 void _MD_unix_map_accept_error(int err) | |
512 { | |
513 PRErrorCode prError; | |
514 | |
515 switch (err) { | |
516 case ENODEV: | |
517 prError = PR_NOT_TCP_SOCKET_ERROR; | |
518 break; | |
519 default: | |
520 _MD_unix_map_default_error(err); | |
521 return; | |
522 } | |
523 PR_SetError(prError, err); | |
524 } | |
525 | |
526 void _MD_unix_map_connect_error(int err) | |
527 { | |
528 PRErrorCode prError; | |
529 | |
530 switch (err) { | |
531 #if defined(UNIXWARE) | |
532 /* | |
533 * On some platforms, if we connect to a port on the local host | |
534 * (the loopback address) that no process is listening on, we get | |
535 * EIO instead of ECONNREFUSED. | |
536 */ | |
537 case EIO: | |
538 prError = PR_CONNECT_REFUSED_ERROR; | |
539 break; | |
540 #endif | |
541 case ENXIO: | |
542 prError = PR_IO_ERROR; | |
543 break; | |
544 default: | |
545 _MD_unix_map_default_error(err); | |
546 return; | |
547 } | |
548 PR_SetError(prError, err); | |
549 } | |
550 | |
551 void _MD_unix_map_bind_error(int err) | |
552 { | |
553 PRErrorCode prError; | |
554 | |
555 switch (err) { | |
556 case EINVAL: | |
557 prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR; | |
558 break; | |
559 default: | |
560 _MD_unix_map_default_error(err); | |
561 return; | |
562 } | |
563 PR_SetError(prError, err); | |
564 } | |
565 | |
566 void _MD_unix_map_listen_error(int err) | |
567 { | |
568 _MD_unix_map_default_error(err); | |
569 } | |
570 | |
571 void _MD_unix_map_shutdown_error(int err) | |
572 { | |
573 _MD_unix_map_default_error(err); | |
574 } | |
575 | |
576 void _MD_unix_map_socketpair_error(int err) | |
577 { | |
578 PRErrorCode prError; | |
579 | |
580 switch (err) { | |
581 case ENOMEM: | |
582 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
583 break; | |
584 default: | |
585 _MD_unix_map_default_error(err); | |
586 return; | |
587 } | |
588 PR_SetError(prError, err); | |
589 } | |
590 | |
591 void _MD_unix_map_getsockname_error(int err) | |
592 { | |
593 PRErrorCode prError; | |
594 | |
595 switch (err) { | |
596 case ENOMEM: | |
597 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
598 break; | |
599 default: | |
600 _MD_unix_map_default_error(err); | |
601 return; | |
602 } | |
603 PR_SetError(prError, err); | |
604 } | |
605 | |
606 void _MD_unix_map_getpeername_error(int err) | |
607 { | |
608 PRErrorCode prError; | |
609 | |
610 switch (err) { | |
611 case ENOMEM: | |
612 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
613 break; | |
614 default: | |
615 _MD_unix_map_default_error(err); | |
616 return; | |
617 } | |
618 PR_SetError(prError, err); | |
619 } | |
620 | |
621 void _MD_unix_map_getsockopt_error(int err) | |
622 { | |
623 PRErrorCode prError; | |
624 | |
625 switch (err) { | |
626 case EINVAL: | |
627 prError = PR_BUFFER_OVERFLOW_ERROR; | |
628 break; | |
629 case ENOMEM: | |
630 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
631 break; | |
632 default: | |
633 _MD_unix_map_default_error(err); | |
634 return; | |
635 } | |
636 PR_SetError(prError, err); | |
637 } | |
638 | |
639 void _MD_unix_map_setsockopt_error(int err) | |
640 { | |
641 PRErrorCode prError; | |
642 | |
643 switch (err) { | |
644 case EINVAL: | |
645 prError = PR_BUFFER_OVERFLOW_ERROR; | |
646 break; | |
647 case ENOMEM: | |
648 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
649 break; | |
650 default: | |
651 _MD_unix_map_default_error(err); | |
652 return; | |
653 } | |
654 PR_SetError(prError, err); | |
655 } | |
656 | |
657 void _MD_unix_map_open_error(int err) | |
658 { | |
659 PRErrorCode prError; | |
660 | |
661 switch (err) { | |
662 case EAGAIN: | |
663 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
664 break; | |
665 case EBUSY: | |
666 prError = PR_IO_ERROR; | |
667 break; | |
668 case ENODEV: | |
669 prError = PR_FILE_NOT_FOUND_ERROR; | |
670 break; | |
671 case ENOMEM: | |
672 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
673 break; | |
674 #ifdef EOVERFLOW | |
675 case EOVERFLOW: | |
676 prError = PR_FILE_TOO_BIG_ERROR; | |
677 break; | |
678 #endif | |
679 case ETIMEDOUT: | |
680 prError = PR_REMOTE_FILE_ERROR; | |
681 break; | |
682 default: | |
683 _MD_unix_map_default_error(err); | |
684 return; | |
685 } | |
686 PR_SetError(prError, err); | |
687 } | |
688 | |
689 void _MD_unix_map_mmap_error(int err) | |
690 { | |
691 PRErrorCode prError; | |
692 | |
693 switch (err) { | |
694 case EAGAIN: | |
695 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
696 break; | |
697 case EMFILE: | |
698 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
699 break; | |
700 case ENODEV: | |
701 prError = PR_OPERATION_NOT_SUPPORTED_ERROR; | |
702 break; | |
703 case ENXIO: | |
704 prError = PR_INVALID_ARGUMENT_ERROR; | |
705 break; | |
706 default: | |
707 _MD_unix_map_default_error(err); | |
708 return; | |
709 } | |
710 PR_SetError(prError, err); | |
711 } | |
712 | |
713 void _MD_unix_map_gethostname_error(int err) | |
714 { | |
715 _MD_unix_map_default_error(err); | |
716 } | |
717 | |
718 void _MD_unix_map_select_error(int err) | |
719 { | |
720 _MD_unix_map_default_error(err); | |
721 } | |
722 | |
723 #if defined(_PR_POLL_AVAILABLE) || defined(_PR_NEED_FAKE_POLL) | |
724 void _MD_unix_map_poll_error(int err) | |
725 { | |
726 PRErrorCode prError; | |
727 | |
728 switch (err) { | |
729 case EAGAIN: | |
730 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
731 break; | |
732 default: | |
733 _MD_unix_map_default_error(err); | |
734 return; | |
735 } | |
736 PR_SetError(prError, err); | |
737 } | |
738 | |
739 void _MD_unix_map_poll_revents_error(int err) | |
740 { | |
741 if (err & POLLNVAL) | |
742 PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF); | |
743 else if (err & POLLHUP) | |
744 PR_SetError(PR_CONNECT_RESET_ERROR, EPIPE); | |
745 else if (err & POLLERR) | |
746 PR_SetError(PR_IO_ERROR, EIO); | |
747 else | |
748 PR_SetError(PR_UNKNOWN_ERROR, err); | |
749 } | |
750 #endif /* _PR_POLL_AVAILABLE || _PR_NEED_FAKE_POLL */ | |
751 | |
752 | |
753 void _MD_unix_map_flock_error(int err) | |
754 { | |
755 PRErrorCode prError; | |
756 | |
757 switch (err) { | |
758 case EINVAL: | |
759 prError = PR_BAD_DESCRIPTOR_ERROR; | |
760 break; | |
761 case EWOULDBLOCK: | |
762 prError = PR_FILE_IS_LOCKED_ERROR; | |
763 break; | |
764 default: | |
765 _MD_unix_map_default_error(err); | |
766 return; | |
767 } | |
768 PR_SetError(prError, err); | |
769 } | |
770 | |
771 void _MD_unix_map_lockf_error(int err) | |
772 { | |
773 PRErrorCode prError; | |
774 | |
775 switch (err) { | |
776 case EACCES: | |
777 prError = PR_FILE_IS_LOCKED_ERROR; | |
778 break; | |
779 case EDEADLK: | |
780 prError = PR_INSUFFICIENT_RESOURCES_ERROR; | |
781 break; | |
782 default: | |
783 _MD_unix_map_default_error(err); | |
784 return; | |
785 } | |
786 PR_SetError(prError, err); | |
787 } | |
788 | |
789 #ifdef AIX | |
790 void _MD_aix_map_sendfile_error(int err) | |
791 { | |
792 _MD_unix_map_default_error(err); | |
793 } | |
794 #endif /* AIX */ | |
795 | |
796 #ifdef HPUX11 | |
797 void _MD_hpux_map_sendfile_error(int err) | |
798 { | |
799 _MD_unix_map_default_error(err); | |
800 } | |
801 #endif /* HPUX11 */ | |
802 | |
803 #ifdef SOLARIS | |
804 void _MD_solaris_map_sendfile_error(int err) | |
805 { | |
806 PRErrorCode prError; | |
807 | |
808 switch (err) { | |
809 /* | |
810 * Solaris defines a 0 return value for sendfile to mean end-of-file. | |
811 */ | |
812 case 0: | |
813 prError = PR_END_OF_FILE_ERROR; | |
814 break; | |
815 | |
816 default: | |
817 _MD_unix_map_default_error(err) ; | |
818 return; | |
819 } | |
820 PR_SetError(prError, err); | |
821 } | |
822 #endif /* SOLARIS */ | |
823 | |
824 #ifdef LINUX | |
825 void _MD_linux_map_sendfile_error(int err) | |
826 { | |
827 _MD_unix_map_default_error(err) ; | |
828 } | |
829 #endif /* LINUX */ |