"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/libglusterfs/src/compat-errno.c" (16 Sep 2020, 46827 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "compat-errno.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2   Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
    3   This file is part of GlusterFS.
    4 
    5   This file is licensed to you under your choice of the GNU Lesser
    6   General Public License, version 3 or any later version (LGPLv3 or
    7   later), or the GNU General Public License, version 2 (GPLv2), in all
    8   cases as published by the Free Software Foundation.
    9 */
   10 
   11 #include <stdint.h>
   12 
   13 #include "glusterfs/compat-errno.h"
   14 
   15 static int32_t gf_error_to_errno_array[1024];
   16 static int32_t gf_errno_to_error_array[1024];
   17 
   18 static int32_t gf_compat_errno_init_done;
   19 
   20 #ifdef GF_SOLARIS_HOST_OS
   21 static void
   22 init_compat_errno_arrays()
   23 {
   24     /*      ENOMSG  35      / * No message of desired type          */
   25     gf_error_to_errno_array[GF_ERROR_CODE_NOMSG] = ENOMSG;
   26     gf_errno_to_error_array[ENOMSG] = GF_ERROR_CODE_NOMSG;
   27 
   28     /*      EIDRM   36      / * Identifier removed                  */
   29     gf_error_to_errno_array[GF_ERROR_CODE_IDRM] = EIDRM;
   30     gf_errno_to_error_array[EIDRM] = GF_ERROR_CODE_IDRM;
   31 
   32     /*      ECHRNG  37      / * Channel number out of range         */
   33     gf_error_to_errno_array[GF_ERROR_CODE_CHRNG] = ECHRNG;
   34     gf_errno_to_error_array[ECHRNG] = GF_ERROR_CODE_CHRNG;
   35 
   36     /*      EL2NSYNC 38     / * Level 2 not synchronized            */
   37     gf_error_to_errno_array[GF_ERROR_CODE_L2NSYNC] = EL2NSYNC;
   38     gf_errno_to_error_array[EL2NSYNC] = GF_ERROR_CODE_L2NSYNC;
   39 
   40     /*      EL3HLT  39      / * Level 3 halted                      */
   41     gf_error_to_errno_array[GF_ERROR_CODE_L3HLT] = EL3HLT;
   42     gf_errno_to_error_array[EL3HLT] = GF_ERROR_CODE_L3HLT;
   43 
   44     /*      EL3RST  40      / * Level 3 reset                       */
   45     gf_error_to_errno_array[GF_ERROR_CODE_L3RST] = EL3RST;
   46     gf_errno_to_error_array[EL3RST] = GF_ERROR_CODE_L3RST;
   47 
   48     /*      ELNRNG  41      / * Link number out of range            */
   49     gf_error_to_errno_array[GF_ERROR_CODE_LNRNG] = ELNRNG;
   50     gf_errno_to_error_array[ELNRNG] = GF_ERROR_CODE_LNRNG;
   51 
   52     /*      EUNATCH 42      / * Protocol driver not attached                */
   53     gf_error_to_errno_array[GF_ERROR_CODE_UNATCH] = EUNATCH;
   54     gf_errno_to_error_array[EUNATCH] = GF_ERROR_CODE_UNATCH;
   55 
   56     /*      ENOCSI  43      / * No CSI structure available          */
   57     gf_error_to_errno_array[GF_ERROR_CODE_NOCSI] = ENOCSI;
   58     gf_errno_to_error_array[ENOCSI] = GF_ERROR_CODE_NOCSI;
   59 
   60     /*      EL2HLT  44      / * Level 2 halted                      */
   61     gf_error_to_errno_array[GF_ERROR_CODE_L2HLT] = EL2HLT;
   62     gf_errno_to_error_array[EL2HLT] = GF_ERROR_CODE_L2HLT;
   63 
   64     /*      EDEADLK 45      / * Deadlock condition.                 */
   65     gf_error_to_errno_array[GF_ERROR_CODE_DEADLK] = EDEADLK;
   66     gf_errno_to_error_array[EDEADLK] = GF_ERROR_CODE_DEADLK;
   67 
   68     /*      ENOLCK  46      / * No record locks available.          */
   69     gf_error_to_errno_array[GF_ERROR_CODE_NOLCK] = ENOLCK;
   70     gf_errno_to_error_array[ENOLCK] = GF_ERROR_CODE_NOLCK;
   71 
   72     /*      ECANCELED 47    / * Operation canceled                  */
   73     gf_error_to_errno_array[GF_ERROR_CODE_CANCELED] = ECANCELED;
   74     gf_errno_to_error_array[ECANCELED] = GF_ERROR_CODE_CANCELED;
   75 
   76     /*      ENOTSUP 48      / * Operation not supported             */
   77     gf_error_to_errno_array[GF_ERROR_CODE_NOTSUPP] = ENOTSUP;
   78     gf_errno_to_error_array[ENOTSUP] = GF_ERROR_CODE_NOTSUPP;
   79 
   80     /* Filesystem Quotas */
   81     /*      EDQUOT  49      / * Disc quota exceeded                 */
   82     gf_error_to_errno_array[GF_ERROR_CODE_DQUOT] = EDQUOT;
   83     gf_errno_to_error_array[EDQUOT] = GF_ERROR_CODE_DQUOT;
   84 
   85     /* Convergent Error Returns */
   86     /*      EBADE   50      / * invalid exchange                    */
   87     gf_error_to_errno_array[GF_ERROR_CODE_BADE] = EBADE;
   88     gf_errno_to_error_array[EBADE] = GF_ERROR_CODE_BADE;
   89     /*      EBADR   51      / * invalid request descriptor          */
   90     gf_error_to_errno_array[GF_ERROR_CODE_BADR] = EBADR;
   91     gf_errno_to_error_array[EBADR] = GF_ERROR_CODE_BADR;
   92     /*      EXFULL  52      / * exchange full                       */
   93     gf_error_to_errno_array[GF_ERROR_CODE_XFULL] = EXFULL;
   94     gf_errno_to_error_array[EXFULL] = GF_ERROR_CODE_XFULL;
   95     /*      ENOANO  53      / * no anode                            */
   96     gf_error_to_errno_array[GF_ERROR_CODE_NOANO] = ENOANO;
   97     gf_errno_to_error_array[ENOANO] = GF_ERROR_CODE_NOANO;
   98     /*      EBADRQC 54      / * invalid request code                        */
   99     gf_error_to_errno_array[GF_ERROR_CODE_BADRQC] = EBADRQC;
  100     gf_errno_to_error_array[EBADRQC] = GF_ERROR_CODE_BADRQC;
  101     /*      EBADSLT 55      / * invalid slot                                */
  102     gf_error_to_errno_array[GF_ERROR_CODE_BADSLT] = EBADSLT;
  103     gf_errno_to_error_array[EBADSLT] = GF_ERROR_CODE_BADSLT;
  104     /*      EDEADLOCK 56    / * file locking deadlock error         */
  105     /* This is same as EDEADLK on linux */
  106     gf_error_to_errno_array[GF_ERROR_CODE_DEADLK] = EDEADLOCK;
  107     gf_errno_to_error_array[EDEADLOCK] = GF_ERROR_CODE_DEADLK;
  108 
  109     /*      EBFONT  57      / * bad font file fmt                   */
  110     gf_error_to_errno_array[GF_ERROR_CODE_BFONT] = EBFONT;
  111     gf_errno_to_error_array[EBFONT] = GF_ERROR_CODE_BFONT;
  112 
  113     /* Interprocess Robust Locks */
  114     /*      EOWNERDEAD      58      / * process died with the lock */
  115     gf_error_to_errno_array[GF_ERROR_CODE_OWNERDEAD] = EOWNERDEAD;
  116     gf_errno_to_error_array[EOWNERDEAD] = GF_ERROR_CODE_OWNERDEAD;
  117     /*      ENOTRECOVERABLE 59      / * lock is not recoverable */
  118     gf_error_to_errno_array[GF_ERROR_CODE_NOTRECOVERABLE] = ENOTRECOVERABLE;
  119     gf_errno_to_error_array[ENOTRECOVERABLE] = GF_ERROR_CODE_NOTRECOVERABLE;
  120 
  121     /* stream problems */
  122     /*      ENOSTR  60      / * Device not a stream                 */
  123     gf_error_to_errno_array[GF_ERROR_CODE_NOSTR] = ENOSTR;
  124     gf_errno_to_error_array[ENOSTR] = GF_ERROR_CODE_NOSTR;
  125     /*      ENODATA 61      / * no data (for no delay io)           */
  126     gf_error_to_errno_array[GF_ERROR_CODE_NODATA] = ENODATA;
  127     gf_errno_to_error_array[ENODATA] = GF_ERROR_CODE_NODATA;
  128     /*      ETIME   62      / * timer expired                       */
  129     gf_error_to_errno_array[GF_ERROR_CODE_TIME] = ETIME;
  130     gf_errno_to_error_array[ETIME] = GF_ERROR_CODE_TIME;
  131     /*      ENOSR   63      / * out of streams resources            */
  132     gf_error_to_errno_array[GF_ERROR_CODE_NOSR] = ENOSR;
  133     gf_errno_to_error_array[ENOSR] = GF_ERROR_CODE_NOSR;
  134 
  135     /*      ENONET  64      / * Machine is not on the network       */
  136     gf_error_to_errno_array[GF_ERROR_CODE_NONET] = ENONET;
  137     gf_errno_to_error_array[ENONET] = GF_ERROR_CODE_NONET;
  138     /*      ENOPKG  65      / * Package not installed               */
  139     gf_error_to_errno_array[GF_ERROR_CODE_NOPKG] = ENOPKG;
  140     gf_errno_to_error_array[ENOPKG] = GF_ERROR_CODE_NOPKG;
  141     /*      EREMOTE 66      / * The object is remote                        */
  142     gf_error_to_errno_array[GF_ERROR_CODE_REMOTE] = EREMOTE;
  143     gf_errno_to_error_array[EREMOTE] = GF_ERROR_CODE_REMOTE;
  144     /*      ENOLINK 67      / * the link has been severed           */
  145     gf_error_to_errno_array[GF_ERROR_CODE_NOLINK] = ENOLINK;
  146     gf_errno_to_error_array[ENOLINK] = GF_ERROR_CODE_NOLINK;
  147     /*      EADV    68      / * advertise error                     */
  148     gf_error_to_errno_array[GF_ERROR_CODE_ADV] = EADV;
  149     gf_errno_to_error_array[EADV] = GF_ERROR_CODE_ADV;
  150     /*      ESRMNT  69      / * srmount error                       */
  151     gf_error_to_errno_array[GF_ERROR_CODE_SRMNT] = ESRMNT;
  152     gf_errno_to_error_array[ESRMNT] = GF_ERROR_CODE_SRMNT;
  153 
  154     /*      ECOMM   70      / * Communication error on send         */
  155     gf_error_to_errno_array[GF_ERROR_CODE_COMM] = ECOMM;
  156     gf_errno_to_error_array[ECOMM] = GF_ERROR_CODE_COMM;
  157     /*      EPROTO  71      / * Protocol error                      */
  158     gf_error_to_errno_array[GF_ERROR_CODE_PROTO] = EPROTO;
  159     gf_errno_to_error_array[EPROTO] = GF_ERROR_CODE_PROTO;
  160 
  161     /* Interprocess Robust Locks */
  162     /*      ELOCKUNMAPPED   72      / * locked lock was unmapped */
  163     gf_error_to_errno_array[GF_ERROR_CODE_LOCKUNMAPPED] = ELOCKUNMAPPED;
  164     gf_errno_to_error_array[ELOCKUNMAPPED] = GF_ERROR_CODE_LOCKUNMAPPED;
  165 
  166     /*      ENOTACTIVE 73   / * Facility is not active              */
  167     gf_error_to_errno_array[GF_ERROR_CODE_NOTACTIVE] = ENOTACTIVE;
  168     gf_errno_to_error_array[ENOTACTIVE] = GF_ERROR_CODE_NOTACTIVE;
  169     /*      EMULTIHOP 74    / * multihop attempted                  */
  170     gf_error_to_errno_array[GF_ERROR_CODE_MULTIHOP] = EMULTIHOP;
  171     gf_errno_to_error_array[EMULTIHOP] = GF_ERROR_CODE_MULTIHOP;
  172     /*      EBADMSG 77      / * trying to read unreadable message   */
  173     gf_error_to_errno_array[GF_ERROR_CODE_BADMSG] = EBADMSG;
  174     gf_errno_to_error_array[EBADMSG] = GF_ERROR_CODE_BADMSG;
  175     /*      ENAMETOOLONG 78 / * path name is too long               */
  176     gf_error_to_errno_array[GF_ERROR_CODE_NAMETOOLONG] = ENAMETOOLONG;
  177     gf_errno_to_error_array[ENAMETOOLONG] = GF_ERROR_CODE_NAMETOOLONG;
  178     /*      EOVERFLOW 79    / * value too large to be stored in data type */
  179     gf_error_to_errno_array[GF_ERROR_CODE_OVERFLOW] = EOVERFLOW;
  180     gf_errno_to_error_array[EOVERFLOW] = GF_ERROR_CODE_OVERFLOW;
  181     /*      ENOTUNIQ 80     / * given log. name not unique          */
  182     gf_error_to_errno_array[GF_ERROR_CODE_NOTUNIQ] = ENOTUNIQ;
  183     gf_errno_to_error_array[ENOTUNIQ] = GF_ERROR_CODE_NOTUNIQ;
  184     /*      EBADFD  81      / * f.d. invalid for this operation     */
  185     gf_error_to_errno_array[GF_ERROR_CODE_BADFD] = EBADFD;
  186     gf_errno_to_error_array[EBADFD] = GF_ERROR_CODE_BADFD;
  187     /*      EREMCHG 82      / * Remote address changed              */
  188     gf_error_to_errno_array[GF_ERROR_CODE_REMCHG] = EREMCHG;
  189     gf_errno_to_error_array[EREMCHG] = GF_ERROR_CODE_REMCHG;
  190 
  191     /* shared library problems */
  192     /*      ELIBACC 83      / * Can't access a needed shared lib.   */
  193     gf_error_to_errno_array[GF_ERROR_CODE_LIBACC] = ELIBACC;
  194     gf_errno_to_error_array[ELIBACC] = GF_ERROR_CODE_LIBACC;
  195     /*      ELIBBAD 84      / * Accessing a corrupted shared lib.   */
  196     gf_error_to_errno_array[GF_ERROR_CODE_LIBBAD] = ELIBBAD;
  197     gf_errno_to_error_array[ELIBBAD] = GF_ERROR_CODE_LIBBAD;
  198     /*      ELIBSCN 85      / * .lib section in a.out corrupted.    */
  199     gf_error_to_errno_array[GF_ERROR_CODE_LIBSCN] = ELIBSCN;
  200     gf_errno_to_error_array[ELIBSCN] = GF_ERROR_CODE_LIBSCN;
  201     /*      ELIBMAX 86      / * Attempting to link in too many libs.        */
  202     gf_error_to_errno_array[GF_ERROR_CODE_LIBMAX] = ELIBMAX;
  203     gf_errno_to_error_array[ELIBMAX] = GF_ERROR_CODE_LIBMAX;
  204     /*      ELIBEXEC 87     / * Attempting to exec a shared library.        */
  205     gf_error_to_errno_array[GF_ERROR_CODE_LIBEXEC] = ELIBEXEC;
  206     gf_errno_to_error_array[ELIBEXEC] = GF_ERROR_CODE_LIBEXEC;
  207     /*      EILSEQ  88      / * Illegal byte sequence.              */
  208     gf_error_to_errno_array[GF_ERROR_CODE_ILSEQ] = EILSEQ;
  209     gf_errno_to_error_array[EILSEQ] = GF_ERROR_CODE_ILSEQ;
  210     /*      ENOSYS  89      / * Unsupported file system operation   */
  211     gf_error_to_errno_array[GF_ERROR_CODE_NOSYS] = ENOSYS;
  212     gf_errno_to_error_array[ENOSYS] = GF_ERROR_CODE_NOSYS;
  213     /*      ELOOP   90      / * Symbolic link loop                  */
  214     gf_error_to_errno_array[GF_ERROR_CODE_LOOP] = ELOOP;
  215     gf_errno_to_error_array[ELOOP] = GF_ERROR_CODE_LOOP;
  216     /*      ERESTART 91     / * Restartable system call             */
  217     gf_error_to_errno_array[GF_ERROR_CODE_RESTART] = ERESTART;
  218     gf_errno_to_error_array[ERESTART] = GF_ERROR_CODE_RESTART;
  219     /*      ESTRPIPE 92     / * if pipe/FIFO, don't sleep in stream head */
  220     gf_error_to_errno_array[GF_ERROR_CODE_STRPIPE] = ESTRPIPE;
  221     gf_errno_to_error_array[ESTRPIPE] = GF_ERROR_CODE_STRPIPE;
  222     /*      ENOTEMPTY 93    / * directory not empty                 */
  223     gf_error_to_errno_array[GF_ERROR_CODE_NOTEMPTY] = ENOTEMPTY;
  224     gf_errno_to_error_array[ENOTEMPTY] = GF_ERROR_CODE_NOTEMPTY;
  225     /*      EUSERS  94      / * Too many users (for UFS)            */
  226     gf_error_to_errno_array[GF_ERROR_CODE_USERS] = EUSERS;
  227     gf_errno_to_error_array[EUSERS] = GF_ERROR_CODE_USERS;
  228 
  229     /* BSD Networking Software */
  230     /* argument errors */
  231     /*      ENOTSOCK        95      / * Socket operation on non-socket */
  232     gf_error_to_errno_array[GF_ERROR_CODE_NOTSOCK] = ENOTSOCK;
  233     gf_errno_to_error_array[ENOTSOCK] = GF_ERROR_CODE_NOTSOCK;
  234     /*      EDESTADDRREQ    96      / * Destination address required */
  235     gf_error_to_errno_array[GF_ERROR_CODE_DESTADDRREQ] = EDESTADDRREQ;
  236     gf_errno_to_error_array[EDESTADDRREQ] = GF_ERROR_CODE_DESTADDRREQ;
  237     /*      EMSGSIZE        97      / * Message too long */
  238     gf_error_to_errno_array[GF_ERROR_CODE_MSGSIZE] = EMSGSIZE;
  239     gf_errno_to_error_array[EMSGSIZE] = GF_ERROR_CODE_MSGSIZE;
  240     /*      EPROTOTYPE      98      / * Protocol wrong type for socket */
  241     gf_error_to_errno_array[GF_ERROR_CODE_PROTOTYPE] = EPROTOTYPE;
  242     gf_errno_to_error_array[EPROTOTYPE] = GF_ERROR_CODE_PROTOTYPE;
  243     /*      ENOPROTOOPT     99      / * Protocol not available */
  244     gf_error_to_errno_array[GF_ERROR_CODE_NOPROTOOPT] = ENOPROTOOPT;
  245     gf_errno_to_error_array[ENOPROTOOPT] = GF_ERROR_CODE_NOPROTOOPT;
  246     /*      EPROTONOSUPPORT 120     / * Protocol not supported */
  247     gf_error_to_errno_array[GF_ERROR_CODE_PROTONOSUPPORT] = EPROTONOSUPPORT;
  248     gf_errno_to_error_array[EPROTONOSUPPORT] = GF_ERROR_CODE_PROTONOSUPPORT;
  249     /*      ESOCKTNOSUPPORT 121     / * Socket type not supported */
  250     gf_error_to_errno_array[GF_ERROR_CODE_SOCKTNOSUPPORT] = ESOCKTNOSUPPORT;
  251     gf_errno_to_error_array[ESOCKTNOSUPPORT] = GF_ERROR_CODE_SOCKTNOSUPPORT;
  252 
  253     /*      EOPNOTSUPP      122     / * Operation not supported on socket */
  254     gf_error_to_errno_array[GF_ERROR_CODE_OPNOTSUPP] = EOPNOTSUPP;
  255     gf_errno_to_error_array[EOPNOTSUPP] = GF_ERROR_CODE_OPNOTSUPP;
  256     /*      EPFNOSUPPORT    123     / * Protocol family not supported */
  257     gf_error_to_errno_array[GF_ERROR_CODE_PFNOSUPPORT] = EPFNOSUPPORT;
  258     gf_errno_to_error_array[EPFNOSUPPORT] = GF_ERROR_CODE_PFNOSUPPORT;
  259     /*      EAFNOSUPPORT    124     / * Address family not supported by */
  260     /* protocol family */
  261     gf_error_to_errno_array[GF_ERROR_CODE_AFNOSUPPORT] = EAFNOSUPPORT;
  262     gf_errno_to_error_array[EAFNOSUPPORT] = GF_ERROR_CODE_AFNOSUPPORT;
  263     /*      EADDRINUSE      125     / * Address already in use */
  264     gf_error_to_errno_array[GF_ERROR_CODE_ADDRINUSE] = EADDRINUSE;
  265     gf_errno_to_error_array[EADDRINUSE] = GF_ERROR_CODE_ADDRINUSE;
  266     /*      EADDRNOTAVAIL   126     / * Can't assign requested address */
  267     /* operational errors */
  268     gf_error_to_errno_array[GF_ERROR_CODE_ADDRNOTAVAIL] = EADDRNOTAVAIL;
  269     gf_errno_to_error_array[EADDRNOTAVAIL] = GF_ERROR_CODE_ADDRNOTAVAIL;
  270     /*      ENETDOWN        127     / * Network is down */
  271     gf_error_to_errno_array[GF_ERROR_CODE_NETDOWN] = ENETDOWN;
  272     gf_errno_to_error_array[ENETDOWN] = GF_ERROR_CODE_NETDOWN;
  273     /*      ENETUNREACH     128     / * Network is unreachable */
  274     gf_error_to_errno_array[GF_ERROR_CODE_NETUNREACH] = ENETUNREACH;
  275     gf_errno_to_error_array[ENETUNREACH] = GF_ERROR_CODE_NETUNREACH;
  276     /*      ENETRESET       129     / * Network dropped connection because */
  277     /* of reset */
  278     gf_error_to_errno_array[GF_ERROR_CODE_NETRESET] = ENETRESET;
  279     gf_errno_to_error_array[ENETRESET] = GF_ERROR_CODE_NETRESET;
  280     /*      ECONNABORTED    130     / * Software caused connection abort */
  281     gf_error_to_errno_array[GF_ERROR_CODE_CONNABORTED] = ECONNABORTED;
  282     gf_errno_to_error_array[ECONNABORTED] = GF_ERROR_CODE_CONNABORTED;
  283     /*      ECONNRESET      131     / * Connection reset by peer */
  284     gf_error_to_errno_array[GF_ERROR_CODE_CONNRESET] = ECONNRESET;
  285     gf_errno_to_error_array[ECONNRESET] = GF_ERROR_CODE_CONNRESET;
  286     /*      ENOBUFS         132     / * No buffer space available */
  287     gf_error_to_errno_array[GF_ERROR_CODE_NOBUFS] = ENOBUFS;
  288     gf_errno_to_error_array[ENOBUFS] = GF_ERROR_CODE_NOBUFS;
  289     /*      EISCONN         133     / * Socket is already connected */
  290     gf_error_to_errno_array[GF_ERROR_CODE_ISCONN] = EISCONN;
  291     gf_errno_to_error_array[EISCONN] = GF_ERROR_CODE_ISCONN;
  292     /*      ENOTCONN        134     / * Socket is not connected */
  293     gf_error_to_errno_array[GF_ERROR_CODE_NOTCONN] = ENOTCONN;
  294     gf_errno_to_error_array[ENOTCONN] = GF_ERROR_CODE_NOTCONN;
  295     /* XENIX has 135 - 142 */
  296     /*      ESHUTDOWN       143     / * Can't send after socket shutdown */
  297     gf_error_to_errno_array[GF_ERROR_CODE_SHUTDOWN] = ESHUTDOWN;
  298     gf_errno_to_error_array[ESHUTDOWN] = GF_ERROR_CODE_SHUTDOWN;
  299     /*      ETOOMANYREFS    144     / * Too many references: can't splice */
  300     gf_error_to_errno_array[GF_ERROR_CODE_TOOMANYREFS] = ETOOMANYREFS;
  301     gf_errno_to_error_array[ETOOMANYREFS] = GF_ERROR_CODE_TOOMANYREFS;
  302     /*      ETIMEDOUT       145     / * Connection timed out */
  303     gf_error_to_errno_array[GF_ERROR_CODE_TIMEDOUT] = ETIMEDOUT;
  304     gf_errno_to_error_array[ETIMEDOUT] = GF_ERROR_CODE_TIMEDOUT;
  305 
  306     /*      ECONNREFUSED    146     / * Connection refused */
  307     gf_error_to_errno_array[GF_ERROR_CODE_CONNREFUSED] = ECONNREFUSED;
  308     gf_errno_to_error_array[ECONNREFUSED] = GF_ERROR_CODE_CONNREFUSED;
  309     /*      EHOSTDOWN       147     / * Host is down */
  310     gf_error_to_errno_array[GF_ERROR_CODE_HOSTDOWN] = EHOSTDOWN;
  311     gf_errno_to_error_array[EHOSTDOWN] = GF_ERROR_CODE_HOSTDOWN;
  312     /*      EHOSTUNREACH    148     / * No route to host */
  313     gf_error_to_errno_array[GF_ERROR_CODE_HOSTUNREACH] = EHOSTUNREACH;
  314     gf_errno_to_error_array[EHOSTUNREACH] = GF_ERROR_CODE_HOSTUNREACH;
  315     /*      EALREADY        149     / * operation already in progress */
  316     gf_error_to_errno_array[GF_ERROR_CODE_ALREADY] = EALREADY;
  317     gf_errno_to_error_array[EALREADY] = GF_ERROR_CODE_ALREADY;
  318     /*      EINPROGRESS     150     / * operation now in progress */
  319     gf_error_to_errno_array[GF_ERROR_CODE_INPROGRESS] = EINPROGRESS;
  320     gf_errno_to_error_array[EINPROGRESS] = GF_ERROR_CODE_INPROGRESS;
  321 
  322     /* SUN Network File System */
  323     /*      ESTALE          151     / * Stale NFS file handle */
  324     gf_error_to_errno_array[GF_ERROR_CODE_STALE] = ESTALE;
  325     gf_errno_to_error_array[ESTALE] = GF_ERROR_CODE_STALE;
  326 
  327     return;
  328 }
  329 #endif /* GF_SOLARIS_HOST_OS */
  330 
  331 #ifdef GF_DARWIN_HOST_OS
  332 static void
  333 init_compat_errno_arrays()
  334 {
  335     /*    EDEADLK         11              / * Resource deadlock would occur */
  336     gf_error_to_errno_array[GF_ERROR_CODE_DEADLK] = EDEADLK;
  337     gf_errno_to_error_array[EDEADLK] = GF_ERROR_CODE_DEADLK;
  338 
  339     /*    EAGAIN          35              / * Try Again */
  340     gf_error_to_errno_array[GF_ERROR_CODE_AGAIN] = EAGAIN;
  341     gf_errno_to_error_array[EAGAIN] = GF_ERROR_CODE_AGAIN;
  342 
  343     /*      EINPROGRESS     36              / * Operation now in progress */
  344     gf_error_to_errno_array[GF_ERROR_CODE_INPROGRESS] = EINPROGRESS;
  345     gf_errno_to_error_array[EINPROGRESS] = GF_ERROR_CODE_INPROGRESS;
  346 
  347     /*      EALREADY        37              / * Operation already in progress */
  348     gf_error_to_errno_array[GF_ERROR_CODE_ALREADY] = EALREADY;
  349     gf_errno_to_error_array[EALREADY] = GF_ERROR_CODE_ALREADY;
  350 
  351     /*      ENOTSOCK        38              / * Socket operation on non-socket
  352      */
  353     gf_error_to_errno_array[GF_ERROR_CODE_NOTSOCK] = ENOTSOCK;
  354     gf_errno_to_error_array[ENOTSOCK] = GF_ERROR_CODE_NOTSOCK;
  355 
  356     /*      EDESTADDRREQ    39              / * Destination address required */
  357     gf_error_to_errno_array[GF_ERROR_CODE_DESTADDRREQ] = EDESTADDRREQ;
  358     gf_errno_to_error_array[EDESTADDRREQ] = GF_ERROR_CODE_DESTADDRREQ;
  359 
  360     /*      EMSGSIZE        40              / * Message too long */
  361     gf_error_to_errno_array[GF_ERROR_CODE_MSGSIZE] = EMSGSIZE;
  362     gf_errno_to_error_array[EMSGSIZE] = GF_ERROR_CODE_MSGSIZE;
  363 
  364     /*      EPROTOTYPE      41              / * Protocol wrong type for socket
  365      */
  366     gf_error_to_errno_array[GF_ERROR_CODE_PROTOTYPE] = EPROTOTYPE;
  367     gf_errno_to_error_array[EPROTOTYPE] = GF_ERROR_CODE_PROTOTYPE;
  368 
  369     /*      ENOPROTOOPT     42              / * Protocol not available */
  370     gf_error_to_errno_array[GF_ERROR_CODE_NOPROTOOPT] = ENOPROTOOPT;
  371     gf_errno_to_error_array[ENOPROTOOPT] = GF_ERROR_CODE_NOPROTOOPT;
  372 
  373     /*      EPROTONOSUPPORT 43              / * Protocol not supported */
  374     gf_error_to_errno_array[GF_ERROR_CODE_PROTONOSUPPORT] = EPROTONOSUPPORT;
  375     gf_errno_to_error_array[EPROTONOSUPPORT] = GF_ERROR_CODE_PROTONOSUPPORT;
  376 
  377     /*      ESOCKTNOSUPPORT 44              / * Socket type not supported */
  378     gf_error_to_errno_array[GF_ERROR_CODE_SOCKTNOSUPPORT] = ESOCKTNOSUPPORT;
  379     gf_errno_to_error_array[ESOCKTNOSUPPORT] = GF_ERROR_CODE_SOCKTNOSUPPORT;
  380 
  381     /*      EOPNOTSUPP      45              / * Operation not supported */
  382     gf_error_to_errno_array[GF_ERROR_CODE_OPNOTSUPP] = EOPNOTSUPP;
  383     gf_errno_to_error_array[EOPNOTSUPP] = GF_ERROR_CODE_OPNOTSUPP;
  384 
  385     /*      EPFNOSUPPORT    46              / * Protocol family not supported */
  386     gf_error_to_errno_array[GF_ERROR_CODE_PFNOSUPPORT] = EPFNOSUPPORT;
  387     gf_errno_to_error_array[EPFNOSUPPORT] = GF_ERROR_CODE_PFNOSUPPORT;
  388 
  389     /*      EAFNOSUPPORT    47              / * Address family not supported by
  390      * protocol family */
  391     gf_error_to_errno_array[GF_ERROR_CODE_AFNOSUPPORT] = EAFNOSUPPORT;
  392     gf_errno_to_error_array[EAFNOSUPPORT] = GF_ERROR_CODE_AFNOSUPPORT;
  393 
  394     /*      EADDRINUSE      48              / * Address already in use */
  395     gf_error_to_errno_array[GF_ERROR_CODE_ADDRINUSE] = EADDRINUSE;
  396     gf_errno_to_error_array[EADDRINUSE] = GF_ERROR_CODE_ADDRINUSE;
  397 
  398     /*      EADDRNOTAVAIL   49              / * Can't assign requested address
  399      */
  400     gf_error_to_errno_array[GF_ERROR_CODE_ADDRNOTAVAIL] = EADDRNOTAVAIL;
  401     gf_errno_to_error_array[EADDRNOTAVAIL] = GF_ERROR_CODE_ADDRNOTAVAIL;
  402 
  403     /*      ENETDOWN        50              / * Network is down */
  404     gf_error_to_errno_array[GF_ERROR_CODE_NETDOWN] = ENETDOWN;
  405     gf_errno_to_error_array[ENETDOWN] = GF_ERROR_CODE_NETDOWN;
  406 
  407     /*      ENETUNREACH     51              / * Network is unreachable */
  408     gf_error_to_errno_array[GF_ERROR_CODE_NETUNREACH] = ENETUNREACH;
  409     gf_errno_to_error_array[ENETUNREACH] = GF_ERROR_CODE_NETUNREACH;
  410 
  411     /*      ENETRESET       52              / * Network dropped connection on
  412      * reset */
  413     gf_error_to_errno_array[GF_ERROR_CODE_NETRESET] = ENETRESET;
  414     gf_errno_to_error_array[ENETRESET] = GF_ERROR_CODE_NETRESET;
  415 
  416     /*      ECONNABORTED    53              / * Software caused connection abort
  417      */
  418     gf_error_to_errno_array[GF_ERROR_CODE_CONNABORTED] = ECONNABORTED;
  419     gf_errno_to_error_array[ECONNABORTED] = GF_ERROR_CODE_CONNABORTED;
  420 
  421     /*      ECONNRESET      54              / * Connection reset by peer */
  422     gf_error_to_errno_array[GF_ERROR_CODE_CONNRESET] = ECONNRESET;
  423     gf_errno_to_error_array[ECONNRESET] = GF_ERROR_CODE_CONNRESET;
  424 
  425     /*      ENOBUFS         55              / * No buffer space available */
  426     gf_error_to_errno_array[GF_ERROR_CODE_NOBUFS] = ENOBUFS;
  427     gf_errno_to_error_array[ENOBUFS] = GF_ERROR_CODE_NOBUFS;
  428 
  429     /*      EISCONN         56              / * Socket is already connected */
  430     gf_error_to_errno_array[GF_ERROR_CODE_ISCONN] = EISCONN;
  431     gf_errno_to_error_array[EISCONN] = GF_ERROR_CODE_ISCONN;
  432 
  433     /*      ENOTCONN        57              / * Socket is not connected */
  434     gf_error_to_errno_array[GF_ERROR_CODE_NOTCONN] = ENOTCONN;
  435     gf_errno_to_error_array[ENOTCONN] = GF_ERROR_CODE_NOTCONN;
  436 
  437     /*      ESHUTDOWN       58              / * Can't send after socket shutdown
  438      */
  439     gf_error_to_errno_array[GF_ERROR_CODE_SHUTDOWN] = ESHUTDOWN;
  440     gf_errno_to_error_array[ESHUTDOWN] = GF_ERROR_CODE_SHUTDOWN;
  441 
  442     /*      ETOOMANYREFS    59              / * Too many references: can't
  443      * splice */
  444     gf_error_to_errno_array[GF_ERROR_CODE_TOOMANYREFS] = ETOOMANYREFS;
  445     gf_errno_to_error_array[ETOOMANYREFS] = GF_ERROR_CODE_TOOMANYREFS;
  446 
  447     /*      ETIMEDOUT       60              / * Operation timed out */
  448     gf_error_to_errno_array[GF_ERROR_CODE_TIMEDOUT] = ETIMEDOUT;
  449     gf_errno_to_error_array[ETIMEDOUT] = GF_ERROR_CODE_TIMEDOUT;
  450 
  451     /*      ECONNREFUSED    61              / * Connection refused */
  452     gf_error_to_errno_array[GF_ERROR_CODE_CONNREFUSED] = ECONNREFUSED;
  453     gf_errno_to_error_array[ECONNREFUSED] = GF_ERROR_CODE_CONNREFUSED;
  454 
  455     /*      ELOOP           62              / * Too many levels of symbolic
  456      * links */
  457     gf_error_to_errno_array[GF_ERROR_CODE_LOOP] = ELOOP;
  458     gf_errno_to_error_array[ELOOP] = GF_ERROR_CODE_LOOP;
  459 
  460     /*      ENAMETOOLONG    63              / * File name too long */
  461     gf_error_to_errno_array[GF_ERROR_CODE_NAMETOOLONG] = ENAMETOOLONG;
  462     gf_errno_to_error_array[ENAMETOOLONG] = GF_ERROR_CODE_NAMETOOLONG;
  463 
  464     /*      EHOSTDOWN       64              / * Host is down */
  465     gf_error_to_errno_array[GF_ERROR_CODE_HOSTDOWN] = EHOSTDOWN;
  466     gf_errno_to_error_array[EHOSTDOWN] = GF_ERROR_CODE_HOSTDOWN;
  467 
  468     /*      EHOSTUNREACH    65              / * No route to host */
  469     gf_error_to_errno_array[GF_ERROR_CODE_HOSTUNREACH] = EHOSTUNREACH;
  470     gf_errno_to_error_array[EHOSTUNREACH] = GF_ERROR_CODE_HOSTUNREACH;
  471 
  472     /*      ENOTEMPTY       66              / * Directory not empty */
  473     gf_error_to_errno_array[GF_ERROR_CODE_NOTEMPTY] = ENOTEMPTY;
  474     gf_errno_to_error_array[ENOTEMPTY] = GF_ERROR_CODE_NOTEMPTY;
  475 
  476     /*      EPROCLIM        67              / * Too many processes */
  477     gf_error_to_errno_array[GF_ERROR_CODE_PROCLIM] = EPROCLIM;
  478     gf_errno_to_error_array[EPROCLIM] = GF_ERROR_CODE_PROCLIM;
  479 
  480     /*      EUSERS          68              / * Too many users */
  481     gf_error_to_errno_array[GF_ERROR_CODE_USERS] = EUSERS;
  482     gf_errno_to_error_array[EUSERS] = GF_ERROR_CODE_USERS;
  483 
  484     /*      EDQUOT          69              / * Disc quota exceeded */
  485     gf_error_to_errno_array[GF_ERROR_CODE_DQUOT] = EDQUOT;
  486     gf_errno_to_error_array[EDQUOT] = GF_ERROR_CODE_DQUOT;
  487 
  488     /*      ESTALE          70              / * Stale NFS file handle */
  489     gf_error_to_errno_array[GF_ERROR_CODE_STALE] = ESTALE;
  490     gf_errno_to_error_array[ESTALE] = GF_ERROR_CODE_STALE;
  491 
  492     /*      EREMOTE         71              / * Too many levels of remote in
  493      * path */
  494     gf_error_to_errno_array[GF_ERROR_CODE_REMOTE] = EREMOTE;
  495     gf_errno_to_error_array[EREMOTE] = GF_ERROR_CODE_REMOTE;
  496 
  497     /*      EBADRPC         72              / * RPC struct is bad */
  498     gf_error_to_errno_array[GF_ERROR_CODE_BADRPC] = EBADRPC;
  499     gf_errno_to_error_array[EBADRPC] = GF_ERROR_CODE_BADRPC;
  500 
  501     /*      ERPCMISMATCH    73              / * RPC version wrong */
  502     gf_error_to_errno_array[GF_ERROR_CODE_RPCMISMATCH] = ERPCMISMATCH;
  503     gf_errno_to_error_array[ERPCMISMATCH] = GF_ERROR_CODE_RPCMISMATCH;
  504 
  505     /*      EPROGUNAVAIL    74              / * RPC prog. not avail */
  506     gf_error_to_errno_array[GF_ERROR_CODE_PROGUNAVAIL] = EPROGUNAVAIL;
  507     gf_errno_to_error_array[EPROGUNAVAIL] = GF_ERROR_CODE_PROGUNAVAIL;
  508 
  509     /*      EPROGMISMATCH   75              / * Program version wrong */
  510     gf_error_to_errno_array[GF_ERROR_CODE_PROGMISMATCH] = EPROGMISMATCH;
  511     gf_errno_to_error_array[EPROGMISMATCH] = GF_ERROR_CODE_PROGMISMATCH;
  512 
  513     /*      EPROCUNAVAIL    76              / * Bad procedure for program */
  514     gf_error_to_errno_array[GF_ERROR_CODE_PROCUNAVAIL] = EPROCUNAVAIL;
  515     gf_errno_to_error_array[EPROCUNAVAIL] = GF_ERROR_CODE_PROCUNAVAIL;
  516 
  517     /*      ENOLCK          77              / * No locks available */
  518     gf_error_to_errno_array[GF_ERROR_CODE_NOLCK] = ENOLCK;
  519     gf_errno_to_error_array[ENOLCK] = GF_ERROR_CODE_NOLCK;
  520 
  521     /*      ENOSYS          78              / * Function not implemented */
  522     gf_error_to_errno_array[GF_ERROR_CODE_NOSYS] = ENOSYS;
  523     gf_errno_to_error_array[ENOSYS] = GF_ERROR_CODE_NOSYS;
  524 
  525     /*      EFTYPE          79              / * Inappropriate file type or
  526      * format */
  527     gf_error_to_errno_array[GF_ERROR_CODE_FTYPE] = EFTYPE;
  528     gf_errno_to_error_array[EFTYPE] = GF_ERROR_CODE_FTYPE;
  529 
  530     /*      EAUTH           80              / * Authentication error */
  531     gf_error_to_errno_array[GF_ERROR_CODE_AUTH] = EAUTH;
  532     gf_errno_to_error_array[EAUTH] = GF_ERROR_CODE_AUTH;
  533 
  534     /*      ENEEDAUTH       81              / * Need authenticator */
  535     gf_error_to_errno_array[GF_ERROR_CODE_NEEDAUTH] = ENEEDAUTH;
  536     gf_errno_to_error_array[ENEEDAUTH] = GF_ERROR_CODE_NEEDAUTH;
  537     /* Intelligent device errors */
  538     /*      EPWROFF         82      / * Device power is off */
  539     gf_error_to_errno_array[GF_ERROR_CODE_PWROFF] = EPWROFF;
  540     gf_errno_to_error_array[EPWROFF] = GF_ERROR_CODE_PWROFF;
  541     /*      EDEVERR         83      / * Device error, e.g. paper out */
  542     gf_error_to_errno_array[GF_ERROR_CODE_DEVERR] = EDEVERR;
  543     gf_errno_to_error_array[EDEVERR] = GF_ERROR_CODE_DEVERR;
  544 
  545     /*      EOVERFLOW       84              / * Value too large to be stored in
  546      * data type */
  547     gf_error_to_errno_array[GF_ERROR_CODE_OVERFLOW] = EOVERFLOW;
  548     gf_errno_to_error_array[EOVERFLOW] = GF_ERROR_CODE_OVERFLOW;
  549 
  550     /* Program loading errors */
  551     /*   EBADEXEC   85      / * Bad executable */
  552     gf_error_to_errno_array[GF_ERROR_CODE_BADEXEC] = EBADEXEC;
  553     gf_errno_to_error_array[EBADEXEC] = GF_ERROR_CODE_BADEXEC;
  554 
  555     /*   EBADARCH   86      / * Bad CPU type in executable */
  556     gf_error_to_errno_array[GF_ERROR_CODE_BADARCH] = EBADARCH;
  557     gf_errno_to_error_array[EBADARCH] = GF_ERROR_CODE_BADARCH;
  558 
  559     /*   ESHLIBVERS 87      / * Shared library version mismatch */
  560     gf_error_to_errno_array[GF_ERROR_CODE_SHLIBVERS] = ESHLIBVERS;
  561     gf_errno_to_error_array[ESHLIBVERS] = GF_ERROR_CODE_SHLIBVERS;
  562 
  563     /*   EBADMACHO  88      / * Malformed Macho file */
  564     gf_error_to_errno_array[GF_ERROR_CODE_BADMACHO] = EBADMACHO;
  565     gf_errno_to_error_array[EBADMACHO] = GF_ERROR_CODE_BADMACHO;
  566 
  567 #ifdef EDOOFUS
  568     /*    EDOOFUS           88              / * Programming error */
  569     gf_error_to_errno_array[GF_ERROR_CODE_DOOFUS] = EDOOFUS;
  570     gf_errno_to_error_array[EDOOFUS] = GF_ERROR_CODE_DOOFUS;
  571 #endif
  572 
  573     /*      ECANCELED       89              / * Operation canceled */
  574     gf_error_to_errno_array[GF_ERROR_CODE_CANCELED] = ECANCELED;
  575     gf_errno_to_error_array[ECANCELED] = GF_ERROR_CODE_CANCELED;
  576 
  577     /*   EIDRM              90              / * Identifier removed */
  578     gf_error_to_errno_array[GF_ERROR_CODE_IDRM] = EIDRM;
  579     gf_errno_to_error_array[EIDRM] = GF_ERROR_CODE_IDRM;
  580     /*   ENOMSG             91              / * No message of desired type */
  581     gf_error_to_errno_array[GF_ERROR_CODE_NOMSG] = ENOMSG;
  582     gf_errno_to_error_array[ENOMSG] = GF_ERROR_CODE_NOMSG;
  583 
  584     /*   EILSEQ             92              / * Illegal byte sequence */
  585     gf_error_to_errno_array[GF_ERROR_CODE_ILSEQ] = EILSEQ;
  586     gf_errno_to_error_array[EILSEQ] = GF_ERROR_CODE_ILSEQ;
  587 
  588     /*   ENOATTR            93              / * Attribute not found */
  589     gf_error_to_errno_array[GF_ERROR_CODE_NOATTR] = ENOATTR;
  590     gf_errno_to_error_array[ENOATTR] = GF_ERROR_CODE_NOATTR;
  591 
  592     /*   EBADMSG            94              / * Bad message */
  593     gf_error_to_errno_array[GF_ERROR_CODE_BADMSG] = EBADMSG;
  594     gf_errno_to_error_array[EBADMSG] = GF_ERROR_CODE_BADMSG;
  595 
  596     /*   EMULTIHOP  95              / * Reserved */
  597     gf_error_to_errno_array[GF_ERROR_CODE_MULTIHOP] = EMULTIHOP;
  598     gf_errno_to_error_array[EMULTIHOP] = GF_ERROR_CODE_MULTIHOP;
  599 
  600     /*      ENODATA         96              / * No message available on STREAM
  601      */
  602     gf_error_to_errno_array[GF_ERROR_CODE_NEEDAUTH] = ENEEDAUTH;
  603     gf_errno_to_error_array[ENEEDAUTH] = GF_ERROR_CODE_NEEDAUTH;
  604 
  605     /*   ENOLINK            97              / * Reserved */
  606     gf_error_to_errno_array[GF_ERROR_CODE_NOLINK] = ENOLINK;
  607     gf_errno_to_error_array[ENOLINK] = GF_ERROR_CODE_NOLINK;
  608 
  609     /*   ENOSR              98              / * No STREAM resources */
  610     gf_error_to_errno_array[GF_ERROR_CODE_NOSR] = ENOSR;
  611     gf_errno_to_error_array[ENOSR] = GF_ERROR_CODE_NOSR;
  612 
  613     /*   ENOSTR             99              / * Not a STREAM */
  614     gf_error_to_errno_array[GF_ERROR_CODE_NOSTR] = ENOSTR;
  615     gf_errno_to_error_array[ENOSTR] = GF_ERROR_CODE_NOSTR;
  616 
  617     /*      EPROTO          100             / * Protocol error */
  618     gf_error_to_errno_array[GF_ERROR_CODE_PROTO] = EPROTO;
  619     gf_errno_to_error_array[EPROTO] = GF_ERROR_CODE_PROTO;
  620     /*   ETIME              101             / * STREAM ioctl timeout */
  621     gf_error_to_errno_array[GF_ERROR_CODE_TIME] = ETIME;
  622     gf_errno_to_error_array[ETIME] = GF_ERROR_CODE_TIME;
  623 
  624     /* This value is only discrete when compiling __DARWIN_UNIX03, or KERNEL */
  625     /*      EOPNOTSUPP      102             / * Operation not supported on
  626      * socket */
  627     gf_error_to_errno_array[GF_ERROR_CODE_OPNOTSUPP] = EOPNOTSUPP;
  628     gf_errno_to_error_array[EOPNOTSUPP] = GF_ERROR_CODE_OPNOTSUPP;
  629 
  630     /*   ENOPOLICY  103             / * No such policy registered */
  631     gf_error_to_errno_array[GF_ERROR_CODE_NOPOLICY] = ENOPOLICY;
  632     gf_errno_to_error_array[ENOPOLICY] = GF_ERROR_CODE_NOPOLICY;
  633 
  634     return;
  635 }
  636 #endif /* GF_DARWIN_HOST_OS */
  637 
  638 #ifdef GF_BSD_HOST_OS
  639 static void
  640 init_compat_errno_arrays()
  641 {
  642     /* Quite a bit of things changed in FreeBSD - current */
  643 
  644     /*    EAGAIN          35              / * Try Again */
  645     gf_error_to_errno_array[GF_ERROR_CODE_AGAIN] = EAGAIN;
  646     gf_errno_to_error_array[EAGAIN] = GF_ERROR_CODE_AGAIN;
  647 
  648     /*    EDEADLK         11              / * Resource deadlock would occur */
  649     gf_error_to_errno_array[GF_ERROR_CODE_DEADLK] = EDEADLK;
  650     gf_errno_to_error_array[EDEADLK] = GF_ERROR_CODE_DEADLK;
  651 
  652     /*      EINPROGRESS     36              / * Operation now in progress */
  653     gf_error_to_errno_array[GF_ERROR_CODE_INPROGRESS] = EINPROGRESS;
  654     gf_errno_to_error_array[EINPROGRESS] = GF_ERROR_CODE_INPROGRESS;
  655 
  656     /*      EALREADY        37              / * Operation already in progress */
  657     gf_error_to_errno_array[GF_ERROR_CODE_ALREADY] = EALREADY;
  658     gf_errno_to_error_array[EALREADY] = GF_ERROR_CODE_ALREADY;
  659 
  660     /*      ENOTSOCK        38              / * Socket operation on non-socket
  661      */
  662     gf_error_to_errno_array[GF_ERROR_CODE_NOTSOCK] = ENOTSOCK;
  663     gf_errno_to_error_array[ENOTSOCK] = GF_ERROR_CODE_NOTSOCK;
  664 
  665     /*      EDESTADDRREQ    39              / * Destination address required */
  666     gf_error_to_errno_array[GF_ERROR_CODE_DESTADDRREQ] = EDESTADDRREQ;
  667     gf_errno_to_error_array[EDESTADDRREQ] = GF_ERROR_CODE_DESTADDRREQ;
  668 
  669     /*      EMSGSIZE        40              / * Message too long */
  670     gf_error_to_errno_array[GF_ERROR_CODE_MSGSIZE] = EMSGSIZE;
  671     gf_errno_to_error_array[EMSGSIZE] = GF_ERROR_CODE_MSGSIZE;
  672 
  673     /*      EPROTOTYPE      41              / * Protocol wrong type for socket
  674      */
  675     gf_error_to_errno_array[GF_ERROR_CODE_PROTOTYPE] = EPROTOTYPE;
  676     gf_errno_to_error_array[EPROTOTYPE] = GF_ERROR_CODE_PROTOTYPE;
  677 
  678     /*      ENOPROTOOPT     42              / * Protocol not available */
  679     gf_error_to_errno_array[GF_ERROR_CODE_NOPROTOOPT] = ENOPROTOOPT;
  680     gf_errno_to_error_array[ENOPROTOOPT] = GF_ERROR_CODE_NOPROTOOPT;
  681 
  682     /*      EPROTONOSUPPORT 43              / * Protocol not supported */
  683     gf_error_to_errno_array[GF_ERROR_CODE_PROTONOSUPPORT] = EPROTONOSUPPORT;
  684     gf_errno_to_error_array[EPROTONOSUPPORT] = GF_ERROR_CODE_PROTONOSUPPORT;
  685 
  686     /*      ESOCKTNOSUPPORT 44              / * Socket type not supported */
  687     gf_error_to_errno_array[GF_ERROR_CODE_SOCKTNOSUPPORT] = ESOCKTNOSUPPORT;
  688     gf_errno_to_error_array[ESOCKTNOSUPPORT] = GF_ERROR_CODE_SOCKTNOSUPPORT;
  689 
  690     /*      EOPNOTSUPP      45              / * Operation not supported */
  691     gf_error_to_errno_array[GF_ERROR_CODE_OPNOTSUPP] = EOPNOTSUPP;
  692     gf_errno_to_error_array[EOPNOTSUPP] = GF_ERROR_CODE_OPNOTSUPP;
  693 
  694     /*      EPFNOSUPPORT    46              / * Protocol family not supported */
  695     gf_error_to_errno_array[GF_ERROR_CODE_PFNOSUPPORT] = EPFNOSUPPORT;
  696     gf_errno_to_error_array[EPFNOSUPPORT] = GF_ERROR_CODE_PFNOSUPPORT;
  697 
  698     /*      EAFNOSUPPORT    47              / * Address family not supported by
  699      * protocol family */
  700     gf_error_to_errno_array[GF_ERROR_CODE_AFNOSUPPORT] = EAFNOSUPPORT;
  701     gf_errno_to_error_array[EAFNOSUPPORT] = GF_ERROR_CODE_AFNOSUPPORT;
  702 
  703     /*      EADDRINUSE      48              / * Address already in use */
  704     gf_error_to_errno_array[GF_ERROR_CODE_ADDRINUSE] = EADDRINUSE;
  705     gf_errno_to_error_array[EADDRINUSE] = GF_ERROR_CODE_ADDRINUSE;
  706 
  707     /*      EADDRNOTAVAIL   49              / * Can't assign requested address
  708      */
  709     gf_error_to_errno_array[GF_ERROR_CODE_ADDRNOTAVAIL] = EADDRNOTAVAIL;
  710     gf_errno_to_error_array[EADDRNOTAVAIL] = GF_ERROR_CODE_ADDRNOTAVAIL;
  711 
  712     /*      ENETDOWN        50              / * Network is down */
  713     gf_error_to_errno_array[GF_ERROR_CODE_NETDOWN] = ENETDOWN;
  714     gf_errno_to_error_array[ENETDOWN] = GF_ERROR_CODE_NETDOWN;
  715 
  716     /*      ENETUNREACH     51              / * Network is unreachable */
  717     gf_error_to_errno_array[GF_ERROR_CODE_NETUNREACH] = ENETUNREACH;
  718     gf_errno_to_error_array[ENETUNREACH] = GF_ERROR_CODE_NETUNREACH;
  719 
  720     /*      ENETRESET       52              / * Network dropped connection on
  721      * reset */
  722     gf_error_to_errno_array[GF_ERROR_CODE_NETRESET] = ENETRESET;
  723     gf_errno_to_error_array[ENETRESET] = GF_ERROR_CODE_NETRESET;
  724 
  725     /*      ECONNABORTED    53              / * Software caused connection abort
  726      */
  727     gf_error_to_errno_array[GF_ERROR_CODE_CONNABORTED] = ECONNABORTED;
  728     gf_errno_to_error_array[ECONNABORTED] = GF_ERROR_CODE_CONNABORTED;
  729 
  730     /*      ECONNRESET      54              / * Connection reset by peer */
  731     gf_error_to_errno_array[GF_ERROR_CODE_CONNRESET] = ECONNRESET;
  732     gf_errno_to_error_array[ECONNRESET] = GF_ERROR_CODE_CONNRESET;
  733 
  734     /*      ENOBUFS         55              / * No buffer space available */
  735     gf_error_to_errno_array[GF_ERROR_CODE_NOBUFS] = ENOBUFS;
  736     gf_errno_to_error_array[ENOBUFS] = GF_ERROR_CODE_NOBUFS;
  737 
  738     /*      EISCONN         56              / * Socket is already connected */
  739     gf_error_to_errno_array[GF_ERROR_CODE_ISCONN] = EISCONN;
  740     gf_errno_to_error_array[EISCONN] = GF_ERROR_CODE_ISCONN;
  741 
  742     /*      ENOTCONN        57              / * Socket is not connected */
  743     gf_error_to_errno_array[GF_ERROR_CODE_NOTCONN] = ENOTCONN;
  744     gf_errno_to_error_array[ENOTCONN] = GF_ERROR_CODE_NOTCONN;
  745 
  746     /*      ESHUTDOWN       58              / * Can't send after socket shutdown
  747      */
  748     gf_error_to_errno_array[GF_ERROR_CODE_SHUTDOWN] = ESHUTDOWN;
  749     gf_errno_to_error_array[ESHUTDOWN] = GF_ERROR_CODE_SHUTDOWN;
  750 
  751     /*      ETOOMANYREFS    59              / * Too many references: can't
  752      * splice */
  753     gf_error_to_errno_array[GF_ERROR_CODE_TOOMANYREFS] = ETOOMANYREFS;
  754     gf_errno_to_error_array[ETOOMANYREFS] = GF_ERROR_CODE_TOOMANYREFS;
  755 
  756     /*      ETIMEDOUT       60              / * Operation timed out */
  757     gf_error_to_errno_array[GF_ERROR_CODE_TIMEDOUT] = ETIMEDOUT;
  758     gf_errno_to_error_array[ETIMEDOUT] = GF_ERROR_CODE_TIMEDOUT;
  759 
  760     /*      ECONNREFUSED    61              / * Connection refused */
  761     gf_error_to_errno_array[GF_ERROR_CODE_CONNREFUSED] = ECONNREFUSED;
  762     gf_errno_to_error_array[ECONNREFUSED] = GF_ERROR_CODE_CONNREFUSED;
  763 
  764     /*      ELOOP           62              / * Too many levels of symbolic
  765      * links */
  766     gf_error_to_errno_array[GF_ERROR_CODE_LOOP] = ELOOP;
  767     gf_errno_to_error_array[ELOOP] = GF_ERROR_CODE_LOOP;
  768 
  769     /*      ENAMETOOLONG    63              / * File name too long */
  770     gf_error_to_errno_array[GF_ERROR_CODE_NAMETOOLONG] = ENAMETOOLONG;
  771     gf_errno_to_error_array[ENAMETOOLONG] = GF_ERROR_CODE_NAMETOOLONG;
  772 
  773     /*      EHOSTDOWN       64              / * Host is down */
  774     gf_error_to_errno_array[GF_ERROR_CODE_HOSTDOWN] = EHOSTDOWN;
  775     gf_errno_to_error_array[EHOSTDOWN] = GF_ERROR_CODE_HOSTDOWN;
  776 
  777     /*      EHOSTUNREACH    65              / * No route to host */
  778     gf_error_to_errno_array[GF_ERROR_CODE_HOSTUNREACH] = EHOSTUNREACH;
  779     gf_errno_to_error_array[EHOSTUNREACH] = GF_ERROR_CODE_HOSTUNREACH;
  780 
  781     /*      ENOTEMPTY       66              / * Directory not empty */
  782     gf_error_to_errno_array[GF_ERROR_CODE_NOTEMPTY] = ENOTEMPTY;
  783     gf_errno_to_error_array[ENOTEMPTY] = GF_ERROR_CODE_NOTEMPTY;
  784 
  785     /*      EPROCLIM        67              / * Too many processes */
  786     gf_error_to_errno_array[GF_ERROR_CODE_PROCLIM] = EPROCLIM;
  787     gf_errno_to_error_array[EPROCLIM] = GF_ERROR_CODE_PROCLIM;
  788 
  789     /*      EUSERS          68              / * Too many users */
  790     gf_error_to_errno_array[GF_ERROR_CODE_USERS] = EUSERS;
  791     gf_errno_to_error_array[EUSERS] = GF_ERROR_CODE_USERS;
  792 
  793     /*      EDQUOT          69              / * Disc quota exceeded */
  794     gf_error_to_errno_array[GF_ERROR_CODE_DQUOT] = EDQUOT;
  795     gf_errno_to_error_array[EDQUOT] = GF_ERROR_CODE_DQUOT;
  796 
  797     /*      ESTALE          70              / * Stale NFS file handle */
  798     gf_error_to_errno_array[GF_ERROR_CODE_STALE] = ESTALE;
  799     gf_errno_to_error_array[ESTALE] = GF_ERROR_CODE_STALE;
  800 
  801     /*      EREMOTE         71              / * Too many levels of remote in
  802      * path */
  803     gf_error_to_errno_array[GF_ERROR_CODE_REMOTE] = EREMOTE;
  804     gf_errno_to_error_array[EREMOTE] = GF_ERROR_CODE_REMOTE;
  805 
  806     /*      EBADRPC         72              / * RPC struct is bad */
  807     gf_error_to_errno_array[GF_ERROR_CODE_BADRPC] = EBADRPC;
  808     gf_errno_to_error_array[EBADRPC] = GF_ERROR_CODE_BADRPC;
  809 
  810     /*      ERPCMISMATCH    73              / * RPC version wrong */
  811     gf_error_to_errno_array[GF_ERROR_CODE_RPCMISMATCH] = ERPCMISMATCH;
  812     gf_errno_to_error_array[ERPCMISMATCH] = GF_ERROR_CODE_RPCMISMATCH;
  813 
  814     /*      EPROGUNAVAIL    74              / * RPC prog. not avail */
  815     gf_error_to_errno_array[GF_ERROR_CODE_PROGUNAVAIL] = EPROGUNAVAIL;
  816     gf_errno_to_error_array[EPROGUNAVAIL] = GF_ERROR_CODE_PROGUNAVAIL;
  817 
  818     /*      EPROGMISMATCH   75              / * Program version wrong */
  819     gf_error_to_errno_array[GF_ERROR_CODE_PROGMISMATCH] = EPROGMISMATCH;
  820     gf_errno_to_error_array[EPROGMISMATCH] = GF_ERROR_CODE_PROGMISMATCH;
  821 
  822     /*      EPROCUNAVAIL    76              / * Bad procedure for program */
  823     gf_error_to_errno_array[GF_ERROR_CODE_PROCUNAVAIL] = EPROCUNAVAIL;
  824     gf_errno_to_error_array[EPROCUNAVAIL] = GF_ERROR_CODE_PROCUNAVAIL;
  825 
  826     /*      ENOLCK          77              / * No locks available */
  827     gf_error_to_errno_array[GF_ERROR_CODE_NOLCK] = ENOLCK;
  828     gf_errno_to_error_array[ENOLCK] = GF_ERROR_CODE_NOLCK;
  829 
  830     /*      ENOSYS          78              / * Function not implemented */
  831     gf_error_to_errno_array[GF_ERROR_CODE_NOSYS] = ENOSYS;
  832     gf_errno_to_error_array[ENOSYS] = GF_ERROR_CODE_NOSYS;
  833 
  834     /*      EFTYPE          79              / * Inappropriate file type or
  835      * format */
  836     gf_error_to_errno_array[GF_ERROR_CODE_FTYPE] = EFTYPE;
  837     gf_errno_to_error_array[EFTYPE] = GF_ERROR_CODE_FTYPE;
  838 
  839     /*      EAUTH           80              / * Authentication error */
  840     gf_error_to_errno_array[GF_ERROR_CODE_AUTH] = EAUTH;
  841     gf_errno_to_error_array[EAUTH] = GF_ERROR_CODE_AUTH;
  842 
  843     /*      ENEEDAUTH       81              / * Need authenticator */
  844     gf_error_to_errno_array[GF_ERROR_CODE_NEEDAUTH] = ENEEDAUTH;
  845     gf_errno_to_error_array[ENEEDAUTH] = GF_ERROR_CODE_NEEDAUTH;
  846 
  847     /*      EIDRM           82              / * Identifier removed */
  848     gf_error_to_errno_array[GF_ERROR_CODE_IDRM] = EIDRM;
  849     gf_errno_to_error_array[EIDRM] = GF_ERROR_CODE_IDRM;
  850 
  851     /*      ENOMSG          83              / * No message of desired type */
  852     gf_error_to_errno_array[GF_ERROR_CODE_NOMSG] = ENOMSG;
  853     gf_errno_to_error_array[ENOMSG] = GF_ERROR_CODE_NOMSG;
  854 
  855     /*      EOVERFLOW       84              / * Value too large to be stored in
  856      * data type */
  857     gf_error_to_errno_array[GF_ERROR_CODE_OVERFLOW] = EOVERFLOW;
  858     gf_errno_to_error_array[EOVERFLOW] = GF_ERROR_CODE_OVERFLOW;
  859 
  860     /*      ECANCELED       85              / * Operation canceled */
  861     gf_error_to_errno_array[GF_ERROR_CODE_CANCELED] = ECANCELED;
  862     gf_errno_to_error_array[ECANCELED] = GF_ERROR_CODE_CANCELED;
  863 
  864     /*      EILSEQ          86              / * Illegal byte sequence */
  865     gf_error_to_errno_array[GF_ERROR_CODE_ILSEQ] = EILSEQ;
  866     gf_errno_to_error_array[EILSEQ] = GF_ERROR_CODE_ILSEQ;
  867 
  868     /*      ENOATTR         87              / * Attribute not found */
  869     gf_error_to_errno_array[GF_ERROR_CODE_NOATTR] = ENOATTR;
  870     gf_errno_to_error_array[ENOATTR] = GF_ERROR_CODE_NOATTR;
  871 
  872 #ifdef EDOOFUS
  873     /*    EDOOFUS           88              / * Programming error */
  874     gf_error_to_errno_array[GF_ERROR_CODE_DOOFUS] = EDOOFUS;
  875     gf_errno_to_error_array[EDOOFUS] = GF_ERROR_CODE_DOOFUS;
  876 #endif
  877 
  878     /*      EBADMSG         89              / * Bad message */
  879     gf_error_to_errno_array[GF_ERROR_CODE_BADMSG] = EBADMSG;
  880     gf_errno_to_error_array[EBADMSG] = GF_ERROR_CODE_BADMSG;
  881 
  882 #ifdef __NetBSD__
  883     /*      ENODATA         89              / * No message available */
  884     gf_error_to_errno_array[GF_ERROR_CODE_NODATA] = ENODATA;
  885     gf_errno_to_error_array[ENODATA] = GF_ERROR_CODE_NODATA;
  886 #endif
  887 
  888     /*      EMULTIHOP       90              / * Multihop attempted */
  889     gf_error_to_errno_array[GF_ERROR_CODE_MULTIHOP] = EMULTIHOP;
  890     gf_errno_to_error_array[EMULTIHOP] = GF_ERROR_CODE_MULTIHOP;
  891 
  892     /*      ENOLINK         91              / * Link has been severed */
  893     gf_error_to_errno_array[GF_ERROR_CODE_NOLINK] = ENOLINK;
  894     gf_errno_to_error_array[ENOLINK] = GF_ERROR_CODE_NOLINK;
  895 
  896     /*      EPROTO          92              / * Protocol error */
  897     gf_error_to_errno_array[GF_ERROR_CODE_PROTO] = EPROTO;
  898     gf_errno_to_error_array[EPROTO] = GF_ERROR_CODE_PROTO;
  899 
  900     return;
  901 }
  902 #endif /* GF_BSD_HOST_OS */
  903 
  904 #ifdef GF_LINUX_HOST_OS
  905 static void
  906 init_compat_errno_arrays()
  907 {
  908     /* Things are fine. Everything should work seemlessly on GNU/Linux machines
  909      */
  910     return;
  911 }
  912 #endif /* GF_LINUX_HOST_OS */
  913 
  914 static void
  915 init_errno_arrays()
  916 {
  917     int i;
  918     for (i = 0; i < GF_ERROR_CODE_UNKNOWN; i++) {
  919         gf_errno_to_error_array[i] = i;
  920         gf_error_to_errno_array[i] = i;
  921     }
  922     /* Now change the order if it needs to be. */
  923     init_compat_errno_arrays();
  924 
  925     return;
  926 }
  927 
  928 int32_t
  929 gf_errno_to_error(int32_t op_errno)
  930 {
  931     if (!gf_compat_errno_init_done) {
  932         init_errno_arrays();
  933         gf_compat_errno_init_done = 1;
  934     }
  935 
  936     if ((op_errno > GF_ERROR_CODE_SUCCESS) &&
  937         (op_errno < GF_ERROR_CODE_UNKNOWN))
  938         return gf_errno_to_error_array[op_errno];
  939 
  940     return op_errno;
  941 }
  942 
  943 int32_t
  944 gf_error_to_errno(int32_t error)
  945 {
  946     if (!gf_compat_errno_init_done) {
  947         init_errno_arrays();
  948         gf_compat_errno_init_done = 1;
  949     }
  950 
  951     if ((error > GF_ERROR_CODE_SUCCESS) && (error < GF_ERROR_CODE_UNKNOWN))
  952         return gf_error_to_errno_array[error];
  953 
  954     return error;
  955 }