Back to index

glibc  2.9
errnoconv.c
Go to the documentation of this file.
00001 /* Convert the error number the AIX kernel returns to what the Linux
00002    application expects.
00003    Copyright (C) 2000 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <errno.h>
00022 #include "linux-errno.h"
00023 
00024 
00025 static int mapping[] =
00026 {
00027   [AIX_EPERM] = EPERM,
00028   [AIX_ENOENT] = ENOENT,
00029   [AIX_ESRCH] = ESRCH,
00030   [AIX_EINTR] = EINTR,
00031   [AIX_EIO] = EIO,
00032   [AIX_ENXIO] = ENXIO,
00033   [AIX_E2BIG] = E2BIG,
00034   [AIX_ENOEXEC] = ENOEXEC,
00035   [AIX_EBADF] = EBADF,
00036   [AIX_ECHILD] = ECHILD,
00037   [AIX_EAGAIN] = EAGAIN,
00038   [AIX_ENOMEM] = ENOMEM,
00039   [AIX_EACCES] = EACCES,
00040   [AIX_EFAULT] = EFAULT,
00041   [AIX_ENOTBLK] = ENOTBLK,
00042   [AIX_EBUSY] = EBUSY,
00043   [AIX_EEXIST] = EEXIST,
00044   [AIX_EXDEV] = EXDEV,
00045   [AIX_ENODEV] = ENODEV,
00046   [AIX_ENOTDIR] = ENOTDIR,
00047   [AIX_EISDIR] = EISDIR,
00048   [AIX_EINVAL] = EINVAL,
00049   [AIX_ENFILE] = ENFILE,
00050   [AIX_EMFILE] = EMFILE,
00051   [AIX_ENOTTY] = ENOTTY,
00052   [AIX_ETXTBSY] = ETXTBSY,
00053   [AIX_EFBIG] = EFBIG,
00054   [AIX_ENOSPC] = ENOSPC,
00055   [AIX_EIDRM] = EIDRM,
00056   [AIX_ECHRNG] = ECHRNG,
00057   [AIX_EL2NSYNC] = EL2NSYNC,
00058   [AIX_EL3HLT] = EL3HLT,
00059   [AIX_EL3RST] = EL3RST,
00060   [AIX_ELNRNG] = ELNRNG,
00061   [AIX_EUNATCH] = EUNATCH,
00062   [AIX_ENOCSI] = ENOCSI,
00063   [AIX_EL2HLT] = EL2HLT,
00064   [AIX_EDEADLK] = EDEADLK,
00065   [AIX_ENOTREADY] = ENOTREADY,
00066   // EWPROTECT: no Linux equivalent
00067   // EFORMAT: no Linux equivalent
00068   [AIX_ENOLCK] = ENOLCK,
00069   // ENOCONNECT: No Linux equivalent
00070   [AIX_ESTALE] = ESTALE,
00071   // EDIST: no Linux equivalent
00072   [54] = EAGAIN,            // EWOULDBLOCK
00073   [AIX_EINPROGRESS] = EINPROGRESS,
00074   [AIX_EALREADY] = EALREADY,
00075   [AIX_ENOTSOCK] = ENOTSOCK,
00076   [AIX_EDESTADDRREQ] = EDESTADDRREQ,
00077   [AIX_EMSGSIZE] = EMSGSIZE,
00078   [AIX_EPROTOTYPE] = EPROTOTYPE,
00079   [AIX_ENOPROTOOPT] = ENOPROTOOPT,
00080   [AIX_EPROTONOSUPPORT] = EPROTONOSUPPORT,
00081   [AIX_ESOCKTNOSUPPORT] = ESOCKTNOSUPPORT,
00082   [AIX_EOPNOTSUPP] = EOPNOTSUPP,
00083   [AIX_EPFNOSUPPORT] = EPFNOSUPPORT,
00084   [AIX_EAFNOSUPPORT] = EAFNOSUPPORT,
00085   [AIX_EADDRINUSE] = EADDRINUSE,
00086   [AIX_EADDRNOTAVAIL] = EADDRNOTAVAIL,
00087   [AIX_ENETDOWN] = ENETDOWN,
00088   [AIX_ENETUNREACH] = ENETUNREACH,
00089   [AIX_ENETRESET] = ENETRESET,
00090   [AIX_ECONNABORTED] = ECONNABORTED,
00091   [AIX_ECONNRESET] = ECONNRESET,
00092   [AIX_ENOBUFS] = ENOBUFS,
00093   [AIX_EISCONN] = EISCONN,
00094   [AIX_ENOTCONN] = ENOTCONN,
00095   [AIX_ESHUTDOWN] = ESHUTDOWN,
00096   [AIX_ETIMEDOUT] = ETIMEDOUT,
00097   [AIX_ECONNREFUSED] = ECONNREFUSED,
00098   [AIX_EHOSTDOWN] = EHOSTDOWN,
00099   [AIX_EHOSTUNREACH] = EHOSTUNREACH,
00100   [AIX_ERESTART] = ERESTART,
00101   [AIX_EPROCLIM] = EPROCLIM,
00102   [AIX_EUSERS] = EUSERS,
00103   [AIX_ELOOP] = ELOOP,
00104   [AIX_ENAMETOOLONG] = ENAMETOOLONG,
00105   [87] = ENOTEMPTY,         // ENOTEMPTY
00106   [AIX_EDQUOT] = EDQUOT,
00107   [AIX_ECORRUPT] = ECORRUPT,
00108   [AIX_EREMOTE] = EREMOTE,
00109   [AIX_ENOSYS] = ENOSYS,
00110   [AIX_EMEDIA] = EMEDIA,
00111   [AIX_ESOFT] = ESOFT,
00112   [AIX_ENOATTR] = ENOATTR,
00113   [AIX_ESAD] = ESAD,
00114   // ENOTRUST: no Linux equivalent
00115   [AIX_ETOOMANYREFS] = ETOOMANYREFS,
00116   [AIX_EILSEQ] = EILSEQ,
00117   [AIX_ECANCELED] = ECANCELED,
00118   [AIX_ENOSR] = ENOSR,
00119   [AIX_ETIME] = ETIME,
00120   [AIX_EBADMSG] = EBADMSG,
00121   [AIX_EPROTO] = EPROTO,
00122   [AIX_ENODATA] = ENODATA,
00123   [AIX_ENOSTR] = ENOSTR,
00124   [AIX_ENOTSUP] = ENOTSUP,
00125   [AIX_EMULTIHOP] = EMULTIHOP,
00126   [AIX_ENOLINK] = ENOLINK,
00127   [AIX_EOVERFLOW] = EOVERFLOW
00128 };
00129 
00130 
00131 int
00132 __errno_aix_to_linux (int err)
00133 {
00134   int conv;
00135 
00136   if (err >= 0 && err < (sizeof (mapping) / sizeof (mapping[0]))
00137       && ((conv = mapping[err]) != 0 || err == 0))
00138     return conv;
00139 
00140   /* The error value is not known.  Create a special value which can
00141      be easily recognized as an invalid result.  */
00142   return 512 + err;
00143 }