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