Back to index

lightning-sunbird  0.9+nobinonly
unix_errors.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "primpl.h"
00039 #if defined(_PR_POLL_AVAILABLE)
00040 #include <poll.h>
00041 #endif
00042 #include <errno.h>
00043 
00044 void _MD_unix_map_default_error(int err)
00045 {
00046     PRErrorCode prError;
00047 
00048     switch (err ) {
00049         case EACCES:
00050             prError = PR_NO_ACCESS_RIGHTS_ERROR;
00051             break;
00052         case EADDRINUSE:
00053             prError = PR_ADDRESS_IN_USE_ERROR;
00054             break;
00055         case EADDRNOTAVAIL:
00056             prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;
00057             break;
00058         case EAFNOSUPPORT:
00059             prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
00060             break;
00061         case EAGAIN:
00062             prError = PR_WOULD_BLOCK_ERROR;
00063             break;
00064         /*
00065          * On QNX and Neutrino, EALREADY is defined as EBUSY.
00066          */
00067 #if EALREADY != EBUSY
00068         case EALREADY:
00069             prError = PR_ALREADY_INITIATED_ERROR;
00070             break;
00071 #endif
00072         case EBADF:
00073             prError = PR_BAD_DESCRIPTOR_ERROR;
00074             break;
00075 #ifdef EBADMSG
00076         case EBADMSG:
00077             prError = PR_IO_ERROR;
00078             break;
00079 #endif
00080         case EBUSY:
00081             prError = PR_FILESYSTEM_MOUNTED_ERROR;
00082             break;
00083         case ECONNABORTED:
00084             prError = PR_CONNECT_ABORTED_ERROR;
00085             break;
00086         case ECONNREFUSED:
00087             prError = PR_CONNECT_REFUSED_ERROR;
00088             break;
00089         case ECONNRESET:
00090             prError = PR_CONNECT_RESET_ERROR;
00091             break;
00092         case EDEADLK:
00093             prError = PR_DEADLOCK_ERROR;
00094             break;
00095 #ifdef EDIRCORRUPTED
00096         case EDIRCORRUPTED:
00097             prError = PR_DIRECTORY_CORRUPTED_ERROR;
00098             break;
00099 #endif
00100 #ifdef EDQUOT
00101         case EDQUOT:
00102             prError = PR_NO_DEVICE_SPACE_ERROR;
00103             break;
00104 #endif
00105         case EEXIST:
00106             prError = PR_FILE_EXISTS_ERROR;
00107             break;
00108         case EFAULT:
00109             prError = PR_ACCESS_FAULT_ERROR;
00110             break;
00111         case EFBIG:
00112             prError = PR_FILE_TOO_BIG_ERROR;
00113             break;
00114         case EHOSTUNREACH:
00115             prError = PR_HOST_UNREACHABLE_ERROR;
00116             break;
00117         case EINPROGRESS:
00118             prError = PR_IN_PROGRESS_ERROR;
00119             break;
00120         case EINTR:
00121             prError = PR_PENDING_INTERRUPT_ERROR;
00122             break;
00123         case EINVAL:
00124             prError = PR_INVALID_ARGUMENT_ERROR;
00125             break;
00126         case EIO:
00127             prError = PR_IO_ERROR;
00128             break;
00129         case EISCONN:
00130             prError = PR_IS_CONNECTED_ERROR;
00131             break;
00132         case EISDIR:
00133             prError = PR_IS_DIRECTORY_ERROR;
00134             break;
00135         case ELOOP:
00136             prError = PR_LOOP_ERROR;
00137             break;
00138         case EMFILE:
00139             prError = PR_PROC_DESC_TABLE_FULL_ERROR;
00140             break;
00141         case EMLINK:
00142             prError = PR_MAX_DIRECTORY_ENTRIES_ERROR;
00143             break;
00144         case EMSGSIZE:
00145             prError = PR_INVALID_ARGUMENT_ERROR;
00146             break;
00147 #ifdef EMULTIHOP
00148         case EMULTIHOP:
00149             prError = PR_REMOTE_FILE_ERROR;
00150             break;
00151 #endif
00152         case ENAMETOOLONG:
00153             prError = PR_NAME_TOO_LONG_ERROR;
00154             break;
00155         case ENETUNREACH:
00156             prError = PR_NETWORK_UNREACHABLE_ERROR;
00157             break;
00158         case ENFILE:
00159             prError = PR_SYS_DESC_TABLE_FULL_ERROR;
00160             break;
00161         /*
00162          * On SCO OpenServer 5, ENOBUFS is defined as ENOSR.
00163          */
00164 #if defined(ENOBUFS) && (ENOBUFS != ENOSR)
00165         case ENOBUFS:
00166             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00167             break;
00168 #endif
00169         case ENODEV:
00170             prError = PR_FILE_NOT_FOUND_ERROR;
00171             break;
00172         case ENOENT:
00173             prError = PR_FILE_NOT_FOUND_ERROR;
00174             break;
00175         case ENOLCK:
00176             prError = PR_FILE_IS_LOCKED_ERROR;
00177             break;
00178 #ifdef ENOLINK 
00179         case ENOLINK:
00180             prError = PR_REMOTE_FILE_ERROR;
00181             break;
00182 #endif
00183         case ENOMEM:
00184             prError = PR_OUT_OF_MEMORY_ERROR;
00185             break;
00186         case ENOPROTOOPT:
00187             prError = PR_INVALID_ARGUMENT_ERROR;
00188             break;
00189         case ENOSPC:
00190             prError = PR_NO_DEVICE_SPACE_ERROR;
00191             break;
00192 #ifdef ENOSR
00193         case ENOSR:
00194             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00195             break;
00196 #endif
00197         case ENOTCONN:
00198             prError = PR_NOT_CONNECTED_ERROR;
00199             break;
00200         case ENOTDIR:
00201             prError = PR_NOT_DIRECTORY_ERROR;
00202             break;
00203         case ENOTSOCK:
00204             prError = PR_NOT_SOCKET_ERROR;
00205             break;
00206         case ENXIO:
00207             prError = PR_FILE_NOT_FOUND_ERROR;
00208             break;
00209         case EOPNOTSUPP:
00210             prError = PR_NOT_TCP_SOCKET_ERROR;
00211             break;
00212 #ifdef EOVERFLOW
00213         case EOVERFLOW:
00214             prError = PR_BUFFER_OVERFLOW_ERROR;
00215             break;
00216 #endif
00217         case EPERM:
00218             prError = PR_NO_ACCESS_RIGHTS_ERROR;
00219             break;
00220         case EPIPE:
00221             prError = PR_CONNECT_RESET_ERROR;
00222             break;
00223 #ifdef EPROTO
00224         case EPROTO:
00225             prError = PR_IO_ERROR;
00226             break;
00227 #endif
00228         case EPROTONOSUPPORT:
00229             prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR;
00230             break;
00231         case EPROTOTYPE:
00232             prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
00233             break;
00234         case ERANGE:
00235             prError = PR_INVALID_METHOD_ERROR;
00236             break;
00237         case EROFS:
00238             prError = PR_READ_ONLY_FILESYSTEM_ERROR;
00239             break;
00240         case ESPIPE:
00241             prError = PR_INVALID_METHOD_ERROR;
00242             break;
00243         case ETIMEDOUT:
00244             prError = PR_IO_TIMEOUT_ERROR;
00245             break;
00246 #if EWOULDBLOCK != EAGAIN
00247         case EWOULDBLOCK:
00248             prError = PR_WOULD_BLOCK_ERROR;
00249             break;
00250 #endif
00251         case EXDEV:
00252             prError = PR_NOT_SAME_DEVICE_ERROR;
00253             break;
00254         default:
00255             prError = PR_UNKNOWN_ERROR;
00256             break;
00257     }
00258     PR_SetError(prError, err);
00259 }
00260 
00261 void _MD_unix_map_opendir_error(int err)
00262 {
00263     _MD_unix_map_default_error(err);
00264 }
00265 
00266 void _MD_unix_map_closedir_error(int err)
00267 {
00268     PRErrorCode prError;
00269 
00270     switch (err) {
00271         case EINVAL:
00272             prError = PR_BAD_DESCRIPTOR_ERROR;
00273             break;
00274         default:
00275             _MD_unix_map_default_error(err);
00276             return;
00277     }
00278     PR_SetError(prError, err);
00279 }
00280 
00281 void _MD_unix_readdir_error(int err)
00282 {
00283     PRErrorCode prError;
00284 
00285     switch (err) {
00286         case 0:
00287         case ENOENT:
00288             prError = PR_NO_MORE_FILES_ERROR;
00289             break;
00290 #ifdef EOVERFLOW
00291         case EOVERFLOW:
00292             prError = PR_IO_ERROR;
00293             break;
00294 #endif
00295         case EINVAL:
00296             prError = PR_IO_ERROR;
00297             break;
00298         case ENXIO:
00299             prError = PR_IO_ERROR;
00300             break;
00301         default:
00302             _MD_unix_map_default_error(err);
00303             return;
00304     }
00305     PR_SetError(prError, err);
00306 }
00307 
00308 void _MD_unix_map_unlink_error(int err)
00309 {
00310     PRErrorCode prError;
00311 
00312     switch (err) {
00313         case EPERM:
00314             prError = PR_IS_DIRECTORY_ERROR;
00315             break;
00316         default:
00317             _MD_unix_map_default_error(err);
00318             return;
00319     }
00320     PR_SetError(prError, err);
00321 }
00322 
00323 void _MD_unix_map_stat_error(int err)
00324 {
00325     PRErrorCode prError;
00326 
00327     switch (err) {
00328         case ETIMEDOUT:
00329             prError = PR_REMOTE_FILE_ERROR;
00330             break;
00331         default:
00332             _MD_unix_map_default_error(err);
00333             return;
00334     }
00335     PR_SetError(prError, err);
00336 }
00337 
00338 void _MD_unix_map_fstat_error(int err)
00339 {
00340     PRErrorCode prError;
00341 
00342     switch (err) {
00343         case ETIMEDOUT:
00344             prError = PR_REMOTE_FILE_ERROR;
00345             break;
00346         default:
00347             _MD_unix_map_default_error(err);
00348             return;
00349     }
00350     PR_SetError(prError, err);
00351 }
00352 
00353 void _MD_unix_map_rename_error(int err)
00354 {
00355     PRErrorCode prError;
00356 
00357     switch (err) {
00358         case EEXIST:
00359             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
00360             break;
00361         default:
00362             _MD_unix_map_default_error(err);
00363             return;
00364     }
00365     PR_SetError(prError, err);
00366 }
00367 
00368 void _MD_unix_map_access_error(int err)
00369 {
00370     PRErrorCode prError;
00371 
00372     switch (err) {
00373         case ETIMEDOUT:
00374             prError = PR_REMOTE_FILE_ERROR;
00375             break;
00376         default:
00377             _MD_unix_map_default_error(err);
00378             return;
00379     }
00380     PR_SetError(prError, err);
00381 }
00382 
00383 void _MD_unix_map_mkdir_error(int err)
00384 {
00385     _MD_unix_map_default_error(err);
00386 }
00387 
00388 void _MD_unix_map_rmdir_error(int err)
00389 {
00390     PRErrorCode prError;
00391 
00392     switch (err) {
00393         /*
00394          * On AIX 4.3, ENOTEMPTY is defined as EEXIST.
00395          */
00396 #if ENOTEMPTY != EEXIST
00397         case ENOTEMPTY:
00398             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
00399             break;
00400 #endif
00401         case EEXIST:
00402             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
00403             break;
00404         case EINVAL:
00405             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
00406             break;
00407         case ETIMEDOUT:
00408             prError = PR_REMOTE_FILE_ERROR;
00409             break;
00410         default:
00411             _MD_unix_map_default_error(err);
00412             return;
00413     }
00414     PR_SetError(prError, err);
00415 }
00416 
00417 void _MD_unix_map_read_error(int err)
00418 {
00419     PRErrorCode prError;
00420 
00421     switch (err) {
00422         case EINVAL:
00423             prError = PR_INVALID_METHOD_ERROR;
00424             break;
00425         case ENXIO:
00426             prError = PR_INVALID_ARGUMENT_ERROR;
00427             break;
00428         default:
00429             _MD_unix_map_default_error(err);
00430             return;
00431     }
00432     PR_SetError(prError, err);
00433 }
00434 
00435 void _MD_unix_map_write_error(int err)
00436 {
00437     PRErrorCode prError;
00438 
00439     switch (err) {
00440         case EINVAL:
00441             prError = PR_INVALID_METHOD_ERROR;
00442             break;
00443         case ENXIO:
00444             prError = PR_INVALID_METHOD_ERROR;
00445             break;
00446         case ETIMEDOUT:
00447             prError = PR_REMOTE_FILE_ERROR;
00448             break;
00449         default:
00450             _MD_unix_map_default_error(err);
00451             return;
00452     }
00453     PR_SetError(prError, err);
00454 }
00455 
00456 void _MD_unix_map_lseek_error(int err)
00457 {
00458     _MD_unix_map_default_error(err);
00459 }
00460 
00461 void _MD_unix_map_fsync_error(int err)
00462 {
00463     PRErrorCode prError;
00464 
00465     switch (err) {
00466         case ETIMEDOUT:
00467             prError = PR_REMOTE_FILE_ERROR;
00468             break;
00469         case EINVAL:
00470             prError = PR_INVALID_METHOD_ERROR;
00471             break;
00472         default:
00473             _MD_unix_map_default_error(err);
00474             return;
00475     }
00476     PR_SetError(prError, err);
00477 }
00478 
00479 void _MD_unix_map_close_error(int err)
00480 {
00481     PRErrorCode prError;
00482 
00483     switch (err) {
00484         case ETIMEDOUT:
00485             prError = PR_REMOTE_FILE_ERROR;
00486             break;
00487         default:
00488             _MD_unix_map_default_error(err);
00489             return;
00490     }
00491     PR_SetError(prError, err);
00492 }
00493 
00494 void _MD_unix_map_socket_error(int err)
00495 {
00496     PRErrorCode prError;
00497 
00498     switch (err) {
00499         case ENOMEM:
00500             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00501             break;
00502         default:
00503             _MD_unix_map_default_error(err);
00504             return;
00505     }
00506     PR_SetError(prError, err);
00507 }
00508 
00509 void _MD_unix_map_socketavailable_error(int err)
00510 {
00511     PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
00512 }
00513 
00514 void _MD_unix_map_recv_error(int err)
00515 {
00516     _MD_unix_map_default_error(err);
00517 }
00518 
00519 void _MD_unix_map_recvfrom_error(int err)
00520 {
00521     _MD_unix_map_default_error(err);
00522 }
00523 
00524 void _MD_unix_map_send_error(int err)
00525 {
00526     _MD_unix_map_default_error(err);
00527 }
00528 
00529 void _MD_unix_map_sendto_error(int err)
00530 {
00531     _MD_unix_map_default_error(err);
00532 }
00533 
00534 void _MD_unix_map_writev_error(int err)
00535 {
00536     _MD_unix_map_default_error(err);
00537 }
00538 
00539 void _MD_unix_map_accept_error(int err)
00540 {
00541     PRErrorCode prError;
00542 
00543     switch (err) {
00544         case ENODEV:
00545             prError = PR_NOT_TCP_SOCKET_ERROR;
00546             break;
00547         default:
00548             _MD_unix_map_default_error(err);
00549             return;
00550     }
00551     PR_SetError(prError, err);
00552 }
00553 
00554 void _MD_unix_map_connect_error(int err)
00555 {
00556     PRErrorCode prError;
00557 
00558     switch (err) {
00559         case EACCES:
00560             prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
00561             break;
00562 #if defined(UNIXWARE) || defined(SNI) || defined(NEC)
00563         /*
00564          * On some platforms, if we connect to a port on the local host 
00565          * (the loopback address) that no process is listening on, we get 
00566          * EIO instead of ECONNREFUSED.
00567          */
00568         case EIO:
00569             prError = PR_CONNECT_REFUSED_ERROR;
00570             break;
00571 #endif
00572         case ELOOP:
00573             prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
00574             break;
00575         case ENOENT:
00576             prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
00577             break;
00578         case ENXIO:
00579             prError = PR_IO_ERROR;
00580             break;
00581         default:
00582             _MD_unix_map_default_error(err);
00583             return;
00584     }
00585     PR_SetError(prError, err);
00586 }
00587 
00588 void _MD_unix_map_bind_error(int err)
00589 {
00590     PRErrorCode prError;
00591 
00592     switch (err) {
00593         case EINVAL:
00594             prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR;
00595             break;
00596         /*
00597          * UNIX domain sockets are not supported in NSPR
00598          */
00599         case EIO:
00600         case EISDIR:
00601         case ELOOP:
00602         case ENOENT:
00603         case ENOTDIR:
00604         case EROFS:
00605             prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
00606             break;
00607         default:
00608             _MD_unix_map_default_error(err);
00609             return;
00610     }
00611     PR_SetError(prError, err);
00612 }
00613 
00614 void _MD_unix_map_listen_error(int err)
00615 {
00616     _MD_unix_map_default_error(err);
00617 }
00618 
00619 void _MD_unix_map_shutdown_error(int err)
00620 {
00621     _MD_unix_map_default_error(err);
00622 }
00623 
00624 void _MD_unix_map_socketpair_error(int err)
00625 {
00626     PRErrorCode prError;
00627 
00628     switch (err) {
00629         case ENOMEM:
00630             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00631             break;
00632         default:
00633             _MD_unix_map_default_error(err);
00634             return;
00635     }
00636     PR_SetError(prError, err);
00637 }
00638 
00639 void _MD_unix_map_getsockname_error(int err)
00640 {
00641     PRErrorCode prError;
00642 
00643     switch (err) {
00644         case ENOMEM:
00645             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00646             break;
00647         default:
00648             _MD_unix_map_default_error(err);
00649             return;
00650     }
00651     PR_SetError(prError, err);
00652 }
00653 
00654 void _MD_unix_map_getpeername_error(int err)
00655 {
00656     PRErrorCode prError;
00657 
00658     switch (err) {
00659         case ENOMEM:
00660             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00661             break;
00662         default:
00663             _MD_unix_map_default_error(err);
00664             return;
00665     }
00666     PR_SetError(prError, err);
00667 }
00668 
00669 void _MD_unix_map_getsockopt_error(int err)
00670 {
00671     PRErrorCode prError;
00672 
00673     switch (err) {
00674         case EINVAL:
00675             prError = PR_BUFFER_OVERFLOW_ERROR;
00676             break;
00677         case ENOMEM:
00678             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00679             break;
00680         default:
00681             _MD_unix_map_default_error(err);
00682             return;
00683     }
00684     PR_SetError(prError, err);
00685 }
00686 
00687 void _MD_unix_map_setsockopt_error(int err)
00688 {
00689     PRErrorCode prError;
00690 
00691     switch (err) {
00692         case EINVAL:
00693             prError = PR_BUFFER_OVERFLOW_ERROR;
00694             break;
00695         case ENOMEM:
00696             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00697             break;
00698         default:
00699             _MD_unix_map_default_error(err);
00700             return;
00701     }
00702     PR_SetError(prError, err);
00703 }
00704 
00705 void _MD_unix_map_open_error(int err)
00706 {
00707     PRErrorCode prError;
00708 
00709     switch (err) {
00710         case EAGAIN:
00711             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00712             break;
00713         case EBUSY:
00714             prError = PR_IO_ERROR;
00715             break;
00716         case ENODEV:
00717             prError = PR_FILE_NOT_FOUND_ERROR;
00718             break;
00719         case ENOMEM:
00720             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00721             break;
00722 #ifdef EOVERFLOW
00723         case EOVERFLOW:
00724             prError = PR_FILE_TOO_BIG_ERROR;
00725             break;
00726 #endif
00727         case ETIMEDOUT:
00728             prError = PR_REMOTE_FILE_ERROR;
00729             break;
00730         default:
00731             _MD_unix_map_default_error(err);
00732             return;
00733     }
00734     PR_SetError(prError, err);
00735 }
00736 
00737 void _MD_unix_map_mmap_error(int err)
00738 {
00739     PRErrorCode prError;
00740 
00741     switch (err) {
00742         case EAGAIN:
00743             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00744             break;
00745         case EMFILE:
00746             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00747             break;
00748         case ENODEV:
00749             prError = PR_OPERATION_NOT_SUPPORTED_ERROR;
00750             break;
00751         case ENXIO:
00752             prError = PR_INVALID_ARGUMENT_ERROR;
00753             break;
00754         default:
00755             _MD_unix_map_default_error(err);
00756             return;
00757     }
00758     PR_SetError(prError, err);
00759 }
00760 
00761 void _MD_unix_map_gethostname_error(int err)
00762 {
00763     _MD_unix_map_default_error(err);
00764 }
00765 
00766 void _MD_unix_map_select_error(int err)
00767 {
00768     _MD_unix_map_default_error(err);
00769 }
00770 
00771 #if defined(_PR_POLL_AVAILABLE) || defined(_PR_NEED_FAKE_POLL)
00772 void _MD_unix_map_poll_error(int err)
00773 {
00774     PRErrorCode prError;
00775 
00776     switch (err) {
00777         case EAGAIN:
00778             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00779             break;
00780         default:
00781             _MD_unix_map_default_error(err);
00782             return;
00783     }
00784     PR_SetError(prError, err);
00785 }
00786 
00787 void _MD_unix_map_poll_revents_error(int err)
00788 {
00789     if (err & POLLNVAL)
00790         PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF);
00791     else if (err & POLLHUP)
00792         PR_SetError(PR_CONNECT_RESET_ERROR, EPIPE);
00793     else if (err & POLLERR)
00794         PR_SetError(PR_IO_ERROR, EIO);
00795     else
00796         PR_SetError(PR_UNKNOWN_ERROR, err);
00797 }
00798 #endif /* _PR_POLL_AVAILABLE || _PR_NEED_FAKE_POLL */
00799 
00800 
00801 void _MD_unix_map_flock_error(int err)
00802 {
00803     PRErrorCode prError;
00804 
00805     switch (err) {
00806         case EINVAL:
00807             prError = PR_BAD_DESCRIPTOR_ERROR;
00808             break;
00809         case EWOULDBLOCK:
00810             prError = PR_FILE_IS_LOCKED_ERROR;
00811             break;
00812         default:
00813             _MD_unix_map_default_error(err);
00814             return;
00815     }
00816     PR_SetError(prError, err);
00817 }
00818 
00819 void _MD_unix_map_lockf_error(int err)
00820 {
00821     PRErrorCode prError;
00822 
00823     switch (err) {
00824         case EACCES:
00825             prError = PR_FILE_IS_LOCKED_ERROR;
00826             break;
00827         case EDEADLK:
00828             prError = PR_INSUFFICIENT_RESOURCES_ERROR;
00829             break;
00830         default:
00831             _MD_unix_map_default_error(err);
00832             return;
00833     }
00834     PR_SetError(prError, err);
00835 }
00836 
00837 #ifdef AIX
00838 void _MD_aix_map_sendfile_error(int err)
00839 {
00840     _MD_unix_map_default_error(err);
00841 }
00842 #endif /* AIX */
00843 
00844 #ifdef HPUX11
00845 void _MD_hpux_map_sendfile_error(int err)
00846 {
00847     _MD_unix_map_default_error(err);
00848 }
00849 #endif /* HPUX11 */
00850 
00851 #ifdef SOLARIS
00852 void _MD_solaris_map_sendfile_error(int err)
00853 {
00854     PRErrorCode prError;
00855 
00856     switch (err) {
00857         /*
00858          * Solaris defines a 0 return value for sendfile to mean end-of-file.
00859          */
00860         case 0:
00861             prError = PR_END_OF_FILE_ERROR;
00862             break;
00863 
00864         default:
00865             _MD_unix_map_default_error(err) ;
00866             return;
00867     }
00868     PR_SetError(prError, err);
00869 }
00870 #endif /* SOLARIS */
00871 
00872 #ifdef LINUX
00873 void _MD_linux_map_sendfile_error(int err)
00874 {
00875     _MD_unix_map_default_error(err) ;
00876 }
00877 #endif /* LINUX */