aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_errno.c
blob: 69880db86319b588d4ae4d968b90efe7548ea6b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* $FreeBSD$ */

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <sys/param.h>
#include <sys/errno.h>
#include <sys/systm.h>

#include <compat/linux/linux.h>
#include <compat/linux/linux_errno.h>
#include <compat/linux/linux_errno.inc>

int
bsd_to_linux_errno(int error)
{

	KASSERT(error >= 0 && error <= ELAST,
	    ("%s: bad error %d", __func__, error));

	return (linux_errtbl[error]);
}

#ifdef INVARIANTS
void
linux_check_errtbl(void)
{
	int i;

	for (i = 1; i < nitems(linux_errtbl); i++) {
		KASSERT(linux_errtbl[i] != 0,
		    ("%s: linux_errtbl[%d] == 0", __func__, i));
	}

	for (i = 1; i < nitems(linux_to_bsd_errtbl); i++) {
		KASSERT(linux_to_bsd_errtbl[i] != 0,
		    ("%s: linux_to_bsd_errtbl[%d] == 0", __func__, i));
	}

}
#endif