xref: /freebsd-src/sys/compat/linux/linux_errno.c (revision 74fe6c29fb7eef3418d7919dcd41dc1a04a982a1)
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 #include <sys/cdefs.h>
32 #include <sys/errno.h>
33 
34 /*
35  * Linux syscalls return negative errno's, we do positive and map them
36  * Reference:
37  *   FreeBSD: src/sys/sys/errno.h
38  *   Linux:   include/uapi/asm-generic/errno-base.h
39  *            include/uapi/asm-generic/errno.h
40  */
41 const int bsd_to_linux_errno_generic[ELAST + 1] = {
42 	-0,
43 	-1,
44 	-2,
45 	-3,
46 	-4,
47 	-5,
48 	-6,
49 	-7,
50 	-8,
51 	-9,
52 
53 	-10,
54 	-35,	/* EDEADLK */
55 	-12,
56 	-13,
57 	-14,
58 	-15,
59 	-16,
60 	-17,
61 	-18,
62 	-19,
63 
64 	-20,
65 	-21,
66 	-22,
67 	-23,
68 	-24,
69 	-25,
70 	-26,
71 	-27,
72 	-28,
73 	-29,
74 
75 	-30,
76 	-31,
77 	-32,
78 	-33,
79 	-34,
80 	-11,	/* EAGAIN */
81 	-115,
82 	-114,
83 	-88,
84 	-89,
85 
86 	-90,
87 	-91,
88 	-92,
89 	-93,
90 	-94,
91 	-95,
92 	-96,
93 	-97,
94 	-98,
95 	-99,
96 
97 	-100,
98 	-101,
99 	-102,
100 	-103,
101 	-104,
102 	-105,
103 	-106,
104 	-107,
105 	-108,
106 	-109,
107 
108 	-110,
109 	-111,
110 	-40,
111 	-36,
112 	-112,
113 	-113,
114 	-39,
115 	-11,
116 	-87,
117 	-122,
118 
119 	-116,
120 	-66,
121 	-6,	/* EBADRPC -> ENXIO */
122 	-6,	/* ERPCMISMATCH -> ENXIO */
123 	-6,	/* EPROGUNAVAIL -> ENXIO */
124 	-6,	/* EPROGMISMATCH -> ENXIO */
125 	-6,	/* EPROCUNAVAIL -> ENXIO */
126 	-37,
127 	-38,
128 	-9,
129 
130 	-6,	/* EAUTH -> ENXIO */
131 	-6,	/* ENEEDAUTH -> ENXIO */
132 	-43,
133 	-42,
134 	-75,
135 	-125,
136 	-84,
137 	-61,
138 	-16,	/* EDOOFUS -> EBUSY */
139 	-74,
140 
141 	-72,
142 	-67,
143 	-71,
144 	-1,	/* ENOTCAPABLE -> EPERM */
145 	-1,	/* ECAPMODE -> EPERM */
146 	-131,	/* ENOTRECOVERABLE */
147 	-130,	/* EOWNERDEAD */
148 };
149 
150 _Static_assert(ELAST == 96,
151     "missing errno entries in bsd_to_linux_errno_generic");
152