xref: /freebsd/sys/compat/linux/linux_errno.inc (revision 4bfebc8d2c5d0e813dfdcbe7038b36ffc2bb9f1b)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 1994-1996 Søren Schmidt
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30
31/*
32 * Linux syscalls return negative errno's, we do positive and map them
33 * Reference:
34 *   FreeBSD: src/sys/sys/errno.h
35 *   Linux:   include/uapi/asm-generic/errno-base.h
36 *            include/uapi/asm-generic/errno.h
37 *
38 * XXX: The "XXX" comments below should be replaced with rationale
39 *      for the errno value chosen.
40 */
41const int linux_errtbl[ELAST + 1] = {
42	/* [0, 9] */
43	[0] = -0,
44	[EPERM] = -LINUX_EPERM,
45	[ENOENT] = -LINUX_ENOENT,
46	[ESRCH] = -LINUX_ESRCH,
47	[EINTR] = -LINUX_EINTR,
48	[EIO] = -LINUX_EIO,
49	[ENXIO] = -LINUX_ENXIO,
50	[E2BIG] = -LINUX_E2BIG,
51	[ENOEXEC] = -LINUX_ENOEXEC,
52	[EBADF] = -LINUX_EBADF,
53
54	/* [10, 19] */
55	[ECHILD] = -LINUX_ECHILD,
56	[EDEADLK] = -LINUX_EDEADLK,
57	[ENOMEM] = -LINUX_ENOMEM,
58	[EACCES] = -LINUX_EACCES,
59	[EFAULT] = -LINUX_EFAULT,
60	[ENOTBLK] = -LINUX_ENOTBLK,
61	[EBUSY] = -LINUX_EBUSY,
62	[EEXIST] = -LINUX_EEXIST,
63	[EXDEV] = -LINUX_EXDEV,
64	[ENODEV] = -LINUX_ENODEV,
65
66	/* [20, 29] */
67	[ENOTDIR] = -LINUX_ENOTDIR,
68	[EISDIR] = -LINUX_EISDIR,
69	[EINVAL] = -LINUX_EINVAL,
70	[ENFILE] = -LINUX_ENFILE,
71	[EMFILE] = -LINUX_EMFILE,
72	[ENOTTY] = -LINUX_ENOTTY,
73	[ETXTBSY] = -LINUX_ETXTBSY,
74	[EFBIG] = -LINUX_EFBIG,
75	[ENOSPC] = -LINUX_ENOSPC,
76	[ESPIPE] = -LINUX_ESPIPE,
77
78	/* [30, 39] */
79	[EROFS] = -LINUX_EROFS,
80	[EMLINK] = -LINUX_EMLINK,
81	[EPIPE] = -LINUX_EPIPE,
82	[EDOM] = -LINUX_EDOM,
83	[ERANGE] = -LINUX_ERANGE,
84	[EAGAIN] = -LINUX_EAGAIN,
85	[EINPROGRESS] = -LINUX_EINPROGRESS,
86	[EALREADY] = -LINUX_EALREADY,
87	[ENOTSOCK] = -LINUX_ENOTSOCK,
88	[EDESTADDRREQ] = -LINUX_EDESTADDRREQ,
89
90	/* [40, 49] */
91	[EMSGSIZE] = -LINUX_EMSGSIZE,
92	[EPROTOTYPE] = -LINUX_EPROTOTYPE,
93	[ENOPROTOOPT] = -LINUX_ENOPROTOOPT,
94	[EPROTONOSUPPORT] = -LINUX_EPROTONOTSUPPORT,
95	[ESOCKTNOSUPPORT] = -LINUX_ESOCKNOTSUPPORT,
96	[EOPNOTSUPP] = -LINUX_EOPNOTSUPPORT,
97	[EPFNOSUPPORT] = -LINUX_EPFNOTSUPPORT,
98	[EAFNOSUPPORT] = -LINUX_EAFNOTSUPPORT,
99	[EADDRINUSE] = -LINUX_EADDRINUSE,
100	[EADDRNOTAVAIL] = -LINUX_EADDRNOTAVAIL,
101
102	/* [50, 59] */
103	[ENETDOWN] = -LINUX_ENETDOWN,
104	[ENETUNREACH] = -LINUX_ENETUNREACH,
105	[ENETRESET] = -LINUX_ENETRESET,
106	[ECONNABORTED] = -LINUX_ECONNABORTED,
107	[ECONNRESET] = -LINUX_ECONNRESET,
108	[ENOBUFS] = -LINUX_ENOBUFS,
109	[EISCONN] = -LINUX_EISCONN,
110	[ENOTCONN] = -LINUX_ENOTCONN,
111	[ESHUTDOWN] = -LINUX_ESHUTDOWN,
112	[ETOOMANYREFS] = -LINUX_ETOOMANYREFS,
113
114	/* [60, 69] */
115	[ETIMEDOUT] = -LINUX_ETIMEDOUT,
116	[ECONNREFUSED] = -LINUX_ECONNREFUSED,
117	[ELOOP] = -LINUX_ELOOP,
118	[ENAMETOOLONG] = -LINUX_ENAMETOOLONG,
119	[EHOSTDOWN] = -LINUX_EHOSTDOWN,
120	[EHOSTUNREACH] = -LINUX_EHOSTUNREACH,
121	[ENOTEMPTY] = -LINUX_ENOTEMPTY,
122	[EPROCLIM] = -LINUX_EAGAIN,	/* XXX */
123	[EUSERS] = -LINUX_EUSERS,
124	[EDQUOT] = -LINUX_EDQUOT,
125
126	/* [70, 79] */
127	[ESTALE] = -LINUX_ESTALE,
128	[EREMOTE] = -LINUX_EREMOTE,
129	[EBADRPC] = -LINUX_ENXIO,	/* XXX */
130	[ERPCMISMATCH] = -LINUX_ENXIO,	/* XXX */
131	[EPROGUNAVAIL] = -LINUX_ENXIO,	/* XXX */
132	[EPROGMISMATCH] = -LINUX_ENXIO,	/* XXX */
133	[EPROCUNAVAIL] = -LINUX_ENXIO,	/* XXX */
134	[ENOLCK] = -LINUX_ENOLCK,
135	[ENOSYS] = -LINUX_ENOSYS,
136	[EFTYPE] = -LINUX_EBADF,	/* XXX */
137
138	/* [80, 89] */
139	[EAUTH] = -LINUX_ENXIO,		/* XXX */
140	[ENEEDAUTH] = -LINUX_ENXIO,	/* XXX */
141	[EIDRM] = -LINUX_EIDRM,
142	[ENOMSG] = -LINUX_ENOMSG,
143	[EOVERFLOW] = -LINUX_EOVERFLOW,
144	[ECANCELED] = -LINUX_ECANCELED,
145	[EILSEQ] = -LINUX_EILSEQ,
146	[ENOATTR] = -LINUX_ENODATA,	/* XXX */
147	[EDOOFUS] = -LINUX_EINVAL,	/* XXX */
148	[EBADMSG] = -LINUX_EBADMSG,
149
150	/* [90, 99] */
151	[EMULTIHOP] = -LINUX_EMULTIHOP,
152	[ENOLINK] = -LINUX_ENOLINK,
153	[EPROTO] = -LINUX_EPROTO,
154	[ENOTCAPABLE] = -LINUX_EPERM,	/* XXX */
155	[ECAPMODE] = -LINUX_EPERM,	/* XXX */
156	[ENOTRECOVERABLE] = -LINUX_ENOTRECOVERABLE,
157	[EOWNERDEAD] = -LINUX_EOWNERDEAD,
158	[EINTEGRITY] = -LINUX_EINVAL,	/* XXX */
159};
160
161_Static_assert(ELAST == 97,
162    "missing errno entries in linux_errtbl");
163