From owner-svn-src-all@freebsd.org Sun Apr 28 13:40:20 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED70E157EAD8; Sun, 28 Apr 2019 13:40:19 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 92F6193A68; Sun, 28 Apr 2019 13:40:19 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A207B4CB; Sun, 28 Apr 2019 13:40:19 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3SDeJ9U023674; Sun, 28 Apr 2019 13:40:19 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3SDeHkn023667; Sun, 28 Apr 2019 13:40:17 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201904281340.x3SDeHkn023667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 28 Apr 2019 13:40:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346827 - in stable/11: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/compat/linux sys/i386/linux sys/modules/linux_common X-SVN-Group: stable-11 X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in stable/11: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/compat/linux sys/i386/linux sys/modules/linux_common X-SVN-Commit-Revision: 346827 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 92F6193A68 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2019 13:40:20 -0000 Author: dchagin Date: Sun Apr 28 13:40:17 2019 New Revision: 346827 URL: https://svnweb.freebsd.org/changeset/base/346827 Log: MFC r331356 (by emaste@): Share Linux errno table with libsysdecode. Added: stable/11/sys/compat/linux/linux_errno.inc - copied unchanged from r331356, head/sys/compat/linux/linux_errno.inc Modified: stable/11/lib/libsysdecode/errno.c stable/11/sys/amd64/linux/linux_sysvec.c stable/11/sys/amd64/linux32/linux32_sysvec.c stable/11/sys/compat/linux/linux_emul.h stable/11/sys/compat/linux/linux_errno.c stable/11/sys/i386/linux/linux_sysvec.c stable/11/sys/modules/linux_common/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libsysdecode/errno.c ============================================================================== --- stable/11/lib/libsysdecode/errno.c Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/lib/libsysdecode/errno.c Sun Apr 28 13:40:17 2019 (r346827) @@ -37,25 +37,8 @@ __FBSDID("$FreeBSD$"); #include #if defined(__i386__) || defined(__amd64__) -/* - * Linux syscalls return negative errno's, we do positive and map them - * Reference: - * FreeBSD: src/sys/sys/errno.h - * Linux: include/uapi/asm-generic/errno-base.h - * include/uapi/asm-generic/errno.h - */ -static int bsd_to_linux_errno[ELAST + 1] = { - -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, - -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, - -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, - -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, - -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, - -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, - -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, - -72, -67, -71, -1, -1, -131, -130 -}; +static +#include #endif #if defined(__aarch64__) || defined(__amd64__) @@ -158,8 +141,8 @@ sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, * This is imprecise since it returns the first * matching errno. */ - for (i = 0; i < nitems(bsd_to_linux_errno); i++) { - if (error == bsd_to_linux_errno[i]) + for (i = 0; i < nitems(linux_errtbl); i++) { + if (error == linux_errtbl[i]) return (i); } break; @@ -190,7 +173,7 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi, case SYSDECODE_ABI_LINUX: case SYSDECODE_ABI_LINUX32: if (error >= 0 && error <= ELAST) - return (bsd_to_linux_errno[error]); + return (linux_errtbl[error]); break; #endif #if defined(__aarch64__) || defined(__amd64__) Modified: stable/11/sys/amd64/linux/linux_sysvec.c ============================================================================== --- stable/11/sys/amd64/linux/linux_sysvec.c Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/sys/amd64/linux/linux_sysvec.c Sun Apr 28 13:40:17 2019 (r346827) @@ -751,7 +751,7 @@ struct sysentvec elf_linux_sysvec = { .sv_table = linux_sysent, .sv_mask = 0, .sv_errsize = ELAST + 1, - .sv_errtbl = bsd_to_linux_errno_generic, + .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup_elf, .sv_sendsig = linux_rt_sendsig, Modified: stable/11/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- stable/11/sys/amd64/linux32/linux32_sysvec.c Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/sys/amd64/linux32/linux32_sysvec.c Sun Apr 28 13:40:17 2019 (r346827) @@ -952,7 +952,7 @@ struct sysentvec elf_linux_sysvec = { .sv_table = linux32_sysent, .sv_mask = 0, .sv_errsize = ELAST + 1, - .sv_errtbl = bsd_to_linux_errno_generic, + .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup_elf, .sv_sendsig = linux_sendsig, Modified: stable/11/sys/compat/linux/linux_emul.h ============================================================================== --- stable/11/sys/compat/linux/linux_emul.h Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/sys/compat/linux/linux_emul.h Sun Apr 28 13:40:17 2019 (r346827) @@ -77,6 +77,6 @@ struct linux_pemuldata { struct linux_pemuldata *pem_find(struct proc *); -extern const int bsd_to_linux_errno_generic[]; +extern const int linux_errtbl[]; #endif /* !_LINUX_EMUL_H_ */ Modified: stable/11/sys/compat/linux/linux_errno.c ============================================================================== --- stable/11/sys/compat/linux/linux_errno.c Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/sys/compat/linux/linux_errno.c Sun Apr 28 13:40:17 2019 (r346827) @@ -1,151 +1,6 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1994-1996 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ +/* $FreeBSD$ */ #include #include -/* - * Linux syscalls return negative errno's, we do positive and map them - * Reference: - * FreeBSD: src/sys/sys/errno.h - * Linux: include/uapi/asm-generic/errno-base.h - * include/uapi/asm-generic/errno.h - */ -const int bsd_to_linux_errno_generic[ELAST + 1] = { - -0, - -1, - -2, - -3, - -4, - -5, - -6, - -7, - -8, - -9, - - -10, - -35, /* EDEADLK */ - -12, - -13, - -14, - -15, - -16, - -17, - -18, - -19, - - -20, - -21, - -22, - -23, - -24, - -25, - -26, - -27, - -28, - -29, - - -30, - -31, - -32, - -33, - -34, - -11, /* EAGAIN */ - -115, - -114, - -88, - -89, - - -90, - -91, - -92, - -93, - -94, - -95, - -96, - -97, - -98, - -99, - - -100, - -101, - -102, - -103, - -104, - -105, - -106, - -107, - -108, - -109, - - -110, - -111, - -40, - -36, - -112, - -113, - -39, - -11, - -87, - -122, - - -116, - -66, - -6, /* EBADRPC -> ENXIO */ - -6, /* ERPCMISMATCH -> ENXIO */ - -6, /* EPROGUNAVAIL -> ENXIO */ - -6, /* EPROGMISMATCH -> ENXIO */ - -6, /* EPROCUNAVAIL -> ENXIO */ - -37, - -38, - -9, - - -6, /* EAUTH -> ENXIO */ - -6, /* ENEEDAUTH -> ENXIO */ - -43, - -42, - -75, - -125, - -84, - -61, - -16, /* EDOOFUS -> EBUSY */ - -74, - - -72, - -67, - -71, - -1, /* ENOTCAPABLE -> EPERM */ - -1, /* ECAPMODE -> EPERM */ - -131, /* ENOTRECOVERABLE */ - -130, /* EOWNERDEAD */ -}; - -_Static_assert(ELAST == 96, - "missing errno entries in bsd_to_linux_errno_generic"); +#include Copied: stable/11/sys/compat/linux/linux_errno.inc (from r331356, head/sys/compat/linux/linux_errno.inc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/linux/linux_errno.inc Sun Apr 28 13:40:17 2019 (r346827, copy of r331356, head/sys/compat/linux/linux_errno.inc) @@ -0,0 +1,148 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 1994-1996 Søren Schmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Linux syscalls return negative errno's, we do positive and map them + * Reference: + * FreeBSD: src/sys/sys/errno.h + * Linux: include/uapi/asm-generic/errno-base.h + * include/uapi/asm-generic/errno.h + */ +const int linux_errtbl[ELAST + 1] = { + -0, + -1, + -2, + -3, + -4, + -5, + -6, + -7, + -8, + -9, + + -10, + -35, /* EDEADLK */ + -12, + -13, + -14, + -15, + -16, + -17, + -18, + -19, + + -20, + -21, + -22, + -23, + -24, + -25, + -26, + -27, + -28, + -29, + + -30, + -31, + -32, + -33, + -34, + -11, /* EAGAIN */ + -115, + -114, + -88, + -89, + + -90, + -91, + -92, + -93, + -94, + -95, + -96, + -97, + -98, + -99, + + -100, + -101, + -102, + -103, + -104, + -105, + -106, + -107, + -108, + -109, + + -110, + -111, + -40, + -36, + -112, + -113, + -39, + -11, + -87, + -122, + + -116, + -66, + -6, /* EBADRPC -> ENXIO */ + -6, /* ERPCMISMATCH -> ENXIO */ + -6, /* EPROGUNAVAIL -> ENXIO */ + -6, /* EPROGMISMATCH -> ENXIO */ + -6, /* EPROCUNAVAIL -> ENXIO */ + -37, + -38, + -9, + + -6, /* EAUTH -> ENXIO */ + -6, /* ENEEDAUTH -> ENXIO */ + -43, + -42, + -75, + -125, + -84, + -61, + -16, /* EDOOFUS -> EBUSY */ + -74, + + -72, + -67, + -71, + -1, /* ENOTCAPABLE -> EPERM */ + -1, /* ECAPMODE -> EPERM */ + -131, /* ENOTRECOVERABLE */ + -130, /* EOWNERDEAD */ +}; + +_Static_assert(ELAST == 96, + "missing errno entries in linux_errtbl"); Modified: stable/11/sys/i386/linux/linux_sysvec.c ============================================================================== --- stable/11/sys/i386/linux/linux_sysvec.c Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/sys/i386/linux/linux_sysvec.c Sun Apr 28 13:40:17 2019 (r346827) @@ -885,7 +885,7 @@ struct sysentvec linux_sysvec = { .sv_table = linux_sysent, .sv_mask = 0, .sv_errsize = ELAST + 1, - .sv_errtbl = bsd_to_linux_errno_generic, + .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup, .sv_sendsig = linux_sendsig, @@ -922,7 +922,7 @@ struct sysentvec elf_linux_sysvec = { .sv_table = linux_sysent, .sv_mask = 0, .sv_errsize = ELAST + 1, - .sv_errtbl = bsd_to_linux_errno_generic, + .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup_elf, .sv_sendsig = linux_sendsig, Modified: stable/11/sys/modules/linux_common/Makefile ============================================================================== --- stable/11/sys/modules/linux_common/Makefile Sun Apr 28 13:38:29 2019 (r346826) +++ stable/11/sys/modules/linux_common/Makefile Sun Apr 28 13:40:17 2019 (r346827) @@ -8,8 +8,8 @@ SRCS= linux_common.c linux_mib.c linux_mmap.c linux_ut linux.c opt_compat.h device_if.h vnode_if.h bus_if.h EXPORT_SYMS= -EXPORT_SYMS+= bsd_to_linux_errno_generic EXPORT_SYMS+= linux_emul_path +EXPORT_SYMS+= linux_errtbl EXPORT_SYMS+= linux_ioctl_register_handler EXPORT_SYMS+= linux_ioctl_unregister_handler EXPORT_SYMS+= linux_get_osname