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/. */
9 void _MD_os2_map_default_error(PRInt32 err
)
13 PR_SetError(PR_WOULD_BLOCK_ERROR
, err
);
16 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
19 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
23 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
26 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
29 PR_SetError(PR_CONNECT_REFUSED_ERROR
, err
);
32 PR_SetError(PR_IS_CONNECTED_ERROR
, err
);
36 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
39 case ERROR_NETNAME_DELETED
:
40 PR_SetError(PR_CONNECT_RESET_ERROR
, err
);
43 PR_SetError(PR_UNKNOWN_ERROR
, err
);
47 void _MD_os2_map_opendir_error(PRInt32 err
)
50 case ERROR_FILE_NOT_FOUND
:
51 case ERROR_PATH_NOT_FOUND
:
52 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
54 case ERROR_ACCESS_DENIED
:
55 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
57 case ERROR_INVALID_ADDRESS
:
58 case ERROR_INVALID_ACCESS
:
59 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
61 case ERROR_INVALID_NAME
:
62 case ERROR_INVALID_PARAMETER
:
63 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
65 case ERROR_TOO_MANY_OPEN_FILES
:
66 case ERROR_NOT_DOS_DISK
:
68 case ERROR_OPEN_FAILED
:
70 case ERROR_CANNOT_MAKE
:
71 PR_SetError(PR_IO_ERROR
, err
);
73 case ERROR_DRIVE_LOCKED
:
74 case ERROR_DEVICE_IN_USE
:
75 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
77 case ERROR_FILENAME_EXCED_RANGE
:
78 PR_SetError(PR_NAME_TOO_LONG_ERROR
, err
);
80 case ERROR_NOT_ENOUGH_MEMORY
:
81 case ERROR_SHARING_BUFFER_EXCEEDED
:
82 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
85 PR_SetError(PR_UNKNOWN_ERROR
, err
);
90 void _MD_os2_map_closedir_error(PRInt32 err
)
93 case ERROR_FILE_NOT_FOUND
:
94 case ERROR_ACCESS_DENIED
:
95 case ERROR_INVALID_HANDLE
:
96 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
99 PR_SetError(PR_UNKNOWN_ERROR
, err
);
104 void _MD_os2_readdir_error(PRInt32 err
)
108 case ERROR_NO_MORE_FILES
:
109 PR_SetError(PR_NO_MORE_FILES_ERROR
, err
);
111 case ERROR_FILE_NOT_FOUND
:
112 case ERROR_INVALID_HANDLE
:
113 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
115 case ERROR_INVALID_ADDRESS
:
116 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
118 case ERROR_NOT_DOS_DISK
:
119 case ERROR_LOCK_VIOLATION
:
120 case ERROR_BROKEN_PIPE
:
121 case ERROR_NOT_READY
:
122 PR_SetError(PR_IO_ERROR
, err
);
124 case ERROR_NOT_ENOUGH_MEMORY
:
125 case ERROR_MORE_DATA
:
126 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
129 PR_SetError(PR_UNKNOWN_ERROR
, err
);
134 void _MD_os2_map_delete_error(PRInt32 err
)
137 case ERROR_FILE_NOT_FOUND
:
138 case ERROR_PATH_NOT_FOUND
:
139 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
141 case ERROR_ACCESS_DENIED
:
142 case ERROR_WRITE_PROTECT
:
143 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
145 case ERROR_INVALID_ADDRESS
:
146 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
148 case ERROR_DRIVE_LOCKED
:
150 case ERROR_SHARING_VIOLATION
:
151 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
154 PR_SetError(PR_UNKNOWN_ERROR
, err
);
159 /* The error code for stat() is in errno. */
160 void _MD_os2_map_stat_error(PRInt32 err
)
164 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
167 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
170 PR_SetError(PR_UNKNOWN_ERROR
, err
);
174 void _MD_os2_map_fstat_error(PRInt32 err
)
177 case ERROR_ACCESS_DENIED
:
178 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
180 case ERROR_INVALID_HANDLE
:
181 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
183 case ERROR_INVALID_ADDRESS
:
184 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
186 case ERROR_NOT_READY
:
187 case ERROR_PATH_BUSY
:
188 PR_SetError(PR_IO_ERROR
, err
);
190 case ERROR_NOT_ENOUGH_MEMORY
:
191 case ERROR_MORE_DATA
:
192 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
194 case ERROR_DRIVE_LOCKED
:
196 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
199 PR_SetError(PR_UNKNOWN_ERROR
, err
);
204 void _MD_os2_map_rename_error(PRInt32 err
)
207 case ERROR_FILE_NOT_FOUND
:
208 case ERROR_PATH_NOT_FOUND
:
209 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
211 case ERROR_ACCESS_DENIED
:
212 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
214 case ERROR_INVALID_ADDRESS
:
215 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
217 case ERROR_INVALID_NAME
:
218 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
220 case ERROR_NOT_READY
:
221 case ERROR_PATH_BUSY
:
222 PR_SetError(PR_IO_ERROR
, err
);
224 case ERROR_DRIVE_LOCKED
:
225 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
227 case ERROR_FILENAME_EXCED_RANGE
:
228 PR_SetError(PR_NAME_TOO_LONG_ERROR
, err
);
230 case ERROR_NOT_ENOUGH_MEMORY
:
231 case ERROR_MORE_DATA
:
232 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
234 case ERROR_ALREADY_EXISTS
:
235 case ERROR_FILE_EXISTS
:
236 PR_SetError(PR_FILE_EXISTS_ERROR
, err
);
239 PR_SetError(PR_UNKNOWN_ERROR
, err
);
244 /* The error code for access() is in errno. */
245 void _MD_os2_map_access_error(PRInt32 err
)
249 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
252 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
255 PR_SetError(PR_UNKNOWN_ERROR
, err
);
259 void _MD_os2_map_mkdir_error(PRInt32 err
)
262 case ERROR_ALREADY_EXISTS
:
263 case ERROR_FILE_EXISTS
:
264 PR_SetError(PR_FILE_EXISTS_ERROR
, err
);
266 case ERROR_FILE_NOT_FOUND
:
267 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
269 case ERROR_ACCESS_DENIED
:
270 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
272 case ERROR_INVALID_ADDRESS
:
273 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
275 case ERROR_INVALID_NAME
:
276 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
278 case ERROR_NOT_READY
:
279 case ERROR_PATH_BUSY
:
280 PR_SetError(PR_IO_ERROR
, err
);
282 case ERROR_DRIVE_LOCKED
:
283 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
285 case ERROR_FILENAME_EXCED_RANGE
:
286 PR_SetError(PR_NAME_TOO_LONG_ERROR
, err
);
288 case ERROR_TOO_MANY_OPEN_FILES
:
289 PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR
, err
);
291 case ERROR_PATH_NOT_FOUND
:
292 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
294 case ERROR_NOT_ENOUGH_MEMORY
:
295 case ERROR_MORE_DATA
:
296 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
298 case ERROR_DISK_FULL
:
299 case ERROR_HANDLE_DISK_FULL
:
300 PR_SetError(PR_NO_DEVICE_SPACE_ERROR
, err
);
302 case ERROR_WRITE_PROTECT
:
303 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
306 PR_SetError(PR_UNKNOWN_ERROR
, err
);
311 void _MD_os2_map_rmdir_error(PRInt32 err
)
315 case ERROR_FILE_NOT_FOUND
:
316 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
318 case ERROR_ACCESS_DENIED
:
319 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
321 case ERROR_INVALID_ADDRESS
:
322 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
324 case ERROR_INVALID_NAME
:
325 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
327 case ERROR_NOT_READY
:
328 case ERROR_PATH_BUSY
:
329 PR_SetError(PR_IO_ERROR
, err
);
331 case ERROR_DRIVE_LOCKED
:
332 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
334 case ERROR_FILENAME_EXCED_RANGE
:
335 PR_SetError(PR_NAME_TOO_LONG_ERROR
, err
);
337 case ERROR_TOO_MANY_OPEN_FILES
:
338 PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR
, err
);
340 case ERROR_PATH_NOT_FOUND
:
341 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
343 case ERROR_NOT_ENOUGH_MEMORY
:
344 case ERROR_MORE_DATA
:
345 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
347 case ERROR_WRITE_PROTECT
:
348 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
351 PR_SetError(PR_UNKNOWN_ERROR
, err
);
356 void _MD_os2_map_read_error(PRInt32 err
)
359 case ERROR_ACCESS_DENIED
:
360 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
362 case ERROR_INVALID_HANDLE
:
363 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
365 case ERROR_INVALID_ADDRESS
:
366 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
368 case ERROR_NOT_READY
:
369 case ERROR_PATH_BUSY
:
370 PR_SetError(PR_IO_ERROR
, err
);
372 case ERROR_NOT_ENOUGH_MEMORY
:
373 case ERROR_MORE_DATA
:
374 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
376 case ERROR_DRIVE_LOCKED
:
378 case ERROR_SHARING_VIOLATION
:
379 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
381 case ERROR_NETNAME_DELETED
:
382 PR_SetError(PR_CONNECT_RESET_ERROR
, err
);
385 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
388 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
392 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
396 PR_SetError(PR_UNKNOWN_ERROR
, err
);
401 void _MD_os2_map_transmitfile_error(PRInt32 err
)
404 case ERROR_ACCESS_DENIED
:
405 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
407 case ERROR_INVALID_HANDLE
:
408 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
410 case ERROR_INVALID_ADDRESS
:
411 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
413 case ERROR_NOT_READY
:
414 case ERROR_PATH_BUSY
:
415 PR_SetError(PR_IO_ERROR
, err
);
417 case ERROR_NOT_ENOUGH_MEMORY
:
418 case ERROR_MORE_DATA
:
419 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
421 case ERROR_DRIVE_LOCKED
:
423 case ERROR_SHARING_VIOLATION
:
424 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
426 case ERROR_FILENAME_EXCED_RANGE
:
427 PR_SetError(PR_NAME_TOO_LONG_ERROR
, err
);
429 case ERROR_TOO_MANY_OPEN_FILES
:
430 PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR
, err
);
432 case ERROR_PATH_NOT_FOUND
:
433 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
436 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
439 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
443 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
447 PR_SetError(PR_UNKNOWN_ERROR
, err
);
452 void _MD_os2_map_write_error(PRInt32 err
)
455 case ERROR_ACCESS_DENIED
:
456 case ERROR_WRITE_PROTECT
:
457 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
459 case ERROR_INVALID_HANDLE
:
460 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
462 case ERROR_INVALID_ADDRESS
:
463 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
465 case ERROR_NOT_READY
:
466 case ERROR_PATH_BUSY
:
467 PR_SetError(PR_IO_ERROR
, err
);
469 case ERROR_DRIVE_LOCKED
:
471 case ERROR_SHARING_VIOLATION
:
472 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
474 case ERROR_NOT_ENOUGH_MEMORY
:
475 case ERROR_MORE_DATA
:
476 case ERROR_DISK_FULL
:
477 case ERROR_HANDLE_DISK_FULL
:
479 PR_SetError(PR_NO_DEVICE_SPACE_ERROR
, err
);
481 case ERROR_NETNAME_DELETED
:
482 PR_SetError(PR_CONNECT_RESET_ERROR
, err
);
485 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
488 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
492 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
495 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
498 PR_SetError(PR_CONNECT_REFUSED_ERROR
, err
);
501 PR_SetError(PR_IS_CONNECTED_ERROR
, err
);
505 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
509 PR_SetError(PR_UNKNOWN_ERROR
, err
);
514 void _MD_os2_map_lseek_error(PRInt32 err
)
517 case ERROR_INVALID_HANDLE
:
518 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
520 case ERROR_SEEK_ON_DEVICE
:
521 PR_SetError(PR_IO_ERROR
, err
);
524 PR_SetError(PR_UNKNOWN_ERROR
, err
);
529 void _MD_os2_map_fsync_error(PRInt32 err
)
532 case ERROR_ACCESS_DENIED
:
533 case ERROR_WRITE_PROTECT
:
534 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
536 case ERROR_INVALID_HANDLE
:
537 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
539 case ERROR_NOT_ENOUGH_MEMORY
:
540 case ERROR_MORE_DATA
:
541 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
543 case ERROR_DISK_FULL
:
544 case ERROR_HANDLE_DISK_FULL
:
545 PR_SetError(PR_NO_DEVICE_SPACE_ERROR
, err
);
548 PR_SetError(PR_UNKNOWN_ERROR
, err
);
553 void _MD_os2_map_close_error(PRInt32 err
)
556 case ERROR_INVALID_HANDLE
:
558 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
560 case ERROR_NOT_READY
:
561 case ERROR_PATH_BUSY
:
562 PR_SetError(PR_IO_ERROR
, err
);
565 PR_SetError(PR_UNKNOWN_ERROR
, err
);
570 void _MD_os2_map_socket_error(PRInt32 err
)
573 case EPROTONOSUPPORT
:
574 PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR
, err
);
577 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
579 case ERROR_NOT_ENOUGH_MEMORY
:
580 case ERROR_MORE_DATA
:
582 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
585 PR_SetError(PR_UNKNOWN_ERROR
, err
);
590 void _MD_os2_map_recv_error(PRInt32 err
)
594 PR_SetError(PR_WOULD_BLOCK_ERROR
, err
);
597 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
600 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
604 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
607 case ERROR_NETNAME_DELETED
:
608 PR_SetError(PR_CONNECT_RESET_ERROR
, err
);
611 PR_SetError(PR_UNKNOWN_ERROR
, err
);
616 void _MD_os2_map_recvfrom_error(PRInt32 err
)
620 PR_SetError(PR_WOULD_BLOCK_ERROR
, err
);
623 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
626 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
630 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
633 case ERROR_NETNAME_DELETED
:
634 PR_SetError(PR_CONNECT_RESET_ERROR
, err
);
637 PR_SetError(PR_UNKNOWN_ERROR
, err
);
642 void _MD_os2_map_send_error(PRInt32 err
)
646 PR_SetError(PR_WOULD_BLOCK_ERROR
, err
);
649 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
652 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
656 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
659 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
662 PR_SetError(PR_CONNECT_REFUSED_ERROR
, err
);
665 PR_SetError(PR_IS_CONNECTED_ERROR
, err
);
669 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
672 case ERROR_NETNAME_DELETED
:
673 PR_SetError(PR_CONNECT_RESET_ERROR
, err
);
676 PR_SetError(PR_UNKNOWN_ERROR
, err
);
681 void _MD_os2_map_sendto_error(PRInt32 err
)
683 _MD_os2_map_default_error(err
);
686 void _MD_os2_map_writev_error(int err
)
688 _MD_os2_map_default_error(err
);
691 void _MD_os2_map_accept_error(PRInt32 err
)
693 _MD_os2_map_default_error(err
);
696 void _MD_os2_map_acceptex_error(PRInt32 err
)
699 case ERROR_INVALID_HANDLE
:
700 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
702 case ERROR_INVALID_ADDRESS
:
703 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
705 case ERROR_NOT_ENOUGH_MEMORY
:
706 case ERROR_MORE_DATA
:
707 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
710 PR_SetError(PR_UNKNOWN_ERROR
, err
);
716 * An error code of 0 means that the nonblocking connect succeeded.
719 int _MD_os2_get_nonblocking_connect_error(int osfd
)
722 int len
= sizeof(err
);
723 if (getsockopt(osfd
, SOL_SOCKET
, SO_ERROR
, (char *) &err
, &len
) == -1) {
730 void _MD_os2_map_connect_error(PRInt32 err
)
734 PR_SetError(PR_WOULD_BLOCK_ERROR
, err
);
737 PR_SetError(PR_IN_PROGRESS_ERROR
, err
);
741 PR_SetError(PR_ALREADY_INITIATED_ERROR
, err
);
744 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
747 PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR
, err
);
750 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
753 PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR
, err
);
756 PR_SetError(PR_IO_TIMEOUT_ERROR
, err
);
759 PR_SetError(PR_CONNECT_REFUSED_ERROR
, err
);
762 PR_SetError(PR_NETWORK_UNREACHABLE_ERROR
, err
);
765 PR_SetError(PR_ADDRESS_IN_USE_ERROR
, err
);
768 PR_SetError(PR_IS_CONNECTED_ERROR
, err
);
772 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
776 PR_SetError(PR_UNKNOWN_ERROR
, err
);
781 void _MD_os2_map_bind_error(PRInt32 err
)
785 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
788 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
792 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
796 PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR
, err
);
799 PR_SetError(PR_ADDRESS_IN_USE_ERROR
, err
);
802 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
805 PR_SetError(PR_SOCKET_ADDRESS_IS_BOUND_ERROR
, err
);
808 PR_SetError(PR_UNKNOWN_ERROR
, err
);
813 void _MD_os2_map_listen_error(PRInt32 err
)
817 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
820 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
823 PR_SetError(PR_NOT_TCP_SOCKET_ERROR
, err
);
826 PR_SetError(PR_UNKNOWN_ERROR
, err
);
831 void _MD_os2_map_shutdown_error(PRInt32 err
)
835 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
838 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
841 PR_SetError(PR_NOT_CONNECTED_ERROR
, err
);
844 PR_SetError(PR_UNKNOWN_ERROR
, err
);
849 void _MD_os2_map_socketpair_error(PRInt32 err
)
853 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
856 PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR
, err
);
858 case EPROTONOSUPPORT
:
859 PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR
, err
);
862 PR_SetError(PR_NOT_TCP_SOCKET_ERROR
, err
);
865 PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR
, err
);
868 _MD_os2_map_default_error(err
);
873 void _MD_os2_map_getsockname_error(PRInt32 err
)
877 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
880 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
884 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
888 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
891 PR_SetError(PR_UNKNOWN_ERROR
, err
);
896 void _MD_os2_map_getpeername_error(PRInt32 err
)
901 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
904 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
907 PR_SetError(PR_NOT_CONNECTED_ERROR
, err
);
911 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
915 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
918 PR_SetError(PR_UNKNOWN_ERROR
, err
);
923 void _MD_os2_map_getsockopt_error(PRInt32 err
)
927 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
930 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
933 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
937 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
941 PR_SetError(PR_BUFFER_OVERFLOW_ERROR
, err
);
944 PR_SetError(PR_UNKNOWN_ERROR
, err
);
949 void _MD_os2_map_setsockopt_error(PRInt32 err
)
953 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
956 PR_SetError(PR_NOT_SOCKET_ERROR
, err
);
959 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
963 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
967 PR_SetError(PR_BUFFER_OVERFLOW_ERROR
, err
);
970 PR_SetError(PR_UNKNOWN_ERROR
, err
);
975 void _MD_os2_map_open_error(PRInt32 err
)
978 case ERROR_ALREADY_EXISTS
:
979 case ERROR_FILE_EXISTS
:
980 PR_SetError(PR_FILE_EXISTS_ERROR
, err
);
982 case ERROR_FILE_NOT_FOUND
:
983 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
985 case ERROR_ACCESS_DENIED
:
986 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
988 case ERROR_INVALID_ADDRESS
:
989 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
991 case ERROR_INVALID_NAME
:
992 PR_SetError(PR_INVALID_ARGUMENT_ERROR
, err
);
994 case ERROR_NOT_READY
:
995 case ERROR_OPEN_FAILED
:
996 case ERROR_PATH_BUSY
:
997 PR_SetError(PR_IO_ERROR
, err
);
999 case ERROR_DRIVE_LOCKED
:
1000 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
1002 case ERROR_FILENAME_EXCED_RANGE
:
1003 PR_SetError(PR_NAME_TOO_LONG_ERROR
, err
);
1005 case ERROR_TOO_MANY_OPEN_FILES
:
1006 PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR
, err
);
1008 case ERROR_PATH_NOT_FOUND
:
1009 PR_SetError(PR_FILE_NOT_FOUND_ERROR
, err
);
1011 case ERROR_NOT_ENOUGH_MEMORY
:
1012 case ERROR_MORE_DATA
:
1013 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
1015 case ERROR_DISK_FULL
:
1016 case ERROR_HANDLE_DISK_FULL
:
1017 PR_SetError(PR_NO_DEVICE_SPACE_ERROR
, err
);
1019 case ERROR_WRITE_PROTECT
:
1020 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
1023 PR_SetError(PR_UNKNOWN_ERROR
, err
);
1028 void _MD_os2_map_gethostname_error(PRInt32 err
)
1033 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
1039 PR_SetError(PR_UNKNOWN_ERROR
, err
);
1044 void _MD_os2_map_select_error(PRInt32 err
)
1046 PRErrorCode prerror
;
1050 * OS/2 select() only works on sockets. So in this
1051 * context, ENOTSOCK is equivalent to EBADF on Unix.
1054 prerror
= PR_BAD_DESCRIPTOR_ERROR
;
1057 prerror
= PR_INVALID_ARGUMENT_ERROR
;
1061 prerror
= PR_ACCESS_FAULT_ERROR
;
1065 prerror
= PR_UNKNOWN_ERROR
;
1067 PR_SetError(prerror
, err
);
1070 void _MD_os2_map_lockf_error(PRInt32 err
)
1073 case ERROR_ACCESS_DENIED
:
1074 PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR
, err
);
1076 case ERROR_INVALID_HANDLE
:
1077 PR_SetError(PR_BAD_DESCRIPTOR_ERROR
, err
);
1079 case ERROR_INVALID_ADDRESS
:
1080 PR_SetError(PR_ACCESS_FAULT_ERROR
, err
);
1082 case ERROR_DRIVE_LOCKED
:
1084 case ERROR_SHARING_VIOLATION
:
1085 PR_SetError(PR_FILE_IS_LOCKED_ERROR
, err
);
1087 case ERROR_NOT_ENOUGH_MEMORY
:
1088 case ERROR_MORE_DATA
:
1089 PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR
, err
);
1092 PR_SetError(PR_UNKNOWN_ERROR
, err
);