2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / powerpc / aix / errnoconv.c
blobefa0df786a67561232c72ffaea2ca6250bebd0dc
1 /* Convert the error number the AIX kernel returns to what the Linux
2 application expects.
3 Copyright (C) 2000 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #include <errno.h>
22 #include "linux-errno.h"
25 static int mapping[] =
27 [AIX_EPERM] = EPERM,
28 [AIX_ENOENT] = ENOENT,
29 [AIX_ESRCH] = ESRCH,
30 [AIX_EINTR] = EINTR,
31 [AIX_EIO] = EIO,
32 [AIX_ENXIO] = ENXIO,
33 [AIX_E2BIG] = E2BIG,
34 [AIX_ENOEXEC] = ENOEXEC,
35 [AIX_EBADF] = EBADF,
36 [AIX_ECHILD] = ECHILD,
37 [AIX_EAGAIN] = EAGAIN,
38 [AIX_ENOMEM] = ENOMEM,
39 [AIX_EACCES] = EACCES,
40 [AIX_EFAULT] = EFAULT,
41 [AIX_ENOTBLK] = ENOTBLK,
42 [AIX_EBUSY] = EBUSY,
43 [AIX_EEXIST] = EEXIST,
44 [AIX_EXDEV] = EXDEV,
45 [AIX_ENODEV] = ENODEV,
46 [AIX_ENOTDIR] = ENOTDIR,
47 [AIX_EISDIR] = EISDIR,
48 [AIX_EINVAL] = EINVAL,
49 [AIX_ENFILE] = ENFILE,
50 [AIX_EMFILE] = EMFILE,
51 [AIX_ENOTTY] = ENOTTY,
52 [AIX_ETXTBSY] = ETXTBSY,
53 [AIX_EFBIG] = EFBIG,
54 [AIX_ENOSPC] = ENOSPC,
55 [AIX_EIDRM] = EIDRM,
56 [AIX_ECHRNG] = ECHRNG,
57 [AIX_EL2NSYNC] = EL2NSYNC,
58 [AIX_EL3HLT] = EL3HLT,
59 [AIX_EL3RST] = EL3RST,
60 [AIX_ELNRNG] = ELNRNG,
61 [AIX_EUNATCH] = EUNATCH,
62 [AIX_ENOCSI] = ENOCSI,
63 [AIX_EL2HLT] = EL2HLT,
64 [AIX_EDEADLK] = EDEADLK,
65 [AIX_ENOTREADY] = ENOTREADY,
66 // EWPROTECT: no Linux equivalent
67 // EFORMAT: no Linux equivalent
68 [AIX_ENOLCK] = ENOLCK,
69 // ENOCONNECT: No Linux equivalent
70 [AIX_ESTALE] = ESTALE,
71 // EDIST: no Linux equivalent
72 [54] = EAGAIN, // EWOULDBLOCK
73 [AIX_EINPROGRESS] = EINPROGRESS,
74 [AIX_EALREADY] = EALREADY,
75 [AIX_ENOTSOCK] = ENOTSOCK,
76 [AIX_EDESTADDRREQ] = EDESTADDRREQ,
77 [AIX_EMSGSIZE] = EMSGSIZE,
78 [AIX_EPROTOTYPE] = EPROTOTYPE,
79 [AIX_ENOPROTOOPT] = ENOPROTOOPT,
80 [AIX_EPROTONOSUPPORT] = EPROTONOSUPPORT,
81 [AIX_ESOCKTNOSUPPORT] = ESOCKTNOSUPPORT,
82 [AIX_EOPNOTSUPP] = EOPNOTSUPP,
83 [AIX_EPFNOSUPPORT] = EPFNOSUPPORT,
84 [AIX_EAFNOSUPPORT] = EAFNOSUPPORT,
85 [AIX_EADDRINUSE] = EADDRINUSE,
86 [AIX_EADDRNOTAVAIL] = EADDRNOTAVAIL,
87 [AIX_ENETDOWN] = ENETDOWN,
88 [AIX_ENETUNREACH] = ENETUNREACH,
89 [AIX_ENETRESET] = ENETRESET,
90 [AIX_ECONNABORTED] = ECONNABORTED,
91 [AIX_ECONNRESET] = ECONNRESET,
92 [AIX_ENOBUFS] = ENOBUFS,
93 [AIX_EISCONN] = EISCONN,
94 [AIX_ENOTCONN] = ENOTCONN,
95 [AIX_ESHUTDOWN] = ESHUTDOWN,
96 [AIX_ETIMEDOUT] = ETIMEDOUT,
97 [AIX_ECONNREFUSED] = ECONNREFUSED,
98 [AIX_EHOSTDOWN] = EHOSTDOWN,
99 [AIX_EHOSTUNREACH] = EHOSTUNREACH,
100 [AIX_ERESTART] = ERESTART,
101 [AIX_EPROCLIM] = EPROCLIM,
102 [AIX_EUSERS] = EUSERS,
103 [AIX_ELOOP] = ELOOP,
104 [AIX_ENAMETOOLONG] = ENAMETOOLONG,
105 [87] = ENOTEMPTY, // ENOTEMPTY
106 [AIX_EDQUOT] = EDQUOT,
107 [AIX_ECORRUPT] = ECORRUPT,
108 [AIX_EREMOTE] = EREMOTE,
109 [AIX_ENOSYS] = ENOSYS,
110 [AIX_EMEDIA] = EMEDIA,
111 [AIX_ESOFT] = ESOFT,
112 [AIX_ENOATTR] = ENOATTR,
113 [AIX_ESAD] = ESAD,
114 // ENOTRUST: no Linux equivalent
115 [AIX_ETOOMANYREFS] = ETOOMANYREFS,
116 [AIX_EILSEQ] = EILSEQ,
117 [AIX_ECANCELED] = ECANCELED,
118 [AIX_ENOSR] = ENOSR,
119 [AIX_ETIME] = ETIME,
120 [AIX_EBADMSG] = EBADMSG,
121 [AIX_EPROTO] = EPROTO,
122 [AIX_ENODATA] = ENODATA,
123 [AIX_ENOSTR] = ENOSTR,
124 [AIX_ENOTSUP] = ENOTSUP,
125 [AIX_EMULTIHOP] = EMULTIHOP,
126 [AIX_ENOLINK] = ENOLINK,
127 [AIX_EOVERFLOW] = EOVERFLOW
132 __errno_aix_to_linux (int err)
134 int conv;
136 if (err >= 0 && err < (sizeof (mapping) / sizeof (mapping[0]))
137 && ((conv = mapping[err]) != 0 || err == 0))
138 return conv;
140 /* The error value is not known. Create a special value which can
141 be easily recognized as an invalid result. */
142 return 512 + err;